Skip to content

Commit 46cf1ea

Browse files
committed
Auto merge of rust-lang#103344 - Dylan-DPC:rollup-d1rpfvx, r=Dylan-DPC
Rollup of 6 pull requests Successful merges: - rust-lang#102287 (Elaborate supertrait bounds when triggering `unused_must_use` on `impl Trait`) - rust-lang#102922 (Filtering spans when emitting json) - rust-lang#103051 (translation: doc comments with derives, subdiagnostic-less enum variants, more derive use) - rust-lang#103111 (Account for hygiene in typo suggestions, and use them to point to shadowed names) - rust-lang#103260 (Fixup a few tests needing asm support) - rust-lang#103321 (rustdoc: improve appearance of source page navigation bar) Failed merges: - rust-lang#103209 (Diagnostic derives: allow specifying multiple alternative suggestions) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 059e52b + 0569f56 commit 46cf1ea

9 files changed

+67
-137
lines changed

clippy_lints/src/manual_assert.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,13 @@ impl<'tcx> LateLintPass<'tcx> for ManualAssert {
6969
"only a `panic!` in `if`-then statement",
7070
|diag| {
7171
// comments can be noisy, do not show them to the user
72-
diag.tool_only_span_suggestion(
73-
expr.span.shrink_to_lo(),
74-
"add comments back",
75-
comments,
76-
applicability);
72+
if !comments.is_empty() {
73+
diag.tool_only_span_suggestion(
74+
expr.span.shrink_to_lo(),
75+
"add comments back",
76+
comments,
77+
applicability);
78+
}
7779
diag.span_suggestion(
7880
expr.span,
7981
"try instead",

clippy_lints/src/needless_late_init.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,13 @@ fn assignment_suggestions<'tcx>(
180180
let suggestions = assignments
181181
.iter()
182182
.flat_map(|assignment| {
183-
[
184-
assignment.span.until(assignment.rhs_span),
185-
assignment.rhs_span.shrink_to_hi().with_hi(assignment.span.hi()),
186-
]
183+
let mut spans = vec![assignment.span.until(assignment.rhs_span)];
184+
185+
if assignment.rhs_span.hi() != assignment.span.hi() {
186+
spans.push(assignment.rhs_span.shrink_to_hi().with_hi(assignment.span.hi()));
187+
}
188+
189+
spans
187190
})
188191
.map(|span| (span, String::new()))
189192
.collect::<Vec<(Span, String)>>();

tests/ui/entry.fixed

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// needs-asm-support
12
// run-rustfix
23

34
#![allow(unused, clippy::needless_pass_by_value, clippy::collapsible_if)]

tests/ui/entry.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// needs-asm-support
12
// run-rustfix
23

34
#![allow(unused, clippy::needless_pass_by_value, clippy::collapsible_if)]

tests/ui/entry.stderr

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: usage of `contains_key` followed by `insert` on a `HashMap`
2-
--> $DIR/entry.rs:24:5
2+
--> $DIR/entry.rs:25:5
33
|
44
LL | / if !m.contains_key(&k) {
55
LL | | m.insert(k, v);
@@ -9,7 +9,7 @@ LL | | }
99
= note: `-D clippy::map-entry` implied by `-D warnings`
1010

1111
error: usage of `contains_key` followed by `insert` on a `HashMap`
12-
--> $DIR/entry.rs:29:5
12+
--> $DIR/entry.rs:30:5
1313
|
1414
LL | / if !m.contains_key(&k) {
1515
LL | | if true {
@@ -32,7 +32,7 @@ LL + });
3232
|
3333

3434
error: usage of `contains_key` followed by `insert` on a `HashMap`
35-
--> $DIR/entry.rs:38:5
35+
--> $DIR/entry.rs:39:5
3636
|
3737
LL | / if !m.contains_key(&k) {
3838
LL | | if true {
@@ -55,7 +55,7 @@ LL + });
5555
|
5656

5757
error: usage of `contains_key` followed by `insert` on a `HashMap`
58-
--> $DIR/entry.rs:47:5
58+
--> $DIR/entry.rs:48:5
5959
|
6060
LL | / if !m.contains_key(&k) {
6161
LL | | if true {
@@ -79,7 +79,7 @@ LL + }
7979
|
8080

8181
error: usage of `contains_key` followed by `insert` on a `HashMap`
82-
--> $DIR/entry.rs:57:5
82+
--> $DIR/entry.rs:58:5
8383
|
8484
LL | / if !m.contains_key(&k) {
8585
LL | | foo();
@@ -96,7 +96,7 @@ LL + });
9696
|
9797

9898
error: usage of `contains_key` followed by `insert` on a `HashMap`
99-
--> $DIR/entry.rs:63:5
99+
--> $DIR/entry.rs:64:5
100100
|
101101
LL | / if !m.contains_key(&k) {
102102
LL | | match 0 {
@@ -122,7 +122,7 @@ LL + });
122122
|
123123

124124
error: usage of `contains_key` followed by `insert` on a `HashMap`
125-
--> $DIR/entry.rs:75:5
125+
--> $DIR/entry.rs:76:5
126126
|
127127
LL | / if !m.contains_key(&k) {
128128
LL | | match 0 {
@@ -146,7 +146,7 @@ LL + }
146146
|
147147

148148
error: usage of `contains_key` followed by `insert` on a `HashMap`
149-
--> $DIR/entry.rs:85:5
149+
--> $DIR/entry.rs:86:5
150150
|
151151
LL | / if !m.contains_key(&k) {
152152
LL | | foo();
@@ -187,15 +187,15 @@ LL + });
187187
|
188188

189189
error: usage of `contains_key` followed by `insert` on a `HashMap`
190-
--> $DIR/entry.rs:119:5
190+
--> $DIR/entry.rs:120:5
191191
|
192192
LL | / if !m.contains_key(&m!(k)) {
193193
LL | | m.insert(m!(k), m!(v));
194194
LL | | }
195195
| |_____^ help: try this: `m.entry(m!(k)).or_insert_with(|| m!(v));`
196196

197197
error: usage of `contains_key` followed by `insert` on a `HashMap`
198-
--> $DIR/entry.rs:151:5
198+
--> $DIR/entry.rs:152:5
199199
|
200200
LL | / if !m.contains_key(&k) {
201201
LL | | let x = (String::new(), String::new());

tests/ui/manual_assert.edition2018.stderr

+8-47
Original file line numberDiff line numberDiff line change
@@ -4,104 +4,65 @@ error: only a `panic!` in `if`-then statement
44
LL | / if !a.is_empty() {
55
LL | | panic!("qaqaq{:?}", a);
66
LL | | }
7-
| |_____^
7+
| |_____^ help: try instead: `assert!(a.is_empty(), "qaqaq{:?}", a);`
88
|
99
= note: `-D clippy::manual-assert` implied by `-D warnings`
10-
help: try instead
11-
|
12-
LL | assert!(a.is_empty(), "qaqaq{:?}", a);
13-
|
1410

1511
error: only a `panic!` in `if`-then statement
1612
--> $DIR/manual_assert.rs:34:5
1713
|
1814
LL | / if !a.is_empty() {
1915
LL | | panic!("qwqwq");
2016
LL | | }
21-
| |_____^
22-
|
23-
help: try instead
24-
|
25-
LL | assert!(a.is_empty(), "qwqwq");
26-
|
17+
| |_____^ help: try instead: `assert!(a.is_empty(), "qwqwq");`
2718

2819
error: only a `panic!` in `if`-then statement
2920
--> $DIR/manual_assert.rs:51:5
3021
|
3122
LL | / if b.is_empty() {
3223
LL | | panic!("panic1");
3324
LL | | }
34-
| |_____^
35-
|
36-
help: try instead
37-
|
38-
LL | assert!(!b.is_empty(), "panic1");
39-
|
25+
| |_____^ help: try instead: `assert!(!b.is_empty(), "panic1");`
4026

4127
error: only a `panic!` in `if`-then statement
4228
--> $DIR/manual_assert.rs:54:5
4329
|
4430
LL | / if b.is_empty() && a.is_empty() {
4531
LL | | panic!("panic2");
4632
LL | | }
47-
| |_____^
48-
|
49-
help: try instead
50-
|
51-
LL | assert!(!(b.is_empty() && a.is_empty()), "panic2");
52-
|
33+
| |_____^ help: try instead: `assert!(!(b.is_empty() && a.is_empty()), "panic2");`
5334

5435
error: only a `panic!` in `if`-then statement
5536
--> $DIR/manual_assert.rs:57:5
5637
|
5738
LL | / if a.is_empty() && !b.is_empty() {
5839
LL | | panic!("panic3");
5940
LL | | }
60-
| |_____^
61-
|
62-
help: try instead
63-
|
64-
LL | assert!(!(a.is_empty() && !b.is_empty()), "panic3");
65-
|
41+
| |_____^ help: try instead: `assert!(!(a.is_empty() && !b.is_empty()), "panic3");`
6642

6743
error: only a `panic!` in `if`-then statement
6844
--> $DIR/manual_assert.rs:60:5
6945
|
7046
LL | / if b.is_empty() || a.is_empty() {
7147
LL | | panic!("panic4");
7248
LL | | }
73-
| |_____^
74-
|
75-
help: try instead
76-
|
77-
LL | assert!(!(b.is_empty() || a.is_empty()), "panic4");
78-
|
49+
| |_____^ help: try instead: `assert!(!(b.is_empty() || a.is_empty()), "panic4");`
7950

8051
error: only a `panic!` in `if`-then statement
8152
--> $DIR/manual_assert.rs:63:5
8253
|
8354
LL | / if a.is_empty() || !b.is_empty() {
8455
LL | | panic!("panic5");
8556
LL | | }
86-
| |_____^
87-
|
88-
help: try instead
89-
|
90-
LL | assert!(!(a.is_empty() || !b.is_empty()), "panic5");
91-
|
57+
| |_____^ help: try instead: `assert!(!(a.is_empty() || !b.is_empty()), "panic5");`
9258

9359
error: only a `panic!` in `if`-then statement
9460
--> $DIR/manual_assert.rs:66:5
9561
|
9662
LL | / if a.is_empty() {
9763
LL | | panic!("with expansion {}", one!())
9864
LL | | }
99-
| |_____^
100-
|
101-
help: try instead
102-
|
103-
LL | assert!(!a.is_empty(), "with expansion {}", one!());
104-
|
65+
| |_____^ help: try instead: `assert!(!a.is_empty(), "with expansion {}", one!());`
10566

10667
error: only a `panic!` in `if`-then statement
10768
--> $DIR/manual_assert.rs:73:5

tests/ui/manual_assert.edition2021.stderr

+8-47
Original file line numberDiff line numberDiff line change
@@ -4,104 +4,65 @@ error: only a `panic!` in `if`-then statement
44
LL | / if !a.is_empty() {
55
LL | | panic!("qaqaq{:?}", a);
66
LL | | }
7-
| |_____^
7+
| |_____^ help: try instead: `assert!(a.is_empty(), "qaqaq{:?}", a);`
88
|
99
= note: `-D clippy::manual-assert` implied by `-D warnings`
10-
help: try instead
11-
|
12-
LL | assert!(a.is_empty(), "qaqaq{:?}", a);
13-
|
1410

1511
error: only a `panic!` in `if`-then statement
1612
--> $DIR/manual_assert.rs:34:5
1713
|
1814
LL | / if !a.is_empty() {
1915
LL | | panic!("qwqwq");
2016
LL | | }
21-
| |_____^
22-
|
23-
help: try instead
24-
|
25-
LL | assert!(a.is_empty(), "qwqwq");
26-
|
17+
| |_____^ help: try instead: `assert!(a.is_empty(), "qwqwq");`
2718

2819
error: only a `panic!` in `if`-then statement
2920
--> $DIR/manual_assert.rs:51:5
3021
|
3122
LL | / if b.is_empty() {
3223
LL | | panic!("panic1");
3324
LL | | }
34-
| |_____^
35-
|
36-
help: try instead
37-
|
38-
LL | assert!(!b.is_empty(), "panic1");
39-
|
25+
| |_____^ help: try instead: `assert!(!b.is_empty(), "panic1");`
4026

4127
error: only a `panic!` in `if`-then statement
4228
--> $DIR/manual_assert.rs:54:5
4329
|
4430
LL | / if b.is_empty() && a.is_empty() {
4531
LL | | panic!("panic2");
4632
LL | | }
47-
| |_____^
48-
|
49-
help: try instead
50-
|
51-
LL | assert!(!(b.is_empty() && a.is_empty()), "panic2");
52-
|
33+
| |_____^ help: try instead: `assert!(!(b.is_empty() && a.is_empty()), "panic2");`
5334

5435
error: only a `panic!` in `if`-then statement
5536
--> $DIR/manual_assert.rs:57:5
5637
|
5738
LL | / if a.is_empty() && !b.is_empty() {
5839
LL | | panic!("panic3");
5940
LL | | }
60-
| |_____^
61-
|
62-
help: try instead
63-
|
64-
LL | assert!(!(a.is_empty() && !b.is_empty()), "panic3");
65-
|
41+
| |_____^ help: try instead: `assert!(!(a.is_empty() && !b.is_empty()), "panic3");`
6642

6743
error: only a `panic!` in `if`-then statement
6844
--> $DIR/manual_assert.rs:60:5
6945
|
7046
LL | / if b.is_empty() || a.is_empty() {
7147
LL | | panic!("panic4");
7248
LL | | }
73-
| |_____^
74-
|
75-
help: try instead
76-
|
77-
LL | assert!(!(b.is_empty() || a.is_empty()), "panic4");
78-
|
49+
| |_____^ help: try instead: `assert!(!(b.is_empty() || a.is_empty()), "panic4");`
7950

8051
error: only a `panic!` in `if`-then statement
8152
--> $DIR/manual_assert.rs:63:5
8253
|
8354
LL | / if a.is_empty() || !b.is_empty() {
8455
LL | | panic!("panic5");
8556
LL | | }
86-
| |_____^
87-
|
88-
help: try instead
89-
|
90-
LL | assert!(!(a.is_empty() || !b.is_empty()), "panic5");
91-
|
57+
| |_____^ help: try instead: `assert!(!(a.is_empty() || !b.is_empty()), "panic5");`
9258

9359
error: only a `panic!` in `if`-then statement
9460
--> $DIR/manual_assert.rs:66:5
9561
|
9662
LL | / if a.is_empty() {
9763
LL | | panic!("with expansion {}", one!())
9864
LL | | }
99-
| |_____^
100-
|
101-
help: try instead
102-
|
103-
LL | assert!(!a.is_empty(), "with expansion {}", one!());
104-
|
65+
| |_____^ help: try instead: `assert!(!a.is_empty(), "with expansion {}", one!());`
10566

10667
error: only a `panic!` in `if`-then statement
10768
--> $DIR/manual_assert.rs:73:5

tests/ui/missing_doc.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// needs-asm-support
12
// aux-build: proc_macro_with_span.rs
23

34
#![warn(clippy::missing_docs_in_private_items)]

0 commit comments

Comments
 (0)