Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 7 pull requests #30409

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use self::TargetLocation::*;

use common::Config;
use common::{CompileFail, ParseFail, Pretty, RunFail, RunPass, RunPassValgrind};
use common::{Codegen, DebugInfoLldb, DebugInfoGdb, Rustdoc};
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/btree/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use core::marker::PhantomData;
use core::ops::{Deref, DerefMut, Index, IndexMut};
use core::ptr::Unique;
use core::{slice, mem, ptr, cmp};
use alloc::heap::{self, EMPTY};
use alloc::heap;

use borrow::Borrow;

Expand Down
11 changes: 8 additions & 3 deletions src/libcollections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,17 @@ use Bound;

/// A set based on a B-Tree.
///
/// See BTreeMap's documentation for a detailed discussion of this collection's performance
/// See [`BTreeMap`]'s documentation for a detailed discussion of this collection's performance
/// benefits and drawbacks.
///
/// It is a logic error for an item to be modified in such a way that the item's ordering relative
/// to any other item, as determined by the `Ord` trait, changes while it is in the set. This is
/// normally only possible through `Cell`, `RefCell`, global state, I/O, or unsafe code.
/// to any other item, as determined by the [`Ord`] trait, changes while it is in the set. This is
/// normally only possible through [`Cell`], [`RefCell`], global state, I/O, or unsafe code.
///
/// [`BTreeMap`]: ../struct.BTreeMap.html
/// [`Ord`]: ../../core/cmp/trait.Ord.html
/// [`Cell`]: ../../std/cell/struct.Cell.html
/// [`RefCell`]: ../../std/cell/struct.RefCell.html
#[derive(Clone, Hash, PartialEq, Eq, Ord, PartialOrd)]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct BTreeSet<T> {
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use core::fmt;
use core::hash;
use core::iter::FromIterator;
use core::mem;
use core::ops::{self, Deref, Add, Index};
use core::ops::{self, Add};
use core::ptr;
use core::slice;
use core::str::pattern::Pattern;
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ use core::hash::{self, Hash};
use core::intrinsics::{arith_offset, assume, needs_drop};
use core::iter::FromIterator;
use core::mem;
use core::ops::{Index, IndexMut, Deref};
use core::ops::{Index, IndexMut};
use core::ops;
use core::ptr;
use core::slice;
Expand Down
1 change: 0 additions & 1 deletion src/libcore/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ use result::Result;
use result::Result::{Ok, Err};
use ptr;
use mem;
use mem::size_of;
use marker::{Send, Sync, self};
use num::wrapping::OverflowingOps;
use raw::Repr;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/lint/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
use self::TargetLint::*;

use middle::privacy::AccessLevels;
use middle::ty::{self, Ty};
use middle::ty;
use session::{early_error, Session};
use lint::{Level, LevelSource, Lint, LintId, LintArray, LintPass};
use lint::{EarlyLintPass, EarlyLintPassObject, LateLintPass, LateLintPassObject};
Expand Down
5 changes: 3 additions & 2 deletions src/librustc/middle/check_static_recursion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ pub fn check_crate<'ast>(sess: &Session,
ast_map: ast_map,
discriminant_map: RefCell::new(NodeMap()),
};
krate.visit_all_items(&mut visitor);
sess.abort_if_errors();
sess.abort_if_new_errors(|| {
krate.visit_all_items(&mut visitor);
});
}

struct CheckItemRecursionVisitor<'a, 'ast: 'a> {
Expand Down
6 changes: 4 additions & 2 deletions src/librustc/middle/def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pub enum Def {
DefStruct(DefId),
DefLabel(ast::NodeId),
DefMethod(DefId),
DefErr,
}

