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 #60523

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
342309e
Add assert
JohnTitor Mar 29, 2019
70e7265
Expand uint
JohnTitor Mar 29, 2019
d7bb9de
Clean up
JohnTitor Mar 29, 2019
261c7c1
Remove unnecessary cast
JohnTitor Mar 29, 2019
bf3a744
Add tests
JohnTitor Mar 30, 2019
cfe99be
Remove unnecessary variable
JohnTitor Mar 30, 2019
69dc278
Add bar
JohnTitor Mar 30, 2019
6fcd5bb
WIP: correct flags
JohnTitor Mar 30, 2019
1d12b06
Fix variable name
JohnTitor Apr 1, 2019
1aea502
Fix check
JohnTitor Apr 17, 2019
9b9a1f2
Separate comment
JohnTitor Apr 17, 2019
d8454fc
Add flags
JohnTitor Apr 24, 2019
dca8319
Remove check flag
JohnTitor Apr 24, 2019
e21077c
WIP: fix debuginfo test
JohnTitor Apr 24, 2019
a197466
Ignore line length
JohnTitor Apr 30, 2019
4315c78
WIP: add some flags for debuginfo
JohnTitor Apr 30, 2019
6ed4b52
Ignore line length
JohnTitor Apr 30, 2019
a3aafea
Account for paths in incorrect pub qualifier help
estebank May 1, 2019
3b24cf8
Update RLS
Xanewok May 1, 2019
31407e8
Update Cargo
Xanewok May 2, 2019
2c371b2
build dist-aarch64-linux with --enable-profiler
froydnj May 2, 2019
d72f4de
Constrain all regions in the concrete type for an opaque type
matthewjasper May 1, 2019
a0f4914
This continue is not needed
spastorino Apr 26, 2019
9f7b953
Remove root_local fn in favor of base_local
spastorino May 1, 2019
49f0141
Implement base_local iteratively
spastorino May 1, 2019
2e85b31
Fix codegen tests
JohnTitor May 3, 2019
1e2af7d
Reword casting message
estebank May 3, 2019
3c7bcb1
Rollup merge of #59520 - JohnTitor:add-assert, r=eddyb
Centril May 3, 2019
dbe700b
Rollup merge of #60429 - estebank:pub-path, r=michaelwoerister
Centril May 3, 2019
ba4a1e1
Rollup merge of #60436 - Xanewok:update-rls, r=Manishearth
Centril May 3, 2019
ef6e45f
Rollup merge of #60449 - matthewjasper:impl-trait-outlives, r=pnkfelix
Centril May 3, 2019
0c9f635
Rollup merge of #60476 - froydnj:aarch64-profiling, r=alexcrichton
Centril May 3, 2019
df5a557
Rollup merge of #60486 - spastorino:place-related-refactors, r=oli-obk
Centril May 3, 2019
a911963
Rollup merge of #60517 - estebank:wording, r=davidtwco
Centril May 3, 2019
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
5 changes: 4 additions & 1 deletion src/ci/docker/dist-aarch64-linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,8 @@ ENV CC_aarch64_unknown_linux_gnu=aarch64-unknown-linux-gnueabi-gcc \

ENV HOSTS=aarch64-unknown-linux-gnu

ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs
ENV RUST_CONFIGURE_ARGS \
--enable-extended \
--enable-profiler \
--disable-docs
ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS
141 changes: 84 additions & 57 deletions src/librustc/infer/opaque_types/mod.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use rustc_data_structures::fx::FxHashMap;
use syntax_pos::Span;

use crate::hir::def_id::DefId;
use crate::hir;
use crate::hir::Node;
use crate::infer::{self, InferCtxt, InferOk, TypeVariableOrigin};
use crate::infer::outlives::free_region_map::FreeRegionRelations;
use rustc_data_structures::fx::FxHashMap;
use crate::traits::{self, PredicateObligation};
use crate::ty::{self, Ty, TyCtxt, GenericParamDefKind};
use crate::ty::fold::{BottomUpFolder, TypeFoldable, TypeFolder};
use crate::ty::outlives::Component;
use crate::ty::fold::{BottomUpFolder, TypeFoldable, TypeFolder, TypeVisitor};
use crate::ty::subst::{Kind, InternalSubsts, SubstsRef, UnpackedKind};
use crate::util::nodemap::DefIdMap;

