Skip to content

Commit

Permalink
Auto merge of rust-lang#70412 - Dylan-DPC:rollup-yuq2mfy, r=Dylan-DPC
Browse files Browse the repository at this point in the history
Rollup of 5 pull requests

Successful merges:

 - rust-lang#69700 (Rename LayoutDetails to just Layout.)
 - rust-lang#70392 (Make x.py compatible with python 3.8.)
 - rust-lang#70406 (Clean up E0458 explanation)
 - rust-lang#70407 (Avoid tagging as I-nominated on toolstate breakage)
 - rust-lang#70409 (gitignore: allow target to be a symlink)

Failed merges:

 - rust-lang#70375 (avoid catching InterpError)

r? @ghost
  • Loading branch information
bors committed Mar 25, 2020
2 parents a5fb9ae + 84a2865 commit e4519e2
Show file tree
Hide file tree
Showing 15 changed files with 85 additions and 84 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ __pycache__/
/obj/
/rustllvm/
/unicode-downloads
/target/
/target
# Generated by compiletest for incremental:
/tmp/
tags
Expand Down
10 changes: 8 additions & 2 deletions src/etc/lldb_batchmode.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,17 @@ def listen():
def start_watchdog():
"""Starts a watchdog thread that will terminate the process after a certain
period of time"""
watchdog_start_time = time.clock()

try:
from time import clock
except ImportError:
from time import perf_counter as clock

watchdog_start_time = clock()
watchdog_max_time = watchdog_start_time + 30

