@@ -1016,16 +1016,14 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
10161016 . emit ( )
10171017 }
10181018
1019- /// Lookup typo candidate in scope for a macro or import.
1020- fn early_lookup_typo_candidate (
1019+ pub ( crate ) fn add_scope_set_candidates (
10211020 & mut self ,
1021+ suggestions : & mut Vec < TypoSuggestion > ,
10221022 scope_set : ScopeSet < ' ra > ,
10231023 parent_scope : & ParentScope < ' ra > ,
1024- ident : Ident ,
1024+ ctxt : SyntaxContext ,
10251025 filter_fn : & impl Fn ( Res ) -> bool ,
1026- ) -> Option < TypoSuggestion > {
1027- let mut suggestions = Vec :: new ( ) ;
1028- let ctxt = ident. span . ctxt ( ) ;
1026+ ) {
10291027 self . cm ( ) . visit_scopes ( scope_set, parent_scope, ctxt, |this, scope, use_prelude, _| {
10301028 match scope {
10311029 Scope :: DeriveHelpers ( expn_id) => {
@@ -1041,28 +1039,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
10411039 }
10421040 }
10431041 Scope :: DeriveHelpersCompat => {
1044- let res = Res :: NonMacroAttr ( NonMacroAttrKind :: DeriveHelperCompat ) ;
1045- if filter_fn ( res) {
1046- for derive in parent_scope. derives {
1047- let parent_scope = & ParentScope { derives : & [ ] , ..* parent_scope } ;
1048- let Ok ( ( Some ( ext) , _) ) = this. reborrow ( ) . resolve_macro_path (
1049- derive,
1050- Some ( MacroKind :: Derive ) ,
1051- parent_scope,
1052- false ,
1053- false ,
1054- None ,
1055- None ,
1056- ) else {
1057- continue ;
1058- } ;
1059- suggestions. extend (
1060- ext. helper_attrs
1061- . iter ( )
1062- . map ( |name| TypoSuggestion :: typo_from_name ( * name, res) ) ,
1063- ) ;
1064- }
1065- }
1042+ // Never recommend deprecated helper attributes.
10661043 }
10671044 Scope :: MacroRules ( macro_rules_scope) => {
10681045 if let MacroRulesScope :: Binding ( macro_rules_binding) = macro_rules_scope. get ( ) {
@@ -1076,7 +1053,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
10761053 }
10771054 }
10781055 Scope :: Module ( module, _) => {
1079- this. add_module_candidates ( module, & mut suggestions, filter_fn, None ) ;
1056+ this. add_module_candidates ( module, suggestions, filter_fn, None ) ;
10801057 }
10811058 Scope :: MacroUsePrelude => {
10821059 suggestions. extend ( this. macro_use_prelude . iter ( ) . filter_map (
@@ -1134,6 +1111,19 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
11341111
11351112 None :: < ( ) >
11361113 } ) ;
1114+ }
1115+
1116+ /// Lookup typo candidate in scope for a macro or import.
1117+ fn early_lookup_typo_candidate (
1118+ & mut self ,
1119+ scope_set : ScopeSet < ' ra > ,
1120+ parent_scope : & ParentScope < ' ra > ,
1121+ ident : Ident ,
1122+ filter_fn : & impl Fn ( Res ) -> bool ,
1123+ ) -> Option < TypoSuggestion > {
1124+ let mut suggestions = Vec :: new ( ) ;
1125+ let ctxt = ident. span . ctxt ( ) ;
1126+ self . add_scope_set_candidates ( & mut suggestions, scope_set, parent_scope, ctxt, filter_fn) ;
11371127
11381128 // Make sure error reporting is deterministic.
11391129 suggestions. sort_by ( |a, b| a. candidate . as_str ( ) . cmp ( b. candidate . as_str ( ) ) ) ;
0 commit comments