Adjust error messages
diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs
index 083e047..7f1ca96 100644
--- a/compiler/rustc_span/src/symbol.rs
+++ b/compiler/rustc_span/src/symbol.rs
@@ -309,6 +309,7 @@
PathBuf,
Pending,
PinCoerceUnsized,
+ PinDerefMutHelper,
Pointer,
Poll,
ProcMacro,
diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs
index 37e6221..5665229 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs
@@ -3476,6 +3476,24 @@ pub(super) fn note_obligation_cause_code<G: EmissionGuarantee, T>(
// can do about it. As far as they are concerned, `?` is compiler magic.
return;
}
+ if tcx.is_diagnostic_item(sym::PinDerefMutHelper, parent_def_id) {
+ let parent_predicate =
+ self.resolve_vars_if_possible(data.derived.parent_trait_pred);
+
+ // Skip PinDerefMutHelper in suggestions, but still show downstream suggestions.
+ ensure_sufficient_stack(|| {
+ self.note_obligation_cause_code(
+ body_id,
+ err,
+ parent_predicate,
+ param_env,
+ &data.derived.parent_code,
+ obligated_types,
+ seen_requirements,
+ )
+ });
+ return;
+ }
let self_ty_str =
tcx.short_string(parent_trait_pred.skip_binder().self_ty(), err.long_ty_path());
let trait_name = tcx.short_string(
diff --git a/library/core/src/pin.rs b/library/core/src/pin.rs
index 23950ac..81c2dab 100644
--- a/library/core/src/pin.rs
+++ b/library/core/src/pin.rs
@@ -1711,20 +1711,21 @@ mod helper {
#[repr(transparent)]
#[unstable(feature = "pin_derefmut_internals", issue = "none")]
#[allow(missing_debug_implementations)]
- pub struct Pin<Ptr> {
+ pub struct PinHelper<Ptr> {
pointer: Ptr,
}
#[unstable(feature = "pin_derefmut_internals", issue = "none")]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
- pub const trait DerefMut {
+ #[rustc_diagnostic_item = "PinDerefMutHelper"]
+ pub const trait PinDerefMutHelper {
type Target: ?Sized;
fn deref_mut(&mut self) -> &mut Self::Target;
}
#[unstable(feature = "pin_derefmut_internals", issue = "none")]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
- impl<Ptr: [const] super::DerefMut> const DerefMut for Pin<Ptr>
+ impl<Ptr: [const] super::DerefMut> const PinDerefMutHelper for PinHelper<Ptr>
where
Ptr::Target: crate::marker::Unpin,
{
@@ -1743,14 +1744,14 @@ fn deref_mut(&mut self) -> &mut Ptr::Target {
impl<Ptr> const DerefMut for Pin<Ptr>
where
Ptr: [const] Deref,
- helper::Pin<Ptr>: [const] helper::DerefMut<Target = Self::Target>,
+ helper::PinHelper<Ptr>: [const] helper::PinDerefMutHelper<Target = Self::Target>,
{
#[inline]
fn deref_mut(&mut self) -> &mut Ptr::Target {
- // SAFETY: Pin and helper::Pin have the same layout, so this is equivalent to
+ // SAFETY: Pin and PinHelper have the same layout, so this is equivalent to
// `&mut self.pointer` which is safe because `Target: Unpin`.
- helper::DerefMut::deref_mut(unsafe {
- &mut *(self as *mut Pin<Ptr> as *mut helper::Pin<Ptr>)
+ helper::PinDerefMutHelper::deref_mut(unsafe {
+ &mut *(self as *mut Pin<Ptr> as *mut helper::PinHelper<Ptr>)
})
}
}
diff --git "a/tests/mir-opt/inline_coroutine_body.run2-\173closure\0430\175.Inline.panic-abort.diff" "b/tests/mir-opt/inline_coroutine_body.run2-\173closure\0430\175.Inline.panic-abort.diff"
index 226a16d..0203ff5 100644
--- "a/tests/mir-opt/inline_coroutine_body.run2-\173closure\0430\175.Inline.panic-abort.diff"
+++ "b/tests/mir-opt/inline_coroutine_body.run2-\173closure\0430\175.Inline.panic-abort.diff"
@@ -63,9 +63,9 @@
+ let mut _44: &mut std::future::Ready<()>;
+ let mut _45: &mut std::pin::Pin<&mut std::future::Ready<()>>;
+ scope 14 (inlined <Pin<&mut std::future::Ready<()>> as DerefMut>::deref_mut) {
-+ let mut _46: *mut std::pin::helper::Pin<&mut std::future::Ready<()>>;
++ let mut _46: *mut std::pin::helper::PinHelper<&mut std::future::Ready<()>>;
+ let mut _47: *mut std::pin::Pin<&mut std::future::Ready<()>>;
-+ scope 15 (inlined <pin::helper::Pin<&mut std::future::Ready<()>> as pin::helper::DerefMut>::deref_mut) {
++ scope 15 (inlined <pin::helper::PinHelper<&mut std::future::Ready<()>> as pin::helper::PinDerefMutHelper>::deref_mut) {
+ let mut _48: &mut &mut std::future::Ready<()>;
+ scope 16 (inlined <&mut std::future::Ready<()> as DerefMut>::deref_mut) {
+ }
@@ -221,7 +221,7 @@
+ StorageLive(_42);
+ StorageLive(_47);
+ _47 = &raw mut _19;
-+ _46 = copy _47 as *mut std::pin::helper::Pin<&mut std::future::Ready<()>> (PtrToPtr);
++ _46 = copy _47 as *mut std::pin::helper::PinHelper<&mut std::future::Ready<()>> (PtrToPtr);
+ StorageDead(_47);
+ _44 = copy ((*_46).0: &mut std::future::Ready<()>);
+ StorageLive(_49);
diff --git "a/tests/mir-opt/inline_coroutine_body.run2-\173closure\0430\175.Inline.panic-unwind.diff" "b/tests/mir-opt/inline_coroutine_body.run2-\173closure\0430\175.Inline.panic-unwind.diff"
index 770b6e4..6c8cad3 100644
--- "a/tests/mir-opt/inline_coroutine_body.run2-\173closure\0430\175.Inline.panic-unwind.diff"
+++ "b/tests/mir-opt/inline_coroutine_body.run2-\173closure\0430\175.Inline.panic-unwind.diff"
@@ -65,9 +65,9 @@
+ let mut _46: &mut std::future::Ready<()>;
+ let mut _47: &mut std::pin::Pin<&mut std::future::Ready<()>>;
+ scope 14 (inlined <Pin<&mut std::future::Ready<()>> as DerefMut>::deref_mut) {
-+ let mut _48: *mut std::pin::helper::Pin<&mut std::future::Ready<()>>;
++ let mut _48: *mut std::pin::helper::PinHelper<&mut std::future::Ready<()>>;
+ let mut _49: *mut std::pin::Pin<&mut std::future::Ready<()>>;
-+ scope 15 (inlined <pin::helper::Pin<&mut std::future::Ready<()>> as pin::helper::DerefMut>::deref_mut) {
++ scope 15 (inlined <pin::helper::PinHelper<&mut std::future::Ready<()>> as pin::helper::PinDerefMutHelper>::deref_mut) {
+ let mut _50: &mut &mut std::future::Ready<()>;
+ scope 16 (inlined <&mut std::future::Ready<()> as DerefMut>::deref_mut) {
+ }
@@ -238,7 +238,7 @@
+ StorageLive(_44);
+ StorageLive(_49);
+ _49 = &raw mut _19;
-+ _48 = copy _49 as *mut std::pin::helper::Pin<&mut std::future::Ready<()>> (PtrToPtr);
++ _48 = copy _49 as *mut std::pin::helper::PinHelper<&mut std::future::Ready<()>> (PtrToPtr);
+ StorageDead(_49);
+ _46 = copy ((*_48).0: &mut std::future::Ready<()>);
+ StorageLive(_51);
diff --git a/tests/ui/deref/pin-impl-deref.stderr b/tests/ui/deref/pin-impl-deref.stderr
index 918ff7c..4143d66 100644
--- a/tests/ui/deref/pin-impl-deref.stderr
+++ b/tests/ui/deref/pin-impl-deref.stderr
@@ -7,7 +7,6 @@
| required by a bound introduced by this call
|
= note: `DerefMut` is implemented for `&mut MyUnpinType`, but not for `&MyUnpinType`
- = note: required for `pin::helper::Pin<&MyUnpinType>` to implement `pin::helper::DerefMut`
= note: required for `Pin<&MyUnpinType>` to implement `DerefMut`
note: required by a bound in `impl_deref_mut`
--> $DIR/pin-impl-deref.rs:22:27
@@ -24,7 +23,6 @@
| required by a bound introduced by this call
|
= note: `DerefMut` is implemented for `&mut MyPinType`, but not for `&MyPinType`
- = note: required for `pin::helper::Pin<&MyPinType>` to implement `pin::helper::DerefMut`
= note: required for `Pin<&MyPinType>` to implement `DerefMut`
note: required by a bound in `impl_deref_mut`
--> $DIR/pin-impl-deref.rs:22:27
@@ -47,7 +45,6 @@
|
LL | struct MyPinType(core::marker::PhantomPinned);
| ^^^^^^^^^
- = note: required for `pin::helper::Pin<&MyPinType>` to implement `pin::helper::DerefMut`
= note: required for `Pin<&MyPinType>` to implement `DerefMut`
note: required by a bound in `impl_deref_mut`
--> $DIR/pin-impl-deref.rs:22:27
@@ -70,7 +67,6 @@
|
LL | struct MyPinType(core::marker::PhantomPinned);
| ^^^^^^^^^
- = note: required for `pin::helper::Pin<&mut MyPinType>` to implement `pin::helper::DerefMut`
= note: required for `Pin<&mut MyPinType>` to implement `DerefMut`
note: required by a bound in `impl_deref_mut`
--> $DIR/pin-impl-deref.rs:22:27
diff --git a/tests/ui/typeck/pin-unsound-issue-85099-derefmut.stderr b/tests/ui/typeck/pin-unsound-issue-85099-derefmut.stderr
index cc56c77..2bcd92b 100644
--- a/tests/ui/typeck/pin-unsound-issue-85099-derefmut.stderr
+++ b/tests/ui/typeck/pin-unsound-issue-85099-derefmut.stderr
@@ -6,8 +6,8 @@
|
= note: conflicting implementation in crate `core`:
- impl<Ptr> DerefMut for Pin<Ptr>
- where <pin::helper::Pin<Ptr> as pin::helper::DerefMut>::Target == <Pin<Ptr> as Deref>::Target, Ptr: Deref, pin::helper::Pin<Ptr>: pin::helper::DerefMut, pin::helper::Pin<Ptr>: ?Sized;
- = note: upstream crates may add a new impl of trait `std::pin::helper::DerefMut` for type `std::pin::helper::Pin<&dyn SomeTrait<'_, _>>` in future versions
+ where <pin::helper::PinHelper<Ptr> as pin::helper::PinDerefMutHelper>::Target == <Pin<Ptr> as Deref>::Target, Ptr: Deref, pin::helper::PinHelper<Ptr>: pin::helper::PinDerefMutHelper, pin::helper::PinHelper<Ptr>: ?Sized;
+ = note: upstream crates may add a new impl of trait `std::pin::helper::PinDerefMutHelper` for type `std::pin::helper::PinHelper<&dyn SomeTrait<'_, _>>` in future versions
error: aborting due to 1 previous error