Auto merge of #116089 - estebank:issue-115992-2, r=compiler-errors
When suggesting `self.x` for `S { x }`, use `S { x: self.x }`
Fix #115992.
r? `@compiler-errors`
Follow up to #116086.
This commit is contained in:
@@ -4140,6 +4140,12 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
||||
});
|
||||
}
|
||||
|
||||
fn resolve_expr_field(&mut self, f: &'ast ExprField, e: &'ast Expr) {
|
||||
self.resolve_expr(&f.expr, Some(e));
|
||||
self.visit_ident(f.ident);
|
||||
walk_list!(self, visit_attribute, f.attrs.iter());
|
||||
}
|
||||
|
||||
fn resolve_expr(&mut self, expr: &'ast Expr, parent: Option<&'ast Expr>) {
|
||||
// First, record candidate traits for this expression if it could
|
||||
// result in the invocation of a method call.
|
||||
@@ -4155,7 +4161,19 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
||||
|
||||
ExprKind::Struct(ref se) => {
|
||||
self.smart_resolve_path(expr.id, &se.qself, &se.path, PathSource::Struct);
|
||||
visit::walk_expr(self, expr);
|
||||
// This is the same as `visit::walk_expr(self, expr);`, but we want to pass the
|
||||
// parent in for accurate suggestions when encountering `Foo { bar }` that should
|
||||
// have been `Foo { bar: self.bar }`.
|
||||
if let Some(qself) = &se.qself {
|
||||
self.visit_ty(&qself.ty);
|
||||
}
|
||||
self.visit_path(&se.path, expr.id);
|
||||
walk_list!(self, resolve_expr_field, &se.fields, expr);
|
||||
match &se.rest {
|
||||
StructRest::Base(expr) => self.visit_expr(expr),
|
||||
StructRest::Rest(_span) => {}
|
||||
StructRest::None => {}
|
||||
}
|
||||
}
|
||||
|
||||
ExprKind::Break(Some(label), _) | ExprKind::Continue(Some(label)) => {
|
||||
|
||||
Reference in New Issue
Block a user