Skip to content

Commit cbfae9a

Browse files
Make OnDuplicate::Error the default
1 parent 887a3f3 commit cbfae9a

23 files changed

Lines changed: 5 additions & 132 deletions

compiler/rustc_attr_parsing/src/attributes/autodiff.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use rustc_hir::{MethodKind, Target};
88
use rustc_span::{Symbol, sym};
99
use thin_vec::ThinVec;
1010

11+
use crate::attributes::SingleAttributeParser;
1112
use crate::attributes::prelude::Allow;
12-
use crate::attributes::{OnDuplicate, SingleAttributeParser};
1313
use crate::context::{AcceptContext, Stage};
1414
use crate::parser::{ArgParser, MetaItemOrLitParser};
1515
use crate::target_checking::AllowedTargets;
@@ -18,7 +18,6 @@ pub(crate) struct RustcAutodiffParser;
1818

1919
impl<S: Stage> SingleAttributeParser<S> for RustcAutodiffParser {
2020
const PATH: &[Symbol] = &[sym::rustc_autodiff];
21-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
2221
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
2322
Allow(Target::Fn),
2423
Allow(Target::Method(MethodKind::Inherent)),

compiler/rustc_attr_parsing/src/attributes/body.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ pub(crate) struct CoroutineParser;
66

77
impl<S: Stage> NoArgsAttributeParser<S> for CoroutineParser {
88
const PATH: &[Symbol] = &[sym::coroutine];
9-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
109
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Closure)]);
1110
const CREATE: fn(rustc_span::Span) -> AttributeKind = |span| AttributeKind::Coroutine(span);
1211
}

compiler/rustc_attr_parsing/src/attributes/cfi_encoding.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ impl<S: Stage> SingleAttributeParser<S> for CfiEncodingParser {
88
Allow(Target::Enum),
99
Allow(Target::Union),
1010
]);
11-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
1211
const TEMPLATE: AttributeTemplate = template!(NameValueStr: "encoding");
1312

