Skip to content

Commit 5a97281

Browse files
committed
---
yaml --- r: 98082 b: refs/heads/master c: 77eedda h: refs/heads/master v: v3
1 parent b16a382 commit 5a97281

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1167
-1066
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: 289ba105ae613291f0a3a16ef295875130abdc49
2+
refs/heads/master: 77eeddaa481fa083dfa857e5d7dd7f5ab784a9f1
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: b6400f998497c3958f40997a71756ead344a776d
55
refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36

trunk/doc/rust.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2865,19 +2865,19 @@ In a pattern whose head expression has an `enum` type, a placeholder (`_`) stand
28652865
variant. For example:
28662866

28672867
~~~~
2868-
enum List<X> { Nil, Cons(X, @List<X>) }
2868+
enum List<X> { Nil, Cons(X, ~List<X>) }
28692869
2870-
let x: List<int> = Cons(10, @Cons(11, @Nil));
2870+
let x: List<int> = Cons(10, ~Cons(11, ~Nil));
28712871
28722872
match x {
2873-
Cons(_, @Nil) => fail!("singleton list"),
2873+
Cons(_, ~Nil) => fail!("singleton list"),
28742874
Cons(..) => return,
28752875
Nil => fail!("empty list")
28762876
}
28772877
~~~~
28782878

28792879
The first pattern matches lists constructed by applying `Cons` to any head value, and a
2880-
tail value of `@Nil`. The second pattern matches _any_ list constructed with `Cons`,
2880+
tail value of `~Nil`. The second pattern matches _any_ list constructed with `Cons`,
28812881
ignoring the values of its arguments. The difference between `_` and `*` is that the pattern `C(_)` is only type-correct if
28822882
`C` has exactly one argument, while the pattern `C(..)` is type-correct for any enum variant `C`, regardless of how many arguments `C` has.
28832883

@@ -2893,12 +2893,12 @@ An example of an `match` expression:
28932893
# fn process_pair(a: int, b: int) { }
28942894
# fn process_ten() { }
28952895
2896-
enum List<X> { Nil, Cons(X, @List<X>) }
2896+
enum List<X> { Nil, Cons(X, ~List<X>) }
28972897
2898-
let x: List<int> = Cons(10, @Cons(11, @Nil));
2898+
let x: List<int> = Cons(10, ~Cons(11, ~Nil));
28992899
29002900
match x {
2901-
Cons(a, @Cons(b, _)) => {
2901+
Cons(a, ~Cons(b, _)) => {
29022902
process_pair(a,b);
29032903
}
29042904
Cons(10, _) => {

trunk/mk/tests.mk

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -445,17 +445,17 @@ check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4
445445
$$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
446446
$(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2))
447447
@$$(call E, run: $$< via adb)
448-
@$(CFG_ADB) push $$< $(CFG_ADB_TEST_DIR)
449-
@$(CFG_ADB) shell '(cd $(CFG_ADB_TEST_DIR); LD_LIBRARY_PATH=. \
448+
$$(Q)$(CFG_ADB) push $$< $(CFG_ADB_TEST_DIR)
449+
$$(Q)$(CFG_ADB) shell '(cd $(CFG_ADB_TEST_DIR); LD_LIBRARY_PATH=. \
450450
./$$(notdir $$<) \
451451
--logfile $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log \
452-
$$(call CRATE_TEST_EXTRA_ARGS,$(1),$(2),$(3),$(4)))' \
452+
$$(call CRATE_TEST_EXTRA_ARGS,$(1),$(2),$(3),$(4)) $(TESTARGS))' \
453453
> tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp
454-
@cat tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp
455-
@touch tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
456-
@$(CFG_ADB) pull $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log tmp/
457-
@$(CFG_ADB) shell rm $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
458-
@$(CFG_ADB) pull $(CFG_ADB_TEST_DIR)/$$(call TEST_RATCHET_FILE,$(1),$(2),$(3),$(4)) tmp/
454+
$$(Q)cat tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp
455+
$$(Q)touch tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
456+
$$(Q)$(CFG_ADB) pull $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log tmp/
457+
$$(Q)$(CFG_ADB) shell rm $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
458+
$$(Q)$(CFG_ADB) pull $(CFG_ADB_TEST_DIR)/$$(call TEST_RATCHET_FILE,$(1),$(2),$(3),$(4)) tmp/
459459
@if grep -q "result: ok" tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp; \
460460
then \
461461
rm tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp; \

