expand: Move fully_configure to config.rs
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
//! Conditional compilation stripping.
|
||||
|
||||
use crate::base::Annotatable;
|
||||
|
||||
use rustc_ast::attr::HasAttrs;
|
||||
use rustc_ast::mut_visit::*;
|
||||
use rustc_ast::ptr::P;
|
||||
@@ -496,6 +498,49 @@ impl<'a> StripUnconfigured<'a> {
|
||||
pub fn configure_fn_decl(&mut self, fn_decl: &mut ast::FnDecl) {
|
||||
fn_decl.inputs.flat_map_in_place(|arg| self.configure(arg));
|
||||
}
|
||||
|
||||
pub fn fully_configure(&mut self, item: Annotatable) -> Annotatable {
|
||||
// Since the item itself has already been configured by the InvocationCollector,
|
||||
// we know that fold result vector will contain exactly one element
|
||||
match item {
|
||||
Annotatable::Item(item) => Annotatable::Item(self.flat_map_item(item).pop().unwrap()),
|
||||
Annotatable::TraitItem(item) => {
|
||||
Annotatable::TraitItem(self.flat_map_trait_item(item).pop().unwrap())
|
||||
}
|
||||
Annotatable::ImplItem(item) => {
|
||||
Annotatable::ImplItem(self.flat_map_impl_item(item).pop().unwrap())
|
||||
}
|
||||
Annotatable::ForeignItem(item) => {
|
||||
Annotatable::ForeignItem(self.flat_map_foreign_item(item).pop().unwrap())
|
||||
}
|
||||
Annotatable::Stmt(stmt) => {
|
||||
Annotatable::Stmt(stmt.map(|stmt| self.flat_map_stmt(stmt).pop().unwrap()))
|
||||
}
|
||||
Annotatable::Expr(mut expr) => Annotatable::Expr({
|
||||
self.visit_expr(&mut expr);
|
||||
expr
|
||||
}),
|
||||
Annotatable::Arm(arm) => Annotatable::Arm(self.flat_map_arm(arm).pop().unwrap()),
|
||||
Annotatable::Field(field) => {
|
||||
Annotatable::Field(self.flat_map_field(field).pop().unwrap())
|
||||
}
|
||||
Annotatable::FieldPat(fp) => {
|
||||
Annotatable::FieldPat(self.flat_map_field_pattern(fp).pop().unwrap())
|
||||
}
|
||||
Annotatable::GenericParam(param) => {
|
||||
Annotatable::GenericParam(self.flat_map_generic_param(param).pop().unwrap())
|
||||
}
|
||||
Annotatable::Param(param) => {
|
||||
Annotatable::Param(self.flat_map_param(param).pop().unwrap())
|
||||
}
|
||||
Annotatable::StructField(sf) => {
|
||||
Annotatable::StructField(self.flat_map_struct_field(sf).pop().unwrap())
|
||||
}
|
||||
Annotatable::Variant(v) => {
|
||||
Annotatable::Variant(self.flat_map_variant(v).pop().unwrap())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> MutVisitor for StripUnconfigured<'a> {
|
||||
|
||||
Reference in New Issue
Block a user