Skip to content

Commit b968641

Browse files
committed
Remove some unnecessary ast:: and fold:: qualifiers.
1 parent 8ae730a commit b968641

File tree

2 files changed

+37
-46
lines changed

2 files changed

+37
-46
lines changed

src/libsyntax/ext/expand.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use ext::derive::{add_derived_markers, collect_derives};
99
use ext::hygiene::{self, Mark, SyntaxContext};
1010
use ext::placeholders::{placeholder, PlaceholderExpander};
1111
use feature_gate::{self, Features, GateIssue, is_builtin_attr, emit_feature_err};
12-
use fold;
1312
use fold::*;
1413
use parse::{DirectoryOwnership, PResult, ParseSess};
1514
use parse::token::{self, Token};
@@ -1395,7 +1394,7 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> {
13951394
self.check_attributes(&attrs);
13961395
self.collect_bang(mac, span, AstFragmentKind::TraitItems).make_trait_items()
13971396
}
1398-
_ => fold::noop_fold_trait_item(item, self),
1397+
_ => noop_fold_trait_item(item, self),
13991398
}
14001399
}
14011400

@@ -1414,14 +1413,14 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> {
14141413
self.check_attributes(&attrs);
14151414
self.collect_bang(mac, span, AstFragmentKind::ImplItems).make_impl_items()
14161415
}
1417-
_ => fold::noop_fold_impl_item(item, self),
1416+
_ => noop_fold_impl_item(item, self),
14181417
}
14191418
}
14201419

