Skip to content

Commit 949a957

Browse files
committed
---
yaml --- r: 114524 b: refs/heads/master c: 85d9cfb h: refs/heads/master v: v3
1 parent 559f0aa commit 949a957

File tree

17 files changed

+41
-312
lines changed

17 files changed

+41
-312
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: 1fc29ef0c8c35eacf7d72e5eb0e7c961009ab4c9
2+
refs/heads/master: 85d9cfb809d8191a03e84c5754e2e778281e5ce9
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ec0258a381b88b5574e3f8ce72ae553ac3a574b7
55
refs/heads/try: 7c6c492fb2af9a85f21ff952942df3523b22fd17

trunk/src/doc/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,7 @@ let ys = xs;
11061106
11071107
xs = Nil;
11081108
1109-
// `xs` can't be used again
1109+
// `xs` can be used again
11101110
~~~
11111111

11121112
A destructor call will only occur for a variable that has not been moved from,

trunk/src/librustc/middle/check_match.rs

Lines changed: 22 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -863,18 +863,9 @@ fn default(cx: &MatchCheckCtxt, r: &[@Pat]) -> Option<Vec<@Pat> > {
863863

864864
fn check_local(cx: &mut MatchCheckCtxt, loc: &Local) {
865865
visit::walk_local(cx, loc, ());
866-
867-
let name = match loc.source {
868-
LocalLet => "local",
869-
LocalFor => "`for` loop"
870-
};
871-
872-
let mut spans = vec![];
873-
find_refutable(cx, loc.pat, &mut spans);
874-
875-
for span in spans.iter() {
876-
cx.tcx.sess.span_err(*span,
877-
format!("refutable pattern in {} binding", name).as_slice());
866+
if is_refutable(cx, loc.pat) {
867+
cx.tcx.sess.span_err(loc.pat.span,
868+
"refutable pattern in local binding");
878869
}
879870

880871
// Check legality of move bindings.
@@ -888,65 +879,53 @@ fn check_fn(cx: &mut MatchCheckCtxt,
888879
sp: Span) {
889880
visit::walk_fn(cx, kind, decl, body, sp, ());
890881
for input in decl.inputs.iter() {
891-
let mut spans = vec![];
892-
find_refutable(cx, input.pat, &mut spans);
893-
894-
for span in spans.iter() {
895-
cx.tcx.sess.span_err(*span,
882+
if is_refutable(cx, input.pat) {
883+
cx.tcx.sess.span_err(input.pat.span,
896884
"refutable pattern in function argument");
897885
}
898886
}
899887
}
900888

901-
fn find_refutable(cx: &MatchCheckCtxt, pat: &Pat, spans: &mut Vec<Span>) {
902-
macro_rules! this_pattern {
903-
() => {
904-
{
905-
spans.push(pat.span);
906-
return
907-
}
908-
}
909-
}
889+
fn is_refutable(cx: &MatchCheckCtxt, pat: &Pat) -> bool {
910890
let opt_def = cx.tcx.def_map.borrow().find_copy(&pat.id);
911891
match opt_def {
912892
Some(DefVariant(enum_id, _, _)) => {
913893
if ty::enum_variants(cx.tcx, enum_id).len() != 1u {
914-
this_pattern!()
894+
return true;
915895
}
916896
}
917-
Some(DefStatic(..)) => this_pattern!(),
897+
Some(DefStatic(..)) => return true,
918898
_ => ()
919899
}
920900

921901
match pat.node {
922902
PatUniq(sub) | PatRegion(sub) | PatIdent(_, _, Some(sub)) => {
923-
find_refutable(cx, sub, spans)
903+
is_refutable(cx, sub)
924904
}
925-
PatWild | PatWildMulti | PatIdent(_, _, None) => {}
905+
PatWild | PatWildMulti | PatIdent(_, _, None) => { false }
926906
PatLit(lit) => {
927907
match lit.node {
928908
ExprLit(lit) => {
929909
match lit.node {
930-
LitNil => {} // `()`
931-
_ => this_pattern!(),
910+
LitNil => false, // `()`
911+
_ => true,
932912
}
933913
}
934-
_ => this_pattern!(),
914+
_ => true,
935915
}
936916
}
937-
PatRange(_, _) => { this_pattern!() }
917+
PatRange(_, _) => { true }
938918
PatStruct(_, ref fields, _) => {
939-
for f in fields.iter() {
940-
find_refutable(cx, f.pat, spans);
941-
}
919+
fields.iter().any(|f| is_refutable(cx, f.pat))
942920
}
943-
PatTup(ref elts) | PatEnum(_, Some(ref elts))=> {
944-
for elt in elts.iter() {
945-
find_refutable(cx, *elt, spans)
946-
}
921+
PatTup(ref elts) => {
922+
elts.iter().any(|elt| is_refutable(cx, *elt))
923+
}
924+
PatEnum(_, Some(ref args)) => {
925+
args.iter().any(|a| is_refutable(cx, *a))
947926
}
948-
PatEnum(_,_) => {}
949-
PatVec(..) => { this_pattern!() }
927+
PatEnum(_,_) => { false }
928+
PatVec(..) => { true }
950929
}
951930
}
952931

trunk/src/librustc/middle/privacy.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -297,23 +297,6 @@ impl<'a> Visitor<()> for EmbargoVisitor<'a> {
297297
}
298298
}
299299

300-
ast::ItemTy(ref ty, _) if public_first => {
301-
match ty.node {
302-
ast::TyPath(_, _, id) => {
303-
match self.tcx.def_map.borrow().get_copy(&id) {
304-
ast::DefPrimTy(..) => {},
305-
def => {
306-
let did = def_id_of_def(def);
307-
if is_local(did) {
308-
self.exported_items.insert(did.node);
309-
}
310-
}
311-
}
312-
}
313-
_ => {}
314-
}
315-
}
316-
317300
_ => {}
318301
}
319302

trunk/src/libserialize/json.rs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,36 +1434,6 @@ impl<T: Iterator<char>> Parser<T> {
14341434
},
14351435
},
14361436
_ => return self.error(InvalidEscape),
1437-
/*=======
1438-
'u' => {
1439-
// Parse \u1234.
1440-
let mut i = 0u;
1441-
let mut n = 0u;
1442-
while i < 4u && !self.eof() {
1443-
self.bump();
1444-
n = match self.ch_or_null() {
1445-
c @ '0' .. '9' => n * 16u + (c as uint) - ('0' as uint),
1446-
'a' | 'A' => n * 16u + 10u,
1447-
'b' | 'B' => n * 16u + 11u,
1448-
'c' | 'C' => n * 16u + 12u,
1449-
'd' | 'D' => n * 16u + 13u,
1450-
'e' | 'E' => n * 16u + 14u,
1451-
'f' | 'F' => n * 16u + 15u,
1452-
_ => return self.error(UnrecognizedHex)
1453-
};
1454-
1455-
i += 1u;
1456-
}
1457-
1458-
// Error out if we didn't parse 4 digits.
1459-
if i != 4u {
1460-
return self.error(NotFourDigit);
1461-
}
1462-
1463-
res.push_char(char::from_u32(n as u32).unwrap());
1464-
}
1465-
_ => return self.error(InvalidEscape),
1466-
>>>>>>> Add a streaming parser to serialize::json.*/
14671437
}
14681438
escape = false;
14691439
} else if self.ch_is('\\') {

trunk/src/libstd/str.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,24 @@ Unicode string manipulation (`str` type)
1616
1717
Rust's string type is one of the core primitive types of the language. While
1818
represented by the name `str`, the name `str` is not actually a valid type in
19-
Rust. Each string must also be decorated with a pointer. `String` is used
20-
for an owned string, so there is only one commonly-used `str` type in Rust:
21-
`&str`.
19+
Rust. Each string must also be decorated with its ownership. This means that
20+
there is one common kind of string in Rust:
2221
23-
`&str` is the borrowed string type. This type of string can only be created
24-
from other strings, unless it is a static string (see below). As the word
25-
"borrowed" implies, this type of string is owned elsewhere, and this string
26-
cannot be moved out of.
22+
* `&str` - This is the borrowed string type. This type of string can only be
23+
created from the other kind of string. As the name "borrowed"
24+
implies, this type of string is owned elsewhere, and this string
25+
cannot be moved out of.
2726
28-
As an example, here's some code that uses a string.
27+
As an example, here's the one kind of string.
2928
3029
```rust
3130
fn main() {
3231
let borrowed_string = "This string is borrowed with the 'static lifetime";
3332
}
3433
```
3534
36-
From the example above, you can see that Rust's string literals have the
37-
`'static` lifetime. This is akin to C's concept of a static string.
35+
From the example above, you can see that Rust has 1 different kind of string
36+
literal. The "borrowed literal" is akin to C's concept of a static string.
3837
3938
String literals are allocated statically in the rodata of the
4039
executable/library. The string then has the type `&'static str` meaning that
@@ -510,7 +509,7 @@ pub fn from_utf8_lossy<'a>(v: &'a [u8]) -> MaybeOwned<'a> {
510509
Section: MaybeOwned
511510
*/
512511

513-
/// A `MaybeOwned` is a string that can hold either a `String` or a `&str`.
512+
/// A MaybeOwned is a string that can hold either a String or a &str.
514513
/// This can be useful as an optimization when an allocation is sometimes
515514
/// needed but not always.
516515
pub enum MaybeOwned<'a> {
@@ -520,7 +519,7 @@ pub enum MaybeOwned<'a> {
520519
Owned(String)
521520
}
522521

523-
/// `SendStr` is a specialization of `MaybeOwned` to be sendable
522+
/// SendStr is a specialization of `MaybeOwned` to be sendable
524523
pub type SendStr = MaybeOwned<'static>;
525524

526525
impl<'a> MaybeOwned<'a> {

trunk/src/libsyntax/ast.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -417,14 +417,6 @@ pub enum Stmt_ {
417417
StmtMac(Mac, bool),
418418
}
419419

420-
/// Where a local declaration came from: either a true `let ... =
421-
/// ...;`, or one desugared from the pattern of a for loop.
422-
#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
423-
pub enum LocalSource {
424-
LocalLet,
425-
LocalFor,
426-
}
427-
428420
// FIXME (pending discussion of #1697, #2178...): local should really be
429421
// a refinement on pat.
430422
/// Local represents a `let` statement, e.g., `let <pat>:<ty> = <expr>;`
@@ -435,7 +427,6 @@ pub struct Local {
435427
pub init: Option<@Expr>,
436428
pub id: NodeId,
437429
pub span: Span,
438-
pub source: LocalSource,
439430
}
440431

441432
pub type Decl = Spanned<Decl_>;

trunk/src/libsyntax/ext/build.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,6 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
439439
init: Some(ex),
440440
id: ast::DUMMY_NODE_ID,
441441
span: sp,
442-
source: ast::LocalLet,
443442
};
444443
let decl = respan(sp, ast::DeclLocal(local));
445444
@respan(sp, ast::StmtDecl(@decl, ast::DUMMY_NODE_ID))
@@ -463,7 +462,6 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
463462
init: Some(ex),
464463
id: ast::DUMMY_NODE_ID,
465464
span: sp,
466-
source: ast::LocalLet,
467465
};
468466
let decl = respan(sp, ast::DeclLocal(local));
469467
@respan(sp, ast::StmtDecl(@decl, ast::DUMMY_NODE_ID))

