Skip to content

Commit b953959

Browse files
committed
Renamed ast::Purity to ast::FnStyle and ast::ImpureFn to ast::NormalFn and updated associated variable and function names.
1 parent 02f5121 commit b953959

40 files changed

+262
-262
lines changed

src/librustc/metadata/csearch.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use syntax::parse::token;
2828
pub struct StaticMethodInfo {
2929
pub ident: ast::Ident,
3030
pub def_id: ast::DefId,
31-
pub purity: ast::Purity,
31+
pub fn_style: ast::FnStyle,
3232
pub vis: ast::Visibility,
3333
}
3434

src/librustc/metadata/decoder.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -330,11 +330,11 @@ fn item_to_def_like(item: ebml::Doc, did: ast::DefId, cnum: ast::CrateNum)
330330
MutStatic => DlDef(ast::DefStatic(did, true)),
331331
Struct => DlDef(ast::DefStruct(did)),
332332
UnsafeFn => DlDef(ast::DefFn(did, ast::UnsafeFn)),
333-
Fn => DlDef(ast::DefFn(did, ast::ImpureFn)),
333+
Fn => DlDef(ast::DefFn(did, ast::NormalFn)),
334334
ForeignFn => DlDef(ast::DefFn(did, ast::ExternFn)),
335335
StaticMethod | UnsafeStaticMethod => {
336-
let purity = if fam == UnsafeStaticMethod { ast::UnsafeFn } else
337-
{ ast::ImpureFn };
336+
let fn_style = if fam == UnsafeStaticMethod { ast::UnsafeFn } else
337+
{ ast::NormalFn };
338338
// def_static_method carries an optional field of its enclosing
339339
// trait or enclosing impl (if this is an inherent static method).
340340
// 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)
348348
ast::FromImpl(item_reqd_and_translated_parent_item(cnum,
349349
item))
350350
};
351-
DlDef(ast::DefStaticMethod(did, provenance, purity))
351+
DlDef(ast::DefStaticMethod(did, provenance, fn_style))
352352
}
353353
Type | ForeignType => DlDef(ast::DefTy(did)),
354354
Mod => DlDef(ast::DefMod(did)),
@@ -905,17 +905,17 @@ pub fn get_static_methods_if_impl(intr: Rc<IdentInterner>,
905905
let family = item_family(impl_method_doc);
906906
match family {
907907
StaticMethod | UnsafeStaticMethod => {
908-
let purity;
908+
let fn_style;
909909
match item_family(impl_method_doc) {
910-
StaticMethod => purity = ast::ImpureFn,
911-
UnsafeStaticMethod => purity = ast::UnsafeFn,
910+
StaticMethod => fn_style = ast::NormalFn,
911+
UnsafeStaticMethod => fn_style = ast::UnsafeFn,
912912
_ => fail!()
913913
}
914914

915915
static_impl_methods.push(StaticMethodInfo {
916916
ident: item_name(&*intr, impl_method_doc),
917917
def_id: item_def_id(impl_method_doc, cdata),
918-
purity: purity,
918+
fn_style: fn_style,
919919
vis: item_visibility(impl_method_doc),
920920
});
921921
}

src/librustc/metadata/encoder.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -758,12 +758,12 @@ fn encode_method_ty_fields(ecx: &EncodeContext,
758758
encode_method_fty(ecx, ebml_w, &method_ty.fty);
759759
encode_visibility(ebml_w, method_ty.vis);
760760
encode_explicit_self(ebml_w, method_ty.explicit_self);
761-
let purity = method_ty.fty.purity;
761+
let fn_style = method_ty.fty.fn_style;
762762
match method_ty.explicit_self {
763763
ast::SelfStatic => {
764-
encode_family(ebml_w, purity_static_method_family(purity));
764+
encode_family(ebml_w, fn_style_static_method_family(fn_style));
765765
}
766-
_ => encode_family(ebml_w, purity_fn_family(purity))
766+
_ => encode_family(ebml_w, style_fn_family(fn_style))
767767
}
768768
encode_provided_source(ebml_w, method_ty.provided_source);
769769
}
@@ -811,18 +811,18 @@ fn encode_info_for_method(ecx: &EncodeContext,
811811
ebml_w.end_tag();
812812
}
813813

814-
fn purity_fn_family(p: Purity) -> char {
815-
match p {
814+
fn style_fn_family(s: FnStyle) -> char {
815+
match s {
816816
UnsafeFn => 'u',
817-
ImpureFn => 'f',
817+
NormalFn => 'f',
818818
ExternFn => 'e'
819819
}
820820
}
821821

822-
fn purity_static_method_family(p: Purity) -> char {
823-
match p {
822+
fn fn_style_static_method_family(s: FnStyle) -> char {
823+
match s {
824824
UnsafeFn => 'U',
825-
ImpureFn => 'F',
825+
NormalFn => 'F',
826826
_ => fail!("extern fn can't be static")
827827
}
828828
}
@@ -911,11 +911,11 @@ fn encode_info_for_item(ecx: &EncodeContext,
911911
encode_visibility(ebml_w, vis);
912912
ebml_w.end_tag();
913913
}
914-
ItemFn(_, purity, _, ref generics, _) => {
914+
ItemFn(_, fn_style, _, ref generics, _) => {
915915
add_to_index(item, ebml_w, index);
916916
ebml_w.start_tag(tag_items_data_item);
917917
encode_def_id(ebml_w, def_id);
918-
encode_family(ebml_w, purity_fn_family(purity));
918+
encode_family(ebml_w, style_fn_family(fn_style));
919919
let tps_len = generics.ty_params.len();
920920
encode_bounds_and_type(ebml_w, ecx, &lookup_item_type(tcx, def_id));
921921
encode_name(ebml_w, item.ident.name);
@@ -1165,17 +1165,17 @@ fn encode_info_for_item(ecx: &EncodeContext,
11651165
match method_ty.explicit_self {
11661166
SelfStatic => {
11671167
encode_family(ebml_w,
1168-
purity_static_method_family(
1169-
method_ty.fty.purity));
1168+
fn_style_static_method_family(
1169+
method_ty.fty.fn_style));
11701170

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

11751175
_ => {
11761176
encode_family(ebml_w,
1177-
purity_fn_family(
1178-
method_ty.fty.purity));
1177+
style_fn_family(
1178+
method_ty.fty.fn_style));
11791179
}
11801180
}
11811181

@@ -1227,7 +1227,7 @@ fn encode_info_for_foreign_item(ecx: &EncodeContext,
12271227
encode_def_id(ebml_w, local_def(nitem.id));
12281228
match nitem.node {
12291229
ForeignItemFn(..) => {
1230-
encode_family(ebml_w, purity_fn_family(ImpureFn));
1230+
encode_family(ebml_w, style_fn_family(NormalFn));
12311231
encode_bounds_and_type(ebml_w, ecx,
12321232
&lookup_item_type(ecx.tcx,local_def(nitem.id)));
12331233
encode_name(ebml_w, nitem.ident.name);

src/librustc/metadata/tydecode.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -449,12 +449,12 @@ fn parse_hex(st: &mut PState) -> uint {
449449
};
450450
}
451451

452-
fn parse_purity(c: char) -> Purity {
452+
fn parse_fn_style(c: char) -> FnStyle {
453453
match c {
454454
'u' => UnsafeFn,
455-
'i' => ImpureFn,
455+
'n' => NormalFn,
456456
'c' => ExternFn,
457-
_ => fail!("parse_purity: bad purity {}", c)
457+
_ => fail!("parse_fn_style: bad fn_style {}", c)
458458
}
459459
}
460460

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

477477
fn parse_closure_ty(st: &mut PState, conv: conv_did) -> ty::ClosureTy {
478478
let sigil = parse_sigil(st);
479-
let purity = parse_purity(next(st));
479+
let fn_style = parse_fn_style(next(st));
480480
let onceness = parse_onceness(next(st));
481481
let region = parse_region(st, |x,y| conv(x,y));
482482
let bounds = parse_bounds(st, |x,y| conv(x,y));
483483
let sig = parse_sig(st, |x,y| conv(x,y));
484484
ty::ClosureTy {
485-
purity: purity,
485+
fn_style: fn_style,
486486
sigil: sigil,
487487
onceness: onceness,
488488
region: region,
@@ -492,11 +492,11 @@ fn parse_closure_ty(st: &mut PState, conv: conv_did) -> ty::ClosureTy {
492492
}
493493

494494
fn parse_bare_fn_ty(st: &mut PState, conv: conv_did) -> ty::BareFnTy {
495-
let purity = parse_purity(next(st));
495+
let fn_style = parse_fn_style(next(st));
496496
let abi = parse_abi_set(st);
497497
let sig = parse_sig(st, |x,y| conv(x,y));
498498
ty::BareFnTy {
499-
purity: purity,
499+
fn_style: fn_style,
500500
abi: abi,
501501
sig: sig
502502
}

src/librustc/metadata/tyencode.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,9 @@ fn enc_sigil(w: &mut MemWriter, sigil: Sigil) {
332332
}
333333
}
334334

335-
fn enc_purity(w: &mut MemWriter, p: Purity) {
335+
fn enc_fn_style(w: &mut MemWriter, p: FnStyle) {
336336
match p {
337-
ImpureFn => mywrite!(w, "i"),
337+
NormalFn => mywrite!(w, "n"),
338338
UnsafeFn => mywrite!(w, "u"),
339339
ExternFn => mywrite!(w, "c")
340340
}
@@ -354,14 +354,14 @@ fn enc_onceness(w: &mut MemWriter, o: Onceness) {
354354
}
355355

356356
pub fn enc_bare_fn_ty(w: &mut MemWriter, cx: &ctxt, ft: &ty::BareFnTy) {
357-
enc_purity(w, ft.purity);
357+
enc_fn_style(w, ft.fn_style);
358358
enc_abi(w, ft.abi);
359359
enc_fn_sig(w, cx, &ft.sig);
360360
}
361361

362362
fn enc_closure_ty(w: &mut MemWriter, cx: &ctxt, ft: &ty::ClosureTy) {
363363
enc_sigil(w, ft.sigil);
364-
enc_purity(w, ft.purity);
364+
enc_fn_style(w, ft.fn_style);
365365
enc_onceness(w, ft.onceness);
366366
enc_region(w, cx, ft.region);
367367
let bounds = ty::ParamBounds {builtin_bounds: ft.bounds,

src/librustc/middle/effect.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ enum UnsafeContext {
2929

3030
fn type_is_unsafe_function(ty: ty::t) -> bool {
3131
match ty::get(ty).sty {
32-
ty::ty_bare_fn(ref f) => f.purity == ast::UnsafeFn,
33-
ty::ty_closure(ref f) => f.purity == ast::UnsafeFn,
32+
ty::ty_bare_fn(ref f) => f.fn_style == ast::UnsafeFn,
33+
ty::ty_closure(ref f) => f.fn_style == ast::UnsafeFn,
3434
_ => false,
3535
}
3636
}
@@ -84,10 +84,10 @@ impl<'a> Visitor<()> for EffectCheckVisitor<'a> {
8484
block: &ast::Block, span: Span, node_id: ast::NodeId, _:()) {
8585

8686
let (is_item_fn, is_unsafe_fn) = match *fn_kind {
87-
visit::FkItemFn(_, _, purity, _) =>
88-
(true, purity == ast::UnsafeFn),
87+
visit::FkItemFn(_, _, fn_style, _) =>
88+
(true, fn_style == ast::UnsafeFn),
8989
visit::FkMethod(_, _, method) =>
90-
(true, method.purity == ast::UnsafeFn),
90+
(true, method.fn_style == ast::UnsafeFn),
9191
_ => (false, false),
9292
};
9393

src/librustc/middle/resolve.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1182,11 +1182,11 @@ impl<'a> Resolver<'a> {
11821182
(DefStatic(local_def(item.id), mutbl), sp, is_public);
11831183
parent
11841184
}
1185-
ItemFn(_, purity, _, _, _) => {
1185+
ItemFn(_, fn_style, _, _, _) => {
11861186
let (name_bindings, new_parent) =
11871187
self.add_child(ident, parent, ForbidDuplicateValues, sp);
11881188

1189-
let def = DefFn(local_def(item.id), purity);
1189+
let def = DefFn(local_def(item.id), fn_style);
11901190
name_bindings.define_value(def, sp, is_public);
11911191
new_parent
11921192
}
@@ -1313,7 +1313,7 @@ impl<'a> Resolver<'a> {
13131313
DefStaticMethod(local_def(method.id),
13141314
FromImpl(local_def(
13151315
item.id)),
1316-
method.purity)
1316+
method.fn_style)
13171317
}
13181318
_ => {
13191319
// Non-static methods become
@@ -1364,7 +1364,7 @@ impl<'a> Resolver<'a> {
13641364
// Static methods become `def_static_method`s.
13651365
DefStaticMethod(local_def(ty_m.id),
13661366
FromTrait(local_def(item.id)),
1367-
ty_m.purity)
1367+
ty_m.fn_style)
13681368
}
13691369
_ => {
13701370
// Non-static methods become `def_method`s.
@@ -1869,7 +1869,7 @@ impl<'a> Resolver<'a> {
18691869
DUMMY_SP);
18701870
let def = DefFn(
18711871
static_method_info.def_id,
1872-
static_method_info.purity);
1872+
static_method_info.fn_style);
18731873

18741874
method_name_bindings.define_value(
18751875
def, DUMMY_SP,

src/librustc/middle/trans/base.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1554,8 +1554,8 @@ impl<'a> Visitor<()> for TransItemVisitor<'a> {
15541554
pub fn trans_item(ccx: &CrateContext, item: &ast::Item) {
15551555
let _icx = push_ctxt("trans_item");
15561556
match item.node {
1557-
ast::ItemFn(decl, purity, _abi, ref generics, body) => {
1558-
if purity == ast::ExternFn {
1557+
ast::ItemFn(decl, fn_style, _abi, ref generics, body) => {
1558+
if fn_style == ast::ExternFn {
15591559
let llfndecl = get_item_val(ccx, item.id);
15601560
foreign::trans_rust_fn_with_foreign_abi(
15611561
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 {
18991899
}
19001900
}
19011901

1902-
ast::ItemFn(_, purity, _, _, _) => {
1903-
let llfn = if purity != ast::ExternFn {
1902+
ast::ItemFn(_, fn_style, _, _, _) => {
1903+
let llfn = if fn_style != ast::ExternFn {
19041904
register_fn(ccx, i.span, sym, i.id, ty)
19051905
} else {
19061906
foreign::register_rust_fn_with_foreign_abi(ccx,

src/librustc/middle/trans/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
615615

616616
let opt_def = cx.tcx().def_map.borrow().find_copy(&e.id);
617617
match opt_def {
618-
Some(ast::DefFn(def_id, _purity)) => {
618+
Some(ast::DefFn(def_id, _fn_style)) => {
619619
if !ast_util::is_local(def_id) {
620620
let ty = csearch::get_type(cx.tcx(), def_id).ty;
621621
(base::trans_external_path(cx, def_id, ty), true)

src/librustc/middle/trans/reflect.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ impl<'a> Reflector<'a> {
211211
// FIXME (#2594): fetch constants out of intrinsic
212212
// FIXME (#4809): visitor should break out bare fns from other fns
213213
ty::ty_closure(ref fty) => {
214-
let pureval = ast_purity_constant(fty.purity);
214+
let pureval = ast_fn_style_constant(fty.fn_style);
215215
let sigilval = ast_sigil_constant(fty.sigil);
216216
let retval = if ty::type_is_bot(fty.sig.output) {0u} else {1u};
217217
let extra = vec!(self.c_uint(pureval),
@@ -226,7 +226,7 @@ impl<'a> Reflector<'a> {
226226
// FIXME (#2594): fetch constants out of intrinsic:: for the
227227
// numbers.
228228
ty::ty_bare_fn(ref fty) => {
229-
let pureval = ast_purity_constant(fty.purity);
229+
let pureval = ast_fn_style_constant(fty.fn_style);
230230
let sigilval = 0u;
231231
let retval = if ty::type_is_bot(fty.sig.output) {0u} else {1u};
232232
let extra = vec!(self.c_uint(pureval),
@@ -399,10 +399,10 @@ pub fn ast_sigil_constant(sigil: ast::Sigil) -> uint {
399399
}
400400
}
401401

402-
pub fn ast_purity_constant(purity: ast::Purity) -> uint {
403-
match purity {
402+
pub fn ast_fn_style_constant(fn_style: ast::FnStyle) -> uint {
403+
match fn_style {
404404
ast::UnsafeFn => 1u,
405-
ast::ImpureFn => 2u,
405+
ast::NormalFn => 2u,
406406
ast::ExternFn => 3u
407407
}
408408
}

0 commit comments

Comments
 (0)