1
Fork 0

Rollup merge of #98497 - compiler-errors:span-inference-note, r=lcnr

Improve some inference diagnostics

- Properly point out point location where "type must be known at this point", or else omit the note if it's not associated with a useful span.
- Fix up some type ambiguity diagnostics, errors shouldn't say "cannot infer type for reference `&'a ()`" when the given type has no inference variables.
This commit is contained in:
Guillaume Gomez 2022-07-01 23:39:09 +02:00 committed by GitHub
commit b0935b1ddf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
52 changed files with 195 additions and 135 deletions

View file

@ -1538,9 +1538,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
ty
} else {
if !self.is_tainted_by_errors() {
self.emit_inference_failure_err((**self).body_id, sp, ty.into(), vec![], E0282)
.note("type must be known at this point")
.emit();
self.emit_inference_failure_err(
(**self).body_id,
sp,
ty.into(),
vec![],
E0282,
true,
)
.emit();
}
let err = self.tcx.ty_error();
self.demand_suptype(sp, err, ty);

View file

@ -694,6 +694,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
t.into(),
vec![],
E0282,
false,
)
.emit();
}
@ -708,6 +709,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
c.into(),
vec![],
E0282,
false,
)
.emit();
}