Expand Down Expand Up @@ -373,58 +374,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
let least_region = least_region.unwrap_or(self.tcx.lifetimes.re_static);
debug!("constrain_opaque_types: least_region={:?}", least_region);

// Require that the type `concrete_ty` outlives
// `least_region`, modulo any type parameters that appear
// in the type, which we ignore. This is because impl
// trait values are assumed to capture all the in-scope
// type parameters. This little loop here just invokes
// `outlives` repeatedly, draining all the nested
// obligations that result.
let mut types = vec![concrete_ty];
let bound_region = |r| self.sub_regions(infer::CallReturn(span), least_region, r);
while let Some(ty) = types.pop() {
let mut components = smallvec![];
self.tcx.push_outlives_components(ty, &mut components);
while let Some(component) = components.pop() {
match component {
Component::Region(r) => {
bound_region(r);
}

Component::Param(_) => {
// ignore type parameters like `T`, they are captured
// implicitly by the `impl Trait`
}

Component::UnresolvedInferenceVariable(_) => {
// we should get an error that more type
// annotations are needed in this case
self.tcx
.sess
.delay_span_bug(span, "unresolved inf var in opaque");
}

Component::Projection(ty::ProjectionTy {
substs,
item_def_id: _,
}) => {
for k in substs {
match k.unpack() {
UnpackedKind::Lifetime(lt) => bound_region(lt),
UnpackedKind::Type(ty) => types.push(ty),
UnpackedKind::Const(_) => {
// Const parameters don't impose constraints.
}
}
}
}

Component::EscapingProjection(more_components) => {
components.extend(more_components);
}
}
}
}
concrete_ty.visit_with(&mut OpaqueTypeOutlivesVisitor {
infcx: self,
least_region,
span,
});
}

/// Given the fully resolved, instantiated type for an opaque
Expand Down Expand Up @@ -502,6 +456,80 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
}
}

// Visitor that requires that (almost) all regions in the type visited outlive
// `least_region`. We cannot use `push_outlives_components` because regions in
// closure signatures are not included in their outlives components. We need to
// ensure all regions outlive the given bound so that we don't end up with,
// say, `ReScope` appearing in a return type and causing ICEs when other
// functions end up with region constraints involving regions from other
// functions.
//
// We also cannot use `for_each_free_region` because for closures it includes
// the regions parameters from the enclosing item.
//
// We ignore any type parameters because impl trait values are assumed to
// capture all the in-scope type parameters.
struct OpaqueTypeOutlivesVisitor<'a, 'gcx, 'tcx> {
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
least_region: ty::Region<'tcx>,
span: Span,
}

impl<'tcx> TypeVisitor<'tcx> for OpaqueTypeOutlivesVisitor<'_, '_, 'tcx>
{
fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &ty::Binder<T>) -> bool {
t.skip_binder().visit_with(self);
false // keep visiting
}

fn visit_region(&mut self, r: ty::Region<'tcx>) -> bool {
match *r {
// ignore bound regions, keep visiting
ty::ReLateBound(_, _) => false,
_ => {
self.infcx.sub_regions(infer::CallReturn(self.span), self.least_region, r);
false
}
}
}

fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool {
// We're only interested in types involving regions
if !ty.flags.intersects(ty::TypeFlags::HAS_FREE_REGIONS) {
return false; // keep visiting
}

match ty.sty {
ty::Closure(def_id, ref substs) => {
// Skip lifetime parameters of the enclosing item(s)

for upvar_ty in substs.upvar_tys(def_id, self.infcx.tcx) {
upvar_ty.visit_with(self);
}

substs.closure_sig_ty(def_id, self.infcx.tcx).visit_with(self);
}

ty::Generator(def_id, ref substs, _) => {
// Skip lifetime parameters of the enclosing item(s)
// Also skip the witness type, because that has no free regions.

for upvar_ty in substs.upvar_tys(def_id, self.infcx.tcx) {
upvar_ty.visit_with(self);
}

substs.return_ty(def_id, self.infcx.tcx).visit_with(self);
substs.yield_ty(def_id, self.infcx.tcx).visit_with(self);
}
_ => {
ty.super_visit_with(self);
}
}

false
}
}

struct ReverseMapper<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
tcx: TyCtxt<'cx, 'gcx, 'tcx>,

