Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8bb913d

Browse files
authoredSep 12, 2022
Rollup merge of rust-lang#101700 - compiler-errors:deletion-span, r=davidtwco
A `SubstitutionPart` is not considered a deletion if it replaces nothing with nothing Fixes rust-lang#101689
2 parents b9775e8 + 3bf33c3 commit 8bb913d

21 files changed

+163
-221
lines changed
 

‎compiler/rustc_errors/src/emitter.rs

+20-10
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,10 @@ pub trait Emitter: Translate {
268268
SuggestionStyle::ShowAlways,
269269
].contains(&sugg.style)
270270
{
271-
let substitution = &sugg.substitutions[0].parts[0].snippet.trim();
271+
// Don't trim the substitution if it's only whitespace changes
272+
let substitution = &sugg.substitutions[0].parts[0].snippet;
273+
let substitution =
274+
if substitution.trim().is_empty() { substitution } else { substitution.trim() };
272275
let msg = if substitution.is_empty() || sugg.style.hide_inline() {
273276
// This substitution is only removal OR we explicitly don't want to show the
274277
// code inline (`hide_inline`). Therefore, we don't show the substitution.
@@ -1704,7 +1707,7 @@ impl EmitterWriter {
17041707
{
17051708
notice_capitalization |= only_capitalization;
17061709

1707-
let has_deletion = parts.iter().any(|p| p.is_deletion());
1710+
let has_deletion = parts.iter().any(|p| p.is_deletion(sm));
17081711
let is_multiline = complete.lines().count() > 1;
17091712

17101713
if let Some(span) = span.primary_span() {
@@ -1880,16 +1883,23 @@ impl EmitterWriter {
18801883
let span_start_pos = sm.lookup_char_pos(part.span.lo()).col_display;
18811884
let span_end_pos = sm.lookup_char_pos(part.span.hi()).col_display;
18821885

1886+
// If this addition is _only_ whitespace, then don't trim it,
1887+
// or else we're just not rendering anything.
1888+
let is_whitespace_addition = part.snippet.trim().is_empty();
1889+
18831890
// Do not underline the leading...
1884-
let start = part.snippet.len().saturating_sub(part.snippet.trim_start().len());
1891+
let start = if is_whitespace_addition {
1892+
0
1893+
} else {
1894+
part.snippet.len().saturating_sub(part.snippet.trim_start().len())
1895+
};
18851896
// ...or trailing spaces. Account for substitutions containing unicode
18861897
// characters.
1887-
let sub_len: usize = part
1888-
.snippet
1889-
.trim()
1890-
.chars()
1891-
.map(|ch| unicode_width::UnicodeWidthChar::width(ch).unwrap_or(1))
1892-
.sum();
1898+
let sub_len: usize =
1899+
if is_whitespace_addition { &part.snippet } else { part.snippet.trim() }
1900+
.chars()
1901+
.map(|ch| unicode_width::UnicodeWidthChar::width(ch).unwrap_or(1))
1902+
.sum();
18931903

18941904
let offset: isize = offsets
18951905
.iter()
@@ -2130,7 +2140,7 @@ impl EmitterWriter {
21302140
}
21312141
}
21322142

2133-
#[derive(Clone, Copy)]
2143+
#[derive(Clone, Copy, Debug)]
21342144
enum DisplaySuggestion {
21352145
Underline,
21362146
Diff,

‎compiler/rustc_errors/src/lib.rs

+9-10
Original file line numberDiff line numberDiff line change
@@ -150,21 +150,20 @@ pub struct SubstitutionHighlight {
150150

151151
impl SubstitutionPart {
152152
pub fn is_addition(&self, sm: &SourceMap) -> bool {
153-
!self.snippet.is_empty()
154-
&& sm
155-
.span_to_snippet(self.span)
156-
.map_or(self.span.is_empty(), |snippet| snippet.trim().is_empty())
153+
!self.snippet.is_empty() && !self.replaces_meaningful_content(sm)
157154
}
158155

159-
pub fn is_deletion(&self) -> bool {
160-
self.snippet.trim().is_empty()
156+
pub fn is_deletion(&self, sm: &SourceMap) -> bool {
157+
self.snippet.trim().is_empty() && self.replaces_meaningful_content(sm)
161158
}
162159

163160
pub fn is_replacement(&self, sm: &SourceMap) -> bool {
164-
!self.snippet.is_empty()
165-
&& sm
166-
.span_to_snippet(self.span)
167-
.map_or(!self.span.is_empty(), |snippet| !snippet.trim().is_empty())
161+
!self.snippet.is_empty() && self.replaces_meaningful_content(sm)
162+
}
163+
164+
fn replaces_meaningful_content(&self, sm: &SourceMap) -> bool {
165+
sm.span_to_snippet(self.span)
166+
.map_or(!self.span.is_empty(), |snippet| !snippet.trim().is_empty())
168167
}
169168
}
170169

‎src/test/ui/dyn-keyword/dyn-2018-edition-lint.stderr

+14-21
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ LL | #[deny(bare_trait_objects)]
1313
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
1414
help: use `dyn`
1515
|
16-
LL - fn function(x: &SomeTrait, y: Box<SomeTrait>) {
17-
LL + fn function(x: &dyn SomeTrait, y: Box<SomeTrait>) {
18-
|
16+
LL | fn function(x: &dyn SomeTrait, y: Box<SomeTrait>) {
17+
| +++
1918

2019
error: trait objects without an explicit `dyn` are deprecated
2120
--> $DIR/dyn-2018-edition-lint.rs:4:35
@@ -27,9 +26,8 @@ LL | fn function(x: &SomeTrait, y: Box<SomeTrait>) {
2726
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
2827
help: use `dyn`
2928
|
30-
LL - fn function(x: &SomeTrait, y: Box<SomeTrait>) {
31-
LL + fn function(x: &SomeTrait, y: Box<dyn SomeTrait>) {
32-
|
29+
LL | fn function(x: &SomeTrait, y: Box<dyn SomeTrait>) {
30+
| +++
3331

3432
error: trait objects without an explicit `dyn` are deprecated
3533
--> $DIR/dyn-2018-edition-lint.rs:17:14
@@ -41,9 +39,8 @@ LL | let _x: &SomeTrait = todo!();
4139
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
4240
help: use `dyn`
4341
|
44-
LL - let _x: &SomeTrait = todo!();
45-
LL + let _x: &dyn SomeTrait = todo!();
46-
|
42+
LL | let _x: &dyn SomeTrait = todo!();
43+
| +++
4744

4845
error: trait objects without an explicit `dyn` are deprecated
4946
--> $DIR/dyn-2018-edition-lint.rs:4:17
@@ -55,9 +52,8 @@ LL | fn function(x: &SomeTrait, y: Box<SomeTrait>) {
5552
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
5653
help: use `dyn`
5754
|
58-
LL - fn function(x: &SomeTrait, y: Box<SomeTrait>) {
59-
LL + fn function(x: &dyn SomeTrait, y: Box<SomeTrait>) {
60-
|
55+
LL | fn function(x: &dyn SomeTrait, y: Box<SomeTrait>) {
56+
| +++
6157

6258
error: trait objects without an explicit `dyn` are deprecated
6359
--> $DIR/dyn-2018-edition-lint.rs:4:17
@@ -69,9 +65,8 @@ LL | fn function(x: &SomeTrait, y: Box<SomeTrait>) {
6965
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
7066
help: use `dyn`
7167
|
72-
LL - fn function(x: &SomeTrait, y: Box<SomeTrait>) {
73-
LL + fn function(x: &dyn SomeTrait, y: Box<SomeTrait>) {
74-
|
68+
LL | fn function(x: &dyn SomeTrait, y: Box<SomeTrait>) {
69+
| +++
7570

7671
error: trait objects without an explicit `dyn` are deprecated
7772
--> $DIR/dyn-2018-edition-lint.rs:4:35
@@ -83,9 +78,8 @@ LL | fn function(x: &SomeTrait, y: Box<SomeTrait>) {
8378
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
8479
help: use `dyn`
8580
|
86-
LL - fn function(x: &SomeTrait, y: Box<SomeTrait>) {
87-
LL + fn function(x: &SomeTrait, y: Box<dyn SomeTrait>) {
88-
|
81+
LL | fn function(x: &SomeTrait, y: Box<dyn SomeTrait>) {
82+
| +++
8983

9084
error: trait objects without an explicit `dyn` are deprecated
9185
--> $DIR/dyn-2018-edition-lint.rs:4:35
@@ -97,9 +91,8 @@ LL | fn function(x: &SomeTrait, y: Box<SomeTrait>) {
9791
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
9892
help: use `dyn`
9993
|
100-
LL - fn function(x: &SomeTrait, y: Box<SomeTrait>) {
101-
LL + fn function(x: &SomeTrait, y: Box<dyn SomeTrait>) {
102-
|
94+
LL | fn function(x: &SomeTrait, y: Box<dyn SomeTrait>) {
95+
| +++
10396

10497
error: aborting due to 7 previous errors
10598

‎src/test/ui/dyn-keyword/dyn-2021-edition-error.stderr

+4-6
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ LL | fn function(x: &SomeTrait, y: Box<SomeTrait>) {
66
|
77
help: add `dyn` keyword before this trait
88
|
9-
LL - fn function(x: &SomeTrait, y: Box<SomeTrait>) {
10-
LL + fn function(x: &dyn SomeTrait, y: Box<SomeTrait>) {
11-
|
9+
LL | fn function(x: &dyn SomeTrait, y: Box<SomeTrait>) {
10+
| +++
1211

1312
error[E0782]: trait objects must include the `dyn` keyword
1413
--> $DIR/dyn-2021-edition-error.rs:3:35
@@ -18,9 +17,8 @@ LL | fn function(x: &SomeTrait, y: Box<SomeTrait>) {
1817
|
1918
help: add `dyn` keyword before this trait
2019
|
21-
LL - fn function(x: &SomeTrait, y: Box<SomeTrait>) {
22-
LL + fn function(x: &SomeTrait, y: Box<dyn SomeTrait>) {
23-
|
20+
LL | fn function(x: &SomeTrait, y: Box<dyn SomeTrait>) {
21+
| +++
2422

2523
error: aborting due to 2 previous errors
2624

‎src/test/ui/dyn-keyword/dyn-angle-brackets.stderr

+2-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ LL | #![deny(bare_trait_objects)]
1313
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
1414
help: use `dyn`
1515
|
16-
LL - <fmt::Debug>::fmt(self, f)
17-
LL + <dyn fmt::Debug>::fmt(self, f)
18-
|
16+
LL | <dyn fmt::Debug>::fmt(self, f)
17+
| +++
1918

2019
error: aborting due to previous error
2120

‎src/test/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.edition2021.stderr

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ LL | fn ice() -> impl AsRef<Fn(&())> {
66
|
77
help: add `dyn` keyword before this trait
88
|
9-
LL - fn ice() -> impl AsRef<Fn(&())> {
10-
LL + fn ice() -> impl AsRef<dyn Fn(&())> {
11-
|
9+
LL | fn ice() -> impl AsRef<dyn Fn(&())> {
10+
| +++
1211

1312
error[E0277]: the trait bound `(): AsRef<(dyn for<'r> Fn(&'r ()) + 'static)>` is not satisfied
1413
--> $DIR/generic-with-implicit-hrtb-without-dyn.rs:6:13

‎src/test/ui/issues/issue-86756.stderr

+2-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ LL | eq::<dyn, Foo>
2525
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
2626
help: use `dyn`
2727
|
28-
LL - eq::<dyn, Foo>
29-
LL + eq::<dyn, dyn Foo>
30-
|
28+
LL | eq::<dyn, dyn Foo>
29+
| +++
3130

3231
error[E0107]: missing generics for trait `Foo`
3332
--> $DIR/issue-86756.rs:5:15

‎src/test/ui/lint/force-warn/allowed-group-warn-by-default-lint.stderr

+6-9
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
99
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
1010
help: use `dyn`
1111
|
12-
LL - pub fn function(_x: Box<SomeTrait>) {}
13-
LL + pub fn function(_x: Box<dyn SomeTrait>) {}
14-
|
12+
LL | pub fn function(_x: Box<dyn SomeTrait>) {}
13+
| +++
1514

1615
warning: trait objects without an explicit `dyn` are deprecated
1716
--> $DIR/allowed-group-warn-by-default-lint.rs:10:25
@@ -23,9 +22,8 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
2322
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
2423
help: use `dyn`
2524
|
26-
LL - pub fn function(_x: Box<SomeTrait>) {}
27-
LL + pub fn function(_x: Box<dyn SomeTrait>) {}
28-
|
25+
LL | pub fn function(_x: Box<dyn SomeTrait>) {}
26+
| +++
2927

3028
warning: trait objects without an explicit `dyn` are deprecated
3129
--> $DIR/allowed-group-warn-by-default-lint.rs:10:25
@@ -37,9 +35,8 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
3735
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
3836
help: use `dyn`
3937
|
40-
LL - pub fn function(_x: Box<SomeTrait>) {}
41-
LL + pub fn function(_x: Box<dyn SomeTrait>) {}
42-
|
38+
LL | pub fn function(_x: Box<dyn SomeTrait>) {}
39+
| +++
4340

4441
warning: 3 warnings emitted
4542

‎src/test/ui/lint/force-warn/cap-lints-allow.stderr

+6-9
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
99
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
1010
help: use `dyn`
1111
|
12-
LL - pub fn function(_x: Box<SomeTrait>) {}
13-
LL + pub fn function(_x: Box<dyn SomeTrait>) {}
14-
|
12+
LL | pub fn function(_x: Box<dyn SomeTrait>) {}
13+
| +++
1514

1615
warning: trait objects without an explicit `dyn` are deprecated
1716
--> $DIR/cap-lints-allow.rs:8:25
@@ -23,9 +22,8 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
2322
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
2423
help: use `dyn`
2524
|
26-
LL - pub fn function(_x: Box<SomeTrait>) {}
27-
LL + pub fn function(_x: Box<dyn SomeTrait>) {}
28-
|
25+
LL | pub fn function(_x: Box<dyn SomeTrait>) {}
26+
| +++
2927

3028
warning: trait objects without an explicit `dyn` are deprecated
3129
--> $DIR/cap-lints-allow.rs:8:25
@@ -37,9 +35,8 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
3735
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
3836
help: use `dyn`
3937
|
40-
LL - pub fn function(_x: Box<SomeTrait>) {}
41-
LL + pub fn function(_x: Box<dyn SomeTrait>) {}
42-
|
38+
LL | pub fn function(_x: Box<dyn SomeTrait>) {}
39+
| +++
4340

4441
warning: 3 warnings emitted
4542

‎src/test/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.stderr

+6-9
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
99
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
1010
help: use `dyn`
1111
|
12-
LL - pub fn function(_x: Box<SomeTrait>) {}
13-
LL + pub fn function(_x: Box<dyn SomeTrait>) {}
14-
|
12+
LL | pub fn function(_x: Box<dyn SomeTrait>) {}
13+
| +++
1514

1615
warning: trait objects without an explicit `dyn` are deprecated
1716
--> $DIR/lint-group-allowed-cli-warn-by-default-lint.rs:8:25
@@ -23,9 +22,8 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
2322
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
2423
help: use `dyn`
2524
|
26-
LL - pub fn function(_x: Box<SomeTrait>) {}
27-
LL + pub fn function(_x: Box<dyn SomeTrait>) {}
28-
|
25+
LL | pub fn function(_x: Box<dyn SomeTrait>) {}
26+
| +++
2927

3028
warning: trait objects without an explicit `dyn` are deprecated
3129
--> $DIR/lint-group-allowed-cli-warn-by-default-lint.rs:8:25
@@ -37,9 +35,8 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
3735
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
3836
help: use `dyn`
3937
|
40-
LL - pub fn function(_x: Box<SomeTrait>) {}
41-
LL + pub fn function(_x: Box<dyn SomeTrait>) {}
42-
|
38+
LL | pub fn function(_x: Box<dyn SomeTrait>) {}
39+
| +++
4340

4441
warning: 3 warnings emitted
4542

‎src/test/ui/lint/force-warn/lint-group-allowed-lint-group.stderr

+6-9
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
99
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
1010
help: use `dyn`
1111
|
12-
LL - pub fn function(_x: Box<SomeTrait>) {}
13-
LL + pub fn function(_x: Box<dyn SomeTrait>) {}
14-
|
12+
LL | pub fn function(_x: Box<dyn SomeTrait>) {}
13+
| +++
1514

1615
warning: trait objects without an explicit `dyn` are deprecated
1716
--> $DIR/lint-group-allowed-lint-group.rs:10:25
@@ -23,9 +22,8 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
2322
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
2423
help: use `dyn`
2524
|
26-
LL - pub fn function(_x: Box<SomeTrait>) {}
27-
LL + pub fn function(_x: Box<dyn SomeTrait>) {}
28-
|
25+
LL | pub fn function(_x: Box<dyn SomeTrait>) {}
26+
| +++
2927

3028
warning: trait objects without an explicit `dyn` are deprecated
3129
--> $DIR/lint-group-allowed-lint-group.rs:10:25
@@ -37,9 +35,8 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
3735
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
3836
help: use `dyn`
3937
|
40-
LL - pub fn function(_x: Box<SomeTrait>) {}
41-
LL + pub fn function(_x: Box<dyn SomeTrait>) {}
42-
|
38+
LL | pub fn function(_x: Box<dyn SomeTrait>) {}
39+
| +++
4340

4441
warning: 3 warnings emitted
4542

‎src/test/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.stderr

+6-9
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
99
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
1010
help: use `dyn`
1111
|
12-
LL - pub fn function(_x: Box<SomeTrait>) {}
13-
LL + pub fn function(_x: Box<dyn SomeTrait>) {}
14-
|
12+
LL | pub fn function(_x: Box<dyn SomeTrait>) {}
13+
| +++
1514

1615
warning: trait objects without an explicit `dyn` are deprecated
1716
--> $DIR/lint-group-allowed-warn-by-default-lint.rs:10:25
@@ -23,9 +22,8 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
2322
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
2423
help: use `dyn`
2524
|
26-
LL - pub fn function(_x: Box<SomeTrait>) {}
27-
LL + pub fn function(_x: Box<dyn SomeTrait>) {}
28-
|
25+
LL | pub fn function(_x: Box<dyn SomeTrait>) {}
26+
| +++
2927

3028
warning: trait objects without an explicit `dyn` are deprecated
3129
--> $DIR/lint-group-allowed-warn-by-default-lint.rs:10:25
@@ -37,9 +35,8 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
3735
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
3836
help: use `dyn`
3937
|
40-
LL - pub fn function(_x: Box<SomeTrait>) {}
41-
LL + pub fn function(_x: Box<dyn SomeTrait>) {}
42-
|
38+
LL | pub fn function(_x: Box<dyn SomeTrait>) {}
39+
| +++
4340

4441
warning: 3 warnings emitted
4542

‎src/test/ui/parser/increment-notfixed.stderr

+12-18
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ help: use `+= 1` instead
88
|
99
LL | { let tmp = i; i += 1; tmp };
1010
| +++++++++++ ~~~~~~~~~~~~~~~
11-
LL - i++;
12-
LL + i += 1;
13-
|
11+
LL | i += 1;
12+
| ~~~~
1413

1514
error: Rust has no postfix increment operator
1615
--> $DIR/increment-notfixed.rs:17:12
@@ -24,9 +23,8 @@ help: use `+= 1` instead
2423
|
2524
LL | while { let tmp = i; i += 1; tmp } < 5 {
2625
| +++++++++++ ~~~~~~~~~~~~~~~
27-
LL - while i++ < 5 {
28-
LL + while i += 1 < 5 {
29-
|
26+
LL | while i += 1 < 5 {
27+
| ~~~~
3028

3129
error: Rust has no postfix increment operator
3230
--> $DIR/increment-notfixed.rs:25:8
@@ -38,9 +36,8 @@ help: use `+= 1` instead
3836
|
3937
LL | { let tmp_ = tmp; tmp += 1; tmp_ };
4038
| ++++++++++++ ~~~~~~~~~~~~~~~~~~
41-
LL - tmp++;
42-
LL + tmp += 1;
43-
|
39+
LL | tmp += 1;
40+
| ~~~~
4441

4542
error: Rust has no postfix increment operator
4643
--> $DIR/increment-notfixed.rs:31:14
@@ -54,9 +51,8 @@ help: use `+= 1` instead
5451
|
5552
LL | while { let tmp_ = tmp; tmp += 1; tmp_ } < 5 {
5653
| ++++++++++++ ~~~~~~~~~~~~~~~~~~
57-
LL - while tmp++ < 5 {
58-
LL + while tmp += 1 < 5 {
59-
|
54+
LL | while tmp += 1 < 5 {
55+
| ~~~~
6056

6157
error: Rust has no postfix increment operator
6258
--> $DIR/increment-notfixed.rs:39:16
@@ -68,9 +64,8 @@ help: use `+= 1` instead
6864
|
6965
LL | { let tmp = foo.bar.qux; foo.bar.qux += 1; tmp };
7066
| +++++++++++ ~~~~~~~~~~~~~~~~~~~~~~~~~
71-
LL - foo.bar.qux++;
72-
LL + foo.bar.qux += 1;
73-
|
67+
LL | foo.bar.qux += 1;
68+
| ~~~~
7469

7570
error: Rust has no postfix increment operator
7671
--> $DIR/increment-notfixed.rs:49:10
@@ -82,9 +77,8 @@ help: use `+= 1` instead
8277
|
8378
LL | { let tmp = s.tmp; s.tmp += 1; tmp };
8479
| +++++++++++ ~~~~~~~~~~~~~~~~~~~
85-
LL - s.tmp++;
86-
LL + s.tmp += 1;
87-
|
80+
LL | s.tmp += 1;
81+
| ~~~~
8882

8983
error: Rust has no prefix increment operator
9084
--> $DIR/increment-notfixed.rs:56:5

‎src/test/ui/parser/trait-object-trait-parens.stderr

+6-9
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ LL | let _: Box<(Obj) + (?Sized) + (for<'a> Trait<'a>)>;
2727
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
2828
help: use `dyn`
2929
|
30-
LL - let _: Box<(Obj) + (?Sized) + (for<'a> Trait<'a>)>;
31-
LL + let _: Box<dyn (Obj) + (?Sized) + (for<'a> Trait<'a>)>;
32-
|
30+
LL | let _: Box<dyn (Obj) + (?Sized) + (for<'a> Trait<'a>)>;
31+
| +++
3332

3433
error[E0225]: only auto traits can be used as additional traits in a trait object
3534
--> $DIR/trait-object-trait-parens.rs:8:35
@@ -52,9 +51,8 @@ LL | let _: Box<?Sized + (for<'a> Trait<'a>) + (Obj)>;
5251
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
5352
help: use `dyn`
5453
|
55-
LL - let _: Box<?Sized + (for<'a> Trait<'a>) + (Obj)>;
56-
LL + let _: Box<dyn ?Sized + (for<'a> Trait<'a>) + (Obj)>;
57-
|
54+
LL | let _: Box<dyn ?Sized + (for<'a> Trait<'a>) + (Obj)>;
55+
| +++
5856

5957
error[E0225]: only auto traits can be used as additional traits in a trait object
6058
--> $DIR/trait-object-trait-parens.rs:13:47
@@ -77,9 +75,8 @@ LL | let _: Box<for<'a> Trait<'a> + (Obj) + (?Sized)>;
7775
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
7876
help: use `dyn`
7977
|
80-
LL - let _: Box<for<'a> Trait<'a> + (Obj) + (?Sized)>;
81-
LL + let _: Box<dyn for<'a> Trait<'a> + (Obj) + (?Sized)>;
82-
|
78+
LL | let _: Box<dyn for<'a> Trait<'a> + (Obj) + (?Sized)>;
79+
| +++
8380

8481
error[E0225]: only auto traits can be used as additional traits in a trait object
8582
--> $DIR/trait-object-trait-parens.rs:18:36

‎src/test/ui/rust-2021/reserved-prefixes-migration.stderr

+10-15
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ LL | #![warn(rust_2021_prefixes_incompatible_syntax)]
1313
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/reserving-syntax.html>
1414
help: insert whitespace here to avoid this being parsed as a prefix in Rust 2021
1515
|
16-
LL - m2!(z"hey");
17-
LL + m2!(z "hey");
18-
|
16+
LL | m2!(z "hey");
17+
| +
1918

2019
warning: prefix `prefix` is unknown
2120
--> $DIR/reserved-prefixes-migration.rs:19:9
@@ -27,9 +26,8 @@ LL | m2!(prefix"hey");
2726
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/reserving-syntax.html>
2827
help: insert whitespace here to avoid this being parsed as a prefix in Rust 2021
2928
|
30-
LL - m2!(prefix"hey");
31-
LL + m2!(prefix "hey");
32-
|
29+
LL | m2!(prefix "hey");
30+
| +
3331

3432
warning: prefix `hey` is unknown
3533
--> $DIR/reserved-prefixes-migration.rs:22:9
@@ -41,9 +39,8 @@ LL | m3!(hey#123);
4139
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/reserving-syntax.html>
4240
help: insert whitespace here to avoid this being parsed as a prefix in Rust 2021
4341
|
44-
LL - m3!(hey#123);
45-
LL + m3!(hey #123);
46-
|
42+
LL | m3!(hey #123);
43+
| +
4744

4845
warning: prefix `hey` is unknown
4946
--> $DIR/reserved-prefixes-migration.rs:25:9
@@ -55,9 +52,8 @@ LL | m3!(hey#hey);
5552
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/reserving-syntax.html>
5653
help: insert whitespace here to avoid this being parsed as a prefix in Rust 2021
5754
|
58-
LL - m3!(hey#hey);
59-
LL + m3!(hey #hey);
60-
|
55+
LL | m3!(hey #hey);
56+
| +
6157

6258
warning: prefix `kind` is unknown
6359
--> $DIR/reserved-prefixes-migration.rs:35:14
@@ -69,9 +65,8 @@ LL | #name = #kind#value
6965
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/reserving-syntax.html>
7066
help: insert whitespace here to avoid this being parsed as a prefix in Rust 2021
7167
|
72-
LL - #name = #kind#value
73-
LL + #name = #kind #value
74-
|
68+
LL | #name = #kind #value
69+
| +
7570

7671
warning: 5 warnings emitted
7772

‎src/test/ui/rust-2021/reserved-prefixes.stderr

+18-27
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ LL | demo3!(foo#bar);
77
= note: prefixed identifiers and literals are reserved since Rust 2021
88
help: consider inserting whitespace here
99
|
10-
LL - demo3!(foo#bar);
11-
LL + demo3!(foo #bar);
12-
|
10+
LL | demo3!(foo #bar);
11+
| +
1312

1413
error: prefix `foo` is unknown
1514
--> $DIR/reserved-prefixes.rs:17:12
@@ -20,9 +19,8 @@ LL | demo2!(foo"bar");
2019
= note: prefixed identifiers and literals are reserved since Rust 2021
2120
help: consider inserting whitespace here
2221
|
23-
LL - demo2!(foo"bar");
24-
LL + demo2!(foo "bar");
25-
|
22+
LL | demo2!(foo "bar");
23+
| +
2624

2725
error: prefix `foo` is unknown
2826
--> $DIR/reserved-prefixes.rs:18:12
@@ -33,9 +31,8 @@ LL | demo2!(foo'b');
3331
= note: prefixed identifiers and literals are reserved since Rust 2021
3432
help: consider inserting whitespace here
3533
|
36-
LL - demo2!(foo'b');
37-
LL + demo2!(foo 'b');
38-
|
34+
LL | demo2!(foo 'b');
35+
| +
3936

4037
error: prefix `foo` is unknown
4138
--> $DIR/reserved-prefixes.rs:20:12
@@ -46,9 +43,8 @@ LL | demo2!(foo'b);
4643
= note: prefixed identifiers and literals are reserved since Rust 2021
4744
help: consider inserting whitespace here
4845
|
49-
LL - demo2!(foo'b);
50-
LL + demo2!(foo 'b);
51-
|
46+
LL | demo2!(foo 'b);
47+
| +
5248

5349
error: prefix `foo` is unknown
5450
--> $DIR/reserved-prefixes.rs:21:12
@@ -59,9 +55,8 @@ LL | demo3!(foo# bar);
5955
= note: prefixed identifiers and literals are reserved since Rust 2021
6056
help: consider inserting whitespace here
6157
|
62-
LL - demo3!(foo# bar);
63-
LL + demo3!(foo # bar);
64-
|
58+
LL | demo3!(foo # bar);
59+
| +
6560

6661
error: prefix `foo` is unknown
6762
--> $DIR/reserved-prefixes.rs:22:12
@@ -72,9 +67,8 @@ LL | demo4!(foo#! bar);
7267
= note: prefixed identifiers and literals are reserved since Rust 2021
7368
help: consider inserting whitespace here
7469
|
75-
LL - demo4!(foo#! bar);
76-
LL + demo4!(foo #! bar);
77-
|
70+
LL | demo4!(foo #! bar);
71+
| +
7872

7973
error: prefix `foo` is unknown
8074
--> $DIR/reserved-prefixes.rs:23:12
@@ -85,9 +79,8 @@ LL | demo4!(foo## bar);
8579
= note: prefixed identifiers and literals are reserved since Rust 2021
8680
help: consider inserting whitespace here
8781
|
88-
LL - demo4!(foo## bar);
89-
LL + demo4!(foo ## bar);
90-
|
82+
LL | demo4!(foo ## bar);
83+
| +
9184

9285
error: prefix `foo` is unknown
9386
--> $DIR/reserved-prefixes.rs:25:12
@@ -98,9 +91,8 @@ LL | demo4!(foo#bar#);
9891
= note: prefixed identifiers and literals are reserved since Rust 2021
9992
help: consider inserting whitespace here
10093
|
101-
LL - demo4!(foo#bar#);
102-
LL + demo4!(foo #bar#);
103-
|
94+
LL | demo4!(foo #bar#);
95+
| +
10496

10597
error: prefix `bar` is unknown
10698
--> $DIR/reserved-prefixes.rs:25:16
@@ -111,9 +103,8 @@ LL | demo4!(foo#bar#);
111103
= note: prefixed identifiers and literals are reserved since Rust 2021
112104
help: consider inserting whitespace here
113105
|
114-
LL - demo4!(foo#bar#);
115-
LL + demo4!(foo#bar #);
116-
|
106+
LL | demo4!(foo#bar #);
107+
| +
117108

118109
error: aborting due to 9 previous errors
119110

‎src/test/ui/suggestions/issue-61963.stderr

+14-21
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ LL | #![deny(bare_trait_objects)]
1313
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
1414
help: use `dyn`
1515
|
16-
LL - bar: Box<Bar>,
17-
LL + bar: Box<dyn Bar>,
18-
|
16+
LL | bar: Box<dyn Bar>,
17+
| +++
1918

2019
error: trait objects without an explicit `dyn` are deprecated
2120
--> $DIR/issue-61963.rs:18:1
@@ -27,9 +26,8 @@ LL | pub struct Foo {
2726
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
2827
help: use `dyn`
2928
|
30-
LL - pub struct Foo {
31-
LL + dyn pub struct Foo {
32-
|
29+
LL | dyn pub struct Foo {
30+
| +++
3331

3432
error: trait objects without an explicit `dyn` are deprecated
3533
--> $DIR/issue-61963.rs:28:14
@@ -41,9 +39,8 @@ LL | bar: Box<Bar>,
4139
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
4240
help: use `dyn`
4341
|
44-
LL - bar: Box<Bar>,
45-
LL + bar: Box<dyn Bar>,
46-
|
42+
LL | bar: Box<dyn Bar>,
43+
| +++
4744

4845
error: trait objects without an explicit `dyn` are deprecated
4946
--> $DIR/issue-61963.rs:28:14
@@ -55,9 +52,8 @@ LL | bar: Box<Bar>,
5552
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
5653
help: use `dyn`
5754
|
58-
LL - bar: Box<Bar>,
59-
LL + bar: Box<dyn Bar>,
60-
|
55+
LL | bar: Box<dyn Bar>,
56+
| +++
6157

6258
error: trait objects without an explicit `dyn` are deprecated
6359
--> $DIR/issue-61963.rs:18:1
@@ -69,9 +65,8 @@ LL | pub struct Foo {
6965
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
7066
help: use `dyn`
7167
|
72-
LL - pub struct Foo {
73-
LL + dyn pub struct Foo {
74-
|
68+
LL | dyn pub struct Foo {
69+
| +++
7570

7671
error: trait objects without an explicit `dyn` are deprecated
7772
--> $DIR/issue-61963.rs:18:1
@@ -83,9 +78,8 @@ LL | pub struct Foo {
8378
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
8479
help: use `dyn`
8580
|
86-
LL - pub struct Foo {
87-
LL + dyn pub struct Foo {
88-
|
81+
LL | dyn pub struct Foo {
82+
| +++
8983

9084
error: trait objects without an explicit `dyn` are deprecated
9185
--> $DIR/issue-61963.rs:18:1
@@ -97,9 +91,8 @@ LL | pub struct Foo {
9791
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
9892
help: use `dyn`
9993
|
100-
LL - pub struct Foo {
101-
LL + dyn pub struct Foo {
102-
|
94+
LL | dyn pub struct Foo {
95+
| +++
10396

10497
error: aborting due to 7 previous errors
10598

‎src/test/ui/suggestions/suggest-blanket-impl-local-trait.stderr

+14-21
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ LL | impl LocalTraitTwo for LocalTraitOne {}
66
|
77
help: add `dyn` keyword before this trait
88
|
9-
LL - impl LocalTraitTwo for LocalTraitOne {}
10-
LL + impl LocalTraitTwo for dyn LocalTraitOne {}
11-
|
9+
LL | impl LocalTraitTwo for dyn LocalTraitOne {}
10+
| +++
1211
help: alternatively use a blanket implementation to implement `LocalTraitTwo` for all types that also implement `LocalTraitOne`
1312
|
1413
LL | impl<T: LocalTraitOne> LocalTraitTwo for T {}
@@ -22,9 +21,8 @@ LL | impl fmt::Display for LocalTraitOne {
2221
|
2322
help: add `dyn` keyword before this trait
2423
|
25-
LL - impl fmt::Display for LocalTraitOne {
26-
LL + impl fmt::Display for dyn LocalTraitOne {
27-
|
24+
LL | impl fmt::Display for dyn LocalTraitOne {
25+
| +++
2826

2927
error[E0782]: trait objects must include the `dyn` keyword
3028
--> $DIR/suggest-blanket-impl-local-trait.rs:26:23
@@ -34,9 +32,8 @@ LL | impl fmt::Display for LocalTraitTwo + Send {
3432
|
3533
help: add `dyn` keyword before this trait
3634
|
37-
LL - impl fmt::Display for LocalTraitTwo + Send {
38-
LL + impl fmt::Display for dyn LocalTraitTwo + Send {
39-
|
35+
LL | impl fmt::Display for dyn LocalTraitTwo + Send {
36+
| +++
4037

4138
error[E0782]: trait objects must include the `dyn` keyword
4239
--> $DIR/suggest-blanket-impl-local-trait.rs:34:24
@@ -46,9 +43,8 @@ LL | impl LocalTraitOne for fmt::Display {}
4643
|
4744
help: add `dyn` keyword before this trait
4845
|
49-
LL - impl LocalTraitOne for fmt::Display {}
50-
LL + impl LocalTraitOne for dyn fmt::Display {}
51-
|
46+
LL | impl LocalTraitOne for dyn fmt::Display {}
47+
| +++
5248
help: alternatively use a blanket implementation to implement `LocalTraitOne` for all types that also implement `fmt::Display`
5349
|
5450
LL | impl<T: fmt::Display> LocalTraitOne for T {}
@@ -62,9 +58,8 @@ LL | impl LocalTraitOne for fmt::Display + Send {}
6258
|
6359
help: add `dyn` keyword before this trait
6460
|
65-
LL - impl LocalTraitOne for fmt::Display + Send {}
66-
LL + impl LocalTraitOne for dyn fmt::Display + Send {}
67-
|
61+
LL | impl LocalTraitOne for dyn fmt::Display + Send {}
62+
| +++
6863
help: alternatively use a blanket implementation to implement `LocalTraitOne` for all types that also implement `fmt::Display + Send`
6964
|
7065
LL | impl<T: fmt::Display + Send> LocalTraitOne for T {}
@@ -78,9 +73,8 @@ LL | impl<E> GenericTrait<E> for LocalTraitOne {}
7873
|
7974
help: add `dyn` keyword before this trait
8075
|
81-
LL - impl<E> GenericTrait<E> for LocalTraitOne {}
82-
LL + impl<E> GenericTrait<E> for dyn LocalTraitOne {}
83-
|
76+
LL | impl<E> GenericTrait<E> for dyn LocalTraitOne {}
77+
| +++
8478
help: alternatively use a blanket implementation to implement `GenericTrait<E>` for all types that also implement `LocalTraitOne`
8579
|
8680
LL | impl<E, T: LocalTraitOne> GenericTrait<E> for T {}
@@ -94,9 +88,8 @@ LL | impl<T, E> GenericTraitTwo<E> for GenericTrait<T> {}
9488
|
9589
help: add `dyn` keyword before this trait
9690
|
97-
LL - impl<T, E> GenericTraitTwo<E> for GenericTrait<T> {}
98-
LL + impl<T, E> GenericTraitTwo<E> for dyn GenericTrait<T> {}
99-
|
91+
LL | impl<T, E> GenericTraitTwo<E> for dyn GenericTrait<T> {}
92+
| +++
10093
help: alternatively use a blanket implementation to implement `GenericTraitTwo<E>` for all types that also implement `GenericTrait<T>`
10194
|
10295
LL | impl<T, E, U: GenericTrait<T>> GenericTraitTwo<E> for U {}

‎src/test/ui/suggestions/suggest-swapping-self-ty-and-trait-edition-2021.stderr

+2-3
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ LL | impl<'a, T> Struct<T> for Trait<'a, T> {}
3939
|
4040
help: add `dyn` keyword before this trait
4141
|
42-
LL - impl<'a, T> Struct<T> for Trait<'a, T> {}
43-
LL + impl<'a, T> Struct<T> for dyn Trait<'a, T> {}
44-
|
42+
LL | impl<'a, T> Struct<T> for dyn Trait<'a, T> {}
43+
| +++
4544

4645
error: aborting due to 4 previous errors
4746

‎src/test/ui/suggestions/suggest-swapping-self-ty-and-trait.stderr

+2-3
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ LL | impl<'a, T> Struct<T> for Trait<'a, T> {}
4242
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
4343
help: use `dyn`
4444
|
45-
LL - impl<'a, T> Struct<T> for Trait<'a, T> {}
46-
LL + impl<'a, T> Struct<T> for dyn Trait<'a, T> {}
47-
|
45+
LL | impl<'a, T> Struct<T> for dyn Trait<'a, T> {}
46+
| +++
4847

4948
error: aborting due to 3 previous errors; 1 warning emitted
5049

‎src/test/ui/traits/bound/not-on-bare-trait.stderr

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ LL | fn foo(_x: Foo + Send) {
99
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
1010
help: use `dyn`
1111
|
12-
LL - fn foo(_x: Foo + Send) {
13-
LL + fn foo(_x: dyn Foo + Send) {
14-
|
12+
LL | fn foo(_x: dyn Foo + Send) {
13+
| +++
1514

1615
error[E0277]: the size for values of type `(dyn Foo + Send + 'static)` cannot be known at compilation time
1716
--> $DIR/not-on-bare-trait.rs:7:8

0 commit comments

Comments
 (0)
Please sign in to comment.