Skip to content

expand: Turn ast::Crate into a first class expansion target #91313

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 1, 2021

Conversation

petrochenkov
Copy link
Contributor

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

And stop creating a fake `mod` item for the crate root when expanding a crate.
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 28, 2021
let mut fold_crate = |krate: ast::Crate| {
let mut krate = match self.configure(krate) {
Some(krate) => krate,
None => return empty_crate(),
Copy link
Member

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?

Copy link
Contributor Author

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.

@Aaron1011
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Dec 1, 2021

📌 Commit 141c6cc has been approved by Aaron1011

@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 1, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 1, 2021
…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
@apiraino apiraino added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Dec 1, 2021
@bors bors merged commit 519a842 into rust-lang:master Dec 1, 2021
@rustbot rustbot added this to the 1.59.0 milestone Dec 1, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Dec 30, 2021
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.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 5, 2022
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`
@petrochenkov petrochenkov deleted the cratexp branch February 22, 2025 18:43
# 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