Expand Down Expand Up @@ -563,8 +591,7 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for ReverseMapper<'cx, 'gcx, 'tcx>
// ignore `'static`, as that can appear anywhere
ty::ReStatic |

// ignore `ReScope`, as that can appear anywhere
// See `src/test/run-pass/issue-49556.rs` for example.
// ignore `ReScope`, which may appear in impl Trait in bindings.
ty::ReScope(..) => return r,

_ => { }
Expand Down
11 changes: 7 additions & 4 deletions src/librustc/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2055,10 +2055,13 @@ impl<'tcx> Place<'tcx> {

/// Finds the innermost `Local` from this `Place`.
pub fn base_local(&self) -> Option<Local> {
match self {
Place::Base(PlaceBase::Local(local)) => Some(*local),
Place::Projection(box Projection { base, elem: _ }) => base.base_local(),
Place::Base(PlaceBase::Static(..)) => None,
let mut place = self;
loop {
match place {
Place::Projection(proj) => place = &proj.base,
Place::Base(PlaceBase::Static(_)) => return None,
Place::Base(PlaceBase::Local(local)) => return Some(*local),
}
}
}

Expand Down
14 changes: 5 additions & 9 deletions src/librustc_codegen_llvm/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ struct MemberDescription<'ll> {
size: Size,
align: Align,
flags: DIFlags,
discriminant: Option<u64>,
discriminant: Option<u128>,
}

// A factory for MemberDescriptions. It produces a list of member descriptions
Expand Down Expand Up @@ -1355,7 +1355,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> {
flags: DIFlags::FlagZero,
discriminant: Some(self.layout.ty.ty_adt_def().unwrap()
.discriminant_for_variant(cx.tcx, i)
.val as u64),
.val),
}
}).collect()
}
Expand Down Expand Up @@ -1454,12 +1454,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> {
let value = (i.as_u32() as u128)
.wrapping_sub(niche_variants.start().as_u32() as u128)
.wrapping_add(niche_start);
let value = truncate(value, discr.value.size(cx));
// NOTE(eddyb) do *NOT* remove this assert, until
// we pass the full 128-bit value to LLVM, otherwise
// truncation will be silent and remain undetected.
assert_eq!(value as u64 as u128, value);
Some(value as u64)
Some(truncate(value, discr.value.size(cx)))
};

MemberDescription {
Expand Down Expand Up @@ -1932,7 +1927,8 @@ fn set_members_of_composite_type(cx: &CodegenCx<'ll, 'tcx>,
member_description.offset.bits(),
match member_description.discriminant {
None => None,
Some(value) => Some(cx.const_u64(value)),
Some(value) =>
Some(cx.const_uint_big(cx.type_i128(), value)),
},
member_description.flags,
member_description.type_metadata))
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/borrow_check/borrow_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'gcx, 'tcx> {

self.insert_as_pending_if_two_phase(location, &assigned_place, kind, idx);

if let Some(local) = borrowed_place.root_local() {
if let Some(local) = borrowed_place.base_local() {
self.local_map.entry(local).or_default().insert(idx);
}
}
Expand Down
1 change: 0 additions & 1 deletion src/librustc_mir/borrow_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1831,7 +1831,6 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
}

place = base;
continue;
}
}
}
Expand Down
17 changes: 1 addition & 16 deletions src/librustc_mir/borrow_check/place_ext.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use rustc::hir;
use rustc::mir::ProjectionElem;
use rustc::mir::{Local, Mir, Place, PlaceBase, Mutability, Static, StaticKind};
use rustc::mir::{Mir, Place, PlaceBase, Mutability, Static, StaticKind};
use rustc::ty::{self, TyCtxt};
use crate::borrow_check::borrow_set::LocalsStateAtExit;

Expand All @@ -16,10 +16,6 @@ crate trait PlaceExt<'tcx> {
mir: &Mir<'tcx>,
locals_state_at_exit: &LocalsStateAtExit,
) -> bool;

/// If this is a place like `x.f.g`, returns the local
/// `x`. Returns `None` if this is based in a static.
fn root_local(&self) -> Option<Local>;
}

impl<'tcx> PlaceExt<'tcx> for Place<'tcx> {
Expand Down Expand Up @@ -82,15 +78,4 @@ impl<'tcx> PlaceExt<'tcx> for Place<'tcx> {
},
}
}

