Skip to content

Commit

Permalink
Renamed ast::Purity to ast::FnStyle and ast::ImpureFn to ast::NormalF…
Browse files Browse the repository at this point in the history
…n and updated associated variable and function names.
  • Loading branch information
kaseyc authored and alexcrichton committed Apr 10, 2014
1 parent 3f2c55f commit 0bf4e90
Show file tree
Hide file tree
Showing 40 changed files with 262 additions and 262 deletions.
2 changes: 1 addition & 1 deletion src/librustc/metadata/csearch.rs
Expand Up @@ -28,7 +28,7 @@ use syntax::parse::token;
pub struct StaticMethodInfo {
pub ident: ast::Ident,
pub def_id: ast::DefId,
pub purity: ast::Purity,
pub fn_style: ast::FnStyle,
pub vis: ast::Visibility,
}

Expand Down
16 changes: 8 additions & 8 deletions src/librustc/metadata/decoder.rs
Expand Up @@ -330,11 +330,11 @@ fn item_to_def_like(item: ebml::Doc, did: ast::DefId, cnum: ast::CrateNum)
MutStatic => DlDef(ast::DefStatic(did, true)),
Struct => DlDef(ast::DefStruct(did)),
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)),
StaticMethod | UnsafeStaticMethod => {
let purity = if fam == UnsafeStaticMethod { ast::UnsafeFn } else
{ ast::ImpureFn };
let fn_style = if fam == UnsafeStaticMethod { ast::UnsafeFn } else
{ ast::NormalFn };
// def_static_method carries an optional field of its enclosing
// 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
Expand All @@ -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,
item))
};
DlDef(ast::DefStaticMethod(did, provenance, purity))
DlDef(ast::DefStaticMethod(did, provenance, fn_style))
}
Type | ForeignType => DlDef(ast::DefTy(did)),
Mod => DlDef(ast::DefMod(did)),
Expand Down Expand Up @@ -905,17 +905,17 @@ pub fn get_static_methods_if_impl(intr: Rc<IdentInterner>,
let family = item_family(impl_method_doc);
match family {
StaticMethod | UnsafeStaticMethod => {
let purity;
let fn_style;
match item_family(impl_method_doc) {
StaticMethod => purity = ast::ImpureFn,
UnsafeStaticMethod => purity = ast::UnsafeFn,
StaticMethod => fn_style = ast::NormalFn,
UnsafeStaticMethod => fn_style = ast::UnsafeFn,
_ => fail!()
}

static_impl_methods.push(StaticMethodInfo {
ident: item_name(&*intr, impl_method_doc),
def_id: item_def_id(impl_method_doc, cdata),
purity: purity,
fn_style: fn_style,
vis: item_visibility(impl_method_doc),
});
}
Expand Down
32 changes: 16 additions & 16 deletions src/librustc/metadata/encoder.rs
Expand Up @@ -758,12 +758,12 @@ fn encode_method_ty_fields(ecx: &EncodeContext,
encode_method_fty(ecx, ebml_w, &method_ty.fty);
encode_visibility(ebml_w, method_ty.vis);
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 {
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);
}
Expand Down Expand Up @@ -811,18 +811,18 @@ fn encode_info_for_method(ecx: &EncodeContext,
ebml_w.end_tag();
}

fn purity_fn_family(p: Purity) -> char {
match p {
fn style_fn_family(s: FnStyle) -> char {
match s {
UnsafeFn => 'u',
ImpureFn => 'f',
NormalFn => 'f',
ExternFn => 'e'
}
}

fn purity_static_method_family(p: Purity) -> char {
match p {
fn fn_style_static_method_family(s: FnStyle) -> char {
match s {
UnsafeFn => 'U',
ImpureFn => 'F',
NormalFn => 'F',
_ => fail!("extern fn can't be static")
}
}
Expand Down Expand Up @@ -911,11 +911,11 @@ fn encode_info_for_item(ecx: &EncodeContext,
encode_visibility(ebml_w, vis);
ebml_w.end_tag();
}
ItemFn(_, purity, _, ref generics, _) => {
ItemFn(_, fn_style, _, ref generics, _) => {
add_to_index(item, ebml_w, index);
ebml_w.start_tag(tag_items_data_item);
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();
encode_bounds_and_type(ebml_w, ecx, &lookup_item_type(tcx, def_id));
encode_name(ebml_w, item.ident.name);
Expand Down Expand Up @@ -1165,17 +1165,17 @@ fn encode_info_for_item(ecx: &EncodeContext,
match method_ty.explicit_self {
SelfStatic => {
encode_family(ebml_w,
purity_static_method_family(
method_ty.fty.purity));
fn_style_static_method_family(
method_ty.fty.fn_style));

let tpt = ty::lookup_item_type(tcx, method_def_id);
encode_bounds_and_type(ebml_w, ecx, &tpt);
}

_ => {
encode_family(ebml_w,
purity_fn_family(
method_ty.fty.purity));
style_fn_family(
method_ty.fty.fn_style));
}
}

Expand Down Expand Up @@ -1227,7 +1227,7 @@ fn encode_info_for_foreign_item(ecx: &EncodeContext,
encode_def_id(ebml_w, local_def(nitem.id));
match nitem.node {
ForeignItemFn(..) => {
encode_family(ebml_w, purity_fn_family(ImpureFn));
encode_family(ebml_w, style_fn_family(NormalFn));
encode_bounds_and_type(ebml_w, ecx,
&lookup_item_type(ecx.tcx,local_def(nitem.id)));
encode_name(ebml_w, nitem.ident.name);
Expand Down
14 changes: 7 additions & 7 deletions src/librustc/metadata/tydecode.rs
Expand Up @@ -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 {
'u' => UnsafeFn,
'i' => ImpureFn,
'n' => NormalFn,
'c' => ExternFn,
_ => fail!("parse_purity: bad purity {}", c)
_ => fail!("parse_fn_style: bad fn_style {}", c)
}
}

Expand All @@ -476,13 +476,13 @@ fn parse_onceness(c: char) -> ast::Onceness {

fn parse_closure_ty(st: &mut PState, conv: conv_did) -> ty::ClosureTy {
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 region = parse_region(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));
ty::ClosureTy {
purity: purity,
fn_style: fn_style,
sigil: sigil,
onceness: onceness,
region: region,
Expand All @@ -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 {
let purity = parse_purity(next(st));
let fn_style = parse_fn_style(next(st));
let abi = parse_abi_set(st);
let sig = parse_sig(st, |x,y| conv(x,y));
ty::BareFnTy {
purity: purity,
fn_style: fn_style,
abi: abi,
sig: sig
}
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/metadata/tyencode.rs
Expand Up @@ -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 {
ImpureFn => mywrite!(w, "i"),
NormalFn => mywrite!(w, "n"),
UnsafeFn => mywrite!(w, "u"),
ExternFn => mywrite!(w, "c")
}
Expand All @@ -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) {
enc_purity(w, ft.purity);
enc_fn_style(w, ft.fn_style);
enc_abi(w, ft.abi);
enc_fn_sig(w, cx, &ft.sig);
}

fn enc_closure_ty(w: &mut MemWriter, cx: &ctxt, ft: &ty::ClosureTy) {
enc_sigil(w, ft.sigil);
enc_purity(w, ft.purity);
enc_fn_style(w, ft.fn_style);
enc_onceness(w, ft.onceness);
enc_region(w, cx, ft.region);
let bounds = ty::ParamBounds {builtin_bounds: ft.bounds,
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/middle/effect.rs
Expand Up @@ -29,8 +29,8 @@ enum UnsafeContext {

fn type_is_unsafe_function(ty: ty::t) -> bool {
match ty::get(ty).sty {
ty::ty_bare_fn(ref f) => f.purity == ast::UnsafeFn,
ty::ty_closure(ref f) => f.purity == ast::UnsafeFn,
ty::ty_bare_fn(ref f) => f.fn_style == ast::UnsafeFn,
ty::ty_closure(ref f) => f.fn_style == ast::UnsafeFn,
_ => false,
}
}
Expand Down Expand Up @@ -84,10 +84,10 @@ impl<'a> Visitor<()> for EffectCheckVisitor<'a> {
block: &ast::Block, span: Span, node_id: ast::NodeId, _:()) {

let (is_item_fn, is_unsafe_fn) = match *fn_kind {
visit::FkItemFn(_, _, purity, _) =>
(true, purity == ast::UnsafeFn),
visit::FkItemFn(_, _, fn_style, _) =>
(true, fn_style == ast::UnsafeFn),
visit::FkMethod(_, _, method) =>
(true, method.purity == ast::UnsafeFn),
(true, method.fn_style == ast::UnsafeFn),
_ => (false, false),
};

Expand Down
10 changes: 5 additions & 5 deletions src/librustc/middle/resolve.rs
Expand Up @@ -1182,11 +1182,11 @@ impl<'a> Resolver<'a> {
(DefStatic(local_def(item.id), mutbl), sp, is_public);
parent
}
ItemFn(_, purity, _, _, _) => {
ItemFn(_, fn_style, _, _, _) => {
let (name_bindings, new_parent) =
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);
new_parent
}
Expand Down Expand Up @@ -1313,7 +1313,7 @@ impl<'a> Resolver<'a> {
DefStaticMethod(local_def(method.id),
FromImpl(local_def(
item.id)),
method.purity)
method.fn_style)
}
_ => {
// Non-static methods become
Expand Down Expand Up @@ -1364,7 +1364,7 @@ impl<'a> Resolver<'a> {
// Static methods become `def_static_method`s.
DefStaticMethod(local_def(ty_m.id),
FromTrait(local_def(item.id)),
ty_m.purity)
ty_m.fn_style)
}
_ => {
// Non-static methods become `def_method`s.
Expand Down Expand Up @@ -1869,7 +1869,7 @@ impl<'a> Resolver<'a> {
DUMMY_SP);
let def = DefFn(
static_method_info.def_id,
static_method_info.purity);
static_method_info.fn_style);

method_name_bindings.define_value(
def, DUMMY_SP,
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/middle/trans/base.rs
Expand Up @@ -1554,8 +1554,8 @@ impl<'a> Visitor<()> for TransItemVisitor<'a> {
pub fn trans_item(ccx: &CrateContext, item: &ast::Item) {
let _icx = push_ctxt("trans_item");
match item.node {
ast::ItemFn(decl, purity, _abi, ref generics, body) => {
if purity == ast::ExternFn {
ast::ItemFn(decl, fn_style, _abi, ref generics, body) => {
if fn_style == ast::ExternFn {
let llfndecl = get_item_val(ccx, item.id);
foreign::trans_rust_fn_with_foreign_abi(
ccx, decl, body, item.attrs.as_slice(), llfndecl, item.id);
Expand Down Expand Up @@ -1899,8 +1899,8 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
}
}

ast::ItemFn(_, purity, _, _, _) => {
let llfn = if purity != ast::ExternFn {
ast::ItemFn(_, fn_style, _, _, _) => {
let llfn = if fn_style != ast::ExternFn {
register_fn(ccx, i.span, sym, i.id, ty)
} else {
foreign::register_rust_fn_with_foreign_abi(ccx,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/consts.rs
Expand Up @@ -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);
match opt_def {
Some(ast::DefFn(def_id, _purity)) => {
Some(ast::DefFn(def_id, _fn_style)) => {
if !ast_util::is_local(def_id) {
let ty = csearch::get_type(cx.tcx(), def_id).ty;
(base::trans_external_path(cx, def_id, ty), true)
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/middle/trans/reflect.rs
Expand Up @@ -211,7 +211,7 @@ impl<'a> Reflector<'a> {
// FIXME (#2594): fetch constants out of intrinsic
// FIXME (#4809): visitor should break out bare fns from other fns
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 retval = if ty::type_is_bot(fty.sig.output) {0u} else {1u};
let extra = vec!(self.c_uint(pureval),
Expand All @@ -226,7 +226,7 @@ impl<'a> Reflector<'a> {
// FIXME (#2594): fetch constants out of intrinsic:: for the
// numbers.
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 retval = if ty::type_is_bot(fty.sig.output) {0u} else {1u};
let extra = vec!(self.c_uint(pureval),
Expand Down Expand Up @@ -399,10 +399,10 @@ pub fn ast_sigil_constant(sigil: ast::Sigil) -> uint {
}
}

pub fn ast_purity_constant(purity: ast::Purity) -> uint {
match purity {
pub fn ast_fn_style_constant(fn_style: ast::FnStyle) -> uint {
match fn_style {
ast::UnsafeFn => 1u,
ast::ImpureFn => 2u,
ast::NormalFn => 2u,
ast::ExternFn => 3u
}
}

0 comments on commit 0bf4e90

Please sign in to comment.