Skip to content

Commit

Permalink
Rollup merge of rust-lang#121319 - compiler-errors:err, r=oli-obk
Browse files Browse the repository at this point in the history
return `ty::Error` when equating `ty::Error`

This helps iron out a difference in diagnostics between `Sub` and `Equate` relations, which I'm currently trying to unify.

r? oli-obk
  • Loading branch information
Noratrieb committed Feb 20, 2024
2 parents 9788b19 + 84baf2f commit 599768d
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 @@ -90,6 +90,11 @@ impl<'tcx> TypeRelation<'tcx> for Equate<'_, '_, 'tcx> {
infcx.instantiate_ty_var(self, !self.a_is_expected, b_vid, ty::Invariant, a)?;
}

(&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 599768d

Please sign in to comment.