diff options
| author | Kasey Carrothers <kaseyc.808@gmail.com> | 2014-04-06 18:04:40 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-04-10 15:22:00 -0700 |
| commit | 0bf4e900d421f011d7c68016308aab4998f9084e (patch) | |
| tree | fd128aabc724629c461caa4e8fc79da30a2c1e25 /src/libsyntax | |
| parent | 3f2c55f7d5b5c7717dd12eef4572c52a4e8ff550 (diff) | |
| download | rust-0bf4e900d421f011d7c68016308aab4998f9084e.tar.gz rust-0bf4e900d421f011d7c68016308aab4998f9084e.zip | |
Renamed ast::Purity to ast::FnStyle and ast::ImpureFn to ast::NormalFn and updated associated variable and function names.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 22 | ||||
| -rw-r--r-- | src/libsyntax/ast_util.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/build.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/generic.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/fold.rs | 12 | ||||
| -rw-r--r-- | src/libsyntax/parse/mod.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 46 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 50 | ||||
| -rw-r--r-- | src/libsyntax/visit.rs | 6 |
9 files changed, 72 insertions, 72 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 6a5acff3fe0..1eb034a573a 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -210,8 +210,8 @@ pub enum MethodProvenance { #[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)] pub enum Def { - DefFn(DefId, Purity), - DefStaticMethod(/* method */ DefId, MethodProvenance, Purity), + DefFn(DefId, FnStyle), + DefStaticMethod(/* method */ DefId, MethodProvenance, FnStyle), DefSelfTy(/* trait id */ NodeId), DefMod(DefId), DefForeignMod(DefId), @@ -696,7 +696,7 @@ pub struct TypeField { pub struct TypeMethod { pub ident: Ident, pub attrs: Vec<Attribute>, - pub purity: Purity, + pub fn_style: FnStyle, pub decl: P<FnDecl>, pub generics: Generics, pub explicit_self: ExplicitSelf, @@ -794,7 +794,7 @@ pub struct ClosureTy { pub sigil: Sigil, pub region: Option<Lifetime>, pub lifetimes: Vec<Lifetime>, - pub purity: Purity, + pub fn_style: FnStyle, pub onceness: Onceness, pub decl: P<FnDecl>, // Optional optvec distinguishes between "fn()" and "fn:()" so we can @@ -806,7 +806,7 @@ pub struct ClosureTy { #[deriving(Eq, TotalEq, Encodable, Decodable, Hash)] pub struct BareFnTy { - pub purity: Purity, + pub fn_style: FnStyle, pub abi: Abi, pub lifetimes: Vec<Lifetime>, pub decl: P<FnDecl> @@ -886,16 +886,16 @@ pub struct FnDecl { } #[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)] -pub enum Purity { +pub enum FnStyle { UnsafeFn, // declared with "unsafe fn" - ImpureFn, // declared with "fn" + NormalFn, // declared with "fn" ExternFn, // declared with "extern fn" } -impl fmt::Show for Purity { +impl fmt::Show for FnStyle { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { - ImpureFn => "impure".fmt(f), + NormalFn => "normal".fmt(f), UnsafeFn => "unsafe".fmt(f), ExternFn => "extern".fmt(f), } @@ -925,7 +925,7 @@ pub struct Method { pub attrs: Vec<Attribute>, pub generics: Generics, pub explicit_self: ExplicitSelf, - pub purity: Purity, + pub fn_style: FnStyle, pub decl: P<FnDecl>, pub body: P<Block>, pub id: NodeId, @@ -1119,7 +1119,7 @@ pub struct Item { #[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)] pub enum Item_ { ItemStatic(P<Ty>, Mutability, @Expr), - ItemFn(P<FnDecl>, Purity, Abi, Generics, P<Block>), + ItemFn(P<FnDecl>, FnStyle, Abi, Generics, P<Block>), ItemMod(Mod), ItemForeignMod(ForeignMod), ItemTy(P<Ty>, Generics), diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index ec9c02ac82a..55864205996 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -264,7 +264,7 @@ pub fn trait_method_to_ty_method(method: &TraitMethod) -> TypeMethod { TypeMethod { ident: m.ident, attrs: m.attrs.clone(), - purity: m.purity, + fn_style: m.fn_style, decl: m.decl, generics: m.generics.clone(), explicit_self: m.explicit_self, diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index b7c12cd4fdc..203edf6590f 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -825,7 +825,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { name, Vec::new(), ast::ItemFn(self.fn_decl(inputs, output), - ast::ImpureFn, + ast::NormalFn, abi::Rust, generics, body)) diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs index 1dcb753624d..8a44caf34a5 100644 --- a/src/libsyntax/ext/deriving/generic.rs +++ b/src/libsyntax/ext/deriving/generic.rs @@ -619,7 +619,7 @@ impl<'a> MethodDef<'a> { attrs: attrs, generics: fn_generics, explicit_self: explicit_self, - purity: ast::ImpureFn, + fn_style: ast::NormalFn, decl: fn_decl, body: body_block, id: ast::DUMMY_NODE_ID, diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index e21f14e4a96..e9e69eabef8 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -158,7 +158,7 @@ pub trait Folder { TyClosure(ref f) => { TyClosure(@ClosureTy { sigil: f.sigil, - purity: f.purity, + fn_style: f.fn_style, region: fold_opt_lifetime(&f.region, self), onceness: f.onceness, bounds: fold_opt_bounds(&f.bounds, self), @@ -169,7 +169,7 @@ pub trait Folder { TyBareFn(ref f) => { TyBareFn(@BareFnTy { lifetimes: f.lifetimes.iter().map(|l| fold_lifetime(l, self)).collect(), - purity: f.purity, + fn_style: f.fn_style, abi: f.abi, decl: self.fold_fn_decl(f.decl) }) @@ -549,10 +549,10 @@ pub fn noop_fold_item_underscore<T: Folder>(i: &Item_, folder: &mut T) -> Item_ ItemStatic(t, m, e) => { ItemStatic(folder.fold_ty(t), m, folder.fold_expr(e)) } - ItemFn(decl, purity, abi, ref generics, body) => { + ItemFn(decl, fn_style, abi, ref generics, body) => { ItemFn( folder.fold_fn_decl(decl), - purity, + fn_style, abi, fold_generics(generics, folder), folder.fold_block(body) @@ -603,7 +603,7 @@ pub fn noop_fold_type_method<T: Folder>(m: &TypeMethod, fld: &mut T) -> TypeMeth id: fld.new_id(m.id), // Needs to be first, for ast_map. ident: fld.fold_ident(m.ident), attrs: m.attrs.iter().map(|a| fold_attribute_(*a, fld)).collect(), - purity: m.purity, + fn_style: m.fn_style, decl: fld.fold_fn_decl(m.decl), generics: fold_generics(&m.generics, fld), explicit_self: fld.fold_explicit_self(&m.explicit_self), @@ -680,7 +680,7 @@ pub fn noop_fold_method<T: Folder>(m: &Method, folder: &mut T) -> @Method { attrs: m.attrs.iter().map(|a| fold_attribute_(*a, folder)).collect(), generics: fold_generics(&m.generics, folder), explicit_self: folder.fold_explicit_self(&m.explicit_self), - purity: m.purity, + fn_style: m.fn_style, decl: folder.fold_fn_decl(m.decl), body: folder.fold_block(m.body), span: folder.new_span(m.span), diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 35f9898ebbb..eca9f955d93 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -657,7 +657,7 @@ mod test { cf: ast::Return, variadic: false }), - ast::ImpureFn, + ast::NormalFn, abi::Rust, ast::Generics{ // no idea on either of these: lifetimes: Vec::new(), diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index c8ea0b6aac2..fe4bd87c4eb 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -14,7 +14,7 @@ use abi; use ast::{Sigil, BorrowedSigil, ManagedSigil, OwnedSigil}; use ast::{BareFnTy, ClosureTy}; use ast::{RegionTyParamBound, TraitTyParamBound}; -use ast::{Provided, Public, Purity}; +use ast::{Provided, Public, FnStyle}; use ast::{Mod, BiAdd, Arg, Arm, Attribute, BindByRef, BindByValue}; use ast::{BiBitAnd, BiBitOr, BiBitXor, Block}; use ast::{BlockCheckMode, UnBox}; @@ -31,7 +31,7 @@ use ast::{ExprVec, ExprVstore, ExprVstoreSlice}; use ast::{ExprVstoreMutSlice, ExprWhile, ExprForLoop, ExternFn, Field, FnDecl}; use ast::{ExprVstoreUniq, Once, Many}; use ast::{ForeignItem, ForeignItemStatic, ForeignItemFn, ForeignMod}; -use ast::{Ident, ImpureFn, Inherited, Item, Item_, ItemStatic}; +use ast::{Ident, NormalFn, Inherited, Item, Item_, ItemStatic}; use ast::{ItemEnum, ItemFn, ItemForeignMod, ItemImpl}; use ast::{ItemMac, ItemMod, ItemStruct, ItemTrait, ItemTy, Lit, Lit_}; use ast::{LitBool, LitFloat, LitFloatUnsuffixed, LitInt, LitChar}; @@ -867,7 +867,7 @@ impl<'a> Parser<'a> { | | | Argument types | | Lifetimes | | - | Purity + | Function Style ABI */ @@ -878,12 +878,12 @@ impl<'a> Parser<'a> { abi::Rust }; - let purity = self.parse_unsafety(); + let fn_style = self.parse_unsafety(); self.expect_keyword(keywords::Fn); let (decl, lifetimes) = self.parse_ty_fn_decl(true); return TyBareFn(@BareFnTy { abi: abi, - purity: purity, + fn_style: fn_style, lifetimes: lifetimes, decl: decl }); @@ -925,7 +925,7 @@ impl<'a> Parser<'a> { TyClosure(@ClosureTy { sigil: OwnedSigil, region: None, - purity: ImpureFn, + fn_style: NormalFn, onceness: Once, bounds: bounds, decl: decl, @@ -945,11 +945,11 @@ impl<'a> Parser<'a> { | | | Argument types | | Lifetimes | Once-ness (a.k.a., affine) - Purity + Function Style */ - let purity = self.parse_unsafety(); + let fn_style = self.parse_unsafety(); let onceness = if self.eat_keyword(keywords::Once) {Once} else {Many}; let lifetimes = if self.eat(&token::LT) { @@ -985,7 +985,7 @@ impl<'a> Parser<'a> { TyClosure(@ClosureTy { sigil: BorrowedSigil, region: region, - purity: purity, + fn_style: fn_style, onceness: onceness, bounds: bounds, decl: decl, @@ -993,11 +993,11 @@ impl<'a> Parser<'a> { }) } - pub fn parse_unsafety(&mut self) -> Purity { + pub fn parse_unsafety(&mut self) -> FnStyle { if self.eat_keyword(keywords::Unsafe) { return UnsafeFn; } else { - return ImpureFn; + return NormalFn; } } @@ -1045,7 +1045,7 @@ impl<'a> Parser<'a> { let vis_span = p.span; let vis = p.parse_visibility(); - let pur = p.parse_fn_purity(); + let style = p.parse_fn_style(); // NB: at the moment, trait methods are public by default; this // could change. let ident = p.parse_ident(); @@ -1071,7 +1071,7 @@ impl<'a> Parser<'a> { Required(TypeMethod { ident: ident, attrs: attrs, - purity: pur, + fn_style: style, decl: d, generics: generics, explicit_self: explicit_self, @@ -1089,7 +1089,7 @@ impl<'a> Parser<'a> { attrs: attrs, generics: generics, explicit_self: explicit_self, - purity: pur, + fn_style: style, decl: d, body: body, id: ast::DUMMY_NODE_ID, @@ -3754,11 +3754,11 @@ impl<'a> Parser<'a> { } // parse an item-position function declaration. - fn parse_item_fn(&mut self, purity: Purity, abi: abi::Abi) -> ItemInfo { + fn parse_item_fn(&mut self, fn_style: FnStyle, abi: abi::Abi) -> ItemInfo { let (ident, generics) = self.parse_fn_header(); let decl = self.parse_fn_decl(false); let (inner_attrs, body) = self.parse_inner_attrs_and_block(); - (ident, ItemFn(decl, purity, abi, generics, body), Some(inner_attrs)) + (ident, ItemFn(decl, fn_style, abi, generics, body), Some(inner_attrs)) } // parse a method in a trait impl, starting with `attrs` attributes. @@ -3772,7 +3772,7 @@ impl<'a> Parser<'a> { let lo = self.span.lo; let visa = self.parse_visibility(); - let pur = self.parse_fn_purity(); + let fn_style = self.parse_fn_style(); let ident = self.parse_ident(); let generics = self.parse_generics(); let (explicit_self, decl) = self.parse_fn_decl_with_self(|p| { @@ -3787,7 +3787,7 @@ impl<'a> Parser<'a> { attrs: attrs, generics: generics, explicit_self: explicit_self, - purity: pur, + fn_style: fn_style, decl: decl, body: body, id: ast::DUMMY_NODE_ID, @@ -4169,8 +4169,8 @@ impl<'a> Parser<'a> { let lo = self.span.lo; // Parse obsolete purity. - let purity = self.parse_fn_purity(); - if purity != ImpureFn { + let fn_style = self.parse_fn_style(); + if fn_style != NormalFn { self.obsolete(self.last_span, ObsoleteUnsafeExternFn); } @@ -4208,8 +4208,8 @@ impl<'a> Parser<'a> { } // parse safe/unsafe and fn - fn parse_fn_purity(&mut self) -> Purity { - if self.eat_keyword(keywords::Fn) { ImpureFn } + fn parse_fn_style(&mut self) -> FnStyle { + if self.eat_keyword(keywords::Fn) { NormalFn } else if self.eat_keyword(keywords::Unsafe) { self.expect_keyword(keywords::Fn); UnsafeFn @@ -4540,7 +4540,7 @@ impl<'a> Parser<'a> { // FUNCTION ITEM self.bump(); let (ident, item_, extra_attrs) = - self.parse_item_fn(ImpureFn, abi::Rust); + self.parse_item_fn(NormalFn, abi::Rust); let item = self.mk_item(lo, self.last_span.hi, ident, diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 44e95aa9573..b33f76a6047 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -186,11 +186,11 @@ pub fn path_to_str(p: &ast::Path) -> ~str { to_str(|s| s.print_path(p, false)) } -pub fn fun_to_str(decl: &ast::FnDecl, purity: ast::Purity, name: ast::Ident, +pub fn fun_to_str(decl: &ast::FnDecl, fn_style: ast::FnStyle, name: ast::Ident, opt_explicit_self: Option<ast::ExplicitSelf_>, generics: &ast::Generics) -> ~str { to_str(|s| { - try!(s.print_fn(decl, Some(purity), abi::Rust, + try!(s.print_fn(decl, Some(fn_style), abi::Rust, name, generics, opt_explicit_self, ast::Inherited)); try!(s.end()); // Close the head box s.end() // Close the outer box @@ -479,7 +479,7 @@ impl<'a> State<'a> { ty_params: OwnedSlice::empty() }; try!(self.print_ty_fn(Some(f.abi), None, &None, - f.purity, ast::Many, f.decl, None, &None, + f.fn_style, ast::Many, f.decl, None, &None, Some(&generics), None)); } ast::TyClosure(f) => { @@ -488,7 +488,7 @@ impl<'a> State<'a> { ty_params: OwnedSlice::empty() }; try!(self.print_ty_fn(None, Some(f.sigil), &f.region, - f.purity, f.onceness, f.decl, None, &f.bounds, + f.fn_style, f.onceness, f.decl, None, &f.bounds, Some(&generics), None)); } ast::TyPath(ref path, ref bounds, _) => { @@ -567,10 +567,10 @@ impl<'a> State<'a> { try!(word(&mut self.s, ";")); try!(self.end()); // end the outer cbox } - ast::ItemFn(decl, purity, abi, ref typarams, body) => { + ast::ItemFn(decl, fn_style, abi, ref typarams, body) => { try!(self.print_fn( decl, - Some(purity), + Some(fn_style), abi, item.ident, typarams, @@ -861,7 +861,7 @@ impl<'a> State<'a> { try!(self.print_ty_fn(None, None, &None, - m.purity, + m.fn_style, ast::Many, m.decl, Some(m.ident), @@ -883,7 +883,7 @@ impl<'a> State<'a> { try!(self.hardbreak_if_not_bol()); try!(self.maybe_print_comment(meth.span.lo)); try!(self.print_outer_attributes(meth.attrs.as_slice())); - try!(self.print_fn(meth.decl, Some(meth.purity), abi::Rust, + try!(self.print_fn(meth.decl, Some(meth.fn_style), abi::Rust, meth.ident, &meth.generics, Some(meth.explicit_self.node), meth.vis)); try!(word(&mut self.s, " ")); @@ -1708,14 +1708,14 @@ impl<'a> State<'a> { pub fn print_fn(&mut self, decl: &ast::FnDecl, - purity: Option<ast::Purity>, + fn_style: Option<ast::FnStyle>, abi: abi::Abi, name: ast::Ident, generics: &ast::Generics, opt_explicit_self: Option<ast::ExplicitSelf_>, vis: ast::Visibility) -> IoResult<()> { try!(self.head("")); - try!(self.print_fn_header_info(opt_explicit_self, purity, abi, + try!(self.print_fn_header_info(opt_explicit_self, fn_style, abi, ast::Many, None, vis)); try!(self.nbsp()); try!(self.print_ident(name)); @@ -2024,7 +2024,7 @@ impl<'a> State<'a> { opt_abi: Option<abi::Abi>, opt_sigil: Option<ast::Sigil>, opt_region: &Option<ast::Lifetime>, - purity: ast::Purity, + fn_style: ast::FnStyle, onceness: ast::Onceness, decl: &ast::FnDecl, id: Option<ast::Ident>, @@ -2040,12 +2040,12 @@ impl<'a> State<'a> { try!(word(&mut self.s, "proc")); } else if opt_sigil == Some(ast::BorrowedSigil) { try!(self.print_extern_opt_abi(opt_abi)); - try!(self.print_purity(purity)); + try!(self.print_fn_style(fn_style)); try!(self.print_onceness(onceness)); } else { try!(self.print_opt_abi_and_extern_if_nondefault(opt_abi)); try!(self.print_opt_sigil(opt_sigil)); - try!(self.print_purity(purity)); + try!(self.print_fn_style(fn_style)); try!(self.print_onceness(onceness)); try!(word(&mut self.s, "fn")); } @@ -2294,10 +2294,10 @@ impl<'a> State<'a> { } } - pub fn print_opt_purity(&mut self, - opt_purity: Option<ast::Purity>) -> IoResult<()> { - match opt_purity { - Some(purity) => self.print_purity(purity), + pub fn print_opt_fn_style(&mut self, + opt_fn_style: Option<ast::FnStyle>) -> IoResult<()> { + match opt_fn_style { + Some(fn_style) => self.print_fn_style(fn_style), None => Ok(()) } } @@ -2338,7 +2338,7 @@ impl<'a> State<'a> { pub fn print_fn_header_info(&mut self, _opt_explicit_self: Option<ast::ExplicitSelf_>, - opt_purity: Option<ast::Purity>, + opt_fn_style: Option<ast::FnStyle>, abi: abi::Abi, onceness: ast::Onceness, opt_sigil: Option<ast::Sigil>, @@ -2349,11 +2349,11 @@ impl<'a> State<'a> { try!(self.word_nbsp("extern")); try!(self.word_nbsp(abi.to_str())); - if opt_purity != Some(ast::ExternFn) { - try!(self.print_opt_purity(opt_purity)); + if opt_fn_style != Some(ast::ExternFn) { + try!(self.print_opt_fn_style(opt_fn_style)); } } else { - try!(self.print_opt_purity(opt_purity)); + try!(self.print_opt_fn_style(opt_fn_style)); } try!(self.print_onceness(onceness)); @@ -2361,9 +2361,9 @@ impl<'a> State<'a> { self.print_opt_sigil(opt_sigil) } - pub fn print_purity(&mut self, p: ast::Purity) -> IoResult<()> { - match p { - ast::ImpureFn => Ok(()), + pub fn print_fn_style(&mut self, s: ast::FnStyle) -> IoResult<()> { + match s { + ast::NormalFn => Ok(()), ast::UnsafeFn => self.word_nbsp("unsafe"), ast::ExternFn => self.word_nbsp("extern") } @@ -2399,7 +2399,7 @@ mod test { variadic: false }; let generics = ast_util::empty_generics(); - assert_eq!(&fun_to_str(&decl, ast::ImpureFn, abba_ident, + assert_eq!(&fun_to_str(&decl, ast::NormalFn, abba_ident, None, &generics), &~"fn abba()"); } diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 81e5e228027..5b376f4c5fe 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -29,7 +29,7 @@ use owned_slice::OwnedSlice; pub enum FnKind<'a> { // fn foo() or extern "Abi" fn foo() - FkItemFn(Ident, &'a Generics, Purity, Abi), + FkItemFn(Ident, &'a Generics, FnStyle, Abi), // fn foo(&self) FkMethod(Ident, &'a Generics, &'a Method), @@ -207,8 +207,8 @@ pub fn walk_item<E: Clone, V: Visitor<E>>(visitor: &mut V, item: &Item, env: E) visitor.visit_ty(typ, env.clone()); visitor.visit_expr(expr, env); } - ItemFn(declaration, purity, abi, ref generics, body) => { - visitor.visit_fn(&FkItemFn(item.ident, generics, purity, abi), + ItemFn(declaration, fn_style, abi, ref generics, body) => { + visitor.visit_fn(&FkItemFn(item.ident, generics, fn_style, abi), declaration, body, item.span, |
