Skip to content

Commit 0a66e8f

Browse files
Consider add-prefix replacements too
1 parent 039118a commit 0a66e8f

File tree

44 files changed

+222
-330
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+222
-330
lines changed

compiler/rustc_errors/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,10 @@ impl SubstitutionPart {
236236
/// it with "abx" is, since the "c" character is lost.
237237
pub fn is_destructive_replacement(&self, sm: &SourceMap) -> bool {
238238
self.is_replacement(sm)
239-
&& !sm
240-
.span_to_snippet(self.span)
241-
.is_ok_and(|snippet| self.snippet.trim_start().starts_with(snippet.trim_start()))
239+
&& !sm.span_to_snippet(self.span).is_ok_and(|snippet| {
240+
self.snippet.trim_start().starts_with(snippet.trim_start())
241+
|| self.snippet.trim_end().ends_with(snippet.trim_end())
242+
})
242243
}
243244

244245
fn replaces_meaningful_content(&self, sm: &SourceMap) -> bool {

tests/ui/closures/2229_closure_analysis/issue-118144.stderr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ LL | V(x) = func_arg;
88
|
99
help: consider dereferencing to access the inner value using the Deref trait
1010
|
11-
LL - V(x) = func_arg;
12-
LL + V(x) = &*func_arg;
13-
|
11+
LL | V(x) = &*func_arg;
12+
| ~~~~~~~~~~
1413

1514
error: aborting due to 1 previous error
1615

tests/ui/empty/empty-struct-braces-expr.stderr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,8 @@ LL | let xe3 = XE::Empty3;
125125
|
126126
help: there is a variant with a similar name
127127
|
128-
LL - let xe3 = XE::Empty3;
129-
LL + let xe3 = XE::XEmpty3;
130-
|
128+
LL | let xe3 = XE::XEmpty3;
129+
| ~~~~~~~
131130

132131
error[E0599]: no variant or associated item named `Empty3` found for enum `empty_struct::XE` in the current scope
133132
--> $DIR/empty-struct-braces-expr.rs:26:19

tests/ui/env-macro/error-recovery-issue-55897.stderr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ LL | use env;
3030
|
3131
help: consider importing this module instead
3232
|
33-
LL - use env;
34-
LL + use std::env;
35-
|
33+
LL | use std::env;
34+
| ~~~~~~~~
3635

3736
error: aborting due to 4 previous errors
3837

tests/ui/error-codes/E0027.stderr

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,16 @@ LL | Dog { age: x } => {}
66
|
77
help: include the missing field in the pattern
88
|
9-
LL - Dog { age: x } => {}
10-
LL + Dog { age: x, name } => {}
11-
|
9+
LL | Dog { age: x, name } => {}
10+
| ~~~~~~~~
1211
help: if you don't care about this missing field, you can explicitly ignore it
1312
|
14-
LL - Dog { age: x } => {}
15-
LL + Dog { age: x, name: _ } => {}
16-
|
13+
LL | Dog { age: x, name: _ } => {}
14+
| ~~~~~~~~~~~
1715
help: or always ignore missing fields here
1816
|
19-
LL - Dog { age: x } => {}
20-
LL + Dog { age: x, .. } => {}
21-
|
17+
LL | Dog { age: x, .. } => {}
18+
| ~~~~~~
2219

2320
error[E0027]: pattern does not mention field `age`
2421
--> $DIR/E0027.rs:15:9

tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,8 @@ LL | extern "rust-call" fn call(self, args: ()) -> () {}
9595
found signature `extern "rust-call" fn(Foo, ()) -> ()`
9696
help: change the self-receiver type to match the trait
9797
|
98-
LL - extern "rust-call" fn call(self, args: ()) -> () {}
99-
LL + extern "rust-call" fn call(&self, args: ()) -> () {}
100-
|
98+
LL | extern "rust-call" fn call(&self, args: ()) -> () {}
99+
| ~~~~~
101100

102101
error[E0183]: manual implementations of `FnOnce` are experimental
103102
--> $DIR/feature-gate-unboxed-closures-manual-impls.rs:18:6

tests/ui/imports/suggest-import-issue-120074.edition2015.stderr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ LL | println!("Hello, {}!", crate::bar::do_the_thing);
66
|
77
help: a similar path exists
88
|
9-
LL - println!("Hello, {}!", crate::bar::do_the_thing);
10-
LL + println!("Hello, {}!", crate::foo::bar::do_the_thing);
11-
|
9+
LL | println!("Hello, {}!", crate::foo::bar::do_the_thing);
10+
| ~~~~~~~~
1211
help: consider importing this module
1312
|
1413
LL + use foo::bar;

tests/ui/imports/suggest-import-issue-120074.edition2021.stderr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ LL | println!("Hello, {}!", crate::bar::do_the_thing);
66
|
77
help: a similar path exists
88
|
9-
LL - println!("Hello, {}!", crate::bar::do_the_thing);
10-
LL + println!("Hello, {}!", crate::foo::bar::do_the_thing);
11-
|
9+
LL | println!("Hello, {}!", crate::foo::bar::do_the_thing);
10+
| ~~~~~~~~
1211
help: consider importing this module
1312
|
1413
LL + use foo::bar;

tests/ui/issues/issue-57741-dereference-boxed-value/issue-57741.stderr

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ LL | T::A(a) | T::B(a) => a,
1010
found enum `T`
1111
help: consider dereferencing the boxed value
1212
|
13-
LL - let y = match x {
14-
LL + let y = match *x {
15-
|
13+
LL | let y = match *x {
14+
| ~~
1615

1716
error[E0308]: mismatched types
1817
--> $DIR/issue-57741.rs:20:19
@@ -26,9 +25,8 @@ LL | T::A(a) | T::B(a) => a,
2625
found enum `T`
2726
help: consider dereferencing the boxed value
2827
|
29-
LL - let y = match x {
30-
LL + let y = match *x {
31-
|
28+
LL | let y = match *x {
29+
| ~~
3230

3331
error[E0308]: mismatched types
3432
--> $DIR/issue-57741.rs:27:9
@@ -42,9 +40,8 @@ LL | S::A { a } | S::B { b: a } => a,
4240
found enum `S`
4341
help: consider dereferencing the boxed value
4442
|
45-
LL - let y = match x {
46-
LL + let y = match *x {
47-
|
43+
LL | let y = match *x {
44+
| ~~
4845

4946
error[E0308]: mismatched types
5047
--> $DIR/issue-57741.rs:27:22
@@ -58,9 +55,8 @@ LL | S::A { a } | S::B { b: a } => a,
5855
found enum `S`
5956
help: consider dereferencing the boxed value
6057
|
61-
LL - let y = match x {
62-
LL + let y = match *x {
63-
|
58+
LL | let y = match *x {
59+
| ~~
6460

6561
error: aborting due to 4 previous errors
6662

tests/ui/let-else/let-else-deref-coercion.stderr

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ LL | let Bar::Present(z) = self else {
88
|
99
help: consider dereferencing to access the inner value using the Deref trait
1010
|
11-
LL - let Bar::Present(z) = self else {
12-
LL + let Bar::Present(z) = &**self else {
13-
|
11+
LL | let Bar::Present(z) = &**self else {
12+
| ~~~~~~~
1413

1514
error[E0308]: mismatched types
1615
--> $DIR/let-else-deref-coercion.rs:68:13
@@ -22,9 +21,8 @@ LL | let Bar(z) = x;
2221
|
2322
help: consider dereferencing to access the inner value using the Deref trait
2423
|
25-
LL - let Bar(z) = x;
26-
LL + let Bar(z) = &**x;
27-
|
24+
LL | let Bar(z) = &**x;
25+
| ~~~~
2826

2927
error: aborting due to 2 previous errors
3028

0 commit comments

Comments
 (0)