@@ -914,7 +914,7 @@ impl<'a> LoweringContext<'a> {
914
914
let qpath = self . lower_qpath ( t. id , qself, path, ParamMode :: Explicit , itctx) ;
915
915
let ty = self . ty_path ( id, t. span , qpath) ;
916
916
if let hir:: TyTraitObject ( ..) = ty. node {
917
- self . maybe_lint_bare_trait ( t. span , t. id ) ;
917
+ self . maybe_lint_bare_trait ( t. span , t. id , qself . is_none ( ) && path . is_global ( ) ) ;
918
918
}
919
919
return ty;
920
920
}
@@ -955,7 +955,7 @@ impl<'a> LoweringContext<'a> {
955
955
self . elided_lifetime ( t. span )
956
956
} ) ;
957
957
if kind != TraitObjectSyntax :: Dyn {
958
- self . maybe_lint_bare_trait ( t. span , t. id ) ;
958
+ self . maybe_lint_bare_trait ( t. span , t. id , false ) ;
959
959
}
960
960
hir:: TyTraitObject ( bounds, lifetime_bound)
961
961
}
@@ -3710,12 +3710,12 @@ impl<'a> LoweringContext<'a> {
3710
3710
}
3711
3711
}
3712
3712
3713
- fn maybe_lint_bare_trait ( & self , span : Span , id : NodeId ) {
3713
+ fn maybe_lint_bare_trait ( & self , span : Span , id : NodeId , is_global : bool ) {
3714
3714
if self . sess . features . borrow ( ) . dyn_trait {
3715
3715
self . sess . buffer_lint_with_diagnostic (
3716
3716
builtin:: BARE_TRAIT_OBJECT , id, span,
3717
3717
"trait objects without an explicit `dyn` are deprecated" ,
3718
- builtin:: BuiltinLintDiagnostics :: BareTraitObject ( span)
3718
+ builtin:: BuiltinLintDiagnostics :: BareTraitObject ( span, is_global )
3719
3719
)
3720
3720
}
3721
3721
}
0 commit comments