Skip to content

Commit

Permalink
return ty::Error when equating ty::Error
Browse files Browse the repository at this point in the history
This helps iron out a difference between Sub and Equate
  • Loading branch information
compiler-errors committed Feb 19, 2024
1 parent ccb1415 commit 84baf2f
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 95 deletions.
5 changes: 5 additions & 0 deletions compiler/rustc_infer/src/infer/relate/equate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ impl<'tcx> TypeRelation<'tcx> for Equate<'_, '_, 'tcx> {
self.fields.instantiate(a, ty::Invariant, b_id, self.a_is_expected)?;
}

(&ty::Error(e), _) | (_, &ty::Error(e)) => {
infcx.set_tainted_by_errors(e);
return Ok(Ty::new_error(self.tcx(), e));
}

(
&ty::Alias(ty::Opaque, ty::AliasTy { def_id: a_def_id, .. }),
&ty::Alias(ty::Opaque, ty::AliasTy { def_id: b_def_id, .. }),
Expand Down
1 change: 0 additions & 1 deletion tests/ui/generic-associated-types/issue-79636-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ where
//~^ ERROR: missing generics for associated type `Monad::Wrapped`
{
outer.bind(|inner| inner)
//~^ ERROR type annotations needed
}

fn main() {
Expand Down
17 changes: 3 additions & 14 deletions tests/ui/generic-associated-types/issue-79636-1.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,8 @@ help: function arguments must have a statically known size, borrowed types alway
LL | fn bind<B, F>(&self, f: F) -> Self::Wrapped<B> {
| +

error[E0282]: type annotations needed
--> $DIR/issue-79636-1.rs:17:17
|
LL | outer.bind(|inner| inner)
| ^^^^^
|
help: consider giving this closure parameter an explicit type
|
LL | outer.bind(|inner: /* Type */| inner)
| ++++++++++++

error[E0277]: the trait bound `Option<Option<bool>>: Monad` is not satisfied
--> $DIR/issue-79636-1.rs:22:21
--> $DIR/issue-79636-1.rs:21:21
|
LL | assert_eq!(join(Some(Some(true))), Some(true));
| ---- ^^^^^^^^^^^^^^^^ the trait `Monad` is not implemented for `Option<Option<bool>>`
Expand All @@ -63,7 +52,7 @@ LL | where
LL | MOuter: Monad<Unwrapped = MInner>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `join`

error: aborting due to 4 previous errors
error: aborting due to 3 previous errors

Some errors have detailed explanations: E0107, E0277, E0282.
Some errors have detailed explanations: E0107, E0277.
For more information about an error, try `rustc --explain E0107`.
1 change: 0 additions & 1 deletion tests/ui/impl-trait/where-allowed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ fn in_impl_Fn_return_in_parameters(_: &impl Fn() -> impl Debug) { panic!() }
fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() }
//~^ ERROR `impl Trait` is not allowed in the parameters of `Fn` trait bounds
//~| ERROR nested `impl Trait` is not allowed
//~| ERROR: type annotations needed

// Allowed
fn in_impl_Fn_return_in_return() -> &'static impl Fn() -> impl Debug { panic!() }
Expand Down
Loading

0 comments on commit 84baf2f

Please sign in to comment.