trunk/src/librustc/front/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ fn method_in_cfg(cx: &Context, meth: &ast::Method) -> bool {
201201
fn trait_method_in_cfg(cx: &Context, meth: &ast::TraitMethod) -> bool {
202202
match *meth {
203203
ast::Required(ref meth) => (cx.in_cfg)(meth.attrs),
204-
ast::Provided(@ref meth) => (cx.in_cfg)(meth.attrs)
204+
ast::Provided(meth) => (cx.in_cfg)(meth.attrs)
205205
}
206206
}
207207

trunk/src/librustc/middle/astencode.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -308,15 +308,13 @@ impl Folder for NestedItemsDropper {
308308
fn fold_block(&mut self, blk: ast::P<ast::Block>) -> ast::P<ast::Block> {
309309
let stmts_sans_items = blk.stmts.iter().filter_map(|stmt| {
310310
match stmt.node {
311-
ast::StmtExpr(_, _) | ast::StmtSemi(_, _) |
312-
ast::StmtDecl(@codemap::Spanned {
313-
node: ast::DeclLocal(_),
314-
span: _
315-
}, _) => Some(*stmt),
316-
ast::StmtDecl(@codemap::Spanned {
317-
node: ast::DeclItem(_),
318-
span: _
319-
}, _) => None,
311+
ast::StmtExpr(_, _) | ast::StmtSemi(_, _) => Some(*stmt),
312+
ast::StmtDecl(decl, _) => {
313+
match decl.node {
314+
ast::DeclLocal(_) => Some(*stmt),
315+
ast::DeclItem(_) => None,
316+
}
317+
}
320318
ast::StmtMac(..) => fail!("unexpanded macro in astencode")
321319
}
322320
}).collect();

trunk/src/librustc/middle/cfg/construct.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ impl CFGBuilder {
101101
self.add_node(pat.id, [pred])
102102
}
103103

104-
ast::PatBox(subpat) |
105104
ast::PatUniq(subpat) |
106105
ast::PatRegion(subpat) |
107106
ast::PatIdent(_, _, Some(subpat)) => {

trunk/src/librustc/middle/check_const.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use middle::typeck;
1616
use util::ppaux;
1717

1818
use syntax::ast::*;
19-
use syntax::codemap;
2019
use syntax::{ast_util, ast_map};
2120
use syntax::visit::Visitor;
2221
use syntax::visit;
@@ -84,14 +83,13 @@ pub fn check_item(v: &mut CheckCrateVisitor,
8483
pub fn check_pat(v: &mut CheckCrateVisitor, p: &Pat, _is_const: bool) {
8584
fn is_str(e: @Expr) -> bool {
8685
match e.node {
87-
ExprVstore(
88-
@Expr { node: ExprLit(@codemap::Spanned {
89-
node: LitStr(..),
90-
..}),
91-
.. },
92-
ExprVstoreUniq
93-
) => true,
94-
_ => false
86+
ExprVstore(expr, ExprVstoreUniq) => {
87+
match expr.node {
88+
ExprLit(lit) => ast_util::lit_is_str(lit),
89+
_ => false,
90+
}
91+
}
92+
_ => false,
9593
}
9694
}
9795
match p.node {
@@ -120,7 +118,7 @@ pub fn check_expr(v: &mut CheckCrateVisitor,
120118
"cannot do allocations in constant expressions");
121119
return;
122120
}
123-
ExprLit(@codemap::Spanned {node: LitStr(..), ..}) => { }
121+
ExprLit(lit) if ast_util::lit_is_str(lit) => {}
124122
ExprBinary(..) | ExprUnary(..) => {
125123
let method_map = method_map.borrow();
126124
if method_map.get().contains_key(&e.id) {

trunk/src/librustc/middle/check_match.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use std::num;
2323
use std::vec;
2424
use syntax::ast::*;
2525
use syntax::ast_util::{unguarded_pat, walk_pat};
26-
use syntax::codemap::{Span, DUMMY_SP, Spanned};
26+
use syntax::codemap::{DUMMY_SP, Span};
2727
use syntax::visit;
2828
use syntax::visit::{Visitor, FnKind};
2929

@@ -362,7 +362,7 @@ fn pat_ctor_id(cx: &MatchCheckCtxt, p: @Pat) -> Option<ctor> {
362362
_ => Some(single)
363363
}
364364
}
365-
PatBox(_) | PatUniq(_) | PatTup(_) | PatRegion(..) => {
365+
PatUniq(_) | PatTup(_) | PatRegion(..) => {
366366
Some(single)
367367
}
368368
PatVec(ref before, slice, ref after) => {
@@ -735,7 +735,7 @@ fn specialize(cx: &MatchCheckCtxt,
735735
}
736736
}
737737
PatTup(args) => Some(vec::append(args, r.tail())),
738-
PatBox(a) | PatUniq(a) | PatRegion(a) => {
738+
PatUniq(a) | PatRegion(a) => {
739739
Some(vec::append(~[a], r.tail()))
740740
}
741741
PatLit(expr) => {
@@ -874,16 +874,22 @@ fn is_refutable(cx: &MatchCheckCtxt, pat: &Pat) -> bool {
874874
}
875875

876876
match pat.node {
877-
PatBox(sub) | PatUniq(sub) | PatRegion(sub) |
878-
PatIdent(_, _, Some(sub)) => {
877+
PatUniq(sub) | PatRegion(sub) | PatIdent(_, _, Some(sub)) => {
879878
is_refutable(cx, sub)
880879
}
881880
PatWild | PatWildMulti | PatIdent(_, _, None) => { false }
882-
PatLit(@Expr {node: ExprLit(@Spanned { node: LitNil, ..}), ..}) => {
883-
// "()"
884-
false
881+
PatLit(lit) => {
882+
match lit.node {
883+
ExprLit(lit) => {
884+
match lit.node {
885+
LitNil => false, // `()`
886+
_ => true,
887+
}
888+
}
889+
_ => true,
890+
}
885891
}
886-
PatLit(_) | PatRange(_, _) => { true }
892+
PatRange(_, _) => { true }
887893
PatStruct(_, ref fields, _) => {
888894
fields.iter().any(|f| is_refutable(cx, f.pat))
889895
}

trunk/src/librustc/middle/kind.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,18 @@ pub fn check_expr(cx: &mut Context, e: &Expr) {
330330
// Search for auto-adjustments to find trait coercions.
331331
let adjustments = cx.tcx.adjustments.borrow();
332332
match adjustments.get().find(&e.id) {
333-
Some(&@ty::AutoObject(..)) => {
334-
let source_ty = ty::expr_ty(cx.tcx, e);
335-
let target_ty = ty::expr_ty_adjusted(cx.tcx, e);
336-
check_trait_cast(cx, source_ty, target_ty, e.span);
333+
Some(adjustment) => {
334+
match **adjustment {
335+
ty::AutoObject(..) => {
336+
let source_ty = ty::expr_ty(cx.tcx, e);
337+
let target_ty = ty::expr_ty_adjusted(cx.tcx, e);
338+
check_trait_cast(cx, source_ty, target_ty, e.span);
339+
}
340+
ty::AutoAddEnv(..) |
341+
ty::AutoDerefRef(..) => {}
342+
}
337343
}
338-
Some(&@ty::AutoAddEnv(..)) | Some(&@ty::AutoDerefRef(..)) | None => {}
344+
None => {}
339345
}
340346

341347
visit::walk_expr(cx, e, ());

trunk/src/librustc/middle/lint.rs

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ use syntax::ast_map;
6262
use syntax::attr;
6363
use syntax::attr::{AttrMetaMethods, AttributeMethods};
6464
use syntax::codemap::Span;
65-
use syntax::codemap;
6665
use syntax::parse::token;
6766
use syntax::{ast, ast_util, visit};
6867
use syntax::ast_util::IdVisitingOperation;
@@ -590,11 +589,16 @@ fn check_while_true_expr(cx: &Context, e: &ast::Expr) {
590589
match e.node {
591590
ast::ExprWhile(cond, _) => {
592591
match cond.node {
593-
ast::ExprLit(@codemap::Spanned {
594-
node: ast::LitBool(true), ..}) =>
595-
{
596-
cx.span_lint(WhileTrue, e.span,
597-
"denote infinite loops with loop { ... }");
592+
ast::ExprLit(lit) => {
593+
match lit.node {
594+
ast::LitBool(true) => {
595+
cx.span_lint(WhileTrue,
596+
e.span,
597+
"denote infinite loops with loop \
598+
{ ... }");
599+
}
600+
_ => {}
601+
}
598602
}
599603
_ => ()
600604
}
@@ -989,9 +993,15 @@ fn check_heap_expr(cx: &Context, e: &ast::Expr) {
989993

990994
fn check_path_statement(cx: &Context, s: &ast::Stmt) {
991995
match s.node {
992-
ast::StmtSemi(@ast::Expr { node: ast::ExprPath(_), .. }, _) => {
993-
cx.span_lint(PathStatement, s.span,
994-
"path statement with no effect");
996+
ast::StmtSemi(expr, _) => {
997+
match expr.node {
998+
ast::ExprPath(_) => {
999+
cx.span_lint(PathStatement,
1000+
s.span,
1001+
"path statement with no effect");
1002+
}
1003+
_ => {}
1004+
}
9951005
}
9961006
_ => ()
9971007
}
@@ -1132,7 +1142,9 @@ fn check_unnecessary_allocation(cx: &Context, e: &ast::Expr) {
11321142
ast::ExprVstore(e2, ast::ExprVstoreUniq) |
11331143
ast::ExprVstore(e2, ast::ExprVstoreBox) => {
11341144
match e2.node {
1135-
ast::ExprLit(@codemap::Spanned{node: ast::LitStr(..), ..}) |
1145+
ast::ExprLit(lit) if ast_util::lit_is_str(lit) => {
1146+
VectorAllocation
1147+
}
11361148
ast::ExprVec(..) => VectorAllocation,
11371149
_ => return
11381150
}
@@ -1152,18 +1164,27 @@ fn check_unnecessary_allocation(cx: &Context, e: &ast::Expr) {
11521164
adjustments.get().find_copy(&e.id)
11531165
};
11541166
match adjustment {
1155-
Some(@ty::AutoDerefRef(ty::AutoDerefRef { autoref, .. })) => {
1156-
match (allocation, autoref) {
1157-
(VectorAllocation, Some(ty::AutoBorrowVec(..))) => {
1158-
report("unnecessary allocation, the sigil can be removed");
1159-
}
1160-
(BoxAllocation, Some(ty::AutoPtr(_, ast::MutImmutable))) => {
1161-
report("unnecessary allocation, use & instead");
1162-
}
1163-
(BoxAllocation, Some(ty::AutoPtr(_, ast::MutMutable))) => {
1164-
report("unnecessary allocation, use &mut instead");
1167+
Some(adjustment) => {
1168+
match *adjustment {
1169+
ty::AutoDerefRef(ty::AutoDerefRef { autoref, .. }) => {
1170+
match (allocation, autoref) {
1171+
(VectorAllocation, Some(ty::AutoBorrowVec(..))) => {
1172+
report("unnecessary allocation, the sigil can be \
1173+
removed");
1174+
}
1175+
(BoxAllocation,
1176+
Some(ty::AutoPtr(_, ast::MutImmutable))) => {
1177+
report("unnecessary allocation, use & instead");
1178+
}
1179+
(BoxAllocation,
1180+
Some(ty::AutoPtr(_, ast::MutMutable))) => {
1181+
report("unnecessary allocation, use &mut \
1182+
instead");
1183+
}
1184+
_ => ()
1185+
}
11651186
}
1166-
_ => ()
1187+
_ => {}
11671188
}
11681189
}
11691190

trunk/src/librustc/middle/liveness.rs

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ fn visit_fn(v: &mut LivenessVisitor,
439439

440440
// check for various error conditions
441441
lsets.visit_block(body, ());
442-
lsets.check_ret(id, sp, fk, entry_ln);
442+
lsets.check_ret(id, sp, fk, entry_ln, body);
443443
lsets.warn_about_unused_args(decl, entry_ln);
444444
}
445445

@@ -1575,7 +1575,8 @@ impl Liveness {
15751575
id: NodeId,
15761576
sp: Span,
15771577
_fk: &FnKind,
1578-
entry_ln: LiveNode) {
1578+
entry_ln: LiveNode,
1579+
body: &Block) {
15791580
if self.live_on_entry(entry_ln, self.s.no_ret_var).is_some() {
15801581
// if no_ret_var is live, then we fall off the end of the
15811582
// function without any kind of return expression:
@@ -1588,9 +1589,30 @@ impl Liveness {
15881589
self.tcx.sess.span_err(
15891590
sp, "some control paths may return");
15901591
} else {
1592+
let ends_with_stmt = match body.expr {
1593+
None if body.stmts.len() > 0 =>
1594+
match body.stmts.last().node {
1595+
StmtSemi(e, _) => {
1596+
let t_stmt = ty::expr_ty(self.tcx, e);
1597+
ty::get(t_stmt).sty == ty::get(t_ret).sty
1598+
},
1599+
_ => false
1600+
},
1601+
_ => false
1602+
};
1603+
if ends_with_stmt {
1604+
let last_stmt = body.stmts.last();
1605+
let span_semicolon = Span {
1606+
lo: last_stmt.span.hi,
1607+
hi: last_stmt.span.hi,
1608+
expn_info: last_stmt.span.expn_info
1609+
};
1610+
self.tcx.sess.span_note(
1611+
span_semicolon, "consider removing this semicolon:");
1612+
}
15911613
self.tcx.sess.span_err(
15921614
sp, "not all control paths return a value");
1593-
}
1615+
}
15941616
}
15951617
}
15961618

0 commit comments

Comments
 (0)