Skip to content

Commit f473feb

Browse files
Remove the old target checking logic
1 parent 9cda660 commit f473feb

File tree

8 files changed

+133
-1297
lines changed

8 files changed

+133
-1297
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
@@ -232,12 +232,7 @@ impl<'a> Visitor<'a> for CollectProcMacros<'a> {
232232
let fn_ident = if let ast::ItemKind::Fn(fn_) = &item.kind {
233233
fn_.ident
234234
} else {
235-
self.dcx
236-
.create_err(errors::AttributeOnlyBeUsedOnBareFunctions {
237-
span: attr.span,
238-
path: &pprust::path_to_string(&attr.get_normal_item().path),
239-
})
240-
.emit();
235+
// Error handled by general target checking logic
241236
return;
242237
};
243238

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_passes/messages.ftl

Lines changed: 3 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,6 @@ passes_abi_ne =
1313
passes_abi_of =
1414
fn_abi_of({$fn_name}) = {$fn_abi}
1515
16-
passes_align_attr_application =
17-
`#[rustc_align(...)]` should be applied to a function item
18-
.label = not a function item
19-
20-
passes_align_on_fields =
21-
attribute should be applied to a function or method
22-
.warn = {-passes_previously_accepted}
23-
24-
passes_align_should_be_repr_align =
25-
`#[rustc_align(...)]` is not supported on {$item} items
26-
.suggestion = use `#[repr(align(...))]` instead
27-
28-
passes_allow_incoherent_impl =
29-
`rustc_allow_incoherent_impl` attribute should be applied to impl items
30-
.label = the only currently supported targets are inherent methods
31-
32-
passes_allow_internal_unstable =
33-
attribute should be applied to a macro
34-
.label = not a macro
35-
3616
passes_attr_application_enum =
3717
attribute should be applied to an enum
3818
.label = not an enum
@@ -78,18 +58,10 @@ passes_change_fields_to_be_of_unit_type =
7858
*[other] fields
7959
}
8060
81-
passes_cold =
82-
{passes_should_be_applied_to_fn}
83-
.warn = {-passes_previously_accepted}
84-
.label = {passes_should_be_applied_to_fn.label}
85-
8661
passes_collapse_debuginfo =
8762
`collapse_debuginfo` attribute should be applied to macro definitions
8863
.label = not a macro definition
8964
90-
passes_confusables = attribute should be applied to an inherent method
91-
.label = not an inherent method
92-
9365
passes_const_continue_attr =
9466
`#[const_continue]` should be applied to a break expression
9567
.label = not a break expression
@@ -98,16 +70,6 @@ passes_const_stable_not_stable =
9870
attribute `#[rustc_const_stable]` can only be applied to functions that are declared `#[stable]`
9971
.label = attribute specified here
10072
101-
passes_coroutine_on_non_closure =
102-
attribute should be applied to closures
103-
.label = not a closure
104-
105-
passes_coverage_attribute_not_allowed =
106-
coverage attribute not allowed here
107-
.not_fn_impl_mod = not a function, impl block, or module
108-
.no_body = function has no body
109-
.help = coverage attribute can be applied to a function (with body), impl block, or module
110-
11173
passes_dead_codes =
11274
{ $multiple ->
11375
*[true] multiple {$descr}s are
@@ -129,9 +91,6 @@ passes_debug_visualizer_placement =
12991
passes_debug_visualizer_unreadable =
13092
couldn't read {$file}: {$error}
13193
132-
passes_deprecated =
133-
attribute is ignored here
134-
13594
passes_deprecated_annotation_has_no_effect =
13695
this `#[deprecated]` annotation has no effect
13796
.suggestion = remove the unnecessary deprecation attribute
@@ -304,10 +263,6 @@ passes_duplicate_lang_item_crate_depends =
304263
passes_enum_variant_same_name =
305264
it is impossible to refer to the {$dead_descr} `{$dead_name}` because it is shadowed by this enum variant with the same name
306265
307-
passes_export_name =
308-
attribute should be applied to a free function, impl method or static
309-
.label = not a free function, impl method or static
310-
311266
passes_extern_main =
312267
the `main` function cannot be declared in an `extern` block
313268
@@ -317,21 +272,10 @@ passes_feature_previously_declared =
317272
passes_feature_stable_twice =
318273
feature `{$feature}` is declared stable since {$since}, but was previously declared stable since {$prev_since}
319274
320-
passes_ffi_const_invalid_target =
321-
`#[ffi_const]` may only be used on foreign functions
322-
323-
passes_ffi_pure_invalid_target =
324-
`#[ffi_pure]` may only be used on foreign functions
325-
326275
passes_has_incoherent_inherent_impl =
327276
`rustc_has_incoherent_inherent_impls` attribute should be applied to types or traits
328277
.label = only adts, extern types and traits are supported
329278
330-
passes_ignored_attr =
331-
`#[{$sym}]` is ignored on struct fields and match arms
332-
.warn = {-passes_previously_accepted}
333-
.note = {-passes_see_issue(issue: "80564")}
334-
335279
passes_ignored_attr_with_macro =
336280
`#[{$sym}]` is ignored on struct fields, match arms and macro defs
337281
.warn = {-passes_previously_accepted}
@@ -358,7 +302,7 @@ passes_incorrect_do_not_recommend_location =
358302
`#[diagnostic::do_not_recommend]` can only be placed on trait implementations
359303
360304
passes_incorrect_target =
361-
`{$name}` lang item must be applied to a {$kind} with {$at_least ->
305+
`{$name}` lang item must be applied to {$kind} with {$at_least ->
362306
[true] at least {$num}
363307
*[false] {$num}
364308
} generic {$num ->
@@ -373,22 +317,10 @@ passes_incorrect_target =
373317
passes_ineffective_unstable_impl = an `#[unstable]` annotation here has no effect
374318
.note = see issue #55436 <https://github.com/rust-lang/rust/issues/55436> for more information
375319
376-
passes_inline_ignored_constants =
377-
`#[inline]` is ignored on constants
378-
.warn = {-passes_previously_accepted}
379-
.note = {-passes_see_issue(issue: "65833")}
380-
381320
passes_inline_ignored_for_exported =
382321
`#[inline]` is ignored on externally exported functions
383322
.help = externally exported functions are functions with `#[no_mangle]`, `#[export_name]`, or `#[linkage]`
384323
385-
passes_inline_ignored_function_prototype =
386-
`#[inline]` is ignored on function prototypes
387-
388-
passes_inline_not_fn_or_closure =
389-
attribute should be applied to function or closure
390-
.label = not a function or closure
391-
392324
passes_inner_crate_level_attr =
393325
crate-level attribute should be in the root module
394326
@@ -438,21 +370,6 @@ passes_link =
438370
.warn = {-passes_previously_accepted}
439371
.label = not an `extern` block
440372
441-
passes_link_name =
442-
attribute should be applied to a foreign function or static
443-
.warn = {-passes_previously_accepted}
444-
.label = not a foreign function or static
445-
.help = try `#[link(name = "{$value}")]` instead
446-
447-
passes_link_ordinal =
448-
attribute should be applied to a foreign function or static
449-
.label = not a foreign function or static
450-
451-
passes_link_section =
452-
attribute should be applied to a function or static
453-
.warn = {-passes_previously_accepted}
454-
.label = not a function or static
455-
456373
passes_linkage =
457374
attribute should be applied to a function or static
458375
.label = not a function definition or static
@@ -468,9 +385,6 @@ passes_macro_export_on_decl_macro =
468385
`#[macro_export]` has no effect on declarative macro definitions
469386
.note = declarative macros follow the same exporting rules as regular items
470387
471-
passes_macro_use =
472-
`#[{$name}]` only has an effect on `extern crate` and modules
473-
474388
passes_may_dangle =
475389
`#[may_dangle]` must be applied to a lifetime or type generic parameter in `Drop` impl
476390
@@ -509,7 +423,7 @@ passes_must_not_suspend =
509423
.label = is not a struct, enum, union, or trait
510424
511425
passes_must_use_no_effect =
512-
`#[must_use]` has no effect when applied to {$article} {$target}
426+
`#[must_use]` has no effect when applied to {$target}
513427
514428
passes_no_link =
515429
attribute should be applied to an `extern crate` item
@@ -529,18 +443,6 @@ passes_no_main_function =
529443
.teach_note = If you don't know the basics of Rust, you can go look to the Rust Book to get started: https://doc.rust-lang.org/book/
530444
.non_function_main = non-function item at `crate::main` is found
531445
532-
passes_no_mangle =
533-
attribute should be applied to a free function, impl method or static
534-
.warn = {-passes_previously_accepted}
535-
.label = not a free function, impl method or static
536-
537-
passes_no_mangle_foreign =
538-
`#[no_mangle]` has no effect on a foreign {$foreign_item_kind}
539-
.warn = {-passes_previously_accepted}
540-
.label = foreign {$foreign_item_kind}
541-
.note = symbol names in extern blocks are not mangled
542-
.suggestion = remove this attribute
543-
544446
passes_no_sanitize =
545447
`#[no_sanitize({$attr_str})]` should be applied to {$accepted_kind}
546448
.label = not {$accepted_kind}
@@ -556,19 +458,6 @@ passes_non_exported_macro_invalid_attrs =
556458
passes_object_lifetime_err =
557459
{$repr}
558460
559-
passes_only_has_effect_on =
560-
`#[{$attr_name}]` only has an effect on {$target_name ->
561-
[function] functions
562-
[module] modules
563-
[trait_implementation_block] trait implementation blocks
564-
[inherent_implementation_block] inherent implementation blocks
565-
*[unspecified] (unspecified--this is a compiler bug)
566-
}
567-
568-
passes_optimize_invalid_target =
569-
attribute applied to an invalid target
570-
.label = invalid target
571-
572461
passes_outer_crate_level_attr =
573462
crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
574463
@@ -584,10 +473,6 @@ passes_parent_info =
584473
*[other] {$descr}s
585474
} in this {$parent_descr}
586475
587-
passes_pass_by_value =
588-
`pass_by_value` attribute should be applied to a struct, enum or type alias
589-
.label = is not a struct, enum or type alias
590-
591476
passes_proc_macro_bad_sig = {$kind} has incorrect signature
592477
593478
passes_remove_fields =
@@ -604,7 +489,7 @@ passes_repr_align_greater_than_target_max =
604489
.note = `isize::MAX` is {$size} for the current target
605490
606491
passes_repr_align_should_be_align =
607-
`#[repr(align(...))]` is not supported on {$item} items
492+
`#[repr(align(...))]` is not supported on {$item}
608493
.help = use `#[rustc_align(...)]` instead
609494
610495
passes_repr_conflicting =
@@ -619,18 +504,10 @@ passes_rustc_const_stable_indirect_pairing =
619504
passes_rustc_dirty_clean =
620505
attribute requires -Z query-dep-graph to be enabled
621506
622-
passes_rustc_force_inline =
623-
attribute should be applied to a function
624-
.label = not a function definition
625-
626507
passes_rustc_force_inline_coro =
627508
attribute cannot be applied to a `async`, `gen` or `async gen` function
628509
.label = `async`, `gen` or `async gen` function
629510
630-
passes_rustc_layout_scalar_valid_range_not_struct =
631-
attribute should be applied to a struct
632-
.label = not a struct
633-
634511
passes_rustc_legacy_const_generics_index =
635512
#[rustc_legacy_const_generics] must have one index for each generic parameter
636513
.label = generic parameters
@@ -664,14 +541,6 @@ passes_rustc_pub_transparent =
664541
attribute should be applied to `#[repr(transparent)]` types
665542
.label = not a `#[repr(transparent)]` type
666543
667-
passes_rustc_std_internal_symbol =
668-
attribute should be applied to functions or statics
669-
.label = not a function or static
670-
671-
passes_rustc_unstable_feature_bound =
672-
attribute should be applied to `impl` or free function outside of any `impl` or trait
673-
.label = not an `impl` or free function
674-
675544
passes_should_be_applied_to_fn =
676545
attribute should be applied to a function definition
677546
.label = {$on_crate ->
@@ -683,24 +552,12 @@ passes_should_be_applied_to_static =
683552
attribute should be applied to a static
684553
.label = not a static
685554
686-
passes_should_be_applied_to_struct_enum =
687-
attribute should be applied to a struct or enum
688-
.label = not a struct or enum
689-
690555
passes_should_be_applied_to_trait =
691556
attribute should be applied to a trait
692557
.label = not a trait
693558
694-
passes_stability_promotable =
695-
attribute cannot be applied to an expression
696-
697559
passes_string_interpolation_only_works = string interpolation only works in `format!` invocations
698560
699-
passes_target_feature_on_statement =
700-
{passes_should_be_applied_to_fn}
701-
.warn = {-passes_previously_accepted}
702-
.label = {passes_should_be_applied_to_fn.label}
703-
704561
passes_trait_impl_const_stability_mismatch = const stability on the impl does not match the const stability on the trait
705562
passes_trait_impl_const_stability_mismatch_impl_stable = this impl is (implicitly) stable...
706563
passes_trait_impl_const_stability_mismatch_impl_unstable = this impl is unstable...
@@ -825,11 +682,6 @@ passes_unused_variable_try_prefix = unused variable: `{$name}`
825682
.label = unused variable
826683
.suggestion = if this is intentional, prefix it with an underscore
827684
828-
829-
passes_used_static =
830-
attribute must be applied to a `static` variable
831-
.label = but this is a {$target}
832-
833685
passes_useless_assignment =
834686
useless assignment of {$is_field_assign ->
835687
[true] field

0 commit comments

Comments
 (0)