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 13 pull requests #55425

Closed
wants to merge 44 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
a0df420
Implement FromStr for PathBuf
SimonSapin Oct 17, 2018
ac18635
Add MaybeUninit::new
SimonSapin Oct 21, 2018
412ad9b
Allow extern statics with an extern type
mjbshaw Oct 22, 2018
5b84550
Keep an obligation for both sized and unsized types
mjbshaw Oct 22, 2018
1c8fb66
Move `BoundTy` to `ty::TyKind`
scalexm Oct 22, 2018
cdf5547
Shift both late bound regions and bound types
scalexm Oct 22, 2018
ab820ad
Rename `BoundTyIndex` to `BoundVar`
scalexm Oct 23, 2018
9049c85
Rename `BoundTy` field `level` -> `index`
scalexm Oct 23, 2018
8642a23
Adjust bound tys indices in canonicalization
scalexm Oct 23, 2018
e76fffc
Remove `ReCanonical` in favor of `ReLateBound`
scalexm Oct 24, 2018
b86d700
Rename `Binder::no_late_bound_regions` to `Binder::no_bound_vars`
scalexm Oct 24, 2018
235c848
Extend `ty::fold::RegionReplacer` to `ty::fold::BoundVarReplacer`
scalexm Oct 24, 2018
47499cc
Fix doc comment
scalexm Oct 25, 2018
18eeed5
Move cg_llvm::back::linker to cg_utils
bjorn3 Oct 20, 2018
2bf01aa
Rename `as_bound_var` to `assert_bound_var`
scalexm Oct 25, 2018
2b205dc
Substitute binders directly
scalexm Oct 25, 2018
029cf2f
Move collect_and_partition_mono_items to rustc_mir
bjorn3 Oct 25, 2018
06695c2
Remove rustc_metadata_utils, which contains only one function
bjorn3 Oct 25, 2018
adafd0f
Fix indentation
bjorn3 Oct 25, 2018
8d5fb4c
Add note linking to Rust 2018 path semantics docs.
davidtwco Oct 18, 2018
c674802
Remove unnecessary mut in iterator.find_map documentation example, Re…
meven Oct 23, 2018
bb37f18
Turn ICE for dangling pointers into error
oli-obk Oct 22, 2018
caabc72
Reproduce the underlying issue
oli-obk Oct 22, 2018
7a2879f
Update dangling-alloc-id-ice-2.rs
oli-obk Oct 23, 2018
9d18968
Typo
oli-obk Oct 24, 2018
5c45fef
Update and add new test (fixes #55353)
oli-obk Oct 26, 2018
599eb12
Add trailing newline
oli-obk Oct 26, 2018
4cb611f
Update string.rs
rick68 Oct 27, 2018
c04893a
Fix an ICE in the min_const_fn analysis
oli-obk Oct 27, 2018
630c6a5
introducing lint reason annotations (RFC 2383)
zackmdavis Sep 30, 2018
dc0609c
feature-gate lint reasons
zackmdavis Sep 30, 2018
f90de11
in which lint reasons are restricted to come last in the attribute
zackmdavis Oct 12, 2018
f66ea66
wherein the status of empty and reason-only lint attributes is clarified
zackmdavis Oct 16, 2018
80c1f0b
Rollup merge of #54683 - zackmdavis:critique_of_pure_lints, r=petroch…
Mark-Simulacrum Oct 27, 2018
ef8f09a
Rollup merge of #55148 - SimonSapin:path-fromstr, r=oli-obk
Mark-Simulacrum Oct 27, 2018
be00065
Rollup merge of #55185 - davidtwco:issue-55130, r=nikomatsakis
Mark-Simulacrum Oct 27, 2018
671e8ea
Rollup merge of #55252 - SimonSapin:maybeuninit-new, r=bluss
Mark-Simulacrum Oct 27, 2018
b3740b1
Rollup merge of #55257 - mjbshaw:static, r=oli-obk
Mark-Simulacrum Oct 27, 2018
805fcb6
Rollup merge of #55262 - oli-obk:dangling_alloc_id_ice, r=RalfJung
Mark-Simulacrum Oct 27, 2018
0956690
Rollup merge of #55330 - scalexm:bound-ty, r=nikomatsakis
Mark-Simulacrum Oct 27, 2018
2994675
Rollup merge of #55349 - bjorn3:rustc_mir_collect_and_partition_mono_…
Mark-Simulacrum Oct 27, 2018
18d3f3f
Rollup merge of #55389 - meven:master, r=shepmaster
Mark-Simulacrum Oct 27, 2018
545eae8
Rollup merge of #55406 - rick68:patch-16, r=varkor
Mark-Simulacrum Oct 27, 2018
25be4f6
Rollup merge of #55412 - oli-obk:min_const_fn_ice, r=estebank
Mark-Simulacrum Oct 27, 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
14 changes: 3 additions & 11 deletions src/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2136,11 +2136,13 @@ dependencies = [
"flate2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
"rustc_allocator 0.0.0",
"rustc_data_structures 0.0.0",
"rustc_incremental 0.0.0",
"rustc_metadata_utils 0.0.0",
"rustc_metadata 0.0.0",
"rustc_mir 0.0.0",
"rustc_target 0.0.0",
"serialize 0.0.0",
"syntax 0.0.0",
"syntax_pos 0.0.0",
]
Expand Down Expand Up @@ -2283,23 +2285,13 @@ dependencies = [
"rustc 0.0.0",
"rustc_data_structures 0.0.0",
"rustc_errors 0.0.0",
"rustc_metadata_utils 0.0.0",
"rustc_target 0.0.0",
"serialize 0.0.0",
"syntax 0.0.0",
"syntax_ext 0.0.0",
"syntax_pos 0.0.0",
]

[[package]]
name = "rustc_metadata_utils"
version = "0.0.0"
dependencies = [
"rustc 0.0.0",
"syntax 0.0.0",
"syntax_pos 0.0.0",
]

[[package]]
name = "rustc_mir"
version = "0.0.0"
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ impl String {
///
/// // These are all done without reallocating...
/// let cap = s.capacity();
/// for i in 0..10 {
/// for _ in 0..10 {
/// s.push('a');
/// }
///
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/iter/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1857,7 +1857,7 @@ pub trait Iterator {
/// ```
/// let a = ["lol", "NaN", "2", "5"];
///
/// let mut first_number = a.iter().find_map(|s| s.parse().ok());
/// let first_number = a.iter().find_map(|s| s.parse().ok());
///
/// assert_eq!(first_number, Some(2));
/// ```
Expand Down
1 change: 1 addition & 0 deletions src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
#![feature(const_fn)]
#![feature(const_int_ops)]
#![feature(const_fn_union)]
#![feature(const_manually_drop_new)]
#![feature(custom_attribute)]
#![feature(doc_cfg)]
#![feature(doc_spotlight)]
Expand Down
9 changes: 9 additions & 0 deletions src/libcore/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,15 @@ pub union MaybeUninit<T> {
}

impl<T> MaybeUninit<T> {
/// Create a new `MaybeUninit` initialized with the given value.
///
/// Note that dropping a `MaybeUninit` will never call `T`'s drop code.
/// It is your responsibility to make sure `T` gets dropped if it got initialized.
#[unstable(feature = "maybe_uninit", issue = "53491")]
pub const fn new(val: T) -> MaybeUninit<T> {
MaybeUninit { value: ManuallyDrop::new(val) }
}

/// Create a new `MaybeUninit` in an uninitialized state.
///
/// Note that dropping a `MaybeUninit` will never call `T`'s drop code.
Expand Down
9 changes: 4 additions & 5 deletions src/librustc/ich/impls_ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ for ty::RegionKind {
ty::ReEmpty => {
// No variant fields to hash for these ...
}
ty::ReCanonical(c) => {
c.hash_stable(hcx, hasher);
}
ty::ReLateBound(db, ty::BrAnon(i)) => {
db.hash_stable(hcx, hasher);
i.hash_stable(hcx, hasher);
Expand Down Expand Up @@ -147,7 +144,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for ty::RegionVid {
}
}

impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::BoundTyIndex {
impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::BoundVar {
#[inline]
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'gcx>,
Expand Down Expand Up @@ -894,6 +891,9 @@ for ty::TyKind<'gcx>
Param(param_ty) => {
param_ty.hash_stable(hcx, hasher);
}
Bound(bound_ty) => {
bound_ty.hash_stable(hcx, hasher);
}
Foreign(def_id) => {
def_id.hash_stable(hcx, hasher);
}
Expand All @@ -911,7 +911,6 @@ impl_stable_hash_for!(enum ty::InferTy {
FreshTy(a),
FreshIntTy(a),
FreshFloatTy(a),
BoundTy(a),
});

impl<'a, 'gcx> HashStable<StableHashingContext<'a>>
Expand Down
72 changes: 42 additions & 30 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, BoundTyIndex, Lift, List, Ty, TyCtxt, TypeFlags};
use ty::{self, BoundTy, BoundVar, Lift, List, Ty, TyCtxt, TypeFlags};

use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::indexed_vec::Idx;
Expand Down Expand Up @@ -225,21 +225,35 @@ struct Canonicalizer<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
query_state: &'cx mut OriginalQueryValues<'tcx>,
// Note that indices is only used once `var_values` is big enough to be
// heap-allocated.
indices: FxHashMap<Kind<'tcx>, BoundTyIndex>,
indices: FxHashMap<Kind<'tcx>, BoundVar>,
canonicalize_region_mode: &'cx dyn CanonicalizeRegionMode,
needs_canonical_flags: TypeFlags,

binder_index: ty::DebruijnIndex,
}

impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Canonicalizer<'cx, 'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> {
self.tcx
}

fn fold_binder<T>(&mut self, t: &ty::Binder<T>) -> ty::Binder<T>
where T: TypeFoldable<'tcx>
{
self.binder_index.shift_in(1);
let t = t.super_fold_with(self);
self.binder_index.shift_out(1);
t
}

fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
match *r {
ty::ReLateBound(..) => {
// leave bound regions alone
r
ty::ReLateBound(index, ..) => {
if index >= self.binder_index {
bug!("escaping late bound region during canonicalization")
} else {
r
}
}

ty::ReVar(vid) => {
Expand All @@ -263,8 +277,8 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Canonicalizer<'cx, 'gcx, 'tcx>
| ty::ReEmpty
| ty::ReErased => self.canonicalize_region_mode.canonicalize_free_region(self, r),

ty::ReClosureBound(..) | ty::ReCanonical(_) => {
bug!("canonical region encountered during canonicalization")
ty::ReClosureBound(..) => {
bug!("closure bound region encountered during canonicalization")
}
}
}
Expand All @@ -283,8 +297,12 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Canonicalizer<'cx, 'gcx, 'tcx>
bug!("encountered a fresh type during canonicalization")
}

ty::Infer(ty::BoundTy(_)) => {
bug!("encountered a canonical type during canonicalization")
ty::Bound(bound_ty) => {
if bound_ty.index >= self.binder_index {
bug!("escaping bound type during canonicalization")
} else {
t
}
}

ty::Closure(..)
Expand Down Expand Up @@ -335,12 +353,6 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> {
where
V: TypeFoldable<'tcx> + Lift<'gcx>,
{
debug_assert!(
!value.has_type_flags(TypeFlags::HAS_CANONICAL_VARS),
"canonicalizing a canonical value: {:?}",
value,
);

let needs_canonical_flags = if canonicalize_region_mode.any() {
TypeFlags::HAS_FREE_REGIONS | TypeFlags::KEEP_IN_LOCAL_TCX
} else {
Expand All @@ -367,6 +379,7 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> {
variables: SmallVec::new(),
query_state,
indices: FxHashMap::default(),
binder_index: ty::INNERMOST,
};
let out_value = value.fold_with(&mut canonicalizer);

Expand All @@ -393,7 +406,7 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> {
/// or returns an existing variable if `kind` has already been
/// seen. `kind` is expected to be an unbound variable (or
/// potentially a free region).
fn canonical_var(&mut self, info: CanonicalVarInfo, kind: Kind<'tcx>) -> BoundTy {
fn canonical_var(&mut self, info: CanonicalVarInfo, kind: Kind<'tcx>) -> BoundVar {
let Canonicalizer {
variables,
query_state,
Expand All @@ -413,7 +426,7 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> {
// direct linear search of `var_values`.
if let Some(idx) = var_values.iter().position(|&k| k == kind) {
// `kind` is already present in `var_values`.
BoundTyIndex::new(idx)
BoundVar::new(idx)
} else {
// `kind` isn't present in `var_values`. Append it. Likewise
// for `info` and `variables`.
Expand All @@ -428,35 +441,35 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> {
*indices = var_values
.iter()
.enumerate()
.map(|(i, &kind)| (kind, BoundTyIndex::new(i)))
.map(|(i, &kind)| (kind, BoundVar::new(i)))
.collect();
}
// The cv is the index of the appended element.
BoundTyIndex::new(var_values.len() - 1)
BoundVar::new(var_values.len() - 1)
}
} else {
// `var_values` is large. Do a hashmap search via `indices`.
*indices.entry(kind).or_insert_with(|| {
variables.push(info);
var_values.push(kind);
assert_eq!(variables.len(), var_values.len());
BoundTyIndex::new(variables.len() - 1)
BoundVar::new(variables.len() - 1)
})
};

BoundTy {
level: ty::INNERMOST,
var,
}
var
}

fn canonical_var_for_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
let info = CanonicalVarInfo {
kind: CanonicalVarKind::Region,
};
let b = self.canonical_var(info, r.into());
debug_assert_eq!(ty::INNERMOST, b.level);
self.tcx().mk_region(ty::ReCanonical(b.var))
let var = self.canonical_var(info, r.into());
let region = ty::ReLateBound(
self.binder_index,
ty::BoundRegion::BrAnon(var.as_u32())
);
self.tcx().mk_region(region)
}

/// Given a type variable `ty_var` of the given kind, first check
Expand All @@ -472,9 +485,8 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> {
let info = CanonicalVarInfo {
kind: CanonicalVarKind::Ty(ty_kind),
};
let b = self.canonical_var(info, ty_var.into());
debug_assert_eq!(ty::INNERMOST, b.level);
self.tcx().mk_infer(ty::InferTy::BoundTy(b))
let var = self.canonical_var(info, ty_var.into());
self.tcx().mk_ty(ty::Bound(BoundTy::new(self.binder_index, var)))
}
}
}
12 changes: 6 additions & 6 deletions src/librustc/infer/canonical/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
//! - a map M (of type `CanonicalVarValues`) from those canonical
//! variables back to the original.
//!
//! We can then do queries using T2. These will give back constriants
//! We can then do queries using T2. These will give back constraints
//! on the canonical variables which can be translated, using the map
//! M, into constraints in our source context. This process of
//! translating the results back is done by the
Expand All @@ -40,7 +40,7 @@ use std::ops::Index;
use syntax::source_map::Span;
use ty::fold::TypeFoldable;
use ty::subst::Kind;
use ty::{self, BoundTyIndex, Lift, Region, List, TyCtxt};
use ty::{self, BoundVar, Lift, Region, List, TyCtxt};

mod canonicalizer;

Expand Down Expand Up @@ -72,7 +72,7 @@ impl<'gcx> UseSpecializedDecodable for CanonicalVarInfos<'gcx> {}
/// canonicalized query response.
#[derive(Clone, Debug, PartialEq, Eq, Hash, RustcDecodable, RustcEncodable)]
pub struct CanonicalVarValues<'tcx> {
pub var_values: IndexVec<BoundTyIndex, Kind<'tcx>>,
pub var_values: IndexVec<BoundVar, Kind<'tcx>>,
}

/// When we canonicalize a value to form a query, we wind up replacing
Expand Down Expand Up @@ -264,7 +264,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
span: Span,
variables: &List<CanonicalVarInfo>,
) -> CanonicalVarValues<'tcx> {
let var_values: IndexVec<BoundTyIndex, Kind<'tcx>> = variables
let var_values: IndexVec<BoundVar, Kind<'tcx>> = variables
.iter()
.map(|info| self.fresh_inference_var_for_canonical_var(span, *info))
.collect();
Expand Down Expand Up @@ -367,10 +367,10 @@ BraceStructLiftImpl! {
} where R: Lift<'tcx>
}

impl<'tcx> Index<BoundTyIndex> for CanonicalVarValues<'tcx> {
impl<'tcx> Index<BoundVar> for CanonicalVarValues<'tcx> {
type Output = Kind<'tcx>;

fn index(&self, value: BoundTyIndex) -> &Kind<'tcx> {
fn index(&self, value: BoundVar) -> &Kind<'tcx> {
&self.var_values[value]
}
}
Loading