Auto merge of #108221 - petrochenkov:cratecfg, r=michaelwoerister
rustc_interface: Add a new query `pre_configure` It partially expands crate attributes before the main expansion pass (without modifying the crate), and the produced preliminary crate attribute list is used for querying a few attributes that are required very early. Crate-level cfg attributes on the crate itself are then expanded normally during the main expansion pass, like attributes on any other nodes. This is a continuation of https://github.com/rust-lang/rust/pull/92473 and one more step to very unstable crate-level proc macro attributes maybe actually working. Previously crate attributes were pre-configured simultaneously with feature extraction, and then written directly into `ast::Crate`.
This commit is contained in:
commit
df7fd9995f
20 changed files with 207 additions and 128 deletions
|
@ -341,7 +341,7 @@ pub trait EarlyCheckNode<'a>: Copy {
|
|||
'a: 'b;
|
||||
}
|
||||
|
||||
impl<'a> EarlyCheckNode<'a> for &'a ast::Crate {
|
||||
impl<'a> EarlyCheckNode<'a> for (&'a ast::Crate, &'a [ast::Attribute]) {
|
||||
fn id(self) -> ast::NodeId {
|
||||
ast::CRATE_NODE_ID
|
||||
}
|
||||
|
@ -349,15 +349,15 @@ impl<'a> EarlyCheckNode<'a> for &'a ast::Crate {
|
|||
where
|
||||
'a: 'b,
|
||||
{
|
||||
&self.attrs
|
||||
&self.1
|
||||
}
|
||||
fn check<'b, T: EarlyLintPass>(self, cx: &mut EarlyContextAndPass<'b, T>)
|
||||
where
|
||||
'a: 'b,
|
||||
{
|
||||
lint_callback!(cx, check_crate, self);
|
||||
ast_visit::walk_crate(cx, self);
|
||||
lint_callback!(cx, check_crate_post, self);
|
||||
lint_callback!(cx, check_crate, self.0);
|
||||
ast_visit::walk_crate(cx, self.0);
|
||||
lint_callback!(cx, check_crate_post, self.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue