Skip to content

Commit 650e521

Browse files
nikomatsakisManishearth
authored andcommitted
---
yaml --- r: 275709 b: refs/heads/master c: ecd10f0 h: refs/heads/master i: 275707: 91cf33f
1 parent 25be6c9 commit 650e521

File tree

35 files changed

+116
-142
lines changed

35 files changed

+116
-142
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: 91aea5cf87953788477ccaa3a37c3f2c855e7a0a
2+
refs/heads/master: ecd10f04cea34352ff240b0462d40cd1d95a4e0f
33
refs/heads/snap-stage3: 235d77457d80b549dad3ac36d94f235208a1eafb
44
refs/heads/try: 49312a405e14a449b98fe0056b12a40ac128be4a
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

trunk/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

trunk/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':

trunk/src/librustc/hir/fold.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,10 +1060,11 @@ 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) => {
1063+
ExprClosure(capture_clause, decl, body, fn_decl_span) => {
10641064
ExprClosure(capture_clause,
10651065
folder.fold_fn_decl(decl),
1066-
folder.fold_block(body))
1066+
folder.fold_block(body),
1067+
folder.new_span(fn_decl_span))
10671068
}
10681069
ExprBlock(blk) => ExprBlock(folder.fold_block(blk)),
10691070
ExprAssign(el, er) => {

trunk/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) => {
788+
ExprClosure(_, ref function_declaration, ref body, _fn_decl_span) => {
789789
visitor.visit_fn(FnKind::Closure(expression.attrs.as_attr_slice()),
790790
function_declaration,
791791
body,

trunk/src/librustc/hir/lowering.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,11 +1260,12 @@ 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) => {
1263+
ExprKind::Closure(capture_clause, ref decl, ref body, fn_decl_span) => {
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))
1267+
lower_block(lctx, body),
1268+
fn_decl_span)
12681269
})
12691270
}
12701271
ExprKind::Block(ref blk) => hir::ExprBlock(lower_block(lctx, blk)),

