Skip to content

Commit 9b3e829

Browse files
authored
Rollup merge of rust-lang#75304 - Aaron1011:feature/diag-deref-move-out, r=estebank
Note when a a move/borrow error is caused by a deref coercion Fixes rust-lang#73268 When a deref coercion occurs, we may end up with a move error if the base value has been partially moved out of. However, we do not indicate anywhere that a deref coercion is occuring, resulting in an error message with a confusing span. This PR adds an explicit note to move errors when a deref coercion is involved. We mention the name of the type that the deref-coercion resolved to, as well as the `Deref::Target` associated type being used.
2 parents 470675f + 850265f commit 9b3e829

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

core/src/ops/deref.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,13 @@
6363
pub trait Deref {
6464
/// The resulting type after dereferencing.
6565
#[stable(feature = "rust1", since = "1.0.0")]
66+
#[rustc_diagnostic_item = "deref_target"]
6667
type Target: ?Sized;
6768

6869
/// Dereferences the value.
6970
#[must_use]
7071
#[stable(feature = "rust1", since = "1.0.0")]
72+
#[rustc_diagnostic_item = "deref_method"]
7173
fn deref(&self) -> &Self::Target;
7274
}
7375

0 commit comments

Comments
 (0)