Skip to content

Commit f20591e

Browse files
lilyballJakub Wieczorek
authored andcommitted
---
yaml --- r: 135421 b: refs/heads/master c: 5d8cfd5 h: refs/heads/master i: 135419: b2842ba v: v3
1 parent 8cd7d2a commit f20591e

File tree

18 files changed

+86
-81
lines changed

18 files changed

+86
-81
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: 88d1a22f76a774b2df3c904ceb54c86e58a859c3
2+
refs/heads/master: 5d8cfd53b513d999ffff22f17e3066a30a8ed949
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ae81c89f34f1ac2cdb596cf216612e94822a8466
55
refs/heads/try: 14378ea357c06c23607ca61ade44f60a7a64a1c7

trunk/src/etc/emacs/rust-mode-tests.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ Convert the line-column information from that list into a buffer position value.
623623
(move-to-column column)
624624
(point))))
625625

626-
;;; FIXME: Maybe add an ERT explainer function (something that shows the
626+
;;; TODO: Maybe add an ERT explainer function (something that shows the
627627
;;; surrounding code of the final point, not just the position).
628628
(defun rust-test-motion (source-code init-pos final-pos manip-func &optional &rest args)
629629
"Test that MANIP-FUNC moves point from INIT-POS to FINAL-POS.

trunk/src/etc/kate/rust.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!DOCTYPE language SYSTEM "language.dtd"
33
[
4-
<!-- FIXME: Kate's regex engine has very limited support for
4+
<!-- TODO: Kate's regex engine has very limited support for
55
predefined char classes, so making rustIdent consistent with actual
66
Rust identifiers will be a bit difficult -->
77
<!ENTITY rustIdent "[a-zA-Z_][a-zA-Z_0-9]*">

trunk/src/etc/vim/syntax/rust.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ syn keyword rustTodo contained TODO FIXME XXX NB NOTE
216216

217217
" Folding rules {{{2
218218
" Trivial folding rules to begin with.
219-
" FIXME: use the AST to make really good folding
219+
" TODO: use the AST to make really good folding
220220
syn region rustFoldBraces start="{" end="}" transparent fold
221221

222222
" Default highlighting {{{1

trunk/src/librustc/lint/builtin.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,6 @@ impl LintPass for UnusedAttribute {
593593
"static_assert",
594594
"thread_local",
595595
"no_debug",
596-
"unsafe_no_drop_flag",
597596

598597
// used in resolve
599598
"prelude_import",

trunk/src/librustc/metadata/common.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,6 @@ pub static tag_reachable_extern_fn_id: uint = 0x91;
214214

215215
pub static tag_items_data_item_stability: uint = 0x92;
216216

217-
pub static tag_items_data_item_repr: uint = 0x93;
218-
219217
#[deriving(Clone, Show)]
220218
pub struct LinkMeta {
221219
pub crate_name: String,

trunk/src/librustc/metadata/csearch.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -350,12 +350,6 @@ pub fn get_stability(cstore: &cstore::CStore,
350350
decoder::get_stability(&*cdata, def.node)
351351
}
352352

353-
pub fn get_repr_attrs(cstore: &cstore::CStore, def: ast::DefId)
354-
-> Vec<attr::ReprAttr> {
355-
let cdata = cstore.get_crate_data(def.krate);
356-
decoder::get_repr_attrs(&*cdata, def.node)
357-
}
358-
359353
pub fn is_associated_type(cstore: &cstore::CStore, def: ast::DefId) -> bool {
360354
let cdata = cstore.get_crate_data(def.krate);
361355
decoder::is_associated_type(&*cdata, def.node)

trunk/src/librustc/metadata/decoder.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -384,17 +384,6 @@ pub fn get_stability(cdata: Cmd, id: ast::NodeId) -> Option<attr::Stability> {
384384
})
385385
}
386386

387-
pub fn get_repr_attrs(cdata: Cmd, id: ast::NodeId) -> Vec<attr::ReprAttr> {
388-
let item = lookup_item(id, cdata.data());
389-
match reader::maybe_get_doc(item, tag_items_data_item_repr).map(|doc| {
390-
let mut decoder = reader::Decoder::new(doc);
391-
Decodable::decode(&mut decoder).unwrap()
392-
}) {
393-
Some(attrs) => attrs,
394-
None => Vec::new(),
395-
}
396-
}
397-
398387
pub fn get_impl_trait(cdata: Cmd,
399388
id: ast::NodeId,
400389
tcx: &ty::ctxt) -> Option<Rc<ty::TraitRef>>

trunk/src/librustc/metadata/encoder.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,6 @@ fn encode_enum_variant_info(ecx: &EncodeContext,
332332
encode_parent_item(rbml_w, local_def(id));
333333
encode_visibility(rbml_w, variant.node.vis);
334334
encode_attributes(rbml_w, variant.node.attrs.as_slice());
335-
encode_repr_attrs(rbml_w, ecx, variant.node.attrs.as_slice());
336335

337336
let stab = stability::lookup(ecx.tcx, ast_util::local_def(variant.node.id));
338337
encode_stability(rbml_w, stab);
@@ -949,19 +948,6 @@ fn encode_method_argument_names(rbml_w: &mut Encoder,
949948
rbml_w.end_tag();
950949
}
951950

952-
fn encode_repr_attrs(rbml_w: &mut Encoder,
953-
ecx: &EncodeContext,
954-
attrs: &[Attribute]) {
955-
let mut repr_attrs = Vec::new();
956-
for attr in attrs.iter() {
957-
repr_attrs.extend(attr::find_repr_attrs(ecx.tcx.sess.diagnostic(),
958-
attr).into_iter());
959-
}
960-
rbml_w.start_tag(tag_items_data_item_repr);
961-
repr_attrs.encode(rbml_w);
962-
rbml_w.end_tag();
963-
}
964-
965951
fn encode_inlined_item(ecx: &EncodeContext,
966952
rbml_w: &mut Encoder,
967953
ii: InlinedItemRef) {
@@ -1151,7 +1137,6 @@ fn encode_info_for_item(ecx: &EncodeContext,
11511137
encode_bounds_and_type(rbml_w, ecx, &lookup_item_type(tcx, def_id));
11521138
encode_name(rbml_w, item.ident.name);
11531139
encode_attributes(rbml_w, item.attrs.as_slice());
1154-
encode_repr_attrs(rbml_w, ecx, item.attrs.as_slice());
11551140
for v in (*enum_definition).variants.iter() {
11561141
encode_variant_id(rbml_w, local_def(v.node.id));
11571142
}
@@ -1198,7 +1183,6 @@ fn encode_info_for_item(ecx: &EncodeContext,
11981183
encode_path(rbml_w, path.clone());
11991184
encode_stability(rbml_w, stab);
12001185
encode_visibility(rbml_w, vis);
1201-
encode_repr_attrs(rbml_w, ecx, item.attrs.as_slice());
12021186

12031187
/* Encode def_ids for each field and method
12041188
for methods, write all the stuff get_trait_method

trunk/src/librustc/middle/ty.rs

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -583,9 +583,6 @@ pub struct ctxt<'tcx> {
583583
/// Caches the results of trait selection. This cache is used
584584
/// for things that do not have to do with the parameters in scope.
585585
pub selection_cache: traits::SelectionCache,
586-
587-
/// Caches the representation hints for struct definitions.
588-
pub repr_hint_cache: RefCell<DefIdMap<Rc<Vec<attr::ReprAttr>>>>,
589586
}
590587

591588
pub enum tbox_flag {
@@ -1536,7 +1533,6 @@ pub fn mk_ctxt<'tcx>(s: Session,
15361533
associated_types: RefCell::new(DefIdMap::new()),
15371534
trait_associated_types: RefCell::new(DefIdMap::new()),
15381535
selection_cache: traits::SelectionCache::new(),
1539-
repr_hint_cache: RefCell::new(DefIdMap::new()),
15401536
}
15411537
}
15421538

@@ -4330,7 +4326,7 @@ pub fn ty_dtor(cx: &ctxt, struct_id: DefId) -> DtorKind {
43304326
}
43314327

43324328
pub fn has_dtor(cx: &ctxt, struct_id: DefId) -> bool {
4333-
cx.destructor_for_type.borrow().contains_key(&struct_id)
4329+
ty_dtor(cx, struct_id).is_present()
43344330
}
43354331

43364332
pub fn with_path<T>(cx: &ctxt, id: ast::DefId, f: |ast_map::PathElems| -> T) -> T {
@@ -4517,26 +4513,14 @@ pub fn lookup_simd(tcx: &ctxt, did: DefId) -> bool {
45174513
}
45184514

45194515
/// Obtain the representation annotation for a struct definition.
4520-
pub fn lookup_repr_hints(tcx: &ctxt, did: DefId) -> Rc<Vec<attr::ReprAttr>> {
4521-
match tcx.repr_hint_cache.borrow().find(&did) {
4522-
None => {}
4523-
Some(ref hints) => return (*hints).clone(),
4524-
}
4516+
pub fn lookup_repr_hints(tcx: &ctxt, did: DefId) -> Vec<attr::ReprAttr> {
4517+
let mut acc = Vec::new();
45254518

4526-
let acc = if did.krate == LOCAL_CRATE {
4527-
let mut acc = Vec::new();
4528-
ty::each_attr(tcx, did, |meta| {
4529-
acc.extend(attr::find_repr_attrs(tcx.sess.diagnostic(),
4530-
meta).into_iter());
4531-
true
4532-
});
4533-
acc
4534-
} else {
4535-
csearch::get_repr_attrs(&tcx.sess.cstore, did)
4536-
};
4519+
ty::each_attr(tcx, did, |meta| {
4520+
acc.extend(attr::find_repr_attrs(tcx.sess.diagnostic(), meta).into_iter());
4521+
true
4522+
});
45374523

4538-
let acc = Rc::new(acc);
4539-
tcx.repr_hint_cache.borrow_mut().insert(did, acc.clone());
45404524
acc
45414525
}
45424526

trunk/src/libsyntax/ast.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,7 @@ pub enum Expr_ {
521521
ExprLit(P<Lit>),
522522
ExprCast(P<Expr>, P<Ty>),
523523
ExprIf(P<Expr>, P<Block>, Option<P<Expr>>),
524+
ExprIfLet(P<Pat>, P<Expr>, P<Block>, Option<P<Expr>>),
524525
// FIXME #6993: change to Option<Name> ... or not, if these are hygienic.
525526
ExprWhile(P<Expr>, P<Block>, Option<Ident>),
526527
// FIXME #6993: change to Option<Name> ... or not, if these are hygienic.

trunk/src/libsyntax/attr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ fn int_type_of_word(s: &str) -> Option<IntType> {
508508
}
509509
}
510510

511-
#[deriving(PartialEq, Show, Encodable, Decodable)]
511+
#[deriving(PartialEq, Show)]
512512
pub enum ReprAttr {
513513
ReprAny,
514514
ReprInt(Span, IntType),
@@ -527,7 +527,7 @@ impl ReprAttr {
527527
}
528528
}
529529

530-
#[deriving(Eq, Hash, PartialEq, Show, Encodable, Decodable)]
530+
#[deriving(Eq, Hash, PartialEq, Show)]
531531
pub enum IntType {
532532
SignedInt(ast::IntTy),
533533
UnsignedInt(ast::UintTy)

trunk/src/libsyntax/fold.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,6 +1205,12 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span}: Expr, folder: &mut T) ->
12051205
folder.fold_block(tr),
12061206
fl.map(|x| folder.fold_expr(x)))
12071207
}
1208+
ExprIfLet(pat, expr, tr, fl) => {
1209+
ExprIfLet(folder.fold_pat(pat),
1210+
folder.fold_expr(expr),
1211+
folder.fold_block(tr),
1212+
fl.map(|x| folder.fold_expr(x)))
1213+
}
12081214
ExprWhile(cond, body, opt_ident) => {
12091215
ExprWhile(folder.fold_expr(cond),
12101216
folder.fold_block(body),

trunk/src/libsyntax/parse/classify.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use ast;
2424
pub fn expr_requires_semi_to_be_stmt(e: &ast::Expr) -> bool {
2525
match e.node {
2626
ast::ExprIf(..)
27+
| ast::ExprIfLet(..)
2728
| ast::ExprMatch(..)
2829
| ast::ExprBlock(_)
2930
| ast::ExprWhile(..)

trunk/src/libsyntax/parse/parser.rs

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use ast::{DeclLocal, DefaultBlock, UnDeref, BiDiv, EMPTY_CTXT, EnumDef, Explicit
2323
use ast::{Expr, Expr_, ExprAddrOf, ExprMatch, ExprAgain};
2424
use ast::{ExprAssign, ExprAssignOp, ExprBinary, ExprBlock, ExprBox};
2525
use ast::{ExprBreak, ExprCall, ExprCast};
26-
use ast::{ExprField, ExprTupField, ExprFnBlock, ExprIf, ExprIndex, ExprSlice};
26+
use ast::{ExprField, ExprTupField, ExprFnBlock, ExprIf, ExprIfLet, ExprIndex, ExprSlice};
2727
use ast::{ExprLit, ExprLoop, ExprMac};
2828
use ast::{ExprMethodCall, ExprParen, ExprPath, ExprProc};
2929
use ast::{ExprRepeat, ExprRet, ExprStruct, ExprTup, ExprUnary, ExprUnboxedFn};
@@ -576,13 +576,10 @@ impl<'a> Parser<'a> {
576576
/// If the next token is the given keyword, eat it and return
577577
/// true. Otherwise, return false.
578578
pub fn eat_keyword(&mut self, kw: keywords::Keyword) -> bool {
579-
match self.token {
580-
token::IDENT(sid, false) if kw.to_name() == sid.name => {
581-
self.bump();
582-
true
583-
}
584-
_ => false
585-
}
579+
if self.is_keyword(kw) {
580+
self.bump();
581+
true
582+
} else { false }
586583
}
587584

588585
/// If the given word is not a keyword, signal an error.
@@ -2860,8 +2857,11 @@ impl<'a> Parser<'a> {
28602857
}
28612858
}
28622859

2863-
/// Parse an 'if' expression ('if' token already eaten)
2860+
/// Parse an 'if' or 'if let' expression ('if' token already eaten)
28642861
pub fn parse_if_expr(&mut self) -> P<Expr> {
2862+
if self.is_keyword(keywords::Let) {
2863+
return self.parse_if_let_expr();
2864+
}
28652865
let lo = self.last_span.lo;
28662866
let cond = self.parse_expr_res(RestrictionNoStructLiteral);
28672867
let thn = self.parse_block();
@@ -2875,6 +2875,23 @@ impl<'a> Parser<'a> {
28752875
self.mk_expr(lo, hi, ExprIf(cond, thn, els))
28762876
}
28772877

2878+
/// Parse an 'if let' expression ('if' token already eaten)
2879+
pub fn parse_if_let_expr(&mut self) -> P<Expr> {
2880+
let lo = self.last_span.lo;
2881+
self.expect_keyword(keywords::Let);
2882+
let pat = self.parse_pat();
2883+
self.expect(&token::EQ);
2884+
let expr = self.parse_expr_res(RestrictionNoStructLiteral);
2885+
let thn = self.parse_block();
2886+
let (hi, els) = if self.eat_keyword(keywords::Else) {
2887+
let expr = self.parse_else_expr();
2888+
(expr.span.hi, Some(expr))
2889+
} else {
2890+
(thn.span.hi, None)
2891+
};
2892+
self.mk_expr(lo, hi, ExprIfLet(pat, expr, thn, els))
2893+
}
2894+
28782895
// `|args| expr`
28792896
pub fn parse_lambda_expr(&mut self, capture_clause: CaptureClause)
28802897
-> P<Expr> {

trunk/src/libsyntax/print/pprust.rs

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,6 +1307,19 @@ impl<'a> State<'a> {
13071307
try!(self.print_block(&**then));
13081308
self.print_else(e.as_ref().map(|e| &**e))
13091309
}
1310+
// "another else-if-let"
1311+
ast::ExprIfLet(ref pat, ref expr, ref then, ref e) => {
1312+
try!(self.cbox(indent_unit - 1u));
1313+
try!(self.ibox(0u));
1314+
try!(word(&mut self.s, " else if let "));
1315+
try!(self.print_pat(&**pat));
1316+
try!(space(&mut self.s));
1317+
try!(self.word_space("="));
1318+
try!(self.print_expr(&**expr));
1319+
try!(space(&mut self.s));
1320+
try!(self.print_block(&**then));
1321+
self.print_else(e.as_ref().map(|e| &**e))
1322+
}
13101323
// "final else"
13111324
ast::ExprBlock(ref b) => {
13121325
try!(self.cbox(indent_unit - 1u));
@@ -1325,15 +1338,26 @@ impl<'a> State<'a> {
13251338
}
13261339

13271340
pub fn print_if(&mut self, test: &ast::Expr, blk: &ast::Block,
1328-
elseopt: Option<&ast::Expr>, chk: bool) -> IoResult<()> {
1341+
elseopt: Option<&ast::Expr>) -> IoResult<()> {
13291342
try!(self.head("if"));
1330-
if chk { try!(self.word_nbsp("check")); }
13311343
try!(self.print_expr(test));
13321344
try!(space(&mut self.s));
13331345
try!(self.print_block(blk));
13341346
self.print_else(elseopt)
13351347
}
13361348

1349+
pub fn print_if_let(&mut self, pat: &ast::Pat, expr: &ast::Expr, blk: &ast::Block,
1350+
elseopt: Option<&ast::Expr>) -> IoResult<()> {
1351+
try!(self.head("if let"));
1352+
try!(self.print_pat(pat));
1353+
try!(space(&mut self.s));
1354+
try!(self.word_space("="));
1355+
try!(self.print_expr(expr));
1356+
try!(space(&mut self.s));
1357+
try!(self.print_block(blk));
1358+
self.print_else(elseopt)
1359+
}
1360+
13371361
pub fn print_mac(&mut self, m: &ast::Mac) -> IoResult<()> {
13381362
match m.node {
13391363
// I think it's reasonable to hide the ctxt here:
@@ -1474,7 +1498,10 @@ impl<'a> State<'a> {
14741498
try!(self.print_type(&**ty));
14751499
}
14761500
ast::ExprIf(ref test, ref blk, ref elseopt) => {
1477-
try!(self.print_if(&**test, &**blk, elseopt.as_ref().map(|e| &**e), false));
1501+
try!(self.print_if(&**test, &**blk, elseopt.as_ref().map(|e| &**e)));
1502+
}
1503+
ast::ExprIfLet(ref pat, ref expr, ref blk, ref elseopt) => {
1504+
try!(self.print_if_let(&**pat, &**expr, &** blk, elseopt.as_ref().map(|e| &**e)));
14781505
}
14791506
ast::ExprWhile(ref test, ref blk, opt_ident) => {
14801507
for ident in opt_ident.iter() {

trunk/src/libsyntax/visit.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,13 +730,19 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
730730
visitor.visit_expr(&**subexpression);
731731
visitor.visit_block(&**block)
732732
}
733+
ExprIfLet(ref pattern, ref subexpression, ref if_block, ref optional_else) => {
734+
visitor.visit_pat(&**pattern);
735+
visitor.visit_expr(&**subexpression);
736+
visitor.visit_block(&**if_block);
737+
walk_expr_opt(visitor, optional_else);
738+
}
733739
ExprForLoop(ref pattern, ref subexpression, ref block, _) => {
734740
visitor.visit_pat(&**pattern);
735741
visitor.visit_expr(&**subexpression);
736742
visitor.visit_block(&**block)
737743
}
738744
ExprLoop(ref block, _) => visitor.visit_block(&**block),
739-
ExprMatch(ref subexpression, ref arms) => {
745+
ExprMatch(ref subexpression, ref arms, _) => {
740746
visitor.visit_expr(&**subexpression);
741747
for arm in arms.iter() {
742748
visitor.visit_arm(arm)

trunk/src/test/debuginfo/issue12886.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@
99
// except according to those terms.
1010

1111
// ignore-android: FIXME(#10381)
12-
// ignore-windows failing on 64-bit bots FIXME #17638
1312

1413
// compile-flags:-g
15-
// gdb-command:break issue12886.rs:30
14+
// gdb-command:break issue12886.rs:29
1615
// gdb-command:run
1716
// gdb-command:next
18-
// gdb-check:[...]31[...]s
17+
// gdb-check:[...]30[...]s
1918
// gdb-command:continue
2019

2120
// IF YOU MODIFY THIS FILE, BE CAREFUL TO ADAPT THE LINE NUMBERS IN THE DEBUGGER COMMANDS

0 commit comments

Comments
 (0)