Skip to content

Commit 2824f25

Browse files
Remove the old target checking logic
1 parent 33ad3c8 commit 2824f25

File tree

10 files changed

+133
-1324
lines changed

10 files changed

+133
-1324
lines changed

compiler/rustc_builtin_macros/messages.ftl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,6 @@ builtin_macros_only_one_argument = {$name} takes 1 argument
259259
260260
builtin_macros_proc_macro = `proc-macro` crate types currently cannot export any items other than functions tagged with `#[proc_macro]`, `#[proc_macro_derive]`, or `#[proc_macro_attribute]`
261261
262-
builtin_macros_proc_macro_attribute_only_be_used_on_bare_functions = the `#[{$path}]` attribute may only be used on bare functions
263-
264262
builtin_macros_proc_macro_attribute_only_usable_with_crate_type = the `#[{$path}]` attribute is only usable with crates of the `proc-macro` crate type
265263
266264
builtin_macros_requires_cfg_pattern =

compiler/rustc_builtin_macros/src/errors.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -905,14 +905,6 @@ pub(crate) struct TakesNoArguments<'a> {
905905
pub name: &'a str,
906906
}
907907

908-
#[derive(Diagnostic)]
909-
#[diag(builtin_macros_proc_macro_attribute_only_be_used_on_bare_functions)]
910-
pub(crate) struct AttributeOnlyBeUsedOnBareFunctions<'a> {
911-
#[primary_span]
912-
pub span: Span,
913-
pub path: &'a str,
914-
}
915-
916908
#[derive(Diagnostic)]
917909
#[diag(builtin_macros_proc_macro_attribute_only_usable_with_crate_type)]
918910
pub(crate) struct AttributeOnlyUsableWithCrateType<'a> {

compiler/rustc_builtin_macros/src/proc_macro_harness.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,7 @@ impl<'a> Visitor<'a> for CollectProcMacros<'a> {
231231
let fn_ident = if let ast::ItemKind::Fn(fn_) = &item.kind {
232232
fn_.ident
233233
} else {
234-
self.dcx
235-
.create_err(errors::AttributeOnlyBeUsedOnBareFunctions {
236-
span: attr.span,
237-
path: &pprust::path_to_string(&attr.get_normal_item().path),
238-
})
239-
.emit();
234+
// Error handled by general target checking logic
240235
return;
241236
};
242237

compiler/rustc_error_codes/src/error_codes/E0518.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
#### Note: this error code is no longer emitted by the compiler.
2+
13
An `#[inline(..)]` attribute was incorrectly placed on something other than a
24
function or method.
35

46
Example of erroneous code:
57

6-
```compile_fail,E0518
8+
```ignore (no longer emitted)
79
#[inline(always)]
810
struct Foo;
911

compiler/rustc_hir/src/hir.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,6 +1233,13 @@ impl Attribute {
12331233
_ => None,
12341234
}
12351235
}
1236+
1237+
pub fn is_parsed_attr(&self) -> bool {
1238+
match self {
1239+
Attribute::Parsed(_) => true,
1240+
Attribute::Unparsed(_) => false,
1241+
}
1242+
}
12361243
}
12371244

12381245
impl AttributeExt for Attribute {
@@ -1303,13 +1310,8 @@ impl AttributeExt for Attribute {
13031310
match &self {
13041311
Attribute::Unparsed(u) => u.span,
13051312
// FIXME: should not be needed anymore when all attrs are parsed
1306-
Attribute::Parsed(AttributeKind::Deprecation { span, .. }) => *span,
13071313
Attribute::Parsed(AttributeKind::DocComment { span, .. }) => *span,
1308-
Attribute::Parsed(AttributeKind::MacroUse { span, .. }) => *span,
1309-
Attribute::Parsed(AttributeKind::MayDangle(span)) => *span,
1310-
Attribute::Parsed(AttributeKind::Ignore { span, .. }) => *span,
1311-
Attribute::Parsed(AttributeKind::ShouldPanic { span, .. }) => *span,
1312-
Attribute::Parsed(AttributeKind::AutomaticallyDerived(span)) => *span,
1314+
Attribute::Parsed(AttributeKind::Deprecation { span, .. }) => *span,
13131315
a => panic!("can't get the span of an arbitrary parsed attribute: {a:?}"),
13141316
}
13151317
}

compiler/rustc_lint/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ fn register_builtins(store: &mut LintStore) {
364364
store.register_renamed("static_mut_ref", "static_mut_refs");
365365
store.register_renamed("temporary_cstring_as_ptr", "dangling_pointers_from_temporaries");
366366
store.register_renamed("elided_named_lifetimes", "mismatched_lifetime_syntaxes");
367+
store.register_renamed("useless_deprecated", "unused_attributes");
367368

368369
// These were moved to tool lints, but rustc still sees them when compiling normally, before
369370
// tool lints are registered, so `check_tool_name_for_backwards_compat` doesn't work. Use

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ declare_lint_pass! {
141141
UNUSED_QUALIFICATIONS,
142142
UNUSED_UNSAFE,
143143
UNUSED_VARIABLES,
144-
USELESS_DEPRECATED,
145144
WARNINGS,
146145
// tidy-alphabetical-end
147146
]
@@ -2708,32 +2707,6 @@ declare_lint! {
27082707
report_in_external_macro
27092708
}
27102709

2711-
declare_lint! {
2712-
/// The `useless_deprecated` lint detects deprecation attributes with no effect.
2713-
///
2714-
/// ### Example
2715-
///
2716-
/// ```rust,compile_fail
2717-
/// struct X;
2718-
///
2719-
/// #[deprecated = "message"]
2720-
/// impl Default for X {
2721-
/// fn default() -> Self {
2722-
/// X
2723-
/// }
2724-
/// }
2725-
/// ```
2726-
///
2727-
/// {{produces}}
2728-
///
2729-
/// ### Explanation
2730-
///
2731-
/// Deprecation attributes have no effect on trait implementations.
2732-
pub USELESS_DEPRECATED,
2733-
Deny,
2734-
"detects deprecation attributes with no effect",
2735-
}
2736-
27372710
declare_lint! {
27382711
/// The `ineffective_unstable_trait_impl` lint detects `#[unstable]` attributes which are not used.
27392712
///

0 commit comments

Comments
 (0)