Skip to content

[crater] error on everything attribute related - #165441

Draft
mejrs wants to merge 7 commits into
rust-lang:mainfrom
mejrs:attribute_errors
Draft

mejrs wants to merge 7 commits into
rust-lang:mainfrom
mejrs:attribute_errors

Conversation

@mejrs

@mejrs mejrs commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

View all comments

All attributes now get parsed, let's see what happens. Main goals here:

  • figure out how often macro_escape is used
  • figure out which warnings are widely reported and note that in a comment
  • if some warnings are never or very rarely emitted, let's see if that can be turned into an error
  • this parses attributes on macro calls together, I wonder if that matters.

(repr combinations/no_mangle/export_name are not included, they are covered in other crater runs)

r? @JonathanBrouwer, can you double check? I might've overlooked stuff.

@mejrs mejrs added S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. C-crater Category: Issues tracking / PRs primarily containing crater runs labels Nov 4, 2026
@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 4, 2026
@mejrs

mejrs commented Nov 4, 2026

Copy link
Copy Markdown
Member Author

Let's see whether rustc can bootstrap on linux with these changes

@bors try

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Nov 4, 2026
[crater] error on everything attribute related
@rust-log-analyzer

This comment has been minimized.

@rust-bors

rust-bors Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

💔 Test for acda8ae failed: CI. Failed jobs:

@rust-log-analyzer

This comment has been minimized.

@mejrs

mejrs commented Nov 4, 2026

Copy link
Copy Markdown
Member Author

@bors try jobs=test-aarch64-apple-1

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Nov 4, 2026
[crater] error on everything attribute related


try-job: test-aarch64-apple-1
@rust-log-analyzer

This comment has been minimized.

@rust-bors

rust-bors Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

💔 Test for bf08b19 failed: CI. Failed job:

@mejrs

mejrs commented Nov 4, 2026

Copy link
Copy Markdown
Member Author

@bors try

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Nov 4, 2026
[crater] error on everything attribute related
@rust-log-analyzer

This comment has been minimized.

@rust-bors

rust-bors Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

💔 Test for d189687 failed: CI. Failed jobs:

@mejrs

mejrs commented Nov 5, 2026

Copy link
Copy Markdown
Member Author

@bors try

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Nov 5, 2026
[crater] error on everything attribute related
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

Error(Target::Crate),
Error(Target::WherePredicate),
Error(Target::Param),
Warn(Target::MacroCall), // #158816: 100+ regressions in `cucumber`

@JonathanBrouwer JonathanBrouwer Nov 23, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would love a PR that adds all these comments to main :3

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is the plan :)

@JonathanBrouwer JonathanBrouwer left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is all that I could find, a lot of them are questions about how big you want your scope to be, so feel free to not include all of them :)

View changes since this review

