Skip to content

Commit 5ffd98e

Browse files
committed
---
yaml --- r: 41967 b: refs/heads/master c: d912d53 h: refs/heads/master i: 41965: 61ae8be 41963: 1f2a5eb 41959: fef9b59 41951: 7f7d825 v: v3
1 parent a42bbd7 commit 5ffd98e

File tree

20 files changed

+94
-133
lines changed

20 files changed

+94
-133
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: 69fff85ec83029d8889a0c2877ee5a9798140d1f
2+
refs/heads/master: d912d53ea9921c4fc9044c657ddcb3e044617fa9
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2f46b763da2c098913884f101b6d71d69af41b49
55
refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650

trunk/AUTHORS.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,5 +148,4 @@ Vincent Belliard <[email protected]>
148148
Wade Mealing <[email protected]>
149149
William Ting <[email protected]>
150150
Yasuhiro Fujii <[email protected]>
151-
Youngsoo Son <[email protected]>
152151
Zack Corr <[email protected]>

trunk/doc/rust.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ let log loop
222222
match mod move mut
223223
priv pub pure
224224
ref return
225-
self static struct super
225+
self static struct
226226
true trait type
227227
unsafe use
228228
while

trunk/src/libcore/hashmap.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ pub mod linear {
6060
((capacity as float) * 3. / 4.) as uint
6161
}
6262

63+
pub fn LinearMap<K:Eq Hash,V>() -> LinearMap<K,V> {
64+
linear_map_with_capacity(INITIAL_CAPACITY)
65+
}
66+
6367
pub fn linear_map_with_capacity<K:Eq Hash,V>(
6468
initial_capacity: uint) -> LinearMap<K,V> {
6569
let r = rand::Rng();
@@ -347,8 +351,7 @@ pub mod linear {
347351
}
348352
}
349353

