Skip to content

Commit 2972b5e

Browse files
committed
Auto merge of #152369 - Bryntet:lint_attrs, r=JonathanBrouwer,jdonszelmann
Port lint attributes to attribute parser *[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/pull/152369)* Tracking issue: #131229 Ports `#[allow]`, `#[deny]`, `#[expect]`, `#[forbid]`, and `#[warn]` to being parsed attrs I tried my best to make this PR as small as possible, it was difficult. I hope it isn't too difficult to review r? @JonathanBrouwer r? @jdonszelmann
2 parents f908263 + ce7c492 commit 2972b5e

99 files changed

Lines changed: 1980 additions & 1455 deletions

File tree

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: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4224,7 +4224,6 @@ dependencies = [
42244224
name = "rustc_lint_defs"
42254225
version = "0.0.0"
42264226
dependencies = [
4227-
"rustc_ast",
42284227
"rustc_data_structures",
42294228
"rustc_error_messages",
42304229
"rustc_hir_id",

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ struct LoweringContext<'a, 'hir, R> {
154154

155155
impl<'a, 'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'a, 'hir, R> {
156156
fn new(tcx: TyCtxt<'hir>, resolver: &'a mut R) -> Self {
157-
let registered_tools = tcx.registered_tools(()).iter().map(|x| x.name).collect();
157+
let registered_tools = tcx.registered_tools(());
158158
Self {
159159
tcx,
160160
resolver,

compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,15 @@ impl<S: Stage> AttributeParser<S> for NakedParser {
295295

296296
let span = self.span?;
297297

298+
let Some(tools) = cx.tools else {
299+
unreachable!("tools required while parsing attributes");
300+
};
301+
302+
let tools = tools.iter().map(|tool| tool.name).collect::<Vec<_>>();
298303
// only if we found a naked attribute do we do the somewhat expensive check
299304
'outer: for other_attr in cx.all_attrs {
300305
for allowed_attr in ALLOW_LIST {
301-
if other_attr.segments().next().is_some_and(|i| cx.tools.contains(&i.name)) {
306+
if other_attr.segments().next().is_some_and(|i| tools.contains(&i.name)) {
302307
// effectively skips the error message being emitted below
303308
// if it's a tool attribute
304309
continue 'outer;

0 commit comments

Comments
 (0)