Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
586d87a
chore : Resolving Windows environment test failures
lms0806 May 14, 2026
b8813df
Use #[panic_handler] rather than #[lang = "panic_impl"]
bjorn3 May 25, 2026
f45a817
Promotes 5 Thumb-mode bare-metal Arm targets to Tier 2
cezarbbb Apr 25, 2026
fba2ec9
Add #[unsafe_eii] to unsafe EII UI tests
AsakuraMizu May 30, 2026
d2abca4
Remove `Clone` from parser types
JonathanBrouwer Apr 10, 2026
79e85e6
Add debug assertion to check usage of arguments of `MetaItemParser`
JonathanBrouwer Apr 10, 2026
b3d4af3
Properly check arguments of `#[inline]`
JonathanBrouwer Apr 12, 2026
bf2db50
Properly check arguments of `#[instruction_set]`
JonathanBrouwer Apr 12, 2026
f3983c7
Properly check arguments of `#[macro_export]`
JonathanBrouwer Apr 12, 2026
f35ea0e
Properly check arguments of `#[rustc_allow_const_fn_unstable]`
JonathanBrouwer Apr 12, 2026
5c90b79
Properly check arguments of `#[optimize]`
JonathanBrouwer Apr 12, 2026
10c6c99
Properly check arguments of `#[coverage]`
JonathanBrouwer Apr 12, 2026
4081ff4
Properly check arguments of `#[used]`
JonathanBrouwer Apr 29, 2026
6c7f601
Properly check arguments of `#[rustc_must_implement_one_of]`
JonathanBrouwer Apr 12, 2026
2b72962
Properly check arguments of `#[rustc_dump_layout]`
JonathanBrouwer Apr 12, 2026
29b5a16
Properly check arguments of query dep graph attrs
JonathanBrouwer Apr 12, 2026
5bee968
Properly check arguments of `#[rustc_abi]`
JonathanBrouwer Apr 12, 2026
3fcbca4
Properly check arguments of `#[test_runner]`
JonathanBrouwer Apr 12, 2026
dfc475d
cg_ssa: a bit less `immediate_or_packed_pair`
scottmcm May 31, 2026
a96cc82
miri: require (almost) all 1-ZST arguments to be actually passed
RalfJung May 2, 2026
b592dd8
Tune backport Zulip messages
apiraino Jun 1, 2026
6fac60d
Trace `?id.local_def_index` instead of `id` in `def_path_hash`
aerooneqq Jun 1, 2026
4a647a5
Don't drop uninit memory when panics
Mark-Simulacrum Jun 1, 2026
266f4ca
Rollup merge of #156085 - RalfJung:miri-ignored-args, r=saethlin
JonathanBrouwer Jun 1, 2026
8b4dd9a
Rollup merge of #155193 - JonathanBrouwer:args_used_check, r=jdonszel…
JonathanBrouwer Jun 1, 2026
06cb2bc
Rollup merge of #155763 - cezarbbb:promote-thumb-to-tier2, r=petroche…
JonathanBrouwer Jun 1, 2026
0786711
Rollup merge of #156562 - lms0806:issue_156558, r=Mark-Simulacrum
JonathanBrouwer Jun 1, 2026
251b4ca
Rollup merge of #156588 - Jules-Bertholet:fix-panicky-mapwindows-clon…
JonathanBrouwer Jun 1, 2026
a6c1556
Rollup merge of #156817 - AsakuraMizu:eii-use-unsafe-eii-tests, r=jdo…
JonathanBrouwer Jun 1, 2026
40eedb2
Rollup merge of #156924 - bjorn3:less_panic_impl, r=jdonszelmann
JonathanBrouwer Jun 1, 2026
a4938b6
Rollup merge of #157220 - scottmcm:less-from-packed-pair, r=dianqk
JonathanBrouwer Jun 1, 2026
e08b2f9
Rollup merge of #157241 - aerooneqq:def-path-hash-instrumentation-fix…
JonathanBrouwer Jun 1, 2026
6bd955d
Rollup merge of #157242 - apiraino:tune-backport-zulip-messages, r=Urgau
JonathanBrouwer Jun 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ fn parse_unstable(

for param in list.mixed() {
let param_span = param.span();
if let Some(ident) = param.meta_item().and_then(|i| i.path().word()) {
if let Some(ident) = param.meta_item_no_args().and_then(|i| i.path().word()) {
res.push(ident.name);
} else {
cx.emit_err(session_diagnostics::ExpectsFeatures {
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl SingleAttributeParser for OptimizeParser {
fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option<AttributeKind> {
let single = cx.expect_single_element_list(args, cx.attr_span)?;

let res = match single.meta_item().and_then(|i| i.path().word().map(|i| i.name)) {
let res = match single.meta_item_no_args().and_then(|i| i.path().word().map(|i| i.name)) {
Some(sym::size) => OptimizeAttr::Size,
Some(sym::speed) => OptimizeAttr::Speed,
Some(sym::none) => OptimizeAttr::DoNotOptimize,
Expand Down Expand Up @@ -80,7 +80,7 @@ impl SingleAttributeParser for CoverageParser {
let mut fail_incorrect_argument =
|span| cx.adcx().expected_specific_argument(span, &[sym::on, sym::off]);

let Some(arg) = arg.meta_item() else {
let Some(arg) = arg.meta_item_no_args() else {
fail_incorrect_argument(arg.span());
return None;
};
Expand Down Expand Up @@ -373,7 +373,7 @@ impl AttributeParser for UsedParser {
return;
};

match l.meta_item().and_then(|i| i.path().word_sym()) {
match l.meta_item_no_args().and_then(|i| i.path().word_sym()) {
Some(sym::compiler) => {
if !cx.features().used_with_arg() {
feature_err(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ impl AttributeParser for OnConstParser {
|this, cx, args| {
if !cx.features().diagnostic_on_const() {
// `UnknownDiagnosticAttribute` is emitted in rustc_resolve/macros.rs
args.ignore_args();
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ impl OnMoveParser {
fn parse<'sess>(&mut self, cx: &mut AcceptContext<'_, 'sess>, args: &ArgParser, mode: Mode) {
if !cx.features().diagnostic_on_move() {
// `UnknownDiagnosticAttribute` is emitted in rustc_resolve/macros.rs
args.ignore_args();
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ impl OnUnknownParser {
&& !features.diagnostic_on_unknown()
{
// `UnknownDiagnosticAttribute` is emitted in rustc_resolve/macros.rs
args.ignore_args();
return;
}
let span = cx.attr_span;
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_attr_parsing/src/attributes/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ impl DocParser {

// FIXME: convert list into a Vec of `AttributeKind` because current code is awful.
for attr in list.mixed() {
// Arguments of `attr` are checked via the span, so can be safely ignored
attr.ignore_args();
self.attribute.test_attrs.push(attr.span());
}
}
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_attr_parsing/src/attributes/dummy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ impl SingleAttributeParser for RustcDummyParser {
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(ALL_TARGETS);
const TEMPLATE: AttributeTemplate = template!(Word); // Anything, really

fn convert(_: &mut AcceptContext<'_, '_>, _: &ArgParser) -> Option<AttributeKind> {
fn convert(_: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option<AttributeKind> {
args.ignore_args();
Some(AttributeKind::RustcDummy)
}
}
2 changes: 1 addition & 1 deletion compiler/rustc_attr_parsing/src/attributes/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl SingleAttributeParser for InlineParser {
ArgParser::List(list) => {
let l = cx.expect_single(list)?;

match l.meta_item().and_then(|i| i.path().word_sym()) {
match l.meta_item_no_args().and_then(|i| i.path().word_sym()) {
Some(sym::always) => {
Some(AttributeKind::Inline(InlineAttr::Always, cx.attr_span))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl SingleAttributeParser for InstructionSetParser {
const POSSIBLE_ARM_SYMBOLS: &[Symbol] = &[sym::a32, sym::t32];
let maybe_meta_item = cx.expect_single_element_list(args, cx.attr_span)?;

let Some(meta_item) = maybe_meta_item.meta_item() else {
let Some(meta_item) = maybe_meta_item.meta_item_no_args() else {
cx.adcx().expected_specific_argument(maybe_meta_item.span(), POSSIBLE_SYMBOLS);
return None;
};
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ impl SingleAttributeParser for MacroExportParser {
cx.adcx().warn_ill_formed_attribute_input(INVALID_MACRO_EXPORT_ARGUMENTS);
return None;
};
match l.meta_item().and_then(|i| i.path().word_sym()) {
match l.meta_item_no_args().and_then(|i| i.path().word_sym()) {
Some(sym::local_inner_macros) => true,
_ => {
cx.adcx().warn_ill_formed_attribute_input(INVALID_MACRO_EXPORT_ARGUMENTS);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl CombineAttributeParser for RustcDumpLayoutParser {

let mut result = Vec::new();
for item in items.mixed() {
let Some(arg) = item.meta_item() else {
let Some(arg) = item.meta_item_no_args() else {
cx.adcx().expected_not_literal(item.span());
continue;
};
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl SingleAttributeParser for RustcMustImplementOneOfParser {

let mut errored = false;
for argument in inputs {
let Some(meta) = argument.meta_item() else {
let Some(meta) = argument.meta_item_no_args() else {
cx.adcx().expected_identifier(argument.span());
return None;
};
Expand Down Expand Up @@ -820,7 +820,7 @@ impl SingleAttributeParser for RustcIfThisChangedParser {
ArgParser::NoArgs => Some(AttributeKind::RustcIfThisChanged(cx.attr_span, None)),
ArgParser::List(list) => {
let item = cx.expect_single(list)?;
let Some(ident) = item.meta_item().and_then(|item| item.ident()) else {
let Some(ident) = item.meta_item_no_args().and_then(|item| item.ident()) else {
cx.adcx().expected_identifier(item.span());
return None;
};
Expand Down Expand Up @@ -878,7 +878,7 @@ impl CombineAttributeParser for RustcThenThisWouldNeedParser {
cx.emit_err(AttributeRequiresOpt { span: cx.attr_span, opt: "-Z query-dep-graph" });
}
let item = cx.expect_single_element_list(args, cx.attr_span)?;
let Some(ident) = item.meta_item().and_then(|item| item.ident()) else {
let Some(ident) = item.meta_item_no_args().and_then(|item| item.ident()) else {
cx.adcx().expected_identifier(item.span());
return None;
};
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_attr_parsing/src/attributes/test_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl SingleAttributeParser for RustcAbiParser {
let mut fail_incorrect_argument =
|span| cx.adcx().expected_specific_argument(span, &[sym::assert_eq, sym::debug]);

let Some(arg) = arg.meta_item() else {
let Some(arg) = arg.meta_item_no_args() else {
fail_incorrect_argument(args.span);
return None;
};
Expand Down Expand Up @@ -173,7 +173,7 @@ impl SingleAttributeParser for TestRunnerParser {
fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option<AttributeKind> {
let single = cx.expect_single_element_list(args, cx.attr_span)?;

let Some(meta) = single.meta_item() else {
let Some(meta) = single.meta_item_no_args() else {
cx.adcx().expected_not_literal(single.span());
return None;
};
Expand Down
9 changes: 9 additions & 0 deletions compiler/rustc_attr_parsing/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use std::collections::btree_map::Entry;
use std::mem;
use std::ops::{Deref, DerefMut};
use std::sync::LazyLock;
#[cfg(debug_assertions)]
use std::sync::atomic::{AtomicBool, Ordering};

use rustc_ast::{AttrStyle, MetaItemLit, Safety};
use rustc_data_structures::sync::{DynSend, DynSync};
Expand Down Expand Up @@ -405,6 +407,8 @@ impl<'f, 'sess: 'f> SharedContext<'f, 'sess> {
kind: EmitAttribute,
span: impl Into<MultiSpan>,
) {
#[cfg(debug_assertions)]
self.has_lint_been_emitted.store(true, Ordering::Relaxed);
if !matches!(
self.should_emit,
ShouldEmit::ErrorsAndLints { .. } | ShouldEmit::EarlyFatal { also_emit_lints: true }
Expand Down Expand Up @@ -744,6 +748,11 @@ pub struct SharedContext<'p, 'sess> {
pub(crate) target: rustc_hir::Target,

pub(crate) emit_lint: &'p mut dyn FnMut(LintId, MultiSpan, EmitAttribute),

/// This atomic bool keeps track of whether any lint has been emitted.
/// This is used for the arguments-used check.
#[cfg(debug_assertions)]
pub(crate) has_lint_been_emitted: AtomicBool,
}

/// Context given to every attribute parser during finalization.
Expand Down
39 changes: 38 additions & 1 deletion compiler/rustc_attr_parsing/src/interface.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use std::convert::identity;
#[cfg(debug_assertions)]
use std::sync::atomic::{AtomicBool, Ordering};

use rustc_ast as ast;
use rustc_ast::token::DocFragmentKind;
Expand Down Expand Up @@ -228,6 +230,8 @@ impl<'sess> AttributeParser<'sess> {
target_span,
target,
emit_lint: &mut emit_lint,
#[cfg(debug_assertions)]
has_lint_been_emitted: AtomicBool::new(false),
},
attr_span,
inner_span,
Expand Down Expand Up @@ -395,6 +399,8 @@ impl<'sess> AttributeParser<'sess> {
target_span,
target,
emit_lint: &mut emit_lint,
#[cfg(debug_assertions)]
has_lint_been_emitted: AtomicBool::new(false),
},
attr_span,
inner_span,
Expand All @@ -409,6 +415,10 @@ impl<'sess> AttributeParser<'sess> {
finalizers.push(accept.finalizer);

Self::check_target(&accept.allowed_targets, &mut cx);
#[cfg(debug_assertions)]
if !cx.shared.has_lint_been_emitted.load(Ordering::Relaxed) {
cx.shared.cx.check_args_used(&attr, &args)
}
} else {
let attr = AttrItem {
path: attr_path.clone(),
Expand Down Expand Up @@ -442,7 +452,14 @@ impl<'sess> AttributeParser<'sess> {
early_parsed_state.finalize_early_parsed_attributes(&mut attributes);
for f in &finalizers {
if let Some(attr) = f(&mut FinalizeContext {
shared: SharedContext { cx: self, target_span, target, emit_lint: &mut emit_lint },
shared: SharedContext {
cx: self,
target_span,
target,
emit_lint: &mut emit_lint,
#[cfg(debug_assertions)]
has_lint_been_emitted: AtomicBool::new(false),
},
all_attrs: &attr_paths,
}) {
attributes.push(Attribute::Parsed(attr));
Expand All @@ -456,6 +473,26 @@ impl<'sess> AttributeParser<'sess> {
attributes
}

#[cfg(debug_assertions)]
/// Checks whether all `ArgParser`s were observed by an attribute parser at least once
/// This check exists because otherwise it is too easy to accidentally ignore the arguments of an attribute
fn check_args_used(&self, attr: &ast::Attribute, args: &ArgParser) {
if let ArgParser::List(items) = args {
for item in items.mixed() {
if let crate::parser::MetaItemOrLitParser::MetaItemParser(item) = item {
if !item.are_args_checked() {
self.dcx().span_delayed_bug(
item.span(),
"attribute args were not properly checked",
);
return;
}
self.check_args_used(attr, item.args());
}
}
}
}

/// Returns whether there is a parser for an attribute with this name
pub fn is_parsed_attribute(path: &[Symbol]) -> bool {
/// The list of attributes that are parsed attributes,
Expand Down
Loading
Loading