diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs index 22342a956710..d9ea2e005789 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs @@ -392,7 +392,7 @@ fn note_error_origin( { err.span_suggestion_verbose( span, - "consider dereferencing to access the inner value using the Deref trait", + "consider dereferencing to access the inner value using the `Deref` trait", format!("{prefix}{peeled_snippet}"), Applicability::MaybeIncorrect, ); diff --git a/tests/ui/closures/2229_closure_analysis/issue-118144.stderr b/tests/ui/closures/2229_closure_analysis/issue-118144.stderr index bfe4afc4b58c..dd17a305881e 100644 --- a/tests/ui/closures/2229_closure_analysis/issue-118144.stderr +++ b/tests/ui/closures/2229_closure_analysis/issue-118144.stderr @@ -6,7 +6,7 @@ LL | V(x) = func_arg; | | | expected `&mut V`, found `V` | -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | V(x) = &*func_arg; | ++ diff --git a/tests/ui/let-else/let-else-deref-coercion.stderr b/tests/ui/let-else/let-else-deref-coercion.stderr index 543737868c9f..ed4e32cbd659 100644 --- a/tests/ui/let-else/let-else-deref-coercion.stderr +++ b/tests/ui/let-else/let-else-deref-coercion.stderr @@ -6,7 +6,7 @@ LL | let Bar::Present(z) = self else { | | | expected `Foo`, found `Bar` | -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | let Bar::Present(z) = &**self else { | +++ @@ -19,7 +19,7 @@ LL | let Bar(z) = x; | | | expected `Foo`, found `Bar` | -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | let Bar(z) = &**x; | +++ diff --git a/tests/ui/pattern/deref-patterns/const-pats-do-not-mislead-inference.stable.stderr b/tests/ui/pattern/deref-patterns/const-pats-do-not-mislead-inference.stable.stderr index 0770569e0406..74f558af4e95 100644 --- a/tests/ui/pattern/deref-patterns/const-pats-do-not-mislead-inference.stable.stderr +++ b/tests/ui/pattern/deref-patterns/const-pats-do-not-mislead-inference.stable.stderr @@ -19,7 +19,7 @@ LL | if let "..." = &Box::new(x) {} | = note: expected reference `&Box<_>` found reference `&'static str` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | if let "..." = &*Box::new(x) {} | + @@ -34,7 +34,7 @@ LL | if let b"..." = Box::new(&x) {} | = note: expected struct `Box<&_>` found reference `&'static [u8; 3]` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | if let b"..." = *Box::new(&x) {} | + diff --git a/tests/ui/pattern/deref-patterns/needs-gate.stderr b/tests/ui/pattern/deref-patterns/needs-gate.stderr index 3d938a7e23fc..edc70048ecf2 100644 --- a/tests/ui/pattern/deref-patterns/needs-gate.stderr +++ b/tests/ui/pattern/deref-patterns/needs-gate.stderr @@ -18,7 +18,7 @@ LL | 0 => {} | = note: expected struct `Box<{integer}>` found type `{integer}` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | match *Box::new(0) { | + diff --git a/tests/ui/pin-ergonomics/pattern-matching-mix-deref-pattern.normal.stderr b/tests/ui/pin-ergonomics/pattern-matching-mix-deref-pattern.normal.stderr index 0e55a5170284..e35e22d0ec24 100644 --- a/tests/ui/pin-ergonomics/pattern-matching-mix-deref-pattern.normal.stderr +++ b/tests/ui/pin-ergonomics/pattern-matching-mix-deref-pattern.normal.stderr @@ -8,7 +8,7 @@ LL | let Foo { x, y } = foo.as_mut(); | = note: expected struct `Pin<&mut Foo>` found struct `Foo<_, _>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | let Foo { x, y } = *foo.as_mut(); | + @@ -23,7 +23,7 @@ LL | Foo { x, y } => {} | = note: expected struct `Pin<&mut Foo>` found struct `Foo<_, _>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | match *foo.as_mut() { | + @@ -38,7 +38,7 @@ LL | Foo { x, y } => {} | = note: expected struct `Pin<&mut Foo>` found struct `Foo<_, _>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | let _ = || match *foo.as_mut() { | + @@ -53,7 +53,7 @@ LL | let Foo { x, y } = foo; | = note: expected struct `Pin<&Foo>` found struct `Foo<_, _>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | let Foo { x, y } = *foo; | + @@ -68,7 +68,7 @@ LL | Foo { x, y } => {} | = note: expected struct `Pin<&Foo>` found struct `Foo<_, _>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | match *foo { | + @@ -83,7 +83,7 @@ LL | Foo { x, y } => {} | = note: expected struct `Pin<&Foo>` found struct `Foo<_, _>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | let _ = || match *foo { | + @@ -98,7 +98,7 @@ LL | let Bar(x, y) = bar.as_mut(); | = note: expected struct `Pin<&mut Bar>` found struct `Bar<_, _>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | let Bar(x, y) = *bar.as_mut(); | + @@ -113,7 +113,7 @@ LL | Bar(x, y) => {} | = note: expected struct `Pin<&mut Bar>` found struct `Bar<_, _>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | match *bar.as_mut() { | + @@ -128,7 +128,7 @@ LL | Bar(x, y) => {} | = note: expected struct `Pin<&mut Bar>` found struct `Bar<_, _>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | let _ = || match *bar.as_mut() { | + @@ -143,7 +143,7 @@ LL | let Bar(x, y) = bar; | = note: expected struct `Pin<&Bar>` found struct `Bar<_, _>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | let Bar(x, y) = *bar; | + @@ -158,7 +158,7 @@ LL | Bar(x, y) => {} | = note: expected struct `Pin<&Bar>` found struct `Bar<_, _>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | match *bar { | + @@ -173,7 +173,7 @@ LL | Bar(x, y) => {} | = note: expected struct `Pin<&Bar>` found struct `Bar<_, _>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | let _ = || match *bar { | + @@ -188,7 +188,7 @@ LL | let NonPinProject { x } = foo; | = note: expected struct `Pin<&mut NonPinProject>` found struct `NonPinProject<_>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | let NonPinProject { x } = *foo; | + @@ -203,7 +203,7 @@ LL | let NonPinProject { x } = bar; | = note: expected struct `Pin<&NonPinProject>` found struct `NonPinProject<_>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | let NonPinProject { x } = *bar; | + @@ -218,7 +218,7 @@ LL | NonPinProject { x } => {} | = note: expected struct `Pin<&mut NonPinProject>` found struct `NonPinProject<_>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | match *foo { | + @@ -233,7 +233,7 @@ LL | NonPinProject { x } => {} | = note: expected struct `Pin<&NonPinProject>` found struct `NonPinProject<_>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | match *bar { | + diff --git a/tests/ui/pin-ergonomics/pattern-matching.normal.stderr b/tests/ui/pin-ergonomics/pattern-matching.normal.stderr index 8ec481fba9e0..409013c34024 100644 --- a/tests/ui/pin-ergonomics/pattern-matching.normal.stderr +++ b/tests/ui/pin-ergonomics/pattern-matching.normal.stderr @@ -28,7 +28,7 @@ LL | let Foo { x, y } = foo_mut; | = note: expected struct `Pin<&mut Foo>` found struct `Foo<_, _>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | let Foo { x, y } = *foo_mut; | + @@ -43,7 +43,7 @@ LL | let Foo { x, y } = foo_const; | = note: expected struct `Pin<&Foo>` found struct `Foo<_, _>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | let Foo { x, y } = *foo_const; | + @@ -58,7 +58,7 @@ LL | Bar::Foo(x, y) => { | = note: expected struct `Pin<&mut Bar>` found enum `Bar<_, _>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | match *bar_mut { | + @@ -73,7 +73,7 @@ LL | _ if let Bar::Bar { x, y } = bar_mut => { | = note: expected struct `Pin<&mut Bar>` found enum `Bar<_, _>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | _ if let Bar::Bar { x, y } = *bar_mut => { | + @@ -88,7 +88,7 @@ LL | Bar::Bar { x, y } => { | = note: expected struct `Pin<&Bar>` found enum `Bar<_, _>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | match *bar_const { | + @@ -103,7 +103,7 @@ LL | _ if let Bar::Foo(x, y) = bar_const => { | = note: expected struct `Pin<&Bar>` found enum `Bar<_, _>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | _ if let Bar::Foo(x, y) = *bar_const => { | + @@ -118,7 +118,7 @@ LL | let (Foo { x, y },) = foo_mut; | = note: expected struct `Pin<&mut (Foo,)>` found tuple `(_,)` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | let (Foo { x, y },) = *foo_mut; | + @@ -133,7 +133,7 @@ LL | let (Foo { x, y },) = foo_const; | = note: expected struct `Pin<&(Foo,)>` found tuple `(_,)` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | let (Foo { x, y },) = *foo_const; | + diff --git a/tests/ui/suggestions/suggest-deref-in-match-issue-132784.rs b/tests/ui/suggestions/suggest-deref-in-match-issue-132784.rs index 205e57f4a9ff..7b9b3cf19850 100644 --- a/tests/ui/suggestions/suggest-deref-in-match-issue-132784.rs +++ b/tests/ui/suggestions/suggest-deref-in-match-issue-132784.rs @@ -2,8 +2,8 @@ fn main() { let mut x = Arc::new(Some(1)); match x { - //~^ HELP consider dereferencing to access the inner value using the Deref trait - //~| HELP consider dereferencing to access the inner value using the Deref trait + //~^ HELP consider dereferencing to access the inner value using the `Deref` trait + //~| HELP consider dereferencing to access the inner value using the `Deref` trait Some(_) => {} //~^ ERROR mismatched types None => {} @@ -11,8 +11,8 @@ fn main() { } match &x { - //~^ HELP consider dereferencing to access the inner value using the Deref trait - //~| HELP consider dereferencing to access the inner value using the Deref trait + //~^ HELP consider dereferencing to access the inner value using the `Deref` trait + //~| HELP consider dereferencing to access the inner value using the `Deref` trait Some(_) => {} //~^ ERROR mismatched types None => {} @@ -21,8 +21,8 @@ fn main() { let mut y = Box::new(Some(1)); match y { - //~^ HELP consider dereferencing to access the inner value using the Deref trait - //~| HELP consider dereferencing to access the inner value using the Deref trait + //~^ HELP consider dereferencing to access the inner value using the `Deref` trait + //~| HELP consider dereferencing to access the inner value using the `Deref` trait Some(_) => {} //~^ ERROR mismatched types None => {} @@ -31,8 +31,8 @@ fn main() { let mut z = Arc::new(Some(1)); match z as Arc> { - //~^ HELP consider dereferencing to access the inner value using the Deref trait - //~| HELP consider dereferencing to access the inner value using the Deref trait + //~^ HELP consider dereferencing to access the inner value using the `Deref` trait + //~| HELP consider dereferencing to access the inner value using the `Deref` trait Some(_) => {} //~^ ERROR mismatched types None => {} @@ -41,8 +41,8 @@ fn main() { let z_const: &Arc> = &z; match z_const { - //~^ HELP consider dereferencing to access the inner value using the Deref trait - //~| HELP consider dereferencing to access the inner value using the Deref trait + //~^ HELP consider dereferencing to access the inner value using the `Deref` trait + //~| HELP consider dereferencing to access the inner value using the `Deref` trait Some(_) => {} //~^ ERROR mismatched types None => {} @@ -52,8 +52,8 @@ fn main() { // Normal reference because Arc doesn't implement DerefMut. let z_mut: &mut Arc> = &mut z; match z_mut { - //~^ HELP consider dereferencing to access the inner value using the Deref trait - //~| HELP consider dereferencing to access the inner value using the Deref trait + //~^ HELP consider dereferencing to access the inner value using the `Deref` trait + //~| HELP consider dereferencing to access the inner value using the `Deref` trait Some(_) => {} //~^ ERROR mismatched types None => {} @@ -63,8 +63,8 @@ fn main() { // Mutable reference because Box does implement DerefMut. let y_mut: &mut Box> = &mut y; match y_mut { - //~^ HELP consider dereferencing to access the inner value using the Deref trait - //~| HELP consider dereferencing to access the inner value using the Deref trait + //~^ HELP consider dereferencing to access the inner value using the `Deref` trait + //~| HELP consider dereferencing to access the inner value using the `Deref` trait Some(_) => {} //~^ ERROR mismatched types None => {} @@ -74,8 +74,8 @@ fn main() { // Difficult expression. let difficult = Arc::new(Some(1)); match (& (&difficult) ) { - //~^ HELP consider dereferencing to access the inner value using the Deref trait - //~| HELP consider dereferencing to access the inner value using the Deref trait + //~^ HELP consider dereferencing to access the inner value using the `Deref` trait + //~| HELP consider dereferencing to access the inner value using the `Deref` trait Some(_) => {} //~^ ERROR mismatched types None => {} diff --git a/tests/ui/suggestions/suggest-deref-in-match-issue-132784.stderr b/tests/ui/suggestions/suggest-deref-in-match-issue-132784.stderr index 6092272aa8c5..e0a7e2c8cedf 100644 --- a/tests/ui/suggestions/suggest-deref-in-match-issue-132784.stderr +++ b/tests/ui/suggestions/suggest-deref-in-match-issue-132784.stderr @@ -9,7 +9,7 @@ LL | Some(_) => {} | = note: expected struct `Arc>` found enum `Option<_>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | match *x { | + @@ -25,7 +25,7 @@ LL | None => {} | = note: expected struct `Arc>` found enum `Option<_>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | match *x { | + @@ -41,7 +41,7 @@ LL | Some(_) => {} | = note: expected struct `Arc>` found enum `Option<_>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | match &*x { | + @@ -57,7 +57,7 @@ LL | None => {} | = note: expected struct `Arc>` found enum `Option<_>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | match &*x { | + @@ -73,7 +73,7 @@ LL | Some(_) => {} | = note: expected struct `Box>` found enum `Option<_>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | match *y { | + @@ -89,7 +89,7 @@ LL | None => {} | = note: expected struct `Box>` found enum `Option<_>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | match *y { | + @@ -105,7 +105,7 @@ LL | Some(_) => {} | = note: expected struct `Arc>` found enum `Option<_>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL - match z as Arc> { LL + match *(z as Arc>) { @@ -122,7 +122,7 @@ LL | None => {} | = note: expected struct `Arc>` found enum `Option<_>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL - match z as Arc> { LL + match *(z as Arc>) { @@ -139,7 +139,7 @@ LL | Some(_) => {} | = note: expected struct `Arc>` found enum `Option<_>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | match &**z_const { | +++ @@ -155,7 +155,7 @@ LL | None => {} | = note: expected struct `Arc>` found enum `Option<_>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | match &**z_const { | +++ @@ -171,7 +171,7 @@ LL | Some(_) => {} | = note: expected struct `Arc>` found enum `Option<_>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | match &**z_mut { | +++ @@ -187,7 +187,7 @@ LL | None => {} | = note: expected struct `Arc>` found enum `Option<_>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | match &**z_mut { | +++ @@ -203,7 +203,7 @@ LL | Some(_) => {} | = note: expected struct `Box>` found enum `Option<_>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | match &**y_mut { | +++ @@ -219,7 +219,7 @@ LL | None => {} | = note: expected struct `Box>` found enum `Option<_>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL | match &**y_mut { | +++ @@ -235,7 +235,7 @@ LL | Some(_) => {} | = note: expected struct `Arc>` found enum `Option<_>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL - match (& (&difficult) ) { LL + match &*difficult { @@ -252,7 +252,7 @@ LL | None => {} | = note: expected struct `Arc>` found enum `Option<_>` -help: consider dereferencing to access the inner value using the Deref trait +help: consider dereferencing to access the inner value using the `Deref` trait | LL - match (& (&difficult) ) { LL + match &*difficult {