1
Fork 0

Renamed ast::Purity to ast::FnStyle and ast::ImpureFn to ast::NormalFn and updated associated variable and function names.

This commit is contained in:
Kasey Carrothers 2014-04-06 18:04:40 -07:00 committed by Alex Crichton
parent 3f2c55f7d5
commit 0bf4e900d4
40 changed files with 262 additions and 262 deletions

View file

@ -28,7 +28,7 @@ use syntax::parse::token;
pub struct StaticMethodInfo { pub struct StaticMethodInfo {
pub ident: ast::Ident, pub ident: ast::Ident,
pub def_id: ast::DefId, pub def_id: ast::DefId,
pub purity: ast::Purity, pub fn_style: ast::FnStyle,
pub vis: ast::Visibility, pub vis: ast::Visibility,
} }

View file

@ -330,11 +330,11 @@ fn item_to_def_like(item: ebml::Doc, did: ast::DefId, cnum: ast::CrateNum)
MutStatic => DlDef(ast::DefStatic(did, true)), MutStatic => DlDef(ast::DefStatic(did, true)),
Struct => DlDef(ast::DefStruct(did)), Struct => DlDef(ast::DefStruct(did)),
UnsafeFn => DlDef(ast::DefFn(did, ast::UnsafeFn)), UnsafeFn => DlDef(ast::DefFn(did, ast::UnsafeFn)),
Fn => DlDef(ast::DefFn(did, ast::ImpureFn)), Fn => DlDef(ast::DefFn(did, ast::NormalFn)),
ForeignFn => DlDef(ast::DefFn(did, ast::ExternFn)), ForeignFn => DlDef(ast::DefFn(did, ast::ExternFn)),
StaticMethod | UnsafeStaticMethod => { StaticMethod | UnsafeStaticMethod => {
let purity = if fam == UnsafeStaticMethod { ast::UnsafeFn } else let fn_style = if fam == UnsafeStaticMethod { ast::UnsafeFn } else
{ ast::ImpureFn }; { ast::NormalFn };
// def_static_method carries an optional field of its enclosing // def_static_method carries an optional field of its enclosing
// trait or enclosing impl (if this is an inherent static method). // trait or enclosing impl (if this is an inherent static method).
// So we need to detect whether this is in a trait or not, which // So we need to detect whether this is in a trait or not, which
@ -348,7 +348,7 @@ fn item_to_def_like(item: ebml::Doc, did: ast::DefId, cnum: ast::CrateNum)
ast::FromImpl(item_reqd_and_translated_parent_item(cnum, ast::FromImpl(item_reqd_and_translated_parent_item(cnum,
item)) item))
}; };
DlDef(ast::DefStaticMethod(did, provenance, purity)) DlDef(ast::DefStaticMethod(did, provenance, fn_style))
} }
Type | ForeignType => DlDef(ast::DefTy(did)), Type | ForeignType => DlDef(ast::DefTy(did)),
Mod => DlDef(ast::DefMod(did)), Mod => DlDef(ast::DefMod(did)),
@ -905,17 +905,17 @@ pub fn get_static_methods_if_impl(intr: Rc<IdentInterner>,
let family = item_family(impl_method_doc); let family = item_family(impl_method_doc);
match family { match family {
StaticMethod | UnsafeStaticMethod => { StaticMethod | UnsafeStaticMethod => {
let purity; let fn_style;
match item_family(impl_method_doc) { match item_family(impl_method_doc) {
StaticMethod => purity = ast::ImpureFn, StaticMethod => fn_style = ast::NormalFn,
UnsafeStaticMethod => purity = ast::UnsafeFn, UnsafeStaticMethod => fn_style = ast::UnsafeFn,
_ => fail!() _ => fail!()
} }
static_impl_methods.push(StaticMethodInfo { static_impl_methods.push(StaticMethodInfo {
ident: item_name(&*intr, impl_method_doc), ident: item_name(&*intr, impl_method_doc),
def_id: item_def_id(impl_method_doc, cdata), def_id: item_def_id(impl_method_doc, cdata),
purity: purity, fn_style: fn_style,
vis: item_visibility(impl_method_doc), vis: item_visibility(impl_method_doc),
}); });
} }

View file

@ -758,12 +758,12 @@ fn encode_method_ty_fields(ecx: &EncodeContext,
encode_method_fty(ecx, ebml_w, &method_ty.fty); encode_method_fty(ecx, ebml_w, &method_ty.fty);
encode_visibility(ebml_w, method_ty.vis); encode_visibility(ebml_w, method_ty.vis);
encode_explicit_self(ebml_w, method_ty.explicit_self); encode_explicit_self(ebml_w, method_ty.explicit_self);
let purity = method_ty.fty.purity; let fn_style = method_ty.fty.fn_style;
match method_ty.explicit_self { match method_ty.explicit_self {
ast::SelfStatic => { ast::SelfStatic => {
encode_family(ebml_w, purity_static_method_family(purity)); encode_family(ebml_w, fn_style_static_method_family(fn_style));
} }
_ => encode_family(ebml_w, purity_fn_family(purity)) _ => encode_family(ebml_w, style_fn_family(fn_style))
} }
encode_provided_source(ebml_w, method_ty.provided_source); encode_provided_source(ebml_w, method_ty.provided_source);
} }
@ -811,18 +811,18 @@ fn encode_info_for_method(ecx: &EncodeContext,
ebml_w.end_tag(); ebml_w.end_tag();
} }
fn purity_fn_family(p: Purity) -> char { fn style_fn_family(s: FnStyle) -> char {
match p { match s {
UnsafeFn => 'u', UnsafeFn => 'u',
ImpureFn => 'f', NormalFn => 'f',
ExternFn => 'e' ExternFn => 'e'
} }
} }
fn purity_static_method_family(p: Purity) -> char { fn fn_style_static_method_family(s: FnStyle) -> char {
match p { match s {
UnsafeFn => 'U', UnsafeFn => 'U',
ImpureFn => 'F', NormalFn => 'F',
_ => fail!("extern fn can't be static") _ => fail!("extern fn can't be static")
} }
} }
@ -911,11 +911,11 @@ fn encode_info_for_item(ecx: &EncodeContext,
encode_visibility(ebml_w, vis); encode_visibility(ebml_w, vis);
ebml_w.end_tag(); ebml_w.end_tag();
} }
ItemFn(_, purity, _, ref generics, _) => { ItemFn(_, fn_style, _, ref generics, _) => {
add_to_index(item, ebml_w, index); add_to_index(item, ebml_w, index);
ebml_w.start_tag(tag_items_data_item); ebml_w.start_tag(tag_items_data_item);
encode_def_id(ebml_w, def_id); encode_def_id(ebml_w, def_id);
encode_family(ebml_w, purity_fn_family(purity)); encode_family(ebml_w, style_fn_family(fn_style));
let tps_len = generics.ty_params.len(); let tps_len = generics.ty_params.len();
encode_bounds_and_type(ebml_w, ecx, &lookup_item_type(tcx, def_id)); encode_bounds_and_type(ebml_w, ecx, &lookup_item_type(tcx, def_id));
encode_name(ebml_w, item.ident.name); encode_name(ebml_w, item.ident.name);
@ -1165,8 +1165,8 @@ fn encode_info_for_item(ecx: &EncodeContext,
match method_ty.explicit_self { match method_ty.explicit_self {
SelfStatic => { SelfStatic => {
encode_family(ebml_w, encode_family(ebml_w,
purity_static_method_family( fn_style_static_method_family(
method_ty.fty.purity)); method_ty.fty.fn_style));
let tpt = ty::lookup_item_type(tcx, method_def_id); let tpt = ty::lookup_item_type(tcx, method_def_id);
encode_bounds_and_type(ebml_w, ecx, &tpt); encode_bounds_and_type(ebml_w, ecx, &tpt);
@ -1174,8 +1174,8 @@ fn encode_info_for_item(ecx: &EncodeContext,
_ => { _ => {
encode_family(ebml_w, encode_family(ebml_w,
purity_fn_family( style_fn_family(
method_ty.fty.purity)); method_ty.fty.fn_style));
} }
} }
@ -1227,7 +1227,7 @@ fn encode_info_for_foreign_item(ecx: &EncodeContext,
encode_def_id(ebml_w, local_def(nitem.id)); encode_def_id(ebml_w, local_def(nitem.id));
match nitem.node { match nitem.node {
ForeignItemFn(..) => { ForeignItemFn(..) => {
encode_family(ebml_w, purity_fn_family(ImpureFn)); encode_family(ebml_w, style_fn_family(NormalFn));
encode_bounds_and_type(ebml_w, ecx, encode_bounds_and_type(ebml_w, ecx,
&lookup_item_type(ecx.tcx,local_def(nitem.id))); &lookup_item_type(ecx.tcx,local_def(nitem.id)));
encode_name(ebml_w, nitem.ident.name); encode_name(ebml_w, nitem.ident.name);

View file

@ -449,12 +449,12 @@ fn parse_hex(st: &mut PState) -> uint {
}; };
} }
fn parse_purity(c: char) -> Purity { fn parse_fn_style(c: char) -> FnStyle {
match c { match c {
'u' => UnsafeFn, 'u' => UnsafeFn,
'i' => ImpureFn, 'n' => NormalFn,
'c' => ExternFn, 'c' => ExternFn,
_ => fail!("parse_purity: bad purity {}", c) _ => fail!("parse_fn_style: bad fn_style {}", c)
} }
} }
@ -476,13 +476,13 @@ fn parse_onceness(c: char) -> ast::Onceness {
fn parse_closure_ty(st: &mut PState, conv: conv_did) -> ty::ClosureTy { fn parse_closure_ty(st: &mut PState, conv: conv_did) -> ty::ClosureTy {
let sigil = parse_sigil(st); let sigil = parse_sigil(st);
let purity = parse_purity(next(st)); let fn_style = parse_fn_style(next(st));
let onceness = parse_onceness(next(st)); let onceness = parse_onceness(next(st));
let region = parse_region(st, |x,y| conv(x,y)); let region = parse_region(st, |x,y| conv(x,y));
let bounds = parse_bounds(st, |x,y| conv(x,y)); let bounds = parse_bounds(st, |x,y| conv(x,y));
let sig = parse_sig(st, |x,y| conv(x,y)); let sig = parse_sig(st, |x,y| conv(x,y));
ty::ClosureTy { ty::ClosureTy {
purity: purity, fn_style: fn_style,
sigil: sigil, sigil: sigil,
onceness: onceness, onceness: onceness,
region: region, region: region,
@ -492,11 +492,11 @@ fn parse_closure_ty(st: &mut PState, conv: conv_did) -> ty::ClosureTy {
} }
fn parse_bare_fn_ty(st: &mut PState, conv: conv_did) -> ty::BareFnTy { fn parse_bare_fn_ty(st: &mut PState, conv: conv_did) -> ty::BareFnTy {
let purity = parse_purity(next(st)); let fn_style = parse_fn_style(next(st));
let abi = parse_abi_set(st); let abi = parse_abi_set(st);
let sig = parse_sig(st, |x,y| conv(x,y)); let sig = parse_sig(st, |x,y| conv(x,y));
ty::BareFnTy { ty::BareFnTy {
purity: purity, fn_style: fn_style,
abi: abi, abi: abi,
sig: sig sig: sig
} }

View file

@ -332,9 +332,9 @@ fn enc_sigil(w: &mut MemWriter, sigil: Sigil) {
} }
} }
fn enc_purity(w: &mut MemWriter, p: Purity) { fn enc_fn_style(w: &mut MemWriter, p: FnStyle) {
match p { match p {
ImpureFn => mywrite!(w, "i"), NormalFn => mywrite!(w, "n"),
UnsafeFn => mywrite!(w, "u"), UnsafeFn => mywrite!(w, "u"),
ExternFn => mywrite!(w, "c") ExternFn => mywrite!(w, "c")
} }
@ -354,14 +354,14 @@ fn enc_onceness(w: &mut MemWriter, o: Onceness) {
} }
pub fn enc_bare_fn_ty(w: &mut MemWriter, cx: &ctxt, ft: &ty::BareFnTy) { pub fn enc_bare_fn_ty(w: &mut MemWriter, cx: &ctxt, ft: &ty::BareFnTy) {
enc_purity(w, ft.purity); enc_fn_style(w, ft.fn_style);
enc_abi(w, ft.abi); enc_abi(w, ft.abi);
enc_fn_sig(w, cx, &ft.sig); enc_fn_sig(w, cx, &ft.sig);
} }
fn enc_closure_ty(w: &mut MemWriter, cx: &ctxt, ft: &ty::ClosureTy) { fn enc_closure_ty(w: &mut MemWriter, cx: &ctxt, ft: &ty::ClosureTy) {
enc_sigil(w, ft.sigil); enc_sigil(w, ft.sigil);
enc_purity(w, ft.purity); enc_fn_style(w, ft.fn_style);
enc_onceness(w, ft.onceness); enc_onceness(w, ft.onceness);
enc_region(w, cx, ft.region); enc_region(w, cx, ft.region);
let bounds = ty::ParamBounds {builtin_bounds: ft.bounds, let bounds = ty::ParamBounds {builtin_bounds: ft.bounds,

View file

@ -29,8 +29,8 @@ enum UnsafeContext {
fn type_is_unsafe_function(ty: ty::t) -> bool { fn type_is_unsafe_function(ty: ty::t) -> bool {
match ty::get(ty).sty { match ty::get(ty).sty {
ty::ty_bare_fn(ref f) => f.purity == ast::UnsafeFn, ty::ty_bare_fn(ref f) => f.fn_style == ast::UnsafeFn,
ty::ty_closure(ref f) => f.purity == ast::UnsafeFn, ty::ty_closure(ref f) => f.fn_style == ast::UnsafeFn,
_ => false, _ => false,
} }
} }
@ -84,10 +84,10 @@ impl<'a> Visitor<()> for EffectCheckVisitor<'a> {
block: &ast::Block, span: Span, node_id: ast::NodeId, _:()) { block: &ast::Block, span: Span, node_id: ast::NodeId, _:()) {
let (is_item_fn, is_unsafe_fn) = match *fn_kind { let (is_item_fn, is_unsafe_fn) = match *fn_kind {
visit::FkItemFn(_, _, purity, _) => visit::FkItemFn(_, _, fn_style, _) =>
(true, purity == ast::UnsafeFn), (true, fn_style == ast::UnsafeFn),
visit::FkMethod(_, _, method) => visit::FkMethod(_, _, method) =>
(true, method.purity == ast::UnsafeFn), (true, method.fn_style == ast::UnsafeFn),
_ => (false, false), _ => (false, false),
}; };

View file

@ -1182,11 +1182,11 @@ impl<'a> Resolver<'a> {
(DefStatic(local_def(item.id), mutbl), sp, is_public); (DefStatic(local_def(item.id), mutbl), sp, is_public);
parent parent
} }
ItemFn(_, purity, _, _, _) => { ItemFn(_, fn_style, _, _, _) => {
let (name_bindings, new_parent) = let (name_bindings, new_parent) =
self.add_child(ident, parent, ForbidDuplicateValues, sp); self.add_child(ident, parent, ForbidDuplicateValues, sp);
let def = DefFn(local_def(item.id), purity); let def = DefFn(local_def(item.id), fn_style);
name_bindings.define_value(def, sp, is_public); name_bindings.define_value(def, sp, is_public);
new_parent new_parent
} }
@ -1313,7 +1313,7 @@ impl<'a> Resolver<'a> {
DefStaticMethod(local_def(method.id), DefStaticMethod(local_def(method.id),
FromImpl(local_def( FromImpl(local_def(
item.id)), item.id)),
method.purity) method.fn_style)
} }
_ => { _ => {
// Non-static methods become // Non-static methods become
@ -1364,7 +1364,7 @@ impl<'a> Resolver<'a> {
// Static methods become `def_static_method`s. // Static methods become `def_static_method`s.
DefStaticMethod(local_def(ty_m.id), DefStaticMethod(local_def(ty_m.id),
FromTrait(local_def(item.id)), FromTrait(local_def(item.id)),
ty_m.purity) ty_m.fn_style)
} }
_ => { _ => {
// Non-static methods become `def_method`s. // Non-static methods become `def_method`s.
@ -1869,7 +1869,7 @@ impl<'a> Resolver<'a> {
DUMMY_SP); DUMMY_SP);
let def = DefFn( let def = DefFn(
static_method_info.def_id, static_method_info.def_id,
static_method_info.purity); static_method_info.fn_style);
method_name_bindings.define_value( method_name_bindings.define_value(
def, DUMMY_SP, def, DUMMY_SP,

View file

@ -1554,8 +1554,8 @@ impl<'a> Visitor<()> for TransItemVisitor<'a> {
pub fn trans_item(ccx: &CrateContext, item: &ast::Item) { pub fn trans_item(ccx: &CrateContext, item: &ast::Item) {
let _icx = push_ctxt("trans_item"); let _icx = push_ctxt("trans_item");
match item.node { match item.node {
ast::ItemFn(decl, purity, _abi, ref generics, body) => { ast::ItemFn(decl, fn_style, _abi, ref generics, body) => {
if purity == ast::ExternFn { if fn_style == ast::ExternFn {
let llfndecl = get_item_val(ccx, item.id); let llfndecl = get_item_val(ccx, item.id);
foreign::trans_rust_fn_with_foreign_abi( foreign::trans_rust_fn_with_foreign_abi(
ccx, decl, body, item.attrs.as_slice(), llfndecl, item.id); ccx, decl, body, item.attrs.as_slice(), llfndecl, item.id);
@ -1899,8 +1899,8 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
} }
} }
ast::ItemFn(_, purity, _, _, _) => { ast::ItemFn(_, fn_style, _, _, _) => {
let llfn = if purity != ast::ExternFn { let llfn = if fn_style != ast::ExternFn {
register_fn(ccx, i.span, sym, i.id, ty) register_fn(ccx, i.span, sym, i.id, ty)
} else { } else {
foreign::register_rust_fn_with_foreign_abi(ccx, foreign::register_rust_fn_with_foreign_abi(ccx,

View file

@ -615,7 +615,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
let opt_def = cx.tcx().def_map.borrow().find_copy(&e.id); let opt_def = cx.tcx().def_map.borrow().find_copy(&e.id);
match opt_def { match opt_def {
Some(ast::DefFn(def_id, _purity)) => { Some(ast::DefFn(def_id, _fn_style)) => {
if !ast_util::is_local(def_id) { if !ast_util::is_local(def_id) {
let ty = csearch::get_type(cx.tcx(), def_id).ty; let ty = csearch::get_type(cx.tcx(), def_id).ty;
(base::trans_external_path(cx, def_id, ty), true) (base::trans_external_path(cx, def_id, ty), true)

View file

@ -211,7 +211,7 @@ impl<'a> Reflector<'a> {
// FIXME (#2594): fetch constants out of intrinsic // FIXME (#2594): fetch constants out of intrinsic
// FIXME (#4809): visitor should break out bare fns from other fns // FIXME (#4809): visitor should break out bare fns from other fns
ty::ty_closure(ref fty) => { ty::ty_closure(ref fty) => {
let pureval = ast_purity_constant(fty.purity); let pureval = ast_fn_style_constant(fty.fn_style);
let sigilval = ast_sigil_constant(fty.sigil); let sigilval = ast_sigil_constant(fty.sigil);
let retval = if ty::type_is_bot(fty.sig.output) {0u} else {1u}; let retval = if ty::type_is_bot(fty.sig.output) {0u} else {1u};
let extra = vec!(self.c_uint(pureval), let extra = vec!(self.c_uint(pureval),
@ -226,7 +226,7 @@ impl<'a> Reflector<'a> {
// FIXME (#2594): fetch constants out of intrinsic:: for the // FIXME (#2594): fetch constants out of intrinsic:: for the
// numbers. // numbers.
ty::ty_bare_fn(ref fty) => { ty::ty_bare_fn(ref fty) => {
let pureval = ast_purity_constant(fty.purity); let pureval = ast_fn_style_constant(fty.fn_style);
let sigilval = 0u; let sigilval = 0u;
let retval = if ty::type_is_bot(fty.sig.output) {0u} else {1u}; let retval = if ty::type_is_bot(fty.sig.output) {0u} else {1u};
let extra = vec!(self.c_uint(pureval), let extra = vec!(self.c_uint(pureval),
@ -399,10 +399,10 @@ pub fn ast_sigil_constant(sigil: ast::Sigil) -> uint {
} }
} }
pub fn ast_purity_constant(purity: ast::Purity) -> uint { pub fn ast_fn_style_constant(fn_style: ast::FnStyle) -> uint {
match purity { match fn_style {
ast::UnsafeFn => 1u, ast::UnsafeFn => 1u,
ast::ImpureFn => 2u, ast::NormalFn => 2u,
ast::ExternFn => 3u ast::ExternFn => 3u
} }
} }

View file

@ -415,14 +415,14 @@ pub fn type_id(t: t) -> uint { get(t).id }
#[deriving(Clone, Eq, TotalEq, Hash)] #[deriving(Clone, Eq, TotalEq, Hash)]
pub struct BareFnTy { pub struct BareFnTy {
pub purity: ast::Purity, pub fn_style: ast::FnStyle,
pub abi: abi::Abi, pub abi: abi::Abi,
pub sig: FnSig, pub sig: FnSig,
} }
#[deriving(Clone, Eq, TotalEq, Hash)] #[deriving(Clone, Eq, TotalEq, Hash)]
pub struct ClosureTy { pub struct ClosureTy {
pub purity: ast::Purity, pub fn_style: ast::FnStyle,
pub sigil: ast::Sigil, pub sigil: ast::Sigil,
pub onceness: ast::Onceness, pub onceness: ast::Onceness,
pub region: Region, pub region: Region,
@ -791,7 +791,7 @@ pub struct expected_found<T> {
#[deriving(Clone, Show)] #[deriving(Clone, Show)]
pub enum type_err { pub enum type_err {
terr_mismatch, terr_mismatch,
terr_purity_mismatch(expected_found<Purity>), terr_fn_style_mismatch(expected_found<FnStyle>),
terr_onceness_mismatch(expected_found<Onceness>), terr_onceness_mismatch(expected_found<Onceness>),
terr_abi_mismatch(expected_found<abi::Abi>), terr_abi_mismatch(expected_found<abi::Abi>),
terr_mutability, terr_mutability,
@ -1397,7 +1397,7 @@ pub fn mk_ctor_fn(cx: &ctxt,
let input_args = input_tys.iter().map(|t| *t).collect(); let input_args = input_tys.iter().map(|t| *t).collect();
mk_bare_fn(cx, mk_bare_fn(cx,
BareFnTy { BareFnTy {
purity: ast::ImpureFn, fn_style: ast::NormalFn,
abi: abi::Rust, abi: abi::Rust,
sig: FnSig { sig: FnSig {
binder_id: binder_id, binder_id: binder_id,
@ -2843,7 +2843,7 @@ pub fn adjust_ty(cx: &ctxt,
ty::ty_bare_fn(ref b) => { ty::ty_bare_fn(ref b) => {
ty::mk_closure( ty::mk_closure(
cx, cx,
ty::ClosureTy {purity: b.purity, ty::ClosureTy {fn_style: b.fn_style,
sigil: s, sigil: s,
onceness: ast::Many, onceness: ast::Many,
region: r, region: r,
@ -3340,7 +3340,7 @@ pub fn type_err_to_str(cx: &ctxt, err: &type_err) -> ~str {
match *err { match *err {
terr_mismatch => ~"types differ", terr_mismatch => ~"types differ",
terr_purity_mismatch(values) => { terr_fn_style_mismatch(values) => {
format!("expected {} fn but found {} fn", format!("expected {} fn but found {} fn",
values.expected.to_str(), values.found.to_str()) values.expected.to_str(), values.found.to_str())
} }
@ -4297,16 +4297,16 @@ pub fn eval_repeat_count<T: ExprTyProvider>(tcx: &T, count_expr: &ast::Expr) ->
} }
} }
// Determine what purity to check a nested function under // Determine what the style to check a nested function under
pub fn determine_inherited_purity(parent: (ast::Purity, ast::NodeId), pub fn determine_inherited_style(parent: (ast::FnStyle, ast::NodeId),
child: (ast::Purity, ast::NodeId), child: (ast::FnStyle, ast::NodeId),
child_sigil: ast::Sigil) child_sigil: ast::Sigil)
-> (ast::Purity, ast::NodeId) { -> (ast::FnStyle, ast::NodeId) {
// If the closure is a stack closure and hasn't had some non-standard // If the closure is a stack closure and hasn't had some non-standard
// purity inferred for it, then check it under its parent's purity. // style inferred for it, then check it under its parent's style.
// Otherwise, use its own // Otherwise, use its own
match child_sigil { match child_sigil {
ast::BorrowedSigil if child.val0() == ast::ImpureFn => parent, ast::BorrowedSigil if child.val0() == ast::NormalFn => parent,
_ => child _ => child
} }
} }
@ -4665,12 +4665,12 @@ pub fn hash_crate_independent(tcx: &ctxt, t: t, svh: &Svh) -> u64 {
} }
ty_bare_fn(ref b) => { ty_bare_fn(ref b) => {
byte!(14); byte!(14);
hash!(b.purity); hash!(b.fn_style);
hash!(b.abi); hash!(b.abi);
} }
ty_closure(ref c) => { ty_closure(ref c) => {
byte!(15); byte!(15);
hash!(c.purity); hash!(c.fn_style);
hash!(c.sigil); hash!(c.sigil);
hash!(c.onceness); hash!(c.onceness);
hash!(c.bounds); hash!(c.bounds);

View file

@ -49,7 +49,7 @@ pub trait TypeFolder {
-> ty::BareFnTy { -> ty::BareFnTy {
ty::BareFnTy { sig: self.fold_sig(&fty.sig), ty::BareFnTy { sig: self.fold_sig(&fty.sig),
abi: fty.abi, abi: fty.abi,
purity: fty.purity } fn_style: fty.fn_style }
} }
fn fold_closure_ty(&mut self, fn fold_closure_ty(&mut self,
@ -58,7 +58,7 @@ pub trait TypeFolder {
ty::ClosureTy { ty::ClosureTy {
region: self.fold_region(fty.region), region: self.fold_region(fty.region),
sig: self.fold_sig(&fty.sig), sig: self.fold_sig(&fty.sig),
purity: fty.purity, fn_style: fty.fn_style,
sigil: fty.sigil, sigil: fty.sigil,
onceness: fty.onceness, onceness: fty.onceness,
bounds: fty.bounds, bounds: fty.bounds,

View file

@ -523,7 +523,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>(
tcx.sess.span_err(ast_ty.span, tcx.sess.span_err(ast_ty.span,
"variadic function must have C calling convention"); "variadic function must have C calling convention");
} }
ty::mk_bare_fn(tcx, ty_of_bare_fn(this, ast_ty.id, bf.purity, ty::mk_bare_fn(tcx, ty_of_bare_fn(this, ast_ty.id, bf.fn_style,
bf.abi, bf.decl)) bf.abi, bf.decl))
} }
ast::TyClosure(ref f) => { ast::TyClosure(ref f) => {
@ -543,7 +543,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>(
rscope, rscope,
ast_ty.id, ast_ty.id,
f.sigil, f.sigil,
f.purity, f.fn_style,
f.onceness, f.onceness,
bounds, bounds,
&f.region, &f.region,
@ -661,24 +661,24 @@ struct SelfInfo {
pub fn ty_of_method<AC:AstConv>( pub fn ty_of_method<AC:AstConv>(
this: &AC, this: &AC,
id: ast::NodeId, id: ast::NodeId,
purity: ast::Purity, fn_style: ast::FnStyle,
untransformed_self_ty: ty::t, untransformed_self_ty: ty::t,
explicit_self: ast::ExplicitSelf, explicit_self: ast::ExplicitSelf,
decl: &ast::FnDecl) -> ty::BareFnTy { decl: &ast::FnDecl) -> ty::BareFnTy {
ty_of_method_or_bare_fn(this, id, purity, abi::Rust, Some(SelfInfo { ty_of_method_or_bare_fn(this, id, fn_style, abi::Rust, Some(SelfInfo {
untransformed_self_ty: untransformed_self_ty, untransformed_self_ty: untransformed_self_ty,
explicit_self: explicit_self explicit_self: explicit_self
}), decl) }), decl)
} }
pub fn ty_of_bare_fn<AC:AstConv>(this: &AC, id: ast::NodeId, pub fn ty_of_bare_fn<AC:AstConv>(this: &AC, id: ast::NodeId,
purity: ast::Purity, abi: abi::Abi, fn_style: ast::FnStyle, abi: abi::Abi,
decl: &ast::FnDecl) -> ty::BareFnTy { decl: &ast::FnDecl) -> ty::BareFnTy {
ty_of_method_or_bare_fn(this, id, purity, abi, None, decl) ty_of_method_or_bare_fn(this, id, fn_style, abi, None, decl)
} }
fn ty_of_method_or_bare_fn<AC:AstConv>(this: &AC, id: ast::NodeId, fn ty_of_method_or_bare_fn<AC:AstConv>(this: &AC, id: ast::NodeId,
purity: ast::Purity, abi: abi::Abi, fn_style: ast::FnStyle, abi: abi::Abi,
opt_self_info: Option<SelfInfo>, opt_self_info: Option<SelfInfo>,
decl: &ast::FnDecl) -> ty::BareFnTy { decl: &ast::FnDecl) -> ty::BareFnTy {
debug!("ty_of_method_or_bare_fn"); debug!("ty_of_method_or_bare_fn");
@ -724,7 +724,7 @@ fn ty_of_method_or_bare_fn<AC:AstConv>(this: &AC, id: ast::NodeId,
}; };
return ty::BareFnTy { return ty::BareFnTy {
purity: purity, fn_style: fn_style,
abi: abi, abi: abi,
sig: ty::FnSig { sig: ty::FnSig {
binder_id: id, binder_id: id,
@ -740,7 +740,7 @@ pub fn ty_of_closure<AC:AstConv,RS:RegionScope>(
rscope: &RS, rscope: &RS,
id: ast::NodeId, id: ast::NodeId,
sigil: ast::Sigil, sigil: ast::Sigil,
purity: ast::Purity, fn_style: ast::FnStyle,
onceness: ast::Onceness, onceness: ast::Onceness,
bounds: ty::BuiltinBounds, bounds: ty::BuiltinBounds,
opt_lifetime: &Option<ast::Lifetime>, opt_lifetime: &Option<ast::Lifetime>,
@ -797,7 +797,7 @@ pub fn ty_of_closure<AC:AstConv,RS:RegionScope>(
}; };
ty::ClosureTy { ty::ClosureTy {
purity: purity, fn_style: fn_style,
sigil: sigil, sigil: sigil,
onceness: onceness, onceness: onceness,
region: bound_region, region: bound_region,

View file

@ -1163,7 +1163,7 @@ impl<'a> LookupContext<'a> {
let transformed_self_ty = *fn_sig.inputs.get(0); let transformed_self_ty = *fn_sig.inputs.get(0);
let fty = ty::mk_bare_fn(tcx, ty::BareFnTy { let fty = ty::mk_bare_fn(tcx, ty::BareFnTy {
sig: fn_sig, sig: fn_sig,
purity: bare_fn_ty.purity, fn_style: bare_fn_ty.fn_style,
abi: bare_fn_ty.abi.clone(), abi: bare_fn_ty.abi.clone(),
}); });
debug!("after replacing bound regions, fty={}", self.ty_to_str(fty)); debug!("after replacing bound regions, fty={}", self.ty_to_str(fty));

View file

@ -177,32 +177,32 @@ pub enum FnKind {
} }
#[deriving(Clone)] #[deriving(Clone)]
pub struct PurityState { pub struct FnStyleState {
pub def: ast::NodeId, pub def: ast::NodeId,
pub purity: ast::Purity, pub fn_style: ast::FnStyle,
from_fn: bool from_fn: bool
} }
impl PurityState { impl FnStyleState {
pub fn function(purity: ast::Purity, def: ast::NodeId) -> PurityState { pub fn function(fn_style: ast::FnStyle, def: ast::NodeId) -> FnStyleState {
PurityState { def: def, purity: purity, from_fn: true } FnStyleState { def: def, fn_style: fn_style, from_fn: true }
} }
pub fn recurse(&mut self, blk: &ast::Block) -> PurityState { pub fn recurse(&mut self, blk: &ast::Block) -> FnStyleState {
match self.purity { match self.fn_style {
// If this unsafe, then if the outer function was already marked as // If this unsafe, then if the outer function was already marked as
// unsafe we shouldn't attribute the unsafe'ness to the block. This // unsafe we shouldn't attribute the unsafe'ness to the block. This
// way the block can be warned about instead of ignoring this // way the block can be warned about instead of ignoring this
// extraneous block (functions are never warned about). // extraneous block (functions are never warned about).
ast::UnsafeFn if self.from_fn => *self, ast::UnsafeFn if self.from_fn => *self,
purity => { fn_style => {
let (purity, def) = match blk.rules { let (fn_style, def) = match blk.rules {
ast::UnsafeBlock(..) => (ast::UnsafeFn, blk.id), ast::UnsafeBlock(..) => (ast::UnsafeFn, blk.id),
ast::DefaultBlock => (purity, self.def), ast::DefaultBlock => (fn_style, self.def),
}; };
PurityState{ def: def, FnStyleState{ def: def,
purity: purity, fn_style: fn_style,
from_fn: false } from_fn: false }
} }
} }
@ -227,7 +227,7 @@ pub struct FnCtxt<'a> {
err_count_on_creation: uint, err_count_on_creation: uint,
ret_ty: ty::t, ret_ty: ty::t,
ps: RefCell<PurityState>, ps: RefCell<FnStyleState>,
// Sometimes we generate region pointers where the precise region // Sometimes we generate region pointers where the precise region
// to use is not known. For example, an expression like `&x.f` // to use is not known. For example, an expression like `&x.f`
@ -281,7 +281,7 @@ fn blank_fn_ctxt<'a>(ccx: &'a CrateCtxt<'a>,
FnCtxt { FnCtxt {
err_count_on_creation: ccx.tcx.sess.err_count(), err_count_on_creation: ccx.tcx.sess.err_count(),
ret_ty: rty, ret_ty: rty,
ps: RefCell::new(PurityState::function(ast::ImpureFn, 0)), ps: RefCell::new(FnStyleState::function(ast::NormalFn, 0)),
region_lb: Cell::new(region_bnd), region_lb: Cell::new(region_bnd),
fn_kind: Vanilla, fn_kind: Vanilla,
inh: inh, inh: inh,
@ -335,7 +335,7 @@ fn check_bare_fn(ccx: &CrateCtxt,
match ty::get(fty).sty { match ty::get(fty).sty {
ty::ty_bare_fn(ref fn_ty) => { ty::ty_bare_fn(ref fn_ty) => {
let inh = Inherited::new(ccx.tcx, param_env); let inh = Inherited::new(ccx.tcx, param_env);
let fcx = check_fn(ccx, fn_ty.purity, &fn_ty.sig, let fcx = check_fn(ccx, fn_ty.fn_style, &fn_ty.sig,
decl, id, body, Vanilla, &inh); decl, id, body, Vanilla, &inh);
vtable::resolve_in_block(&fcx, body); vtable::resolve_in_block(&fcx, body);
@ -415,7 +415,7 @@ impl<'a> Visitor<()> for GatherLocalsVisitor<'a> {
} }
fn check_fn<'a>(ccx: &'a CrateCtxt<'a>, fn check_fn<'a>(ccx: &'a CrateCtxt<'a>,
purity: ast::Purity, fn_style: ast::FnStyle,
fn_sig: &ty::FnSig, fn_sig: &ty::FnSig,
decl: &ast::FnDecl, decl: &ast::FnDecl,
id: ast::NodeId, id: ast::NodeId,
@ -456,7 +456,7 @@ fn check_fn<'a>(ccx: &'a CrateCtxt<'a>,
let fcx = FnCtxt { let fcx = FnCtxt {
err_count_on_creation: err_count_on_creation, err_count_on_creation: err_count_on_creation,
ret_ty: ret_ty, ret_ty: ret_ty,
ps: RefCell::new(PurityState::function(purity, id)), ps: RefCell::new(FnStyleState::function(fn_style, id)),
region_lb: Cell::new(body.id), region_lb: Cell::new(body.id),
fn_kind: fn_kind, fn_kind: fn_kind,
inh: inherited, inh: inherited,
@ -2127,7 +2127,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
// fresh bound regions for any bound regions we find in the // fresh bound regions for any bound regions we find in the
// expected types so as to avoid capture. // expected types so as to avoid capture.
// //
// Also try to pick up inferred purity and sigil, defaulting // Also try to pick up inferred style and sigil, defaulting
// to impure and block. Note that we only will use those for // to impure and block. Note that we only will use those for
// block syntax lambdas; that is, lambdas without explicit // block syntax lambdas; that is, lambdas without explicit
// sigils. // sigils.
@ -2136,7 +2136,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
|x| Some((*x).clone())); |x| Some((*x).clone()));
let error_happened = false; let error_happened = false;
let (expected_sig, let (expected_sig,
expected_purity, expected_style,
expected_sigil, expected_sigil,
expected_onceness, expected_onceness,
expected_bounds) = { expected_bounds) = {
@ -2146,7 +2146,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
replace_late_bound_regions_in_fn_sig( replace_late_bound_regions_in_fn_sig(
tcx, &cenv.sig, tcx, &cenv.sig,
|_| fcx.inh.infcx.fresh_bound_region(expr.id)); |_| fcx.inh.infcx.fresh_bound_region(expr.id));
(Some(sig), cenv.purity, cenv.sigil, (Some(sig), cenv.fn_style, cenv.sigil,
cenv.onceness, cenv.bounds) cenv.onceness, cenv.bounds)
} }
_ => { _ => {
@ -2162,7 +2162,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
} }
_ => () _ => ()
} }
(None, ast::ImpureFn, sigil, (None, ast::NormalFn, sigil,
onceness, bounds) onceness, bounds)
} }
} }
@ -2170,9 +2170,9 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
// If the proto is specified, use that, otherwise select a // If the proto is specified, use that, otherwise select a
// proto based on inference. // proto based on inference.
let (sigil, purity) = match ast_sigil_opt { let (sigil, fn_style) = match ast_sigil_opt {
Some(p) => (p, ast::ImpureFn), Some(p) => (p, ast::NormalFn),
None => (expected_sigil, expected_purity) None => (expected_sigil, expected_style)
}; };
// construct the function type // construct the function type
@ -2180,7 +2180,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
fcx.infcx(), fcx.infcx(),
expr.id, expr.id,
sigil, sigil,
purity, fn_style,
expected_onceness, expected_onceness,
expected_bounds, expected_bounds,
&None, &None,
@ -2208,13 +2208,13 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
fcx.write_ty(expr.id, fty); fcx.write_ty(expr.id, fty);
let (inherited_purity, id) = let (inherited_style, id) =
ty::determine_inherited_purity((fcx.ps.borrow().purity, ty::determine_inherited_style((fcx.ps.borrow().fn_style,
fcx.ps.borrow().def), fcx.ps.borrow().def),
(purity, expr.id), (fn_style, expr.id),
sigil); sigil);
check_fn(fcx.ccx, inherited_purity, &fty_sig, check_fn(fcx.ccx, inherited_style, &fty_sig,
decl, id, body, fn_kind, fcx.inh); decl, id, body, fn_kind, fcx.inh);
} }
@ -3272,8 +3272,8 @@ pub fn check_block_with_expected(fcx: &FnCtxt,
expected: Option<ty::t>) { expected: Option<ty::t>) {
let prev = { let prev = {
let mut fcx_ps = fcx.ps.borrow_mut(); let mut fcx_ps = fcx.ps.borrow_mut();
let purity_state = fcx_ps.recurse(blk); let fn_style_state = fcx_ps.recurse(blk);
replace(&mut *fcx_ps, purity_state) replace(&mut *fcx_ps, fn_style_state)
}; };
fcx.with_region_lb(blk.id, || { fcx.with_region_lb(blk.id, || {
@ -4223,7 +4223,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
} }
}; };
let fty = ty::mk_bare_fn(tcx, ty::BareFnTy { let fty = ty::mk_bare_fn(tcx, ty::BareFnTy {
purity: ast::UnsafeFn, fn_style: ast::UnsafeFn,
abi: abi::RustIntrinsic, abi: abi::RustIntrinsic,
sig: FnSig {binder_id: it.id, sig: FnSig {binder_id: it.id,
inputs: inputs, inputs: inputs,

View file

@ -200,14 +200,14 @@ pub fn ensure_trait_methods(ccx: &CrateCtxt, trait_id: ast::NodeId) {
ty_method_of_trait_method( ty_method_of_trait_method(
ccx, trait_id, &trait_ty_generics, ccx, trait_id, &trait_ty_generics,
&m.id, &m.ident, &m.explicit_self, &m.id, &m.ident, &m.explicit_self,
&m.generics, &m.purity, m.decl) &m.generics, &m.fn_style, m.decl)
} }
&ast::Provided(ref m) => { &ast::Provided(ref m) => {
ty_method_of_trait_method( ty_method_of_trait_method(
ccx, trait_id, &trait_ty_generics, ccx, trait_id, &trait_ty_generics,
&m.id, &m.ident, &m.explicit_self, &m.id, &m.ident, &m.explicit_self,
&m.generics, &m.purity, m.decl) &m.generics, &m.fn_style, m.decl)
} }
}; };
@ -376,11 +376,11 @@ pub fn ensure_trait_methods(ccx: &CrateCtxt, trait_id: ast::NodeId) {
m_ident: &ast::Ident, m_ident: &ast::Ident,
m_explicit_self: &ast::ExplicitSelf, m_explicit_self: &ast::ExplicitSelf,
m_generics: &ast::Generics, m_generics: &ast::Generics,
m_purity: &ast::Purity, m_fn_style: &ast::FnStyle,
m_decl: &ast::FnDecl) -> ty::Method m_decl: &ast::FnDecl) -> ty::Method
{ {
let trait_self_ty = ty::mk_self(this.tcx, local_def(trait_id)); let trait_self_ty = ty::mk_self(this.tcx, local_def(trait_id));
let fty = astconv::ty_of_method(this, *m_id, *m_purity, trait_self_ty, let fty = astconv::ty_of_method(this, *m_id, *m_fn_style, trait_self_ty,
*m_explicit_self, m_decl); *m_explicit_self, m_decl);
let num_trait_type_params = trait_generics.type_param_defs().len(); let num_trait_type_params = trait_generics.type_param_defs().len();
let ty_generics = ty_generics_for_fn_or_method(this, m_generics, let ty_generics = ty_generics_for_fn_or_method(this, m_generics,
@ -508,7 +508,7 @@ fn convert_methods(ccx: &CrateCtxt,
rcvr_generics: &ast::Generics, rcvr_generics: &ast::Generics,
rcvr_visibility: ast::Visibility) -> ty::Method rcvr_visibility: ast::Visibility) -> ty::Method
{ {
let fty = astconv::ty_of_method(ccx, m.id, m.purity, let fty = astconv::ty_of_method(ccx, m.id, m.fn_style,
untransformed_rcvr_ty, untransformed_rcvr_ty,
m.explicit_self, m.decl); m.explicit_self, m.decl);
@ -818,11 +818,11 @@ pub fn ty_of_item(ccx: &CrateCtxt, it: &ast::Item)
tcx.tcache.borrow_mut().insert(local_def(it.id), tpt.clone()); tcx.tcache.borrow_mut().insert(local_def(it.id), tpt.clone());
return tpt; return tpt;
} }
ast::ItemFn(decl, purity, abi, ref generics, _) => { ast::ItemFn(decl, fn_style, abi, ref generics, _) => {
let ty_generics = ty_generics_for_fn_or_method(ccx, generics, 0); let ty_generics = ty_generics_for_fn_or_method(ccx, generics, 0);
let tofd = astconv::ty_of_bare_fn(ccx, let tofd = astconv::ty_of_bare_fn(ccx,
it.id, it.id,
purity, fn_style,
abi, abi,
decl); decl);
let tpt = ty_param_bounds_and_ty { let tpt = ty_param_bounds_and_ty {
@ -1029,7 +1029,7 @@ pub fn ty_of_foreign_fn_decl(ccx: &CrateCtxt,
ccx.tcx, ccx.tcx,
ty::BareFnTy { ty::BareFnTy {
abi: abi, abi: abi,
purity: ast::UnsafeFn, fn_style: ast::UnsafeFn,
sig: ty::FnSig {binder_id: def_id.node, sig: ty::FnSig {binder_id: def_id.node,
inputs: input_tys, inputs: input_tys,
output: output_ty, output: output_ty,

View file

@ -385,7 +385,7 @@ impl<'f> Coerce<'f> {
debug!("coerce_from_bare_fn(a={}, b={})", debug!("coerce_from_bare_fn(a={}, b={})",
a.inf_str(self.get_ref().infcx), b.inf_str(self.get_ref().infcx)); a.inf_str(self.get_ref().infcx), b.inf_str(self.get_ref().infcx));
if fn_ty_a.abi != abi::Rust || fn_ty_a.purity != ast::ImpureFn { if fn_ty_a.abi != abi::Rust || fn_ty_a.fn_style != ast::NormalFn {
return self.subtype(a, b); return self.subtype(a, b);
} }

View file

@ -64,7 +64,7 @@ use util::ppaux::Repr;
use std::result; use std::result;
use syntax::ast::{Onceness, Purity}; use syntax::ast::{Onceness, FnStyle};
use syntax::ast; use syntax::ast;
use syntax::owned_slice::OwnedSlice; use syntax::owned_slice::OwnedSlice;
use syntax::abi; use syntax::abi;
@ -194,10 +194,10 @@ pub trait Combine {
fn bare_fn_tys(&self, a: &ty::BareFnTy, fn bare_fn_tys(&self, a: &ty::BareFnTy,
b: &ty::BareFnTy) -> cres<ty::BareFnTy> { b: &ty::BareFnTy) -> cres<ty::BareFnTy> {
let purity = if_ok!(self.purities(a.purity, b.purity)); let fn_style = if_ok!(self.fn_styles(a.fn_style, b.fn_style));
let abi = if_ok!(self.abi(a.abi, b.abi)); let abi = if_ok!(self.abi(a.abi, b.abi));
let sig = if_ok!(self.fn_sigs(&a.sig, &b.sig)); let sig = if_ok!(self.fn_sigs(&a.sig, &b.sig));
Ok(ty::BareFnTy {purity: purity, Ok(ty::BareFnTy {fn_style: fn_style,
abi: abi, abi: abi,
sig: sig}) sig: sig})
} }
@ -207,11 +207,11 @@ pub trait Combine {
let p = if_ok!(self.sigils(a.sigil, b.sigil)); let p = if_ok!(self.sigils(a.sigil, b.sigil));
let r = if_ok!(self.contraregions(a.region, b.region)); let r = if_ok!(self.contraregions(a.region, b.region));
let purity = if_ok!(self.purities(a.purity, b.purity)); let fn_style = if_ok!(self.fn_styles(a.fn_style, b.fn_style));
let onceness = if_ok!(self.oncenesses(a.onceness, b.onceness)); let onceness = if_ok!(self.oncenesses(a.onceness, b.onceness));
let bounds = if_ok!(self.bounds(a.bounds, b.bounds)); let bounds = if_ok!(self.bounds(a.bounds, b.bounds));
let sig = if_ok!(self.fn_sigs(&a.sig, &b.sig)); let sig = if_ok!(self.fn_sigs(&a.sig, &b.sig));
Ok(ty::ClosureTy {purity: purity, Ok(ty::ClosureTy {fn_style: fn_style,
sigil: p, sigil: p,
onceness: onceness, onceness: onceness,
region: r, region: r,
@ -246,7 +246,7 @@ pub trait Combine {
} }
} }
fn purities(&self, a: Purity, b: Purity) -> cres<Purity>; fn fn_styles(&self, a: FnStyle, b: FnStyle) -> cres<FnStyle>;
fn abi(&self, a: abi::Abi, b: abi::Abi) -> cres<abi::Abi> { fn abi(&self, a: abi::Abi, b: abi::Abi) -> cres<abi::Abi> {
if a == b { if a == b {

View file

@ -1102,10 +1102,10 @@ impl<'a> ErrorReportingHelpers for InferCtxt<'a> {
output: ast::P<ast::Ty>, output: ast::P<ast::Ty>,
item: ast::P<ast::Item>, item: ast::P<ast::Item>,
generics: ast::Generics) { generics: ast::Generics) {
let (fn_decl, purity, ident) = match item.node { let (fn_decl, fn_style, ident) = match item.node {
// FIXME: handling method // FIXME: handling method
ast::ItemFn(ref fn_decl, ref purity, _, _, _) => { ast::ItemFn(ref fn_decl, ref fn_style, _, _, _) => {
(fn_decl, purity, item.ident) (fn_decl, fn_style, item.ident)
}, },
_ => fail!("Expect function or method") _ => fail!("Expect function or method")
@ -1117,7 +1117,7 @@ impl<'a> ErrorReportingHelpers for InferCtxt<'a> {
variadic: fn_decl.variadic variadic: fn_decl.variadic
}; };
let suggested_fn = let suggested_fn =
pprust::fun_to_str(&fd, *purity, ident, None, &generics); pprust::fun_to_str(&fd, *fn_style, ident, None, &generics);
let msg = format!("consider using an explicit lifetime \ let msg = format!("consider using an explicit lifetime \
parameter as shown: {}", suggested_fn); parameter as shown: {}", suggested_fn);
self.tcx.sess.span_note(item.span, msg); self.tcx.sess.span_note(item.span, msg);

View file

@ -22,8 +22,8 @@ use middle::typeck::infer::{cres, InferCtxt};
use middle::typeck::infer::{TypeTrace, Subtype}; use middle::typeck::infer::{TypeTrace, Subtype};
use middle::typeck::infer::fold_regions_in_sig; use middle::typeck::infer::fold_regions_in_sig;
use syntax::ast::{Many, Once, MutImmutable, MutMutable}; use syntax::ast::{Many, Once, MutImmutable, MutMutable};
use syntax::ast::{ExternFn, ImpureFn, UnsafeFn, NodeId}; use syntax::ast::{ExternFn, NormalFn, UnsafeFn, NodeId};
use syntax::ast::{Onceness, Purity}; use syntax::ast::{Onceness, FnStyle};
use collections::HashMap; use collections::HashMap;
use util::common::{indenter}; use util::common::{indenter};
use util::ppaux::mt_to_str; use util::ppaux::mt_to_str;
@ -81,10 +81,10 @@ impl<'f> Combine for Glb<'f> {
Lub(*self.get_ref()).tys(a, b) Lub(*self.get_ref()).tys(a, b)
} }
fn purities(&self, a: Purity, b: Purity) -> cres<Purity> { fn fn_styles(&self, a: FnStyle, b: FnStyle) -> cres<FnStyle> {
match (a, b) { match (a, b) {
(ExternFn, _) | (_, ExternFn) => Ok(ExternFn), (ExternFn, _) | (_, ExternFn) => Ok(ExternFn),
(ImpureFn, _) | (_, ImpureFn) => Ok(ImpureFn), (NormalFn, _) | (_, NormalFn) => Ok(NormalFn),
(UnsafeFn, UnsafeFn) => Ok(UnsafeFn) (UnsafeFn, UnsafeFn) => Ok(UnsafeFn)
} }
} }

View file

@ -23,8 +23,8 @@ use middle::typeck::infer::fold_regions_in_sig;
use middle::typeck::infer::{TypeTrace, Subtype}; use middle::typeck::infer::{TypeTrace, Subtype};
use collections::HashMap; use collections::HashMap;
use syntax::ast::{Many, Once, NodeId}; use syntax::ast::{Many, Once, NodeId};
use syntax::ast::{ExternFn, ImpureFn, UnsafeFn}; use syntax::ast::{ExternFn, NormalFn, UnsafeFn};
use syntax::ast::{Onceness, Purity}; use syntax::ast::{Onceness, FnStyle};
use util::ppaux::mt_to_str; use util::ppaux::mt_to_str;
pub struct Lub<'f>(pub CombineFields<'f>); // least-upper-bound: common supertype pub struct Lub<'f>(pub CombineFields<'f>); // least-upper-bound: common supertype
@ -75,10 +75,10 @@ impl<'f> Combine for Lub<'f> {
Glb(*self.get_ref()).tys(a, b) Glb(*self.get_ref()).tys(a, b)
} }
fn purities(&self, a: Purity, b: Purity) -> cres<Purity> { fn fn_styles(&self, a: FnStyle, b: FnStyle) -> cres<FnStyle> {
match (a, b) { match (a, b) {
(UnsafeFn, _) | (_, UnsafeFn) => Ok(UnsafeFn), (UnsafeFn, _) | (_, UnsafeFn) => Ok(UnsafeFn),
(ImpureFn, _) | (_, ImpureFn) => Ok(ImpureFn), (NormalFn, _) | (_, NormalFn) => Ok(NormalFn),
(ExternFn, ExternFn) => Ok(ExternFn), (ExternFn, ExternFn) => Ok(ExternFn),
} }
} }

View file

@ -25,7 +25,7 @@ use middle::typeck::infer::{TypeTrace, Subtype};
use util::common::{indenter}; use util::common::{indenter};
use util::ppaux::bound_region_to_str; use util::ppaux::bound_region_to_str;
use syntax::ast::{Onceness, Purity}; use syntax::ast::{Onceness, FnStyle};
pub struct Sub<'f>(pub CombineFields<'f>); // "subtype", "subregion" etc pub struct Sub<'f>(pub CombineFields<'f>); // "subtype", "subregion" etc
@ -87,9 +87,9 @@ impl<'f> Combine for Sub<'f> {
} }
} }
fn purities(&self, a: Purity, b: Purity) -> cres<Purity> { fn fn_styles(&self, a: FnStyle, b: FnStyle) -> cres<FnStyle> {
self.lub().purities(a, b).compare(b, || { self.lub().fn_styles(a, b).compare(b, || {
ty::terr_purity_mismatch(expected_found(self, a, b)) ty::terr_fn_style_mismatch(expected_found(self, a, b))
}) })
} }

View file

@ -182,7 +182,7 @@ impl Env {
let inputs = input_tys.map(|t| {mode: ast::expl(ast::by_copy), let inputs = input_tys.map(|t| {mode: ast::expl(ast::by_copy),
ty: *t}); ty: *t});
ty::mk_fn(self.tcx, FnTyBase { ty::mk_fn(self.tcx, FnTyBase {
meta: FnMeta {purity: ast::ImpureFn, meta: FnMeta {fn_style: ast::NormalFn,
proto: ast::ProtoBare, proto: ast::ProtoBare,
onceness: ast::Many, onceness: ast::Many,
region: ty::ReStatic, region: ty::ReStatic,

View file

@ -357,7 +357,7 @@ fn check_main_fn_ty(ccx: &CrateCtxt,
_ => () _ => ()
} }
let se_ty = ty::mk_bare_fn(tcx, ty::BareFnTy { let se_ty = ty::mk_bare_fn(tcx, ty::BareFnTy {
purity: ast::ImpureFn, fn_style: ast::NormalFn,
abi: abi::Rust, abi: abi::Rust,
sig: ty::FnSig { sig: ty::FnSig {
binder_id: main_id, binder_id: main_id,
@ -403,7 +403,7 @@ fn check_start_fn_ty(ccx: &CrateCtxt,
} }
let se_ty = ty::mk_bare_fn(tcx, ty::BareFnTy { let se_ty = ty::mk_bare_fn(tcx, ty::BareFnTy {
purity: ast::ImpureFn, fn_style: ast::NormalFn,
abi: abi::Rust, abi: abi::Rust,
sig: ty::FnSig { sig: ty::FnSig {
binder_id: start_id, binder_id: start_id,

View file

@ -252,7 +252,7 @@ pub fn ty_to_str(cx: &ctxt, typ: t) -> ~str {
ty_to_str(cx, input) ty_to_str(cx, input)
} }
fn bare_fn_to_str(cx: &ctxt, fn bare_fn_to_str(cx: &ctxt,
purity: ast::Purity, fn_style: ast::FnStyle,
abi: abi::Abi, abi: abi::Abi,
ident: Option<ast::Ident>, ident: Option<ast::Ident>,
sig: &ty::FnSig) sig: &ty::FnSig)
@ -263,10 +263,10 @@ pub fn ty_to_str(cx: &ctxt, typ: t) -> ~str {
format!("extern {} ", abi.to_str()) format!("extern {} ", abi.to_str())
}; };
match purity { match fn_style {
ast::ImpureFn => {} ast::NormalFn => {}
_ => { _ => {
s.push_str(purity.to_str()); s.push_str(fn_style.to_str());
s.push_char(' '); s.push_char(' ');
} }
}; };
@ -305,10 +305,10 @@ pub fn ty_to_str(cx: &ctxt, typ: t) -> ~str {
} }
} }
match cty.purity { match cty.fn_style {
ast::ImpureFn => {} ast::NormalFn => {}
_ => { _ => {
s.push_str(cty.purity.to_str()); s.push_str(cty.fn_style.to_str());
s.push_char(' '); s.push_char(' ');
} }
}; };
@ -405,7 +405,7 @@ pub fn ty_to_str(cx: &ctxt, typ: t) -> ~str {
closure_to_str(cx, *f) closure_to_str(cx, *f)
} }
ty_bare_fn(ref f) => { ty_bare_fn(ref f) => {
bare_fn_to_str(cx, f.purity, f.abi, None, &f.sig) bare_fn_to_str(cx, f.fn_style, f.abi, None, &f.sig)
} }
ty_infer(infer_ty) => infer_ty.to_str(), ty_infer(infer_ty) => infer_ty.to_str(),
ty_err => ~"[type error]", ty_err => ~"[type error]",
@ -812,8 +812,8 @@ impl Repr for ast::Visibility {
impl Repr for ty::BareFnTy { impl Repr for ty::BareFnTy {
fn repr(&self, tcx: &ctxt) -> ~str { fn repr(&self, tcx: &ctxt) -> ~str {
format!("BareFnTy \\{purity: {:?}, abi: {}, sig: {}\\}", format!("BareFnTy \\{fn_style: {:?}, abi: {}, sig: {}\\}",
self.purity, self.fn_style,
self.abi.to_str(), self.abi.to_str(),
self.sig.repr(tcx)) self.sig.repr(tcx))
} }

View file

@ -356,7 +356,7 @@ impl Clean<Generics> for ast::Generics {
pub struct Method { pub struct Method {
pub generics: Generics, pub generics: Generics,
pub self_: SelfTy, pub self_: SelfTy,
pub purity: ast::Purity, pub fn_style: ast::FnStyle,
pub decl: FnDecl, pub decl: FnDecl,
} }
@ -383,7 +383,7 @@ impl Clean<Item> for ast::Method {
inner: MethodItem(Method { inner: MethodItem(Method {
generics: self.generics.clean(), generics: self.generics.clean(),
self_: self.explicit_self.clean(), self_: self.explicit_self.clean(),
purity: self.purity.clone(), fn_style: self.fn_style.clone(),
decl: decl, decl: decl,
}), }),
} }
@ -392,7 +392,7 @@ impl Clean<Item> for ast::Method {
#[deriving(Clone, Encodable, Decodable)] #[deriving(Clone, Encodable, Decodable)]
pub struct TyMethod { pub struct TyMethod {
pub purity: ast::Purity, pub fn_style: ast::FnStyle,
pub decl: FnDecl, pub decl: FnDecl,
pub generics: Generics, pub generics: Generics,
pub self_: SelfTy, pub self_: SelfTy,
@ -419,7 +419,7 @@ impl Clean<Item> for ast::TypeMethod {
id: self.id, id: self.id,
visibility: None, visibility: None,
inner: TyMethodItem(TyMethod { inner: TyMethodItem(TyMethod {
purity: self.purity.clone(), fn_style: self.fn_style.clone(),
decl: decl, decl: decl,
self_: self.explicit_self.clean(), self_: self.explicit_self.clean(),
generics: self.generics.clean(), generics: self.generics.clean(),
@ -451,7 +451,7 @@ impl Clean<SelfTy> for ast::ExplicitSelf {
pub struct Function { pub struct Function {
pub decl: FnDecl, pub decl: FnDecl,
pub generics: Generics, pub generics: Generics,
pub purity: ast::Purity, pub fn_style: ast::FnStyle,
} }
impl Clean<Item> for doctree::Function { impl Clean<Item> for doctree::Function {
@ -465,7 +465,7 @@ impl Clean<Item> for doctree::Function {
inner: FunctionItem(Function { inner: FunctionItem(Function {
decl: self.decl.clean(), decl: self.decl.clean(),
generics: self.generics.clean(), generics: self.generics.clean(),
purity: self.purity, fn_style: self.fn_style,
}), }),
} }
} }
@ -478,7 +478,7 @@ pub struct ClosureDecl {
pub lifetimes: Vec<Lifetime>, pub lifetimes: Vec<Lifetime>,
pub decl: FnDecl, pub decl: FnDecl,
pub onceness: ast::Onceness, pub onceness: ast::Onceness,
pub purity: ast::Purity, pub fn_style: ast::FnStyle,
pub bounds: Vec<TyParamBound>, pub bounds: Vec<TyParamBound>,
} }
@ -490,7 +490,7 @@ impl Clean<ClosureDecl> for ast::ClosureTy {
lifetimes: self.lifetimes.clean().move_iter().collect(), lifetimes: self.lifetimes.clean().move_iter().collect(),
decl: self.decl.clean(), decl: self.decl.clean(),
onceness: self.onceness, onceness: self.onceness,
purity: self.purity, fn_style: self.fn_style,
bounds: match self.bounds { bounds: match self.bounds {
Some(ref x) => x.clean().move_iter().collect(), Some(ref x) => x.clean().move_iter().collect(),
None => Vec::new() None => Vec::new()
@ -960,7 +960,7 @@ impl Clean<Item> for doctree::Typedef {
#[deriving(Clone, Encodable, Decodable)] #[deriving(Clone, Encodable, Decodable)]
pub struct BareFunctionDecl { pub struct BareFunctionDecl {
pub purity: ast::Purity, pub fn_style: ast::FnStyle,
pub generics: Generics, pub generics: Generics,
pub decl: FnDecl, pub decl: FnDecl,
pub abi: ~str, pub abi: ~str,
@ -969,7 +969,7 @@ pub struct BareFunctionDecl {
impl Clean<BareFunctionDecl> for ast::BareFnTy { impl Clean<BareFunctionDecl> for ast::BareFnTy {
fn clean(&self) -> BareFunctionDecl { fn clean(&self) -> BareFunctionDecl {
BareFunctionDecl { BareFunctionDecl {
purity: self.purity, fn_style: self.fn_style,
generics: Generics { generics: Generics {
lifetimes: self.lifetimes.clean().move_iter().collect(), lifetimes: self.lifetimes.clean().move_iter().collect(),
type_params: Vec::new(), type_params: Vec::new(),
@ -1164,7 +1164,7 @@ impl Clean<Item> for ast::ForeignItem {
ForeignFunctionItem(Function { ForeignFunctionItem(Function {
decl: decl.clean(), decl: decl.clean(),
generics: generics.clean(), generics: generics.clean(),
purity: ast::ExternFn, fn_style: ast::ExternFn,
}) })
} }
ast::ForeignItemStatic(ref ty, mutbl) => { ast::ForeignItemStatic(ref ty, mutbl) => {

View file

@ -113,7 +113,7 @@ pub struct Function {
pub id: NodeId, pub id: NodeId,
pub name: Ident, pub name: Ident,
pub vis: ast::Visibility, pub vis: ast::Visibility,
pub purity: ast::Purity, pub fn_style: ast::FnStyle,
pub where: Span, pub where: Span,
pub generics: ast::Generics, pub generics: ast::Generics,
} }

View file

@ -29,9 +29,9 @@ use html::render::{cache_key, current_location_key};
/// Helper to render an optional visibility with a space after it (if the /// Helper to render an optional visibility with a space after it (if the
/// visibility is preset) /// visibility is preset)
pub struct VisSpace(pub Option<ast::Visibility>); pub struct VisSpace(pub Option<ast::Visibility>);
/// Similarly to VisSpace, this structure is used to render a purity with a /// Similarly to VisSpace, this structure is used to render a function style with a
/// space after it. /// space after it.
pub struct PuritySpace(pub ast::Purity); pub struct FnStyleSpace(pub ast::FnStyle);
/// Wrapper struct for properly emitting a method declaration. /// Wrapper struct for properly emitting a method declaration.
pub struct Method<'a>(pub &'a clean::SelfTy, pub &'a clean::FnDecl); pub struct Method<'a>(pub &'a clean::SelfTy, pub &'a clean::FnDecl);
@ -41,9 +41,9 @@ impl VisSpace {
} }
} }
impl PuritySpace { impl FnStyleSpace {
pub fn get(&self) -> ast::Purity { pub fn get(&self) -> ast::FnStyle {
let PuritySpace(v) = *self; v let FnStyleSpace(v) = *self; v
} }
} }
@ -343,7 +343,7 @@ impl fmt::Show for clean::Type {
}; };
write!(f.buf, "{}{}{arrow, select, yes{ -&gt; {ret}} other{}}", write!(f.buf, "{}{}{arrow, select, yes{ -&gt; {ret}} other{}}",
PuritySpace(decl.purity), FnStyleSpace(decl.fn_style),
match decl.sigil { match decl.sigil {
ast::OwnedSigil => format!("proc({})", decl.decl.inputs), ast::OwnedSigil => format!("proc({})", decl.decl.inputs),
ast::BorrowedSigil => format!("{}|{}|", region, decl.decl.inputs), ast::BorrowedSigil => format!("{}|{}|", region, decl.decl.inputs),
@ -355,7 +355,7 @@ impl fmt::Show for clean::Type {
} }
clean::BareFunction(ref decl) => { clean::BareFunction(ref decl) => {
write!(f.buf, "{}{}fn{}{}", write!(f.buf, "{}{}fn{}{}",
PuritySpace(decl.purity), FnStyleSpace(decl.fn_style),
match decl.abi { match decl.abi {
ref x if "" == *x => ~"", ref x if "" == *x => ~"",
ref x if "\"Rust\"" == *x => ~"", ref x if "\"Rust\"" == *x => ~"",
@ -472,12 +472,12 @@ impl fmt::Show for VisSpace {
} }
} }
impl fmt::Show for PuritySpace { impl fmt::Show for FnStyleSpace {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self.get() { match self.get() {
ast::UnsafeFn => write!(f.buf, "unsafe "), ast::UnsafeFn => write!(f.buf, "unsafe "),
ast::ExternFn => write!(f.buf, "extern "), ast::ExternFn => write!(f.buf, "extern "),
ast::ImpureFn => Ok(()) ast::NormalFn => Ok(())
} }
} }
} }

View file

@ -51,7 +51,7 @@ use rustc::util::nodemap::NodeSet;
use clean; use clean;
use doctree; use doctree;
use fold::DocFolder; use fold::DocFolder;
use html::format::{VisSpace, Method, PuritySpace}; use html::format::{VisSpace, Method, FnStyleSpace};
use html::layout; use html::layout;
use html::markdown; use html::markdown;
use html::markdown::Markdown; use html::markdown::Markdown;
@ -1191,10 +1191,10 @@ fn item_module(w: &mut Writer, cx: &Context,
fn item_function(w: &mut Writer, it: &clean::Item, fn item_function(w: &mut Writer, it: &clean::Item,
f: &clean::Function) -> fmt::Result { f: &clean::Function) -> fmt::Result {
try!(write!(w, "<pre class='rust fn'>{vis}{purity}fn \ try!(write!(w, "<pre class='rust fn'>{vis}{fn_style}fn \
{name}{generics}{decl}</pre>", {name}{generics}{decl}</pre>",
vis = VisSpace(it.visibility), vis = VisSpace(it.visibility),
purity = PuritySpace(f.purity), fn_style = FnStyleSpace(f.fn_style),
name = it.name.get_ref().as_slice(), name = it.name.get_ref().as_slice(),
generics = f.generics, generics = f.generics,
decl = f.decl)); decl = f.decl));
@ -1305,12 +1305,12 @@ fn item_trait(w: &mut Writer, it: &clean::Item,
} }
fn render_method(w: &mut Writer, meth: &clean::Item) -> fmt::Result { fn render_method(w: &mut Writer, meth: &clean::Item) -> fmt::Result {
fn fun(w: &mut Writer, it: &clean::Item, purity: ast::Purity, fn fun(w: &mut Writer, it: &clean::Item, fn_style: ast::FnStyle,
g: &clean::Generics, selfty: &clean::SelfTy, g: &clean::Generics, selfty: &clean::SelfTy,
d: &clean::FnDecl) -> fmt::Result { d: &clean::FnDecl) -> fmt::Result {
write!(w, "{}fn <a href='\\#{ty}.{name}' class='fnname'>{name}</a>\ write!(w, "{}fn <a href='\\#{ty}.{name}' class='fnname'>{name}</a>\
{generics}{decl}", {generics}{decl}",
match purity { match fn_style {
ast::UnsafeFn => "unsafe ", ast::UnsafeFn => "unsafe ",
_ => "", _ => "",
}, },
@ -1321,10 +1321,10 @@ fn render_method(w: &mut Writer, meth: &clean::Item) -> fmt::Result {
} }
match meth.inner { match meth.inner {
clean::TyMethodItem(ref m) => { clean::TyMethodItem(ref m) => {
fun(w, meth, m.purity, &m.generics, &m.self_, &m.decl) fun(w, meth, m.fn_style, &m.generics, &m.self_, &m.decl)
} }
clean::MethodItem(ref m) => { clean::MethodItem(ref m) => {
fun(w, meth, m.purity, &m.generics, &m.self_, &m.decl) fun(w, meth, m.fn_style, &m.generics, &m.self_, &m.decl)
} }
_ => unreachable!() _ => unreachable!()
} }

View file

@ -95,7 +95,7 @@ impl<'a> RustdocVisitor<'a> {
} }
pub fn visit_fn(&mut self, item: &ast::Item, fd: &ast::FnDecl, pub fn visit_fn(&mut self, item: &ast::Item, fd: &ast::FnDecl,
purity: &ast::Purity, _abi: &abi::Abi, fn_style: &ast::FnStyle, _abi: &abi::Abi,
gen: &ast::Generics) -> Function { gen: &ast::Generics) -> Function {
debug!("Visiting fn"); debug!("Visiting fn");
Function { Function {
@ -106,7 +106,7 @@ impl<'a> RustdocVisitor<'a> {
name: item.ident, name: item.ident,
where: item.span, where: item.span,
generics: gen.clone(), generics: gen.clone(),
purity: *purity, fn_style: *fn_style,
} }
} }

View file

@ -210,8 +210,8 @@ pub enum MethodProvenance {
#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)] #[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum Def { pub enum Def {
DefFn(DefId, Purity), DefFn(DefId, FnStyle),
DefStaticMethod(/* method */ DefId, MethodProvenance, Purity), DefStaticMethod(/* method */ DefId, MethodProvenance, FnStyle),
DefSelfTy(/* trait id */ NodeId), DefSelfTy(/* trait id */ NodeId),
DefMod(DefId), DefMod(DefId),
DefForeignMod(DefId), DefForeignMod(DefId),
@ -696,7 +696,7 @@ pub struct TypeField {
pub struct TypeMethod { pub struct TypeMethod {
pub ident: Ident, pub ident: Ident,
pub attrs: Vec<Attribute>, pub attrs: Vec<Attribute>,
pub purity: Purity, pub fn_style: FnStyle,
pub decl: P<FnDecl>, pub decl: P<FnDecl>,
pub generics: Generics, pub generics: Generics,
pub explicit_self: ExplicitSelf, pub explicit_self: ExplicitSelf,
@ -794,7 +794,7 @@ pub struct ClosureTy {
pub sigil: Sigil, pub sigil: Sigil,
pub region: Option<Lifetime>, pub region: Option<Lifetime>,
pub lifetimes: Vec<Lifetime>, pub lifetimes: Vec<Lifetime>,
pub purity: Purity, pub fn_style: FnStyle,
pub onceness: Onceness, pub onceness: Onceness,
pub decl: P<FnDecl>, pub decl: P<FnDecl>,
// Optional optvec distinguishes between "fn()" and "fn:()" so we can // Optional optvec distinguishes between "fn()" and "fn:()" so we can
@ -806,7 +806,7 @@ pub struct ClosureTy {
#[deriving(Eq, TotalEq, Encodable, Decodable, Hash)] #[deriving(Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct BareFnTy { pub struct BareFnTy {
pub purity: Purity, pub fn_style: FnStyle,
pub abi: Abi, pub abi: Abi,
pub lifetimes: Vec<Lifetime>, pub lifetimes: Vec<Lifetime>,
pub decl: P<FnDecl> pub decl: P<FnDecl>
@ -886,16 +886,16 @@ pub struct FnDecl {
} }
#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)] #[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum Purity { pub enum FnStyle {
UnsafeFn, // declared with "unsafe fn" UnsafeFn, // declared with "unsafe fn"
ImpureFn, // declared with "fn" NormalFn, // declared with "fn"
ExternFn, // declared with "extern 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 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self { match *self {
ImpureFn => "impure".fmt(f), NormalFn => "normal".fmt(f),
UnsafeFn => "unsafe".fmt(f), UnsafeFn => "unsafe".fmt(f),
ExternFn => "extern".fmt(f), ExternFn => "extern".fmt(f),
} }
@ -925,7 +925,7 @@ pub struct Method {
pub attrs: Vec<Attribute>, pub attrs: Vec<Attribute>,
pub generics: Generics, pub generics: Generics,
pub explicit_self: ExplicitSelf, pub explicit_self: ExplicitSelf,
pub purity: Purity, pub fn_style: FnStyle,
pub decl: P<FnDecl>, pub decl: P<FnDecl>,
pub body: P<Block>, pub body: P<Block>,
pub id: NodeId, pub id: NodeId,
@ -1119,7 +1119,7 @@ pub struct Item {
#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)] #[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum Item_ { pub enum Item_ {
ItemStatic(P<Ty>, Mutability, @Expr), ItemStatic(P<Ty>, Mutability, @Expr),
ItemFn(P<FnDecl>, Purity, Abi, Generics, P<Block>), ItemFn(P<FnDecl>, FnStyle, Abi, Generics, P<Block>),
ItemMod(Mod), ItemMod(Mod),
ItemForeignMod(ForeignMod), ItemForeignMod(ForeignMod),
ItemTy(P<Ty>, Generics), ItemTy(P<Ty>, Generics),

View file

@ -264,7 +264,7 @@ pub fn trait_method_to_ty_method(method: &TraitMethod) -> TypeMethod {
TypeMethod { TypeMethod {
ident: m.ident, ident: m.ident,
attrs: m.attrs.clone(), attrs: m.attrs.clone(),
purity: m.purity, fn_style: m.fn_style,
decl: m.decl, decl: m.decl,
generics: m.generics.clone(), generics: m.generics.clone(),
explicit_self: m.explicit_self, explicit_self: m.explicit_self,

View file

@ -825,7 +825,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
name, name,
Vec::new(), Vec::new(),
ast::ItemFn(self.fn_decl(inputs, output), ast::ItemFn(self.fn_decl(inputs, output),
ast::ImpureFn, ast::NormalFn,
abi::Rust, abi::Rust,
generics, generics,
body)) body))

View file

@ -619,7 +619,7 @@ impl<'a> MethodDef<'a> {
attrs: attrs, attrs: attrs,
generics: fn_generics, generics: fn_generics,
explicit_self: explicit_self, explicit_self: explicit_self,
purity: ast::ImpureFn, fn_style: ast::NormalFn,
decl: fn_decl, decl: fn_decl,
body: body_block, body: body_block,
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,

View file

@ -158,7 +158,7 @@ pub trait Folder {
TyClosure(ref f) => { TyClosure(ref f) => {
TyClosure(@ClosureTy { TyClosure(@ClosureTy {
sigil: f.sigil, sigil: f.sigil,
purity: f.purity, fn_style: f.fn_style,
region: fold_opt_lifetime(&f.region, self), region: fold_opt_lifetime(&f.region, self),
onceness: f.onceness, onceness: f.onceness,
bounds: fold_opt_bounds(&f.bounds, self), bounds: fold_opt_bounds(&f.bounds, self),
@ -169,7 +169,7 @@ pub trait Folder {
TyBareFn(ref f) => { TyBareFn(ref f) => {
TyBareFn(@BareFnTy { TyBareFn(@BareFnTy {
lifetimes: f.lifetimes.iter().map(|l| fold_lifetime(l, self)).collect(), lifetimes: f.lifetimes.iter().map(|l| fold_lifetime(l, self)).collect(),
purity: f.purity, fn_style: f.fn_style,
abi: f.abi, abi: f.abi,
decl: self.fold_fn_decl(f.decl) 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(t, m, e) => {
ItemStatic(folder.fold_ty(t), m, folder.fold_expr(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( ItemFn(
folder.fold_fn_decl(decl), folder.fold_fn_decl(decl),
purity, fn_style,
abi, abi,
fold_generics(generics, folder), fold_generics(generics, folder),
folder.fold_block(body) 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. id: fld.new_id(m.id), // Needs to be first, for ast_map.
ident: fld.fold_ident(m.ident), ident: fld.fold_ident(m.ident),
attrs: m.attrs.iter().map(|a| fold_attribute_(*a, fld)).collect(), 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), decl: fld.fold_fn_decl(m.decl),
generics: fold_generics(&m.generics, fld), generics: fold_generics(&m.generics, fld),
explicit_self: fld.fold_explicit_self(&m.explicit_self), 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(), attrs: m.attrs.iter().map(|a| fold_attribute_(*a, folder)).collect(),
generics: fold_generics(&m.generics, folder), generics: fold_generics(&m.generics, folder),
explicit_self: folder.fold_explicit_self(&m.explicit_self), explicit_self: folder.fold_explicit_self(&m.explicit_self),
purity: m.purity, fn_style: m.fn_style,
decl: folder.fold_fn_decl(m.decl), decl: folder.fold_fn_decl(m.decl),
body: folder.fold_block(m.body), body: folder.fold_block(m.body),
span: folder.new_span(m.span), span: folder.new_span(m.span),

View file

@ -657,7 +657,7 @@ mod test {
cf: ast::Return, cf: ast::Return,
variadic: false variadic: false
}), }),
ast::ImpureFn, ast::NormalFn,
abi::Rust, abi::Rust,
ast::Generics{ // no idea on either of these: ast::Generics{ // no idea on either of these:
lifetimes: Vec::new(), lifetimes: Vec::new(),

View file

@ -14,7 +14,7 @@ use abi;
use ast::{Sigil, BorrowedSigil, ManagedSigil, OwnedSigil}; use ast::{Sigil, BorrowedSigil, ManagedSigil, OwnedSigil};
use ast::{BareFnTy, ClosureTy}; use ast::{BareFnTy, ClosureTy};
use ast::{RegionTyParamBound, TraitTyParamBound}; 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::{Mod, BiAdd, Arg, Arm, Attribute, BindByRef, BindByValue};
use ast::{BiBitAnd, BiBitOr, BiBitXor, Block}; use ast::{BiBitAnd, BiBitOr, BiBitXor, Block};
use ast::{BlockCheckMode, UnBox}; use ast::{BlockCheckMode, UnBox};
@ -31,7 +31,7 @@ use ast::{ExprVec, ExprVstore, ExprVstoreSlice};
use ast::{ExprVstoreMutSlice, ExprWhile, ExprForLoop, ExternFn, Field, FnDecl}; use ast::{ExprVstoreMutSlice, ExprWhile, ExprForLoop, ExternFn, Field, FnDecl};
use ast::{ExprVstoreUniq, Once, Many}; use ast::{ExprVstoreUniq, Once, Many};
use ast::{ForeignItem, ForeignItemStatic, ForeignItemFn, ForeignMod}; 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::{ItemEnum, ItemFn, ItemForeignMod, ItemImpl};
use ast::{ItemMac, ItemMod, ItemStruct, ItemTrait, ItemTy, Lit, Lit_}; use ast::{ItemMac, ItemMod, ItemStruct, ItemTrait, ItemTy, Lit, Lit_};
use ast::{LitBool, LitFloat, LitFloatUnsuffixed, LitInt, LitChar}; use ast::{LitBool, LitFloat, LitFloatUnsuffixed, LitInt, LitChar};
@ -867,7 +867,7 @@ impl<'a> Parser<'a> {
| | | Argument types | | | Argument types
| | Lifetimes | | Lifetimes
| | | |
| Purity | Function Style
ABI ABI
*/ */
@ -878,12 +878,12 @@ impl<'a> Parser<'a> {
abi::Rust abi::Rust
}; };
let purity = self.parse_unsafety(); let fn_style = self.parse_unsafety();
self.expect_keyword(keywords::Fn); self.expect_keyword(keywords::Fn);
let (decl, lifetimes) = self.parse_ty_fn_decl(true); let (decl, lifetimes) = self.parse_ty_fn_decl(true);
return TyBareFn(@BareFnTy { return TyBareFn(@BareFnTy {
abi: abi, abi: abi,
purity: purity, fn_style: fn_style,
lifetimes: lifetimes, lifetimes: lifetimes,
decl: decl decl: decl
}); });
@ -925,7 +925,7 @@ impl<'a> Parser<'a> {
TyClosure(@ClosureTy { TyClosure(@ClosureTy {
sigil: OwnedSigil, sigil: OwnedSigil,
region: None, region: None,
purity: ImpureFn, fn_style: NormalFn,
onceness: Once, onceness: Once,
bounds: bounds, bounds: bounds,
decl: decl, decl: decl,
@ -945,11 +945,11 @@ impl<'a> Parser<'a> {
| | | Argument types | | | Argument types
| | Lifetimes | | Lifetimes
| Once-ness (a.k.a., affine) | 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 onceness = if self.eat_keyword(keywords::Once) {Once} else {Many};
let lifetimes = if self.eat(&token::LT) { let lifetimes = if self.eat(&token::LT) {
@ -985,7 +985,7 @@ impl<'a> Parser<'a> {
TyClosure(@ClosureTy { TyClosure(@ClosureTy {
sigil: BorrowedSigil, sigil: BorrowedSigil,
region: region, region: region,
purity: purity, fn_style: fn_style,
onceness: onceness, onceness: onceness,
bounds: bounds, bounds: bounds,
decl: decl, 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) { if self.eat_keyword(keywords::Unsafe) {
return UnsafeFn; return UnsafeFn;
} else { } else {
return ImpureFn; return NormalFn;
} }
} }
@ -1045,7 +1045,7 @@ impl<'a> Parser<'a> {
let vis_span = p.span; let vis_span = p.span;
let vis = p.parse_visibility(); 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 // NB: at the moment, trait methods are public by default; this
// could change. // could change.
let ident = p.parse_ident(); let ident = p.parse_ident();
@ -1071,7 +1071,7 @@ impl<'a> Parser<'a> {
Required(TypeMethod { Required(TypeMethod {
ident: ident, ident: ident,
attrs: attrs, attrs: attrs,
purity: pur, fn_style: style,
decl: d, decl: d,
generics: generics, generics: generics,
explicit_self: explicit_self, explicit_self: explicit_self,
@ -1089,7 +1089,7 @@ impl<'a> Parser<'a> {
attrs: attrs, attrs: attrs,
generics: generics, generics: generics,
explicit_self: explicit_self, explicit_self: explicit_self,
purity: pur, fn_style: style,
decl: d, decl: d,
body: body, body: body,
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
@ -3754,11 +3754,11 @@ impl<'a> Parser<'a> {
} }
// parse an item-position function declaration. // 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 (ident, generics) = self.parse_fn_header();
let decl = self.parse_fn_decl(false); let decl = self.parse_fn_decl(false);
let (inner_attrs, body) = self.parse_inner_attrs_and_block(); 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. // 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 lo = self.span.lo;
let visa = self.parse_visibility(); let visa = self.parse_visibility();
let pur = self.parse_fn_purity(); let fn_style = self.parse_fn_style();
let ident = self.parse_ident(); let ident = self.parse_ident();
let generics = self.parse_generics(); let generics = self.parse_generics();
let (explicit_self, decl) = self.parse_fn_decl_with_self(|p| { let (explicit_self, decl) = self.parse_fn_decl_with_self(|p| {
@ -3787,7 +3787,7 @@ impl<'a> Parser<'a> {
attrs: attrs, attrs: attrs,
generics: generics, generics: generics,
explicit_self: explicit_self, explicit_self: explicit_self,
purity: pur, fn_style: fn_style,
decl: decl, decl: decl,
body: body, body: body,
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
@ -4169,8 +4169,8 @@ impl<'a> Parser<'a> {
let lo = self.span.lo; let lo = self.span.lo;
// Parse obsolete purity. // Parse obsolete purity.
let purity = self.parse_fn_purity(); let fn_style = self.parse_fn_style();
if purity != ImpureFn { if fn_style != NormalFn {
self.obsolete(self.last_span, ObsoleteUnsafeExternFn); self.obsolete(self.last_span, ObsoleteUnsafeExternFn);
} }
@ -4208,8 +4208,8 @@ impl<'a> Parser<'a> {
} }
// parse safe/unsafe and fn // parse safe/unsafe and fn
fn parse_fn_purity(&mut self) -> Purity { fn parse_fn_style(&mut self) -> FnStyle {
if self.eat_keyword(keywords::Fn) { ImpureFn } if self.eat_keyword(keywords::Fn) { NormalFn }
else if self.eat_keyword(keywords::Unsafe) { else if self.eat_keyword(keywords::Unsafe) {
self.expect_keyword(keywords::Fn); self.expect_keyword(keywords::Fn);
UnsafeFn UnsafeFn
@ -4540,7 +4540,7 @@ impl<'a> Parser<'a> {
// FUNCTION ITEM // FUNCTION ITEM
self.bump(); self.bump();
let (ident, item_, extra_attrs) = 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, let item = self.mk_item(lo,
self.last_span.hi, self.last_span.hi,
ident, ident,

View file

@ -186,11 +186,11 @@ pub fn path_to_str(p: &ast::Path) -> ~str {
to_str(|s| s.print_path(p, false)) 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_>, opt_explicit_self: Option<ast::ExplicitSelf_>,
generics: &ast::Generics) -> ~str { generics: &ast::Generics) -> ~str {
to_str(|s| { 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)); name, generics, opt_explicit_self, ast::Inherited));
try!(s.end()); // Close the head box try!(s.end()); // Close the head box
s.end() // Close the outer box s.end() // Close the outer box
@ -479,7 +479,7 @@ impl<'a> State<'a> {
ty_params: OwnedSlice::empty() ty_params: OwnedSlice::empty()
}; };
try!(self.print_ty_fn(Some(f.abi), None, &None, 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)); Some(&generics), None));
} }
ast::TyClosure(f) => { ast::TyClosure(f) => {
@ -488,7 +488,7 @@ impl<'a> State<'a> {
ty_params: OwnedSlice::empty() ty_params: OwnedSlice::empty()
}; };
try!(self.print_ty_fn(None, Some(f.sigil), &f.region, 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)); Some(&generics), None));
} }
ast::TyPath(ref path, ref bounds, _) => { ast::TyPath(ref path, ref bounds, _) => {
@ -567,10 +567,10 @@ impl<'a> State<'a> {
try!(word(&mut self.s, ";")); try!(word(&mut self.s, ";"));
try!(self.end()); // end the outer cbox 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( try!(self.print_fn(
decl, decl,
Some(purity), Some(fn_style),
abi, abi,
item.ident, item.ident,
typarams, typarams,
@ -861,7 +861,7 @@ impl<'a> State<'a> {
try!(self.print_ty_fn(None, try!(self.print_ty_fn(None,
None, None,
&None, &None,
m.purity, m.fn_style,
ast::Many, ast::Many,
m.decl, m.decl,
Some(m.ident), Some(m.ident),
@ -883,7 +883,7 @@ impl<'a> State<'a> {
try!(self.hardbreak_if_not_bol()); try!(self.hardbreak_if_not_bol());
try!(self.maybe_print_comment(meth.span.lo)); try!(self.maybe_print_comment(meth.span.lo));
try!(self.print_outer_attributes(meth.attrs.as_slice())); 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.ident, &meth.generics, Some(meth.explicit_self.node),
meth.vis)); meth.vis));
try!(word(&mut self.s, " ")); try!(word(&mut self.s, " "));
@ -1708,14 +1708,14 @@ impl<'a> State<'a> {
pub fn print_fn(&mut self, pub fn print_fn(&mut self,
decl: &ast::FnDecl, decl: &ast::FnDecl,
purity: Option<ast::Purity>, fn_style: Option<ast::FnStyle>,
abi: abi::Abi, abi: abi::Abi,
name: ast::Ident, name: ast::Ident,
generics: &ast::Generics, generics: &ast::Generics,
opt_explicit_self: Option<ast::ExplicitSelf_>, opt_explicit_self: Option<ast::ExplicitSelf_>,
vis: ast::Visibility) -> IoResult<()> { vis: ast::Visibility) -> IoResult<()> {
try!(self.head("")); 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)); ast::Many, None, vis));
try!(self.nbsp()); try!(self.nbsp());
try!(self.print_ident(name)); try!(self.print_ident(name));
@ -2024,7 +2024,7 @@ impl<'a> State<'a> {
opt_abi: Option<abi::Abi>, opt_abi: Option<abi::Abi>,
opt_sigil: Option<ast::Sigil>, opt_sigil: Option<ast::Sigil>,
opt_region: &Option<ast::Lifetime>, opt_region: &Option<ast::Lifetime>,
purity: ast::Purity, fn_style: ast::FnStyle,
onceness: ast::Onceness, onceness: ast::Onceness,
decl: &ast::FnDecl, decl: &ast::FnDecl,
id: Option<ast::Ident>, id: Option<ast::Ident>,
@ -2040,12 +2040,12 @@ impl<'a> State<'a> {
try!(word(&mut self.s, "proc")); try!(word(&mut self.s, "proc"));
} else if opt_sigil == Some(ast::BorrowedSigil) { } else if opt_sigil == Some(ast::BorrowedSigil) {
try!(self.print_extern_opt_abi(opt_abi)); 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)); try!(self.print_onceness(onceness));
} else { } else {
try!(self.print_opt_abi_and_extern_if_nondefault(opt_abi)); try!(self.print_opt_abi_and_extern_if_nondefault(opt_abi));
try!(self.print_opt_sigil(opt_sigil)); 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!(self.print_onceness(onceness));
try!(word(&mut self.s, "fn")); try!(word(&mut self.s, "fn"));
} }
@ -2294,10 +2294,10 @@ impl<'a> State<'a> {
} }
} }
pub fn print_opt_purity(&mut self, pub fn print_opt_fn_style(&mut self,
opt_purity: Option<ast::Purity>) -> IoResult<()> { opt_fn_style: Option<ast::FnStyle>) -> IoResult<()> {
match opt_purity { match opt_fn_style {
Some(purity) => self.print_purity(purity), Some(fn_style) => self.print_fn_style(fn_style),
None => Ok(()) None => Ok(())
} }
} }
@ -2338,7 +2338,7 @@ impl<'a> State<'a> {
pub fn print_fn_header_info(&mut self, pub fn print_fn_header_info(&mut self,
_opt_explicit_self: Option<ast::ExplicitSelf_>, _opt_explicit_self: Option<ast::ExplicitSelf_>,
opt_purity: Option<ast::Purity>, opt_fn_style: Option<ast::FnStyle>,
abi: abi::Abi, abi: abi::Abi,
onceness: ast::Onceness, onceness: ast::Onceness,
opt_sigil: Option<ast::Sigil>, opt_sigil: Option<ast::Sigil>,
@ -2349,11 +2349,11 @@ impl<'a> State<'a> {
try!(self.word_nbsp("extern")); try!(self.word_nbsp("extern"));
try!(self.word_nbsp(abi.to_str())); try!(self.word_nbsp(abi.to_str()));
if opt_purity != Some(ast::ExternFn) { if opt_fn_style != Some(ast::ExternFn) {
try!(self.print_opt_purity(opt_purity)); try!(self.print_opt_fn_style(opt_fn_style));
} }
} else { } else {
try!(self.print_opt_purity(opt_purity)); try!(self.print_opt_fn_style(opt_fn_style));
} }
try!(self.print_onceness(onceness)); try!(self.print_onceness(onceness));
@ -2361,9 +2361,9 @@ impl<'a> State<'a> {
self.print_opt_sigil(opt_sigil) self.print_opt_sigil(opt_sigil)
} }
pub fn print_purity(&mut self, p: ast::Purity) -> IoResult<()> { pub fn print_fn_style(&mut self, s: ast::FnStyle) -> IoResult<()> {
match p { match s {
ast::ImpureFn => Ok(()), ast::NormalFn => Ok(()),
ast::UnsafeFn => self.word_nbsp("unsafe"), ast::UnsafeFn => self.word_nbsp("unsafe"),
ast::ExternFn => self.word_nbsp("extern") ast::ExternFn => self.word_nbsp("extern")
} }
@ -2399,7 +2399,7 @@ mod test {
variadic: false variadic: false
}; };
let generics = ast_util::empty_generics(); 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), None, &generics),
&~"fn abba()"); &~"fn abba()");
} }

View file

@ -29,7 +29,7 @@ use owned_slice::OwnedSlice;
pub enum FnKind<'a> { pub enum FnKind<'a> {
// fn foo() or extern "Abi" fn foo() // fn foo() or extern "Abi" fn foo()
FkItemFn(Ident, &'a Generics, Purity, Abi), FkItemFn(Ident, &'a Generics, FnStyle, Abi),
// fn foo(&self) // fn foo(&self)
FkMethod(Ident, &'a Generics, &'a Method), 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_ty(typ, env.clone());
visitor.visit_expr(expr, env); visitor.visit_expr(expr, env);
} }
ItemFn(declaration, purity, abi, ref generics, body) => { ItemFn(declaration, fn_style, abi, ref generics, body) => {
visitor.visit_fn(&FkItemFn(item.ident, generics, purity, abi), visitor.visit_fn(&FkItemFn(item.ident, generics, fn_style, abi),
declaration, declaration,
body, body,
item.span, item.span,

View file

@ -17,7 +17,7 @@ trait Mumbo {
impl Mumbo for uint { impl Mumbo for uint {
// Cannot have a larger effect than the trait: // Cannot have a larger effect than the trait:
unsafe fn jumbo(&self, x: @uint) { *self + *x; } unsafe fn jumbo(&self, x: @uint) { *self + *x; }
//~^ ERROR expected impure fn but found unsafe fn //~^ ERROR expected normal fn but found unsafe fn
} }
fn main() {} fn main() {}