trunk/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) =>
253+
ast::ExprClosure(_, ref decl, ref block, _fn_decl_span) =>
254254
closure(ClosureParts::new(&decl,
255255
&block,
256256
e.id,

trunk/src/librustc/hir/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -949,8 +949,10 @@ 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-
ExprClosure(CaptureClause, P<FnDecl>, P<Block>),
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),
954956
/// A block (`{ ... }`)
955957
ExprBlock(P<Block>),
956958

trunk/src/librustc/hir/print.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1392,7 +1392,7 @@ impl<'a> State<'a> {
13921392
}
13931393
self.bclose_(expr.span, indent_unit)?;
13941394
}
1395-
hir::ExprClosure(capture_clause, ref decl, ref body) => {
1395+
hir::ExprClosure(capture_clause, ref decl, ref body, _fn_decl_span) => {
13961396
self.print_capture_clause(capture_clause)?;
13971397

13981398
self.print_fn_block_args(&decl)?;

trunk/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(..) => {
541-
self.walk_captures(expr)
540+
hir::ExprClosure(_, _, _, fn_decl_span) => {
541+
self.walk_captures(expr, fn_decl_span)
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) {
1145+
fn walk_captures(&mut self, closure_expr: &hir::Expr, fn_decl_span: Span) {
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-
closure_expr.span,
1155+
fn_decl_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-
closure_expr.span,
1164+
fn_decl_span,
11651165
cmt_var,
11661166
upvar_borrow.region,
11671167
upvar_borrow.kind,

trunk/src/librustc/middle/liveness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

trunk/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
};

trunk/src/librustc_borrowck/borrowck/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ pub fn closure_to_block(closure_id: ast::NodeId,
415415
tcx: &TyCtxt) -> ast::NodeId {
416416
match tcx.map.get(closure_id) {
417417
hir_map::NodeExpr(expr) => match expr.node {
418-
hir::ExprClosure(_, _, ref block) => {
418+
hir::ExprClosure(_, _, ref block, _) => {
419419
block.id
420420
}
421421
_ => {

trunk/src/librustc_mir/hair/cx/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ fn convert_var<'a, 'tcx: 'a>(cx: &mut Cx<'a, 'tcx>,
725725
let body_id = match cx.tcx.map.find(closure_expr_id) {
726726
Some(map::NodeExpr(expr)) => {
727727
match expr.node {
728-
hir::ExprClosure(_, _, ref body) => body.id,
728+
hir::ExprClosure(_, _, ref body, _) => body.id,
729729
_ => {
730730
span_bug!(expr.span, "closure expr is not a closure expr");
731731
}

trunk/src/librustc_passes/loops.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl<'a, 'v> Visitor<'v> for CheckLoopVisitor<'a> {
4848
hir::ExprLoop(ref b, _) => {
4949
self.with_context(Loop, |v| v.visit_block(&b));
5050
}
51-
hir::ExprClosure(_, _, ref b) => {
51+
hir::ExprClosure(_, _, ref b, _) => {
5252
self.with_context(Closure, |v| v.visit_block(&b));
5353
}
5454
hir::ExprBreak(_) => self.require_loop("break", e.span),

trunk/src/librustc_save_analysis/dump_visitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,7 @@ impl<'v, 'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor<'v> for DumpVisitor<'l, 'tcx,
12581258
ty),
12591259
}
12601260
}
1261-
ast::ExprKind::Closure(_, ref decl, ref body) => {
1261+
ast::ExprKind::Closure(_, ref decl, ref body, _fn_decl_span) => {
12621262
let mut id = String::from("$");
12631263
id.push_str(&ex.id.to_string());
12641264
self.process_formals(&decl.inputs, &id);

trunk/src/librustc_trans/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1339,7 +1339,7 @@ fn build_cfg(tcx: &TyCtxt, id: ast::NodeId) -> (ast::NodeId, Option<cfg::CFG>) {
13391339
}
13401340
Some(hir_map::NodeExpr(e)) => {
13411341
match e.node {
1342-
hir::ExprClosure(_, _, ref blk) => blk,
1342+
hir::ExprClosure(_, _, ref blk, _) => blk,
13431343
_ => bug!("unexpected expr variant in has_nested_returns"),
13441344
}
13451345
}

trunk/src/librustc_trans/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
990990
None => C_nil(cx),
991991
}
992992
},
993-
hir::ExprClosure(_, ref decl, ref body) => {
993+
hir::ExprClosure(_, ref decl, ref body, _) => {
994994
match ety.sty {
995995
ty::TyClosure(def_id, ref substs) => {
996996
closure::trans_closure_expr(closure::Dest::Ignore(cx),

trunk/src/librustc_trans/debuginfo/create_scope_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ fn walk_expr(cx: &CrateContext,
479479
})
480480
}
481481

482-
hir::ExprClosure(_, ref decl, ref block) => {
482+
hir::ExprClosure(_, ref decl, ref block, _) => {
483483
with_new_scope(cx,
484484
block.span,
485485
scope_stack,

trunk/src/librustc_trans/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,7 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
11181118
hir::ExprVec(..) | hir::ExprRepeat(..) => {
11191119
tvec::trans_fixed_vstore(bcx, expr, dest)
11201120
}
1121-
hir::ExprClosure(_, ref decl, ref body) => {
1121+
hir::ExprClosure(_, ref decl, ref body, _) => {
11221122
let dest = match dest {
11231123
SaveIn(lldest) => closure::Dest::SaveIn(bcx, lldest),
11241124
Ignore => closure::Dest::Ignore(bcx.ccx())

trunk/src/librustc_typeck/check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3530,7 +3530,7 @@ fn check_expr_with_expectation_and_lvalue_pref<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
35303530
hir::ExprMatch(ref discrim, ref arms, match_src) => {
35313531
_match::check_match(fcx, expr, &discrim, arms, expected, match_src);
35323532
}
3533-
hir::ExprClosure(capture, ref decl, ref body) => {
3533+
hir::ExprClosure(capture, ref decl, ref body, _) => {
35343534
closure::check_expr_closure(fcx, expr, capture, &decl, &body, expected);
35353535
}
35363536
hir::ExprBlock(ref b) => {

trunk/src/librustc_typeck/check/regionck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &hir::Expr) {
782782
intravisit::walk_expr(rcx, expr);
783783
}
784784

785-
hir::ExprClosure(_, _, ref body) => {
785+
hir::ExprClosure(_, _, ref body, _) => {
786786
check_expr_fn_block(rcx, expr, &body);
787787
}
788788

trunk/src/librustc_typeck/check/upvar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ struct SeedBorrowKind<'a,'tcx:'a> {
9898
impl<'a, 'tcx, 'v> Visitor<'v> for SeedBorrowKind<'a, 'tcx> {
9999
fn visit_expr(&mut self, expr: &hir::Expr) {
100100
match expr.node {
101-
hir::ExprClosure(cc, _, ref body) => {
101+
hir::ExprClosure(cc, _, ref body, _) => {
102102
self.check_closure(expr, cc, &body);
103103
}
104104

trunk/src/librustc_typeck/check/writeback.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ impl<'cx, 'tcx, 'v> Visitor<'v> for WritebackCx<'cx, 'tcx> {
156156
self.visit_method_map_entry(ResolvingExpr(e.span),
157157
MethodCall::expr(e.id));
158158

159-
if let hir::ExprClosure(_, ref decl, _) = e.node {
159+
if let hir::ExprClosure(_, ref decl, _, _) = e.node {
160160
for input in &decl.inputs {
161161
self.visit_node_id(ResolvingExpr(e.span), input.id);
162162
}

trunk/src/librustdoc/html/render.rs

Lines changed: 24 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,6 @@ pub struct Cache {
258258
parent_stack: Vec<DefId>,
259259
parent_is_trait_impl: bool,
260260
search_index: Vec<IndexItem>,
261-
seen_modules: HashSet<DefId>,
262-
seen_mod: bool,
263261
stripped_mod: bool,
264262
deref_trait_did: Option<DefId>,
265263

@@ -522,8 +520,6 @@ pub fn run(mut krate: clean::Crate,
522520
parent_is_trait_impl: false,
523521
extern_locations: HashMap::new(),
524522
primitive_locations: HashMap::new(),
525-
seen_modules: HashSet::new(),
526-
seen_mod: false,
527523
stripped_mod: false,
528524
access_levels: krate.access_levels.clone(),
529525
orphan_methods: Vec::new(),
@@ -980,20 +976,13 @@ impl DocFolder for Cache {
980976
// we don't want it or its children in the search index.
981977
let orig_stripped_mod = match item.inner {
982978
clean::StrippedItem(box clean::ModuleItem(..)) => {
983-
mem::replace(&mut self.stripped_mod, true)
979+
let prev = self.stripped_mod;
980+
self.stripped_mod = true;
981+
prev
984982
}
985983
_ => self.stripped_mod,
986984
};
987985

988-
// Inlining can cause us to visit the same item multiple times.
989-
// (i.e. relevant for gathering impls and implementors)
990-
let orig_seen_mod = if item.is_mod() {
991-
let seen_this = self.seen_mod || !self.seen_modules.insert(item.def_id);
992-
mem::replace(&mut self.seen_mod, seen_this)
993-
} else {
994-
self.seen_mod
995-
};
996-
997986
// Register any generics to their corresponding string. This is used
998987
// when pretty-printing types
999988
match item.inner {
@@ -1009,22 +998,20 @@ impl DocFolder for Cache {
1009998
_ => {}
1010999
}
10111000

1012-
if !self.seen_mod {
1013-
// Propagate a trait methods' documentation to all implementors of the
1014-
// trait
1015-
if let clean::TraitItem(ref t) = item.inner {
1016-
self.traits.insert(item.def_id, t.clone());
1017-
}
1001+
// Propagate a trait methods' documentation to all implementors of the
1002+
// trait
1003+
if let clean::TraitItem(ref t) = item.inner {
1004+
self.traits.insert(item.def_id, t.clone());
1005+
}
10181006

1019-
// Collect all the implementors of traits.
1020-
if let clean::ImplItem(ref i) = item.inner {
1021-
if let Some(did) = i.trait_.def_id() {
1022-
self.implementors.entry(did).or_insert(vec![]).push(Implementor {
1023-
def_id: item.def_id,
1024-
stability: item.stability.clone(),
1025-
impl_: i.clone(),
1026-
});
1027-
}
1007+
// Collect all the implementors of traits.
1008+
if let clean::ImplItem(ref i) = item.inner {
1009+
if let Some(did) = i.trait_.def_id() {
1010+
self.implementors.entry(did).or_insert(vec![]).push(Implementor {
1011+
def_id: item.def_id,
1012+
stability: item.stability.clone(),
1013+
impl_: i.clone(),
1014+
});
10281015
}
10291016
}
10301017

@@ -1196,6 +1183,7 @@ impl DocFolder for Cache {
11961183
} => {
11971184
Some(did)
11981185
}
1186+
11991187
ref t => {
12001188
t.primitive_type().and_then(|t| {
12011189
self.primitive_locations.get(&t).map(|n| {
@@ -1205,14 +1193,13 @@ impl DocFolder for Cache {
12051193
})
12061194
}
12071195
};
1208-
if !self.seen_mod {
1209-
if let Some(did) = did {
1210-
self.impls.entry(did).or_insert(vec![]).push(Impl {
1211-
impl_: i,
1212-
dox: attrs.value("doc").map(|s|s.to_owned()),
1213-
stability: item.stability.clone(),
1214-
});
1215-
}
1196+
1197+
if let Some(did) = did {
1198+
self.impls.entry(did).or_insert(vec![]).push(Impl {
1199+
impl_: i,
1200+
dox: attrs.value("doc").map(|s|s.to_owned()),
1201+
stability: item.stability.clone(),
1202+
});
12161203
}
12171204
None
12181205
} else {
@@ -1222,7 +1209,6 @@ impl DocFolder for Cache {
12221209

12231210
if pushed { self.stack.pop().unwrap(); }
12241211
if parent_pushed { self.parent_stack.pop().unwrap(); }
1225-
self.seen_mod = orig_seen_mod;
12261212
self.stripped_mod = orig_stripped_mod;
12271213
self.parent_is_trait_impl = orig_parent_is_trait_impl;
12281214
return ret;

0 commit comments

Comments
 (0)