trunk/src/libsyntax/ext/expand.rs

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -147,17 +147,11 @@ pub fn expand_expr(e: @ast::Expr, fld: &mut MacroExpander) -> @ast::Expr {
147147
// ['<ident>:] loop {
148148
// match i.next() {
149149
// None => break,
150-
// Some(mut value) => {
151-
// let <src_pat> = value;
152-
// <src_loop_block>
153-
// }
150+
// Some(<src_pat>) => <src_loop_block>
154151
// }
155152
// }
156153
// }
157154
// }
158-
//
159-
// (The use of the `let` is to give better error messages
160-
// when the pattern is refutable.)
161155

162156
let local_ident = token::gensym_ident("__i"); // FIXME #13573
163157
let next_ident = fld.cx.ident_of("next");
@@ -173,33 +167,11 @@ pub fn expand_expr(e: @ast::Expr, fld: &mut MacroExpander) -> @ast::Expr {
173167
fld.cx.arm(span, vec!(none_pat), break_expr)
174168
};
175169

176-
// let <src_pat> = value;
177-
let value_ident = token::gensym_ident("__value");
178-
// this is careful to use src_pat.span so that error
179-
// messages point exact at that.
180-
let local = @ast::Local {
181-
ty: fld.cx.ty_infer(src_pat.span),
182-
pat: src_pat,
183-
init: Some(fld.cx.expr_ident(src_pat.span, value_ident)),
184-
id: ast::DUMMY_NODE_ID,
185-
span: src_pat.span,
186-
source: ast::LocalFor
187-
};
188-
let local = codemap::respan(src_pat.span, ast::DeclLocal(local));
189-
let local = @codemap::respan(span, ast::StmtDecl(@local, ast::DUMMY_NODE_ID));
190-
191-
// { let ...; <src_loop_block> }
192-
let block = fld.cx.block(span, vec![local],
193-
Some(fld.cx.expr_block(src_loop_block)));
194-
195-
// `Some(mut value) => { ... }`
196-
// Note the _'s in the name will stop any unused mutability warnings.
197-
let value_pat = fld.cx.pat_ident_binding_mode(span, value_ident,
198-
ast::BindByValue(ast::MutMutable));
170+
// `Some(<src_pat>) => <src_loop_block>`
199171
let some_arm =
200172
fld.cx.arm(span,
201-
vec!(fld.cx.pat_enum(span, some_path, vec!(value_pat))),
202-
fld.cx.expr_block(block));
173+
vec!(fld.cx.pat_enum(span, some_path, vec!(src_pat))),
174+
fld.cx.expr_block(src_loop_block));
203175

