Skip to content

Commit 116897f

Browse files
committed
Remove ast::pure_fn and all concept of pure from the compiler
1 parent 45f588e commit 116897f

File tree

11 files changed

+21
-39
lines changed

11 files changed

+21
-39
lines changed

src/librustc/metadata/decoder.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,8 @@ enum Family {
100100
Const, // c
101101
Fn, // f
102102
UnsafeFn, // u
103-
PureFn, // p
104103
StaticMethod, // F
105104
UnsafeStaticMethod, // U
106-
PureStaticMethod, // P
107105
ForeignFn, // e
108106
Type, // y
109107
ForeignType, // T
@@ -125,10 +123,8 @@ fn item_family(item: ebml::Doc) -> Family {
125123
'c' => Const,
126124
'f' => Fn,
127125
'u' => UnsafeFn,
128-
'p' => PureFn,
129126
'F' => StaticMethod,
130127
'U' => UnsafeStaticMethod,
131-
'P' => PureStaticMethod,
132128
'e' => ForeignFn,
133129
'y' => Type,
134130
'T' => ForeignType,
@@ -325,7 +321,6 @@ fn item_to_def_like(item: ebml::Doc, did: ast::def_id, cnum: ast::crate_num)
325321
Struct => dl_def(ast::def_struct(did)),
326322
UnsafeFn => dl_def(ast::def_fn(did, ast::unsafe_fn)),
327323
Fn => dl_def(ast::def_fn(did, ast::impure_fn)),
328-
PureFn => dl_def(ast::def_fn(did, ast::pure_fn)),
329324
ForeignFn => dl_def(ast::def_fn(did, ast::extern_fn)),
330325
UnsafeStaticMethod => {
331326
let trait_did_opt = translated_parent_item_opt(cnum, item);
@@ -335,10 +330,6 @@ fn item_to_def_like(item: ebml::Doc, did: ast::def_id, cnum: ast::crate_num)
335330
let trait_did_opt = translated_parent_item_opt(cnum, item);
336331
dl_def(ast::def_static_method(did, trait_did_opt, ast::impure_fn))
337332
}
338-
PureStaticMethod => {
339-
let trait_did_opt = translated_parent_item_opt(cnum, item);
340-
dl_def(ast::def_static_method(did, trait_did_opt, ast::pure_fn))
341-
}
342333
Type | ForeignType => dl_def(ast::def_ty(did)),
343334
Mod => dl_def(ast::def_mod(did)),
344335
ForeignMod => dl_def(ast::def_foreign_mod(did)),
@@ -822,12 +813,11 @@ pub fn get_static_methods_if_impl(intr: @ident_interner,
822813
let impl_method_doc = lookup_item(impl_method_id.node, cdata.data);
823814
let family = item_family(impl_method_doc);
824815
match family {
825-
StaticMethod | UnsafeStaticMethod | PureStaticMethod => {
816+
StaticMethod | UnsafeStaticMethod => {
826817
let purity;
827818
match item_family(impl_method_doc) {
828819
StaticMethod => purity = ast::impure_fn,
829820
UnsafeStaticMethod => purity = ast::unsafe_fn,
830-
PureStaticMethod => purity = ast::pure_fn,
831821
_ => fail!()
832822
}
833823

@@ -934,10 +924,8 @@ fn item_family_to_str(fam: Family) -> ~str {
934924
Const => ~"const",
935925
Fn => ~"fn",
936926
UnsafeFn => ~"unsafe fn",
937-
PureFn => ~"pure fn",
938927
StaticMethod => ~"static method",
939928
UnsafeStaticMethod => ~"unsafe static method",
940-
PureStaticMethod => ~"pure static method",
941929
ForeignFn => ~"foreign fn",
942930
Type => ~"type",
943931
ForeignType => ~"foreign type",

src/librustc/metadata/encoder.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,6 @@ fn encode_info_for_method(ecx: &EncodeContext,
753753
fn purity_fn_family(p: purity) -> char {
754754
match p {
755755
unsafe_fn => 'u',
756-
pure_fn => 'p',
757756
impure_fn => 'f',
758757
extern_fn => 'e'
759758
}
@@ -762,7 +761,6 @@ fn purity_fn_family(p: purity) -> char {
762761
fn purity_static_method_family(p: purity) -> char {
763762
match p {
764763
unsafe_fn => 'U',
765-
pure_fn => 'P',
766764
impure_fn => 'F',
767765
_ => fail!("extern fn can't be static")
768766
}

src/librustc/metadata/tydecode.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,10 +439,9 @@ fn parse_hex(st: &mut PState) -> uint {
439439
fn parse_purity(c: char) -> purity {
440440
match c {
441441
'u' => unsafe_fn,
442-
'p' => pure_fn,
443442
'i' => impure_fn,
444443
'c' => extern_fn,
445-
_ => fail!("parse_purity: bad purity")
444+
_ => fail!("parse_purity: bad purity %c", c)
446445
}
447446
}
448447

src/librustc/metadata/tyencode.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,6 @@ fn enc_sigil(w: @io::Writer, sigil: Sigil) {
347347

348348
fn enc_purity(w: @io::Writer, p: purity) {
349349
match p {
350-
pure_fn => w.write_char('p'),
351350
impure_fn => w.write_char('i'),
352351
unsafe_fn => w.write_char('u'),
353352
extern_fn => w.write_char('c')

src/librustc/middle/trans/reflect.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,6 @@ pub fn ast_sigil_constant(sigil: ast::Sigil) -> uint {
398398

399399
pub fn ast_purity_constant(purity: ast::purity) -> uint {
400400
match purity {
401-
ast::pure_fn => 0u,
402401
ast::unsafe_fn => 1u,
403402
ast::impure_fn => 2u,
404403
ast::extern_fn => 3u

src/librustc/middle/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,7 @@ pub fn mk_ctor_fn(cx: ctxt, input_tys: &[ty::t], output: ty::t) -> t {
12531253
let input_args = input_tys.map(|t| *t);
12541254
mk_bare_fn(cx,
12551255
BareFnTy {
1256-
purity: ast::pure_fn,
1256+
purity: ast::impure_fn,
12571257
abis: AbiSet::Rust(),
12581258
sig: FnSig {
12591259
bound_lifetime_names: opt_vec::Empty,

src/librustc/middle/typeck/check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ pub fn blank_fn_ctxt(ccx: @mut CrateCtxt,
275275
err_count_on_creation: ccx.tcx.sess.err_count(),
276276
ret_ty: rty,
277277
indirect_ret_ty: None,
278-
ps: PurityState::function(ast::pure_fn, 0),
278+
ps: PurityState::function(ast::impure_fn, 0),
279279
region_lb: region_bnd,
280280
in_scope_regions: @Nil,
281281
fn_kind: Vanilla,

src/librustc/middle/typeck/infer/glb.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use middle::typeck::infer::fold_regions_in_sig;
2323
use middle::typeck::isr_alist;
2424
use syntax::ast;
2525
use syntax::ast::{Many, Once, extern_fn, impure_fn, m_const, m_imm, m_mutbl};
26-
use syntax::ast::{pure_fn, unsafe_fn};
26+
use syntax::ast::{unsafe_fn};
2727
use syntax::ast::{Onceness, purity};
2828
use syntax::abi::AbiSet;
2929
use syntax::codemap::span;
@@ -103,7 +103,6 @@ impl Combine for Glb {
103103

104104
fn purities(&self, a: purity, b: purity) -> cres<purity> {
105105
match (a, b) {
106-
(pure_fn, _) | (_, pure_fn) => Ok(pure_fn),
107106
(extern_fn, _) | (_, extern_fn) => Ok(extern_fn),
108107
(impure_fn, _) | (_, impure_fn) => Ok(impure_fn),
109108
(unsafe_fn, unsafe_fn) => Ok(unsafe_fn)

src/librustc/middle/typeck/infer/lub.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use extra::list;
2828
use syntax::abi::AbiSet;
2929
use syntax::ast;
3030
use syntax::ast::{Many, Once, extern_fn, m_const, impure_fn};
31-
use syntax::ast::{pure_fn, unsafe_fn};
31+
use syntax::ast::{unsafe_fn};
3232
use syntax::ast::{Onceness, purity};
3333
use syntax::codemap::span;
3434

@@ -92,8 +92,7 @@ impl Combine for Lub {
9292
match (a, b) {
9393
(unsafe_fn, _) | (_, unsafe_fn) => Ok(unsafe_fn),
9494
(impure_fn, _) | (_, impure_fn) => Ok(impure_fn),
95-
(extern_fn, _) | (_, extern_fn) => Ok(extern_fn),
96-
(pure_fn, pure_fn) => Ok(pure_fn)
95+
(extern_fn, extern_fn) => Ok(extern_fn),
9796
}
9897
}
9998

src/libsyntax/ast.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,6 @@ pub struct fn_decl {
845845

846846
#[deriving(Eq, Encodable, Decodable)]
847847
pub enum purity {
848-
pure_fn, // declared with "pure fn"
849848
unsafe_fn, // declared with "unsafe fn"
850849
impure_fn, // declared with "fn"
851850
extern_fn, // declared with "extern fn"
@@ -856,7 +855,6 @@ impl ToStr for purity {
856855
match *self {
857856
impure_fn => ~"impure",
858857
unsafe_fn => ~"unsafe",
859-
pure_fn => ~"pure",
860858
extern_fn => ~"extern"
861859
}
862860
}

src/libsyntax/print/pprust.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2188,26 +2188,29 @@ pub fn print_fn_header_info(s: @ps,
21882188
print_opt_sigil(s, opt_sigil);
21892189
}
21902190

2191-
pub fn opt_sigil_to_str(opt_p: Option<ast::Sigil>) -> ~str {
2191+
pub fn opt_sigil_to_str(opt_p: Option<ast::Sigil>) -> &'static str {
21922192
match opt_p {
2193-
None => ~"fn",
2194-
Some(p) => fmt!("fn%s", p.to_str())
2193+
None => "fn",
2194+
Some(p) => match p {
2195+
ast::BorrowedSigil => "fn&",
2196+
ast::OwnedSigil => "fn~",
2197+
ast::ManagedSigil => "fn@"
2198+
}
21952199
}
21962200
}
21972201

2198-
pub fn purity_to_str(p: ast::purity) -> ~str {
2202+
pub fn purity_to_str(p: ast::purity) -> &'static str {
21992203
match p {
2200-
ast::impure_fn => ~"impure",
2201-
ast::unsafe_fn => ~"unsafe",
2202-
ast::pure_fn => ~"pure",
2203-
ast::extern_fn => ~"extern"
2204+
ast::impure_fn => "impure",
2205+
ast::unsafe_fn => "unsafe",
2206+
ast::extern_fn => "extern"
22042207
}
22052208
}
22062209

2207-
pub fn onceness_to_str(o: ast::Onceness) -> ~str {
2210+
pub fn onceness_to_str(o: ast::Onceness) -> &'static str {
22082211
match o {
2209-
ast::Once => ~"once",
2210-
ast::Many => ~"many"
2212+
ast::Once => "once",
2213+
ast::Many => "many"
22112214
}
22122215
}
22132216

0 commit comments

Comments
 (0)