Repository navigation
apply lint levels of ancestors to pre-expansion lints in mod m; files - #166007
Albab-Hasan wants to merge 2 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
|
Merging this before #165049 seems like a good idea, as this will decrease the size of that PR which is already too big (and might take a while to get merged) I feel like the approach of that PR is better long-term though. |
pre-expansion lints of an out of line module only see the command line and the attributes of the module itself. lint level attributes on the crate root and on enclosing modules are ignored. this test records that behaviour.
…modules an out of line module is linted on its own when its file is loaded during expansion, starting from the command line levels. the expander now keeps the lint level attributes of the enclosing modules in ModuleData and passes them along with the crate attributes, so the lint run enters those levels before the attributes of the module. this also fixes the known-bug test for keyword_idents not reaching other files.
81ca3aa to
7e846ca
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
^ Rebase I feel like we're copying a lot of attributes around, let's see what rust-timer thinks of that |
This comment has been minimized.
This comment has been minimized.
…-levels, r=<try> apply lint levels of ancestors to pre-expansion lints in `mod m;` files
This comment has been minimized.
This comment has been minimized.
| LoadedMod(ast::NodeId, &'a [ast::Attribute], &'a [Box<ast::Item>]), | ||
| /// The second field holds the attributes of the crate root and then of each enclosing | ||
| /// module. Only their lint levels are used, the attributes themselves are not checked. | ||
| LoadedMod(ast::NodeId, &'a [&'a [ast::Attribute]], &'a [ast::Attribute], &'a [Box<ast::Item>]), |
There was a problem hiding this comment.
Could you make this a struct variant?
There was a problem hiding this comment.
Can we put this file in the auxilliary folder?
There was a problem hiding this comment.
Same with this
There was a problem hiding this comment.
The implementation proposed by this PR fails the following test:
//@ check-pass
//@ edition: 2015
#[warn(keyword_idents_2018)]
fn main() {
#[path = "lint_pre_expansion_extern_module_levels_aux.rs"]
mod lint_pre_expansion_extern_module_levels_aux;
}
//~? WARN `try` is a keyword in the 2018 edition
//~? WARN this is accepted in the current edition
//~? WARN `async` is a keyword in the 2018 edition
//~? WARN this is accepted in the current editionThis would work with the implementation in #165049, and I think it is desirable for this to work. To make this work requires a different approach than this PR, that is, this PR is implementation-wise not a step towards that, so I feel iffy about merging this.
How do you feel about this?
There was a problem hiding this comment.
yeah this only follows modules so #165049 is the better fix. id like it in as a stopgap for the crate-attr desugar but im fine closing it if youd rather wait
There was a problem hiding this comment.
Also given that this PR seems to have a significant performance regression, which may be hard to fix? (not sure)
#166007 (comment)
|
Reminder, once the PR becomes ready for a review, use |
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (660e459): comparison URL. Overall result: ❌ regressions - please read:Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf. Next, please: If you can, justify the regressions found in this try perf run in writing along with @bors rollup=never rustc-perf Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -0.8%, secondary -0.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 2.7%, secondary -3.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 466.359s -> 465.942s (-0.09%) |
a
mod m;file is linted on its own when its loaded during expansion and that run only started from the command line levels. so#![deny(keyword_idents)]at the crate root or a lint attribute on an enclosing module never reached it. now the expander passes those attributes along.fixes #132218
#165049 also fixes this by buffering the lints. this is the small version the
-Zcrate-attrlint flag desugar needs, see #t-compiler > -Zcrate-attr lint flag aliasingcc @jyn514
r? @JonathanBrouwer