14211420
fn fold_ty(&mut self, ty: P<ast::Ty>) -> P<ast::Ty> {
14221421
let ty = match ty.node {
14231422
ast::TyKind::Mac(_) => ty.into_inner(),
1424-
_ => return fold::noop_fold_ty(ty, self),
1423+
_ => return noop_fold_ty(ty, self),
14251424
};
14261425

14271426
match ty.node {

src/libsyntax/fold.rs

Lines changed: 34 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
//! that are created by the expansion of a macro.
1010
1111
use ast::*;
12-
use ast;
1312
use syntax_pos::Span;
1413
use source_map::{Spanned, respan};
1514
use parse::token::{self, Token};
@@ -785,31 +784,26 @@ pub fn noop_fold_where_predicate<T: Folder>(
785784
fld: &mut T)
786785
-> WherePredicate {
787786
match pred {
788-
ast::WherePredicate::BoundPredicate(ast::WhereBoundPredicate{bound_generic_params,
789-
bounded_ty,
790-
bounds,
791-
span}) => {
792-
ast::WherePredicate::BoundPredicate(ast::WhereBoundPredicate {
787+
WherePredicate::BoundPredicate(WhereBoundPredicate { bound_generic_params,
788+
bounded_ty,
789+
bounds,
790+
span }) => {
791+
WherePredicate::BoundPredicate(WhereBoundPredicate {
793792
bound_generic_params: fld.fold_generic_params(bound_generic_params),
794793
bounded_ty: fld.fold_ty(bounded_ty),
795794
bounds: bounds.move_map(|x| fld.fold_param_bound(x)),
796795
span: fld.new_span(span)
797796
})
798797
}
799-
ast::WherePredicate::RegionPredicate(ast::WhereRegionPredicate{lifetime,
800-
bounds,
801-
span}) => {
802-
ast::WherePredicate::RegionPredicate(ast::WhereRegionPredicate {
798+
WherePredicate::RegionPredicate(WhereRegionPredicate { lifetime, bounds, span }) => {
799+
WherePredicate::RegionPredicate(WhereRegionPredicate {
803800
span: fld.new_span(span),
804801
lifetime: noop_fold_lifetime(lifetime, fld),
805802
bounds: bounds.move_map(|bound| noop_fold_param_bound(bound, fld))
806803
})
807804
}
808-
ast::WherePredicate::EqPredicate(ast::WhereEqPredicate{id,
809-
lhs_ty,
810-
rhs_ty,
811-
span}) => {
812-
ast::WherePredicate::EqPredicate(ast::WhereEqPredicate{
805+
WherePredicate::EqPredicate(WhereEqPredicate { id, lhs_ty, rhs_ty, span }) => {
806+
WherePredicate::EqPredicate(WhereEqPredicate{
813807
id: fld.new_id(id),
814808
lhs_ty: fld.fold_ty(lhs_ty),
815809
rhs_ty: fld.fold_ty(rhs_ty),
@@ -821,15 +815,13 @@ pub fn noop_fold_where_predicate<T: Folder>(
821815

822816
pub fn noop_fold_variant_data<T: Folder>(vdata: VariantData, fld: &mut T) -> VariantData {
823817
match vdata {
824-
ast::VariantData::Struct(fields, id) => {
825-
ast::VariantData::Struct(fields.move_map(|f| fld.fold_struct_field(f)),
826-
fld.new_id(id))
818+
VariantData::Struct(fields, id) => {
819+
VariantData::Struct(fields.move_map(|f| fld.fold_struct_field(f)), fld.new_id(id))
827820
}
828-
ast::VariantData::Tuple(fields, id) => {
829-
ast::VariantData::Tuple(fields.move_map(|f| fld.fold_struct_field(f)),
830-
fld.new_id(id))
821+
VariantData::Tuple(fields, id) => {
822+
VariantData::Tuple(fields.move_map(|f| fld.fold_struct_field(f)), fld.new_id(id))
831823
}
832-
ast::VariantData::Unit(id) => ast::VariantData::Unit(fld.new_id(id))
824+
VariantData::Unit(id) => VariantData::Unit(fld.new_id(id))
833825
}
834826
}
835827

@@ -839,14 +831,14 @@ pub fn noop_fold_trait_ref<T: Folder>(p: TraitRef, fld: &mut T) -> TraitRef {
839831
path,
840832
ref_id: _,
841833
} = p;
842-
ast::TraitRef {
834+
TraitRef {
843835
path: fld.fold_path(path),
844836
ref_id: id,
845837
}
846838
}
847839

848840
pub fn noop_fold_poly_trait_ref<T: Folder>(p: PolyTraitRef, fld: &mut T) -> PolyTraitRef {
849-
ast::PolyTraitRef {
841+
PolyTraitRef {
850842
bound_generic_params: fld.fold_generic_params(p.bound_generic_params),
851843
trait_ref: fld.fold_trait_ref(p.trait_ref),
852844
span: fld.new_span(p.span),
@@ -932,7 +924,7 @@ pub fn noop_fold_item_kind<T: Folder>(i: ItemKind, folder: &mut T) -> ItemKind {
932924
ItemKind::Enum(enum_definition, generics) => {
933925
let generics = folder.fold_generics(generics);
934926
let variants = enum_definition.variants.move_map(|x| folder.fold_variant(x));
935-
ItemKind::Enum(ast::EnumDef { variants }, generics)
927+
ItemKind::Enum(EnumDef { variants }, generics)
936928
}
937929
ItemKind::Struct(struct_def, generics) => {
938930
let generics = folder.fold_generics(generics);
@@ -991,7 +983,7 @@ pub fn noop_fold_trait_item<T: Folder>(i: TraitItem, folder: &mut T) -> SmallVec
991983
TraitItemKind::Type(folder.fold_bounds(bounds),
992984
default.map(|x| folder.fold_ty(x)))
993985
}
994-
ast::TraitItemKind::Macro(mac) => {
986+
TraitItemKind::Macro(mac) => {
995987
TraitItemKind::Macro(folder.fold_mac(mac))
996988
}
997989
},
@@ -1009,18 +1001,18 @@ pub fn noop_fold_impl_item<T: Folder>(i: ImplItem, folder: &mut T)-> SmallVec<[I
10091001
generics: folder.fold_generics(i.generics),
10101002
defaultness: i.defaultness,
10111003
node: match i.node {
1012-
ast::ImplItemKind::Const(ty, expr) => {
1013-
ast::ImplItemKind::Const(folder.fold_ty(ty), folder.fold_expr(expr))
1004+
ImplItemKind::Const(ty, expr) => {
1005+
ImplItemKind::Const(folder.fold_ty(ty), folder.fold_expr(expr))
10141006
}
1015-
ast::ImplItemKind::Method(sig, body) => {
1016-
ast::ImplItemKind::Method(noop_fold_method_sig(sig, folder),
1007+
ImplItemKind::Method(sig, body) => {
1008+
ImplItemKind::Method(noop_fold_method_sig(sig, folder),
10171009
folder.fold_block(body))
10181010
}
1019-
ast::ImplItemKind::Type(ty) => ast::ImplItemKind::Type(folder.fold_ty(ty)),
1020-
ast::ImplItemKind::Existential(bounds) => {
1021-
ast::ImplItemKind::Existential(folder.fold_bounds(bounds))
1011+
ImplItemKind::Type(ty) => ImplItemKind::Type(folder.fold_ty(ty)),
1012+
ImplItemKind::Existential(bounds) => {
1013+
ImplItemKind::Existential(folder.fold_bounds(bounds))
10221014
},
1023-
ast::ImplItemKind::Macro(mac) => ast::ImplItemKind::Macro(folder.fold_mac(mac))
1015+
ImplItemKind::Macro(mac) => ImplItemKind::Macro(folder.fold_mac(mac))
10241016
},
10251017
span: folder.new_span(i.span),
10261018
tokens: i.tokens,
@@ -1042,28 +1034,28 @@ pub fn noop_fold_mod<T: Folder>(Mod {inner, items, inline}: Mod, folder: &mut T)
10421034

10431035
pub fn noop_fold_crate<T: Folder>(Crate {module, attrs, span}: Crate,
10441036
folder: &mut T) -> Crate {
1045-
let mut items = folder.fold_item(P(ast::Item {
1037+
let mut items = folder.fold_item(P(Item {
10461038
ident: keywords::Invalid.ident(),
10471039
attrs,
1048-
id: ast::DUMMY_NODE_ID,
1049-
vis: respan(span.shrink_to_lo(), ast::VisibilityKind::Public),
1040+
id: DUMMY_NODE_ID,
1041+
vis: respan(span.shrink_to_lo(), VisibilityKind::Public),
10501042
span,
1051-
node: ast::ItemKind::Mod(module),
1043+
node: ItemKind::Mod(module),
10521044
tokens: None,
10531045
})).into_iter();
10541046

10551047
let (module, attrs, span) = match items.next() {
10561048
Some(item) => {
10571049
assert!(items.next().is_none(),
10581050
"a crate cannot expand to more than one item");
1059-
item.and_then(|ast::Item { attrs, span, node, .. }| {
1051+
item.and_then(|Item { attrs, span, node, .. }| {
10601052
match node {
1061-
ast::ItemKind::Mod(m) => (m, attrs, span),
1053+
ItemKind::Mod(m) => (m, attrs, span),
10621054
_ => panic!("fold converted a module to not a module"),
10631055
}
10641056
})
10651057
}
1066-
None => (ast::Mod {
1058+
None => (Mod {
10671059
inner: span,
10681060
items: vec![],
10691061
inline: true,
@@ -1155,7 +1147,7 @@ pub fn noop_fold_pat<T: Folder>(p: P<Pat>, folder: &mut T) -> P<Pat> {
11551147
let pth = folder.fold_path(pth);
11561148
let fs = fields.move_map(|f| {
11571149
Spanned { span: folder.new_span(f.span),
1158-
node: ast::FieldPat {
1150+
node: FieldPat {
11591151
ident: folder.fold_ident(f.node.ident),
11601152
pat: folder.fold_pat(f.node.pat),
11611153
is_shorthand: f.node.is_shorthand,

0 commit comments

Comments
 (0)