Skip to content

Commit 785a8a6

Browse files
committed
Auto merge of #30410 - Manishearth:rollup, r=Manishearth
- Successful merges: #30320, #30368, #30372, #30376, #30388, #30392 - Failed merges: #30354, #30389
2 parents ce7bc51 + f0361a0 commit 785a8a6

Some content is hidden

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

64 files changed

+455
-270
lines changed

src/libcollections/btree/set.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,17 @@ use Bound;
2626

2727
/// A set based on a B-Tree.
2828
///
29-
/// See BTreeMap's documentation for a detailed discussion of this collection's performance
29+
/// See [`BTreeMap`]'s documentation for a detailed discussion of this collection's performance
3030
/// benefits and drawbacks.
3131
///
3232
/// It is a logic error for an item to be modified in such a way that the item's ordering relative
33-
/// to any other item, as determined by the `Ord` trait, changes while it is in the set. This is
34-
/// normally only possible through `Cell`, `RefCell`, global state, I/O, or unsafe code.
33+
/// to any other item, as determined by the [`Ord`] trait, changes while it is in the set. This is
34+
/// normally only possible through [`Cell`], [`RefCell`], global state, I/O, or unsafe code.
35+
///
36+
/// [`BTreeMap`]: ../struct.BTreeMap.html
37+
/// [`Ord`]: ../../core/cmp/trait.Ord.html
38+
/// [`Cell`]: ../../std/cell/struct.Cell.html
39+
/// [`RefCell`]: ../../std/cell/struct.RefCell.html
3540
#[derive(Clone, Hash, PartialEq, Eq, Ord, PartialOrd)]
3641
#[stable(feature = "rust1", since = "1.0.0")]
3742
pub struct BTreeSet<T> {

src/librustc/middle/check_static_recursion.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,9 @@ pub fn check_crate<'ast>(sess: &Session,
9999
ast_map: ast_map,
100100
discriminant_map: RefCell::new(NodeMap()),
101101
};
102-
krate.visit_all_items(&mut visitor);
103-
sess.abort_if_errors();
102+
sess.abort_if_new_errors(|| {
103+
krate.visit_all_items(&mut visitor);
104+
});
104105
}
105106

106107
struct CheckItemRecursionVisitor<'a, 'ast: 'a> {

src/librustc/middle/def.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ pub enum Def {
5252
DefStruct(DefId),
5353
DefLabel(ast::NodeId),
5454
DefMethod(DefId),
55+
DefErr,
5556
}
5657

5758
/// The result of resolving a path.
@@ -124,7 +125,7 @@ impl Def {
124125
DefVariant(..) | DefTy(..) | DefAssociatedTy(..) |
125126
DefTyParam(..) | DefUse(..) | DefStruct(..) | DefTrait(..) |
126127
DefMethod(..) | DefConst(..) | DefAssociatedConst(..) |
127-
DefPrimTy(..) | DefLabel(..) | DefSelfTy(..) => {
128+
DefPrimTy(..) | DefLabel(..) | DefSelfTy(..) | DefErr => {
128129
panic!("attempted .def_id() on invalid {:?}", self)
129130
}
130131
}
@@ -142,7 +143,8 @@ impl Def {
142143

143144
DefLabel(..) |
144145
DefPrimTy(..) |
145-
DefSelfTy(..) => {
146+
DefSelfTy(..) |
147+
DefErr => {
146148
panic!("attempted .def_id() on invalid def: {:?}", self)
147149
}
148150
}

src/librustc/middle/infer/region_inference/mod.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub use self::RegionResolutionError::*;
1818
pub use self::VarValue::*;
1919

2020
use super::{RegionVariableOrigin, SubregionOrigin, TypeTrace, MiscVariable};
21+
use super::unify_key;
2122

2223
use rustc_data_structures::graph::{self, Direction, NodeIndex};
2324
use rustc_data_structures::unify::{self, UnificationTable};
@@ -345,10 +346,13 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
345346
}
346347

347348
pub fn new_region_var(&self, origin: RegionVariableOrigin) -> RegionVid {
348-
let id = self.num_vars();
349+
let vid = RegionVid { index: self.num_vars() };
349350
self.var_origins.borrow_mut().push(origin.clone());
350-
let vid = self.unification_table.borrow_mut().new_key(());
351-
assert_eq!(vid.index, id);
351+
352+
let u_vid = self.unification_table.borrow_mut().new_key(
353+
unify_key::RegionVidKey { min_vid: vid }
354+
);
355+
assert_eq!(vid, u_vid);
352356
if self.in_snapshot() {
353357
self.undo_log.borrow_mut().push(AddVar(vid));
354358
}
@@ -581,7 +585,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
581585
}
582586

583587
pub fn opportunistic_resolve_var(&self, rid: RegionVid) -> ty::Region {
584-
ty::ReVar(self.unification_table.borrow_mut().find(rid))
588+
ty::ReVar(self.unification_table.borrow_mut().find_value(rid).min_vid)
585589
}
586590

587591
fn combine_map(&self, t: CombineMapType) -> &RefCell<CombineMap> {

src/librustc/middle/infer/unify_key.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use syntax::ast;
1212
use middle::ty::{self, IntVarValue, Ty};
13-
use rustc_data_structures::unify::UnifyKey;
13+
use rustc_data_structures::unify::{Combine, UnifyKey};
1414

1515
pub trait ToType<'tcx> {
1616
fn to_type(&self, tcx: &ty::ctxt<'tcx>) -> Ty<'tcx>;
@@ -23,8 +23,28 @@ impl UnifyKey for ty::IntVid {
2323
fn tag(_: Option<ty::IntVid>) -> &'static str { "IntVid" }
2424
}
2525

26+
#[derive(PartialEq, Copy, Clone, Debug)]
27+
pub struct RegionVidKey {
28+
/// The minimum region vid in the unification set. This is needed
29+
/// to have a canonical name for a type to prevent infinite
30+
/// recursion.
31+
pub min_vid: ty::RegionVid
32+
}
33+
34+
impl Combine for RegionVidKey {
35+
fn combine(&self, other: &RegionVidKey) -> RegionVidKey {
36+
let min_vid = if self.min_vid.index < other.min_vid.index {
37+
self.min_vid
38+
} else {
39+
other.min_vid
40+
};
41+
42+
RegionVidKey { min_vid: min_vid }
43+
}
44+
}
45+
2646
impl UnifyKey for ty::RegionVid {
27-
type Value = ();
47+
type Value = RegionVidKey;
2848
fn index(&self) -> u32 { self.index }
2949
fn from_index(i: u32) -> ty::RegionVid { ty::RegionVid { index: i } }
3050
fn tag(_: Option<ty::RegionVid>) -> &'static str { "RegionVid" }

src/librustc/middle/mem_categorization.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,8 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
609609
note: NoteNone
610610
}))
611611
}
612+
613+
def::DefErr => panic!("DefErr in memory categorization")
612614
}
613615
}
614616

