Skip to content

Commit 6141ac4

Browse files
Move ty::Error branch into super_combine_tys
1 parent 06bb836 commit 6141ac4

10 files changed

+12
-81
lines changed

compiler/rustc_infer/src/infer/relate/combine.rs

+5
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ impl<'tcx> InferCtxt<'tcx> {
8282
debug_assert!(!b.has_escaping_bound_vars());
8383

8484
match (a.kind(), b.kind()) {
85+
(&ty::Error(e), _) | (_, &ty::Error(e)) => {
86+
self.set_tainted_by_errors(e);
87+
return Ok(Ty::new_error(self.tcx, e));
88+
}
89+
8590
// Relate integral variables to other types
8691
(&ty::Infer(ty::IntVar(a_id)), &ty::Infer(ty::IntVar(b_id))) => {
8792
self.inner.borrow_mut().int_unification_table().union(a_id, b_id);

compiler/rustc_infer/src/infer/relate/type_relating.rs

-5
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,6 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for TypeRelating<'_, '_, 'tcx> {
129129
)?;
130130
}
131131

132-
(&ty::Error(e), _) | (_, &ty::Error(e)) => {
133-
infcx.set_tainted_by_errors(e);
134-
return Ok(Ty::new_error(self.cx(), e));
135-
}
136-
137132
(
138133
&ty::Alias(ty::Opaque, ty::AliasTy { def_id: a_def_id, .. }),
139134
&ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, .. }),

