-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
expand: Turn ast::Crate
into a first class expansion target
#91313
Conversation
And stop creating a fake `mod` item for the crate root when expanding a crate.
let mut fold_crate = |krate: ast::Crate| { | ||
let mut krate = match self.configure(krate) { | ||
Some(krate) => krate, | ||
None => return empty_crate(), |
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.
Can the entire crate really be removed with something like #![cfg(FALSE)]
? Is there a test case for this?
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.
Yes, libcore has #![cfg(not(test))]
in its root in particular.
There are some tests for this as well, e.g. src\test\ui\issues\issue-34932.rs
and src\test\ui\conditional-compilation\cfg-in-crate-1.rs
.
@bors r+ |
📌 Commit 141c6cc has been approved by |
…askrgr Rollup of 5 pull requests Successful merges: - rust-lang#88502 (Add slice take methods) - rust-lang#91313 (expand: Turn `ast::Crate` into a first class expansion target) - rust-lang#91424 (Update LLVM with patches for better llvm-cov diagnostics) - rust-lang#91425 (Include lint errors in error count for `-Ztreat-err-as-bug`) - rust-lang#91430 (Add tests for `normalize-docs` overflow errors) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
ast: Avoid aborts on fatal errors thrown from mutable AST visitor Set the node to some dummy value and rethrow the error instead. When using the old aborting `visit_clobber` in `InvocationCollector::visit_crate` the next tests abort due to fatal errors: ``` ui\modules\path-invalid-form.rs ui\modules\path-macro.rs ui\modules\path-no-file-name.rs ui\parser\issues\issue-5806.rs ui\parser\mod_file_with_path_attr.rs ``` Follow up to rust-lang#91313.
ast: Always keep a `NodeId` in `ast::Crate` This makes it more uniform with other expanded nodes. It makes generic code in rust-lang#92573 simpler in particular. This is another follow-up to rust-lang#91313. r? `@Aaron1011`
And stop creating a fake
mod
item for the crate root when expanding a crate, thus addressing FIXMEs left in #82238, and making a step towards a proper support for crate-level macro attributes (cc #54726).I haven't added token collection support for the whole crate in this PR, maybe later.
r? @Aaron1011