@@ -1196,7 +1198,7 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
11961198
(*op)(self, cmt.clone(), pat);
11971199

11981200
let opt_def = if let Some(path_res) = self.tcx().def_map.borrow().get(&pat.id) {
1199-
if path_res.depth != 0 {
1201+
if path_res.depth != 0 || path_res.base_def == def::DefErr {
12001202
// Since patterns can be associated constants
12011203
// which are resolved during typeck, we might have
12021204
// some unresolved patterns reaching this stage
@@ -1261,7 +1263,7 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
12611263
_ => {
12621264
self.tcx().sess.span_bug(
12631265
pat.span,
1264-
"enum pattern didn't resolve to enum or struct");
1266+
&format!("enum pattern didn't resolve to enum or struct {:?}", opt_def));
12651267
}
12661268
}
12671269
}

src/librustc/middle/resolve_lifetime.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,16 @@ static ROOT_SCOPE: ScopeChain<'static> = RootScope;
9595

9696
pub fn krate(sess: &Session, krate: &hir::Crate, def_map: &DefMap) -> NamedRegionMap {
9797
let mut named_region_map = NodeMap();
98-
krate.visit_all_items(&mut LifetimeContext {
99-
sess: sess,
100-
named_region_map: &mut named_region_map,
101-
scope: &ROOT_SCOPE,
102-
def_map: def_map,
103-
trait_ref_hack: false,
104-
labels_in_fn: vec![],
98+
sess.abort_if_new_errors(|| {
99+
krate.visit_all_items(&mut LifetimeContext {
100+
sess: sess,
101+
named_region_map: &mut named_region_map,
102+
scope: &ROOT_SCOPE,
103+
def_map: def_map,
104+
trait_ref_hack: false,
105+
labels_in_fn: vec![],
106+
});
105107
});
106-
sess.abort_if_errors();
107108
named_region_map
108109
}
109110

src/librustc/middle/ty/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2100,9 +2100,8 @@ impl<'tcx> ctxt<'tcx> {
21002100
}) => {
21012101
true
21022102
}
2103-
2103+
Some(&def::PathResolution { base_def: def::DefErr, .. })=> true,
21042104
Some(..) => false,
2105-
21062105
None => self.sess.span_bug(expr.span, &format!(
21072106
"no def for path {}", expr.id))
21082107
}

src/librustc/session/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,15 @@ impl Session {
156156
_ => {}
157157
}
158158
}
159+
pub fn abort_if_new_errors<F>(&self, mut f: F)
160+
where F: FnMut()
161+
{
162+
let count = self.err_count();
163+
f();
164+
if self.err_count() > count {
165+
self.abort_if_errors();
166+
}
167+
}
159168
pub fn span_warn(&self, sp: Span, msg: &str) {
160169
if self.can_print_warnings {
161170
self.diagnostic().span_warn(sp, msg)

src/librustc_borrowck/borrowck/gather_loans/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ use rustc_front::hir::{Expr, FnDecl, Block, Pat};
3333
use rustc_front::intravisit;
3434
use rustc_front::intravisit::Visitor;
3535

36+
use self::restrictions::RestrictionResult;
37+
3638
mod lifetime;
3739
mod restrictions;
3840
mod gather_moves;
@@ -354,12 +356,12 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> {
354356

355357
// Create the loan record (if needed).
356358
let loan = match restr {
357-
restrictions::Safe => {
359+
RestrictionResult::Safe => {
358360
// No restrictions---no loan record necessary
359361
return;
360362
}
361363

362-
restrictions::SafeIf(loan_path, restricted_paths) => {
364+
RestrictionResult::SafeIf(loan_path, restricted_paths) => {
363365
let loan_scope = match loan_region {
364366
ty::ReScope(scope) => scope,
365367

0 commit comments

Comments
 (0)