Skip to content

Commit b65ef92

Browse files
committed
---
yaml --- r: 277371 b: refs/heads/try c: 68a18c4 h: refs/heads/master i: 277369: a70a39c 277367: ee58f53
1 parent 5226394 commit b65ef92

File tree

180 files changed

+1195
-1545
lines changed

Some content is hidden

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

180 files changed

+1195
-1545
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 6dbb0e86aec11050480beb76eade6fb805010ba7
33
refs/heads/snap-stage3: 235d77457d80b549dad3ac36d94f235208a1eafb
4-
refs/heads/try: b588f6903dff7a04e094119232c3e980591ecdfc
4+
refs/heads/try: 68a18c4dbc8589a6cffcf16626e3d57633b32463
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/src/doc/book/const-and-static.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,5 @@ the result of a function call or anything similarly complex or at runtime.
7979

8080
Almost always, if you can choose between the two, choose `const`. It’s pretty
8181
rare that you actually want a memory location associated with your constant,
82-
and using a `const` allows for optimizations like constant propagation not only
82+
and using a const allows for optimizations like constant propagation not only
8383
in your crate but downstream crates.

branches/try/src/doc/nomicon/subtyping.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ inferred variance, so `Fn(T)` is invariant in `T`).
5353
Some important variances:
5454

5555
* `&'a T` is variant over `'a` and `T` (as is `*const T` by metaphor)
56-
* `&'a mut T` is variant over `'a` but invariant over `T`
56+
* `&'a mut T` is variant with over `'a` but invariant over `T`
5757
* `Fn(T) -> U` is invariant over `T`, but variant over `U`
5858
* `Box`, `Vec`, and all other collections are variant over the types of
5959
their contents