def watchdog():
while time.clock() < watchdog_max_time:
while clock() < watchdog_max_time:
time.sleep(1)
print("TIMEOUT: lldb_batchmode.py has been running for too long. Aborting!")
thread.interrupt_main()
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
macro_rules! arena_types {
($macro:path, $args:tt, $tcx:lifetime) => (
$macro!($args, [
[] layouts: rustc::ty::layout::LayoutDetails,
[] layouts: rustc::ty::layout::Layout,
[] generics: rustc::ty::Generics,
[] trait_def: rustc::ty::TraitDef,
[] adt_def: rustc::ty::AdtDef,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ rustc_queries! {

query layout_raw(
env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>
) -> Result<&'tcx ty::layout::LayoutDetails, ty::layout::LayoutError<'tcx>> {
) -> Result<&'tcx ty::layout::Layout, ty::layout::LayoutError<'tcx>> {
desc { "computing layout of `{}`", env.value }
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::mir::{
};
use crate::traits;
use crate::traits::{Clause, Clauses, Goal, GoalKind, Goals};
use crate::ty::layout::{LayoutDetails, TargetDataLayout, VariantIdx};
use crate::ty::layout::{Layout, TargetDataLayout, VariantIdx};
use crate::ty::query;
use crate::ty::steal::Steal;
use crate::ty::subst::{GenericArg, InternalSubsts, Subst, SubstsRef};
Expand Down Expand Up @@ -985,7 +985,7 @@ pub struct GlobalCtxt<'tcx> {
/// Stores memory for globals (statics/consts).
pub alloc_map: Lock<interpret::AllocMap<'tcx>>,

layout_interner: ShardedHashMap<&'tcx LayoutDetails, ()>,
layout_interner: ShardedHashMap<&'tcx Layout, ()>,

output_filenames: Arc<OutputFilenames>,
}
Expand Down Expand Up @@ -1040,7 +1040,7 @@ impl<'tcx> TyCtxt<'tcx> {
self.const_stability_interner.intern(stab, |stab| self.arena.alloc(stab))
}

pub fn intern_layout(self, layout: LayoutDetails) -> &'tcx LayoutDetails {
pub fn intern_layout(self, layout: Layout) -> &'tcx Layout {
self.layout_interner.intern(layout, |layout| self.arena.alloc(layout))
}

Expand Down
89 changes: 41 additions & 48 deletions src/librustc/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ impl<'tcx> fmt::Display for LayoutError<'tcx> {
fn layout_raw<'tcx>(
tcx: TyCtxt<'tcx>,
query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>,
) -> Result<&'tcx LayoutDetails, LayoutError<'tcx>> {
) -> Result<&'tcx Layout, LayoutError<'tcx>> {
ty::tls::with_related_context(tcx, move |icx| {
let rec_limit = *tcx.sess.recursion_limit.get();
let (param_env, ty) = query.into_parts();
Expand Down Expand Up @@ -240,7 +240,7 @@ fn invert_mapping(map: &[u32]) -> Vec<u32> {
}

impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
fn scalar_pair(&self, a: Scalar, b: Scalar) -> LayoutDetails {
fn scalar_pair(&self, a: Scalar, b: Scalar) -> Layout {
let dl = self.data_layout();
let b_align = b.value.align(dl);
let align = a.value.align(dl).max(b_align).max(dl.aggregate_align);
Expand All @@ -254,7 +254,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
.chain(Niche::from_scalar(dl, Size::ZERO, a.clone()))
.max_by_key(|niche| niche.available(dl));

LayoutDetails {
Layout {
variants: Variants::Single { index: VariantIdx::new(0) },
fields: FieldPlacement::Arbitrary {
offsets: vec![Size::ZERO, b_offset],
Expand All @@ -273,7 +273,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
fields: &[TyLayout<'_>],
repr: &ReprOptions,
kind: StructKind,
) -> Result<LayoutDetails, LayoutError<'tcx>> {
) -> Result<Layout, LayoutError<'tcx>> {
let dl = self.data_layout();
let pack = repr.pack;
if pack.is_some() && repr.align.is_some() {
Expand Down Expand Up @@ -422,17 +422,11 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
(
Some((
i,
&TyLayout {
details: &LayoutDetails { abi: Abi::Scalar(ref a), .. },
..
},
&TyLayout { layout: &Layout { abi: Abi::Scalar(ref a), .. }, .. },
)),
Some((
j,
&TyLayout {
details: &LayoutDetails { abi: Abi::Scalar(ref b), .. },
..
},
&TyLayout { layout: &Layout { abi: Abi::Scalar(ref b), .. }, .. },
)),
None,
) => {
Expand Down Expand Up @@ -470,7 +464,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
abi = Abi::Uninhabited;
}

Ok(LayoutDetails {
Ok(Layout {
variants: Variants::Single { index: VariantIdx::new(0) },
fields: FieldPlacement::Arbitrary { offsets, memory_index },
abi,
Expand All @@ -480,7 +474,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
})
}

fn layout_raw_uncached(&self, ty: Ty<'tcx>) -> Result<&'tcx LayoutDetails, LayoutError<'tcx>> {
fn layout_raw_uncached(&self, ty: Ty<'tcx>) -> Result<&'tcx Layout, LayoutError<'tcx>> {
let tcx = self.tcx;
let param_env = self.param_env;
let dl = self.data_layout();
Expand All @@ -489,8 +483,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
assert!(bits <= 128);
Scalar { value, valid_range: 0..=(!0 >> (128 - bits)) }
};
let scalar =
|value: Primitive| tcx.intern_layout(LayoutDetails::scalar(self, scalar_unit(value)));
let scalar = |value: Primitive| tcx.intern_layout(Layout::scalar(self, scalar_unit(value)));

let univariant = |fields: &[TyLayout<'_>], repr: &ReprOptions, kind| {
Ok(tcx.intern_layout(self.univariant_uninterned(ty, fields, repr, kind)?))
Expand All @@ -499,11 +492,11 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {

Ok(match ty.kind {
// Basic scalars.
ty::Bool => tcx.intern_layout(LayoutDetails::scalar(
ty::Bool => tcx.intern_layout(Layout::scalar(
self,
Scalar { value: Int(I8, false), valid_range: 0..=1 },
)),
ty::Char => tcx.intern_layout(LayoutDetails::scalar(
ty::Char => tcx.intern_layout(Layout::scalar(
self,
Scalar { value: Int(I32, false), valid_range: 0..=0x10FFFF },
)),
Expand All @@ -516,11 +509,11 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
ty::FnPtr(_) => {
let mut ptr = scalar_unit(Pointer);
ptr.valid_range = 1..=*ptr.valid_range.end();
tcx.intern_layout(LayoutDetails::scalar(self, ptr))
tcx.intern_layout(Layout::scalar(self, ptr))
}

// The never type.
ty::Never => tcx.intern_layout(LayoutDetails {
ty::Never => tcx.intern_layout(Layout {
variants: Variants::Single { index: VariantIdx::new(0) },
fields: FieldPlacement::Union(0),
abi: Abi::Uninhabited,
Expand All @@ -538,13 +531,13 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {

let pointee = tcx.normalize_erasing_regions(param_env, pointee);
if pointee.is_sized(tcx.at(DUMMY_SP), param_env) {
return Ok(tcx.intern_layout(LayoutDetails::scalar(self, data_ptr)));
return Ok(tcx.intern_layout(Layout::scalar(self, data_ptr)));
}

let unsized_part = tcx.struct_tail_erasing_lifetimes(pointee, param_env);
let metadata = match unsized_part.kind {
ty::Foreign(..) => {
return Ok(tcx.intern_layout(LayoutDetails::scalar(self, data_ptr)));
return Ok(tcx.intern_layout(Layout::scalar(self, data_ptr)));
}
ty::Slice(_) | ty::Str => scalar_unit(Int(dl.ptr_sized_integer(), false)),
ty::Dynamic(..) => {
Expand Down Expand Up @@ -581,7 +574,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {

let largest_niche = if count != 0 { element.largest_niche.clone() } else { None };

tcx.intern_layout(LayoutDetails {
tcx.intern_layout(Layout {
variants: Variants::Single { index: VariantIdx::new(0) },
fields: FieldPlacement::Array { stride: element.size, count },
abi,
Expand All @@ -592,7 +585,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
}
ty::Slice(element) => {
let element = self.layout_of(element)?;
tcx.intern_layout(LayoutDetails {
tcx.intern_layout(Layout {
variants: Variants::Single { index: VariantIdx::new(0) },
fields: FieldPlacement::Array { stride: element.size, count: 0 },
abi: Abi::Aggregate { sized: false },
Expand All @@ -601,7 +594,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
size: Size::ZERO,
})
}
ty::Str => tcx.intern_layout(LayoutDetails {
ty::Str => tcx.intern_layout(Layout {
variants: Variants::Single { index: VariantIdx::new(0) },
fields: FieldPlacement::Array { stride: Size::from_bytes(1), count: 0 },
abi: Abi::Aggregate { sized: false },
Expand Down Expand Up @@ -670,7 +663,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
let align = dl.vector_align(size);
let size = size.align_to(align.abi);

tcx.intern_layout(LayoutDetails {
tcx.intern_layout(Layout {
variants: Variants::Single { index: VariantIdx::new(0) },
fields: FieldPlacement::Array { stride: element.size, count },
abi: Abi::Vector { element: scalar, count },
Expand Down Expand Up @@ -746,7 +739,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
align = align.min(AbiAndPrefAlign::new(pack));
}

return Ok(tcx.intern_layout(LayoutDetails {
return Ok(tcx.intern_layout(Layout {
variants: Variants::Single { index },
fields: FieldPlacement::Union(variants[index].len()),
abi,
Expand Down Expand Up @@ -970,7 +963,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
let largest_niche =
Niche::from_scalar(dl, offset, niche_scalar.clone());

return Ok(tcx.intern_layout(LayoutDetails {
return Ok(tcx.intern_layout(Layout {
variants: Variants::Multiple {
discr: niche_scalar,
discr_kind: DiscriminantKind::Niche {
Expand Down Expand Up @@ -1165,7 +1158,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
break;
}
};
let prim = match field.details.abi {
let prim = match field.abi {
Abi::Scalar(ref scalar) => scalar.value,
_ => {
common_prim = None;
Expand Down Expand Up @@ -1212,7 +1205,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {

let largest_niche = Niche::from_scalar(dl, Size::ZERO, tag.clone());

tcx.intern_layout(LayoutDetails {
tcx.intern_layout(Layout {
variants: Variants::Multiple {
discr: tag,
discr_kind: DiscriminantKind::Tag,
Expand Down Expand Up @@ -1243,7 +1236,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
| ty::Placeholder(..)
| ty::UnnormalizedProjection(..)
| ty::GeneratorWitness(..)
| ty::Infer(_) => bug!("LayoutDetails::compute: unexpected type `{}`", ty),
| ty::Infer(_) => bug!("Layout::compute: unexpected type `{}`", ty),

ty::Param(_) | ty::Error => {
return Err(LayoutError::Unknown(ty));
Expand Down Expand Up @@ -1390,7 +1383,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
ty: Ty<'tcx>,
def_id: hir::def_id::DefId,
substs: SubstsRef<'tcx>,
) -> Result<&'tcx LayoutDetails, LayoutError<'tcx>> {
) -> Result<&'tcx Layout, LayoutError<'tcx>> {
use SavedLocalEligibility::*;
let tcx = self.tcx;

Expand All @@ -1409,8 +1402,8 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
let discr_int = Integer::fit_unsigned(max_discr);
let discr_int_ty = discr_int.to_ty(tcx, false);
let discr = Scalar { value: Primitive::Int(discr_int, false), valid_range: 0..=max_discr };
let discr_layout = self.tcx.intern_layout(LayoutDetails::scalar(self, discr.clone()));
let discr_layout = TyLayout { ty: discr_int_ty, details: discr_layout };
let discr_layout = self.tcx.intern_layout(Layout::scalar(self, discr.clone()));
let discr_layout = TyLayout { ty: discr_int_ty, layout: discr_layout };

let promoted_layouts = ineligible_locals
.iter()
Expand Down Expand Up @@ -1559,7 +1552,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
Abi::Aggregate { sized: true }
};

let layout = tcx.intern_layout(LayoutDetails {
let layout = tcx.intern_layout(Layout {
variants: Variants::Multiple {
discr,
discr_kind: DiscriminantKind::Tag,
Expand Down Expand Up @@ -1908,8 +1901,8 @@ impl<'tcx> LayoutOf for LayoutCx<'tcx, TyCtxt<'tcx>> {
fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyLayout {
let param_env = self.param_env.with_reveal_all();
let ty = self.tcx.normalize_erasing_regions(param_env, ty);
let details = self.tcx.layout_raw(param_env.and(ty))?;
let layout = TyLayout { ty, details };
let layout = self.tcx.layout_raw(param_env.and(ty))?;
let layout = TyLayout { ty, layout };

// N.B., this recording is normally disabled; when enabled, it
// can however trigger recursive invocations of `layout_of`.
Expand All @@ -1932,8 +1925,8 @@ impl LayoutOf for LayoutCx<'tcx, ty::query::TyCtxtAt<'tcx>> {
fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyLayout {
let param_env = self.param_env.with_reveal_all();
let ty = self.tcx.normalize_erasing_regions(param_env, ty);
let details = self.tcx.layout_raw(param_env.and(ty))?;
let layout = TyLayout { ty, details };
let layout = self.tcx.layout_raw(param_env.and(ty))?;
let layout = TyLayout { ty, layout };

// N.B., this recording is normally disabled; when enabled, it
// can however trigger recursive invocations of `layout_of`.
Expand Down Expand Up @@ -1982,29 +1975,29 @@ where
+ HasParamEnv<'tcx>,
{
fn for_variant(this: TyLayout<'tcx>, cx: &C, variant_index: VariantIdx) -> TyLayout<'tcx> {
let details = match this.variants {
let layout = match this.variants {
Variants::Single { index }
// If all variants but one are uninhabited, the variant layout is the enum layout.
if index == variant_index &&
// Don't confuse variants of uninhabited enums with the enum itself.
// For more details see https://github.com/rust-lang/rust/issues/69763.
this.fields != FieldPlacement::Union(0) =>
{
this.details
this.layout
}

Variants::Single { index } => {
// Deny calling for_variant more than once for non-Single enums.
if let Ok(layout) = cx.layout_of(this.ty).to_result() {
assert_eq!(layout.variants, Variants::Single { index });
if let Ok(original_layout) = cx.layout_of(this.ty).to_result() {
assert_eq!(original_layout.variants, Variants::Single { index });
}

let fields = match this.ty.kind {
ty::Adt(def, _) => def.variants[variant_index].fields.len(),
_ => bug!(),
};
let tcx = cx.tcx();
tcx.intern_layout(LayoutDetails {
tcx.intern_layout(Layout {
variants: Variants::Single { index: variant_index },
fields: FieldPlacement::Union(fields),
abi: Abi::Uninhabited,
Expand All @@ -2017,17 +2010,17 @@ where
Variants::Multiple { ref variants, .. } => &variants[variant_index],
};

assert_eq!(details.variants, Variants::Single { index: variant_index });
assert_eq!(layout.variants, Variants::Single { index: variant_index });

TyLayout { ty: this.ty, details }
TyLayout { ty: this.ty, layout }
}

fn field(this: TyLayout<'tcx>, cx: &C, i: usize) -> C::TyLayout {
let tcx = cx.tcx();
let discr_layout = |discr: &Scalar| -> C::TyLayout {
let layout = LayoutDetails::scalar(cx, discr.clone());
let layout = Layout::scalar(cx, discr.clone());
MaybeResult::from(Ok(TyLayout {
details: tcx.intern_layout(layout),
layout: tcx.intern_layout(layout),
ty: discr.value.to_ty(tcx),
}))
};
Expand Down
4 changes: 3 additions & 1 deletion src/librustc_error_codes/error_codes/E0458.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
An unknown "kind" was specified for a link attribute. Erroneous code example:
An unknown "kind" was specified for a link attribute.

Erroneous code example:

```compile_fail,E0458
#[link(kind = "wonderful_unicorn")] extern {}
Expand Down
Loading

0 comments on commit e4519e2

Please sign in to comment.