-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass real crate-level attributes to pre_expansion_lint
#89214
Conversation
The test currently fails. The next commit fixes it.
r? @nagisa (rust-highfive has picked a reviewer for you, use r? to override) |
This is a bug and a regression from #69838. |
Thanks, @petrochenkov. Please leave the PR open for now while I try to find a proper fix. |
ab56107
to
2b24fd4
Compare
@petrochenkov Is this about what you had in mind? |
2b24fd4
to
1e15bbe
Compare
📌 Commit 1e15bbe has been approved by |
error_on_unknown_tool
flag to LintLevelsBuilder
pre_expansion_lint
Absolutely. Please let me know if what I wrote is insufficient. |
☀️ Test successful - checks-actions |
Finished benchmarking commit (98c8619): comparison url. Summary: This benchmark run did not return any relevant changes. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression |
The PR concerns the unstable feature
register_tool
(#66079).The feature's implementation requires the attributes of the crate being compiled, so that when attributes like
allow(foo::bar)
are encountered, it can be verified thatregister_tool(foo)
appears in the crate root.However, the crate's attributes are not readily available during early lint passes. Specifically, on this line,
krate.attrs
appears to be the attributes of the current source file, not the attributes of the whole crate:rust/compiler/rustc_lint/src/context.rs
Line 815 in bf64232
Consequently, "unknown tool" errors were being produced when
allow(foo::bar)
appeared in a submodule, even thoughregister_tool(foo)
appeared in the crate root.EDITED: The proposed fix is to obtain the real crate-level attributes in
configure_and_expand
and pass them topre_expansion_lint
. (See @petrochenkov's comment below.)The original "prosed fix" text follows.
The proposed fix is to add an
error_on_unknown_tool
flag toLintLevelsBuilder
. The flag controls whether "unknown tool" errors are emitted. The flag is set during late passes, but not earlier.More specifically, this PR contains two commits:
known-tool-in-submodule
UI test that does not currently pass.error_on_unknown_tool
flag. The new test passes with the addition of this flag.This change has the added benefit of eliminating some errors that were duplicated in existing tests.
To the reviewer: please check that I implemented the UI test correctly.