Const, // c
Fn, // f
UnsafeFn, // u
- PureFn, // p
StaticMethod, // F
UnsafeStaticMethod, // U
- PureStaticMethod, // P
ForeignFn, // e
Type, // y
ForeignType, // T
'c' => Const,
'f' => Fn,
'u' => UnsafeFn,
- 'p' => PureFn,
'F' => StaticMethod,
'U' => UnsafeStaticMethod,
- 'P' => PureStaticMethod,
'e' => ForeignFn,
'y' => Type,
'T' => ForeignType,
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);
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)),
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!()
}
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",
fn purity_fn_family(p: purity) -> char {
match p {
unsafe_fn => 'u',
- pure_fn => 'p',
impure_fn => 'f',
extern_fn => 'e'
}
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")
}
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)
}
}
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')
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
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,
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,
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;
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)
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;
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),
}
}
#[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"
match *self {
impure_fn => ~"impure",
unsafe_fn => ~"unsafe",
- pure_fn => ~"pure",
extern_fn => ~"extern"
}
}
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"
}
}