1
Fork 0

Rollup merge of #139423 - compiler-errors:field-autoderef, r=oli-obk

Suppress missing field error when autoderef bottoms out in infer

I see this error repeatedly when doing refactorings, and it's pretty misleading b/c it's not the source of the error.
This commit is contained in:
Matthias Krüger 2025-04-10 11:10:14 +02:00 committed by GitHub
commit b131828f0d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 12 deletions

View file

@ -2920,8 +2920,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
// We failed to check the expression, report an error.
// Emits an error if we deref an infer variable, like calling `.field` on a base type of &_.
self.structurally_resolve_type(autoderef.span(), autoderef.final_ty(false));
// Emits an error if we deref an infer variable, like calling `.field` on a base type
// of `&_`. We can also use this to suppress unnecessary "missing field" errors that
// will follow ambiguity errors.
let final_ty = self.structurally_resolve_type(autoderef.span(), autoderef.final_ty(false));
if let ty::Error(_) = final_ty.kind() {
return final_ty;
}
if let Some((adjustments, did)) = private_candidate {
// (#90483) apply adjustments to avoid ExprUseVisitor from