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 8 pull requests #60519

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 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
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
1dc4a38
Fix potential integer overflow in SGX memory range calculation.
May 3, 2019
2e85b31
Fix codegen tests
JohnTitor May 3, 2019
544d8e9
Fix argument alias handling for -O and -C opt-level
varkor Apr 30, 2019
226894b
Fix argument alias handling for -g and -C debuginfo
varkor Apr 30, 2019
e5d3c48
Add a run-make test for command aliases
varkor Apr 30, 2019
28b8c20
Add comments
varkor May 1, 2019
f6b5e8a
Update getopts to 0.2.19
varkor May 2, 2019
1e2af7d
Reword casting message
estebank May 3, 2019
9d28309
Rollup merge of #59520 - JohnTitor:add-assert, r=eddyb
Centril May 3, 2019
16f7531
Rollup merge of #60426 - varkor:fix-duplicate-arg-handling, r=alexcri…
Centril May 3, 2019
15494fd
Rollup merge of #60429 - estebank:pub-path, r=michaelwoerister
Centril May 3, 2019
92366d8
Rollup merge of #60449 - matthewjasper:impl-trait-outlives, r=pnkfelix
Centril May 3, 2019
db3f86c
Rollup merge of #60476 - froydnj:aarch64-profiling, r=alexcrichton
Centril May 3, 2019
c2b949a
Rollup merge of #60486 - spastorino:place-related-refactors, r=oli-obk
Centril May 3, 2019
d421649
Rollup merge of #60496 - jethrogb:jb/address-integer-overflow, r=alex…
Centril May 3, 2019
b1d80a6
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
20 changes: 10 additions & 10 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ dependencies = [
"cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)",
"cmake 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
"filetime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down Expand Up @@ -463,7 +463,7 @@ dependencies = [
"diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)",
"filetime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
Expand All @@ -484,7 +484,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
"filetime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"miow 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down Expand Up @@ -974,7 +974,7 @@ dependencies = [

[[package]]
name = "getopts"
version = "0.2.18"
version = "0.2.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down Expand Up @@ -1989,7 +1989,7 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
Expand All @@ -2008,7 +2008,7 @@ version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
"memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"unicase 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
Expand Down Expand Up @@ -3094,7 +3094,7 @@ dependencies = [
"dirs 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
"ignore 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down Expand Up @@ -3521,7 +3521,7 @@ dependencies = [
name = "test"
version = "0.0.0"
dependencies = [
"getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
"proc_macro 0.0.0",
"term 0.0.0",
]
Expand All @@ -3531,7 +3531,7 @@ name = "tester"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
Expand Down Expand Up @@ -4131,7 +4131,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)" = "1a70b146671de62ec8c8ed572219ca5d594d9b06c0b364d5e67b722fc559b48c"
"checksum fwdansi 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "34dd4c507af68d37ffef962063dfa1944ce0dd4d5b82043dbab1dabe088610c3"
"checksum generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef25c5683767570c2bbd7deba372926a55eaae9982d7726ee2a1050239d45b9d"
"checksum getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "0a7292d30132fb5424b354f5dc02512a86e4c516fe544bb7a25e7f266951b797"
"checksum getopts 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)" = "72327b15c228bfe31f1390f93dd5e9279587f0463836393c9df719ce62a3e450"
"checksum git2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c7339329bfa14a00223244311560d11f8f489b453fb90092af97f267a6090ab0"
"checksum git2-curl 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d58551e903ed7e2d6fe3a2f3c7efa3a784ec29b19d0fbb035aaf0497c183fbdd"
"checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ build_helper = { path = "../build_helper" }
cmake = "0.1.38"
filetime = "0.2"
num_cpus = "1.0"
getopts = "0.2.18"
getopts = "0.2.19"
cc = "1.0.35"
libc = "0.2"
serde = "1.0.8"
Expand Down
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
31 changes: 25 additions & 6 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2184,10 +2184,21 @@ pub fn build_session_options_and_crate_config(
TargetTriple::from_triple(host_triple())
};
let opt_level = {
if matches.opt_present("O") {
if cg.opt_level.is_some() {
early_error(error_format, "-O and -C opt-level both provided");
// The `-O` and `-C opt-level` flags specify the same setting, so we want to be able
// to use them interchangeably. However, because they're technically different flags,
// we need to work out manually which should take precedence if both are supplied (i.e.
// the rightmost flag). We do this by finding the (rightmost) position of both flags and
// comparing them. Note that if a flag is not found, its position will be `None`, which
// always compared less than `Some(_)`.
let max_o = matches.opt_positions("O").into_iter().max();
let max_c = matches.opt_strs_pos("C").into_iter().flat_map(|(i, s)| {
if let Some("opt-level") = s.splitn(2, '=').next() {
Some(i)
} else {
None
}
}).max();
if max_o > max_c {
OptLevel::Default
} else {
match cg.opt_level.as_ref().map(String::as_ref) {
Expand All @@ -2211,11 +2222,19 @@ pub fn build_session_options_and_crate_config(
}
}
};
// The `-g` and `-C debuginfo` flags specify the same setting, so we want to be able
// to use them interchangeably. See the note above (regarding `-O` and `-C opt-level`)
// for more details.
let debug_assertions = cg.debug_assertions.unwrap_or(opt_level == OptLevel::No);
let debuginfo = if matches.opt_present("g") {
if cg.debuginfo.is_some() {
early_error(error_format, "-g and -C debuginfo both provided");
let max_g = matches.opt_positions("g").into_iter().max();
let max_c = matches.opt_strs_pos("C").into_iter().flat_map(|(i, s)| {
if let Some("debuginfo") = s.splitn(2, '=').next() {
Some(i)
} else {
None
}
}).max();
let debuginfo = if max_g > max_c {
DebugInfo::Full
} else {
match cg.debuginfo {
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
Loading