if list.is_empty() {
let attr_span = cx.attr_span;
cx.adcx().warn_empty_attribute(attr_span);
cx.adcx().empty_attribute(attr_span);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely convinced I'd even want this change, as the meaning of an empty attribute is clear.

If you do want to do this, the lint attribute still emits UNUSED_ATTRIBUTES for an empty list

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was more to make it easier to search for "warn", I don't intend this change.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you include all calls of warn_unused_duplicate?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(not only in this file)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lint attribute still FCWs on macro calls
(comment at random location because imagine being able to leave comments in files that aren't edited...)

// This is an edgecase added because making this a hard error would break too many crates
// Specifically `#[link = "dl"]` is accepted with a FCW
// For more information, see https://github.com/rust-lang/rust/pull/143193
ArgParser::NameValue(nv) if nv.value_as_str().is_some_and(|v| v == sym::dl) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This edgecase is there exactly because it was found in crater, so feel free to include it again or not

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah this is fine to keep for now, i think. The crater run was recent enough that I don't expect much has changed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(random location again)
There is a call to ILL_FORMED_ATTRIBUTE_INPUT on validate_attr.rs:192. I don't think this is reachable anymore, I'll make a PR to clean up that code.

@JonathanBrouwer JonathanBrouwer Nov 23, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: This is in fact reachable, through active macro parsing :p

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(random location again)
Could you include doc_comment.rs:51, unused doc comments?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to include stuff related to doc comments and attributes, I think it'll be too noisy.

const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::NoLink;

fn finalize_check(cx: &mut FinalizeCheckContext<'_, '_>, attr_span: Span) {
cx.emit_lint(NO_LINK_ATTRIBUTES, NoLinkAttrUsed, attr_span);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to include this? I think there was already a crater run done, not sure

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was cratered in #152856

Comment thread compiler/rustc_passes/src/check_attr.rs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps include this? I think there's already a PR open somewhere that is aiming to break this tho

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, what are you referring to here? The github ui doesn't show it.

@JonathanBrouwer JonathanBrouwer Nov 23, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was referring to the CONFLICTING_REPRS lint, the PR that breaks this already landed though.

Github ui doesn't show it anymore because the code is gone (I think you just rebased on the PR), terrible UI design lol

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Removed in #165238)

}
}

fn check_lint_check(&self, hir_id: HirId, lints: &[LintCheck]) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wanna include all the lints in this function?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually these should really stay lints rather than errors, so I wouldn't include them

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(random location again)
Wanna include all uses of DUPLICATE_MACRO_ATTRIBUTES?

@rust-log-analyzer

This comment has been minimized.

@JonathanBrouwer JonathanBrouwer Nov 23, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also consider including REPEATED_REPRS, again not sure we'd want it to be an error so up to you

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(It's in some libc versions: rust-lang/libc#5446 fixed it)

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job test-aarch64-gnu-llvm-22-2 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@mejrs

mejrs commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

@bors try

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Nov 23, 2026
[crater] error on everything attribute related
@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job dist-x86_64-linux-quick failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 16.95s
warning: the following packages contain code that will be rejected by a future version of Rust: proc-macro-error2 v2.0.1
note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 1`
##[endgroup]
[2026-11-23T22:02:06.426Z INFO  opt_dist::timer] Section `Stage 1 (rustc + rustdoc + cargo PGO)` starts
[2026-11-23T22:02:06.426Z INFO  opt_dist::timer] Section `Stage 1 (rustc + rustdoc + cargo PGO) > Build PGO-instrumented rustc, and vanilla LLVM` starts
[2026-11-23T22:02:06.426Z INFO  opt_dist::exec] Executing `RUST_BACKTRACE=full python3 /checkout/x.py build --target x86_64-unknown-linux-gnu --host x86_64-unknown-linux-gnu --stage 2 library/std --set rust.llvm-bitcode-linker=false --set build.extended=false --set rust.codegen-backends=['llvm'] --set rust.deny-warnings=false --set pgo.rustc.generate="/tmp/tmp-multistage/opt-artifacts/rustc-pgo" cargo --set pgo.cargo.generate="/tmp/tmp-multistage/opt-artifacts/rustc-pgo" rustdoc --set pgo.rustdoc.generate="/tmp/tmp-multistage/opt-artifacts/rustc-pgo" --set llvm.thin-lto=false --set llvm.link-shared=true [at /checkout/obj]`
##[group]Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.02s
##[endgroup]
[TIMING:start] compile::Assemble { target_compiler: Compiler { stage: 2, host: x86_64-unknown-linux-gnu, forced_compiler: false } }
[TIMING:start] builder::Libdir { compiler: Compiler { stage: 2, host: x86_64-unknown-linux-gnu, forced_compiler: false }, target: x86_64-unknown-linux-gnu }
---
    |                  ^
    |
   ::: /cargo/registry/25cdd57fae9f0462/libc-0.2.186/src/unix/linux_like/linux/gnu/mod.rs:409:1
    |
409 | / s_no_extra_traits! {
410 | |     // linux/if_ether.h
411 | |
412 | |     #[repr(C, packed)]
...   |
441 | | }
    | |_- in this macro invocation
---
   --> /cargo/registry/25cdd57fae9f0462/libc-0.2.186/src/macros.rs:229:16
    |
204 | / macro_rules! s_no_extra_traits {
205 | |     ($(
206 | |         $(#[$attr:meta])*
207 | |         $pub:vis $t:ident $i:ident { $($field:tt)* }
208 | |     )*) => ($(
209 | |         s_no_extra_traits!(it: $(#[$attr])* $pub $t $i { $($field)* });
    | |         -------------------------------------------------------------- in this macro invocation (#2)
...   |
229 | |         #[repr(C)]
    | |                ^
...   |
237 | |     );
238 | | }
    | | -
    | | |
    | |_in this expansion of `s_no_extra_traits!` (#1)
    |   in this expansion of `s_no_extra_traits!` (#2)
    |
   ::: /cargo/registry/25cdd57fae9f0462/libc-0.2.186/src/unix/linux_like/linux/gnu/mod.rs:409:1
    |
409 | / s_no_extra_traits! {
410 | |     // linux/if_ether.h
411 | |
412 | |     #[repr(C, packed)]
...   |
441 | | }
    | |_- in this macro invocation (#1)
---
[RUSTC-TIMING] aho_corasick test:false 2.304
[RUSTC-TIMING] regex_syntax test:false 2.812
[RUSTC-TIMING] zlib_rs test:false 2.411
[RUSTC-TIMING] jiff test:false 4.581
Bootstrap failed while executing `build --target x86_64-unknown-linux-gnu --host x86_64-unknown-linux-gnu --stage 2 library/std --set rust.llvm-bitcode-linker=false --set build.extended=false --set rust.codegen-backends=['llvm'] --set rust.deny-warnings=false --set pgo.rustc.generate="/tmp/tmp-multistage/opt-artifacts/rustc-pgo" cargo --set pgo.cargo.generate="/tmp/tmp-multistage/opt-artifacts/rustc-pgo" rustdoc --set pgo.rustdoc.generate="/tmp/tmp-multistage/opt-artifacts/rustc-pgo" --set llvm.thin-lto=false --set llvm.link-shared=true`
Currently active steps:
tool::Cargo { build_compiler: Compiler { stage: 1, host: x86_64-unknown-linux-gnu, forced_compiler: false }, target: x86_64-unknown-linux-gnu } at src/bootstrap/src/core/build_steps/tool.rs:899
tool::ToolBuild { build_compiler: Compiler { stage: 1, host: x86_64-unknown-linux-gnu, forced_compiler: false }, target: x86_64-unknown-linux-gnu, tool: "cargo", path: "src/tools/cargo", mode: ToolTarget, source_type: Submodule, extra_features: [], allow_features: "min_specialization,specialization", cargo_args: [], artifact_kind: Binary } at src/bootstrap/src/core/build_steps/tool.rs:914
Build completed unsuccessfully in 0:08:37
[2026-11-23T22:10:44.060Z INFO  opt_dist::timer] Section `Stage 1 (rustc + rustdoc + cargo PGO) > Build PGO-instrumented rustc, and vanilla LLVM` ended: FAIL (517.63s)`
---
[2026-11-23T22:10:44.060Z INFO  opt_dist::utils] Free disk space: 2.32 TiB out of total 2.55 TiB (9.02% used)
Error: Optimized build pipeline has failed

Caused by:
    Command RUST_BACKTRACE=full python3 /checkout/x.py build --target x86_64-unknown-linux-gnu --host x86_64-unknown-linux-gnu --stage 2 library/std --set rust.llvm-bitcode-linker=false --set build.extended=false --set rust.codegen-backends=['llvm'] --set rust.deny-warnings=false --set pgo.rustc.generate="/tmp/tmp-multistage/opt-artifacts/rustc-pgo" cargo --set pgo.cargo.generate="/tmp/tmp-multistage/opt-artifacts/rustc-pgo" rustdoc --set pgo.rustdoc.generate="/tmp/tmp-multistage/opt-artifacts/rustc-pgo" --set llvm.thin-lto=false --set llvm.link-shared=true [at /checkout/obj] has failed with exit code Some(1)

Stack backtrace:
   0: <anyhow::Error>::msg::<alloc::string::String>
             at /cargo/registry/25cdd57fae9f0462/anyhow-1.0.102/src/backtrace.rs:10:14
   1: <opt_dist::exec::CmdBuilder>::run
             at /rustc/052ec7496f6f79d22cca9e1452728874c1fec341/src/tools/opt-dist/src/exec.rs:84:17
   2: <opt_dist::exec::Bootstrap>::run
             at /rustc/052ec7496f6f79d22cca9e1452728874c1fec341/src/tools/opt-dist/src/exec.rs:296:18
   3: opt_dist::execute_pipeline::{closure#1}::{closure#0}
             at /rustc/052ec7496f6f79d22cca9e1452728874c1fec341/src/tools/opt-dist/src/main.rs:320:25
   4: <opt_dist::timer::TimerSection>::section::<opt_dist::execute_pipeline::{closure#1}::{closure#0}, ()>
             at /rustc/052ec7496f6f79d22cca9e1452728874c1fec341/src/tools/opt-dist/src/timer.rs:111:22
   5: opt_dist::execute_pipeline::{closure#1}
             at /rustc/052ec7496f6f79d22cca9e1452728874c1fec341/src/tools/opt-dist/src/main.rs:289:19
   6: <opt_dist::timer::TimerSection>::section::<opt_dist::execute_pipeline::{closure#1}, (opt_dist::training::RustcPGOProfile, core::option::Option<opt_dist::training::RustdocPGOProfile>, core::option::Option<opt_dist::training::ClippyPGOProfile>, core::option::Option<opt_dist::training::CraneliftPGOProfile>)>
             at /rustc/052ec7496f6f79d22cca9e1452728874c1fec341/src/tools/opt-dist/src/timer.rs:111:22
   7: opt_dist::execute_pipeline
             at /rustc/052ec7496f6f79d22cca9e1452728874c1fec341/src/tools/opt-dist/src/main.rs:286:10
   8: opt_dist::main
             at /rustc/052ec7496f6f79d22cca9e1452728874c1fec341/src/tools/opt-dist/src/main.rs:636:18
   9: <fn() -> core::result::Result<(), anyhow::Error> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/bbcdfd90a3f81ca2a5f6d69b943a6ff0d8582102/library/core/src/ops/function.rs:250:5
  10: std::sys::backtrace::__rust_begin_short_backtrace::<fn() -> core::result::Result<(), anyhow::Error>, core::result::Result<(), anyhow::Error>>
             at /rustc/bbcdfd90a3f81ca2a5f6d69b943a6ff0d8582102/library/std/src/sys/backtrace.rs:166:18
  11: std::rt::lang_start::<core::result::Result<(), anyhow::Error>>::{closure#0}
             at /rustc/bbcdfd90a3f81ca2a5f6d69b943a6ff0d8582102/library/std/src/rt.rs:206:18
  12: <&dyn core::ops::function::Fn<(), Output = i32> + core::panic::unwind_safe::RefUnwindSafe + core::marker::Sync as core::ops::function::FnOnce<()>>::call_once
             at /rustc/bbcdfd90a3f81ca2a5f6d69b943a6ff0d8582102/library/core/src/ops/function.rs:287:21
  13: std::panicking::catch_unwind::do_call::<&dyn core::ops::function::Fn<(), Output = i32> + core::panic::unwind_safe::RefUnwindSafe + core::marker::Sync, i32>
             at /rustc/bbcdfd90a3f81ca2a5f6d69b943a6ff0d8582102/library/std/src/panicking.rs:573:43
  14: std::panicking::catch_unwind::<i32, &dyn core::ops::function::Fn<(), Output = i32> + core::panic::unwind_safe::RefUnwindSafe + core::marker::Sync>
             at /rustc/bbcdfd90a3f81ca2a5f6d69b943a6ff0d8582102/library/std/src/panicking.rs:541:19
  15: std::panic::catch_unwind::<&dyn core::ops::function::Fn<(), Output = i32> + core::panic::unwind_safe::RefUnwindSafe + core::marker::Sync, i32>
             at /rustc/bbcdfd90a3f81ca2a5f6d69b943a6ff0d8582102/library/std/src/panic.rs:359:14
  16: std::rt::lang_start_internal::{closure#0}
             at /rustc/bbcdfd90a3f81ca2a5f6d69b943a6ff0d8582102/library/std/src/rt.rs:175:24
  17: std::panicking::catch_unwind::do_call::<std::rt::lang_start_internal::{closure#0}, isize>
             at /rustc/bbcdfd90a3f81ca2a5f6d69b943a6ff0d8582102/library/std/src/panicking.rs:573:43

@rust-bors

rust-bors Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

💔 Test for 052ec74 failed: CI. Failed jobs:

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) C-crater Category: Issues tracking / PRs primarily containing crater runs S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants