diff --git a/src/compiletest/compiletest.rs b/src/compiletest/compiletest.rs index e8876c4851bc7..683d5fecc3491 100644 --- a/src/compiletest/compiletest.rs +++ b/src/compiletest/compiletest.rs @@ -254,9 +254,17 @@ pub fn make_test(config: &config, testfile: &Path) -> test::TestDescAndFn { } pub fn make_test_name(config: &config, testfile: &Path) -> test::TestName { + + // Try to elide redundant long paths + fn shorten(path: &Path) -> ~str { + let filename = path.filename(); + let dir = path.pop().filename(); + fmt!("%s/%s", dir.get_or_default(~""), filename.get_or_default(~"")) + } + test::DynTestName(fmt!("[%s] %s", mode_str(config.mode), - testfile.to_str())) + shorten(testfile))) } pub fn make_test_closure(config: &config, testfile: &Path) -> test::TestFn { diff --git a/src/etc/vim/syntax/rust.vim b/src/etc/vim/syntax/rust.vim index 625424ac8709e..2c3e09a3e179f 100644 --- a/src/etc/vim/syntax/rust.vim +++ b/src/etc/vim/syntax/rust.vim @@ -2,7 +2,7 @@ " Language: Rust " Maintainer: Patrick Walton " Maintainer: Ben Blum -" Last Change: 2012 Jun 14 +" Last Change: 2013 Jun 14 if version < 600 syntax clear diff --git a/src/libextra/arc.rs b/src/libextra/arc.rs index c5fe07f21875b..d1fe08b2e877e 100644 --- a/src/libextra/arc.rs +++ b/src/libextra/arc.rs @@ -19,7 +19,7 @@ * * ~~~ {.rust} * extern mod std; - * use std::arc; + * use extra::arc; * let numbers=vec::from_fn(100, |ind| (ind as float)*rand::random()); * let shared_numbers=arc::ARC(numbers); * diff --git a/src/libextra/base64.rs b/src/libextra/base64.rs index 5bf4dd517a5b2..392e7ff29a226 100644 --- a/src/libextra/base64.rs +++ b/src/libextra/base64.rs @@ -36,8 +36,8 @@ impl<'self> ToBase64 for &'self [u8] { * # Example * * ~~~ {.rust} - * extern mod std; - * use std::base64::ToBase64; + * extern mod extra; + * use extra::base64::ToBase64; * * fn main () { * let str = [52,32].to_base64(); @@ -99,8 +99,8 @@ impl<'self> ToBase64 for &'self str { * # Example * * ~~~ {.rust} - * extern mod std; - * use std::base64::ToBase64; + * extern mod extra; + * use extra::base64::ToBase64; * * fn main () { * let str = "Hello, World".to_base64(); @@ -127,9 +127,9 @@ impl<'self> FromBase64 for &'self [u8] { * # Example * * ~~~ {.rust} - * extern mod std; - * use std::base64::ToBase64; - * use std::base64::FromBase64; + * extern mod extra; + * use extra::base64::ToBase64; + * use extra::base64::FromBase64; * * fn main () { * let str = [52,32].to_base64(); @@ -207,9 +207,9 @@ impl<'self> FromBase64 for &'self str { * This converts a string literal to base64 and back. * * ~~~ {.rust} - * extern mod std; - * use std::base64::ToBase64; - * use std::base64::FromBase64; + * extern mod extra; + * use extra::base64::ToBase64; + * use extra::base64::FromBase64; * use core::str; * * fn main () { diff --git a/src/libextra/future.rs b/src/libextra/future.rs index 4652e1d647701..030e63adca967 100644 --- a/src/libextra/future.rs +++ b/src/libextra/future.rs @@ -17,7 +17,7 @@ * ~~~ {.rust} * # fn fib(n: uint) -> uint {42}; * # fn make_a_sandwich() {}; - * let mut delayed_fib = std::future::spawn (|| fib(5000) ); + * let mut delayed_fib = extra::future::spawn (|| fib(5000) ); * make_a_sandwich(); * println(fmt!("fib(5000) = %?", delayed_fib.get())) * ~~~ diff --git a/src/libextra/net_ip.rs b/src/libextra/net_ip.rs index 1d0b9829242d5..fc3c765999bc1 100644 --- a/src/libextra/net_ip.rs +++ b/src/libextra/net_ip.rs @@ -55,7 +55,7 @@ pub struct ParseAddrErr { * * # Arguments * - * * ip - a `std::net::ip::IpAddr` + * * ip - a `extra::net::ip::IpAddr` */ pub fn format_addr(ip: &IpAddr) -> ~str { match *ip { @@ -80,7 +80,7 @@ pub fn format_addr(ip: &IpAddr) -> ~str { * Get the associated port * * # Arguments - * * ip - a `std::net::ip::IpAddr` + * * ip - a `extra::net::ip::IpAddr` */ pub fn get_port(ip: &IpAddr) -> uint { match *ip { diff --git a/src/librustc/metadata/common.rs b/src/librustc/metadata/common.rs index 9426cd6041d91..f487c73372fad 100644 --- a/src/librustc/metadata/common.rs +++ b/src/librustc/metadata/common.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -7,7 +7,8 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. - +use core::prelude::*; +use core::cast; // EBML enum definitions and utils shared by the encoder and decoder @@ -111,6 +112,7 @@ pub static tag_items_data_item_reexport_def_id: uint = 0x4e; pub static tag_items_data_item_reexport_name: uint = 0x4f; // used to encode crate_ctxt side tables +#[deriving(Eq)] pub enum astencode_tag { // Reserves 0x50 -- 0x6f tag_ast = 0x50, @@ -136,6 +138,16 @@ pub enum astencode_tag { // Reserves 0x50 -- 0x6f tag_table_moves_map = 0x63, tag_table_capture_map = 0x64 } +static first_astencode_tag : uint = tag_ast as uint; +static last_astencode_tag : uint = tag_table_capture_map as uint; +impl astencode_tag { + pub fn from_uint(value : uint) -> Option { + let is_a_tag = first_astencode_tag <= value && value <= last_astencode_tag; + if !is_a_tag { None } else { + Some(unsafe { cast::transmute(value as int) }) + } + } +} pub static tag_item_trait_method_sort: uint = 0x70; diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index 714164d6a1200..d2b939dc0fc0f 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -100,10 +100,8 @@ enum Family { MutStatic, // b Fn, // f UnsafeFn, // u - PureFn, // p StaticMethod, // F UnsafeStaticMethod, // U - PureStaticMethod, // P ForeignFn, // e Type, // y ForeignType, // T @@ -126,10 +124,8 @@ fn item_family(item: ebml::Doc) -> Family { 'b' => MutStatic, 'f' => Fn, 'u' => UnsafeFn, - 'p' => PureFn, 'F' => StaticMethod, 'U' => UnsafeStaticMethod, - 'P' => PureStaticMethod, 'e' => ForeignFn, 'y' => Type, 'T' => ForeignType, @@ -327,7 +323,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); @@ -337,10 +332,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)), @@ -824,12 +815,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!() } @@ -937,10 +927,8 @@ fn item_family_to_str(fam: Family) -> ~str { MutStatic => ~"static mut", 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", diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 9c28da10e40d5..f6d620df80ab1 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -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") } diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index b53bdcc9bbe0b..c3840c9c87fb2 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -440,10 +440,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) } } diff --git a/src/librustc/metadata/tyencode.rs b/src/librustc/metadata/tyencode.rs index dd62a8e11cb7f..37fedc16122e5 100644 --- a/src/librustc/metadata/tyencode.rs +++ b/src/librustc/metadata/tyencode.rs @@ -350,7 +350,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') diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index 5aad0d894da46..fb8238b84d6e6 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -319,15 +319,10 @@ fn simplify_ast(ii: &ast::inlined_item) -> ast::inlined_item { }); match *ii { - ast::ii_item(i) => { - ast::ii_item(fld.fold_item(i).get()) //hack: we're not dropping items - } - ast::ii_method(d, m) => { - ast::ii_method(d, fld.fold_method(m)) - } - ast::ii_foreign(i) => { - ast::ii_foreign(fld.fold_foreign_item(i)) - } + //hack: we're not dropping items + ast::ii_item(i) => ast::ii_item(fld.fold_item(i).get()), + ast::ii_method(d, m) => ast::ii_method(d, fld.fold_method(m)), + ast::ii_foreign(i) => ast::ii_foreign(fld.fold_foreign_item(i)) } } @@ -346,16 +341,10 @@ fn renumber_ast(xcx: @ExtendedDecodeContext, ii: ast::inlined_item) }); match ii { - ast::ii_item(i) => { - ast::ii_item(fld.fold_item(i).get()) - } - ast::ii_method(d, m) => { - ast::ii_method(xcx.tr_def_id(d), fld.fold_method(m)) - } - ast::ii_foreign(i) => { - ast::ii_foreign(fld.fold_foreign_item(i)) - } - } + ast::ii_item(i) => ast::ii_item(fld.fold_item(i).get()), + ast::ii_method(d, m) => ast::ii_method(xcx.tr_def_id(d), fld.fold_method(m)), + ast::ii_foreign(i) => ast::ii_foreign(fld.fold_foreign_item(i)), + } } // ______________________________________________________________________ @@ -374,22 +363,22 @@ fn decode_def(xcx: @ExtendedDecodeContext, doc: ebml::Doc) -> ast::def { impl tr for ast::def { fn tr(&self, xcx: @ExtendedDecodeContext) -> ast::def { match *self { - ast::def_fn(did, p) => { ast::def_fn(did.tr(xcx), p) } + ast::def_fn(did, p) => ast::def_fn(did.tr(xcx), p), ast::def_static_method(did, did2_opt, p) => { ast::def_static_method(did.tr(xcx), did2_opt.map(|did2| did2.tr(xcx)), p) - } - ast::def_self_ty(nid) => { ast::def_self_ty(xcx.tr_id(nid)) } - ast::def_self(nid, i) => { ast::def_self(xcx.tr_id(nid), i) } - ast::def_mod(did) => { ast::def_mod(did.tr(xcx)) } - ast::def_foreign_mod(did) => { ast::def_foreign_mod(did.tr(xcx)) } - ast::def_static(did, m) => { ast::def_static(did.tr(xcx), m) } - ast::def_arg(nid, b) => { ast::def_arg(xcx.tr_id(nid), b) } - ast::def_local(nid, b) => { ast::def_local(xcx.tr_id(nid), b) } + }, + ast::def_self_ty(nid) => ast::def_self_ty(xcx.tr_id(nid)), + ast::def_self(nid, i) => ast::def_self(xcx.tr_id(nid), i), + ast::def_mod(did) => ast::def_mod(did.tr(xcx)), + ast::def_foreign_mod(did) => ast::def_foreign_mod(did.tr(xcx)), + ast::def_static(did, m) => ast::def_static(did.tr(xcx), m), + ast::def_arg(nid, b) => ast::def_arg(xcx.tr_id(nid), b), + ast::def_local(nid, b) => ast::def_local(xcx.tr_id(nid), b), ast::def_variant(e_did, v_did) => { ast::def_variant(e_did.tr(xcx), v_did.tr(xcx)) - } + }, ast::def_trait(did) => ast::def_trait(did.tr(xcx)), ast::def_ty(did) => ast::def_ty(did.tr(xcx)), ast::def_prim_ty(p) => ast::def_prim_ty(p), @@ -402,9 +391,7 @@ impl tr for ast::def { xcx.tr_id(nid2), xcx.tr_id(nid3)) } - ast::def_struct(did) => { - ast::def_struct(did.tr(xcx)) - } + ast::def_struct(did) => ast::def_struct(did.tr(xcx)), ast::def_region(nid) => ast::def_region(xcx.tr_id(nid)), ast::def_typaram_binder(nid) => { ast::def_typaram_binder(xcx.tr_id(nid)) @@ -419,12 +406,9 @@ impl tr for ast::def { impl tr for ty::AutoAdjustment { fn tr(&self, xcx: @ExtendedDecodeContext) -> ty::AutoAdjustment { - match self { - &ty::AutoAddEnv(r, s) => { - ty::AutoAddEnv(r.tr(xcx), s) - } - - &ty::AutoDerefRef(ref adr) => { + match *self { + ty::AutoAddEnv(r, s) => ty::AutoAddEnv(r.tr(xcx), s), + ty::AutoDerefRef(ref adr) => { ty::AutoDerefRef(ty::AutoDerefRef { autoderefs: adr.autoderefs, autoref: adr.autoref.map(|ar| ar.tr(xcx)), @@ -1110,56 +1094,75 @@ fn decode_side_tables(xcx: @ExtendedDecodeContext, found for id %d (orig %d)", tag, id, id0); - if tag == (c::tag_table_moves_map as uint) { - dcx.maps.moves_map.insert(id); - } else { - let val_doc = entry_doc.get(c::tag_table_val as uint); - let mut val_dsr = reader::Decoder(val_doc); - let val_dsr = &mut val_dsr; - if tag == (c::tag_table_def as uint) { - let def = decode_def(xcx, val_doc); - dcx.tcx.def_map.insert(id, def); - } else if tag == (c::tag_table_node_type as uint) { - let ty = val_dsr.read_ty(xcx); - debug!("inserting ty for node %?: %s", - id, ty_to_str(dcx.tcx, ty)); - dcx.tcx.node_types.insert(id as uint, ty); - } else if tag == (c::tag_table_node_type_subst as uint) { - let tys = val_dsr.read_tys(xcx); - dcx.tcx.node_type_substs.insert(id, tys); - } else if tag == (c::tag_table_freevars as uint) { - let fv_info = @val_dsr.read_to_vec(|val_dsr| { - @val_dsr.read_freevar_entry(xcx) - }); - dcx.tcx.freevars.insert(id, fv_info); - } else if tag == (c::tag_table_tcache as uint) { - let tpbt = val_dsr.read_ty_param_bounds_and_ty(xcx); - let lid = ast::def_id { crate: ast::local_crate, node: id }; - dcx.tcx.tcache.insert(lid, tpbt); - } else if tag == (c::tag_table_param_defs as uint) { - let bounds = val_dsr.read_type_param_def(xcx); - dcx.tcx.ty_param_defs.insert(id, bounds); - } else if tag == (c::tag_table_method_map as uint) { - dcx.maps.method_map.insert( - id, - val_dsr.read_method_map_entry(xcx)); - } else if tag == (c::tag_table_vtable_map as uint) { - dcx.maps.vtable_map.insert(id, - val_dsr.read_vtable_res(xcx)); - } else if tag == (c::tag_table_adjustments as uint) { - let adj: @ty::AutoAdjustment = @Decodable::decode(val_dsr); - adj.tr(xcx); - dcx.tcx.adjustments.insert(id, adj); - } else if tag == (c::tag_table_capture_map as uint) { - let cvars = - at_vec::to_managed_consume( - val_dsr.read_to_vec( - |val_dsr| val_dsr.read_capture_var(xcx))); - dcx.maps.capture_map.insert(id, cvars); - } else { + match c::astencode_tag::from_uint(tag) { + None => { xcx.dcx.tcx.sess.bug( fmt!("unknown tag found in side tables: %x", tag)); } + Some(value) => if value == c::tag_table_moves_map { + dcx.maps.moves_map.insert(id); + } else { + let val_doc = entry_doc.get(c::tag_table_val as uint); + let mut val_dsr = reader::Decoder(val_doc); + let val_dsr = &mut val_dsr; + + match value { + c::tag_table_def => { + let def = decode_def(xcx, val_doc); + dcx.tcx.def_map.insert(id, def); + } + c::tag_table_node_type => { + let ty = val_dsr.read_ty(xcx); + debug!("inserting ty for node %?: %s", + id, ty_to_str(dcx.tcx, ty)); + dcx.tcx.node_types.insert(id as uint, ty); + } + c::tag_table_node_type_subst => { + let tys = val_dsr.read_tys(xcx); + dcx.tcx.node_type_substs.insert(id, tys); + } + c::tag_table_freevars => { + let fv_info = @val_dsr.read_to_vec(|val_dsr| { + @val_dsr.read_freevar_entry(xcx) + }); + dcx.tcx.freevars.insert(id, fv_info); + } + c::tag_table_tcache => { + let tpbt = val_dsr.read_ty_param_bounds_and_ty(xcx); + let lid = ast::def_id { crate: ast::local_crate, node: id }; + dcx.tcx.tcache.insert(lid, tpbt); + } + c::tag_table_param_defs => { + let bounds = val_dsr.read_type_param_def(xcx); + dcx.tcx.ty_param_defs.insert(id, bounds); + } + c::tag_table_method_map => { + dcx.maps.method_map.insert( + id, + val_dsr.read_method_map_entry(xcx)); + } + c::tag_table_vtable_map => { + dcx.maps.vtable_map.insert(id, + val_dsr.read_vtable_res(xcx)); + } + c::tag_table_adjustments => { + let adj: @ty::AutoAdjustment = @Decodable::decode(val_dsr); + adj.tr(xcx); + dcx.tcx.adjustments.insert(id, adj); + } + c::tag_table_capture_map => { + let cvars = + at_vec::to_managed_consume( + val_dsr.read_to_vec( + |val_dsr| val_dsr.read_capture_var(xcx))); + dcx.maps.capture_map.insert(id, cvars); + } + _ => { + xcx.dcx.tcx.sess.bug( + fmt!("unknown tag found in side tables: %x", tag)); + } + } + } } debug!(">< Side table doc loaded"); diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index c1906820883c3..2fa25b10f6051 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -235,22 +235,17 @@ pub fn check_item_recursion(sess: Session, fn visit_expr(e: @expr, (env, v): (env, visit::vt)) { match e.node { - expr_path(*) => { - match env.def_map.find(&e.id) { - Some(&def_static(def_id, _)) => { - if ast_util::is_local(def_id) { - match env.ast_map.get_copy(&def_id.node) { - ast_map::node_item(it, _) => { - (v.visit_item)(it, (env, v)); - } - _ => fail!("const not bound to an item") - } - } - } - _ => () - } - } - _ => () + expr_path(*) => match env.def_map.find(&e.id) { + Some(&def_static(def_id, _)) if ast_util::is_local(def_id) => + match env.ast_map.get_copy(&def_id.node) { + ast_map::node_item(it, _) => { + (v.visit_item)(it, (env, v)); + } + _ => fail!("const not bound to an item") + }, + _ => () + }, + _ => () } visit::visit_expr(e, (env, v)); } diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index 1a7cd856bede7..299d71b2567a1 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -420,57 +420,18 @@ pub fn lit_to_const(lit: @lit) -> const_val { } } +fn compare_vals(a: T, b: T) -> Option { + Some(if a == b { 0 } else if a < b { -1 } else { 1 }) +} pub fn compare_const_vals(a: &const_val, b: &const_val) -> Option { - match (a, b) { - (&const_int(a), &const_int(b)) => { - if a == b { - Some(0) - } else if a < b { - Some(-1) - } else { - Some(1) - } - } - (&const_uint(a), &const_uint(b)) => { - if a == b { - Some(0) - } else if a < b { - Some(-1) - } else { - Some(1) - } - } - (&const_float(a), &const_float(b)) => { - if a == b { - Some(0) - } else if a < b { - Some(-1) - } else { - Some(1) - } - } - (&const_str(ref a), &const_str(ref b)) => { - if (*a) == (*b) { - Some(0) - } else if (*a) < (*b) { - Some(-1) - } else { - Some(1) - } - } - (&const_bool(a), &const_bool(b)) => { - if a == b { - Some(0) - } else if a < b { - Some(-1) - } else { - Some(1) - } - } - _ => { - None + match (a, b) { + (&const_int(a), &const_int(b)) => compare_vals(a, b), + (&const_uint(a), &const_uint(b)) => compare_vals(a, b), + (&const_float(a), &const_float(b)) => compare_vals(a, b), + (&const_str(a), &const_str(b)) => compare_vals(a, b), + (&const_bool(a), &const_bool(b)) => compare_vals(a, b), + _ => None } - } } pub fn compare_lit_exprs(tcx: middle::ty::ctxt, a: @expr, b: @expr) -> Option { @@ -478,15 +439,9 @@ pub fn compare_lit_exprs(tcx: middle::ty::ctxt, a: @expr, b: @expr) -> Option Option { - match compare_lit_exprs(tcx, a, b) { - Some(val) => Some(val == 0), - None => None, - } + compare_lit_exprs(tcx, a, b).map(|&val| val == 0) } pub fn lit_eq(a: @lit, b: @lit) -> Option { - match compare_const_vals(&lit_to_const(a), &lit_to_const(b)) { - Some(val) => Some(val == 0), - None => None, - } + compare_const_vals(&lit_to_const(a), &lit_to_const(b)).map(|&val| val == 0) } diff --git a/src/librustc/middle/trans/reflect.rs b/src/librustc/middle/trans/reflect.rs index c2a8b47f24583..24c7333469765 100644 --- a/src/librustc/middle/trans/reflect.rs +++ b/src/librustc/middle/trans/reflect.rs @@ -396,7 +396,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 diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 328b331ea63ed..87b6e61e1373a 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -1251,7 +1251,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, diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index eb505338e4b2c..a38a2dced93b6 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -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, diff --git a/src/librustc/middle/typeck/infer/glb.rs b/src/librustc/middle/typeck/infer/glb.rs index a1e16cfbe8388..47fb28f84845a 100644 --- a/src/librustc/middle/typeck/infer/glb.rs +++ b/src/librustc/middle/typeck/infer/glb.rs @@ -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 { 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) diff --git a/src/librustc/middle/typeck/infer/lub.rs b/src/librustc/middle/typeck/infer/lub.rs index 213af316549a9..c77bef835e4f8 100644 --- a/src/librustc/middle/typeck/infer/lub.rs +++ b/src/librustc/middle/typeck/infer/lub.rs @@ -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), } } diff --git a/src/libstd/os.rs b/src/libstd/os.rs index e6b92c0ccc3f9..84fdc1c46d182 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -1717,5 +1717,5 @@ mod tests { assert!(!os::mkdir_recursive(&path, (S_IRUSR | S_IWUSR | S_IXUSR) as i32)); } - // More recursive_mkdir tests are in std::tempfile + // More recursive_mkdir tests are in extra::tempfile } diff --git a/src/libstd/str.rs b/src/libstd/str.rs index 16c287c1da823..801a4af281ec3 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -14,7 +14,7 @@ * Strings are a packed UTF-8 representation of text, stored as null * terminated buffers of u8 bytes. Strings should be indexed in bytes, * for efficiency, but UTF-8 unsafe operations should be avoided. For - * some heavy-duty uses, try std::rope. + * some heavy-duty uses, try extra::rope. */ use at_vec; diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index c7f3b41475f07..54ffa270f3362 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -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" } } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index d7b5e57a57f0d..0a20526da44c5 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -2207,26 +2207,29 @@ pub fn print_fn_header_info(s: @ps, print_opt_sigil(s, opt_sigil); } -pub fn opt_sigil_to_str(opt_p: Option) -> ~str { +pub fn opt_sigil_to_str(opt_p: Option) -> &'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" } } diff --git a/src/test/run-pass/newlambdas-ret-infer2.rs b/src/test/run-pass/newlambdas-ret-infer2.rs index 4b580e7fa797a..4dfe3575eb591 100644 --- a/src/test/run-pass/newlambdas-ret-infer2.rs +++ b/src/test/run-pass/newlambdas-ret-infer2.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-test ~fn is not inferred // Test that the lambda kind is inferred correctly as a return // expression