diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs index cfeb0792d9f..8a7ebd6478b 100644 --- a/compiler/rustc_hir_typeck/src/method/probe.rs +++ b/compiler/rustc_hir_typeck/src/method/probe.rs @@ -1376,8 +1376,8 @@ fn consider_probe( (xform_self_ty, xform_ret_ty) = self.xform_self_ty(probe.item, impl_ty, impl_args); xform_self_ty = ocx.normalize(cause, self.param_env, xform_self_ty); - // FIXME: Make this `ocx.eq` once we define opaques more eagerly. - match self.at(cause, self.param_env).eq( + // FIXME: Make this `ocx.sup` once we define opaques more eagerly. + match self.at(cause, self.param_env).sup( DefineOpaqueTypes::No, xform_self_ty, self_ty, @@ -1437,8 +1437,8 @@ fn consider_probe( (xform_self_ty, xform_ret_ty) = self.xform_self_ty(probe.item, trait_ref.self_ty(), trait_ref.args); xform_self_ty = ocx.normalize(cause, self.param_env, xform_self_ty); - // FIXME: Make this `ocx.eq` once we define opaques more eagerly. - match self.at(cause, self.param_env).eq( + // FIXME: Make this `ocx.sup` once we define opaques more eagerly. + match self.at(cause, self.param_env).sup( DefineOpaqueTypes::No, xform_self_ty, self_ty, @@ -1489,8 +1489,8 @@ fn consider_probe( (xform_self_ty, xform_ret_ty) = self.xform_self_ty(probe.item, trait_ref.self_ty(), trait_ref.args); xform_self_ty = ocx.normalize(cause, self.param_env, xform_self_ty); - // FIXME: Make this `ocx.eq` once we define opaques more eagerly. - match self.at(cause, self.param_env).eq( + // FIXME: Make this `ocx.sup` once we define opaques more eagerly. + match self.at(cause, self.param_env).sup( DefineOpaqueTypes::No, xform_self_ty, self_ty, diff --git a/tests/ui/impl-trait/issues/issue-62742.rs b/tests/ui/impl-trait/issues/issue-62742.rs index bd48c51c065..56c63a1daa8 100644 --- a/tests/ui/impl-trait/issues/issue-62742.rs +++ b/tests/ui/impl-trait/issues/issue-62742.rs @@ -1,12 +1,17 @@ use std::marker::PhantomData; -fn _alias_check() { +fn a() { WrongImpl::foo(0i32); - //~^ ERROR the trait bound `RawImpl<_>: Raw<_>` is not satisfied - //~| ERROR the function or associated item `foo` exists for struct `SafeImpl<_, RawImpl<_>>`, but its trait bounds were not satisfied + //~^ ERROR overflow assigning `_` to `[_]` +} + +fn b() { WrongImpl::<()>::foo(0i32); //~^ ERROR the trait bound `RawImpl<()>: Raw<()>` is not satisfied //~| ERROR trait bounds were not satisfied +} + +fn c() { CorrectImpl::foo(0i32); } diff --git a/tests/ui/impl-trait/issues/issue-62742.stderr b/tests/ui/impl-trait/issues/issue-62742.stderr index f6798f55a47..7a1bcfc70d5 100644 --- a/tests/ui/impl-trait/issues/issue-62742.stderr +++ b/tests/ui/impl-trait/issues/issue-62742.stderr @@ -1,30 +1,11 @@ -error[E0599]: the function or associated item `foo` exists for struct `SafeImpl<_, RawImpl<_>>`, but its trait bounds were not satisfied +error[E0275]: overflow assigning `_` to `[_]` --> $DIR/issue-62742.rs:4:16 | LL | WrongImpl::foo(0i32); - | ^^^ function or associated item cannot be called on `SafeImpl<_, RawImpl<_>>` due to unsatisfied trait bounds -... -LL | pub struct RawImpl(PhantomData); - | --------------------- doesn't satisfy `RawImpl<_>: Raw<_>` -... -LL | pub struct SafeImpl>(PhantomData<(A, T)>); - | ----------------------------------------- function or associated item `foo` not found for this struct - | -note: trait bound `RawImpl<_>: Raw<_>` was not satisfied - --> $DIR/issue-62742.rs:29:20 - | -LL | impl> SafeImpl { - | ^^^^^^ -------------- - | | - | unsatisfied trait bound introduced here -note: the trait `Raw` must be implemented - --> $DIR/issue-62742.rs:13:1 - | -LL | pub trait Raw { - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^ error[E0599]: the function or associated item `foo` exists for struct `SafeImpl<(), RawImpl<()>>`, but its trait bounds were not satisfied - --> $DIR/issue-62742.rs:7:22 + --> $DIR/issue-62742.rs:9:22 | LL | WrongImpl::<()>::foo(0i32); | ^^^ function or associated item cannot be called on `SafeImpl<(), RawImpl<()>>` due to unsatisfied trait bounds @@ -36,33 +17,20 @@ LL | pub struct SafeImpl>(PhantomData<(A, T)>); | ----------------------------------------- function or associated item `foo` not found for this struct | note: trait bound `RawImpl<()>: Raw<()>` was not satisfied - --> $DIR/issue-62742.rs:29:20 + --> $DIR/issue-62742.rs:34:20 | LL | impl> SafeImpl { | ^^^^^^ -------------- | | | unsatisfied trait bound introduced here note: the trait `Raw` must be implemented - --> $DIR/issue-62742.rs:13:1 + --> $DIR/issue-62742.rs:18:1 | LL | pub trait Raw { | ^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0277]: the trait bound `RawImpl<_>: Raw<_>` is not satisfied - --> $DIR/issue-62742.rs:4:5 - | -LL | WrongImpl::foo(0i32); - | ^^^^^^^^^ the trait `Raw<_>` is not implemented for `RawImpl<_>` - | - = help: the trait `Raw<[_]>` is implemented for `RawImpl<_>` -note: required by a bound in `SafeImpl` - --> $DIR/issue-62742.rs:27:35 - | -LL | pub struct SafeImpl>(PhantomData<(A, T)>); - | ^^^^^^ required by this bound in `SafeImpl` - error[E0277]: the trait bound `RawImpl<()>: Raw<()>` is not satisfied - --> $DIR/issue-62742.rs:7:5 + --> $DIR/issue-62742.rs:9:5 | LL | WrongImpl::<()>::foo(0i32); | ^^^^^^^^^^^^^^^ the trait `Raw<()>` is not implemented for `RawImpl<()>` @@ -70,12 +38,12 @@ LL | WrongImpl::<()>::foo(0i32); = help: the trait `Raw<[()]>` is implemented for `RawImpl<()>` = help: for that trait implementation, expected `[()]`, found `()` note: required by a bound in `SafeImpl` - --> $DIR/issue-62742.rs:27:35 + --> $DIR/issue-62742.rs:32:35 | LL | pub struct SafeImpl>(PhantomData<(A, T)>); | ^^^^^^ required by this bound in `SafeImpl` -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors -Some errors have detailed explanations: E0277, E0599. -For more information about an error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0275, E0277, E0599. +For more information about an error, try `rustc --explain E0275`. diff --git a/tests/ui/impl-trait/issues/issue-84073.rs b/tests/ui/impl-trait/issues/issue-84073.rs index f2f1835dc34..7acee44a722 100644 --- a/tests/ui/impl-trait/issues/issue-84073.rs +++ b/tests/ui/impl-trait/issues/issue-84073.rs @@ -30,5 +30,5 @@ pub fn new(race: R) {} fn main() { Race::new(|race| race.when()); - //~^ ERROR the method `when` exists for struct `RaceBuilder<_, Never<_>>`, but its trait bounds were not satisfied + //~^ ERROR overflow assigning `_` to `Option<_>` } diff --git a/tests/ui/impl-trait/issues/issue-84073.stderr b/tests/ui/impl-trait/issues/issue-84073.stderr index eeb23b13081..0f4c6e83fbe 100644 --- a/tests/ui/impl-trait/issues/issue-84073.stderr +++ b/tests/ui/impl-trait/issues/issue-84073.stderr @@ -1,29 +1,9 @@ -error[E0599]: the method `when` exists for struct `RaceBuilder<_, Never<_>>`, but its trait bounds were not satisfied +error[E0275]: overflow assigning `_` to `Option<_>` --> $DIR/issue-84073.rs:32:27 | -LL | pub struct Never(PhantomData); - | ------------------- doesn't satisfy `Never<_>: StatefulFuture>` -... -LL | pub struct RaceBuilder { - | ---------------------------- method `when` not found for this struct -... LL | Race::new(|race| race.when()); - | ^^^^ method cannot be called on `RaceBuilder<_, Never<_>>` due to unsatisfied trait bounds - | -note: trait bound `Never<_>: StatefulFuture>` was not satisfied - --> $DIR/issue-84073.rs:14:8 - | -LL | impl RaceBuilder - | ----------------- -LL | where -LL | F: StatefulFuture>, - | ^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound introduced here -note: the trait `StatefulFuture` must be implemented - --> $DIR/issue-84073.rs:3:1 - | -LL | pub trait StatefulFuture {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^ error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0599`. +For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/methods/self-type-is-sup-no-eq.rs b/tests/ui/methods/self-type-is-sup-no-eq.rs new file mode 100644 index 00000000000..ec28b964a05 --- /dev/null +++ b/tests/ui/methods/self-type-is-sup-no-eq.rs @@ -0,0 +1,24 @@ +//@ check-pass + +// Test that we use `sup` not `eq` during method probe, since this has an effect +// on the leak check. This is (conceptually) minimized from a crater run for +// `wrend 0.3.6`. + +use std::ops::Deref; + +struct A; + +impl Deref for A { + type Target = B; + + fn deref(&self) -> &::Target { todo!() } +} + +struct B(T); +impl B { + fn method(&self) {} +} + +fn main() { + A.method(); +}