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 are then expanded normally during the main expansion pass, like attributes on any other nodes.
This commit is contained in:
parent
f26da39e04
commit
aca1b1e0b3
12 changed files with 108 additions and 84 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