Remove ast::pure_fn
and all concept of pure
from the compiler
This commit is contained in:
parent
45f588e8fd
commit
116897fa6c
@ -100,10 +100,8 @@ enum Family {
|
||||
Const, // c
|
||||
Fn, // f
|
||||
UnsafeFn, // u
|
||||
PureFn, // p
|
||||
StaticMethod, // F
|
||||
UnsafeStaticMethod, // U
|
||||
PureStaticMethod, // P
|
||||
ForeignFn, // e
|
||||
Type, // y
|
||||
ForeignType, // T
|
||||
@ -125,10 +123,8 @@ fn item_family(item: ebml::Doc) -> Family {
|
||||
'c' => Const,
|
||||
'f' => Fn,
|
||||
'u' => UnsafeFn,
|
||||
'p' => PureFn,
|
||||
'F' => StaticMethod,
|
||||
'U' => UnsafeStaticMethod,
|
||||
'P' => PureStaticMethod,
|
||||
'e' => ForeignFn,
|
||||
'y' => Type,
|
||||
'T' => ForeignType,
|
||||
@ -325,7 +321,6 @@ fn item_to_def_like(item: ebml::Doc, did: ast::def_id, cnum: ast::crate_num)
|
||||
Struct => dl_def(ast::def_struct(did)),
|
||||
UnsafeFn => dl_def(ast::def_fn(did, ast::unsafe_fn)),
|
||||
Fn => dl_def(ast::def_fn(did, ast::impure_fn)),
|
||||
PureFn => dl_def(ast::def_fn(did, ast::pure_fn)),
|
||||
ForeignFn => dl_def(ast::def_fn(did, ast::extern_fn)),
|
||||
UnsafeStaticMethod => {
|
||||
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)
|
||||
let trait_did_opt = translated_parent_item_opt(cnum, item);
|
||||
dl_def(ast::def_static_method(did, trait_did_opt, ast::impure_fn))
|
||||
}
|
||||
PureStaticMethod => {
|
||||
let trait_did_opt = translated_parent_item_opt(cnum, item);
|
||||
dl_def(ast::def_static_method(did, trait_did_opt, ast::pure_fn))
|
||||
}
|
||||
Type | ForeignType => dl_def(ast::def_ty(did)),
|
||||
Mod => dl_def(ast::def_mod(did)),
|
||||
ForeignMod => dl_def(ast::def_foreign_mod(did)),
|
||||
@ -822,12 +813,11 @@ pub fn get_static_methods_if_impl(intr: @ident_interner,
|
||||
let impl_method_doc = lookup_item(impl_method_id.node, cdata.data);
|
||||
let family = item_family(impl_method_doc);
|
||||
match family {
|
||||
StaticMethod | UnsafeStaticMethod | PureStaticMethod => {
|
||||
StaticMethod | UnsafeStaticMethod => {
|
||||
let purity;
|
||||
match item_family(impl_method_doc) {
|
||||
StaticMethod => purity = ast::impure_fn,
|
||||
UnsafeStaticMethod => purity = ast::unsafe_fn,
|
||||
PureStaticMethod => purity = ast::pure_fn,
|
||||
_ => fail!()
|
||||
}
|
||||
|
||||
@ -934,10 +924,8 @@ fn item_family_to_str(fam: Family) -> ~str {
|
||||
Const => ~"const",
|
||||
Fn => ~"fn",
|
||||
UnsafeFn => ~"unsafe fn",
|
||||
PureFn => ~"pure fn",
|
||||
StaticMethod => ~"static method",
|
||||
UnsafeStaticMethod => ~"unsafe static method",
|
||||
PureStaticMethod => ~"pure static method",
|
||||
ForeignFn => ~"foreign fn",
|
||||
Type => ~"type",
|
||||
ForeignType => ~"foreign type",
|
||||
|
@ -753,7 +753,6 @@ fn encode_info_for_method(ecx: &EncodeContext,
|
||||
fn purity_fn_family(p: purity) -> char {
|
||||
match p {
|
||||
unsafe_fn => 'u',
|
||||
pure_fn => 'p',
|
||||
impure_fn => 'f',
|
||||
extern_fn => 'e'
|
||||
}
|
||||
@ -762,7 +761,6 @@ fn purity_fn_family(p: purity) -> char {
|
||||
fn purity_static_method_family(p: purity) -> char {
|
||||
match p {
|
||||
unsafe_fn => 'U',
|
||||
pure_fn => 'P',
|
||||
impure_fn => 'F',
|
||||
_ => fail!("extern fn can't be static")
|
||||
}
|
||||
|
@ -439,10 +439,9 @@ fn parse_hex(st: &mut PState) -> uint {
|
||||
fn parse_purity(c: char) -> purity {
|
||||
match c {
|
||||
'u' => unsafe_fn,
|
||||
'p' => pure_fn,
|
||||
'i' => impure_fn,
|
||||
'c' => extern_fn,
|
||||
_ => fail!("parse_purity: bad purity")
|
||||
_ => fail!("parse_purity: bad purity %c", c)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -347,7 +347,6 @@ fn enc_sigil(w: @io::Writer, sigil: Sigil) {
|
||||
|
||||
fn enc_purity(w: @io::Writer, p: purity) {
|
||||
match p {
|
||||
pure_fn => w.write_char('p'),
|
||||
impure_fn => w.write_char('i'),
|
||||
unsafe_fn => w.write_char('u'),
|
||||
extern_fn => w.write_char('c')
|
||||
|
@ -398,7 +398,6 @@ pub fn ast_sigil_constant(sigil: ast::Sigil) -> uint {
|
||||
|
||||
pub fn ast_purity_constant(purity: ast::purity) -> uint {
|
||||
match purity {
|
||||
ast::pure_fn => 0u,
|
||||
ast::unsafe_fn => 1u,
|
||||
ast::impure_fn => 2u,
|
||||
ast::extern_fn => 3u
|
||||
|
@ -1253,7 +1253,7 @@ pub fn mk_ctor_fn(cx: ctxt, input_tys: &[ty::t], output: ty::t) -> t {
|
||||
let input_args = input_tys.map(|t| *t);
|
||||
mk_bare_fn(cx,
|
||||
BareFnTy {
|
||||
purity: ast::pure_fn,
|
||||
purity: ast::impure_fn,
|
||||
abis: AbiSet::Rust(),
|
||||
sig: FnSig {
|
||||
bound_lifetime_names: opt_vec::Empty,
|
||||
|
@ -275,7 +275,7 @@ pub fn blank_fn_ctxt(ccx: @mut CrateCtxt,
|
||||
err_count_on_creation: ccx.tcx.sess.err_count(),
|
||||
ret_ty: rty,
|
||||
indirect_ret_ty: None,
|
||||
ps: PurityState::function(ast::pure_fn, 0),
|
||||
ps: PurityState::function(ast::impure_fn, 0),
|
||||
region_lb: region_bnd,
|
||||
in_scope_regions: @Nil,
|
||||
fn_kind: Vanilla,
|
||||
|
@ -23,7 +23,7 @@ use middle::typeck::infer::fold_regions_in_sig;
|
||||
use middle::typeck::isr_alist;
|
||||
use syntax::ast;
|
||||
use syntax::ast::{Many, Once, extern_fn, impure_fn, m_const, m_imm, m_mutbl};
|
||||
use syntax::ast::{pure_fn, unsafe_fn};
|
||||
use syntax::ast::{unsafe_fn};
|
||||
use syntax::ast::{Onceness, purity};
|
||||
use syntax::abi::AbiSet;
|
||||
use syntax::codemap::span;
|
||||
@ -103,7 +103,6 @@ impl Combine for Glb {
|
||||
|
||||
fn purities(&self, a: purity, b: purity) -> cres<purity> {
|
||||
match (a, b) {
|
||||
(pure_fn, _) | (_, pure_fn) => Ok(pure_fn),
|
||||
(extern_fn, _) | (_, extern_fn) => Ok(extern_fn),
|
||||
(impure_fn, _) | (_, impure_fn) => Ok(impure_fn),
|
||||
(unsafe_fn, unsafe_fn) => Ok(unsafe_fn)
|
||||
|
@ -28,7 +28,7 @@ use extra::list;
|
||||
use syntax::abi::AbiSet;
|
||||
use syntax::ast;
|
||||
use syntax::ast::{Many, Once, extern_fn, m_const, impure_fn};
|
||||
use syntax::ast::{pure_fn, unsafe_fn};
|
||||
use syntax::ast::{unsafe_fn};
|
||||
use syntax::ast::{Onceness, purity};
|
||||
use syntax::codemap::span;
|
||||
|
||||
@ -92,8 +92,7 @@ impl Combine for Lub {
|
||||
match (a, b) {
|
||||
(unsafe_fn, _) | (_, unsafe_fn) => Ok(unsafe_fn),
|
||||
(impure_fn, _) | (_, impure_fn) => Ok(impure_fn),
|
||||
(extern_fn, _) | (_, extern_fn) => Ok(extern_fn),
|
||||
(pure_fn, pure_fn) => Ok(pure_fn)
|
||||
(extern_fn, extern_fn) => Ok(extern_fn),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -845,7 +845,6 @@ pub struct fn_decl {
|
||||
|
||||
#[deriving(Eq, Encodable, Decodable)]
|
||||
pub enum purity {
|
||||
pure_fn, // declared with "pure fn"
|
||||
unsafe_fn, // declared with "unsafe fn"
|
||||
impure_fn, // declared with "fn"
|
||||
extern_fn, // declared with "extern fn"
|
||||
@ -856,7 +855,6 @@ impl ToStr for purity {
|
||||
match *self {
|
||||
impure_fn => ~"impure",
|
||||
unsafe_fn => ~"unsafe",
|
||||
pure_fn => ~"pure",
|
||||
extern_fn => ~"extern"
|
||||
}
|
||||
}
|
||||
|
@ -2188,26 +2188,29 @@ pub fn print_fn_header_info(s: @ps,
|
||||
print_opt_sigil(s, opt_sigil);
|
||||
}
|
||||
|
||||
pub fn opt_sigil_to_str(opt_p: Option<ast::Sigil>) -> ~str {
|
||||
pub fn opt_sigil_to_str(opt_p: Option<ast::Sigil>) -> &'static str {
|
||||
match opt_p {
|
||||
None => ~"fn",
|
||||
Some(p) => fmt!("fn%s", p.to_str())
|
||||
None => "fn",
|
||||
Some(p) => match p {
|
||||
ast::BorrowedSigil => "fn&",
|
||||
ast::OwnedSigil => "fn~",
|
||||
ast::ManagedSigil => "fn@"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn purity_to_str(p: ast::purity) -> ~str {
|
||||
pub fn purity_to_str(p: ast::purity) -> &'static str {
|
||||
match p {
|
||||
ast::impure_fn => ~"impure",
|
||||
ast::unsafe_fn => ~"unsafe",
|
||||
ast::pure_fn => ~"pure",
|
||||
ast::extern_fn => ~"extern"
|
||||
ast::impure_fn => "impure",
|
||||
ast::unsafe_fn => "unsafe",
|
||||
ast::extern_fn => "extern"
|
||||
}
|
||||
}
|
||||
|
||||
pub fn onceness_to_str(o: ast::Onceness) -> ~str {
|
||||
pub fn onceness_to_str(o: ast::Onceness) -> &'static str {
|
||||
match o {
|
||||
ast::Once => ~"once",
|
||||
ast::Many => ~"many"
|
||||
ast::Once => "once",
|
||||
ast::Many => "many"
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user