350-
pub impl<K:Hash IterBytes Eq,V> LinearMap<K,V> {
351-
/// Create an empty LinearMap
354+
impl<K:Hash IterBytes Eq,V> LinearMap<K,V> {
352355
static fn new() -> LinearMap<K, V> {
353356
linear_map_with_capacity(INITIAL_CAPACITY)
354357
}
@@ -492,7 +495,7 @@ pub mod linear {
492495

493496
pub impl <T: Hash IterBytes Eq> LinearSet<T> {
494497
/// Create an empty LinearSet
495-
static fn new() -> LinearSet<T> { LinearSet{map: LinearMap::new()} }
498+
static fn new() -> LinearSet<T> { LinearSet{map: LinearMap()} }
496499
}
497500
}
498501

trunk/src/librustc/middle/resolve.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
use core::prelude::*;
1212

13-
use driver::session;
1413
use driver::session::Session;
1514
use metadata::csearch::{each_path, get_method_names_if_trait};
1615
use metadata::csearch::{get_static_methods_if_impl, get_type_name_if_impl};
@@ -3932,10 +3931,7 @@ impl Resolver {
39323931
item_fn(ref fn_decl, _, ref ty_params, ref block) => {
39333932
// If this is the main function, we must record it in the
39343933
// session.
3935-
// FIXME #4404 android JNI hacks
3936-
if !self.session.building_library ||
3937-
self.session.targ_cfg.os == session::os_android {
3938-
3934+
if !self.session.building_library {
39393935
if self.attr_main_fn.is_none() &&
39403936
item.ident == special_idents::main {
39413937

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ use middle::trans::shape::*;
6262
use middle::trans::tvec;
6363
use middle::trans::type_of::*;
6464
use util::common::indenter;
65+
use util::common::is_main_name;
6566
use util::ppaux::{ty_to_str, ty_to_short_str};
6667
use util::ppaux;
6768

@@ -2190,9 +2191,14 @@ fn is_main_fn(sess: &Session, node_id: ast::node_id) -> bool {
21902191

21912192
// Create a _rust_main(args: ~[str]) function which will be called from the
21922193
// runtime rust_start function
2193-
fn create_main_wrapper(ccx: @crate_ctxt, _sp: span, main_llfn: ValueRef) {
2194+
fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef) {
2195+
2196+
if ccx.main_fn != None::<ValueRef> {
2197+
ccx.sess.span_fatal(sp, ~"multiple 'main' functions");
2198+
}
21942199

21952200
let llfn = create_main(ccx, main_llfn);
2201+
ccx.main_fn = Some(llfn);
21962202
create_entry_fn(ccx, llfn);
21972203

21982204
fn create_main(ccx: @crate_ctxt, main_llfn: ValueRef) -> ValueRef {
@@ -3002,6 +3008,7 @@ fn trans_crate(sess: session::Session,
30023008
exp_map2: emap2,
30033009
reachable: reachable,
30043010
item_symbols: HashMap(),
3011+
mut main_fn: None::<ValueRef>,
30053012
link_meta: link_meta,
30063013
enum_sizes: ty::new_ty_hash(),
30073014
discrims: HashMap(),

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ struct crate_ctxt {
163163
exp_map2: resolve::ExportMap2,
164164
reachable: reachable::map,
165165
item_symbols: HashMap<ast::node_id, ~str>,
166+
mut main_fn: Option<ValueRef>,
166167
link_meta: link_meta,
167168
enum_sizes: HashMap<ty::t, uint>,
168169
discrims: HashMap<ast::def_id, ValueRef>,

trunk/src/librustc/middle/ty.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,13 +1659,13 @@ fn subst(cx: ctxt,
16591659
}
16601660
}
16611661
1662-
// Performs substitutions on a set of substitutions (result = sup(sub)) to
1662+
// Performs substitutions on a set of substitutions (result = super(sub)) to
16631663
// yield a new set of substitutions. This is used in trait inheritance.
1664-
fn subst_substs(cx: ctxt, sup: &substs, sub: &substs) -> substs {
1664+
fn subst_substs(cx: ctxt, super: &substs, sub: &substs) -> substs {
16651665
{
1666-
self_r: sup.self_r,
1667-
self_ty: sup.self_ty.map(|typ| subst(cx, sub, *typ)),
1668-
tps: sup.tps.map(|typ| subst(cx, sub, *typ))
1666+
self_r: super.self_r,
1667+
self_ty: super.self_ty.map(|typ| subst(cx, sub, *typ)),
1668+
tps: super.tps.map(|typ| subst(cx, sub, *typ))
16691669
}
16701670
}
16711671

trunk/src/librustc/middle/typeck/check/mod.rs

Lines changed: 17 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,7 +1497,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
14971497
match ty::get(lhs_resolved_t).sty {
14981498
ty::ty_fn(_) => {
14991499
tcx.sess.span_note(
1500-
ex.span, ~"did you forget the `do` keyword for the call?");
1500+
ex.span, ~"did you forget the 'do' keyword for the call?");
15011501
}
15021502
_ => ()
15031503
}
@@ -2207,33 +2207,23 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
22072207
Some(ty::ty_fn(ref fty)) => {
22082208
match fcx.mk_subty(false, expr.span,
22092209
(*fty).sig.output, ty::mk_bool(tcx)) {
2210-
result::Ok(_) =>
2211-
ty::mk_fn(tcx, FnTyBase {
2212-
meta: (*fty).meta,
2213-
sig: FnSig {output: ty::mk_nil(tcx),
2214-
../*bad*/copy (*fty).sig}
2215-
}),
2210+
result::Ok(_) => (),
22162211
result::Err(_) => {
22172212
fcx.type_error_message(expr.span,
22182213
|actual| {
2219-
fmt!("A `for` loop iterator should expect a \
2220-
closure that returns `bool`. This iterator \
2221-
expects a closure that returns `%s`. %s",
2222-
actual, if ty::type_is_nil((*fty).sig.output) {
2223-
"\nDid you mean to use `do` instead of \
2224-
`for`?" } else { "" } )
2214+
fmt!("a `loop` function's last argument \
2215+
should return `bool`, not `%s`", actual)
22252216
},
22262217
(*fty).sig.output, None);
22272218
err_happened = true;
2228-
// Kind of a hack: create a function type with the result
2229-
// replaced with ty_err, to suppress derived errors.
2230-
let t = ty::replace_fn_return_type(tcx, ty::mk_fn(tcx,
2231-
copy *fty),
2232-
ty::mk_err(tcx));
22332219
fcx.write_ty(id, ty::mk_err(tcx));
2234-
t
22352220
}
22362221
}
2222+
ty::mk_fn(tcx, FnTyBase {
2223+
meta: (*fty).meta,
2224+
sig: FnSig {output: ty::mk_nil(tcx),
2225+
../*bad*/copy (*fty).sig}
2226+
})
22372227
}
22382228
_ =>
22392229
match expected {
@@ -2255,22 +2245,14 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
22552245
}
22562246
};
22572247
match b.node {
2258-
ast::expr_fn_block(ref decl, ref body, cap_clause) => {
2259-
// If an error occurred, we pretend this isn't a for
2260-
// loop, so as to assign types to all nodes while also
2261-
// propagating ty_err throughout so as to suppress
2262-
// derived errors. If we passed in ForLoop in the
2263-
// error case, we'd potentially emit a spurious error
2264-
// message because of the indirect_ret_ty.
2265-
let fn_kind = if err_happened { Vanilla }
2266-
else { ForLoop };
2267-
check_expr_fn(fcx, b, None,
2268-
decl, *body, fn_kind, Some(inner_ty));
2269-
demand::suptype(fcx, b.span, inner_ty, fcx.expr_ty(b));
2270-
capture::check_capture_clause(tcx, b.id, cap_clause);
2271-
}
2272-
// argh
2273-
_ => fail ~"expr_fn_block"
2248+
ast::expr_fn_block(ref decl, ref body, cap_clause) => {
2249+
check_expr_fn(fcx, b, None,
2250+
decl, *body, ForLoop, Some(inner_ty));
2251+
demand::suptype(fcx, b.span, inner_ty, fcx.expr_ty(b));
2252+
capture::check_capture_clause(tcx, b.id, cap_clause);
2253+
}
2254+
// argh
2255+
_ => fail ~"expr_fn_block"
22742256
}
22752257
let block_ty = structurally_resolved_type(
22762258
fcx, expr.span, fcx.node_ty(b.id));

trunk/src/librustc/util/common.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ fn local_rhs_span(l: @ast::local, def: span) -> span {
101101
}
102102
}
103103

104+
fn is_main_name(path: syntax::ast_map::path) -> bool {
105+
vec::last(path) == syntax::ast_map::path_name(
106+
syntax::parse::token::special_idents::main
107+
)
108+
}
109+
104110
fn pluralize(n: uint, +s: ~str) -> ~str {
105111
if n == 1 { s }
106112
else { str::concat([s, ~"s"]) }

trunk/src/libstd/priority_queue.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ impl <T: Ord> PriorityQueue<T> {
4747
if self.is_empty() { None } else { Some(self.top()) }
4848
}
4949

50-
/// Returns true if a queue contains some elements
51-
pure fn is_not_empty(&self) -> bool { self.data.is_not_empty() }
52-
5350
/// Returns the number of elements the queue can hold without reallocating
5451
pure fn capacity(&self) -> uint { vec::capacity(&self.data) }
5552

@@ -62,7 +59,7 @@ impl <T: Ord> PriorityQueue<T> {
6259
/// Pop the greatest item from the queue - fails if empty
6360
fn pop(&mut self) -> T {
6461
let mut item = self.data.pop();
65-
if self.is_not_empty() { item <-> self.data[0]; self.siftdown(0); }
62+
if !self.is_empty() { item <-> self.data[0]; self.siftdown(0); }
6663
item
6764
}
6865

@@ -80,7 +77,7 @@ impl <T: Ord> PriorityQueue<T> {
8077
/// Optimized version of a push followed by a pop
8178
fn push_pop(&mut self, item: T) -> T {
8279
let mut item = item;
83-
if self.is_not_empty() && self.data[0] > item {
80+
if !self.is_empty() && self.data[0] > item {
8481
item <-> self.data[0];
8582
self.siftdown(0);
8683
}
@@ -189,7 +186,7 @@ mod tests {
189186
let data = ~[2, 4, 6, 2, 1, 8, 10, 3, 5, 7, 0, 9, 1];
190187
let mut sorted = merge_sort(data, le);
191188
let mut heap = from_vec(data);
192-
while heap.is_not_empty() {
189+
while !heap.is_empty() {
193190
assert *heap.top() == sorted.last();
194191
assert heap.pop() == sorted.pop();
195192
}

trunk/src/libstd/workcache.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ impl Context {
259259
static fn new(db: @Mut<Database>,
260260
lg: @Mut<Logger>,
261261
cfg: @json::Object) -> Context {
262-
Context{db: db, logger: lg, cfg: cfg, freshness: LinearMap::new()}
262+
Context {db: db, logger: lg, cfg: cfg, freshness: LinearMap()}
263263
}
264264
265265
fn prep<T:Owned
@@ -270,7 +270,7 @@ impl Context {
270270
blk: fn(@Mut<Prep>)->Work<T>) -> Work<T> {
271271
let p = @Mut(Prep {ctxt: self,
272272
fn_name: fn_name.to_owned(),
273-
declared_inputs: LinearMap::new()});
273+
declared_inputs: LinearMap()});
274274
blk(p)
275275
}
276276
}

trunk/src/libsyntax/parse/parser.rs

Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,45 +1660,43 @@ impl Parser {
16601660
// them as the lambda arguments
16611661
let e = self.parse_expr_res(RESTRICT_NO_BAR_OR_DOUBLEBAR_OP);
16621662
match e.node {
1663-
expr_call(f, args, false) => {
1664-
let block = self.parse_lambda_block_expr();
1665-
let last_arg = self.mk_expr(block.span.lo, block.span.hi,
1666-
ctor(block));
1667-
let args = vec::append(args, ~[last_arg]);
1668-
self.mk_expr(lo.lo, block.span.hi, expr_call(f, args, true))
1669-
}
1670-
expr_method_call(f, i, tps, args, false) => {
1671-
let block = self.parse_lambda_block_expr();
1672-
let last_arg = self.mk_expr(block.span.lo, block.span.hi,
1673-
ctor(block));
1674-
let args = vec::append(args, ~[last_arg]);
1675-
self.mk_expr(lo.lo, block.span.hi,
1676-
expr_method_call(f, i, tps, args, true))
1677-
}
1678-
expr_field(f, i, tps) => {
1679-
let block = self.parse_lambda_block_expr();
1680-
let last_arg = self.mk_expr(block.span.lo, block.span.hi,
1681-
ctor(block));
1682-
self.mk_expr(lo.lo, block.span.hi,
1683-
expr_method_call(f, i, tps, ~[last_arg], true))
1684-
}
1685-
expr_path(*) | expr_call(*) | expr_method_call(*) |
1686-
expr_paren(*) => {
1687-
let block = self.parse_lambda_block_expr();
1688-
let last_arg = self.mk_expr(block.span.lo, block.span.hi,
1689-
ctor(block));
1690-
self.mk_expr(lo.lo, last_arg.span.hi,
1691-
expr_call(e, ~[last_arg], true))
1692-
}
1693-
_ => {
1694-
// There may be other types of expressions that can
1695-
// represent the callee in `for` and `do` expressions
1696-
// but they aren't represented by tests
1697-
debug!("sugary call on %?", e.node);
1698-
self.span_fatal(
1699-
lo, fmt!("`%s` must be followed by a block call",
1700-
keyword));
1701-
}
1663+
expr_call(f, args, false) => {
1664+
let block = self.parse_lambda_block_expr();
1665+
let last_arg = self.mk_expr(block.span.lo, block.span.hi,
1666+
ctor(block));
1667+
let args = vec::append(args, ~[last_arg]);
1668+
@expr {node: expr_call(f, args, true), .. *e}
1669+
}
1670+
expr_method_call(f, i, tps, args, false) => {
1671+
let block = self.parse_lambda_block_expr();
1672+
let last_arg = self.mk_expr(block.span.lo, block.span.hi,
1673+
ctor(block));
1674+
let args = vec::append(args, ~[last_arg]);
1675+
@expr {node: expr_method_call(f, i, tps, args, true), .. *e}
1676+
}
1677+
expr_field(f, i, tps) => {
1678+
let block = self.parse_lambda_block_expr();
1679+
let last_arg = self.mk_expr(block.span.lo, block.span.hi,
1680+
ctor(block));
1681+
@expr {node: expr_method_call(f, i, tps, ~[last_arg], true),
1682+
.. *e}
1683+
}
1684+
expr_path(*) | expr_call(*) | expr_method_call(*) |
1685+
expr_paren(*) => {
1686+
let block = self.parse_lambda_block_expr();
1687+
let last_arg = self.mk_expr(block.span.lo, block.span.hi,
1688+
ctor(block));
1689+
self.mk_expr(lo.lo, last_arg.span.hi,
1690+
expr_call(e, ~[last_arg], true))
1691+
}
1692+
_ => {
1693+
// There may be other types of expressions that can
1694+
// represent the callee in `for` and `do` expressions
1695+
// but they aren't represented by tests
1696+
debug!("sugary call on %?", e.node);
1697+
self.span_fatal(
1698+
lo, fmt!("`%s` must be followed by a block call", keyword));
1699+
}
17021700
}
17031701
}
17041702

trunk/src/libsyntax/parse/token.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ fn strict_keyword_table() -> HashMap<~str, ()> {
493493
~"once",
494494
~"priv", ~"pub", ~"pure",
495495
~"ref", ~"return",
496-
~"struct", ~"super",
496+
~"struct",
497497
~"true", ~"trait", ~"type",
498498
~"unsafe", ~"use",
499499
~"while"

trunk/src/test/compile-fail/bad-for-loop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010

1111
fn main() {
1212
fn baz(_x: fn(y: int) -> int) {}
13-
for baz |_e| { } //~ ERROR A `for` loop iterator should expect a closure that returns `bool`
13+
for baz |_e| { } //~ ERROR should return `bool`
1414
}

trunk/src/test/compile-fail/issue-2817-2.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ fn main() {
1414
for uint::range(0, 100000) |_i| { //~ ERROR A for-loop body must return (), but
1515
false
1616
};
17-
for not_bool |_i| { //~ ERROR a `for` loop iterator should expect a closure that returns `bool`
17+
for not_bool |_i| { //~ ERROR a `loop` function's last argument should return `bool`
18+
//~^ ERROR A for-loop body must return (), but
1819
~"hi"
1920
};
2021
for uint::range(0, 100000) |_i| { //~ ERROR A for-loop body must return (), but
2122
~"hi"
2223
};
23-
for not_bool() |_i| { //~ ERROR a `for` loop iterator should expect a closure that returns `bool`
24+
for not_bool() |_i| { //~ ERROR a `loop` function's last argument
2425
};
2526
}

0 commit comments

Comments
 (0)