librustc: Remove pure from libsyntax and librustc.

This commit is contained in:
Patrick Walton 2013-03-22 11:09:13 -07:00
parent ec59ce5796
commit e7c60c141b
31 changed files with 251 additions and 252 deletions

View File

@ -20,7 +20,7 @@ use core::util;
use core::vec;
use core::hashmap::linear::LinearSet;
pure fn not_win32(os: session::os) -> bool {
fn not_win32(os: session::os) -> bool {
match os {
session::os_win32 => false,
_ => true

View File

@ -872,7 +872,7 @@ pub fn get_item_attrs(cdata: cmd,
}
}
pure fn struct_field_family_to_visibility(family: Family) -> ast::visibility {
fn struct_field_family_to_visibility(family: Family) -> ast::visibility {
match family {
PublicField => ast::public,
PrivateField => ast::private,

View File

@ -444,7 +444,7 @@ pub impl LoanKind {
/// Creates and returns a new root_map
impl to_bytes::IterBytes for root_map_key {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_2(&self.id, &self.derefs, lsb0, f);
}
}

View File

@ -534,7 +534,7 @@ fn check_item_while_true(cx: ty::ctxt, it: @ast::item) {
}
fn check_item_type_limits(cx: ty::ctxt, it: @ast::item) {
pure fn is_valid<T:cmp::Ord>(binop: ast::binop, v: T,
fn is_valid<T:cmp::Ord>(binop: ast::binop, v: T,
min: T, max: T) -> bool {
match binop {
ast::lt => v <= max,
@ -546,7 +546,7 @@ fn check_item_type_limits(cx: ty::ctxt, it: @ast::item) {
}
}
pure fn rev_binop(binop: ast::binop) -> ast::binop {
fn rev_binop(binop: ast::binop) -> ast::binop {
match binop {
ast::lt => ast::gt,
ast::le => ast::ge,
@ -556,7 +556,7 @@ fn check_item_type_limits(cx: ty::ctxt, it: @ast::item) {
}
}
pure fn int_ty_range(int_ty: ast::int_ty) -> (i64, i64) {
fn int_ty_range(int_ty: ast::int_ty) -> (i64, i64) {
match int_ty {
ast::ty_i => (int::min_value as i64, int::max_value as i64),
ast::ty_char => (u32::min_value as i64, u32::max_value as i64),
@ -567,7 +567,7 @@ fn check_item_type_limits(cx: ty::ctxt, it: @ast::item) {
}
}
pure fn uint_ty_range(uint_ty: ast::uint_ty) -> (u64, u64) {
fn uint_ty_range(uint_ty: ast::uint_ty) -> (u64, u64) {
match uint_ty {
ast::ty_u => (uint::min_value as u64, uint::max_value as u64),
ast::ty_u8 => (u8::min_value as u64, u8::max_value as u64),
@ -622,7 +622,7 @@ fn check_item_type_limits(cx: ty::ctxt, it: @ast::item) {
}
}
pure fn is_comparison(binop: ast::binop) -> bool {
fn is_comparison(binop: ast::binop) -> bool {
match binop {
ast::eq | ast::lt | ast::le |
ast::ne | ast::ge | ast::gt => true,

View File

@ -141,13 +141,13 @@ struct Variable(uint);
struct LiveNode(uint);
impl cmp::Eq for Variable {
pure fn eq(&self, other: &Variable) -> bool { *(*self) == *(*other) }
pure fn ne(&self, other: &Variable) -> bool { *(*self) != *(*other) }
fn eq(&self, other: &Variable) -> bool { *(*self) == *(*other) }
fn ne(&self, other: &Variable) -> bool { *(*self) != *(*other) }
}
impl cmp::Eq for LiveNode {
pure fn eq(&self, other: &LiveNode) -> bool { *(*self) == *(*other) }
pure fn ne(&self, other: &LiveNode) -> bool { *(*self) != *(*other) }
fn eq(&self, other: &LiveNode) -> bool { *(*self) == *(*other) }
fn ne(&self, other: &LiveNode) -> bool { *(*self) != *(*other) }
}
enum LiveNodeKind {
@ -158,7 +158,7 @@ enum LiveNodeKind {
}
impl cmp::Eq for LiveNodeKind {
pure fn eq(&self, other: &LiveNodeKind) -> bool {
fn eq(&self, other: &LiveNodeKind) -> bool {
match (*self) {
FreeVarNode(e0a) => {
match (*other) {
@ -186,7 +186,7 @@ impl cmp::Eq for LiveNodeKind {
}
}
}
pure fn ne(&self, other: &LiveNodeKind) -> bool { !(*self).eq(other) }
fn ne(&self, other: &LiveNodeKind) -> bool { !(*self).eq(other) }
}
fn live_node_kind_to_str(lnk: LiveNodeKind, cx: ty::ctxt) -> ~str {
@ -224,11 +224,11 @@ pub fn check_crate(tcx: ty::ctxt,
}
impl to_str::ToStr for LiveNode {
pure fn to_str(&self) -> ~str { fmt!("ln(%u)", **self) }
fn to_str(&self) -> ~str { fmt!("ln(%u)", **self) }
}
impl to_str::ToStr for Variable {
pure fn to_str(&self) -> ~str { fmt!("v(%u)", **self) }
fn to_str(&self) -> ~str { fmt!("v(%u)", **self) }
}
// ______________________________________________________________________
@ -254,7 +254,7 @@ impl to_str::ToStr for Variable {
// assignment. And so forth.
pub impl LiveNode {
pure fn is_valid(&self) -> bool { **self != uint::max_value }
fn is_valid(&self) -> bool { **self != uint::max_value }
}
fn invalid_node() -> LiveNode { LiveNode(uint::max_value) }

View File

@ -305,7 +305,7 @@ pub struct mem_categorization_ctxt {
}
impl ToStr for MutabilityCategory {
pure fn to_str(&self) -> ~str {
fn to_str(&self) -> ~str {
fmt!("%?", *self)
}
}

View File

@ -151,7 +151,7 @@ pub enum NamespaceResult {
}
pub impl NamespaceResult {
pure fn is_unknown(&self) -> bool {
fn is_unknown(&self) -> bool {
match *self {
UnknownResult => true,
_ => false

View File

@ -41,10 +41,10 @@ enum x86_64_reg_class {
}
impl cmp::Eq for x86_64_reg_class {
pure fn eq(&self, other: &x86_64_reg_class) -> bool {
fn eq(&self, other: &x86_64_reg_class) -> bool {
((*self) as uint) == ((*other) as uint)
}
pure fn ne(&self, other: &x86_64_reg_class) -> bool { !(*self).eq(other) }
fn ne(&self, other: &x86_64_reg_class) -> bool { !(*self).eq(other) }
}
fn is_sse(++c: x86_64_reg_class) -> bool {

View File

@ -678,9 +678,9 @@ pub fn block_parent(cx: block) -> block {
// Accessors
pub impl block_ {
pure fn ccx(@mut self) -> @CrateContext { *self.fcx.ccx }
pure fn tcx(@mut self) -> ty::ctxt { self.fcx.ccx.tcx }
pure fn sess(@mut self) -> Session { self.fcx.ccx.sess }
fn ccx(@mut self) -> @CrateContext { *self.fcx.ccx }
fn tcx(@mut self) -> ty::ctxt { self.fcx.ccx.tcx }
fn sess(@mut self) -> Session { self.fcx.ccx.sess }
fn node_id_to_str(@mut self, id: ast::node_id) -> ~str {
ast_map::node_id_to_str(self.tcx().items, id, self.sess().intr())
@ -1290,7 +1290,7 @@ pub struct mono_id_ {
pub type mono_id = @mono_id_;
impl to_bytes::IterBytes for mono_param_id {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self {
mono_precise(t, ref mids) =>
to_bytes::iter_bytes_3(&0u8, &ty::type_id(t), mids, lsb0, f),
@ -1304,7 +1304,7 @@ impl to_bytes::IterBytes for mono_param_id {
}
impl to_bytes::IterBytes for mono_id_ {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_2(&self.def, &self.params, lsb0, f);
}
}

View File

@ -158,14 +158,14 @@ pub impl DatumMode {
}
impl cmp::Eq for DatumMode {
pure fn eq(&self, other: &DatumMode) -> bool {
fn eq(&self, other: &DatumMode) -> bool {
(*self) as uint == (*other as uint)
}
pure fn ne(&self, other: &DatumMode) -> bool { !(*self).eq(other) }
fn ne(&self, other: &DatumMode) -> bool { !(*self).eq(other) }
}
impl to_bytes::IterBytes for DatumMode {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
(*self as uint).iter_bytes(lsb0, f)
}
}

View File

@ -175,7 +175,7 @@ pub impl Dest {
}
impl cmp::Eq for Dest {
pure fn eq(&self, other: &Dest) -> bool {
fn eq(&self, other: &Dest) -> bool {
match ((*self), (*other)) {
(SaveIn(e0a), SaveIn(e0b)) => e0a == e0b,
(Ignore, Ignore) => true,
@ -183,7 +183,7 @@ impl cmp::Eq for Dest {
(Ignore, _) => false,
}
}
pure fn ne(&self, other: &Dest) -> bool { !(*self).eq(other) }
fn ne(&self, other: &Dest) -> bool { !(*self).eq(other) }
}
fn drop_and_cancel_clean(bcx: block, dat: Datum) -> block {
@ -1695,7 +1695,7 @@ pub enum cast_kind {
}
impl cmp::Eq for cast_kind {
pure fn eq(&self, other: &cast_kind) -> bool {
fn eq(&self, other: &cast_kind) -> bool {
match ((*self), (*other)) {
(cast_pointer, cast_pointer) => true,
(cast_integral, cast_integral) => true,
@ -1709,7 +1709,7 @@ impl cmp::Eq for cast_kind {
(cast_other, _) => false,
}
}
pure fn ne(&self, other: &cast_kind) -> bool { !(*self).eq(other) }
fn ne(&self, other: &cast_kind) -> bool { !(*self).eq(other) }
}
pub fn cast_type_kind(t: ty::t) -> cast_kind {

View File

@ -218,8 +218,8 @@ pub fn simplified_glue_type(tcx: ty::ctxt, field: uint, t: ty::t) -> ty::t {
return t;
}
pub pure fn cast_glue(ccx: @CrateContext, ti: @mut tydesc_info, v: ValueRef)
-> ValueRef {
pub fn cast_glue(ccx: @CrateContext, ti: @mut tydesc_info, v: ValueRef)
-> ValueRef {
unsafe {
let llfnty = type_of_glue_fn(ccx, ti.ty);
llvm::LLVMConstPointerCast(v, T_ptr(llfnty))

View File

@ -121,7 +121,7 @@ pub struct creader_cache_key {
type creader_cache = HashMap<creader_cache_key, t>;
impl to_bytes::IterBytes for creader_cache_key {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_3(&self.cnum, &self.pos, &self.len, lsb0, f);
}
}
@ -135,18 +135,18 @@ struct intern_key {
// implementation will not recurse through sty and you will get stack
// exhaustion.
impl cmp::Eq for intern_key {
pure fn eq(&self, other: &intern_key) -> bool {
fn eq(&self, other: &intern_key) -> bool {
unsafe {
*self.sty == *other.sty && self.o_def_id == other.o_def_id
}
}
pure fn ne(&self, other: &intern_key) -> bool {
fn ne(&self, other: &intern_key) -> bool {
!self.eq(other)
}
}
impl to_bytes::IterBytes for intern_key {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
unsafe {
to_bytes::iter_bytes_2(&*self.sty, &self.o_def_id, lsb0, f);
}
@ -165,7 +165,7 @@ pub type opt_region_variance = Option<region_variance>;
pub enum region_variance { rv_covariant, rv_invariant, rv_contravariant }
impl cmp::Eq for region_variance {
pure fn eq(&self, other: &region_variance) -> bool {
fn eq(&self, other: &region_variance) -> bool {
match ((*self), (*other)) {
(rv_covariant, rv_covariant) => true,
(rv_invariant, rv_invariant) => true,
@ -175,7 +175,7 @@ impl cmp::Eq for region_variance {
(rv_contravariant, _) => false
}
}
pure fn ne(&self, other: &region_variance) -> bool { !(*self).eq(other) }
fn ne(&self, other: &region_variance) -> bool { !(*self).eq(other) }
}
#[auto_encode]
@ -334,7 +334,7 @@ struct t_box_ {
enum t_opaque {}
pub type t = *t_opaque;
pub pure fn get(t: t) -> t_box {
pub fn get(t: t) -> t_box {
unsafe {
let t2 = cast::reinterpret_cast::<t, t_box>(&t);
let t3 = t2;
@ -343,21 +343,21 @@ pub pure fn get(t: t) -> t_box {
}
}
pub pure fn tbox_has_flag(tb: t_box, flag: tbox_flag) -> bool {
pub fn tbox_has_flag(tb: t_box, flag: tbox_flag) -> bool {
(tb.flags & (flag as uint)) != 0u
}
pub pure fn type_has_params(t: t) -> bool {
pub fn type_has_params(t: t) -> bool {
tbox_has_flag(get(t), has_params)
}
pub pure fn type_has_self(t: t) -> bool { tbox_has_flag(get(t), has_self) }
pub pure fn type_needs_infer(t: t) -> bool {
pub fn type_has_self(t: t) -> bool { tbox_has_flag(get(t), has_self) }
pub fn type_needs_infer(t: t) -> bool {
tbox_has_flag(get(t), needs_infer)
}
pub pure fn type_has_regions(t: t) -> bool {
pub fn type_has_regions(t: t) -> bool {
tbox_has_flag(get(t), has_regions)
}
pub pure fn type_def_id(t: t) -> Option<ast::def_id> { get(t).o_def_id }
pub pure fn type_id(t: t) -> uint { get(t).id }
pub fn type_def_id(t: t) -> Option<ast::def_id> { get(t).o_def_id }
pub fn type_id(t: t) -> uint { get(t).id }
#[deriving(Eq)]
pub struct BareFnTy {
@ -388,13 +388,13 @@ pub struct FnSig {
}
impl to_bytes::IterBytes for BareFnTy {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_3(&self.purity, &self.abi, &self.sig, lsb0, f)
}
}
impl to_bytes::IterBytes for ClosureTy {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_5(&self.purity, &self.sigil, &self.onceness,
&self.region, &self.sig, lsb0, f)
}
@ -407,7 +407,7 @@ pub struct param_ty {
}
impl to_bytes::IterBytes for param_ty {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_2(&self.idx, &self.def_id, lsb0, f)
}
}
@ -616,7 +616,7 @@ pub enum InferTy {
}
impl to_bytes::IterBytes for InferTy {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self {
TyVar(ref tv) => to_bytes::iter_bytes_2(&0u8, tv, lsb0, f),
IntVar(ref iv) => to_bytes::iter_bytes_2(&1u8, iv, lsb0, f),
@ -633,7 +633,7 @@ pub enum InferRegion {
}
impl to_bytes::IterBytes for InferRegion {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self {
ReVar(ref rv) => to_bytes::iter_bytes_2(&0u8, rv, lsb0, f),
ReSkolemized(ref v, _) => to_bytes::iter_bytes_2(&1u8, v, lsb0, f)
@ -642,7 +642,7 @@ impl to_bytes::IterBytes for InferRegion {
}
impl cmp::Eq for InferRegion {
pure fn eq(&self, other: &InferRegion) -> bool {
fn eq(&self, other: &InferRegion) -> bool {
match ((*self), *other) {
(ReVar(rva), ReVar(rvb)) => {
rva == rvb
@ -653,13 +653,13 @@ impl cmp::Eq for InferRegion {
_ => false
}
}
pure fn ne(&self, other: &InferRegion) -> bool {
fn ne(&self, other: &InferRegion) -> bool {
!((*self) == (*other))
}
}
impl to_bytes::IterBytes for param_bound {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self {
bound_copy => 0u8.iter_bytes(lsb0, f),
bound_durable => 1u8.iter_bytes(lsb0, f),
@ -672,50 +672,50 @@ impl to_bytes::IterBytes for param_bound {
}
pub trait Vid {
pure fn to_uint(&self) -> uint;
fn to_uint(&self) -> uint;
}
impl Vid for TyVid {
pure fn to_uint(&self) -> uint { **self }
fn to_uint(&self) -> uint { **self }
}
impl ToStr for TyVid {
pure fn to_str(&self) -> ~str { fmt!("<V%u>", self.to_uint()) }
fn to_str(&self) -> ~str { fmt!("<V%u>", self.to_uint()) }
}
impl Vid for IntVid {
pure fn to_uint(&self) -> uint { **self }
fn to_uint(&self) -> uint { **self }
}
impl ToStr for IntVid {
pure fn to_str(&self) -> ~str { fmt!("<VI%u>", self.to_uint()) }
fn to_str(&self) -> ~str { fmt!("<VI%u>", self.to_uint()) }
}
impl Vid for FloatVid {
pure fn to_uint(&self) -> uint { **self }
fn to_uint(&self) -> uint { **self }
}
impl ToStr for FloatVid {
pure fn to_str(&self) -> ~str { fmt!("<VF%u>", self.to_uint()) }
fn to_str(&self) -> ~str { fmt!("<VF%u>", self.to_uint()) }
}
impl Vid for RegionVid {
pure fn to_uint(&self) -> uint { self.id }
fn to_uint(&self) -> uint { self.id }
}
impl ToStr for RegionVid {
pure fn to_str(&self) -> ~str { fmt!("%?", self.id) }
fn to_str(&self) -> ~str { fmt!("%?", self.id) }
}
impl ToStr for FnSig {
pure fn to_str(&self) -> ~str {
fn to_str(&self) -> ~str {
// grr, without tcx not much we can do.
return ~"(...)";
}
}
impl ToStr for InferTy {
pure fn to_str(&self) -> ~str {
fn to_str(&self) -> ~str {
match *self {
TyVar(ref v) => v.to_str(),
IntVar(ref v) => v.to_str(),
@ -725,7 +725,7 @@ impl ToStr for InferTy {
}
impl ToStr for IntVarValue {
pure fn to_str(&self) -> ~str {
fn to_str(&self) -> ~str {
match *self {
IntType(ref v) => v.to_str(),
UintType(ref v) => v.to_str(),
@ -734,25 +734,25 @@ impl ToStr for IntVarValue {
}
impl to_bytes::IterBytes for TyVid {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
self.to_uint().iter_bytes(lsb0, f)
}
}
impl to_bytes::IterBytes for IntVid {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
self.to_uint().iter_bytes(lsb0, f)
}
}
impl to_bytes::IterBytes for FloatVid {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
self.to_uint().iter_bytes(lsb0, f)
}
}
impl to_bytes::IterBytes for RegionVid {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
self.to_uint().iter_bytes(lsb0, f)
}
}
@ -1112,7 +1112,7 @@ pub fn mk_with_id(cx: ctxt, base: t, def_id: ast::def_id) -> t {
}
// Converts s to its machine type equivalent
pub pure fn mach_sty(cfg: @session::config, t: t) -> sty {
pub fn mach_sty(cfg: @session::config, t: t) -> sty {
match get(t).sty {
ty_int(ast::ty_i) => ty_int(cfg.int_type),
ty_uint(ast::ty_u) => ty_uint(cfg.uint_type),
@ -1532,14 +1532,14 @@ pub fn get_element_type(ty: t, i: uint) -> t {
}
}
pub pure fn type_is_box(ty: t) -> bool {
pub fn type_is_box(ty: t) -> bool {
match get(ty).sty {
ty_box(_) => return true,
_ => return false
}
}
pub pure fn type_is_boxed(ty: t) -> bool {
pub fn type_is_boxed(ty: t) -> bool {
match get(ty).sty {
ty_box(_) | ty_opaque_box |
ty_evec(_, vstore_box) | ty_estr(vstore_box) => true,
@ -1547,35 +1547,35 @@ pub pure fn type_is_boxed(ty: t) -> bool {
}
}
pub pure fn type_is_region_ptr(ty: t) -> bool {
pub fn type_is_region_ptr(ty: t) -> bool {
match get(ty).sty {
ty_rptr(_, _) => true,
_ => false
}
}
pub pure fn type_is_slice(ty: t) -> bool {
pub fn type_is_slice(ty: t) -> bool {
match get(ty).sty {
ty_evec(_, vstore_slice(_)) | ty_estr(vstore_slice(_)) => true,
_ => return false
}
}
pub pure fn type_is_unique_box(ty: t) -> bool {
pub fn type_is_unique_box(ty: t) -> bool {
match get(ty).sty {
ty_uniq(_) => return true,
_ => return false
}
}
pub pure fn type_is_unsafe_ptr(ty: t) -> bool {
pub fn type_is_unsafe_ptr(ty: t) -> bool {
match get(ty).sty {
ty_ptr(_) => return true,
_ => return false
}
}
pub pure fn type_is_vec(ty: t) -> bool {
pub fn type_is_vec(ty: t) -> bool {
return match get(ty).sty {
ty_evec(_, _) | ty_unboxed_vec(_) => true,
ty_estr(_) => true,
@ -1583,7 +1583,7 @@ pub pure fn type_is_vec(ty: t) -> bool {
};
}
pub pure fn type_is_unique(ty: t) -> bool {
pub fn type_is_unique(ty: t) -> bool {
match get(ty).sty {
ty_uniq(_) |
ty_evec(_, vstore_uniq) |
@ -1598,7 +1598,7 @@ pub pure fn type_is_unique(ty: t) -> bool {
(A ty_ptr is scalar because it represents a non-managed pointer, so its
contents are abstract to rustc.)
*/
pub pure fn type_is_scalar(ty: t) -> bool {
pub fn type_is_scalar(ty: t) -> bool {
match get(ty).sty {
ty_nil | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) |
ty_infer(IntVar(_)) | ty_infer(FloatVar(_)) | ty_type |
@ -1783,19 +1783,19 @@ pub impl TypeContents {
}
impl ops::Add<TypeContents,TypeContents> for TypeContents {
pure fn add(&self, other: &TypeContents) -> TypeContents {
fn add(&self, other: &TypeContents) -> TypeContents {
TypeContents {bits: self.bits | other.bits}
}
}
impl ops::Sub<TypeContents,TypeContents> for TypeContents {
pure fn sub(&self, other: &TypeContents) -> TypeContents {
fn sub(&self, other: &TypeContents) -> TypeContents {
TypeContents {bits: self.bits & !other.bits}
}
}
impl ToStr for TypeContents {
pure fn to_str(&self) -> ~str {
fn to_str(&self) -> ~str {
fmt!("TypeContents(%s)", u32::to_str_radix(self.bits, 2))
}
}
@ -2534,7 +2534,7 @@ pub fn index_sty(cx: ctxt, sty: &sty) -> Option<mt> {
}
impl to_bytes::IterBytes for bound_region {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self {
ty::br_self => 0u8.iter_bytes(lsb0, f),
@ -2554,7 +2554,7 @@ impl to_bytes::IterBytes for bound_region {
}
impl to_bytes::IterBytes for Region {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self {
re_bound(ref br) =>
to_bytes::iter_bytes_2(&0u8, br, lsb0, f),
@ -2574,7 +2574,7 @@ impl to_bytes::IterBytes for Region {
}
impl to_bytes::IterBytes for vstore {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self {
vstore_fixed(ref u) =>
to_bytes::iter_bytes_2(&0u8, u, lsb0, f),
@ -2589,7 +2589,7 @@ impl to_bytes::IterBytes for vstore {
}
impl to_bytes::IterBytes for TraitStore {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self {
BareTraitStore => 0u8.iter_bytes(lsb0, f),
UniqTraitStore => 1u8.iter_bytes(lsb0, f),
@ -2600,7 +2600,7 @@ impl to_bytes::IterBytes for TraitStore {
}
impl to_bytes::IterBytes for substs {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_3(&self.self_r,
&self.self_ty,
&self.tps, lsb0, f)
@ -2608,28 +2608,28 @@ impl to_bytes::IterBytes for substs {
}
impl to_bytes::IterBytes for mt {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_2(&self.ty,
&self.mutbl, lsb0, f)
}
}
impl to_bytes::IterBytes for field {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_2(&self.ident,
&self.mt, lsb0, f)
}
}
impl to_bytes::IterBytes for arg {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_2(&self.mode,
&self.ty, lsb0, f)
}
}
impl to_bytes::IterBytes for FnSig {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_2(&self.inputs,
&self.output,
lsb0, f);
@ -2637,7 +2637,7 @@ impl to_bytes::IterBytes for FnSig {
}
impl to_bytes::IterBytes for sty {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self {
ty_nil => 0u8.iter_bytes(lsb0, f),
ty_bool => 1u8.iter_bytes(lsb0, f),
@ -2768,7 +2768,7 @@ pub fn ty_fn_purity(fty: t) -> ast::purity {
}
}
pub pure fn ty_fn_ret(fty: t) -> t {
pub fn ty_fn_ret(fty: t) -> t {
match get(fty).sty {
ty_bare_fn(ref f) => f.sig.output,
ty_closure(ref f) => f.sig.output,
@ -2786,7 +2786,7 @@ pub fn is_fn_ty(fty: t) -> bool {
}
}
pub pure fn ty_vstore(ty: t) -> vstore {
pub fn ty_vstore(ty: t) -> vstore {
match get(ty).sty {
ty_evec(_, vstore) => vstore,
ty_estr(vstore) => vstore,
@ -3716,13 +3716,13 @@ pub enum DtorKind {
}
pub impl DtorKind {
pure fn is_not_present(&const self) -> bool {
fn is_not_present(&const self) -> bool {
match *self {
NoDtor => true,
_ => false
}
}
pure fn is_present(&const self) -> bool {
fn is_present(&const self) -> bool {
!self.is_not_present()
}
}
@ -4000,7 +4000,7 @@ pub fn lookup_struct_field(cx: ctxt,
}
}
pure fn is_public(f: field_ty) -> bool {
fn is_public(f: field_ty) -> bool {
// XXX: This is wrong.
match f.vis {
public | inherited => true,
@ -4260,7 +4260,7 @@ pub fn eval_repeat_count(tcx: ctxt, count_expr: @ast::expr) -> uint {
}
// Determine what purity to check a nested function under
pub pure fn determine_inherited_purity(parent_purity: ast::purity,
pub fn determine_inherited_purity(parent_purity: ast::purity,
child_purity: ast::purity,
child_sigil: ast::Sigil)
-> ast::purity {
@ -4364,14 +4364,14 @@ pub fn get_impl_id(tcx: ctxt, trait_id: def_id, self_ty: t) -> def_id {
}
impl cmp::Eq for mt {
pure fn eq(&self, other: &mt) -> bool {
fn eq(&self, other: &mt) -> bool {
(*self).ty == (*other).ty && (*self).mutbl == (*other).mutbl
}
pure fn ne(&self, other: &mt) -> bool { !(*self).eq(other) }
fn ne(&self, other: &mt) -> bool { !(*self).eq(other) }
}
impl cmp::Eq for Region {
pure fn eq(&self, other: &Region) -> bool {
fn eq(&self, other: &Region) -> bool {
match (*self) {
re_bound(e0a) => {
match (*other) {
@ -4405,11 +4405,11 @@ impl cmp::Eq for Region {
}
}
}
pure fn ne(&self, other: &Region) -> bool { !(*self).eq(other) }
fn ne(&self, other: &Region) -> bool { !(*self).eq(other) }
}
impl cmp::Eq for bound_region {
pure fn eq(&self, other: &bound_region) -> bool {
fn eq(&self, other: &bound_region) -> bool {
match (*self) {
br_self => {
match (*other) {
@ -4443,11 +4443,11 @@ impl cmp::Eq for bound_region {
}
}
}
pure fn ne(&self, other: &bound_region) -> bool { !(*self).eq(other) }
fn ne(&self, other: &bound_region) -> bool { !(*self).eq(other) }
}
impl cmp::Eq for param_bound {
pure fn eq(&self, other: &param_bound) -> bool {
fn eq(&self, other: &param_bound) -> bool {
match (*self) {
bound_copy => {
match (*other) {
@ -4481,7 +4481,7 @@ impl cmp::Eq for param_bound {
}
}
}
pure fn ne(&self, other: &param_bound) -> bool { !self.eq(other) }
fn ne(&self, other: &param_bound) -> bool { !self.eq(other) }
}
// Local Variables:

View File

@ -563,7 +563,7 @@ enum Constraint {
}
impl cmp::Eq for Constraint {
pure fn eq(&self, other: &Constraint) -> bool {
fn eq(&self, other: &Constraint) -> bool {
match ((*self), (*other)) {
(ConstrainVarSubVar(v0a, v1a), ConstrainVarSubVar(v0b, v1b)) => {
v0a == v0b && v1a == v1b
@ -579,11 +579,11 @@ impl cmp::Eq for Constraint {
(ConstrainVarSubReg(*), _) => false
}
}
pure fn ne(&self, other: &Constraint) -> bool { !(*self).eq(other) }
fn ne(&self, other: &Constraint) -> bool { !(*self).eq(other) }
}
impl to_bytes::IterBytes for Constraint {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self {
ConstrainVarSubVar(ref v0, ref v1) =>
to_bytes::iter_bytes_3(&0u8, v0, v1, lsb0, f),
@ -603,14 +603,14 @@ struct TwoRegions {
}
impl cmp::Eq for TwoRegions {
pure fn eq(&self, other: &TwoRegions) -> bool {
fn eq(&self, other: &TwoRegions) -> bool {
(*self).a == (*other).a && (*self).b == (*other).b
}
pure fn ne(&self, other: &TwoRegions) -> bool { !(*self).eq(other) }
fn ne(&self, other: &TwoRegions) -> bool { !(*self).eq(other) }
}
impl to_bytes::IterBytes for TwoRegions {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_2(&self.a, &self.b, lsb0, f)
}
}

View File

@ -88,7 +88,7 @@ impl<D:Decoder> Decodable<D> for ident {
}
impl to_bytes::IterBytes for ident {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
self.repr.iter_bytes(lsb0, f)
}
}
@ -274,7 +274,7 @@ pub enum binding_mode {
}
impl to_bytes::IterBytes for binding_mode {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self {
bind_by_copy => 0u8.iter_bytes(lsb0, f),
@ -320,7 +320,7 @@ pub enum pat_ {
pub enum mutability { m_mutbl, m_imm, m_const, }
impl to_bytes::IterBytes for mutability {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
(*self as u8).iter_bytes(lsb0, f)
}
}
@ -333,13 +333,13 @@ pub enum Abi {
}
impl to_bytes::IterBytes for Abi {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
(*self as uint).iter_bytes(lsb0, f)
}
}
impl ToStr for Abi {
pure fn to_str(&self) -> ~str {
fn to_str(&self) -> ~str {
match *self {
RustAbi => ~"\"rust\""
}
@ -356,13 +356,13 @@ pub enum Sigil {
}
impl to_bytes::IterBytes for Sigil {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
(*self as uint).iter_bytes(lsb0, f)
}
}
impl ToStr for Sigil {
pure fn to_str(&self) -> ~str {
fn to_str(&self) -> ~str {
match *self {
BorrowedSigil => ~"&",
OwnedSigil => ~"~",
@ -440,7 +440,7 @@ pub enum inferable<T> {
}
impl<T:to_bytes::IterBytes> to_bytes::IterBytes for inferable<T> {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self {
expl(ref t) =>
to_bytes::iter_bytes_2(&0u8, t, lsb0, f),
@ -458,7 +458,7 @@ impl<T:to_bytes::IterBytes> to_bytes::IterBytes for inferable<T> {
pub enum rmode { by_ref, by_copy }
impl to_bytes::IterBytes for rmode {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
(*self as u8).iter_bytes(lsb0, f)
}
}
@ -796,13 +796,13 @@ pub enum trait_method {
pub enum int_ty { ty_i, ty_char, ty_i8, ty_i16, ty_i32, ty_i64, }
impl ToStr for int_ty {
pure fn to_str(&self) -> ~str {
fn to_str(&self) -> ~str {
::ast_util::int_ty_to_str(*self)
}
}
impl to_bytes::IterBytes for int_ty {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
(*self as u8).iter_bytes(lsb0, f)
}
}
@ -813,13 +813,13 @@ impl to_bytes::IterBytes for int_ty {
pub enum uint_ty { ty_u, ty_u8, ty_u16, ty_u32, ty_u64, }
impl ToStr for uint_ty {
pure fn to_str(&self) -> ~str {
fn to_str(&self) -> ~str {
::ast_util::uint_ty_to_str(*self)
}
}
impl to_bytes::IterBytes for uint_ty {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
(*self as u8).iter_bytes(lsb0, f)
}
}
@ -830,13 +830,13 @@ impl to_bytes::IterBytes for uint_ty {
pub enum float_ty { ty_f, ty_f32, ty_f64, }
impl ToStr for float_ty {
pure fn to_str(&self) -> ~str {
fn to_str(&self) -> ~str {
::ast_util::float_ty_to_str(*self)
}
}
impl to_bytes::IterBytes for float_ty {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
(*self as u8).iter_bytes(lsb0, f)
}
}
@ -872,7 +872,7 @@ pub enum Onceness {
}
impl ToStr for Onceness {
pure fn to_str(&self) -> ~str {
fn to_str(&self) -> ~str {
match *self {
Once => ~"once",
Many => ~"many"
@ -881,7 +881,7 @@ impl ToStr for Onceness {
}
impl to_bytes::IterBytes for Onceness {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
(*self as uint).iter_bytes(lsb0, f);
}
}
@ -930,7 +930,7 @@ pub enum ty_ {
}
impl to_bytes::IterBytes for Ty {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_2(&self.span.lo, &self.span.hi, lsb0, f);
}
}
@ -966,7 +966,7 @@ pub enum purity {
}
impl ToStr for purity {
pure fn to_str(&self) -> ~str {
fn to_str(&self) -> ~str {
match *self {
impure_fn => ~"impure",
unsafe_fn => ~"unsafe",
@ -977,7 +977,7 @@ impl ToStr for purity {
}
impl to_bytes::IterBytes for purity {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
(*self as u8).iter_bytes(lsb0, f)
}
}
@ -992,7 +992,7 @@ pub enum ret_style {
}
impl to_bytes::IterBytes for ret_style {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
(*self as u8).iter_bytes(lsb0, f)
}
}
@ -1278,7 +1278,7 @@ pub enum item_ {
pub enum struct_mutability { struct_mutable, struct_immutable }
impl to_bytes::IterBytes for struct_mutability {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
(*self as u8).iter_bytes(lsb0, f)
}
}

View File

@ -33,7 +33,7 @@ pub enum path_elt {
}
impl cmp::Eq for path_elt {
pure fn eq(&self, other: &path_elt) -> bool {
fn eq(&self, other: &path_elt) -> bool {
match (*self) {
path_mod(e0a) => {
match (*other) {
@ -49,7 +49,7 @@ impl cmp::Eq for path_elt {
}
}
}
pure fn ne(&self, other: &path_elt) -> bool { !(*self).eq(other) }
fn ne(&self, other: &path_elt) -> bool { !(*self).eq(other) }
}
pub type path = ~[path_elt];

View File

@ -24,22 +24,21 @@ use core::str;
use core::to_bytes;
use core::vec;
pub pure fn path_name_i(idents: &[ident], intr: @token::ident_interner)
-> ~str {
pub fn path_name_i(idents: &[ident], intr: @token::ident_interner) -> ~str {
// FIXME: Bad copies (#2543 -- same for everything else that says "bad")
str::connect(idents.map(|i| copy *intr.get(*i)), ~"::")
}
pub pure fn path_to_ident(p: @path) -> ident { copy *p.idents.last() }
pub fn path_to_ident(p: @path) -> ident { copy *p.idents.last() }
pub pure fn local_def(id: node_id) -> def_id {
pub fn local_def(id: node_id) -> def_id {
ast::def_id { crate: local_crate, node: id }
}
pub pure fn is_local(did: ast::def_id) -> bool { did.crate == local_crate }
pub fn is_local(did: ast::def_id) -> bool { did.crate == local_crate }
pub pure fn stmt_id(s: stmt) -> node_id {
pub fn stmt_id(s: stmt) -> node_id {
match s.node {
stmt_decl(_, id) => id,
stmt_expr(_, id) => id,
@ -57,7 +56,7 @@ pub fn variant_def_ids(d: def) -> (def_id, def_id) {
}
}
pub pure fn def_id_of_def(d: def) -> def_id {
pub fn def_id_of_def(d: def) -> def_id {
match d {
def_fn(id, _) | def_static_method(id, _, _) | def_mod(id) |
def_foreign_mod(id) | def_const(id) |
@ -75,7 +74,7 @@ pub pure fn def_id_of_def(d: def) -> def_id {
}
}
pub pure fn binop_to_str(op: binop) -> ~str {
pub fn binop_to_str(op: binop) -> ~str {
match op {
add => return ~"+",
subtract => return ~"-",
@ -98,7 +97,7 @@ pub pure fn binop_to_str(op: binop) -> ~str {
}
}
pub pure fn binop_to_method_name(op: binop) -> Option<~str> {
pub fn binop_to_method_name(op: binop) -> Option<~str> {
match op {
add => return Some(~"add"),
subtract => return Some(~"sub"),
@ -120,7 +119,7 @@ pub pure fn binop_to_method_name(op: binop) -> Option<~str> {
}
}
pub pure fn lazy_binop(b: binop) -> bool {
pub fn lazy_binop(b: binop) -> bool {
match b {
and => true,
or => true,
@ -128,7 +127,7 @@ pub pure fn lazy_binop(b: binop) -> bool {
}
}
pub pure fn is_shift_binop(b: binop) -> bool {
pub fn is_shift_binop(b: binop) -> bool {
match b {
shl => true,
shr => true,
@ -136,7 +135,7 @@ pub pure fn is_shift_binop(b: binop) -> bool {
}
}
pub pure fn unop_to_str(op: unop) -> ~str {
pub fn unop_to_str(op: unop) -> ~str {
match op {
box(mt) => if mt == m_mutbl { ~"@mut " } else { ~"@" },
uniq(mt) => if mt == m_mutbl { ~"~mut " } else { ~"~" },
@ -146,11 +145,11 @@ pub pure fn unop_to_str(op: unop) -> ~str {
}
}
pub pure fn is_path(e: @expr) -> bool {
pub fn is_path(e: @expr) -> bool {
return match e.node { expr_path(_) => true, _ => false };
}
pub pure fn int_ty_to_str(t: int_ty) -> ~str {
pub fn int_ty_to_str(t: int_ty) -> ~str {
match t {
ty_char => ~"u8", // ???
ty_i => ~"",
@ -161,7 +160,7 @@ pub pure fn int_ty_to_str(t: int_ty) -> ~str {
}
}
pub pure fn int_ty_max(t: int_ty) -> u64 {
pub fn int_ty_max(t: int_ty) -> u64 {
match t {
ty_i8 => 0x80u64,
ty_i16 => 0x8000u64,
@ -170,7 +169,7 @@ pub pure fn int_ty_max(t: int_ty) -> u64 {
}
}
pub pure fn uint_ty_to_str(t: uint_ty) -> ~str {
pub fn uint_ty_to_str(t: uint_ty) -> ~str {
match t {
ty_u => ~"u",
ty_u8 => ~"u8",
@ -180,7 +179,7 @@ pub pure fn uint_ty_to_str(t: uint_ty) -> ~str {
}
}
pub pure fn uint_ty_max(t: uint_ty) -> u64 {
pub fn uint_ty_max(t: uint_ty) -> u64 {
match t {
ty_u8 => 0xffu64,
ty_u16 => 0xffffu64,
@ -189,18 +188,18 @@ pub pure fn uint_ty_max(t: uint_ty) -> u64 {
}
}
pub pure fn float_ty_to_str(t: float_ty) -> ~str {
pub fn float_ty_to_str(t: float_ty) -> ~str {
match t { ty_f => ~"f", ty_f32 => ~"f32", ty_f64 => ~"f64" }
}
pub pure fn is_call_expr(e: @expr) -> bool {
pub fn is_call_expr(e: @expr) -> bool {
match e.node { expr_call(_, _, _) => true, _ => false }
}
// This makes def_id hashable
impl to_bytes::IterBytes for def_id {
#[inline(always)]
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_2(&self.crate, &self.node, lsb0, f);
}
}
@ -238,14 +237,14 @@ pub fn ident_to_pat(id: node_id, s: span, +i: ident) -> @pat {
span: s }
}
pub pure fn is_unguarded(a: &arm) -> bool {
pub fn is_unguarded(a: &arm) -> bool {
match a.guard {
None => true,
_ => false
}
}
pub pure fn unguarded_pat(a: &arm) -> Option<~[@pat]> {
pub fn unguarded_pat(a: &arm) -> Option<~[@pat]> {
if is_unguarded(a) { Some(/* FIXME (#2543) */ copy a.pats) } else { None }
}
@ -290,7 +289,7 @@ pub fn split_trait_methods(trait_methods: &[trait_method])
(reqd, provd)
}
pub pure fn struct_field_visibility(field: ast::struct_field) -> visibility {
pub fn struct_field_visibility(field: ast::struct_field) -> visibility {
match field.node.kind {
ast::named_field(_, _, visibility) => visibility,
ast::unnamed_field => ast::public
@ -509,7 +508,7 @@ pub fn compute_id_range_for_inlined_item(item: inlined_item) -> id_range {
compute_id_range(|f| visit_ids_for_inlined_item(item, f))
}
pub pure fn is_item_impl(item: @ast::item) -> bool {
pub fn is_item_impl(item: @ast::item) -> bool {
match item.node {
item_impl(*) => true,
_ => false

View File

@ -89,11 +89,11 @@ pub fn desugar_doc_attr(attr: &ast::attribute) -> ast::attribute {
/* Accessors */
pub pure fn get_attr_name(attr: &ast::attribute) -> @~str {
pub fn get_attr_name(attr: &ast::attribute) -> @~str {
get_meta_item_name(attr.node.value)
}
pub pure fn get_meta_item_name(meta: @ast::meta_item) -> @~str {
pub fn get_meta_item_name(meta: @ast::meta_item) -> @~str {
match meta.node {
ast::meta_word(n) => n,
ast::meta_name_value(n, _) => n,
@ -333,10 +333,10 @@ pub enum inline_attr {
}
impl cmp::Eq for inline_attr {
pure fn eq(&self, other: &inline_attr) -> bool {
fn eq(&self, other: &inline_attr) -> bool {
((*self) as uint) == ((*other) as uint)
}
pure fn ne(&self, other: &inline_attr) -> bool { !(*self).eq(other) }
fn ne(&self, other: &inline_attr) -> bool { !(*self).eq(other) }
}
/// True if something like #[inline] is found in the list of attrs.

View File

@ -30,8 +30,8 @@ use core::uint;
use std::serialize::{Encodable, Decodable, Encoder, Decoder};
pub trait Pos {
pure fn from_uint(n: uint) -> Self;
pure fn to_uint(&self) -> uint;
fn from_uint(n: uint) -> Self;
fn to_uint(&self) -> uint;
}
/// A byte offset
@ -45,71 +45,71 @@ pub struct CharPos(uint);
// have been unsuccessful
impl Pos for BytePos {
pure fn from_uint(n: uint) -> BytePos { BytePos(n) }
pure fn to_uint(&self) -> uint { **self }
fn from_uint(n: uint) -> BytePos { BytePos(n) }
fn to_uint(&self) -> uint { **self }
}
impl cmp::Eq for BytePos {
pure fn eq(&self, other: &BytePos) -> bool { **self == **other }
pure fn ne(&self, other: &BytePos) -> bool { !(*self).eq(other) }
fn eq(&self, other: &BytePos) -> bool { **self == **other }
fn ne(&self, other: &BytePos) -> bool { !(*self).eq(other) }
}
impl cmp::Ord for BytePos {
pure fn lt(&self, other: &BytePos) -> bool { **self < **other }
pure fn le(&self, other: &BytePos) -> bool { **self <= **other }
pure fn ge(&self, other: &BytePos) -> bool { **self >= **other }
pure fn gt(&self, other: &BytePos) -> bool { **self > **other }
fn lt(&self, other: &BytePos) -> bool { **self < **other }
fn le(&self, other: &BytePos) -> bool { **self <= **other }
fn ge(&self, other: &BytePos) -> bool { **self >= **other }
fn gt(&self, other: &BytePos) -> bool { **self > **other }
}
impl Add<BytePos, BytePos> for BytePos {
pure fn add(&self, rhs: &BytePos) -> BytePos {
fn add(&self, rhs: &BytePos) -> BytePos {
BytePos(**self + **rhs)
}
}
impl Sub<BytePos, BytePos> for BytePos {
pure fn sub(&self, rhs: &BytePos) -> BytePos {
fn sub(&self, rhs: &BytePos) -> BytePos {
BytePos(**self - **rhs)
}
}
impl to_bytes::IterBytes for BytePos {
pure fn iter_bytes(&self, +lsb0: bool, &&f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, &&f: to_bytes::Cb) {
(**self).iter_bytes(lsb0, f)
}
}
impl Pos for CharPos {
pure fn from_uint(n: uint) -> CharPos { CharPos(n) }
pure fn to_uint(&self) -> uint { **self }
fn from_uint(n: uint) -> CharPos { CharPos(n) }
fn to_uint(&self) -> uint { **self }
}
impl cmp::Eq for CharPos {
pure fn eq(&self, other: &CharPos) -> bool { **self == **other }
pure fn ne(&self, other: &CharPos) -> bool { !(*self).eq(other) }
fn eq(&self, other: &CharPos) -> bool { **self == **other }
fn ne(&self, other: &CharPos) -> bool { !(*self).eq(other) }
}
impl cmp::Ord for CharPos {
pure fn lt(&self, other: &CharPos) -> bool { **self < **other }
pure fn le(&self, other: &CharPos) -> bool { **self <= **other }
pure fn ge(&self, other: &CharPos) -> bool { **self >= **other }
pure fn gt(&self, other: &CharPos) -> bool { **self > **other }
fn lt(&self, other: &CharPos) -> bool { **self < **other }
fn le(&self, other: &CharPos) -> bool { **self <= **other }
fn ge(&self, other: &CharPos) -> bool { **self >= **other }
fn gt(&self, other: &CharPos) -> bool { **self > **other }
}
impl to_bytes::IterBytes for CharPos {
pure fn iter_bytes(&self, +lsb0: bool, &&f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, &&f: to_bytes::Cb) {
(**self).iter_bytes(lsb0, f)
}
}
impl Add<CharPos,CharPos> for CharPos {
pure fn add(&self, rhs: &CharPos) -> CharPos {
fn add(&self, rhs: &CharPos) -> CharPos {
CharPos(**self + **rhs)
}
}
impl Sub<CharPos,CharPos> for CharPos {
pure fn sub(&self, rhs: &CharPos) -> CharPos {
fn sub(&self, rhs: &CharPos) -> CharPos {
CharPos(**self - **rhs)
}
}
@ -132,10 +132,10 @@ pub struct span {
pub struct spanned<T> { node: T, span: span }
impl cmp::Eq for span {
pure fn eq(&self, other: &span) -> bool {
fn eq(&self, other: &span) -> bool {
return (*self).lo == (*other).lo && (*self).hi == (*other).hi;
}
pure fn ne(&self, other: &span) -> bool { !(*self).eq(other) }
fn ne(&self, other: &span) -> bool { !(*self).eq(other) }
}
impl<S:Encoder> Encodable<S> for span {
@ -149,25 +149,25 @@ impl<D:Decoder> Decodable<D> for span {
}
}
pub pure fn spanned<T>(+lo: BytePos, +hi: BytePos, +t: T) -> spanned<T> {
pub fn spanned<T>(+lo: BytePos, +hi: BytePos, +t: T) -> spanned<T> {
respan(mk_sp(lo, hi), t)
}
pub pure fn respan<T>(sp: span, +t: T) -> spanned<T> {
pub fn respan<T>(sp: span, +t: T) -> spanned<T> {
spanned {node: t, span: sp}
}
pub pure fn dummy_spanned<T>(+t: T) -> spanned<T> {
pub fn dummy_spanned<T>(+t: T) -> spanned<T> {
respan(dummy_sp(), t)
}
/* assuming that we're not in macro expansion */
pub pure fn mk_sp(+lo: BytePos, +hi: BytePos) -> span {
pub fn mk_sp(+lo: BytePos, +hi: BytePos) -> span {
span {lo: lo, hi: hi, expn_info: None}
}
// make this a const, once the compiler supports it
pub pure fn dummy_sp() -> span { return mk_sp(BytePos(0), BytePos(0)); }
pub fn dummy_sp() -> span { return mk_sp(BytePos(0), BytePos(0)); }

View File

@ -231,7 +231,7 @@ pub trait ext_ctxt {
fn span_bug(@mut self, sp: span, msg: &str) -> !;
fn bug(@mut self, msg: &str) -> !;
fn next_id(@mut self) -> ast::node_id;
pure fn trace_macros(@mut self) -> bool;
fn trace_macros(@mut self) -> bool;
fn set_trace_macros(@mut self, x: bool);
/* for unhygienic identifier transformation */
fn str_of(@mut self, id: ast::ident) -> ~str;
@ -310,7 +310,7 @@ pub fn mk_ctxt(parse_sess: @mut parse::ParseSess, +cfg: ast::crate_cfg)
fn next_id(@mut self) -> ast::node_id {
return parse::next_node_id(self.parse_sess);
}
pure fn trace_macros(@mut self) -> bool {
fn trace_macros(@mut self) -> bool {
self.trace_mac
}
fn set_trace_macros(@mut self, x: bool) {
@ -464,7 +464,7 @@ impl <K: Eq + Hash + IterBytes ,V: Copy> MapChain<K,V>{
// traits just don't work anywhere...?
//pub impl Map<Name,SyntaxExtension> for MapChain {
pure fn contains_key (&self, key: &K) -> bool {
fn contains_key (&self, key: &K) -> bool {
match *self {
BaseMapChain (ref map) => map.contains_key(key),
ConsMapChain (ref map,ref rest) =>
@ -475,11 +475,11 @@ impl <K: Eq + Hash + IterBytes ,V: Copy> MapChain<K,V>{
// should each_key and each_value operate on shadowed
// names? I think not.
// delaying implementing this....
pure fn each_key (&self, _f: &fn (&K)->bool) {
fn each_key (&self, _f: &fn (&K)->bool) {
fail!(~"unimplemented 2013-02-15T10:01");
}
pure fn each_value (&self, _f: &fn (&V) -> bool) {
fn each_value (&self, _f: &fn (&V) -> bool) {
fail!(~"unimplemented 2013-02-15T10:02");
}

View File

@ -21,7 +21,7 @@ use core::to_str::ToStr;
pub enum direction { send, recv }
impl ToStr for direction {
pure fn to_str(&self) -> ~str {
fn to_str(&self) -> ~str {
match *self {
send => ~"Send",
recv => ~"Recv"

View File

@ -79,7 +79,7 @@ pub fn new_tt_reader(sp_diag: @span_handler,
return r;
}
pure fn dup_tt_frame(f: @mut TtFrame) -> @mut TtFrame {
fn dup_tt_frame(f: @mut TtFrame) -> @mut TtFrame {
@mut TtFrame {
readme: @mut (copy *f.readme),
idx: f.idx,
@ -92,7 +92,7 @@ pure fn dup_tt_frame(f: @mut TtFrame) -> @mut TtFrame {
}
}
pub pure fn dup_tt_reader(r: @mut TtReader) -> @mut TtReader {
pub fn dup_tt_reader(r: @mut TtReader) -> @mut TtReader {
@mut TtReader {
sp_diag: r.sp_diag,
interner: r.interner,
@ -106,10 +106,10 @@ pub pure fn dup_tt_reader(r: @mut TtReader) -> @mut TtReader {
}
pure fn lookup_cur_matched_by_matched(r: &mut TtReader,
fn lookup_cur_matched_by_matched(r: &mut TtReader,
start: @named_match)
-> @named_match {
pure fn red(+ad: @named_match, idx: &uint) -> @named_match {
fn red(+ad: @named_match, idx: &uint) -> @named_match {
match *ad {
matched_nonterminal(_) => {
// end of the line; duplicate henceforth

View File

@ -61,18 +61,18 @@ impl<T> OptVec<T> {
}
}
pure fn get(&self, i: uint) -> &'self T {
fn get(&self, i: uint) -> &'self T {
match *self {
Empty => fail!(fmt!("Invalid index %u", i)),
Vec(ref v) => &v[i]
}
}
pure fn is_empty(&self) -> bool {
fn is_empty(&self) -> bool {
self.len() == 0
}
pure fn len(&self) -> uint {
fn len(&self) -> uint {
match *self {
Empty => 0,
Vec(ref v) => v.len()
@ -105,7 +105,7 @@ impl<T:Copy> OptVec<T> {
}
impl<A:Eq> Eq for OptVec<A> {
pure fn eq(&self, other: &OptVec<A>) -> bool {
fn eq(&self, other: &OptVec<A>) -> bool {
// Note: cannot use #[deriving(Eq)] here because
// (Empty, Vec(~[])) ought to be equal.
match (self, other) {
@ -116,51 +116,51 @@ impl<A:Eq> Eq for OptVec<A> {
}
}
pure fn ne(&self, other: &OptVec<A>) -> bool {
fn ne(&self, other: &OptVec<A>) -> bool {
!self.eq(other)
}
}
impl<A> BaseIter<A> for OptVec<A> {
pure fn each(&self, blk: &fn(v: &A) -> bool) {
fn each(&self, blk: &fn(v: &A) -> bool) {
match *self {
Empty => {}
Vec(ref v) => v.each(blk)
}
}
pure fn size_hint(&self) -> Option<uint> {
fn size_hint(&self) -> Option<uint> {
Some(self.len())
}
}
impl<A> iter::ExtendedIter<A> for OptVec<A> {
#[inline(always)]
pure fn eachi(&self, blk: &fn(+v: uint, v: &A) -> bool) {
fn eachi(&self, blk: &fn(+v: uint, v: &A) -> bool) {
iter::eachi(self, blk)
}
#[inline(always)]
pure fn all(&self, blk: &fn(&A) -> bool) -> bool {
fn all(&self, blk: &fn(&A) -> bool) -> bool {
iter::all(self, blk)
}
#[inline(always)]
pure fn any(&self, blk: &fn(&A) -> bool) -> bool {
fn any(&self, blk: &fn(&A) -> bool) -> bool {
iter::any(self, blk)
}
#[inline(always)]
pure fn foldl<B>(&self, +b0: B, blk: &fn(&B, &A) -> B) -> B {
fn foldl<B>(&self, +b0: B, blk: &fn(&B, &A) -> B) -> B {
iter::foldl(self, b0, blk)
}
#[inline(always)]
pure fn position(&self, f: &fn(&A) -> bool) -> Option<uint> {
fn position(&self, f: &fn(&A) -> bool) -> Option<uint> {
iter::position(self, f)
}
#[inline(always)]
pure fn map_to_vec<B>(&self, op: &fn(&A) -> B) -> ~[B] {
fn map_to_vec<B>(&self, op: &fn(&A) -> B) -> ~[B] {
iter::map_to_vec(self, op)
}
#[inline(always)]
pure fn flat_map_to_vec<B,IB:BaseIter<B>>(&self, op: &fn(&A) -> IB)
fn flat_map_to_vec<B,IB:BaseIter<B>>(&self, op: &fn(&A) -> IB)
-> ~[B] {
iter::flat_map_to_vec(self, op)
}
@ -169,27 +169,27 @@ impl<A> iter::ExtendedIter<A> for OptVec<A> {
impl<A: Eq> iter::EqIter<A> for OptVec<A> {
#[inline(always)]
pure fn contains(&self, x: &A) -> bool { iter::contains(self, x) }
fn contains(&self, x: &A) -> bool { iter::contains(self, x) }
#[inline(always)]
pure fn count(&self, x: &A) -> uint { iter::count(self, x) }
fn count(&self, x: &A) -> uint { iter::count(self, x) }
}
impl<A: Copy> iter::CopyableIter<A> for OptVec<A> {
#[inline(always)]
pure fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A] {
fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A] {
iter::filter_to_vec(self, pred)
}
#[inline(always)]
pure fn to_vec(&self) -> ~[A] { iter::to_vec(self) }
fn to_vec(&self) -> ~[A] { iter::to_vec(self) }
#[inline(always)]
pure fn find(&self, f: &fn(&A) -> bool) -> Option<A> {
fn find(&self, f: &fn(&A) -> bool) -> Option<A> {
iter::find(self, f)
}
}
impl<A: Copy+Ord> iter::CopyableOrderedIter<A> for OptVec<A> {
#[inline(always)]
pure fn min(&self) -> A { iter::min(self) }
fn min(&self) -> A { iter::min(self) }
#[inline(always)]
pure fn max(&self) -> A { iter::max(self) }
fn max(&self) -> A { iter::max(self) }
}

View File

@ -35,10 +35,10 @@ pub enum cmnt_style {
}
impl cmp::Eq for cmnt_style {
pure fn eq(&self, other: &cmnt_style) -> bool {
fn eq(&self, other: &cmnt_style) -> bool {
((*self) as uint) == ((*other) as uint)
}
pure fn ne(&self, other: &cmnt_style) -> bool {
fn ne(&self, other: &cmnt_style) -> bool {
((*self) as uint) != ((*other) as uint)
}
}

View File

@ -134,7 +134,7 @@ pub impl Parser {
}
}
pure fn token_is_word(&self, word: &~str, tok: &token::Token) -> bool {
fn token_is_word(&self, word: &~str, tok: &token::Token) -> bool {
match *tok {
token::IDENT(sid, false) => { *self.id_to_str(sid) == *word }
_ => { false }

View File

@ -32,7 +32,7 @@ pub trait reader {
fn next_token(@mut self) -> TokenAndSpan;
fn fatal(@mut self, ~str) -> !;
fn span_diag(@mut self) -> @span_handler;
pure fn interner(@mut self) -> @token::ident_interner;
fn interner(@mut self) -> @token::ident_interner;
fn peek(@mut self) -> TokenAndSpan;
fn dup(@mut self) -> @reader;
}
@ -122,7 +122,7 @@ impl reader for StringReader {
self.span_diagnostic.span_fatal(copy self.peek_span, m)
}
fn span_diag(@mut self) -> @span_handler { self.span_diagnostic }
pure fn interner(@mut self) -> @token::ident_interner { self.interner }
fn interner(@mut self) -> @token::ident_interner { self.interner }
fn peek(@mut self) -> TokenAndSpan {
TokenAndSpan {
tok: copy self.peek_tok,
@ -139,7 +139,7 @@ impl reader for TtReader {
self.sp_diag.span_fatal(copy self.cur_span, m);
}
fn span_diag(@mut self) -> @span_handler { self.sp_diag }
pure fn interner(@mut self) -> @token::ident_interner { self.interner }
fn interner(@mut self) -> @token::ident_interner { self.interner }
fn peek(@mut self) -> TokenAndSpan {
TokenAndSpan {
tok: copy self.cur_tok,
@ -261,7 +261,7 @@ fn consume_whitespace_and_comments(rdr: @mut StringReader)
return consume_any_line_comment(rdr);
}
pub pure fn is_line_non_doc_comment(s: &str) -> bool {
pub fn is_line_non_doc_comment(s: &str) -> bool {
s.trim_right().all(|ch| ch == '/')
}
@ -313,7 +313,7 @@ fn consume_any_line_comment(rdr: @mut StringReader)
return None;
}
pub pure fn is_block_non_doc_comment(s: &str) -> bool {
pub fn is_block_non_doc_comment(s: &str) -> bool {
fail_unless!(s.len() >= 1u);
str::all_between(s, 1u, s.len() - 1u, |ch| ch == '*')
}

View File

@ -63,7 +63,7 @@ pub enum ObsoleteSyntax {
impl to_bytes::IterBytes for ObsoleteSyntax {
#[inline(always)]
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
(*self as uint).iter_bytes(lsb0, f);
}
}

View File

@ -196,8 +196,8 @@ macro_rules! maybe_whole (
)
pure fn maybe_append(+lhs: ~[attribute], rhs: Option<~[attribute]>)
-> ~[attribute] {
fn maybe_append(+lhs: ~[attribute], rhs: Option<~[attribute]>)
-> ~[attribute] {
match rhs {
None => lhs,
Some(ref attrs) => vec::append(lhs, (*attrs))
@ -331,7 +331,7 @@ pub impl Parser {
}
fn get_id(&self) -> node_id { next_node_id(self.sess) }
pure fn id_to_str(&self, id: ident) -> @~str {
fn id_to_str(&self, id: ident) -> @~str {
self.sess.interner.get(id)
}

View File

@ -118,7 +118,7 @@ pub enum nonterminal {
nt_matchers(~[ast::matcher])
}
pub pure fn binop_to_str(o: binop) -> ~str {
pub fn binop_to_str(o: binop) -> ~str {
match o {
PLUS => ~"+",
MINUS => ~"-",
@ -228,7 +228,7 @@ pub fn to_str(in: @ident_interner, t: &Token) -> ~str {
}
}
pub pure fn can_begin_expr(t: &Token) -> bool {
pub fn can_begin_expr(t: &Token) -> bool {
match *t {
LPAREN => true,
LBRACE => true,
@ -286,22 +286,22 @@ pub fn is_lit(t: &Token) -> bool {
}
}
pub pure fn is_ident(t: &Token) -> bool {
pub fn is_ident(t: &Token) -> bool {
match *t { IDENT(_, _) => true, _ => false }
}
pub pure fn is_ident_or_path(t: &Token) -> bool {
pub fn is_ident_or_path(t: &Token) -> bool {
match *t {
IDENT(_, _) | INTERPOLATED(nt_path(*)) => true,
_ => false
}
}
pub pure fn is_plain_ident(t: &Token) -> bool {
pub fn is_plain_ident(t: &Token) -> bool {
match *t { IDENT(_, false) => true, _ => false }
}
pub pure fn is_bar(t: &Token) -> bool {
pub fn is_bar(t: &Token) -> bool {
match *t { BINOP(OR) | OROR => true, _ => false }
}
@ -366,7 +366,7 @@ pub impl ident_interner {
fn gensym(&self, val: @~str) -> ast::ident {
ast::ident { repr: self.interner.gensym(val) }
}
pure fn get(&self, idx: ast::ident) -> @~str {
fn get(&self, idx: ast::ident) -> @~str {
self.interner.get(idx.repr)
}
fn len(&self) -> uint {

View File

@ -2214,7 +2214,7 @@ pub fn opt_sigil_to_str(opt_p: Option<ast::Sigil>) -> ~str {
}
}
pub pure fn purity_to_str(p: ast::purity) -> ~str {
pub fn purity_to_str(p: ast::purity) -> ~str {
match p {
ast::impure_fn => ~"impure",
ast::unsafe_fn => ~"unsafe",
@ -2223,7 +2223,7 @@ pub pure fn purity_to_str(p: ast::purity) -> ~str {
}
}
pub pure fn onceness_to_str(o: ast::Onceness) -> ~str {
pub fn onceness_to_str(o: ast::Onceness) -> ~str {
match o {
ast::Once => ~"once",
ast::Many => ~"many"

View File

@ -61,7 +61,7 @@ pub impl<T:Eq + IterBytes + Hash + Const + Copy> Interner<T> {
// this isn't "pure" in the traditional sense, because it can go from
// failing to returning a value as items are interned. But for typestate,
// where we first check a pred and then rely on it, ceasing to fail is ok.
pure fn get(&self, idx: uint) -> T { self.vect[idx] }
fn get(&self, idx: uint) -> T { self.vect[idx] }
fn len(&self) -> uint { let vect = &*self.vect; vect.len() }
}