From 09da2ebd63107997e1319c2a076021660285ef40 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Fri, 4 Oct 2024 11:56:45 -0400 Subject: [PATCH] Move ty::Error branch into super_combine_tys --- .../rustc_infer/src/infer/relate/combine.rs | 5 ++++ .../src/infer/relate/type_relating.rs | 5 ---- ...invalid-type-bound-suggest-issue-127555.rs | 1 - ...lid-type-bound-suggest-issue-127555.stderr | 16 ++--------- ...-predicate-entailment-error.current.stderr | 28 +------------------ ...lse-positive-predicate-entailment-error.rs | 3 +- .../in-trait/return-dont-satisfy-bounds.rs | 1 - .../return-dont-satisfy-bounds.stderr | 14 ++-------- .../rpitit-captures-more-method-lifetimes.rs | 1 - ...itit-captures-more-method-lifetimes.stderr | 19 +------------ 10 files changed, 12 insertions(+), 81 deletions(-) diff --git a/compiler/rustc_infer/src/infer/relate/combine.rs b/compiler/rustc_infer/src/infer/relate/combine.rs index c4f5a85a8bee7..f879fbc5578cb 100644 --- a/compiler/rustc_infer/src/infer/relate/combine.rs +++ b/compiler/rustc_infer/src/infer/relate/combine.rs @@ -43,6 +43,11 @@ impl<'tcx> InferCtxt<'tcx> { debug_assert!(!b.has_escaping_bound_vars()); match (a.kind(), b.kind()) { + (&ty::Error(e), _) | (_, &ty::Error(e)) => { + self.set_tainted_by_errors(e); + return Ok(Ty::new_error(self.tcx, e)); + } + // Relate integral variables to other types (&ty::Infer(ty::IntVar(a_id)), &ty::Infer(ty::IntVar(b_id))) => { self.inner.borrow_mut().int_unification_table().union(a_id, b_id); diff --git a/compiler/rustc_infer/src/infer/relate/type_relating.rs b/compiler/rustc_infer/src/infer/relate/type_relating.rs index 4b4b13e919cea..d99acabb82587 100644 --- a/compiler/rustc_infer/src/infer/relate/type_relating.rs +++ b/compiler/rustc_infer/src/infer/relate/type_relating.rs @@ -183,11 +183,6 @@ impl<'tcx> TypeRelation> for TypeRelating<'_, 'tcx> { )?; } - (&ty::Error(e), _) | (_, &ty::Error(e)) => { - infcx.set_tainted_by_errors(e); - return Ok(Ty::new_error(self.cx(), e)); - } - ( &ty::Alias(ty::Opaque, ty::AliasTy { def_id: a_def_id, .. }), &ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, .. }), diff --git a/tests/ui/associated-types/remove-invalid-type-bound-suggest-issue-127555.rs b/tests/ui/associated-types/remove-invalid-type-bound-suggest-issue-127555.rs index 6083cc7d96dca..b4df58b3c25a8 100644 --- a/tests/ui/associated-types/remove-invalid-type-bound-suggest-issue-127555.rs +++ b/tests/ui/associated-types/remove-invalid-type-bound-suggest-issue-127555.rs @@ -14,7 +14,6 @@ impl Foo for Baz { //~^ ERROR `F` cannot be sent between threads safely where F: FnMut() + Send, - //~^ ERROR impl has stricter requirements than trait { () } diff --git a/tests/ui/associated-types/remove-invalid-type-bound-suggest-issue-127555.stderr b/tests/ui/associated-types/remove-invalid-type-bound-suggest-issue-127555.stderr index 7f3cd2a590053..e6379954776df 100644 --- a/tests/ui/associated-types/remove-invalid-type-bound-suggest-issue-127555.stderr +++ b/tests/ui/associated-types/remove-invalid-type-bound-suggest-issue-127555.stderr @@ -16,18 +16,6 @@ LL | async fn bar(&mut self, _func: F) -> () LL | F: FnMut() + Send, | ^^^^ required by this bound in `::bar` -error[E0276]: impl has stricter requirements than trait - --> $DIR/remove-invalid-type-bound-suggest-issue-127555.rs:16:22 - | -LL | / fn bar(&mut self, func: F) -> impl std::future::Future + Send -LL | | where -LL | | F: FnMut(); - | |___________________- definition of `bar` from trait -... -LL | F: FnMut() + Send, - | ^^^^ impl has extra requirement `F: Send` - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0276, E0277. -For more information about an error, try `rustc --explain E0276`. +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/in-trait/false-positive-predicate-entailment-error.current.stderr b/tests/ui/impl-trait/in-trait/false-positive-predicate-entailment-error.current.stderr index d71c1768a6a3b..058517f0014e9 100644 --- a/tests/ui/impl-trait/in-trait/false-positive-predicate-entailment-error.current.stderr +++ b/tests/ui/impl-trait/in-trait/false-positive-predicate-entailment-error.current.stderr @@ -73,32 +73,6 @@ help: consider further restricting this bound LL | F: Callback + MyFn, | +++++++++++ -error[E0277]: the trait bound `F: Callback` is not satisfied - --> $DIR/false-positive-predicate-entailment-error.rs:43:12 - | -LL | F: Callback, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MyFn` is not implemented for `F`, which is required by `F: Callback` - | -note: required for `F` to implement `Callback` - --> $DIR/false-positive-predicate-entailment-error.rs:14:21 - | -LL | impl> Callback for F { - | ------- ^^^^^^^^^^^ ^ - | | - | unsatisfied trait bound introduced here -note: the requirement `F: Callback` appears on the `impl`'s method `autobatch` but not on the corresponding trait's method - --> $DIR/false-positive-predicate-entailment-error.rs:25:8 - | -LL | trait ChannelSender { - | ------------- in this trait -... -LL | fn autobatch(self) -> impl Trait - | ^^^^^^^^^ this trait's method doesn't have the requirement `F: Callback` -help: consider further restricting this bound - | -LL | F: Callback + MyFn, - | +++++++++++ - error[E0277]: the trait bound `F: MyFn` is not satisfied --> $DIR/false-positive-predicate-entailment-error.rs:36:30 | @@ -168,6 +142,6 @@ help: consider further restricting this bound LL | F: Callback + MyFn, | +++++++++++ -error: aborting due to 8 previous errors +error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/in-trait/false-positive-predicate-entailment-error.rs b/tests/ui/impl-trait/in-trait/false-positive-predicate-entailment-error.rs index 59fdeab9e0a9f..2987d183e0401 100644 --- a/tests/ui/impl-trait/in-trait/false-positive-predicate-entailment-error.rs +++ b/tests/ui/impl-trait/in-trait/false-positive-predicate-entailment-error.rs @@ -41,8 +41,7 @@ impl ChannelSender for Sender { //[current]~| ERROR the trait bound `F: MyFn` is not satisfied where F: Callback, - //[current]~^ ERROR the trait bound `F: Callback` is not satisfied - //[current]~| ERROR the trait bound `F: MyFn` is not satisfied + //[current]~^ ERROR the trait bound `F: MyFn` is not satisfied { Thing } diff --git a/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.rs b/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.rs index 84bc39d926307..ee47de2c73283 100644 --- a/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.rs +++ b/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.rs @@ -8,7 +8,6 @@ impl Foo for Bar { fn foo>(self) -> impl Foo { //~^ ERROR: the trait bound `impl Foo: Foo` is not satisfied [E0277] //~| ERROR: the trait bound `Bar: Foo` is not satisfied [E0277] - //~| ERROR: impl has stricter requirements than trait //~| ERROR: the trait bound `F2: Foo` is not satisfied self } diff --git a/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.stderr b/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.stderr index ae4490999878f..768224e4c515c 100644 --- a/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.stderr +++ b/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.stderr @@ -23,15 +23,6 @@ note: required by a bound in `>::foo` LL | fn foo>(self) -> impl Foo { | ^^^^^^^ required by this bound in `>::foo` -error[E0276]: impl has stricter requirements than trait - --> $DIR/return-dont-satisfy-bounds.rs:8:16 - | -LL | fn foo(self) -> impl Foo; - | -------------------------------- definition of `foo` from trait -... -LL | fn foo>(self) -> impl Foo { - | ^^^^^^^ impl has extra requirement `F2: Foo` - error[E0277]: the trait bound `Bar: Foo` is not satisfied --> $DIR/return-dont-satisfy-bounds.rs:8:34 | @@ -44,7 +35,6 @@ LL | self = help: the trait `Foo` is implemented for `Bar` = help: for that trait implementation, expected `char`, found `u8` -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors -Some errors have detailed explanations: E0276, E0277. -For more information about an error, try `rustc --explain E0276`. +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/precise-capturing/rpitit-captures-more-method-lifetimes.rs b/tests/ui/impl-trait/precise-capturing/rpitit-captures-more-method-lifetimes.rs index 71a91fe319e8d..062351afecbdf 100644 --- a/tests/ui/impl-trait/precise-capturing/rpitit-captures-more-method-lifetimes.rs +++ b/tests/ui/impl-trait/precise-capturing/rpitit-captures-more-method-lifetimes.rs @@ -10,7 +10,6 @@ pub trait Foo { impl Foo for () { fn bar<'im: 'im>(&'im mut self) -> impl Sized + 'im {} //~^ ERROR return type captures more lifetimes than trait definition - //~| WARN impl trait in impl method signature does not match trait method signature } fn main() {} diff --git a/tests/ui/impl-trait/precise-capturing/rpitit-captures-more-method-lifetimes.stderr b/tests/ui/impl-trait/precise-capturing/rpitit-captures-more-method-lifetimes.stderr index 339e2e6335e2d..b390a23eef414 100644 --- a/tests/ui/impl-trait/precise-capturing/rpitit-captures-more-method-lifetimes.stderr +++ b/tests/ui/impl-trait/precise-capturing/rpitit-captures-more-method-lifetimes.stderr @@ -21,22 +21,5 @@ LL | fn bar<'tr: 'tr>(&'tr mut self) -> impl Sized + use; | ^^^^^^^^^^^^^^^^^^^^^^ = note: hidden type inferred to be `impl Sized + 'im` -warning: impl trait in impl method signature does not match trait method signature - --> $DIR/rpitit-captures-more-method-lifetimes.rs:11:40 - | -LL | fn bar<'tr: 'tr>(&'tr mut self) -> impl Sized + use; - | ---------------------- return type from trait method defined here -... -LL | fn bar<'im: 'im>(&'im mut self) -> impl Sized + 'im {} - | ^^^^^^^^^^^^^^^^ - | - = note: add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate - = note: we are soliciting feedback, see issue #121718 for more information - = note: `#[warn(refining_impl_trait_reachable)]` on by default -help: replace the return type so that it matches the trait - | -LL | fn bar<'im: 'im>(&'im mut self) -> impl Sized {} - | ~~~~~~~~~~ - -error: aborting due to 2 previous errors; 1 warning emitted +error: aborting due to 2 previous errors