use rustc::metadata::csearch;
use rustc::metadata::decoder;
+use std::local_data;
+use std::strbuf::StrBuf;
use std;
use core;
use doctree;
use visit_ast;
-use std::local_data;
pub trait Clean<T> {
fn clean(&self) -> T;
let name = if self.name.is_some() {
self.name.unwrap().clean()
} else {
- ~""
+ "".to_owned()
};
let mut foreigns = Vec::new();
for subforeigns in self.foreigns.clean().move_iter() {
pub struct Method {
pub generics: Generics,
pub self_: SelfTy,
- pub purity: ast::Purity,
+ pub fn_style: ast::FnStyle,
pub decl: FnDecl,
}
inner: MethodItem(Method {
generics: self.generics.clean(),
self_: self.explicit_self.clean(),
- purity: self.purity.clone(),
+ fn_style: self.fn_style.clone(),
decl: decl,
}),
}
#[deriving(Clone, Encodable, Decodable)]
pub struct TyMethod {
- pub purity: ast::Purity,
+ pub fn_style: ast::FnStyle,
pub decl: FnDecl,
pub generics: Generics,
pub self_: SelfTy,
id: self.id,
visibility: None,
inner: TyMethodItem(TyMethod {
- purity: self.purity.clone(),
+ fn_style: self.fn_style.clone(),
decl: decl,
self_: self.explicit_self.clean(),
generics: self.generics.clean(),
pub struct Function {
pub decl: FnDecl,
pub generics: Generics,
- pub purity: ast::Purity,
+ pub fn_style: ast::FnStyle,
}
impl Clean<Item> for doctree::Function {
inner: FunctionItem(Function {
decl: self.decl.clean(),
generics: self.generics.clean(),
- purity: self.purity,
+ fn_style: self.fn_style,
}),
}
}
#[deriving(Clone, Encodable, Decodable)]
pub struct ClosureDecl {
- pub sigil: ast::Sigil,
- pub region: Option<Lifetime>,
pub lifetimes: Vec<Lifetime>,
pub decl: FnDecl,
pub onceness: ast::Onceness,
- pub purity: ast::Purity,
+ pub fn_style: ast::FnStyle,
pub bounds: Vec<TyParamBound>,
}
impl Clean<ClosureDecl> for ast::ClosureTy {
fn clean(&self) -> ClosureDecl {
ClosureDecl {
- sigil: self.sigil,
- region: self.region.clean(),
lifetimes: self.lifetimes.clean().move_iter().collect(),
decl: self.decl.clean(),
onceness: self.onceness,
- purity: self.purity,
+ fn_style: self.fn_style,
bounds: match self.bounds {
Some(ref x) => x.clean().move_iter().collect(),
None => Vec::new()
Self(ast::NodeId),
/// Primitives are just the fixed-size numeric types (plus int/uint/float), and char.
Primitive(ast::PrimTy),
- Closure(~ClosureDecl),
+ Closure(~ClosureDecl, Option<Lifetime>),
+ Proc(~ClosureDecl),
/// extern "ABI" fn
BareFunction(~BareFunctionDecl),
Tuple(Vec<Type> ),
tpbs.clean().map(|x| x.move_iter().collect()),
id)
}
- TyClosure(ref c) => Closure(~c.clean()),
+ TyClosure(ref c, region) => Closure(~c.clean(), region.clean()),
+ TyProc(ref c) => Proc(~c.clean()),
TyBareFn(ref barefn) => BareFunction(~barefn.clean()),
TyBot => Bottom,
ref x => fail!("Unimplemented type {:?}", x),
fn path_to_str(p: &ast::Path) -> ~str {
use syntax::parse::token;
- let mut s = ~"";
+ let mut s = StrBuf::new();
let mut first = true;
for i in p.segments.iter().map(|x| token::get_ident(x.identifier)) {
if !first || p.global {
}
s.push_str(i.get());
}
- s
+ s.into_owned()
}
impl Clean<~str> for ast::Ident {
#[deriving(Clone, Encodable, Decodable)]
pub struct BareFunctionDecl {
- pub purity: ast::Purity,
+ pub fn_style: ast::FnStyle,
pub generics: Generics,
pub decl: FnDecl,
pub abi: ~str,
impl Clean<BareFunctionDecl> for ast::BareFnTy {
fn clean(&self) -> BareFunctionDecl {
BareFunctionDecl {
- purity: self.purity,
+ fn_style: self.fn_style,
generics: Generics {
lifetimes: self.lifetimes.clean().move_iter().collect(),
type_params: Vec::new(),
},
decl: self.decl.clean(),
- abi: self.abis.to_str(),
+ abi: self.abi.to_str(),
}
}
}
ForeignFunctionItem(Function {
decl: decl.clean(),
generics: generics.clean(),
- purity: ast::ExternFn,
+ fn_style: ast::ExternFn,
})
}
ast::ForeignItemStatic(ref ty, mutbl) => {
ForeignStaticItem(Static {
type_: ty.clean(),
mutability: if mutbl {Mutable} else {Immutable},
- expr: ~"",
+ expr: "".to_owned(),
})
}
};
let cm = local_data::get(super::ctxtkey, |x| x.unwrap().clone()).sess().codemap().clone();
let sn = match cm.span_to_snippet(*self) {
Some(x) => x,
- None => ~""
+ None => "".to_owned()
};
debug!("got snippet {}", sn);
sn
match lit.node {
ast::LitStr(ref st, _) => st.get().to_owned(),
ast::LitBinary(ref data) => format!("{:?}", data.as_slice()),
- ast::LitChar(c) => ~"'" + std::char::from_u32(c).unwrap().to_str() + "'",
+ ast::LitChar(c) => "'".to_owned() + std::char::from_u32(c).unwrap().to_str() + "'",
ast::LitInt(i, _t) => i.to_str(),
ast::LitUint(u, _t) => u.to_str(),
ast::LitIntUnsuffixed(i) => i.to_str(),
ast::LitFloat(ref f, _t) => f.get().to_str(),
ast::LitFloatUnsuffixed(ref f) => f.get().to_str(),
ast::LitBool(b) => b.to_str(),
- ast::LitNil => ~"",
+ ast::LitNil => "".to_owned(),
}
}
debug!("Trying to get a name from pattern: {:?}", p);
match p.node {
- PatWild => ~"_",
- PatWildMulti => ~"..",
+ PatWild => "_".to_owned(),
+ PatWildMulti => "..".to_owned(),
PatIdent(_, ref p, _) => path_to_str(p),
PatEnum(ref p, _) => path_to_str(p),
PatStruct(..) => fail!("tried to get argument name from pat_struct, \
which is not allowed in function arguments"),
- PatTup(..) => ~"(tuple arg NYI)",
+ PatTup(..) => "(tuple arg NYI)".to_owned(),
PatUniq(p) => name_from_pat(p),
PatRegion(p) => name_from_pat(p),
PatLit(..) => {
warn!("tried to get argument name from PatLit, \
which is silly in function arguments");
- ~"()"
+ "()".to_owned()
},
PatRange(..) => fail!("tried to get argument name from PatRange, \
which is not allowed in function arguments"),