Skip to content

Commit a91f50e

Browse files
committed
Auto merge of #155483 - JonathanBrouwer:rollup-9T12Udy, r=<try>
Rollup of 5 pull requests try-job: dist-various-1 try-job: test-various try-job: x86_64-gnu-aux try-job: x86_64-gnu-llvm-21-3 try-job: x86_64-msvc-1 try-job: aarch64-apple try-job: x86_64-mingw-1 try-job: i686-msvc-2
2 parents 7a38981 + 963d61f commit a91f50e

50 files changed

Lines changed: 345 additions & 271 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4004,6 +4004,7 @@ dependencies = [
40044004
"rustc_ast_pretty",
40054005
"rustc_data_structures",
40064006
"rustc_error_messages",
4007+
"rustc_errors",
40074008
"rustc_hashes",
40084009
"rustc_hir_id",
40094010
"rustc_index",

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ use std::sync::Arc;
4141
use rustc_ast::node_id::NodeMap;
4242
use rustc_ast::visit::Visitor;
4343
use rustc_ast::{self as ast, *};
44-
use rustc_attr_parsing::{AttributeParser, Late, OmitDoc};
44+
use rustc_attr_parsing::{AttributeParser, EmitAttribute, Late, OmitDoc};
4545
use rustc_data_structures::fingerprint::Fingerprint;
4646
use rustc_data_structures::fx::FxIndexSet;
4747
use rustc_data_structures::sorted_map::SortedMap;
@@ -52,7 +52,7 @@ use rustc_errors::{DiagArgFromDisplay, DiagCtxtHandle};
5252
use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res};
5353
use rustc_hir::def_id::{CRATE_DEF_ID, LOCAL_CRATE, LocalDefId};
5454
use rustc_hir::definitions::PerParentDisambiguatorState;
55-
use rustc_hir::lints::{AttributeLint, DelayedLint};
55+
use rustc_hir::lints::{AttributeLint, DelayedLint, DynAttribute};
5656
use rustc_hir::{
5757
self as hir, AngleBrackets, ConstArg, GenericArg, HirId, ItemLocalMap, LifetimeSource,
5858
LifetimeSyntax, ParamName, Target, TraitCandidate, find_attr,
@@ -1174,13 +1174,23 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
11741174
target,
11751175
OmitDoc::Lower,
11761176
|s| l.lower(s),
1177-
|lint_id, span, kind| {
1178-
self.delayed_lints.push(DelayedLint::AttributeParsing(AttributeLint {
1179-
lint_id,
1180-
id: target_hir_id,
1181-
span,
1182-
kind,
1183-
}));
1177+
|lint_id, span, kind| match kind {
1178+
EmitAttribute::Static(attr_kind) => {
1179+
self.delayed_lints.push(DelayedLint::AttributeParsing(AttributeLint {
1180+
lint_id,
1181+
id: target_hir_id,
1182+
span,
1183+
kind: attr_kind,
1184+
}));
1185+
}
1186+
EmitAttribute::Dynamic(callback) => {
1187+
self.delayed_lints.push(DelayedLint::Dynamic(DynAttribute {
1188+
lint_id,
1189+
id: target_hir_id,
1190+
span,
1191+
callback,
1192+
}));
1193+
}
11841194
},
11851195
)
11861196
}

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
@@ -14,7 +14,6 @@ pub(crate) struct OptimizeParser;
1414