1413
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {

compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ pub(crate) struct OptimizeParser;
1212

1313
impl<S: Stage> SingleAttributeParser<S> for OptimizeParser {
1414
const PATH: &[Symbol] = &[sym::optimize];
15-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
1615
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
1716
Allow(Target::Fn),
1817
Allow(Target::Closure),
@@ -60,7 +59,6 @@ pub(crate) struct CoverageParser;
6059

6160
impl<S: Stage> SingleAttributeParser<S> for CoverageParser {
6261
const PATH: &[Symbol] = &[sym::coverage];
63-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
6462
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
6563
Allow(Target::Fn),
6664
Allow(Target::Closure),
@@ -140,7 +138,6 @@ pub(crate) struct RustcObjcClassParser;
140138

141139
impl<S: Stage> SingleAttributeParser<S> for RustcObjcClassParser {
142140
const PATH: &[rustc_span::Symbol] = &[sym::rustc_objc_class];
143-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
144141
const ALLOWED_TARGETS: AllowedTargets =
145142
AllowedTargets::AllowList(&[Allow(Target::ForeignStatic)]);
146143
const TEMPLATE: AttributeTemplate = template!(NameValueStr: "ClassName");
@@ -172,7 +169,6 @@ pub(crate) struct RustcObjcSelectorParser;
172169

173170
impl<S: Stage> SingleAttributeParser<S> for RustcObjcSelectorParser {
174171
const PATH: &[rustc_span::Symbol] = &[sym::rustc_objc_selector];
175-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
176172
const ALLOWED_TARGETS: AllowedTargets =
177173
AllowedTargets::AllowList(&[Allow(Target::ForeignStatic)]);
178174
const TEMPLATE: AttributeTemplate = template!(NameValueStr: "methodName");
@@ -585,8 +581,6 @@ impl<S: Stage> SingleAttributeParser<S> for SanitizeParser {
585581
r#"realtime = "nonblocking|blocking|caller""#,
586582
]);
587583

588-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
589-
590584
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
591585
let Some(list) = args.list() else {
592586
let attr_span = cx.attr_span;
@@ -689,7 +683,6 @@ pub(crate) struct ThreadLocalParser;
689683

690684
impl<S: Stage> NoArgsAttributeParser<S> for ThreadLocalParser {
691685
const PATH: &[Symbol] = &[sym::thread_local];
692-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
693686
const ALLOWED_TARGETS: AllowedTargets =
694687
AllowedTargets::AllowList(&[Allow(Target::Static), Allow(Target::ForeignStatic)]);
695688
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::ThreadLocal;
@@ -699,7 +692,6 @@ pub(crate) struct RustcPassIndirectlyInNonRusticAbisParser;
699692

700693
impl<S: Stage> NoArgsAttributeParser<S> for RustcPassIndirectlyInNonRusticAbisParser {
701694
const PATH: &[Symbol] = &[sym::rustc_pass_indirectly_in_non_rustic_abis];
702-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
703695
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Struct)]);
704696
const CREATE: fn(Span) -> AttributeKind = AttributeKind::RustcPassIndirectlyInNonRusticAbis;
705697
}
@@ -708,7 +700,6 @@ pub(crate) struct RustcEiiForeignItemParser;
708700

709701
impl<S: Stage> NoArgsAttributeParser<S> for RustcEiiForeignItemParser {
710702
const PATH: &[Symbol] = &[sym::rustc_eii_foreign_item];
711-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
712703
const ALLOWED_TARGETS: AllowedTargets =
713704
AllowedTargets::AllowList(&[Allow(Target::ForeignFn), Allow(Target::ForeignStatic)]);
714705
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcEiiForeignItem;
@@ -718,7 +709,6 @@ pub(crate) struct PatchableFunctionEntryParser;
718709

719710
impl<S: Stage> SingleAttributeParser<S> for PatchableFunctionEntryParser {
720711
const PATH: &[Symbol] = &[sym::patchable_function_entry];
721-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
722712
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]);
723713
const TEMPLATE: AttributeTemplate = template!(List: &["prefix_nops = m, entry_nops = n"]);
724714

compiler/rustc_attr_parsing/src/attributes/crate_level.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ pub(crate) struct MoveSizeLimitParser;
108108

109109
impl<S: Stage> SingleAttributeParser<S> for MoveSizeLimitParser {
110110
const PATH: &[Symbol] = &[sym::move_size_limit];
111-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
112111
const TEMPLATE: AttributeTemplate = template!(NameValueStr: "N");
113112
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
114113

@@ -154,7 +153,6 @@ pub(crate) struct PatternComplexityLimitParser;
154153

155154
impl<S: Stage> SingleAttributeParser<S> for PatternComplexityLimitParser {
156155
const PATH: &[Symbol] = &[sym::pattern_complexity_limit];
157-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
158156
const TEMPLATE: AttributeTemplate = template!(NameValueStr: "N");
159157
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
160158

@@ -177,7 +175,6 @@ pub(crate) struct NoCoreParser;
177175

178176
impl<S: Stage> NoArgsAttributeParser<S> for NoCoreParser {
179177
const PATH: &[Symbol] = &[sym::no_core];
180-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
181178
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
182179
const CREATE: fn(Span) -> AttributeKind = AttributeKind::NoCore;
183180
}
@@ -204,7 +201,6 @@ pub(crate) struct RustcCoherenceIsCoreParser;
204201

205202
impl<S: Stage> NoArgsAttributeParser<S> for RustcCoherenceIsCoreParser {
206203
const PATH: &[Symbol] = &[sym::rustc_coherence_is_core];
207-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
208204
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
209205
const CREATE: fn(Span) -> AttributeKind = AttributeKind::RustcCoherenceIsCore;
210206
}
@@ -247,7 +243,6 @@ pub(crate) struct PanicRuntimeParser;
247243

248244
impl<S: Stage> NoArgsAttributeParser<S> for PanicRuntimeParser {
249245
const PATH: &[Symbol] = &[sym::panic_runtime];
250-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
251246
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
252247
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::PanicRuntime;
253248
}
@@ -256,7 +251,6 @@ pub(crate) struct NeedsPanicRuntimeParser;
256251

257252
impl<S: Stage> NoArgsAttributeParser<S> for NeedsPanicRuntimeParser {
258253
const PATH: &[Symbol] = &[sym::needs_panic_runtime];
259-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
260254
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
261255
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::NeedsPanicRuntime;
262256
}
@@ -265,7 +259,6 @@ pub(crate) struct ProfilerRuntimeParser;
265259

266260
impl<S: Stage> NoArgsAttributeParser<S> for ProfilerRuntimeParser {
267261
const PATH: &[Symbol] = &[sym::profiler_runtime];
268-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
269262
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
270263
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::ProfilerRuntime;
271264
}
@@ -283,7 +276,6 @@ pub(crate) struct RustcPreserveUbChecksParser;
283276

284277
impl<S: Stage> NoArgsAttributeParser<S> for RustcPreserveUbChecksParser {
285278
const PATH: &[Symbol] = &[sym::rustc_preserve_ub_checks];
286-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
287279
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
288280
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcPreserveUbChecks;
289281
}
@@ -292,7 +284,6 @@ pub(crate) struct RustcNoImplicitBoundsParser;
292284

293285
impl<S: Stage> NoArgsAttributeParser<S> for RustcNoImplicitBoundsParser {
294286
const PATH: &[Symbol] = &[sym::rustc_no_implicit_bounds];
295-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
296287
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
297288
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcNoImplicitBounds;
298289
}
@@ -301,7 +292,6 @@ pub(crate) struct DefaultLibAllocatorParser;
301292

302293
impl<S: Stage> NoArgsAttributeParser<S> for DefaultLibAllocatorParser {
303294
const PATH: &[Symbol] = &[sym::default_lib_allocator];
304-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
305295
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
306296
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::DefaultLibAllocator;
307297
}

compiler/rustc_attr_parsing/src/attributes/deprecation.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ fn get<S: Stage>(
3434
pub(crate) struct DeprecatedParser;
3535
impl<S: Stage> SingleAttributeParser<S> for DeprecatedParser {
3636
const PATH: &[Symbol] = &[sym::deprecated];
37-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
3837
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowListWarnRest(&[
3938
Allow(Target::Fn),
4039
Allow(Target::Mod),

compiler/rustc_attr_parsing/src/attributes/inline.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ pub(crate) struct RustcForceInlineParser;
6767

6868
impl<S: Stage> SingleAttributeParser<S> for RustcForceInlineParser {
6969
const PATH: &[Symbol] = &[sym::rustc_force_inline];
70-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
7170
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
7271
Allow(Target::Fn),
7372
Allow(Target::Method(MethodKind::Inherent)),

compiler/rustc_attr_parsing/src/attributes/instruction_set.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ impl<S: Stage> SingleAttributeParser<S> for InstructionSetParser {
1515
Allow(Target::Method(MethodKind::Trait { body: true })),
1616
]);
1717
const TEMPLATE: AttributeTemplate = template!(List: &["set"], "https://doc.rust-lang.org/reference/attributes/codegen.html#the-instruction_set-attribute");
18-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
1918

2019
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
2120
const POSSIBLE_SYMBOLS: &[Symbol] = &[sym::arm_a32, sym::arm_t32];

compiler/rustc_attr_parsing/src/attributes/link_attrs.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -499,31 +499,27 @@ impl<S: Stage> SingleAttributeParser<S> for LinkSectionParser {
499499
pub(crate) struct ExportStableParser;
500500
impl<S: Stage> NoArgsAttributeParser<S> for ExportStableParser {
501501
const PATH: &[Symbol] = &[sym::export_stable];
502-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
503502
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(ALL_TARGETS); //FIXME Still checked fully in `check_attr.rs`
504503
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::ExportStable;
505504
}
506505

507506
pub(crate) struct FfiConstParser;
508507
impl<S: Stage> NoArgsAttributeParser<S> for FfiConstParser {
509508
const PATH: &[Symbol] = &[sym::ffi_const];
510-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
511509
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::ForeignFn)]);
512510
const CREATE: fn(Span) -> AttributeKind = AttributeKind::FfiConst;
513511
}
514512

515513
pub(crate) struct FfiPureParser;
516514
impl<S: Stage> NoArgsAttributeParser<S> for FfiPureParser {
517515
const PATH: &[Symbol] = &[sym::ffi_pure];
518-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
519516
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::ForeignFn)]);
520517
const CREATE: fn(Span) -> AttributeKind = AttributeKind::FfiPure;
521518
}
522519

523520
pub(crate) struct RustcStdInternalSymbolParser;
524521
impl<S: Stage> NoArgsAttributeParser<S> for RustcStdInternalSymbolParser {
525522
const PATH: &[Symbol] = &[sym::rustc_std_internal_symbol];
526-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
527523
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
528524
Allow(Target::Fn),
529525
Allow(Target::ForeignFn),
@@ -537,7 +533,6 @@ pub(crate) struct LinkOrdinalParser;
537533

538534
impl<S: Stage> SingleAttributeParser<S> for LinkOrdinalParser {
539535
const PATH: &[Symbol] = &[sym::link_ordinal];
540-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
541536
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
542537
Allow(Target::ForeignFn),
543538
Allow(Target::ForeignStatic),
@@ -578,7 +573,6 @@ pub(crate) struct LinkageParser;
578573
impl<S: Stage> SingleAttributeParser<S> for LinkageParser {
579574
const PATH: &[Symbol] = &[sym::linkage];
580575

581-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
582576
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
583577
Allow(Target::Fn),
584578
Allow(Target::Method(MethodKind::Inherent)),
@@ -661,7 +655,6 @@ pub(crate) struct NeedsAllocatorParser;
661655

662656
impl<S: Stage> NoArgsAttributeParser<S> for NeedsAllocatorParser {
663657
const PATH: &[Symbol] = &[sym::needs_allocator];
664-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
665658
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
666659
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::NeedsAllocator;
667660
}
@@ -670,7 +663,6 @@ pub(crate) struct CompilerBuiltinsParser;
670663

671664
impl<S: Stage> NoArgsAttributeParser<S> for CompilerBuiltinsParser {
672665
const PATH: &[Symbol] = &[sym::compiler_builtins];
673-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
674666
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
675667
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::CompilerBuiltins;
676668
}

compiler/rustc_attr_parsing/src/attributes/lint_helpers.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use super::prelude::*;
33
pub(crate) struct RustcAsPtrParser;
44
impl<S: Stage> NoArgsAttributeParser<S> for RustcAsPtrParser {
55
const PATH: &[Symbol] = &[sym::rustc_as_ptr];
6-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
76
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
87
Allow(Target::Fn),
98
Allow(Target::Method(MethodKind::Inherent)),
@@ -17,7 +16,6 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcAsPtrParser {
1716
pub(crate) struct RustcPubTransparentParser;
1817
impl<S: Stage> NoArgsAttributeParser<S> for RustcPubTransparentParser {
1918
const PATH: &[Symbol] = &[sym::rustc_pub_transparent];
20-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
2119
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
2220
Allow(Target::Struct),
2321
Allow(Target::Enum),
@@ -29,7 +27,6 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcPubTransparentParser {
2927
pub(crate) struct RustcPassByValueParser;
3028
impl<S: Stage> NoArgsAttributeParser<S> for RustcPassByValueParser {
3129
const PATH: &[Symbol] = &[sym::rustc_pass_by_value];
32-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
3330
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
3431
Allow(Target::Struct),
3532
Allow(Target::Enum),
@@ -41,7 +38,6 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcPassByValueParser {
4138
pub(crate) struct RustcShouldNotBeCalledOnConstItemsParser;
4239
impl<S: Stage> NoArgsAttributeParser<S> for RustcShouldNotBeCalledOnConstItemsParser {
4340
const PATH: &[Symbol] = &[sym::rustc_should_not_be_called_on_const_items];
44-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
4541
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
4642
Allow(Target::Method(MethodKind::Inherent)),
4743
Allow(Target::Method(MethodKind::TraitImpl)),

0 commit comments

Comments
 (0)