Skip to content

Commit 82003a9

Browse files
committed
---
yaml --- r: 138357 b: refs/heads/auto c: 4bb21f3 h: refs/heads/master i: 138355: 8f0f6d2 v: v3
1 parent 388331c commit 82003a9

Some content is hidden

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

58 files changed

+928
-191
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: cef0b55c787bb8b827e0111e1c6ccc1373b663da
16+
refs/heads/auto: 4bb21f37efd7a22f2c7a2f639e6c76e645c760c3
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/doc/guide.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,8 +1255,9 @@ version, if we had forgotten the `Greater` case, for example, our program would
12551255
have happily compiled. If we forget in the `match`, it will not. Rust helps us
12561256
make sure to cover all of our bases.
12571257

1258-
`match` is also an expression, which means we can use it on the right hand side
1259-
of a `let` binding. We could also implement the previous line like this:
1258+
`match` is also an expression, which means we can use it on the right
1259+
hand side of a `let` binding or directly where an expression is
1260+
used. We could also implement the previous line like this:
12601261

12611262
```{rust}
12621263
fn cmp(a: int, b: int) -> Ordering {
@@ -1269,18 +1270,15 @@ fn main() {
12691270
let x = 5i;
12701271
let y = 10i;
12711272
1272-
let result = match cmp(x, y) {
1273+
println!("{}", match cmp(x, y) {
12731274
Less => "less",
12741275
Greater => "greater",
12751276
Equal => "equal",
1276-
};
1277-
1278-
println!("{}", result);
1277+
});
12791278
}
12801279
```
12811280

1282-
In this case, it doesn't make a lot of sense, as we are just making a temporary
1283-
string where we don't need to, but sometimes, it's a nice pattern.
1281+
Sometimes, it's a nice pattern.
12841282

12851283
# Looping
12861284

branches/auto/src/libcollections/lib.rs

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

1111
//! Collection types.
1212
//!
13-
//! See [../std/collections](std::collections) for a detailed discussion of collections in Rust.
13+
//! See [std::collections](../std/collections) for a detailed discussion of collections in Rust.
1414
1515

1616
#![crate_name = "collections"]

branches/auto/src/libcore/ops.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ shr_impl!(uint u8 u16 u32 u64 int i8 i16 i32 i64)
626626
* struct Foo;
627627
*
628628
* impl Index<Foo, Foo> for Foo {
629-
* fn index<'a>(&'a self, _rhs: &Foo) -> &'a Foo {
629+
* fn index<'a>(&'a self, _index: &Foo) -> &'a Foo {
630630
* println!("Indexing!");
631631
* self
632632
* }
@@ -657,7 +657,7 @@ pub trait Index<Index, Result> {
657657
* struct Foo;
658658
*
659659
* impl IndexMut<Foo, Foo> for Foo {
660-
* fn index_mut<'a>(&'a mut self, _rhs: &Foo) -> &'a mut Foo {
660+
* fn index_mut<'a>(&'a mut self, _index: &Foo) -> &'a mut Foo {
661661
* println!("Indexing!");
662662
* self
663663
* }
@@ -687,20 +687,20 @@ pub trait IndexMut<Index, Result> {
687687
* ```ignore
688688
* struct Foo;
689689
*
690-
* impl ::core::ops::Slice<Foo, Foo> for Foo {
690+
* impl Slice<Foo, Foo> for Foo {
691691
* fn as_slice_<'a>(&'a self) -> &'a Foo {
692692
* println!("Slicing!");
693693
* self
694694
* }
695-
* fn slice_from_or_fail<'a>(&'a self, from: &Foo) -> &'a Foo {
695+
* fn slice_from_or_fail<'a>(&'a self, _from: &Foo) -> &'a Foo {
696696
* println!("Slicing!");
697697
* self
698698
* }
699-
* fn slice_to_or_fail<'a>(&'a self, to: &Foo) -> &'a Foo {
699+
* fn slice_to_or_fail<'a>(&'a self, _to: &Foo) -> &'a Foo {
700700
* println!("Slicing!");
701701
* self
702702
* }
703-
* fn slice_or_fail<'a>(&'a self, from: &Foo, to: &Foo) -> &'a Foo {
703+
* fn slice_or_fail<'a>(&'a self, _from: &Foo, _to: &Foo) -> &'a Foo {
704704
* println!("Slicing!");
705705
* self
706706
* }
@@ -736,20 +736,20 @@ pub trait Slice<Idx, Sized? Result> for Sized? {
736736
* ```ignore
737737
* struct Foo;
738738
*
739-
* impl ::core::ops::SliceMut<Foo, Foo> for Foo {
739+
* impl SliceMut<Foo, Foo> for Foo {
740740
* fn as_mut_slice_<'a>(&'a mut self) -> &'a mut Foo {
741741
* println!("Slicing!");
742742
* self
743743
* }
744-
* fn slice_from_or_fail_mut<'a>(&'a mut self, from: &Foo) -> &'a mut Foo {
744+
* fn slice_from_or_fail_mut<'a>(&'a mut self, _from: &Foo) -> &'a mut Foo {
745745
* println!("Slicing!");
746746
* self
747747
* }
748-
* fn slice_to_or_fail_mut<'a>(&'a mut self, to: &Foo) -> &'a mut Foo {
748+
* fn slice_to_or_fail_mut<'a>(&'a mut self, _to: &Foo) -> &'a mut Foo {
749749
* println!("Slicing!");
750750
* self
751751
* }
752-
* fn slice_or_fail_mut<'a>(&'a mut self, from: &Foo, to: &Foo) -> &'a mut Foo {
752+
* fn slice_or_fail_mut<'a>(&'a mut self, _from: &Foo, _to: &Foo) -> &'a mut Foo {
753753
* println!("Slicing!");
754754
* self
755755
* }
@@ -901,4 +901,3 @@ def_fn_mut!(A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12)
901901
def_fn_mut!(A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13)
902902
def_fn_mut!(A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14)
903903
def_fn_mut!(A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14 A15)
904-

