Skip to content

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

Merged
merged 1 commit into from
Dec 23, 2022

Conversation

jyn514
Copy link
Member

@jyn514 jyn514 commented Dec 20, 2022

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 for dead_code it doesn't matter because the relevant code is generated by rustc_builtin_macros and isn't linted.

I think @tmiasko or @bjorn3 would be a good reviewer?

r? @tmiasko

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 20, 2022
@@ -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(()) {
Copy link
Member

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?

Copy link
Contributor

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.

Copy link
Member Author

@jyn514 jyn514 Dec 22, 2022

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.

Copy link
Contributor

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.

@jyn514 jyn514 force-pushed the unused_proc_macro_decl branch from e7cdb50 to 55a8538 Compare December 22, 2022 17:17
@rustbot rustbot added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Dec 22, 2022
@jyn514 jyn514 force-pushed the unused_proc_macro_decl branch from 55a8538 to 8e89c70 Compare December 22, 2022 17:20
@jyn514 jyn514 removed the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Dec 22, 2022
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.
@jyn514 jyn514 force-pushed the unused_proc_macro_decl branch from 8e89c70 to 164e221 Compare December 22, 2022 18:04
@tmiasko
Copy link
Contributor

tmiasko commented Dec 22, 2022

@bors r+

@bors
Copy link
Collaborator

bors commented Dec 22, 2022

📌 Commit 164e221 has been approved by tmiasko

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 22, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 23, 2022
…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
@bors bors merged commit 3e58de2 into rust-lang:master Dec 23, 2022
@rustbot rustbot added this to the 1.68.0 milestone Dec 23, 2022
@jyn514 jyn514 deleted the unused_proc_macro_decl branch February 25, 2023 18:32
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

6 participants