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 15 pull requests #55990

Closed
wants to merge 51 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
e753d21
miri: accept extern types in structs if they are the only field
RalfJung Nov 4, 2018
aca76d4
test for offset and alignment of the sized part, instead of field count
RalfJung Nov 4, 2018
bb17f71
also test with PhantomData
RalfJung Nov 4, 2018
5ebd077
make it more obvious that the size is not relevant
RalfJung Nov 5, 2018
a6622c2
note some FIXMEs
RalfJung Nov 5, 2018
ba0bab3
make sure we only guess field alignment at offset 0
RalfJung Nov 6, 2018
b7c319c
do not panic just because cargo failed
RalfJung Nov 11, 2018
0c08529
A few tweaks to iterations/collecting
ljedrz Nov 5, 2018
562be7e
Forward the ABI of the non-zero sized fields of an union if they have…
ogoffart Nov 8, 2018
547ac5e
save-analysis: be even more aggressive about ignorning macro-generate…
nrc Nov 13, 2018
ec7d69b
Distinguish between placeholder kinds
scalexm Nov 2, 2018
669cf7b
Introduce `TyKind::Placeholder` variant
scalexm Nov 2, 2018
4fefd64
Rename some occurences of `skol` to `placeholder`
scalexm Nov 2, 2018
c181d51
Add `HAS_TY_PLACEHOLDER` flag
scalexm Nov 2, 2018
df07c9d
Handle placeholder types in canonicalization
scalexm Nov 2, 2018
920feb6
Instantiate all bound vars universally
scalexm Nov 3, 2018
05f1847
Move `BoundTy` debruijn index to the `TyKind` enum variant
scalexm Nov 3, 2018
3b1f74c
Implement some instantiate / canonical routines
scalexm Nov 3, 2018
f6aa0bd
Fix `ChalkInferenceContext::into_hh_goal`
scalexm Nov 5, 2018
1736391
Fix NLL ui test
scalexm Nov 14, 2018
2ec6f34
Update CI-clang to 7.0.0 for Linux dists.
michaelwoerister Nov 14, 2018
f6b8eb7
Update CI-clang to 7.0.0 for macOS dists.
michaelwoerister Nov 14, 2018
1ca505a
capture_disjoint_fields(rust-lang#53488)
blitzerr Nov 14, 2018
c040a48
Remove extern and some return value as an attempt to make the test pa…
ogoffart Nov 14, 2018
aa3d7a4
properly calculate spans for intra-doc link resolution errors
QuietMisdreavus Nov 15, 2018
a1f83e7
Stress test for MPSC
stepancheg Nov 15, 2018
166f7d9
Implement checked_add_duration for SystemTime
sgeisler Oct 31, 2018
8231831
Rename checked_add_duration to checked_add and make it take the durat…
sgeisler Nov 5, 2018
6779bb4
capture_disjoint_fields(rust-lang#53488)
blitzerr Nov 15, 2018
c5bc83b
expose MutValueVisitor
RalfJung Nov 13, 2018
e4d03f8
miri value visitor: provide place when visiting a primitive
RalfJung Nov 13, 2018
e6e5635
ty: return impl Iterator from Predicate::walk_tys
ljedrz Nov 14, 2018
ffb6ba0
validation: better error when the enum discriminant is Undef
RalfJung Nov 12, 2018
a3770c2
do not accept out-of-bounds pointers in enum discriminants, they migh…
RalfJung Nov 12, 2018
b8915f2
fix other affected tests
RalfJung Nov 12, 2018
8c8ff6a
test/linkage-visibility: Ignore on musl targets
smaeul Sep 16, 2018
939ff0a
Rollup merge of #55527 - sgeisler:time-checked-add, r=sfackler
pietroalbini Nov 15, 2018
bac640f
Rollup merge of #55564 - smaeul:test-fixes-2, r=alexcrichton
pietroalbini Nov 15, 2018
672bc75
Rollup merge of #55672 - RalfJung:miri-extern-types, r=eddyb
pietroalbini Nov 15, 2018
a43c718
Rollup merge of #55827 - ljedrz:various_stashed, r=alexcrichton
pietroalbini Nov 15, 2018
d852bdc
Rollup merge of #55834 - ogoffart:union-abi, r=eddyb
pietroalbini Nov 15, 2018
bd9fd38
Rollup merge of #55867 - RalfJung:dont-panic, r=Mark-Simulacrum
pietroalbini Nov 15, 2018
1d4c2a1
Rollup merge of #55894 - RalfJung:validation-enums, r=oli-obk
pietroalbini Nov 15, 2018
eef9507
Rollup merge of #55916 - RalfJung:mut-visitor, r=oli-obk
pietroalbini Nov 15, 2018
d4b4738
Rollup merge of #55921 - scalexm:placeholders, r=nikomatsakis
pietroalbini Nov 15, 2018
0d97c1a
Rollup merge of #55936 - nrc:save-rename, r=eddyb
pietroalbini Nov 15, 2018
70cbccc
Rollup merge of #55949 - ljedrz:return_impl_Iterator_from_Predicate_w…
pietroalbini Nov 15, 2018
6104758
Rollup merge of #55952 - michaelwoerister:newer-clang, r=alexcrichton
pietroalbini Nov 15, 2018
357031a
Rollup merge of #55953 - blitzerr:master, r=nikomatsakis
pietroalbini Nov 15, 2018
fd65e25
Rollup merge of #55962 - QuietMisdreavus:tricky-spans, r=GuillaumeGomez
pietroalbini Nov 15, 2018
443e50c
Rollup merge of #55963 - stepancheg:mpsc-take-2, r=alexcrichton
pietroalbini Nov 15, 2018
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
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ install:
chmod +x /usr/local/bin/sccache &&
travis_retry curl -fo /usr/local/bin/stamp https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2017-03-17-stamp-x86_64-apple-darwin &&
chmod +x /usr/local/bin/stamp &&
travis_retry curl -f http://releases.llvm.org/6.0.0/clang+llvm-6.0.0-x86_64-apple-darwin.tar.xz | tar xJf - &&
export CC=`pwd`/clang+llvm-6.0.0-x86_64-apple-darwin/bin/clang &&
export CXX=`pwd`/clang+llvm-6.0.0-x86_64-apple-darwin/bin/clang++ &&
travis_retry curl -f http://releases.llvm.org/7.0.0/clang+llvm-7.0.0-x86_64-apple-darwin.tar.xz | tar xJf - &&
export CC=`pwd`/clang+llvm-7.0.0-x86_64-apple-darwin/bin/clang &&
export CXX=`pwd`/clang+llvm-7.0.0-x86_64-apple-darwin/bin/clang++ &&
export AR=ar
;;
esac
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use std::fs::{self, File};
use std::io::BufReader;
use std::io::prelude::*;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
use std::process::{Command, Stdio, exit};
use std::str;

use build_helper::{output, mtime, up_to_date};
Expand Down Expand Up @@ -1098,7 +1098,7 @@ pub fn run_cargo(builder: &Builder,
});

if !ok {
panic!("cargo must succeed");
exit(1);
}

// Ok now we need to actually find all the files listed in `toplevel`. We've
Expand Down
2 changes: 1 addition & 1 deletion src/ci/docker/dist-i686-linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ RUN ./build-gcc.sh
COPY dist-x86_64-linux/build-python.sh /tmp/
RUN ./build-python.sh

# Now build LLVM+Clang 6, afterwards configuring further compilations to use the
# Now build LLVM+Clang 7, afterwards configuring further compilations to use the
# clang/clang++ compilers.
COPY dist-x86_64-linux/build-clang.sh /tmp/
RUN ./build-clang.sh
Expand Down
2 changes: 1 addition & 1 deletion src/ci/docker/dist-x86_64-linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ RUN ./build-gcc.sh
COPY dist-x86_64-linux/build-python.sh /tmp/
RUN ./build-python.sh

# Now build LLVM+Clang 6, afterwards configuring further compilations to use the
# Now build LLVM+Clang 7, afterwards configuring further compilations to use the
# clang/clang++ compilers.
COPY dist-x86_64-linux/build-clang.sh /tmp/
RUN ./build-clang.sh
Expand Down
2 changes: 1 addition & 1 deletion src/ci/docker/dist-x86_64-linux/build-clang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ set -ex

source shared.sh

LLVM=6.0.0
LLVM=7.0.0

mkdir clang
cd clang
Expand Down
2 changes: 1 addition & 1 deletion src/ci/docker/scripts/musl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ hide_output make clean

cd ..

LLVM=60
LLVM=70

# may have been downloaded in a previous run
if [ ! -d libunwind-release_$LLVM ]; then
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/cfg/graphviz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ impl<'a> dot::GraphWalk<'a> for &'a cfg::CFG {
type Node = Node<'a>;
type Edge = Edge<'a>;
fn nodes(&'a self) -> dot::Nodes<'a, Node<'a>> {
let mut v = Vec::new();
self.graph.each_node(|i, nd| { v.push((i, nd)); true });
let v: Vec<_> = self.graph.enumerated_nodes().collect();
v.into()
}
fn edges(&'a self) -> dot::Edges<'a, Edge<'a>> {
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1062,8 +1062,7 @@ impl<'a> LoweringContext<'a> {
attrs
.iter()
.map(|a| self.lower_attr(a))
.collect::<Vec<_>>()
.into()
.collect()
}

fn lower_attr(&mut self, attr: &Attribute) -> Attribute {
Expand Down
20 changes: 16 additions & 4 deletions src/librustc/ich/impls_ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,9 @@ impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::adjustment::AutoBorrow
}
}

impl_stable_hash_for!(struct ty::UpvarId { var_id, closure_expr_id });
impl_stable_hash_for!(struct ty::UpvarPath { hir_id });

impl_stable_hash_for!(struct ty::UpvarId { var_path, closure_expr_id });

impl_stable_hash_for!(enum ty::BorrowKind {
ImmBorrow,
Expand Down Expand Up @@ -451,7 +453,7 @@ impl_stable_hash_for!(
FunctionRetMismatch(a, b),
NoMirFor(s),
UnterminatedCString(ptr),
PointerOutOfBounds { ptr, access, allocation_size },
PointerOutOfBounds { ptr, check, allocation_size },
InvalidBoolOp(bop),
Unimplemented(s),
BoundsCheck { len, index },
Expand All @@ -471,6 +473,11 @@ impl_stable_hash_for!(
}
);

impl_stable_hash_for!(enum mir::interpret::InboundsCheck {
Live,
MaybeDead
});

impl_stable_hash_for!(enum mir::interpret::Lock {
NoLock,
WriteLock(dl),
Expand Down Expand Up @@ -673,9 +680,13 @@ for ty::TyKind<'gcx>
Param(param_ty) => {
param_ty.hash_stable(hcx, hasher);
}
Bound(bound_ty) => {
Bound(debruijn, bound_ty) => {
debruijn.hash_stable(hcx, hasher);
bound_ty.hash_stable(hcx, hasher);
}
ty::Placeholder(placeholder_ty) => {
placeholder_ty.hash_stable(hcx, hasher);
}
Foreign(def_id) => {
def_id.hash_stable(hcx, hasher);
}
Expand Down Expand Up @@ -1085,12 +1096,13 @@ impl_stable_hash_for!(struct infer::canonical::CanonicalVarInfo {

impl_stable_hash_for!(enum infer::canonical::CanonicalVarKind {
Ty(k),
PlaceholderTy(placeholder),
Region(ui),
PlaceholderRegion(placeholder),
});

impl_stable_hash_for!(enum infer::canonical::CanonicalTyVarKind {
General,
General(ui),
Int,
Float
});
Expand Down
58 changes: 45 additions & 13 deletions src/librustc/infer/canonical/canonicalizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use infer::InferCtxt;
use std::sync::atomic::Ordering;
use ty::fold::{TypeFoldable, TypeFolder};
use ty::subst::Kind;
use ty::{self, BoundTy, BoundVar, Lift, List, Ty, TyCtxt, TypeFlags};
use ty::{self, BoundVar, Lift, List, Ty, TyCtxt, TypeFlags};

use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::indexed_vec::Idx;
Expand Down Expand Up @@ -339,20 +339,51 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Canonicalizer<'cx, 'gcx, 'tcx>

fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
match t.sty {
ty::Infer(ty::TyVar(_)) => self.canonicalize_ty_var(CanonicalTyVarKind::General, t),
ty::Infer(ty::TyVar(vid)) => {
match self.infcx.unwrap().probe_ty_var(vid) {
// `t` could be a float / int variable: canonicalize that instead
Ok(t) => self.fold_ty(t),

// `TyVar(vid)` is unresolved, track its universe index in the canonicalized
// result
Err(ui) => self.canonicalize_ty_var(
CanonicalVarInfo {
kind: CanonicalVarKind::Ty(CanonicalTyVarKind::General(ui))
},
t
)
}
}

ty::Infer(ty::IntVar(_)) => self.canonicalize_ty_var(CanonicalTyVarKind::Int, t),
ty::Infer(ty::IntVar(_)) => self.canonicalize_ty_var(
CanonicalVarInfo {
kind: CanonicalVarKind::Ty(CanonicalTyVarKind::Int)
},
t
),

ty::Infer(ty::FloatVar(_)) => self.canonicalize_ty_var(CanonicalTyVarKind::Float, t),
ty::Infer(ty::FloatVar(_)) => self.canonicalize_ty_var(
CanonicalVarInfo {
kind: CanonicalVarKind::Ty(CanonicalTyVarKind::Float)
},
t
),

ty::Infer(ty::FreshTy(_))
| ty::Infer(ty::FreshIntTy(_))
| ty::Infer(ty::FreshFloatTy(_)) => {
bug!("encountered a fresh type during canonicalization")
}

ty::Bound(bound_ty) => {
if bound_ty.index >= self.binder_index {
ty::Placeholder(placeholder) => self.canonicalize_ty_var(
CanonicalVarInfo {
kind: CanonicalVarKind::PlaceholderTy(placeholder)
},
t
),

ty::Bound(debruijn, _) => {
if debruijn >= self.binder_index {
bug!("escaping bound type during canonicalization")
} else {
t
Expand Down Expand Up @@ -408,9 +439,13 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> {
V: TypeFoldable<'tcx> + Lift<'gcx>,
{
let needs_canonical_flags = if canonicalize_region_mode.any() {
TypeFlags::HAS_FREE_REGIONS | TypeFlags::KEEP_IN_LOCAL_TCX
TypeFlags::KEEP_IN_LOCAL_TCX |
TypeFlags::HAS_FREE_REGIONS | // `HAS_RE_PLACEHOLDER` implies `HAS_FREE_REGIONS`
TypeFlags::HAS_TY_PLACEHOLDER
} else {
TypeFlags::KEEP_IN_LOCAL_TCX
TypeFlags::KEEP_IN_LOCAL_TCX |
TypeFlags::HAS_RE_PLACEHOLDER |
TypeFlags::HAS_TY_PLACEHOLDER
};

let gcx = tcx.global_tcx();
Expand Down Expand Up @@ -574,17 +609,14 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> {
/// if `ty_var` is bound to anything; if so, canonicalize
/// *that*. Otherwise, create a new canonical variable for
/// `ty_var`.
fn canonicalize_ty_var(&mut self, ty_kind: CanonicalTyVarKind, ty_var: Ty<'tcx>) -> Ty<'tcx> {
fn canonicalize_ty_var(&mut self, info: CanonicalVarInfo, ty_var: Ty<'tcx>) -> Ty<'tcx> {
let infcx = self.infcx.expect("encountered ty-var without infcx");
let bound_to = infcx.shallow_resolve(ty_var);
if bound_to != ty_var {
self.fold_ty(bound_to)
} else {
let info = CanonicalVarInfo {
kind: CanonicalVarKind::Ty(ty_kind),
};
let var = self.canonical_var(info, ty_var.into());
self.tcx().mk_ty(ty::Bound(BoundTy::new(self.binder_index, var)))
self.tcx().mk_ty(ty::Bound(self.binder_index, var.into()))
}
}
}
42 changes: 28 additions & 14 deletions src/librustc/infer/canonical/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ impl CanonicalVarInfo {
pub fn is_existential(&self) -> bool {
match self.kind {
CanonicalVarKind::Ty(_) => true,
CanonicalVarKind::PlaceholderTy(_) => false,
CanonicalVarKind::Region(_) => true,
CanonicalVarKind::PlaceholderRegion(..) => false,
}
Expand All @@ -136,24 +137,27 @@ pub enum CanonicalVarKind {
/// Some kind of type inference variable.
Ty(CanonicalTyVarKind),

/// A "placeholder" that represents "any type".
PlaceholderTy(ty::PlaceholderType),

/// Region variable `'?R`.
Region(ty::UniverseIndex),

/// A "placeholder" that represents "any region". Created when you
/// are solving a goal like `for<'a> T: Foo<'a>` to represent the
/// bound region `'a`.
PlaceholderRegion(ty::Placeholder),
PlaceholderRegion(ty::PlaceholderRegion),
}

impl CanonicalVarKind {
pub fn universe(self) -> ty::UniverseIndex {
match self {
// At present, we don't support higher-ranked
// quantification over types, so all type variables are in
// the root universe.
CanonicalVarKind::Ty(_) => ty::UniverseIndex::ROOT,
CanonicalVarKind::Ty(kind) => match kind {
CanonicalTyVarKind::General(ui) => ui,
CanonicalTyVarKind::Float | CanonicalTyVarKind::Int => ty::UniverseIndex::ROOT,
}

// Region variables can be created in sub-universes.
CanonicalVarKind::PlaceholderTy(placeholder) => placeholder.universe,
CanonicalVarKind::Region(ui) => ui,
CanonicalVarKind::PlaceholderRegion(placeholder) => placeholder.universe,
}
Expand All @@ -168,7 +172,7 @@ impl CanonicalVarKind {
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, RustcDecodable, RustcEncodable)]
pub enum CanonicalTyVarKind {
/// General type variable `?T` that can be unified with arbitrary types.
General,
General(ty::UniverseIndex),

/// Integral type variable `?I` (that can only be unified with integral types).
Int,
Expand Down Expand Up @@ -358,8 +362,11 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
match cv_info.kind {
CanonicalVarKind::Ty(ty_kind) => {
let ty = match ty_kind {
CanonicalTyVarKind::General => {
self.next_ty_var(TypeVariableOrigin::MiscVariable(span))
CanonicalTyVarKind::General(ui) => {
self.next_ty_var_in_universe(
TypeVariableOrigin::MiscVariable(span),
universe_map(ui)
)
}

CanonicalTyVarKind::Int => self.tcx.mk_int_var(self.next_int_var_id()),
Expand All @@ -369,20 +376,27 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
ty.into()
}

CanonicalVarKind::PlaceholderTy(ty::PlaceholderType { universe, name }) => {
let universe_mapped = universe_map(universe);
let placeholder_mapped = ty::PlaceholderType {
universe: universe_mapped,
name,
};
self.tcx.mk_ty(ty::Placeholder(placeholder_mapped)).into()
}

CanonicalVarKind::Region(ui) => self.next_region_var_in_universe(
RegionVariableOrigin::MiscVariable(span),
universe_map(ui),
).into(),

CanonicalVarKind::PlaceholderRegion(ty::Placeholder { universe, name }) => {
CanonicalVarKind::PlaceholderRegion(ty::PlaceholderRegion { universe, name }) => {
let universe_mapped = universe_map(universe);
let placeholder_mapped = ty::Placeholder {
let placeholder_mapped = ty::PlaceholderRegion {
universe: universe_mapped,
name,
};
self.tcx
.mk_region(ty::RePlaceholder(placeholder_mapped))
.into()
self.tcx.mk_region(ty::RePlaceholder(placeholder_mapped)).into()
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/infer/canonical/query_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,21 +435,21 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
match result_value.unpack() {
UnpackedKind::Type(result_value) => {
// e.g., here `result_value` might be `?0` in the example above...
if let ty::Bound(b) = result_value.sty {
if let ty::Bound(debruijn, b) = result_value.sty {
// ...in which case we would set `canonical_vars[0]` to `Some(?U)`.

// We only allow a `ty::INNERMOST` index in substitutions.
assert_eq!(b.index, ty::INNERMOST);
assert_eq!(debruijn, ty::INNERMOST);
opt_values[b.var] = Some(*original_value);
}
}
UnpackedKind::Lifetime(result_value) => {
// e.g., here `result_value` might be `'?1` in the example above...
if let &ty::RegionKind::ReLateBound(index, br) = result_value {
if let &ty::RegionKind::ReLateBound(debruijn, br) = result_value {
// ... in which case we would set `canonical_vars[0]` to `Some('static)`.

// We only allow a `ty::INNERMOST` index in substitutions.
assert_eq!(index, ty::INNERMOST);
assert_eq!(debruijn, ty::INNERMOST);
opt_values[br.assert_bound_var()] = Some(*original_value);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1315,7 +1315,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
format!(" for lifetime parameter `{}` in coherence check", name)
}
infer::UpvarRegion(ref upvar_id, _) => {
let var_node_id = self.tcx.hir.hir_to_node_id(upvar_id.var_id);
let var_node_id = self.tcx.hir.hir_to_node_id(upvar_id.var_path.hir_id);
let var_name = self.tcx.hir.name(var_node_id);
format!(" for capture of `{}` by closure", var_name)
}
Expand Down
Loading