Point out why a trait is expected on Struct + 'lt
This commit is contained in:
@@ -384,6 +384,8 @@ struct DiagnosticMetadata<'ast> {
|
||||
|
||||
/// Used to detect possible `if let` written without `let` and to provide structured suggestion.
|
||||
in_if_condition: Option<&'ast Expr>,
|
||||
|
||||
current_trait_object: Option<&'ast [ast::GenericBound]>,
|
||||
}
|
||||
|
||||
struct LateResolutionVisitor<'a, 'b, 'ast> {
|
||||
@@ -453,6 +455,7 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
|
||||
self.diagnostic_metadata.current_let_binding = original;
|
||||
}
|
||||
fn visit_ty(&mut self, ty: &'ast Ty) {
|
||||
let prev = self.diagnostic_metadata.current_trait_object;
|
||||
match ty.kind {
|
||||
TyKind::Path(ref qself, ref path) => {
|
||||
self.smart_resolve_path(ty.id, qself.as_ref(), path, PathSource::Type);
|
||||
@@ -464,9 +467,13 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
|
||||
.map_or(Res::Err, |d| d.res());
|
||||
self.r.record_partial_res(ty.id, PartialRes::new(res));
|
||||
}
|
||||
TyKind::TraitObject(ref bounds, ..) => {
|
||||
self.diagnostic_metadata.current_trait_object = Some(&bounds[..]);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
visit::walk_ty(self, ty);
|
||||
self.diagnostic_metadata.current_trait_object = prev;
|
||||
}
|
||||
fn visit_poly_trait_ref(&mut self, tref: &'ast PolyTraitRef, m: &'ast TraitBoundModifier) {
|
||||
self.smart_resolve_path(
|
||||
|
||||
Reference in New Issue
Block a user