tests/ui/associated-types/remove-invalid-type-bound-suggest-issue-127555.rs

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ impl Foo for Baz {
1414
//~^ ERROR `F` cannot be sent between threads safely
1515
where
1616
F: FnMut() + Send,
17-
//~^ ERROR impl has stricter requirements than trait
1817
{
1918
()
2019
}

tests/ui/associated-types/remove-invalid-type-bound-suggest-issue-127555.stderr

+2-14
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,6 @@ LL | async fn bar<F>(&mut self, _func: F) -> ()
1616
LL | F: FnMut() + Send,
1717
| ^^^^ required by this bound in `<Baz as Foo>::bar`
1818

19-
error[E0276]: impl has stricter requirements than trait
20-
--> $DIR/remove-invalid-type-bound-suggest-issue-127555.rs:16:22
21-
|
22-
LL | / fn bar<F>(&mut self, func: F) -> impl std::future::Future<Output = ()> + Send
23-
LL | | where
24-
LL | | F: FnMut();
25-
| |___________________- definition of `bar` from trait
26-
...
27-
LL | F: FnMut() + Send,
28-
| ^^^^ impl has extra requirement `F: Send`
29-
30-
error: aborting due to 2 previous errors
19+
error: aborting due to 1 previous error
3120

32-
Some errors have detailed explanations: E0276, E0277.
33-
For more information about an error, try `rustc --explain E0276`.
21+
For more information about this error, try `rustc --explain E0277`.

tests/ui/impl-trait/in-trait/false-positive-predicate-entailment-error.current.stderr

+1-27
Original file line numberDiff line numberDiff line change
@@ -73,32 +73,6 @@ help: consider further restricting this bound
7373
LL | F: Callback<Self::CallbackArg> + MyFn<i32>,
7474
| +++++++++++
7575

76-
error[E0277]: the trait bound `F: Callback<i32>` is not satisfied
77-
--> $DIR/false-positive-predicate-entailment-error.rs:43:12
78-
|
79-
LL | F: Callback<Self::CallbackArg>,
80-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MyFn<i32>` is not implemented for `F`, which is required by `F: Callback<i32>`
81-
|
82-
note: required for `F` to implement `Callback<i32>`
83-
--> $DIR/false-positive-predicate-entailment-error.rs:14:21
84-
|
85-
LL | impl<A, F: MyFn<A>> Callback<A> for F {
86-
| ------- ^^^^^^^^^^^ ^
87-
| |
88-
| unsatisfied trait bound introduced here
89-
note: the requirement `F: Callback<i32>` appears on the `impl`'s method `autobatch` but not on the corresponding trait's method
90-
--> $DIR/false-positive-predicate-entailment-error.rs:25:8
91-
|
92-
LL | trait ChannelSender {
93-
| ------------- in this trait
94-
...
95-
LL | fn autobatch<F>(self) -> impl Trait
96-
| ^^^^^^^^^ this trait's method doesn't have the requirement `F: Callback<i32>`
97-
help: consider further restricting this bound
98-
|
99-
LL | F: Callback<Self::CallbackArg> + MyFn<i32>,
100-
| +++++++++++
101-
10276
error[E0277]: the trait bound `F: MyFn<i32>` is not satisfied
10377
--> $DIR/false-positive-predicate-entailment-error.rs:36:30
10478
|
@@ -168,6 +142,6 @@ help: consider further restricting this bound
168142
LL | F: Callback<Self::CallbackArg> + MyFn<i32>,
169143
| +++++++++++
170144

171-
error: aborting due to 8 previous errors
145+
error: aborting due to 7 previous errors
172146

173147
For more information about this error, try `rustc --explain E0277`.

tests/ui/impl-trait/in-trait/false-positive-predicate-entailment-error.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ impl ChannelSender for Sender {
4141
//[current]~| ERROR the trait bound `F: MyFn<i32>` is not satisfied
4242
where
4343
F: Callback<Self::CallbackArg>,
44-
//[current]~^ ERROR the trait bound `F: Callback<i32>` is not satisfied
45-
//[current]~| ERROR the trait bound `F: MyFn<i32>` is not satisfied
44+
//[current]~^ ERROR the trait bound `F: MyFn<i32>` is not satisfied
4645
{
4746
Thing
4847
}

tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ impl Foo<char> for Bar {
88
fn foo<F2: Foo<u8>>(self) -> impl Foo<u8> {
99
//~^ ERROR: the trait bound `impl Foo<u8>: Foo<char>` is not satisfied [E0277]
1010
//~| ERROR: the trait bound `Bar: Foo<u8>` is not satisfied [E0277]
11-
//~| ERROR: impl has stricter requirements than trait
1211
//~| ERROR: the trait bound `F2: Foo<u8>` is not satisfied
1312
self
1413
}

tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.stderr

+2-12
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,6 @@ note: required by a bound in `<Bar as Foo<char>>::foo`
2323
LL | fn foo<F2: Foo<u8>>(self) -> impl Foo<u8> {
2424
| ^^^^^^^ required by this bound in `<Bar as Foo<char>>::foo`
2525

26-
error[E0276]: impl has stricter requirements than trait
27-
--> $DIR/return-dont-satisfy-bounds.rs:8:16
28-
|
29-
LL | fn foo<F2>(self) -> impl Foo<T>;
30-
| -------------------------------- definition of `foo` from trait
31-
...
32-
LL | fn foo<F2: Foo<u8>>(self) -> impl Foo<u8> {
33-
| ^^^^^^^ impl has extra requirement `F2: Foo<u8>`
34-
3526
error[E0277]: the trait bound `Bar: Foo<u8>` is not satisfied
3627
--> $DIR/return-dont-satisfy-bounds.rs:8:34
3728
|
@@ -44,7 +35,6 @@ LL | self
4435
= help: the trait `Foo<char>` is implemented for `Bar`
4536
= help: for that trait implementation, expected `char`, found `u8`
4637

47-
error: aborting due to 4 previous errors
38+
error: aborting due to 3 previous errors
4839

49-
Some errors have detailed explanations: E0276, E0277.
50-
For more information about an error, try `rustc --explain E0276`.
40+
For more information about this error, try `rustc --explain E0277`.

tests/ui/impl-trait/precise-capturing/rpitit-captures-more-method-lifetimes.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ pub trait Foo {
1010
impl Foo for () {
1111
fn bar<'im: 'im>(&'im mut self) -> impl Sized + 'im {}
1212
//~^ ERROR return type captures more lifetimes than trait definition
13-
//~| WARN impl trait in impl method signature does not match trait method signature
1413
}
1514

1615
fn main() {}

tests/ui/impl-trait/precise-capturing/rpitit-captures-more-method-lifetimes.stderr

+1-18
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,5 @@ LL | fn bar<'tr: 'tr>(&'tr mut self) -> impl Sized + use<Self>;
2121
| ^^^^^^^^^^^^^^^^^^^^^^
2222
= note: hidden type inferred to be `impl Sized + 'im`
2323

24-
warning: impl trait in impl method signature does not match trait method signature
25-
--> $DIR/rpitit-captures-more-method-lifetimes.rs:11:40
26-
|
27-
LL | fn bar<'tr: 'tr>(&'tr mut self) -> impl Sized + use<Self>;
28-
| ---------------------- return type from trait method defined here
29-
...
30-
LL | fn bar<'im: 'im>(&'im mut self) -> impl Sized + 'im {}
31-
| ^^^^^^^^^^^^^^^^
32-
|
33-
= note: add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate
34-
= note: we are soliciting feedback, see issue #121718 <https://github.com/rust-lang/rust/issues/121718> for more information
35-
= note: `#[warn(refining_impl_trait_reachable)]` on by default
36-
help: replace the return type so that it matches the trait
37-
|
38-
LL | fn bar<'im: 'im>(&'im mut self) -> impl Sized {}
39-
| ~~~~~~~~~~
40-
41-
error: aborting due to 2 previous errors; 1 warning emitted
24+
error: aborting due to 2 previous errors
4225

0 commit comments

Comments
 (0)