@@ -1016,16 +1016,14 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1016
1016
. emit ( )
1017
1017
}
1018
1018
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 (
1021
1020
& mut self ,
1021
+ suggestions : & mut Vec < TypoSuggestion > ,
1022
1022
scope_set : ScopeSet < ' ra > ,
1023
1023
parent_scope : & ParentScope < ' ra > ,
1024
- ident : Ident ,
1024
+ ctxt : SyntaxContext ,
1025
1025
filter_fn : & impl Fn ( Res ) -> bool ,
1026
- ) -> Option < TypoSuggestion > {
1027
- let mut suggestions = Vec :: new ( ) ;
1028
- let ctxt = ident. span . ctxt ( ) ;
1026
+ ) {
1029
1027
self . cm ( ) . visit_scopes ( scope_set, parent_scope, ctxt, |this, scope, use_prelude, _| {
1030
1028
match scope {
1031
1029
Scope :: DeriveHelpers ( expn_id) => {
@@ -1041,28 +1039,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1041
1039
}
1042
1040
}
1043
1041
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.
1066
1043
}
1067
1044
Scope :: MacroRules ( macro_rules_scope) => {
1068
1045
if let MacroRulesScope :: Binding ( macro_rules_binding) = macro_rules_scope. get ( ) {
@@ -1076,7 +1053,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1076
1053
}
1077
1054
}
1078
1055
Scope :: Module ( module, _) => {
1079
- this. add_module_candidates ( module, & mut suggestions, filter_fn, None ) ;
1056
+ this. add_module_candidates ( module, suggestions, filter_fn, None ) ;
1080
1057
}
1081
1058
Scope :: MacroUsePrelude => {
1082
1059
suggestions. extend ( this. macro_use_prelude . iter ( ) . filter_map (
@@ -1134,6 +1111,19 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1134
1111
1135
1112
None :: < ( ) >
1136
1113
} ) ;
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) ;
1137
1127
1138
1128
// Make sure error reporting is deterministic.
1139
1129
suggestions. sort_by ( |a, b| a. candidate . as_str ( ) . cmp ( b. candidate . as_str ( ) ) ) ;
0 commit comments