/// The result of resolving a path.
Expand Down Expand Up @@ -124,7 +125,7 @@ impl Def {
DefVariant(..) | DefTy(..) | DefAssociatedTy(..) |
DefTyParam(..) | DefUse(..) | DefStruct(..) | DefTrait(..) |
DefMethod(..) | DefConst(..) | DefAssociatedConst(..) |
DefPrimTy(..) | DefLabel(..) | DefSelfTy(..) => {
DefPrimTy(..) | DefLabel(..) | DefSelfTy(..) | DefErr => {
panic!("attempted .def_id() on invalid {:?}", self)
}
}
Expand All @@ -142,7 +143,8 @@ impl Def {

DefLabel(..) |
DefPrimTy(..) |
DefSelfTy(..) => {
DefSelfTy(..) |
DefErr => {
panic!("attempted .def_id() on invalid def: {:?}", self)
}
}
Expand Down
1 change: 0 additions & 1 deletion src/librustc/middle/infer/combine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ use super::{InferCtxt};
use super::{MiscVariable, TypeTrace};
use super::type_variable::{RelationDir, BiTo, EqTo, SubtypeOf, SupertypeOf};

use middle::ty::{TyVar};
use middle::ty::{IntType, UintType};
use middle::ty::{self, Ty};
use middle::ty::error::TypeError;
Expand Down
5 changes: 2 additions & 3 deletions src/librustc/middle/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ use middle::region::CodeExtent;
use middle::subst;
use middle::subst::Substs;
use middle::subst::Subst;
use middle::traits::{self, FulfillmentContext, Normalized,
SelectionContext, ObligationCause};
use middle::traits;
use middle::ty::adjustment;
use middle::ty::{TyVid, IntVid, FloatVid, RegionVid};
use middle::ty::{TyVid, IntVid, FloatVid};
use middle::ty::{self, Ty, HasTypeFlags};
use middle::ty::error::{ExpectedFound, TypeError, UnconstrainedNumeric};
use middle::ty::fold::{TypeFolder, TypeFoldable};
Expand Down
14 changes: 9 additions & 5 deletions src/librustc/middle/infer/region_inference/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ pub use self::RegionResolutionError::*;
pub use self::VarValue::*;

use super::{RegionVariableOrigin, SubregionOrigin, TypeTrace, MiscVariable};
use super::unify_key;

use rustc_data_structures::graph::{self, Direction, NodeIndex};
use rustc_data_structures::unify::{self, UnificationTable};
use middle::free_region::FreeRegionMap;
use middle::ty::{self, Ty};
use middle::ty::{BoundRegion, FreeRegion, Region, RegionVid};
use middle::ty::{BoundRegion, Region, RegionVid};
use middle::ty::{ReEmpty, ReStatic, ReFree, ReEarlyBound};
use middle::ty::{ReLateBound, ReScope, ReVar, ReSkolemized, BrFresh};
use middle::ty::error::TypeError;
Expand Down Expand Up @@ -345,10 +346,13 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
}

pub fn new_region_var(&self, origin: RegionVariableOrigin) -> RegionVid {
let id = self.num_vars();
let vid = RegionVid { index: self.num_vars() };
self.var_origins.borrow_mut().push(origin.clone());
let vid = self.unification_table.borrow_mut().new_key(());
assert_eq!(vid.index, id);

let u_vid = self.unification_table.borrow_mut().new_key(
unify_key::RegionVidKey { min_vid: vid }
);
assert_eq!(vid, u_vid);
if self.in_snapshot() {
self.undo_log.borrow_mut().push(AddVar(vid));
}
Expand Down Expand Up @@ -581,7 +585,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
}

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

fn combine_map(&self, t: CombineMapType) -> &RefCell<CombineMap> {
Expand Down
24 changes: 22 additions & 2 deletions src/librustc/middle/infer/unify_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use syntax::ast;
use middle::ty::{self, IntVarValue, Ty};
use rustc_data_structures::unify::UnifyKey;
use rustc_data_structures::unify::{Combine, UnifyKey};

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

#[derive(PartialEq, Copy, Clone, Debug)]
pub struct RegionVidKey {
/// The minimum region vid in the unification set. This is needed
/// to have a canonical name for a type to prevent infinite
/// recursion.
pub min_vid: ty::RegionVid
}

impl Combine for RegionVidKey {
fn combine(&self, other: &RegionVidKey) -> RegionVidKey {
let min_vid = if self.min_vid.index < other.min_vid.index {
self.min_vid
} else {
other.min_vid
};

RegionVidKey { min_vid: min_vid }
}
}

impl UnifyKey for ty::RegionVid {
type Value = ();
type Value = RegionVidKey;
fn index(&self) -> u32 { self.index }
fn from_index(i: u32) -> ty::RegionVid { ty::RegionVid { index: i } }
fn tag(_: Option<ty::RegionVid>) -> &'static str { "RegionVid" }
Expand Down
6 changes: 4 additions & 2 deletions src/librustc/middle/mem_categorization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,8 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
note: NoteNone
}))
}

def::DefErr => panic!("DefErr in memory categorization")
}
}

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

let opt_def = if let Some(path_res) = self.tcx().def_map.borrow().get(&pat.id) {
if path_res.depth != 0 {
if path_res.depth != 0 || path_res.base_def == def::DefErr {
// Since patterns can be associated constants
// which are resolved during typeck, we might have
// some unresolved patterns reaching this stage
Expand Down Expand Up @@ -1261,7 +1263,7 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
_ => {
self.tcx().sess.span_bug(
pat.span,
"enum pattern didn't resolve to enum or struct");
&format!("enum pattern didn't resolve to enum or struct {:?}", opt_def));
}
}
}
Expand Down
17 changes: 9 additions & 8 deletions src/librustc/middle/resolve_lifetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,16 @@ static ROOT_SCOPE: ScopeChain<'static> = RootScope;

