@@ -914,7 +914,7 @@ impl<'a> LoweringContext<'a> {
914914 let qpath = self . lower_qpath ( t. id , qself, path, ParamMode :: Explicit , itctx) ;
915915 let ty = self . ty_path ( id, t. span , qpath) ;
916916 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 ( ) ) ;
918918 }
919919 return ty;
920920 }
@@ -955,7 +955,7 @@ impl<'a> LoweringContext<'a> {
955955 self . elided_lifetime ( t. span )
956956 } ) ;
957957 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 ) ;
959959 }
960960 hir:: TyTraitObject ( bounds, lifetime_bound)
961961 }
@@ -3710,12 +3710,12 @@ impl<'a> LoweringContext<'a> {
37103710 }
37113711 }
37123712
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 ) {
37143714 if self . sess . features . borrow ( ) . dyn_trait {
37153715 self . sess . buffer_lint_with_diagnostic (
37163716 builtin:: BARE_TRAIT_OBJECT , id, span,
37173717 "trait objects without an explicit `dyn` are deprecated" ,
3718- builtin:: BuiltinLintDiagnostics :: BareTraitObject ( span)
3718+ builtin:: BuiltinLintDiagnostics :: BareTraitObject ( span, is_global )
37193719 )
37203720 }
37213721 }
0 commit comments