1515
impl<S: Stage> SingleAttributeParser<S> for OptimizeParser {
1616
const PATH: &[Symbol] = &[sym::optimize];
17-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::WarnButFutureError;
1817
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
1918
Allow(Target::Fn),
2019
Allow(Target::Closure),
@@ -62,7 +61,6 @@ pub(crate) struct CoverageParser;
6261

6362
impl<S: Stage> SingleAttributeParser<S> for CoverageParser {
6463
const PATH: &[Symbol] = &[sym::coverage];
65-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
6664
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
6765
Allow(Target::Fn),
6866
Allow(Target::Closure),
@@ -143,7 +141,6 @@ pub(crate) struct RustcObjcClassParser;
143141

144142
impl<S: Stage> SingleAttributeParser<S> for RustcObjcClassParser {
145143
const PATH: &[rustc_span::Symbol] = &[sym::rustc_objc_class];
146-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
147144
const ALLOWED_TARGETS: AllowedTargets =
148145
AllowedTargets::AllowList(&[Allow(Target::ForeignStatic)]);
149146
const TEMPLATE: AttributeTemplate = template!(NameValueStr: "ClassName");
@@ -175,7 +172,6 @@ pub(crate) struct RustcObjcSelectorParser;
175172

176173
impl<S: Stage> SingleAttributeParser<S> for RustcObjcSelectorParser {
177174
const PATH: &[rustc_span::Symbol] = &[sym::rustc_objc_selector];
178-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
179175
const ALLOWED_TARGETS: AllowedTargets =
180176
AllowedTargets::AllowList(&[Allow(Target::ForeignStatic)]);
181177
const TEMPLATE: AttributeTemplate = template!(NameValueStr: "methodName");
@@ -591,8 +587,6 @@ impl<S: Stage> SingleAttributeParser<S> for SanitizeParser {
591587
r#"realtime = "nonblocking|blocking|caller""#,
592588
]);
593589

594-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
595-
596590
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<AttributeKind> {
597591
let Some(list) = args.list() else {
598592
let attr_span = cx.attr_span;
@@ -695,7 +689,6 @@ pub(crate) struct ThreadLocalParser;
695689

696690
impl<S: Stage> NoArgsAttributeParser<S> for ThreadLocalParser {
697691
const PATH: &[Symbol] = &[sym::thread_local];
698-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::WarnButFutureError;
699692
const ALLOWED_TARGETS: AllowedTargets =
700693
AllowedTargets::AllowList(&[Allow(Target::Static), Allow(Target::ForeignStatic)]);
701694
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::ThreadLocal;
@@ -705,7 +698,6 @@ pub(crate) struct RustcPassIndirectlyInNonRusticAbisParser;
705698

706699
impl<S: Stage> NoArgsAttributeParser<S> for RustcPassIndirectlyInNonRusticAbisParser {
707700
const PATH: &[Symbol] = &[sym::rustc_pass_indirectly_in_non_rustic_abis];
708-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
709701
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Struct)]);
710702
const CREATE: fn(Span) -> AttributeKind = AttributeKind::RustcPassIndirectlyInNonRusticAbis;
711703
}
@@ -714,7 +706,6 @@ pub(crate) struct RustcEiiForeignItemParser;
714706

715707
impl<S: Stage> NoArgsAttributeParser<S> for RustcEiiForeignItemParser {
716708
const PATH: &[Symbol] = &[sym::rustc_eii_foreign_item];
717-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
718709
const ALLOWED_TARGETS: AllowedTargets =
719710
AllowedTargets::AllowList(&[Allow(Target::ForeignFn), Allow(Target::ForeignStatic)]);
720711
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcEiiForeignItem;
@@ -724,7 +715,6 @@ pub(crate) struct PatchableFunctionEntryParser;
724715

725716
impl<S: Stage> SingleAttributeParser<S> for PatchableFunctionEntryParser {
726717
const PATH: &[Symbol] = &[sym::patchable_function_entry];
727-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
728718
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]);
729719
const TEMPLATE: AttributeTemplate = template!(List: &["prefix_nops = m, entry_nops = n"]);
730720

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::Warn;
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::Warn;
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::Warn;
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::Warn;
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::Warn;
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::Warn;
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/doc.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use rustc_ast::ast::{AttrStyle, LitKind, MetaItemLit};
2-
use rustc_errors::msg;
2+
use rustc_errors::{Diagnostic, msg};
33
use rustc_feature::template;
44
use rustc_hir::Target;
55
use rustc_hir::attrs::{
@@ -171,12 +171,15 @@ impl DocParser {
171171

172172
if let Some(used_span) = self.attribute.no_crate_inject {
173173
let unused_span = path.span();
174-
cx.emit_lint(
174+
cx.emit_dyn_lint(
175175
rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES,
176-
AttributeLintKind::UnusedDuplicate {
177-
this: unused_span,
178-
other: used_span,
179-
warning: true,
176+
move |dcx, level| {
177+
rustc_errors::lints::UnusedDuplicate {
178+
this: unused_span,
179+
other: used_span,
180+
warning: true,
181+
}
182+
.into_diag(dcx, level)
180183
},
181184
unused_span,
182185
);

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::WarnButFutureError;
7170
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
7271
Allow(Target::Fn),
7372
Allow(Target::Method(MethodKind::Inherent)),

0 commit comments

Comments
 (0)