Skip to content

Commit 72beda5

Browse files
committed
resolve: Do not show deprecated helper attributes in typo recommendations
Remove one FIXME, addressing it does not reduce the hacky-ness much, and the logic is going to be removed anyway together with the `legacy_derive_helpers` deprecation lint.
1 parent 60dc66f commit 72beda5

File tree

3 files changed

+8
-28
lines changed

3 files changed

+8
-28
lines changed

compiler/rustc_resolve/src/diagnostics.rs

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,28 +1041,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
10411041
}
10421042
}
10431043
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-
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-
}
1044+
// Never recommend deprecated helper attributes.
10661045
}
10671046
Scope::MacroRules(macro_rules_scope) => {
10681047
if let MacroRulesScope::Binding(macro_rules_binding) = macro_rules_scope.get() {

compiler/rustc_resolve/src/ident.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -448,11 +448,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
448448
}
449449
}
450450
Scope::DeriveHelpersCompat => {
451-
// FIXME: Try running this logic earlier, to allocate name bindings for
452-
// legacy derive helpers when creating an attribute invocation with
453-
// following derives. Legacy derive helpers are not common, so it shouldn't
454-
// affect performance. It should also allow to remove the `derives`
455-
// component from `ParentScope`.
456451
let mut result = Err(Determinacy::Determined);
457452
for derive in parent_scope.derives {
458453
let parent_scope = &ParentScope { derives: &[], ..*parent_scope };

tests/ui/proc-macro/proc-macro-attributes.stderr

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ error: cannot find attribute `C` in this scope
22
--> $DIR/proc-macro-attributes.rs:9:3
33
|
44
LL | #[C]
5-
| ^ help: a derive helper attribute with a similar name exists: `B`
5+
| ^
6+
|
7+
help: the derive macro `B` accepts the similarly named `B` attribute
8+
|
9+
LL - #[C]
10+
LL + #[B]
11+
|
612

713
error[E0659]: `B` is ambiguous
814
--> $DIR/proc-macro-attributes.rs:6:3

0 commit comments

Comments
 (0)