Skip to content

Commit 4c25b48

Browse files
committed
---
yaml --- r: 23120 b: refs/heads/master c: 1b2d91c h: refs/heads/master v: v3
1 parent 4e512e6 commit 4c25b48

File tree

7 files changed

+165
-138
lines changed

7 files changed

+165
-138
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: fe8c8ad5827e0156490d78257b5e33cf9bc1281a
2+
refs/heads/master: 1b2d91c79da93461563428d25ae09bbeb59ed292
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/src/libcore/result.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ impl<T: copy, E: copy> result<T, E> {
250250
* }
251251
*/
252252
fn map_vec<T,U:copy,V:copy>(
253-
ts: ~[T], op: fn(T) -> result<V,U>) -> result<~[V],U> {
253+
ts: &[T], op: fn(T) -> result<V,U>) -> result<~[V],U> {
254254

255255
let mut vs: ~[V] = ~[];
256256
vec::reserve(vs, vec::len(ts));
@@ -284,7 +284,7 @@ fn map_opt<T,U:copy,V:copy>(
284284
* used in 'careful' code contexts where it is both appropriate and easy
285285
* to accommodate an error like the vectors being of different lengths.
286286
*/
287-
fn map_vec2<S,T,U:copy,V:copy>(ss: ~[S], ts: ~[T],
287+
fn map_vec2<S,T,U:copy,V:copy>(ss: &[S], ts: &[T],
288288
op: fn(S,T) -> result<V,U>) -> result<~[V],U> {
289289

290290
assert vec::same_length(ss, ts);
@@ -307,7 +307,7 @@ fn map_vec2<S,T,U:copy,V:copy>(ss: ~[S], ts: ~[T],
307307
* error. This could be implemented using `map2()` but it is more efficient
308308
* on its own as no result vector is built.
309309
*/
310-
fn iter_vec2<S,T,U:copy>(ss: ~[S], ts: ~[T],
310+
fn iter_vec2<S,T,U:copy>(ss: &[S], ts: &[T],
311311
op: fn(S,T) -> result<(),U>) -> result<(),U> {
312312

313313
assert vec::same_length(ss, ts);

trunk/src/libcore/vec.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export capacity;
1717
export len;
1818
export from_fn;
1919
export from_elem;
20+
export from_slice;
2021
export build, build_sized;
2122
export to_mut;
2223
export from_mut;
@@ -211,6 +212,11 @@ pure fn from_elem<T: copy>(n_elts: uint, t: T) -> ~[T] {
211212
return v;
212213
}
213214

215+
/// Creates a new unique vector with the same contents as the slice
216+
pure fn from_slice<T: copy>(t: &[T]) -> ~[T] {
217+
from_fn(t.len(), |i| t[i])
218+
}
219+
214220
/**
215221
* Builds a vector by calling a provided function with an argument
216222
* function that pushes an element to the back of a vector.

trunk/src/rustc/middle/ty.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,16 @@ fn param_bounds_to_kind(bounds: param_bounds) -> kind {
532532
kind
533533
}
534534

535+
/// A polytype.
536+
///
537+
/// - `bounds`: The list of bounds for each type parameter. The length of the
538+
/// list also tells you how many type parameters there are.
539+
///
540+
/// - `rp`: true if the type is region-parameterized. Types can have at
541+
/// most one region parameter, always called `&self`.
542+
///
543+
/// - `ty`: the base type. May have reference to the (unsubstituted) bound
544+
/// region `&self` or to (unsubstituted) ty_param types
535545
type ty_param_bounds_and_ty = {bounds: @~[param_bounds],
536546
rp: bool,
537547
ty: t};
@@ -1532,7 +1542,7 @@ pure fn kind_is_owned(k: kind) -> bool {
15321542
15331543
fn proto_kind(p: proto) -> kind {
15341544
match p {
1535-
ast::proto_block => kind_noncopyable(),
1545+
ast::proto_block => kind_noncopyable() | kind_(KIND_MASK_DEFAULT_MODE),
15361546
ast::proto_box => kind_safe_for_default_mode() | kind_owned(),
15371547
ast::proto_uniq => kind_send_copy() | kind_owned(),
15381548
ast::proto_bare => kind_safe_for_default_mode_send() | kind_const() |

trunk/src/rustc/middle/typeck/check.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,16 @@ fn check_bare_fn(ccx: @crate_ctxt,
175175
id: ast::node_id,
176176
self_info: option<self_info>) {
177177
let fty = ty::node_id_to_type(ccx.tcx, id);
178-
let fn_ty = match check ty::get(fty).struct { ty::ty_fn(f) => f };
179-
check_fn(ccx, self_info, fn_ty, decl, body, false, none);
178+
match check ty::get(fty).struct {
179+
ty::ty_fn(ref fn_ty) => {
180+
check_fn(ccx, self_info, fn_ty, decl, body, false, none)
181+
}
182+
}
180183
}
181184

182185
fn check_fn(ccx: @crate_ctxt,
183186
self_info: option<self_info>,
184-
fn_ty: ty::fn_ty,
187+
fn_ty: &ty::fn_ty,
185188
decl: ast::fn_decl,
186189
body: ast::blk,
187190
indirect_ret: bool,
@@ -620,13 +623,15 @@ impl @fn_ctxt {
620623

621624
fn mk_assignty(expr: @ast::expr, borrow_lb: ast::node_id,
622625
sub: ty::t, sup: ty::t) -> result<(), ty::type_err> {
623-
let anmnt = {expr_id: expr.id, span: expr.span, borrow_lb: borrow_lb};
626+
let anmnt = &{expr_id: expr.id, span: expr.span,
627+
borrow_lb: borrow_lb};
624628
infer::mk_assignty(self.infcx, anmnt, sub, sup)
625629
}
626630

627631
fn can_mk_assignty(expr: @ast::expr, borrow_lb: ast::node_id,
628632
sub: ty::t, sup: ty::t) -> result<(), ty::type_err> {
629-
let anmnt = {expr_id: expr.id, span: expr.span, borrow_lb: borrow_lb};
633+
let anmnt = &{expr_id: expr.id, span: expr.span,
634+
borrow_lb: borrow_lb};
630635
infer::can_mk_assignty(self.infcx, anmnt, sub, sup)
631636
}
632637

@@ -821,7 +826,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
821826
// functions. Therefore, we match one level of structure.
822827
let fn_ty =
823828
match structure_of(fcx, sp, in_fty) {
824-
sty @ ty::ty_fn(fn_ty) => {
829+
sty @ ty::ty_fn(ref fn_ty) => {
825830
replace_bound_regions_in_fn_ty(
826831
fcx.ccx.tcx, @nil, none, fn_ty,
827832
|_br| fcx.infcx.next_region_var_nb()).fn_ty
@@ -1124,7 +1129,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
11241129
// what's going on here.
11251130
let expected_tys = do unpack_expected(fcx, expected) |sty| {
11261131
match sty {
1127-
ty::ty_fn(fn_ty) => {
1132+
ty::ty_fn(ref fn_ty) => {
11281133
let {fn_ty, _} =
11291134
replace_bound_regions_in_fn_ty(
11301135
tcx, @nil, none, fn_ty,
@@ -1146,7 +1151,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
11461151

11471152
fcx.write_ty(expr.id, fty);
11481153

1149-
check_fn(fcx.ccx, fcx.self_info, fn_ty, decl, body,
1154+
check_fn(fcx.ccx, fcx.self_info, &fn_ty, decl, body,
11501155
is_loop_body, some(fcx));
11511156
}
11521157

trunk/src/rustc/middle/typeck/check/regionmanip.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// #[warn(deprecated_mode)];
2+
// #[warn(deprecated_pattern)];
3+
14
import syntax::print::pprust::{expr_to_str};
25

36
// Helper functions related to manipulating region types.
@@ -6,7 +9,7 @@ fn replace_bound_regions_in_fn_ty(
69
tcx: ty::ctxt,
710
isr: isr_alist,
811
self_info: option<self_info>,
9-
fn_ty: ty::fn_ty,
12+
fn_ty: &ty::fn_ty,
1013
mapf: fn(ty::bound_region) -> ty::region) ->
1114
{isr: isr_alist, self_info: option<self_info>, fn_ty: ty::fn_ty} {
1215

@@ -17,22 +20,22 @@ fn replace_bound_regions_in_fn_ty(
1720
none => none
1821
};
1922

20-
let mut all_tys = ty::tys_in_fn_ty(fn_ty);
23+
let mut all_tys = ty::tys_in_fn_ty(*fn_ty);
2124

2225
for self_ty.each |t| { vec::push(all_tys, t) }
2326

2427
debug!{"replace_bound_regions_in_fn_ty(self_info.self_ty=%?, fn_ty=%s, \
2528
all_tys=%?)",
2629
self_ty.map(|t| ty_to_str(tcx, t)),
27-
ty_to_str(tcx, ty::mk_fn(tcx, fn_ty)),
30+
ty_to_str(tcx, ty::mk_fn(tcx, *fn_ty)),
2831
all_tys.map(|t| ty_to_str(tcx, t))};
2932
let _i = indenter();
3033

3134
let isr = do create_bound_region_mapping(tcx, isr, all_tys) |br| {
3235
debug!{"br=%?", br};
3336
mapf(br)
3437
};
35-
let t_fn = ty::fold_sty_to_ty(tcx, ty::ty_fn(fn_ty), |t| {
38+
let t_fn = ty::fold_sty_to_ty(tcx, ty::ty_fn(*fn_ty), |t| {
3639
replace_bound_regions(tcx, isr, t)
3740
});
3841
let t_self = self_ty.map(|t| replace_bound_regions(tcx, isr, t));

0 commit comments

Comments
 (0)