204176
// `match i.next() { ... }`
205177
let match_expr = {
@@ -697,8 +669,7 @@ fn expand_non_macro_stmt(s: &Stmt, fld: &mut MacroExpander)
697669
pat: pat,
698670
init: init,
699671
id: id,
700-
span: span,
701-
source: source,
672+
span: span
702673
} = **local;
703674
// expand the pat (it might contain exprs... #:(o)>
704675
let expanded_pat = fld.fold_pat(pat);
@@ -732,7 +703,6 @@ fn expand_non_macro_stmt(s: &Stmt, fld: &mut MacroExpander)
732703
init: new_init_opt,
733704
id: id,
734705
span: span,
735-
source: source
736706
};
737707
SmallVector::one(@Spanned {
738708
node: StmtDecl(@Spanned {

trunk/src/libsyntax/fold.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,6 @@ pub trait Folder {
288288
pat: self.fold_pat(l.pat),
289289
init: l.init.map(|e| self.fold_expr(e)),
290290
span: self.new_span(l.span),
291-
source: l.source,
292291
}
293292
}
294293

trunk/src/libsyntax/parse/parser.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use ast::{Ident, NormalFn, Inherited, Item, Item_, ItemStatic};
3434
use ast::{ItemEnum, ItemFn, ItemForeignMod, ItemImpl};
3535
use ast::{ItemMac, ItemMod, ItemStruct, ItemTrait, ItemTy, Lit, Lit_};
3636
use ast::{LitBool, LitFloat, LitFloatUnsuffixed, LitInt, LitChar};
37-
use ast::{LitIntUnsuffixed, LitNil, LitStr, LitUint, Local, LocalLet};
37+
use ast::{LitIntUnsuffixed, LitNil, LitStr, LitUint, Local};
3838
use ast::{MutImmutable, MutMutable, Mac_, MacInvocTT, Matcher, MatchNonterminal};
3939
use ast::{MatchSeq, MatchTok, Method, MutTy, BiMul, Mutability};
4040
use ast::{NamedField, UnNeg, NoReturn, UnNot, P, Pat, PatEnum};
@@ -3034,7 +3034,6 @@ impl<'a> Parser<'a> {
30343034
init: init,
30353035
id: ast::DUMMY_NODE_ID,
30363036
span: mk_sp(lo, self.last_span.hi),
3037-
source: LocalLet,
30383037
}
30393038
}
30403039

0 commit comments

Comments
 (0)