-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Mark proc_macro_decls_static
as always used
#105978
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
compiler/rustc_passes/src/dead.rs
Outdated
@@ -623,6 +623,11 @@ fn create_and_seed_worklist<'tcx>( | |||
check_foreign_item(tcx, &mut worklist, id); | |||
} | |||
|
|||
if let Some(static_) = tcx.proc_macro_decls_static(()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would adding#[used]
when creating this static work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, if it's possible we should rely on regular user-available attributes instead of hardcoding stuff in the compiler, both for dead code and symbol export analysis.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure it will work (don't want to spend the time testing it with #104860), but it seems like a good idea anyway, done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interaction between dead code lint and #[used] attribute is tested in issue-41628.rs.
e7cdb50
to
55a8538
Compare
55a8538
to
8e89c70
Compare
This would have avoided a bug in rust-lang#104860. In practice this shouldn't matter since nothing uses the query other than the `dead_code` lint, but this isn't documented as an internal-only query so it seems nice for it to be accurate. I think for `dead_code` it doesn't matter because the relevant code is generated by `rustc_builtin_macros` and isn't linted.
8e89c70
to
164e221
Compare
@bors r+ |
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#105978 (Mark `proc_macro_decls_static` as always used) - rust-lang#106051 (Allow building std with cranelift) - rust-lang#106056 (Make `sess.bug` much less noisy) - rust-lang#106057 (Give a more helpful error for "trimmed_def_paths constructed") - rust-lang#106058 (Fix the issue number in comment for as_local_call_operand) - rust-lang#106059 (Avoid running the `Profile` step twice on `x setup`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This would have avoided a bug in #104860.
In practice this shouldn't matter since nothing uses the query other than the
dead_code
lint, but this isn't documented as an internal-only query so it seems nice for it to be accurate. I think fordead_code
it doesn't matter because the relevant code is generated byrustc_builtin_macros
and isn't linted.I think @tmiasko or @bjorn3 would be a good reviewer?
r? @tmiasko