11use rustc_abi:: ExternAbi ;
22use rustc_attr_data_structures:: { AttributeKind , ReprAttr } ;
33use rustc_attr_parsing:: AttributeParser ;
4+ use rustc_errors:: Applicability ;
45use rustc_hir:: def:: { DefKind , Res } ;
6+ use rustc_hir:: def_id:: DefId ;
57use rustc_hir:: intravisit:: { FnKind , Visitor } ;
68use rustc_hir:: { AttrArgs , AttrItem , Attribute , GenericParamKind , PatExprKind , PatKind } ;
79use rustc_middle:: hir:: nested_filter:: All ;
@@ -498,14 +500,22 @@ impl NonUpperCaseGlobals {
498500 // We cannot provide meaningful suggestions
499501 // if the characters are in the category of "Lowercase Letter".
500502 let sub = if * name != uc {
501- NonUpperCaseGlobalSub :: Suggestion { span : ident. span , replace : uc. clone ( ) }
503+ NonUpperCaseGlobalSub :: Suggestion {
504+ span : ident. span ,
505+ replace : uc. clone ( ) ,
506+ applicability : if did. is_some ( ) {
507+ Applicability :: MachineApplicable
508+ } else {
509+ Applicability :: MaybeIncorrect
510+ } ,
511+ }
502512 } else {
503513 NonUpperCaseGlobalSub :: Label { span : ident. span }
504514 } ;
505515
506516 struct UsageCollector < ' a , ' tcx > {
507517 cx : & ' tcx LateContext < ' a > ,
508- did : LocalDefId ,
518+ did : DefId ,
509519 collected : Vec < Span > ,
510520 }
511521
@@ -522,7 +532,7 @@ impl NonUpperCaseGlobals {
522532 _id : rustc_hir:: HirId ,
523533 ) -> Self :: Result {
524534 for seg in path. segments {
525- if seg. res . opt_def_id ( ) == Some ( self . did . to_def_id ( ) ) {
535+ if seg. res . opt_def_id ( ) == Some ( self . did ) {
526536 self . collected . push ( seg. ident . span ) ;
527537 }
528538 }
@@ -535,7 +545,8 @@ impl NonUpperCaseGlobals {
535545 let usages = if let Some ( did) = did
536546 && * name != uc
537547 {
538- let mut usage_collector = UsageCollector { cx, did, collected : Vec :: new ( ) } ;
548+ let mut usage_collector =
549+ UsageCollector { cx, did : did. to_def_id ( ) , collected : Vec :: new ( ) } ;
539550 cx. tcx . hir_walk_toplevel_module ( & mut usage_collector) ;
540551 usage_collector
541552 . collected
0 commit comments