fn root_local(&self) -> Option<Local> {
let mut p = self;
loop {
match p {
Place::Projection(pi) => p = &pi.base,
Place::Base(PlaceBase::Static(_)) => return None,
Place::Base(PlaceBase::Local(l)) => return Some(*l),
}
}
}
}
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/demand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {

let msg = format!("you can convert an `{}` to `{}`", checked_ty, expected_ty);
let cast_msg = format!("you can cast an `{} to `{}`", checked_ty, expected_ty);
let try_msg = format!("{} or panic if it the converted value wouldn't fit", msg);
let try_msg = format!("{} and panic if the converted value wouldn't fit", msg);
let lit_msg = format!(
"change the type of the numeric literal from `{}` to `{}`",
checked_ty,
Expand Down
6 changes: 4 additions & 2 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7149,7 +7149,9 @@ impl<'a> Parser<'a> {
// `()` or a tuple might be allowed. For example, `struct Struct(pub (), pub (usize));`.
// Because of this, we only `bump` the `(` if we're assured it is appropriate to do so
// by the following tokens.
if self.look_ahead(1, |t| t.is_keyword(keywords::Crate)) {
if self.look_ahead(1, |t| t.is_keyword(keywords::Crate)) &&
self.look_ahead(2, |t| t != &token::ModSep) // account for `pub(crate::foo)`
{
// `pub(crate)`
self.bump(); // `(`
self.bump(); // `crate`
Expand Down Expand Up @@ -7192,7 +7194,7 @@ impl<'a> Parser<'a> {
`pub(super)`: visible only in the current module's parent
`pub(in path::to::module)`: visible only on the specified path"##;
let path = self.parse_path(PathStyle::Mod)?;
let sp = self.prev_span;
let sp = path.span;
let help_msg = format!("make this visible only to module `{}` with `in`", path);
self.expect(&token::CloseDelim(token::Paren))?; // `)`
let mut err = struct_span_err!(self.sess.span_diagnostic, sp, E0704, "{}", msg);
Expand Down
4 changes: 2 additions & 2 deletions src/test/codegen/enum-debug-niche-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
// compile-flags: -g -C no-prepopulate-passes

// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_variant_part,{{.*}}size: 32,{{.*}}
// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Placeholder",{{.*}}extraData: i64 4294967295{{[,)].*}}
// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Error",{{.*}}extraData: i64 0{{[,)].*}}
// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Placeholder",{{.*}}extraData: i128 4294967295{{[,)].*}}
// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Error",{{.*}}extraData: i128 0{{[,)].*}}

#![feature(never_type)]
#![feature(nll)]
Expand Down
24 changes: 24 additions & 0 deletions src/test/codegen/repr-u128.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// ignore-tidy-linelength
// ignore-windows
// min-system-llvm-version 8.0

// compile-flags: -g -C no-prepopulate-passes

// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "None",{{.*}}extraData: i128 18446745000000000124{{[,)].*}}

#![feature(repr128)]

#[repr(u128)]
pub enum Foo {
Lo,
Hi = 1 << 64,
Bar = 18_446_745_000_000_000_123,
}

pub fn foo() -> Option<Foo> {
None
}

fn main() {
let roa = foo();
}
34 changes: 34 additions & 0 deletions src/test/debuginfo/repr-u128.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// ignore-windows
// ignore-tidy-linelength
//min-system-llvm-version 8.0

//compile-flags: -g -C no-prepopulate-passes

// === GDB TESTS ===================================================================================

// gdb-command: run

// gdb-command:print vals
// gdbg-check:$1 = (Some(Foo::Lo), None::<Foo>)
// gdbr-check:$1 = repr_u128::Foo::(std::option::Option<Foo>, std::option::Option<Foo>)

// === LLDB TESTS ==================================================================================

// lldb-command:run

// lldb-command:print vals
// lldbg-check:[...]$0 = (Some(Foo::Lo), None::<Foo>)
// lldbr-check:(repr_u128::Foo) vals = repr_u128::Foo::(std::option::Option<Foo>, std::option::Option<Foo>)

#![feature(repr128)]

#[repr(u128)]
pub enum Foo {
Lo,
Hi = 1 << 64,
Bar = 18_446_745_000_000_000_123,
}

fn main() {
let vals = (Some(Foo::Lo), None::<Foo>);
}
Loading