Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
{
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,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
| ++
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/let-else/let-else-deref-coercion.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
| +++
Expand All @@ -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;
| +++
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
| +
Expand All @@ -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) {}
| +
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/pattern/deref-patterns/needs-gate.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
| +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ LL | let Foo { x, y } = foo.as_mut();
|
= note: expected struct `Pin<&mut Foo<T, U>>`
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();
| +
Expand All @@ -23,7 +23,7 @@ LL | Foo { x, y } => {}
|
= note: expected struct `Pin<&mut Foo<T, U>>`
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() {
| +
Expand All @@ -38,7 +38,7 @@ LL | Foo { x, y } => {}
|
= note: expected struct `Pin<&mut Foo<T, U>>`
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() {
| +
Expand All @@ -53,7 +53,7 @@ LL | let Foo { x, y } = foo;
|
= note: expected struct `Pin<&Foo<T, U>>`
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;
| +
Expand All @@ -68,7 +68,7 @@ LL | Foo { x, y } => {}
|
= note: expected struct `Pin<&Foo<T, U>>`
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 {
| +
Expand All @@ -83,7 +83,7 @@ LL | Foo { x, y } => {}
|
= note: expected struct `Pin<&Foo<T, U>>`
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 {
| +
Expand All @@ -98,7 +98,7 @@ LL | let Bar(x, y) = bar.as_mut();
|
= note: expected struct `Pin<&mut Bar<T, U>>`
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();
| +
Expand All @@ -113,7 +113,7 @@ LL | Bar(x, y) => {}
|
= note: expected struct `Pin<&mut Bar<T, U>>`
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() {
| +
Expand All @@ -128,7 +128,7 @@ LL | Bar(x, y) => {}
|
= note: expected struct `Pin<&mut Bar<T, U>>`
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() {
| +
Expand All @@ -143,7 +143,7 @@ LL | let Bar(x, y) = bar;
|
= note: expected struct `Pin<&Bar<T, U>>`
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;
| +
Expand All @@ -158,7 +158,7 @@ LL | Bar(x, y) => {}
|
= note: expected struct `Pin<&Bar<T, U>>`
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 {
| +
Expand All @@ -173,7 +173,7 @@ LL | Bar(x, y) => {}
|
= note: expected struct `Pin<&Bar<T, U>>`
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 {
| +
Expand All @@ -188,7 +188,7 @@ LL | let NonPinProject { x } = foo;
|
= note: expected struct `Pin<&mut NonPinProject<T>>`
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;
| +
Expand All @@ -203,7 +203,7 @@ LL | let NonPinProject { x } = bar;
|
= note: expected struct `Pin<&NonPinProject<U>>`
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;
| +
Expand All @@ -218,7 +218,7 @@ LL | NonPinProject { x } => {}
|
= note: expected struct `Pin<&mut NonPinProject<T>>`
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 {
| +
Expand All @@ -233,7 +233,7 @@ LL | NonPinProject { x } => {}
|
= note: expected struct `Pin<&NonPinProject<U>>`
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 {
| +
Expand Down
16 changes: 8 additions & 8 deletions tests/ui/pin-ergonomics/pattern-matching.normal.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ LL | let Foo { x, y } = foo_mut;
|
= note: expected struct `Pin<&mut Foo<T, U>>`
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;
| +
Expand All @@ -43,7 +43,7 @@ LL | let Foo { x, y } = foo_const;
|
= note: expected struct `Pin<&Foo<T, U>>`
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;
| +
Expand All @@ -58,7 +58,7 @@ LL | Bar::Foo(x, y) => {
|
= note: expected struct `Pin<&mut Bar<T, U>>`
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 {
| +
Expand All @@ -73,7 +73,7 @@ LL | _ if let Bar::Bar { x, y } = bar_mut => {
|
= note: expected struct `Pin<&mut Bar<T, U>>`
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 => {
| +
Expand All @@ -88,7 +88,7 @@ LL | Bar::Bar { x, y } => {
|
= note: expected struct `Pin<&Bar<T, U>>`
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 {
| +
Expand All @@ -103,7 +103,7 @@ LL | _ if let Bar::Foo(x, y) = bar_const => {
|
= note: expected struct `Pin<&Bar<T, U>>`
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 => {
| +
Expand All @@ -118,7 +118,7 @@ LL | let (Foo { x, y },) = foo_mut;
|
= note: expected struct `Pin<&mut (Foo<T, U>,)>`
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;
| +
Expand All @@ -133,7 +133,7 @@ LL | let (Foo { x, y },) = foo_const;
|
= note: expected struct `Pin<&(Foo<T, U>,)>`
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;
| +
Expand Down
32 changes: 16 additions & 16 deletions tests/ui/suggestions/suggest-deref-in-match-issue-132784.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ use std::sync::Arc;
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 => {}
//~^ ERROR mismatched types
}

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 => {}
Expand All @@ -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 => {}
Expand All @@ -31,8 +31,8 @@ fn main() {

let mut z = Arc::new(Some(1));
match z as Arc<Option<i32>> {
//~^ 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 => {}
Expand All @@ -41,8 +41,8 @@ fn main() {

let z_const: &Arc<Option<i32>> = &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 => {}
Expand All @@ -52,8 +52,8 @@ fn main() {
// Normal reference because Arc doesn't implement DerefMut.
let z_mut: &mut Arc<Option<i32>> = &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 => {}
Expand All @@ -63,8 +63,8 @@ fn main() {
// Mutable reference because Box does implement DerefMut.
let y_mut: &mut Box<Option<i32>> = &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 => {}
Expand All @@ -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 => {}
Expand Down
Loading
Loading