diff --git a/src/libextra/fun_treemap.rs b/src/libextra/fun_treemap.rs index 7074d76536a35..edbe323ec2d0b 100644 --- a/src/libextra/fun_treemap.rs +++ b/src/libextra/fun_treemap.rs @@ -31,10 +31,17 @@ enum TreeNode { } /// Create a treemap -pub fn init() -> Treemap { @Empty } +pub fn init() -> Treemap { + @Empty +} /// Insert a value into the map -pub fn insert(m: Treemap, k: K, v: V) -> Treemap { +pub fn insert( + m: Treemap, + k: K, + v: V) + -> Treemap { @match m { @Empty => Node(@k, @v, @Empty, @Empty), @Node(kk, vv, left, right) => cond!( @@ -46,7 +53,11 @@ pub fn insert(m: Treemap, k: K, v: V) -> Treemap { } /// Find a value based on the key -pub fn find(m: Treemap, k: K) -> Option { +pub fn find( + m: Treemap, + k: K) + -> Option { match *m { Empty => None, Node(kk, v, left, right) => cond!( diff --git a/src/libextra/list.rs b/src/libextra/list.rs index 0348176057960..8f7ade7228b02 100644 --- a/src/libextra/list.rs +++ b/src/libextra/list.rs @@ -25,7 +25,7 @@ pub enum MutList { } /// Create a list from a vector -pub fn from_vec(v: &[T]) -> @List { +pub fn from_vec(v: &[T]) -> @List { v.rev_iter().fold(@Nil::, |t, h| @Cons((*h).clone(), t)) } @@ -109,7 +109,7 @@ pub fn head(ls: @List) -> T { } /// Appends one list to another -pub fn append(l: @List, m: @List) -> @List { +pub fn append(l: @List, m: @List) -> @List { match *l { Nil => return m, Cons(ref x, xs) => { diff --git a/src/libextra/serialize.rs b/src/libextra/serialize.rs index 62c1f6631d2dc..679e5e46547c6 100644 --- a/src/libextra/serialize.rs +++ b/src/libextra/serialize.rs @@ -423,7 +423,7 @@ impl> Encodable for @T { } } -impl> Decodable for @T { +impl + 'static> Decodable for @T { fn decode(d: &mut D) -> @T { @Decodable::decode(d) } @@ -435,7 +435,7 @@ impl> Encodable for @mut T { } } -impl> Decodable for @mut T { +impl + 'static> Decodable for @mut T { fn decode(d: &mut D) -> @mut T { @mut Decodable::decode(d) } diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index ab42e84e2acfe..d9be85189a244 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -1259,8 +1259,9 @@ fn encode_info_for_items(ecx: &EncodeContext, // Path and definition ID indexing -fn create_index(index: ~[entry]) - -> ~[@~[entry]] { +fn create_index( + index: ~[entry]) + -> ~[@~[entry]] { let mut buckets: ~[@mut ~[entry]] = ~[]; for uint::range(0u, 256u) |_i| { buckets.push(@mut ~[]); }; for index.iter().advance |elt| { @@ -1275,9 +1276,10 @@ fn create_index(index: ~[entry]) return buckets_frozen; } -fn encode_index(ebml_w: &mut writer::Encoder, - buckets: ~[@~[entry]], - write_fn: &fn(@io::Writer, &T)) { +fn encode_index( + ebml_w: &mut writer::Encoder, + buckets: ~[@~[entry]], + write_fn: &fn(@io::Writer, &T)) { let writer = ebml_w.writer; ebml_w.start_tag(tag_index); let mut bucket_locs: ~[uint] = ~[]; diff --git a/src/librustc/middle/borrowck/check_loans.rs b/src/librustc/middle/borrowck/check_loans.rs index 8f254287d24e0..2338e49a89052 100644 --- a/src/librustc/middle/borrowck/check_loans.rs +++ b/src/librustc/middle/borrowck/check_loans.rs @@ -31,10 +31,11 @@ use syntax::codemap::span; use syntax::visit; use util::ppaux::Repr; +#[deriving(Clone)] struct CheckLoanCtxt<'self> { bccx: @BorrowckCtxt, dfcx_loans: &'self LoanDataFlow, - move_data: move_data::FlowedMoveData, + move_data: @move_data::FlowedMoveData, all_loans: &'self [Loan], reported: @mut HashSet, } @@ -46,10 +47,10 @@ pub fn check_loans(bccx: @BorrowckCtxt, body: &ast::blk) { debug!("check_loans(body id=%?)", body.id); - let clcx = @mut CheckLoanCtxt { + let clcx = CheckLoanCtxt { bccx: bccx, dfcx_loans: dfcx_loans, - move_data: move_data, + move_data: @move_data, all_loans: all_loans, reported: @mut HashSet::new(), }; @@ -139,7 +140,7 @@ impl<'self> CheckLoanCtxt<'self> { return result; } - pub fn check_for_conflicting_loans(&mut self, scope_id: ast::node_id) { + pub fn check_for_conflicting_loans(&self, scope_id: ast::node_id) { //! Checks to see whether any of the loans that are issued //! by `scope_id` conflict with loans that have already been //! issued when we enter `scope_id` (for example, we do not @@ -596,7 +597,7 @@ impl<'self> CheckLoanCtxt<'self> { MoveOk } - pub fn check_call(&mut self, + pub fn check_call(&self, _expr: @ast::expr, _callee: Option<@ast::expr>, _callee_id: ast::node_id, @@ -617,8 +618,8 @@ fn check_loans_in_fn<'a>(fk: &visit::fn_kind, body: &ast::blk, sp: span, id: ast::node_id, - (this, visitor): (@mut CheckLoanCtxt<'a>, - visit::vt<@mut CheckLoanCtxt<'a>>)) { + (this, visitor): (CheckLoanCtxt<'a>, + visit::vt>)) { match *fk { visit::fk_item_fn(*) | visit::fk_method(*) => { @@ -634,7 +635,7 @@ fn check_loans_in_fn<'a>(fk: &visit::fn_kind, visit::visit_fn(fk, decl, body, sp, id, (this, visitor)); - fn check_captured_variables(this: @mut CheckLoanCtxt, + fn check_captured_variables(this: CheckLoanCtxt, closure_id: ast::node_id, span: span) { let cap_vars = this.bccx.capture_map.get(&closure_id); @@ -652,7 +653,7 @@ fn check_loans_in_fn<'a>(fk: &visit::fn_kind, } return; - fn check_by_move_capture(this: @mut CheckLoanCtxt, + fn check_by_move_capture(this: CheckLoanCtxt, closure_id: ast::node_id, cap_var: &moves::CaptureVar, move_path: @LoanPath) { @@ -676,14 +677,14 @@ fn check_loans_in_fn<'a>(fk: &visit::fn_kind, } fn check_loans_in_local<'a>(local: @ast::local, - (this, vt): (@mut CheckLoanCtxt<'a>, - visit::vt<@mut CheckLoanCtxt<'a>>)) { + (this, vt): (CheckLoanCtxt<'a>, + visit::vt>)) { visit::visit_local(local, (this, vt)); } fn check_loans_in_expr<'a>(expr: @ast::expr, - (this, vt): (@mut CheckLoanCtxt<'a>, - visit::vt<@mut CheckLoanCtxt<'a>>)) { + (this, vt): (CheckLoanCtxt<'a>, + visit::vt>)) { visit::visit_expr(expr, (this, vt)); debug!("check_loans_in_expr(expr=%s)", @@ -736,8 +737,8 @@ fn check_loans_in_expr<'a>(expr: @ast::expr, } fn check_loans_in_pat<'a>(pat: @ast::pat, - (this, vt): (@mut CheckLoanCtxt<'a>, - visit::vt<@mut CheckLoanCtxt<'a>>)) + (this, vt): (CheckLoanCtxt<'a>, + visit::vt>)) { this.check_for_conflicting_loans(pat.id); this.check_move_out_from_id(pat.id, pat.span); @@ -745,8 +746,8 @@ fn check_loans_in_pat<'a>(pat: @ast::pat, } fn check_loans_in_block<'a>(blk: &ast::blk, - (this, vt): (@mut CheckLoanCtxt<'a>, - visit::vt<@mut CheckLoanCtxt<'a>>)) + (this, vt): (CheckLoanCtxt<'a>, + visit::vt>)) { visit::visit_block(blk, (this, vt)); this.check_for_conflicting_loans(blk.id); diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs index deafe85a2c94a..acb01e5bf67a6 100644 --- a/src/librustc/middle/kind.rs +++ b/src/librustc/middle/kind.rs @@ -285,6 +285,10 @@ pub fn check_expr(e: @expr, (cx, v): (Context, visit::vt)) { } match e.node { + expr_unary(_, box(_), interior) => { + let interior_type = ty::expr_ty(cx.tcx, interior); + let _ = check_durable(cx.tcx, interior_type, interior.span); + } expr_cast(source, _) => { check_cast_for_escaping_regions(cx, source, e); match ty::get(ty::expr_ty(cx.tcx, e)).sty { diff --git a/src/librustc/middle/subst.rs b/src/librustc/middle/subst.rs index 5a3bb9c55d53c..d43cea2c7336a 100644 --- a/src/librustc/middle/subst.rs +++ b/src/librustc/middle/subst.rs @@ -79,7 +79,7 @@ impl Subst for ~[T] { } } -impl Subst for @T { +impl Subst for @T { fn subst(&self, tcx: ty::ctxt, substs: &ty::substs) -> @T { match self { &@ref t => @t.subst(tcx, substs) diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index 718bb4c9e20c4..b125232a7aac8 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -17,8 +17,8 @@ * * ## Matching * - * The basic state of the code is maintained in an array `m` of `@Match` - * objects. Each `@Match` describes some list of patterns, all of which must + * The basic state of the code is maintained in an array `m` of `Match` + * objects. Each `Match` describes some list of patterns, all of which must * match against the current list of values. If those patterns match, then * the arm listed in the match is the correct arm. A given arm may have * multiple corresponding match entries, one for each alternative that @@ -316,6 +316,7 @@ pub fn variant_opt(bcx: block, pat_id: ast::node_id) } } +#[deriving(Clone)] pub enum TransBindingMode { TrByValue(/*llbinding:*/ ValueRef), TrByRef, @@ -329,6 +330,7 @@ pub enum TransBindingMode { * - `trmode` is the trans binding mode * - `id` is the node id of the binding * - `ty` is the Rust type of the binding */ + #[deriving(Clone)] pub struct BindingInfo { llmatch: ValueRef, trmode: TransBindingMode, @@ -338,15 +340,17 @@ pub struct BindingInfo { pub type BindingsMap = HashMap; +#[deriving(Clone)] pub struct ArmData<'self> { bodycx: block, arm: &'self ast::arm, - bindings_map: BindingsMap + bindings_map: @BindingsMap } +#[deriving(Clone)] pub struct Match<'self> { pats: ~[@ast::pat], - data: @ArmData<'self> + data: ArmData<'self> } pub fn match_to_str(bcx: block, m: &Match) -> ~str { @@ -358,11 +362,11 @@ pub fn match_to_str(bcx: block, m: &Match) -> ~str { } } -pub fn matches_to_str(bcx: block, m: &[@Match]) -> ~str { - fmt!("%?", m.map(|n| match_to_str(bcx, *n))) +pub fn matches_to_str(bcx: block, m: &[Match]) -> ~str { + fmt!("%?", m.map(|n| match_to_str(bcx, n))) } -pub fn has_nested_bindings(m: &[@Match], col: uint) -> bool { +pub fn has_nested_bindings(m: &[Match], col: uint) -> bool { for m.iter().advance |br| { match br.pats[col].node { ast::pat_ident(_, _, Some(_)) => return true, @@ -373,10 +377,10 @@ pub fn has_nested_bindings(m: &[@Match], col: uint) -> bool { } pub fn expand_nested_bindings<'r>(bcx: block, - m: &[@Match<'r>], + m: &[Match<'r>], col: uint, val: ValueRef) - -> ~[@Match<'r>] { + -> ~[Match<'r>] { debug!("expand_nested_bindings(bcx=%s, m=%s, col=%u, val=%?)", bcx.to_str(), matches_to_str(bcx, m), @@ -397,11 +401,12 @@ pub fn expand_nested_bindings<'r>(bcx: block, br.data.bindings_map.get(&path_to_ident(path)); Store(bcx, val, binding_info.llmatch); - @Match {pats: pats, data: br.data} - } - _ => { - *br + Match { + pats: pats, + data: br.data.clone() + } } + _ => (*br).clone(), } } } @@ -419,11 +424,11 @@ pub type enter_pat<'self> = &'self fn(@ast::pat) -> Option<~[@ast::pat]>; pub fn enter_match<'r>(bcx: block, dm: DefMap, - m: &[@Match<'r>], + m: &[Match<'r>], col: uint, val: ValueRef, e: enter_pat) - -> ~[@Match<'r>] { + -> ~[Match<'r>] { debug!("enter_match(bcx=%s, m=%s, col=%u, val=%?)", bcx.to_str(), matches_to_str(bcx, m), @@ -453,7 +458,10 @@ pub fn enter_match<'r>(bcx: block, _ => {} } - result.push(@Match {pats: pats, data: br.data}); + result.push(Match { + pats: pats, + data: br.data.clone() + }); } None => () } @@ -466,10 +474,10 @@ pub fn enter_match<'r>(bcx: block, pub fn enter_default<'r>(bcx: block, dm: DefMap, - m: &[@Match<'r>], + m: &[Match<'r>], col: uint, val: ValueRef) - -> ~[@Match<'r>] { + -> ~[Match<'r>] { debug!("enter_default(bcx=%s, m=%s, col=%u, val=%?)", bcx.to_str(), matches_to_str(bcx, m), @@ -511,12 +519,12 @@ pub fn enter_default<'r>(bcx: block, // wildcards pub fn enter_opt<'r>(bcx: block, - m: &[@Match<'r>], + m: &[Match<'r>], opt: &Opt, col: uint, variant_size: uint, val: ValueRef) - -> ~[@Match<'r>] { + -> ~[Match<'r>] { debug!("enter_opt(bcx=%s, m=%s, col=%u, val=%?)", bcx.to_str(), matches_to_str(bcx, m), @@ -624,11 +632,11 @@ pub fn enter_opt<'r>(bcx: block, pub fn enter_rec_or_struct<'r>(bcx: block, dm: DefMap, - m: &[@Match<'r>], + m: &[Match<'r>], col: uint, fields: &[ast::ident], val: ValueRef) - -> ~[@Match<'r>] { + -> ~[Match<'r>] { debug!("enter_rec_or_struct(bcx=%s, m=%s, col=%u, val=%?)", bcx.to_str(), matches_to_str(bcx, m), @@ -659,11 +667,11 @@ pub fn enter_rec_or_struct<'r>(bcx: block, pub fn enter_tup<'r>(bcx: block, dm: DefMap, - m: &[@Match<'r>], + m: &[Match<'r>], col: uint, val: ValueRef, n_elts: uint) - -> ~[@Match<'r>] { + -> ~[Match<'r>] { debug!("enter_tup(bcx=%s, m=%s, col=%u, val=%?)", bcx.to_str(), matches_to_str(bcx, m), @@ -685,11 +693,11 @@ pub fn enter_tup<'r>(bcx: block, pub fn enter_tuple_struct<'r>(bcx: block, dm: DefMap, - m: &[@Match<'r>], + m: &[Match<'r>], col: uint, val: ValueRef, n_elts: uint) - -> ~[@Match<'r>] { + -> ~[Match<'r>] { debug!("enter_tuple_struct(bcx=%s, m=%s, col=%u, val=%?)", bcx.to_str(), matches_to_str(bcx, m), @@ -711,10 +719,10 @@ pub fn enter_tuple_struct<'r>(bcx: block, pub fn enter_box<'r>(bcx: block, dm: DefMap, - m: &[@Match<'r>], + m: &[Match<'r>], col: uint, val: ValueRef) - -> ~[@Match<'r>] { + -> ~[Match<'r>] { debug!("enter_box(bcx=%s, m=%s, col=%u, val=%?)", bcx.to_str(), matches_to_str(bcx, m), @@ -738,10 +746,10 @@ pub fn enter_box<'r>(bcx: block, pub fn enter_uniq<'r>(bcx: block, dm: DefMap, - m: &[@Match<'r>], + m: &[Match<'r>], col: uint, val: ValueRef) - -> ~[@Match<'r>] { + -> ~[Match<'r>] { debug!("enter_uniq(bcx=%s, m=%s, col=%u, val=%?)", bcx.to_str(), matches_to_str(bcx, m), @@ -765,10 +773,10 @@ pub fn enter_uniq<'r>(bcx: block, pub fn enter_region<'r>(bcx: block, dm: DefMap, - m: &[@Match<'r>], + m: &[Match<'r>], col: uint, val: ValueRef) - -> ~[@Match<'r>] { + -> ~[Match<'r>] { debug!("enter_region(bcx=%s, m=%s, col=%u, val=%?)", bcx.to_str(), matches_to_str(bcx, m), @@ -793,7 +801,7 @@ pub fn enter_region<'r>(bcx: block, // Returns the options in one column of matches. An option is something that // needs to be conditionally matched at runtime; for example, the discriminant // on a set of enum variants or a literal. -pub fn get_options(bcx: block, m: &[@Match], col: uint) -> ~[Opt] { +pub fn get_options(bcx: block, m: &[Match], col: uint) -> ~[Opt] { let ccx = bcx.ccx(); fn add_to_set(tcx: ty::ctxt, set: &mut ~[Opt], val: Opt) { if set.iter().any(|l| opt_eq(tcx, l, &val)) {return;} @@ -943,7 +951,7 @@ pub fn extract_vec_elems(bcx: block, // NB: This function does not collect fields from struct-like enum variants. pub fn collect_record_or_struct_fields(bcx: block, - m: &[@Match], + m: &[Match], col: uint) -> ~[ast::ident] { let mut fields: ~[ast::ident] = ~[]; @@ -971,7 +979,7 @@ pub fn collect_record_or_struct_fields(bcx: block, } pub fn pats_require_rooting(bcx: block, - m: &[@Match], + m: &[Match], col: uint) -> bool { do m.iter().any |br| { @@ -982,7 +990,7 @@ pub fn pats_require_rooting(bcx: block, } pub fn root_pats_as_necessary(mut bcx: block, - m: &[@Match], + m: &[Match], col: uint, val: ValueRef) -> block { @@ -1012,23 +1020,23 @@ macro_rules! any_pat ( ) ) -pub fn any_box_pat(m: &[@Match], col: uint) -> bool { +pub fn any_box_pat(m: &[Match], col: uint) -> bool { any_pat!(m, ast::pat_box(_)) } -pub fn any_uniq_pat(m: &[@Match], col: uint) -> bool { +pub fn any_uniq_pat(m: &[Match], col: uint) -> bool { any_pat!(m, ast::pat_uniq(_)) } -pub fn any_region_pat(m: &[@Match], col: uint) -> bool { +pub fn any_region_pat(m: &[Match], col: uint) -> bool { any_pat!(m, ast::pat_region(_)) } -pub fn any_tup_pat(m: &[@Match], col: uint) -> bool { +pub fn any_tup_pat(m: &[Match], col: uint) -> bool { any_pat!(m, ast::pat_tup(_)) } -pub fn any_tuple_struct_pat(bcx: block, m: &[@Match], col: uint) -> bool { +pub fn any_tuple_struct_pat(bcx: block, m: &[Match], col: uint) -> bool { do m.iter().any |br| { let pat = br.pats[col]; match pat.node { @@ -1046,7 +1054,7 @@ pub fn any_tuple_struct_pat(bcx: block, m: &[@Match], col: uint) -> bool { pub type mk_fail = @fn() -> BasicBlockRef; -pub fn pick_col(m: &[@Match]) -> uint { +pub fn pick_col(m: &[Match]) -> uint { fn score(p: &ast::pat) -> uint { match p.node { ast::pat_lit(_) | ast::pat_enum(_, _) | ast::pat_range(_, _) => 1u, @@ -1201,7 +1209,7 @@ fn insert_lllocals(bcx: block, pub fn compile_guard(bcx: block, guard_expr: @ast::expr, data: &ArmData, - m: &[@Match], + m: &[Match], vals: &[ValueRef], chk: Option) -> block { @@ -1214,8 +1222,10 @@ pub fn compile_guard(bcx: block, let mut bcx = bcx; let mut temp_cleanups = ~[]; - bcx = store_non_ref_bindings(bcx, &data.bindings_map, Some(&mut temp_cleanups)); - bcx = insert_lllocals(bcx, &data.bindings_map, BindLocal, false); + bcx = store_non_ref_bindings(bcx, + data.bindings_map, + Some(&mut temp_cleanups)); + bcx = insert_lllocals(bcx, data.bindings_map, BindLocal, false); let val = unpack_result!(bcx, { do with_scope_result(bcx, guard_expr.info(), @@ -1254,7 +1264,7 @@ pub fn compile_guard(bcx: block, } pub fn compile_submatch(bcx: block, - m: &[@Match], + m: &[Match], vals: &[ValueRef], chk: Option) { debug!("compile_submatch(bcx=%s, m=%s, vals=%?)", @@ -1276,12 +1286,15 @@ pub fn compile_submatch(bcx: block, return; } if m[0].pats.len() == 0u { - let data = m[0].data; + let data = &m[0].data; match data.arm.guard { Some(guard_expr) => { - bcx = compile_guard(bcx, guard_expr, m[0].data, + bcx = compile_guard(bcx, + guard_expr, + &m[0].data, m.slice(1, m.len()), - vals, chk); + vals, + chk); } _ => () } @@ -1291,13 +1304,23 @@ pub fn compile_submatch(bcx: block, let col = pick_col(m); let val = vals[col]; - let m = { - if has_nested_bindings(m, col) { - expand_nested_bindings(bcx, m, col, val) - } else { - m.to_owned() - } - }; + + if has_nested_bindings(m, col) { + let expanded = expand_nested_bindings(bcx, m, col, val); + compile_submatch_continue(bcx, expanded, vals, chk, col, val) + } else { + compile_submatch_continue(bcx, m, vals, chk, col, val) + } +} + +fn compile_submatch_continue(mut bcx: block, + m: &[Match], + vals: &[ValueRef], + chk: Option, + col: uint, + val: ValueRef) { + let tcx = bcx.tcx(); + let dm = tcx.def_map; let vals_left = vec::append(vals.slice(0u, col).to_owned(), vals.slice(col + 1u, vals.len())); @@ -1670,12 +1693,17 @@ pub fn trans_match_inner(scope_cx: block, for arms.iter().advance |arm| { let body = scope_block(bcx, arm.body.info(), "case_body"); let bindings_map = create_bindings_map(bcx, arm.pats[0]); - let arm_data = @ArmData {bodycx: body, - arm: arm, - bindings_map: bindings_map}; - arm_datas.push(arm_data); + let arm_data = ArmData { + bodycx: body, + arm: arm, + bindings_map: @bindings_map + }; + arm_datas.push(arm_data.clone()); for arm.pats.iter().advance |p| { - matches.push(@Match {pats: ~[*p], data: arm_data}); + matches.push(Match { + pats: ~[*p], + data: arm_data.clone(), + }); } } @@ -1703,11 +1731,11 @@ pub fn trans_match_inner(scope_cx: block, // is just to reduce code space. See extensive comment at the start // of the file for more details. if arm_data.arm.guard.is_none() { - bcx = store_non_ref_bindings(bcx, &arm_data.bindings_map, None); + bcx = store_non_ref_bindings(bcx, arm_data.bindings_map, None); } // insert bindings into the lllocals map and add cleanups - bcx = insert_lllocals(bcx, &arm_data.bindings_map, BindLocal, true); + bcx = insert_lllocals(bcx, arm_data.bindings_map, BindLocal, true); bcx = controlflow::trans_block(bcx, &arm_data.arm.body, dest); bcx = trans_block_cleanups(bcx, block_cleanups(arm_data.bodycx)); diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 50f331f7e7d48..0c2ec8c19d087 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -858,7 +858,7 @@ fn mk_rcache() -> creader_cache { return @mut HashMap::new(); } -pub fn new_ty_hash() -> @mut HashMap { +pub fn new_ty_hash() -> @mut HashMap { @mut HashMap::new() } diff --git a/src/libstd/clone.rs b/src/libstd/clone.rs index f24bc002a2b1e..ccab40b2db23d 100644 --- a/src/libstd/clone.rs +++ b/src/libstd/clone.rs @@ -112,7 +112,7 @@ impl DeepClone for ~T { } // FIXME: #6525: should also be implemented for `T: Send + DeepClone` -impl DeepClone for @T { +impl DeepClone for @T { /// Return a deep copy of the managed box. The `Freeze` trait is required to prevent performing /// a deep clone of a potentially cyclical type. #[inline] @@ -120,7 +120,7 @@ impl DeepClone for @T { } // FIXME: #6525: should also be implemented for `T: Send + DeepClone` -impl DeepClone for @mut T { +impl DeepClone for @mut T { /// Return a deep copy of the managed box. The `Freeze` trait is required to prevent performing /// a deep clone of a potentially cyclical type. #[inline] diff --git a/src/libstd/num/num.rs b/src/libstd/num/num.rs index fc199876902f1..f35f495def3a1 100644 --- a/src/libstd/num/num.rs +++ b/src/libstd/num/num.rs @@ -446,12 +446,12 @@ pub fn pow_with_uint+Mul>(radix: uint, pow: uin total } -impl Zero for @mut T { +impl Zero for @mut T { fn zero() -> @mut T { @mut Zero::zero() } fn is_zero(&self) -> bool { (**self).is_zero() } } -impl Zero for @T { +impl Zero for @T { fn zero() -> @T { @Zero::zero() } fn is_zero(&self) -> bool { (**self).is_zero() } } diff --git a/src/libstd/rand.rs b/src/libstd/rand.rs index 76dbc62916817..3574b9c60e6da 100644 --- a/src/libstd/rand.rs +++ b/src/libstd/rand.rs @@ -242,7 +242,7 @@ impl Rand for ~T { fn rand(rng: &mut R) -> ~T { ~rng.gen() } } -impl Rand for @T { +impl Rand for @T { #[inline] fn rand(rng: &mut R) -> @T { @rng.gen() } } diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 230640767c9b4..2f86a0460d1bb 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -414,8 +414,7 @@ pub enum MapChain { // get the map from an env frame -impl MapChain{ - +impl MapChain{ // Constructor. I don't think we need a zero-arg one. fn new(init: ~HashMap) -> @mut MapChain { @mut BaseMapChain(init) diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs index 3d2e0632a3377..014186c9ff415 100644 --- a/src/libsyntax/util/interner.rs +++ b/src/libsyntax/util/interner.rs @@ -21,7 +21,7 @@ pub struct Interner { } // when traits can extend traits, we should extend index to get [] -impl Interner { +impl Interner { pub fn new() -> Interner { Interner { map: @mut HashMap::new(), diff --git a/src/test/auxiliary/cci_nested_lib.rs b/src/test/auxiliary/cci_nested_lib.rs index d53b7d825cb37..b8e831c4503ec 100644 --- a/src/test/auxiliary/cci_nested_lib.rs +++ b/src/test/auxiliary/cci_nested_lib.rs @@ -18,11 +18,15 @@ pub struct alist { data: @mut ~[Entry] } -pub fn alist_add(lst: &alist, k: A, v: B) { +pub fn alist_add(lst: &alist, k: A, v: B) { lst.data.push(Entry{key:k, value:v}); } -pub fn alist_get(lst: &alist, k: A) -> B { +pub fn alist_get( + lst: &alist, + k: A) + -> B { let eq_fn = lst.eq_fn; for lst.data.iter().advance |entry| { if eq_fn(entry.key.clone(), k.clone()) { @@ -33,13 +37,13 @@ pub fn alist_get(lst: &alist, k: A) -> B { } #[inline] -pub fn new_int_alist() -> alist { +pub fn new_int_alist() -> alist { fn eq_int(a: int, b: int) -> bool { a == b } return alist {eq_fn: eq_int, data: @mut ~[]}; } #[inline] -pub fn new_int_alist_2() -> alist { +pub fn new_int_alist_2() -> alist { #[inline] fn eq_int(a: int, b: int) -> bool { a == b } return alist {eq_fn: eq_int, data: @mut ~[]}; diff --git a/src/test/compile-fail/box-static-bound.rs b/src/test/compile-fail/box-static-bound.rs new file mode 100644 index 0000000000000..69d7bedbd3718 --- /dev/null +++ b/src/test/compile-fail/box-static-bound.rs @@ -0,0 +1,10 @@ +fn f(x: T) -> @T { + @x //~ ERROR value may contain borrowed pointers +} + +fn g(x: T) -> @T { + @x // ok +} + +fn main() {} + diff --git a/src/test/compile-fail/kindck-owned-trait.rs b/src/test/compile-fail/kindck-owned-trait.rs index 73d59ff8af218..ef9cbfe5dd932 100644 --- a/src/test/compile-fail/kindck-owned-trait.rs +++ b/src/test/compile-fail/kindck-owned-trait.rs @@ -14,6 +14,7 @@ fn to_foo(t: T) -> @foo { @t as @foo //~^ ERROR value may contain borrowed pointers; add `'static` bound //~^^ ERROR cannot pack type + //~^^^ ERROR value may contain borrowed pointers } fn to_foo2(t: T) -> @foo { diff --git a/src/test/compile-fail/kindck-owned.rs b/src/test/compile-fail/kindck-owned.rs index c3c929a228883..2dfdb2629f7f4 100644 --- a/src/test/compile-fail/kindck-owned.rs +++ b/src/test/compile-fail/kindck-owned.rs @@ -23,5 +23,6 @@ fn main() { copy2(&x); //~ ERROR does not fulfill `'static` copy2(@3); - copy2(@&x); //~ ERROR does not fulfill `'static` + copy2(@&x); //~ ERROR value may contain borrowed pointers + //~^ ERROR does not fulfill `'static` } diff --git a/src/test/run-pass/alignment-gep-tup-like-2.rs b/src/test/run-pass/alignment-gep-tup-like-2.rs index 1d910023a6368..e924c31bad6b5 100644 --- a/src/test/run-pass/alignment-gep-tup-like-2.rs +++ b/src/test/run-pass/alignment-gep-tup-like-2.rs @@ -18,12 +18,16 @@ struct Rec { rec: Option<@mut RecEnum> } -fn make_cycle(a: A) { +fn make_cycle(a: A) { let g: @mut RecEnum = @mut RecEnum(Rec {val: a, rec: None}); g.rec = Some(g); } -fn f(a: A, b: B) -> @fn() -> (A, B) { +fn f( + a: A, + b: B) + -> @fn() -> (A, B) { let result: @fn() -> (A, B) = || (a.clone(), b.clone()); result } diff --git a/src/test/run-pass/generic-box.rs b/src/test/run-pass/generic-box.rs index a3e933f3ceb03..ce1582b3c3c7e 100644 --- a/src/test/run-pass/generic-box.rs +++ b/src/test/run-pass/generic-box.rs @@ -10,7 +10,7 @@ -fn box(x: Box) -> @Box { return @x; } +fn box(x: Box) -> @Box { return @x; } struct Box {x: T, y: T, z: T} diff --git a/src/test/run-pass/generic-exterior-box.rs b/src/test/run-pass/generic-exterior-box.rs index b7fe704749c74..795c73007d55e 100644 --- a/src/test/run-pass/generic-exterior-box.rs +++ b/src/test/run-pass/generic-exterior-box.rs @@ -12,7 +12,7 @@ struct Recbox {x: @T} -fn reclift(t: T) -> Recbox { return Recbox {x: @t}; } +fn reclift(t: T) -> Recbox { return Recbox {x: @t}; } pub fn main() { let foo: int = 17; diff --git a/src/test/run-pass/infer-with-expected.rs b/src/test/run-pass/infer-with-expected.rs index 9dfe7e45c1194..6f2fd54bc9cbc 100644 --- a/src/test/run-pass/infer-with-expected.rs +++ b/src/test/run-pass/infer-with-expected.rs @@ -14,12 +14,12 @@ // happen.) fn eat_tup(_r: ~@(int, @fn(Pair) -> int)) {} -fn eat_rec(_r: @~Rec) {} +fn eat_rec(_r: ~Rec) {} struct Rec<'self> { a: int, b: &'self fn(Pair) -> int } struct Pair { x: int, y: int } pub fn main() { eat_tup(~@(10, |a| a.x )); - eat_rec(@~Rec{a: 10, b: |a| a.x }); + eat_rec(~Rec{a: 10, b: |a| a.x }); } diff --git a/src/test/run-pass/issue-3447.rs b/src/test/run-pass/issue-3447.rs index 711dfd3778b5b..64483ab80a4f0 100644 --- a/src/test/run-pass/issue-3447.rs +++ b/src/test/run-pass/issue-3447.rs @@ -8,13 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct list<'self, T> { - element: &'self T, - next: Option<@mut list<'self, T>> +static S: &'static str = "str"; + +struct list { + element: T, + next: Option<@mut list> } -impl<'self, T> list<'self, T>{ - pub fn addEnd(&mut self, element: &'self T) { +impl list { + pub fn addEnd(&mut self, element: T) { let newList = list { element: element, next: None @@ -25,10 +27,9 @@ impl<'self, T> list<'self, T>{ } pub fn main() { - let s = @"str"; let ls = list { - element: &s, + element: S, next: None }; - println(*ls.element); + println(ls.element); } diff --git a/src/test/run-pass/kindck-owned-trait-contains-1.rs b/src/test/run-pass/kindck-owned-trait-contains-1.rs index 1370aea6df50d..29a89a65a9b17 100644 --- a/src/test/run-pass/kindck-owned-trait-contains-1.rs +++ b/src/test/run-pass/kindck-owned-trait-contains-1.rs @@ -10,19 +10,19 @@ trait repeat { fn get(&self) -> A; } -impl repeat for @A { +impl repeat for @A { fn get(&self) -> A { (**self).clone() } } -fn repeater(v: @A) -> @repeat: { +fn repeater(v: @A) -> @repeat: { // Note: owned kind is not necessary as A appears in the trait type @v as @repeat: // No } pub fn main() { - let x = &3; + let x = 3; let y = repeater(@x); - assert_eq!(*x, *(y.get())); + assert_eq!(x, y.get()); } diff --git a/src/test/run-pass/log-linearized.rs b/src/test/run-pass/log-linearized.rs index 0f388489000fe..97b8c77c31567 100644 --- a/src/test/run-pass/log-linearized.rs +++ b/src/test/run-pass/log-linearized.rs @@ -19,12 +19,12 @@ struct Smallintmap {v: ~[option]} struct V { v: ~[option] } -fn mk() -> @mut Smallintmap { +fn mk() -> @mut Smallintmap { let mut v: ~[option] = ~[]; return @mut Smallintmap {v: v}; } -fn f() { +fn f() { let mut sim = mk::(); error!(sim); } diff --git a/src/test/run-pass/regions-trait.rs b/src/test/run-pass/regions-trait.rs deleted file mode 100644 index 049d5305ca427..0000000000000 --- a/src/test/run-pass/regions-trait.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Ctxt { v: uint } - -trait get_ctxt<'self> { - fn get_ctxt(&self) -> &'self Ctxt; -} - -struct HasCtxt<'self> { c: &'self Ctxt } - -impl<'self> get_ctxt<'self> for HasCtxt<'self> { - fn get_ctxt(&self) -> &'self Ctxt { - self.c - } -} - -fn get_v(gc: @get_ctxt:) -> uint { - gc.get_ctxt().v -} - -pub fn main() { - let ctxt = Ctxt { v: 22 }; - let hc = HasCtxt { c: &ctxt }; - - assert_eq!(get_v(@hc as @get_ctxt:), 22); -}