Skip to content

Commit

Permalink
Deeply normalize type trace in type error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Oct 24, 2024
1 parent 1920c66 commit 4217b87
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1252,8 +1252,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
}
let (expected_found, exp_found, is_simple_error, values) = match values {
None => (None, Mismatch::Fixed("type"), false, None),
Some(ty::ParamEnvAnd { param_env: _, value: values }) => {
Some(ty::ParamEnvAnd { param_env, value: values }) => {
let mut values = self.resolve_vars_if_possible(values);
if self.next_trait_solver() {
values = deeply_normalize_for_diagnostics(self, param_env, values);
}
let (is_simple_error, exp_found) = match values {
ValuePairs::Terms(ExpectedFound { expected, found }) => {
match (expected.unpack(), found.unpack()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//@ compile-flags: -Znext-solver

// Make sure we try to mention a deeply normalized type in a type mismatch error.

trait Mirror {
type Assoc;
}
impl<T> Mirror for T {
type Assoc = T;
}

fn needs<T>(_: <T as Mirror>::Assoc) {}

fn main() {
needs::<i32>(());
//~^ ERROR mismatched types
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
error[E0308]: mismatched types
--> $DIR/deeply-normalize-type-expectation.rs:15:18
|
LL | needs::<i32>(());
| ------------ ^^ expected `i32`, found `()`
| |
| arguments to this function are incorrect
|
note: function defined here
--> $DIR/deeply-normalize-type-expectation.rs:12:4
|
LL | fn needs<T>(_: <T as Mirror>::Assoc) {}
| ^^^^^ -----------------------

error: aborting due to 1 previous error

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

0 comments on commit 4217b87

Please sign in to comment.