branches/auto/src/librustc/middle/check_static.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,15 @@ struct GlobalChecker {
5757
static_consumptions: NodeSet,
5858
const_borrows: NodeSet,
5959
static_interior_borrows: NodeSet,
60+
static_local_borrows: NodeSet,
6061
}
6162

6263
pub fn check_crate(tcx: &ty::ctxt) {
6364
let mut checker = GlobalChecker {
6465
static_consumptions: NodeSet::new(),
6566
const_borrows: NodeSet::new(),
6667
static_interior_borrows: NodeSet::new(),
68+
static_local_borrows: NodeSet::new(),
6769
};
6870
{
6971
let visitor = euv::ExprUseVisitor::new(&mut checker, tcx);
@@ -200,6 +202,14 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckStaticVisitor<'a, 'tcx> {
200202
}
201203
}
202204

205+
// local variables in a block expression in a static context (i.e. being
206+
// assigned to a static variable) cannot be borrowed.
207+
if self.checker.static_local_borrows.remove(&e.id) {
208+
self.tcx.sess.span_err(e.span, "cannot borrow a local variable inside \
209+
a static block, define a separate static \
210+
instead");
211+
}
212+
203213
match e.node {
204214
ast::ExprAddrOf(ast::MutMutable, _) => {
205215
if self.mode != InStaticMut {
@@ -298,8 +308,12 @@ impl euv::Delegate for GlobalChecker {
298308

299309
mc::cat_downcast(..) |
300310
mc::cat_discr(..) |
301-
mc::cat_upvar(..) |
302-
mc::cat_local(..) => unreachable!(),
311+
mc::cat_upvar(..) => unreachable!(),
312+
313+
mc::cat_local(..) => {
314+
self.static_local_borrows.insert(borrow_id);
315+
break
316+
}
303317
}
304318
}
305319
}

branches/auto/src/librustc/middle/trans/_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
10901090
let sw = if kind == Switch {
10911091
build::Switch(bcx, test_val, else_cx.llbb, opts.len())
10921092
} else {
1093-
C_int(ccx, 0) // Placeholder for when not using a switch
1093+
C_int(ccx, 0i) // Placeholder for when not using a switch
10941094
};
10951095

10961096
let defaults = enter_default(else_cx, dm, m, col, val);

0 commit comments

Comments
 (0)