pub fn krate(sess: &Session, krate: &hir::Crate, def_map: &DefMap) -> NamedRegionMap {
let mut named_region_map = NodeMap();
krate.visit_all_items(&mut LifetimeContext {
sess: sess,
named_region_map: &mut named_region_map,
scope: &ROOT_SCOPE,
def_map: def_map,
trait_ref_hack: false,
labels_in_fn: vec![],
sess.abort_if_new_errors(|| {
krate.visit_all_items(&mut LifetimeContext {
sess: sess,
named_region_map: &mut named_region_map,
scope: &ROOT_SCOPE,
def_map: def_map,
trait_ref_hack: false,
labels_in_fn: vec![],
});
});
sess.abort_if_errors();
named_region_map
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use syntax::attr::{self, Stability, Deprecation, AttrMetaMethods};
use util::nodemap::{DefIdMap, FnvHashSet, FnvHashMap};

use rustc_front::hir;
use rustc_front::hir::{Block, Crate, Item, Generics, StructField, Variant};
use rustc_front::hir::{Crate, Item, Generics, StructField, Variant};
use rustc_front::intravisit::{self, Visitor};

use std::mem::replace;
Expand Down
6 changes: 2 additions & 4 deletions src/librustc/middle/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use middle::cstore::{self, CrateStore, LOCAL_CRATE};
use middle::def::{self, ExportMap};
use middle::def_id::DefId;
use middle::lang_items::{FnTraitLangItem, FnMutTraitLangItem, FnOnceTraitLangItem};
use middle::subst::{self, ParamSpace, Subst, Substs, VecPerParamSpace};
use middle::subst::{self, Subst, Substs, VecPerParamSpace};
use middle::traits;
use middle::ty;
use middle::ty::fold::TypeFolder;
Expand All @@ -51,7 +51,6 @@ use syntax::parse::token::{InternedString, special_idents};

use rustc_front::hir;
use rustc_front::hir::{ItemImpl, ItemTrait};
use rustc_front::hir::{MutImmutable, MutMutable, Visibility};

pub use self::sty::{Binder, DebruijnIndex};
pub use self::sty::{BuiltinBound, BuiltinBounds, ExistentialBounds};
Expand Down Expand Up @@ -2100,9 +2099,8 @@ impl<'tcx> ctxt<'tcx> {
}) => {
true
}

Some(&def::PathResolution { base_def: def::DefErr, .. })=> true,
Some(..) => false,

None => self.sess.span_bug(expr.span, &format!(
"no def for path {}", expr.id))
}
Expand Down
9 changes: 9 additions & 0 deletions src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,15 @@ impl Session {
_ => {}
}
}
pub fn abort_if_new_errors<F>(&self, mut f: F)
where F: FnMut()
{
let count = self.err_count();
f();
if self.err_count() > count {
self.abort_if_errors();
}
}
pub fn span_warn(&self, sp: Span, msg: &str) {
if self.can_print_warnings {
self.diagnostic().span_warn(sp, msg)
Expand Down
7 changes: 2 additions & 5 deletions src/librustc/util/ppaux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,13 @@

use middle::def_id::DefId;
use middle::subst::{self, Subst};
use middle::ty::{BoundRegion, BrAnon, BrNamed};
use middle::ty::{ReEarlyBound, BrFresh, ctxt};
use middle::ty::{ReFree, ReScope, ReStatic, Region, ReEmpty};
use middle::ty::{ReSkolemized, ReVar, BrEnv};
use middle::ty::{BrAnon, BrEnv, BrFresh, BrNamed};
use middle::ty::{TyBool, TyChar, TyStruct, TyEnum};
use middle::ty::{TyError, TyStr, TyArray, TySlice, TyFloat, TyBareFn};
use middle::ty::{TyParam, TyRawPtr, TyRef, TyTuple};
use middle::ty::TyClosure;
use middle::ty::{TyBox, TyTrait, TyInt, TyUint, TyInfer};
use middle::ty::{self, TypeAndMut, Ty, HasTypeFlags};
use middle::ty::{self, Ty, HasTypeFlags};
use middle::ty::fold::TypeFoldable;

use std::fmt;
Expand Down
8 changes: 5 additions & 3 deletions src/librustc_borrowck/borrowck/gather_loans/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ use syntax::ast;
use syntax::codemap::Span;
use syntax::ast::NodeId;
use rustc_front::hir;
use rustc_front::hir::{Expr, FnDecl, Block, Pat};
use rustc_front::hir::Expr;
use rustc_front::intravisit;
use rustc_front::intravisit::Visitor;

use self::restrictions::RestrictionResult;

mod lifetime;
mod restrictions;
mod gather_moves;
Expand Down Expand Up @@ -354,12 +356,12 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> {

// Create the loan record (if needed).
let loan = match restr {
restrictions::Safe => {
RestrictionResult::Safe => {
// No restrictions---no loan record necessary
return;
}

restrictions::SafeIf(loan_path, restricted_paths) => {
RestrictionResult::SafeIf(loan_path, restricted_paths) => {
let loan_scope = match loan_region {
ty::ReScope(scope) => scope,

Expand Down
Loading