Skip to content

Refactored syntax::fold #15999

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 31, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/librustc/front/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl<'a> fold::Folder for Context<'a> {
fold_expr(self, expr)
}
fn fold_mac(&mut self, mac: &ast::Mac) -> ast::Mac {
fold::fold_mac(mac, self)
fold::noop_fold_mac(mac, self)
}
}

Expand Down
24 changes: 12 additions & 12 deletions src/libsyntax/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ pub struct Crate {

pub type MetaItem = Spanned<MetaItem_>;

#[deriving(Clone, Encodable, Decodable, Eq, Hash, Show)]
#[deriving(Clone, Eq, Encodable, Decodable, Hash, Show)]
pub enum MetaItem_ {
MetaWord(InternedString),
MetaList(InternedString, Vec<Gc<MetaItem>>),
Expand Down Expand Up @@ -423,7 +423,7 @@ pub enum LocalSource {
// FIXME (pending discussion of #1697, #2178...): local should really be
// a refinement on pat.
/// Local represents a `let` statement, e.g., `let <pat>:<ty> = <expr>;`
#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct Local {
pub ty: P<Ty>,
pub pat: Gc<Pat>,
Expand All @@ -435,7 +435,7 @@ pub struct Local {

pub type Decl = Spanned<Decl_>;

#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum Decl_ {
/// A local (let) binding:
DeclLocal(Gc<Local>),
Expand Down Expand Up @@ -677,7 +677,7 @@ pub struct MutTy {
pub mutbl: Mutability,
}

#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct TypeField {
pub ident: Ident,
pub mt: MutTy,
Expand Down Expand Up @@ -961,15 +961,15 @@ pub enum ExplicitSelf_ {

pub type ExplicitSelf = Spanned<ExplicitSelf_>;

#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct Method {
pub attrs: Vec<Attribute>,
pub id: NodeId,
pub span: Span,
pub node: Method_,
}

#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum Method_ {
/// Represents a method declaration
MethDecl(Ident,
Expand Down Expand Up @@ -1048,7 +1048,7 @@ pub type PathListItem = Spanned<PathListItem_>;

pub type ViewPath = Spanned<ViewPath_>;

#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum ViewPath_ {

/// `quux = foo::bar::baz`
Expand Down Expand Up @@ -1113,7 +1113,7 @@ pub struct Attribute_ {
/// that the ref_id is for. The impl_id maps to the "self type" of this impl.
/// If this impl is an ItemImpl, the impl_id is redundant (it could be the
/// same as the impl's node id).
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct TraitRef {
pub path: Path,
pub ref_id: NodeId,
Expand Down Expand Up @@ -1169,7 +1169,7 @@ impl StructFieldKind {
}
}

#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct StructDef {
/// Fields, not including ctor
pub fields: Vec<StructField>,
Expand Down Expand Up @@ -1219,7 +1219,7 @@ pub enum Item_ {
ItemMac(Mac),
}

#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub struct ForeignItem {
pub ident: Ident,
pub attrs: Vec<Attribute>,
Expand All @@ -1229,7 +1229,7 @@ pub struct ForeignItem {
pub vis: Visibility,
}

#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum ForeignItem_ {
ForeignItemFn(P<FnDecl>, Generics),
ForeignItemStatic(P<Ty>, /* is_mutbl */ bool),
Expand All @@ -1238,7 +1238,7 @@ pub enum ForeignItem_ {
/// The data we save and restore about an inlined item or method. This is not
/// part of the AST that we parse from a file, but it becomes part of the tree
/// that we trans.
#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)]
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum InlinedItem {
IIItem(Gc<Item>),
IIMethod(DefId /* impl id */, bool /* is provided */, Gc<Method>),
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/ast_map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ impl<'a, F: FoldOps> Folder for Ctx<'a, F> {
}

fn fold_mac(&mut self, mac: &Mac) -> Mac {
fold::fold_mac(mac, self)
fold::noop_fold_mac(mac, self)
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/libsyntax/ext/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ fn expand_item_underscore(item: &ast::Item_, fld: &mut MacroExpander) -> ast::It
ast::ItemFn(decl, fn_style, abi, ref generics, body) => {
let (rewritten_fn_decl, rewritten_body)
= expand_and_rename_fn_decl_and_block(&*decl, body, fld);
let expanded_generics = fold::fold_generics(generics,fld);
let expanded_generics = fold::noop_fold_generics(generics,fld);
ast::ItemFn(rewritten_fn_decl, fn_style, abi, expanded_generics, rewritten_body)
}
_ => noop_fold_item_underscore(&*item, fld)
Expand Down Expand Up @@ -792,7 +792,7 @@ impl<'a> Folder for IdentRenamer<'a> {
}
}
fn fold_mac(&mut self, macro: &ast::Mac) -> ast::Mac {
fold::fold_mac(macro, self)
fold::noop_fold_mac(macro, self)
}
}

Expand Down Expand Up @@ -824,7 +824,7 @@ impl<'a> Folder for PatIdentRenamer<'a> {
}
}
fn fold_mac(&mut self, macro: &ast::Mac) -> ast::Mac {
fold::fold_mac(macro, self)
fold::noop_fold_mac(macro, self)
}
}

Expand All @@ -847,7 +847,7 @@ fn expand_method(m: &ast::Method, fld: &mut MacroExpander) -> SmallVector<Gc<ast
id: id,
span: fld.new_span(m.span),
node: ast::MethDecl(fld.fold_ident(ident),
fold_generics(generics, fld),
noop_fold_generics(generics, fld),
abi,
fld.fold_explicit_self(explicit_self),
fn_style,
Expand Down Expand Up @@ -1014,7 +1014,7 @@ impl Folder for Marker {
let macro = match m.node {
MacInvocTT(ref path, ref tts, ctxt) => {
MacInvocTT(self.fold_path(path),
fold_tts(tts.as_slice(), self),
self.fold_tts(tts.as_slice()),
mtwt::apply_mark(self.mark, ctxt))
}
};
Expand All @@ -1027,7 +1027,7 @@ impl Folder for Marker {

// apply a given mark to the given token trees. Used prior to expansion of a macro.
fn mark_tts(tts: &[TokenTree], m: Mrk) -> Vec<TokenTree> {
fold_tts(tts, &mut Marker{mark:m})
noop_fold_tts(tts, &mut Marker{mark:m})
}

// apply a given mark to the given expr. Used following the expansion of a macro.
Expand Down
Loading