branches/try/src/etc/generate-keyword-tests.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,15 @@
3434
// option. This file may not be copied, modified, or distributed
3535
// except according to those terms.
3636
37-
// compile-flags: -Z parse-only
38-
3937
// This file was auto-generated using 'src/etc/generate-keyword-tests.py %s'
4038
4139
fn main() {
42-
let %s = "foo"; //~ error: expected pattern, found keyword `%s`
40+
let %s = "foo"; //~ error: ident
4341
}
4442
"""
4543

4644
test_dir = os.path.abspath(
47-
os.path.join(os.path.dirname(__file__), '../test/parse-fail')
45+
os.path.join(os.path.dirname(__file__), '../test/compile-fail')
4846
)
4947

5048
for kw in sys.argv[1:]:
@@ -55,7 +53,7 @@
5553
os.chmod(test_file, stat.S_IWUSR)
5654

5755
with open(test_file, 'wt') as f:
58-
f.write(template % (datetime.datetime.now().year, kw, kw, kw))
56+
f.write(template % (datetime.datetime.now().year, kw, kw))
5957

6058
# mark file read-only
6159
os.chmod(test_file, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)

branches/try/src/etc/htmldocck.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,9 @@ def check_tree_text(tree, path, pat, regexp):
342342
return ret
343343

344344

345-
def get_tree_count(tree, path):
345+
def check_tree_count(tree, path, count):
346346
path = normalize_xpath(path)
347-
return len(tree.findall(path))
347+
return len(tree.findall(path)) == count
348348

349349
def stderr(*args):
350350
print(*args, file=sys.stderr)
@@ -393,10 +393,7 @@ def check_command(c, cache):
393393

394394
elif c.cmd == 'count': # count test
395395
if len(c.args) == 3: # @count <path> <pat> <count> = count test
396-
expected = int(c.args[2])
397-
found = get_tree_count(cache.get_tree(c.args[0]), c.args[1])
398-
cerr = "Expected {} occurrences but found {}".format(expected, found)
399-
ret = expected == found
396+
ret = check_tree_count(cache.get_tree(c.args[0]), c.args[1], int(c.args[2]))
400397
else:
401398
raise InvalidCheck('Invalid number of @{} arguments'.format(c.cmd))
402399
elif c.cmd == 'valid-html':

branches/try/src/libcore/iter/iterator.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -598,13 +598,13 @@ pub trait Iterator {
598598
/// # Examples
599599
///
600600
/// ```
601-
/// let a = ['a', 'b', 'c'];
601+
/// let a = [1, 2, 3];
602602
///
603603
/// let mut iter = a.iter().enumerate();
604604
///
605-
/// assert_eq!(iter.next(), Some((0, &'a')));
606-
/// assert_eq!(iter.next(), Some((1, &'b')));
607-
/// assert_eq!(iter.next(), Some((2, &'c')));
605+
/// assert_eq!(iter.next(), Some((0, &1)));
606+
/// assert_eq!(iter.next(), Some((1, &2)));
607+
/// assert_eq!(iter.next(), Some((2, &3)));
608608
/// assert_eq!(iter.next(), None);
609609
/// ```
610610
#[inline]
@@ -2109,3 +2109,4 @@ impl<'a, I: Iterator + ?Sized> Iterator for &'a mut I {
21092109
fn next(&mut self) -> Option<I::Item> { (**self).next() }
21102110
fn size_hint(&self) -> (usize, Option<usize>) { (**self).size_hint() }
21112111
}
2112+

branches/try/src/librustc/hir/fold.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use syntax::attr::ThinAttributesExt;
1818
use hir;
1919
use syntax::codemap::{respan, Span, Spanned};
2020
use syntax::ptr::P;
21-
use syntax::parse::token::keywords;
21+
use syntax::parse::token;
2222
use syntax::util::move_map::MoveMap;
2323

2424
pub trait Folder : Sized {
@@ -867,7 +867,7 @@ pub fn noop_fold_crate<T: Folder>(Crate { module, attrs, config, span,
867867
let config = folder.fold_meta_items(config);
868868

869869
let crate_mod = folder.fold_item(hir::Item {
870-
name: keywords::Invalid.name(),
870+
name: token::special_idents::invalid.name,
871871
attrs: attrs,
872872
id: DUMMY_NODE_ID,
873873
vis: hir::Public,
@@ -1060,11 +1060,10 @@ pub fn noop_fold_expr<T: Folder>(Expr { id, node, span, attrs }: Expr, folder: &
10601060
arms.move_map(|x| folder.fold_arm(x)),
10611061
source)
10621062
}
1063-
ExprClosure(capture_clause, decl, body, fn_decl_span) => {
1063+
ExprClosure(capture_clause, decl, body) => {
10641064
ExprClosure(capture_clause,
10651065
folder.fold_fn_decl(decl),
1066-
folder.fold_block(body),
1067-
folder.new_span(fn_decl_span))
1066+
folder.fold_block(body))
10681067
}
10691068
ExprBlock(blk) => ExprBlock(folder.fold_block(blk)),
10701069
ExprAssign(el, er) => {

branches/try/src/librustc/hir/intravisit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
785785
visitor.visit_expr(subexpression);
786786
walk_list!(visitor, visit_arm, arms);
787787
}
788-
ExprClosure(_, ref function_declaration, ref body, _fn_decl_span) => {
788+
ExprClosure(_, ref function_declaration, ref body) => {
789789
visitor.visit_fn(FnKind::Closure(expression.attrs.as_attr_slice()),
790790
function_declaration,
791791
body,

branches/try/src/librustc/hir/lowering.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,12 +1260,11 @@ pub fn lower_expr(lctx: &LoweringContext, e: &Expr) -> P<hir::Expr> {
12601260
arms.iter().map(|x| lower_arm(lctx, x)).collect(),
12611261
hir::MatchSource::Normal)
12621262
}
1263-
ExprKind::Closure(capture_clause, ref decl, ref body, fn_decl_span) => {
1263+
ExprKind::Closure(capture_clause, ref decl, ref body) => {
12641264
lctx.with_parent_def(e.id, || {
12651265
hir::ExprClosure(lower_capture_clause(lctx, capture_clause),
12661266
lower_fn_decl(lctx, decl),
1267-
lower_block(lctx, body),
1268-
fn_decl_span)
1267+
lower_block(lctx, body))
12691268
})
12701269
}
12711270
ExprKind::Block(ref blk) => hir::ExprBlock(lower_block(lctx, blk)),

branches/try/src/librustc/hir/map/blocks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ impl<'a> FnLikeNode<'a> {
250250
}
251251
}
252252
map::NodeExpr(e) => match e.node {
253-
ast::ExprClosure(_, ref decl, ref block, _fn_decl_span) =>
253+
ast::ExprClosure(_, ref decl, ref block) =>
254254
closure(ClosureParts::new(&decl,
255255
&block,
256256
e.id,

branches/try/src/librustc/hir/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -949,10 +949,8 @@ pub enum Expr_ {
949949
/// A `match` block, with a source that indicates whether or not it is
950950
/// the result of a desugaring, and if so, which kind.
951951
ExprMatch(P<Expr>, HirVec<Arm>, MatchSource),
952-
/// A closure (for example, `move |a, b, c| {a + b + c}`).
953-
///
954-
/// The final span is the span of the argument block `|...|`
955-
ExprClosure(CaptureClause, P<FnDecl>, P<Block>, Span),
952+
/// A closure (for example, `move |a, b, c| {a + b + c}`)
953+
ExprClosure(CaptureClause, P<FnDecl>, P<Block>),
956954
/// A block (`{ ... }`)
957955
ExprBlock(P<Block>),
958956

branches/try/src/librustc/hir/print.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ use syntax::abi::Abi;
1414
use syntax::ast;
1515
use syntax::codemap::{self, CodeMap, BytePos, Spanned};
1616
use syntax::errors;
17-
use syntax::parse::token::{self, keywords, BinOpToken};
17+
use syntax::parse::token::{self, BinOpToken};
1818
use syntax::parse::lexer::comments;
19+
use syntax::parse;
1920
use syntax::print::pp::{self, break_offset, word, space, hardbreak};
2021
use syntax::print::pp::{Breaks, eof};
2122
use syntax::print::pp::Breaks::{Consistent, Inconsistent};
@@ -1391,7 +1392,7 @@ impl<'a> State<'a> {
13911392
}
13921393
self.bclose_(expr.span, indent_unit)?;
13931394
}
1394-
hir::ExprClosure(capture_clause, ref decl, ref body, _fn_decl_span) => {
1395+
hir::ExprClosure(capture_clause, ref decl, ref body) => {
13951396
self.print_capture_clause(capture_clause)?;
13961397

13971398
self.print_fn_block_args(&decl)?;
@@ -2208,8 +2209,9 @@ impl<'a> State<'a> {
22082209
hir::TyInfer if is_closure => self.print_pat(&input.pat)?,
22092210
_ => {
22102211
match input.pat.node {
2211-
PatKind::Ident(_, ref path1, _)
2212-
if path1.node.name == keywords::Invalid.name() => {
2212+
PatKind::Ident(_, ref path1, _) if
2213+
path1.node.name ==
2214+
parse::token::special_idents::invalid.name => {
22132215
// Do nothing.
22142216
}
22152217
_ => {

branches/try/src/librustc/infer/mod.rs

Lines changed: 5 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use ty::fold::TypeFoldable;
3535
use ty::relate::{Relate, RelateResult, TypeRelation};
3636
use traits::{self, PredicateObligations, ProjectionMode};
3737
use rustc_data_structures::unify::{self, UnificationTable};
38-
use std::cell::{Cell, RefCell, Ref};
38+
use std::cell::{RefCell, Ref};
3939
use std::fmt;
4040
use syntax::ast;
4141
use syntax::codemap;
@@ -110,25 +110,6 @@ pub struct InferCtxt<'a, 'tcx: 'a> {
110110
// documentation for `ProjectionMode`.
111111
projection_mode: ProjectionMode,
112112

113-
// When an error occurs, we want to avoid reporting "derived"
114-
// errors that are due to this original failure. Normally, we
115-
// handle this with the `err_count_on_creation` count, which
116-
// basically just tracks how many errors were reported when we
117-
// started type-checking a fn and checks to see if any new errors
118-
// have been reported since then. Not great, but it works.
119-
//
120-
// However, when errors originated in other passes -- notably
121-
// resolve -- this heuristic breaks down. Therefore, we have this
122-
// auxiliary flag that one can set whenever one creates a
123-
// type-error that is due to an error in a prior pass.
124-
//
125-
// Don't read this flag directly, call `is_tainted_by_errors()`
126-
// and `set_tainted_by_errors()`.
127-
tainted_by_errors_flag: Cell<bool>,
128-
129-
// Track how many errors were reported when this infcx is created.
130-
// If the number of errors increases, that's also a sign (line
131-
// `tained_by_errors`) to avoid reporting certain kinds of errors.
132113
err_count_on_creation: usize,
133114
}
134115

@@ -398,7 +379,6 @@ pub fn new_infer_ctxt<'a, 'tcx>(tcx: &'a TyCtxt<'tcx>,
398379
reported_trait_errors: RefCell::new(FnvHashSet()),
399380
normalize: false,
400381
projection_mode: projection_mode,
401-
tainted_by_errors_flag: Cell::new(false),
402382
err_count_on_creation: tcx.sess.err_count()
403383
}
404384
}
@@ -1148,36 +1128,15 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
11481128
.map(|method| resolve_ty(method.ty)))
11491129
}
11501130

1151-
/// True if errors have been reported since this infcx was
1152-
/// created. This is sometimes used as a heuristic to skip
1153-
/// reporting errors that often occur as a result of earlier
1154-
/// errors, but where it's hard to be 100% sure (e.g., unresolved
1155-
/// inference variables, regionck errors).
1156-
pub fn is_tainted_by_errors(&self) -> bool {
1157-
debug!("is_tainted_by_errors(err_count={}, err_count_on_creation={}, \
1158-
tainted_by_errors_flag={})",
1159-
self.tcx.sess.err_count(),
1160-
self.err_count_on_creation,
1161-
self.tainted_by_errors_flag.get());
1162-
1163-
if self.tcx.sess.err_count() > self.err_count_on_creation {
1164-
return true; // errors reported since this infcx was made
1165-
}
1166-
self.tainted_by_errors_flag.get()
1167-
}
1168-
1169-
/// Set the "tainted by errors" flag to true. We call this when we
1170-
/// observe an error from a prior pass.
1171-
pub fn set_tainted_by_errors(&self) {
1172-
debug!("set_tainted_by_errors()");
1173-
self.tainted_by_errors_flag.set(true)
1131+
pub fn errors_since_creation(&self) -> bool {
1132+
self.tcx.sess.err_count() - self.err_count_on_creation != 0
11741133
}
11751134

11761135
pub fn node_type(&self, id: ast::NodeId) -> Ty<'tcx> {
11771136
match self.tables.borrow().node_types.get(&id) {
11781137
Some(&t) => t,
11791138
// FIXME
1180-
None if self.is_tainted_by_errors() =>
1139+
None if self.errors_since_creation() =>
11811140
self.tcx.types.err,
11821141
None => {
11831142
bug!("no type for node {}: {} in fcx",
@@ -1199,7 +1158,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
11991158
free_regions: &FreeRegionMap,
12001159
subject_node_id: ast::NodeId) {
12011160
let errors = self.region_vars.resolve_regions(free_regions, subject_node_id);
1202-
if !self.is_tainted_by_errors() {
1161+
if !self.errors_since_creation() {
12031162
// As a heuristic, just skip reporting region errors
12041163
// altogether if other errors have been reported while
12051164
// this infcx was in use. This is totally hokey but

branches/try/src/librustc/infer/sub.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Sub<'a, 'tcx> {
9191
}
9292

9393
(&ty::TyError, _) | (_, &ty::TyError) => {
94-
infcx.set_tainted_by_errors();
9594
Ok(self.tcx().types.err)
9695
}
9796

branches/try/src/librustc/middle/expr_use_visitor.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -537,8 +537,8 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
537537
self.consume_expr(&count);
538538
}
539539

540-
hir::ExprClosure(_, _, _, fn_decl_span) => {
541-
self.walk_captures(expr, fn_decl_span)
540+
hir::ExprClosure(..) => {
541+
self.walk_captures(expr)
542542
}
543543

544544
hir::ExprBox(ref base) => {
@@ -1142,7 +1142,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
11421142
}));
11431143
}
11441144

1145-
fn walk_captures(&mut self, closure_expr: &hir::Expr, fn_decl_span: Span) {
1145+
fn walk_captures(&mut self, closure_expr: &hir::Expr) {
11461146
debug!("walk_captures({:?})", closure_expr);
11471147

11481148
self.tcx().with_freevars(closure_expr.id, |freevars| {
@@ -1152,7 +1152,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
11521152
closure_expr_id: closure_expr.id };
11531153
let upvar_capture = self.typer.upvar_capture(upvar_id).unwrap();
11541154
let cmt_var = return_if_err!(self.cat_captured_var(closure_expr.id,
1155-
fn_decl_span,
1155+
closure_expr.span,
11561156
freevar.def));
11571157
match upvar_capture {
11581158
ty::UpvarCapture::ByValue => {
@@ -1161,7 +1161,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
11611161
}
11621162
ty::UpvarCapture::ByRef(upvar_borrow) => {
11631163
self.delegate.borrow(closure_expr.id,
1164-
fn_decl_span,
1164+
closure_expr.span,
11651165
cmt_var,
11661166
upvar_borrow.region,
11671167
upvar_borrow.kind,

branches/try/src/librustc/middle/liveness.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ use std::io;
125125
use std::rc::Rc;
126126
use syntax::ast::{self, NodeId};
127127
use syntax::codemap::{BytePos, original_sp, Span};
128-
use syntax::parse::token::keywords;
128+
use syntax::parse::token::special_idents;
129129
use syntax::ptr::P;
130130

131131
use hir::Expr;
@@ -948,7 +948,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
948948
self.propagate_through_expr(&e, succ)
949949
}
950950

951-
hir::ExprClosure(_, _, ref blk, _) => {
951+
hir::ExprClosure(_, _, ref blk) => {
952952
debug!("{} is an ExprClosure",
953953
expr_to_string(expr));
954954

@@ -1578,7 +1578,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
15781578
let var = self.variable(p_id, sp);
15791579
// Ignore unused self.
15801580
let name = path1.node;
1581-
if name != keywords::SelfValue.name() {
1581+
if name != special_idents::self_.name {
15821582
if !self.warn_about_unused(sp, p_id, entry_ln, var) {
15831583
if self.live_on_entry(entry_ln, var).is_none() {
15841584
self.report_dead_assign(p_id, sp, var, true);

branches/try/src/librustc/middle/mem_categorization.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
728728
};
729729

730730
match fn_expr.node {
731-
hir::ExprClosure(_, _, ref body, _) => body.id,
731+
hir::ExprClosure(_, _, ref body) => body.id,
732732
_ => bug!()
733733
}
734734
};

0 commit comments

Comments
 (0)