Skip to content

Commit 0ac12ba

Browse files
committed
---
yaml --- r: 44860 b: refs/heads/master c: ca9549b h: refs/heads/master v: v3
1 parent 6828587 commit 0ac12ba

File tree

7 files changed

+30
-28
lines changed

7 files changed

+30
-28
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: 382143abd871d9b2c73df08ffd2928c44f314ab3
2+
refs/heads/master: ca9549bdfc3dd969e9182d58038f90bbef026ded
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d9689399d091c3265f00434a69c551a61c28dc
55
refs/heads/try: ef355f6332f83371e4acf04fc4eb940ab41d78d3

trunk/doc/rust.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -908,11 +908,6 @@ function defined above on `[1, 2]` will instantiate type parameter `T`
908908
with `int`, and require the closure parameter to have type
909909
`fn(int)`.
910910

911-
The type parameters can also be explicitly supplied in a trailing
912-
[path](#paths) component after the function name. This might be necessary
913-
if there is not sufficient context to determine the type parameters. For
914-
example, `sys::size_of::<u32>() == 4`.
915-
916911
Since a parameter type is opaque to the generic function, the set of
917912
operations that can be performed on it is limited. Values of parameter
918913
type can always be moved, but they can only be copied when the
@@ -2045,14 +2040,12 @@ an optional reference slot to serve as the function's output, bound to the
20452040
`lval` on the right hand side of the call. If the function eventually returns,
20462041
then the expression completes.
20472042

2048-
Some examples of call expressions:
2043+
An example of a call expression:
20492044

20502045
~~~~
20512046
# fn add(x: int, y: int) -> int { 0 }
2052-
# use core::from_str::FromStr::from_str;
20532047
20542048
let x: int = add(1, 2);
2055-
let pi = from_str::<f32>("3.14");
20562049
~~~~
20572050

20582051
### Lambda expressions

trunk/src/librustc/middle/trans/callee.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ use middle::trans::inline;
3939
use middle::trans::meth;
4040
use middle::trans::monomorphize;
4141
use middle::trans::type_of;
42-
use middle::ty::ty_to_str;
4342
use middle::ty;
4443
use middle::typeck;
4544
use util::common::indenter;
@@ -731,7 +730,7 @@ pub fn trans_arg_expr(bcx: block,
731730

732731
ast::by_copy => {
733732
debug!("by copy arg with type %s, storing to scratch",
734-
ty_to_str(ccx.tcx, arg_datum.ty));
733+
bcx.ty_to_str(arg_datum.ty));
735734
let scratch = scratch_datum(bcx, arg_datum.ty, false);
736735

737736
arg_datum.store_to_datum(bcx, arg_expr.id,

trunk/src/libsyntax/ext/auto_encode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,8 @@ fn mk_impl(
460460
let ty = cx.ty_path(
461461
span,
462462
~[ident],
463-
generics.ty_params.map(
464-
|tp| cx.ty_path(span, ~[tp.ident], ~[])).to_vec()
463+
opt_vec::take_vec(generics.ty_params.map(
464+
|tp| cx.ty_path(span, ~[tp.ident], ~[])))
465465
);
466466

467467
let generics = ast::Generics {

trunk/src/libsyntax/ext/pipes/ast_builder.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -394,13 +394,15 @@ impl ext_ctxt_ast_builder for ext_ctxt {
394394
}
395395

396396
fn ty_vars(&self, ty_params: &OptVec<ast::TyParam>) -> ~[@ast::Ty] {
397-
ty_params.map(|p| self.ty_path_ast_builder(
398-
path(~[p.ident], dummy_sp()))).to_vec()
397+
opt_vec::take_vec(
398+
ty_params.map(|p| self.ty_path_ast_builder(
399+
path(~[p.ident], dummy_sp()))))
399400
}
400401

401402
fn ty_vars_global(&self,
402403
ty_params: &OptVec<ast::TyParam>) -> ~[@ast::Ty] {
403-
ty_params.map(|p| self.ty_path_ast_builder(
404-
path(~[p.ident], dummy_sp()))).to_vec()
404+
opt_vec::take_vec(
405+
ty_params.map(|p| self.ty_path_ast_builder(
406+
path(~[p.ident], dummy_sp()))))
405407
}
406408
}

trunk/src/libsyntax/opt_vec.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ pub fn with<T>(+t: T) -> OptVec<T> {
3131
Vec(~[t])
3232
}
3333

34+
pub fn from<T>(+t: ~[T]) -> OptVec<T> {
35+
if t.len() == 0 {
36+
Empty
37+
} else {
38+
Vec(t)
39+
}
40+
}
41+
3442
impl<T> OptVec<T> {
3543
fn push(&mut self, +t: T) {
3644
match *self {
@@ -70,12 +78,12 @@ impl<T> OptVec<T> {
7078
Vec(ref v) => v.len()
7179
}
7280
}
81+
}
7382

74-
pure fn to_vec(self) -> ~[T] {
75-
match self {
76-
Empty => ~[],
77-
Vec(v) => v
78-
}
83+
pub fn take_vec<T>(+v: OptVec<T>) -> ~[T] {
84+
match v {
85+
Empty => ~[],
86+
Vec(v) => v
7987
}
8088
}
8189

trunk/src/libsyntax/parse/parser.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,7 @@ pub impl Parser {
11571157
let remaining_exprs =
11581158
self.parse_seq_to_end(token::RBRACKET,
11591159
seq_sep_trailing_allowed(token::COMMA),
1160-
|p| p.parse_expr()).to_vec();
1160+
|p| p.parse_expr());
11611161
ex = expr_vec(~[first_expr] + remaining_exprs, mutbl);
11621162
} else {
11631163
// Vector with one element.
@@ -1419,7 +1419,7 @@ pub impl Parser {
14191419
vec::append(
14201420
self.parse_seq_to_before_end(
14211421
ket, seq_sep_none(),
1422-
|p| p.parse_token_tree()).to_vec(),
1422+
|p| p.parse_token_tree()),
14231423
// the close delimiter:
14241424
~[parse_any_tt_tok(self)])))
14251425
}
@@ -2727,7 +2727,7 @@ pub impl Parser {
27272727
let result = self.parse_seq_to_gt(
27282728
Some(token::COMMA),
27292729
|p| p.parse_ty(false));
2730-
result.to_vec()
2730+
opt_vec::take_vec(result)
27312731
}
27322732

27332733
fn parse_fn_decl(parse_arg_fn: fn(Parser) -> arg_or_capture_item)
@@ -2819,7 +2819,7 @@ pub impl Parser {
28192819
args_or_capture_items =
28202820
self.parse_seq_to_before_end(token::RPAREN,
28212821
sep,
2822-
parse_arg_fn).to_vec();
2822+
parse_arg_fn);
28232823
}
28242824
token::RPAREN => {
28252825
args_or_capture_items = ~[];
@@ -2835,7 +2835,7 @@ pub impl Parser {
28352835
args_or_capture_items =
28362836
self.parse_seq_to_before_end(token::RPAREN,
28372837
sep,
2838-
parse_arg_fn).to_vec();
2838+
parse_arg_fn);
28392839
}
28402840

28412841
self.expect(token::RPAREN);
@@ -3032,7 +3032,7 @@ pub impl Parser {
30323032
fn parse_trait_ref_list(ket: token::Token) -> ~[@trait_ref] {
30333033
self.parse_seq_to_before_end(
30343034
ket, seq_sep_none(),
3035-
|p| p.parse_trait_ref()).to_vec()
3035+
|p| p.parse_trait_ref())
30363036
}
30373037

30383038
fn parse_item_struct() -> item_info {

0 commit comments

Comments
 (0)