Skip to content

Commit e4519e2

Browse files
committed
Auto merge of rust-lang#70412 - Dylan-DPC:rollup-yuq2mfy, r=Dylan-DPC
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
2 parents a5fb9ae + 84a2865 commit e4519e2

File tree

15 files changed

+85
-84
lines changed

15 files changed

+85
-84
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ __pycache__/
3535
/obj/
3636
/rustllvm/
3737
/unicode-downloads
38-
/target/
38+
/target
3939
# Generated by compiletest for incremental:
4040
/tmp/
4141
tags

src/etc/lldb_batchmode.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,17 @@ def listen():
139139
def start_watchdog():
140140
"""Starts a watchdog thread that will terminate the process after a certain
141141
period of time"""
142-
watchdog_start_time = time.clock()
142+
143+
try:
144+
from time import clock
145+
except ImportError:
146+
from time import perf_counter as clock
147+
148+
watchdog_start_time = clock()
143149
watchdog_max_time = watchdog_start_time + 30
144150

145151
def watchdog():
146-
while time.clock() < watchdog_max_time:
152+
while clock() < watchdog_max_time:
147153
time.sleep(1)
148154
print("TIMEOUT: lldb_batchmode.py has been running for too long. Aborting!")
149155
thread.interrupt_main()

src/librustc/arena.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
macro_rules! arena_types {
1212
($macro:path, $args:tt, $tcx:lifetime) => (
1313
$macro!($args, [
14-
[] layouts: rustc::ty::layout::LayoutDetails,
14+
[] layouts: rustc::ty::layout::Layout,
1515
[] generics: rustc::ty::Generics,
1616
[] trait_def: rustc::ty::TraitDef,
1717
[] adt_def: rustc::ty::AdtDef,

src/librustc/query/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ rustc_queries! {
738738

739739
query layout_raw(
740740
env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>
741-
) -> Result<&'tcx ty::layout::LayoutDetails, ty::layout::LayoutError<'tcx>> {
741+
) -> Result<&'tcx ty::layout::Layout, ty::layout::LayoutError<'tcx>> {
742742
desc { "computing layout of `{}`", env.value }
743743
}
744744
}

src/librustc/ty/context.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use crate::mir::{
2020
};
2121
use crate::traits;
2222
use crate::traits::{Clause, Clauses, Goal, GoalKind, Goals};
23-
use crate::ty::layout::{LayoutDetails, TargetDataLayout, VariantIdx};
23+
use crate::ty::layout::{Layout, TargetDataLayout, VariantIdx};
2424
use crate::ty::query;
2525
use crate::ty::steal::Steal;
2626
use crate::ty::subst::{GenericArg, InternalSubsts, Subst, SubstsRef};
@@ -985,7 +985,7 @@ pub struct GlobalCtxt<'tcx> {
985985
/// Stores memory for globals (statics/consts).
986986
pub alloc_map: Lock<interpret::AllocMap<'tcx>>,
987987

988-
layout_interner: ShardedHashMap<&'tcx LayoutDetails, ()>,
988+
layout_interner: ShardedHashMap<&'tcx Layout, ()>,
989989

990990
output_filenames: Arc<OutputFilenames>,
991991
}
@@ -1040,7 +1040,7 @@ impl<'tcx> TyCtxt<'tcx> {
10401040
self.const_stability_interner.intern(stab, |stab| self.arena.alloc(stab))
10411041
}
10421042

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

src/librustc/ty/layout.rs

+41-48
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ impl<'tcx> fmt::Display for LayoutError<'tcx> {
181181
fn layout_raw<'tcx>(
182182
tcx: TyCtxt<'tcx>,
183183
query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>,
184-
) -> Result<&'tcx LayoutDetails, LayoutError<'tcx>> {
184+
) -> Result<&'tcx Layout, LayoutError<'tcx>> {
185185
ty::tls::with_related_context(tcx, move |icx| {
186186
let rec_limit = *tcx.sess.recursion_limit.get();
187187
let (param_env, ty) = query.into_parts();
@@ -240,7 +240,7 @@ fn invert_mapping(map: &[u32]) -> Vec<u32> {
240240
}
241241

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

257-
LayoutDetails {
257+
Layout {
258258
variants: Variants::Single { index: VariantIdx::new(0) },
259259
fields: FieldPlacement::Arbitrary {
260260
offsets: vec![Size::ZERO, b_offset],
@@ -273,7 +273,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
273273
fields: &[TyLayout<'_>],
274274
repr: &ReprOptions,
275275
kind: StructKind,
276-
) -> Result<LayoutDetails, LayoutError<'tcx>> {
276+
) -> Result<Layout, LayoutError<'tcx>> {
277277
let dl = self.data_layout();
278278
let pack = repr.pack;
279279
if pack.is_some() && repr.align.is_some() {
@@ -422,17 +422,11 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
422422
(
423423
Some((
424424
i,
425-
&TyLayout {
426-
details: &LayoutDetails { abi: Abi::Scalar(ref a), .. },
427-
..
428-
},
425+
&TyLayout { layout: &Layout { abi: Abi::Scalar(ref a), .. }, .. },
429426
)),
430427
Some((
431428
j,
432-
&TyLayout {
433-
details: &LayoutDetails { abi: Abi::Scalar(ref b), .. },
434-
..
435-
},
429+
&TyLayout { layout: &Layout { abi: Abi::Scalar(ref b), .. }, .. },
436430
)),
437431
None,
438432
) => {
@@ -470,7 +464,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
470464
abi = Abi::Uninhabited;
471465
}
472466

473-
Ok(LayoutDetails {
467+
Ok(Layout {
474468
variants: Variants::Single { index: VariantIdx::new(0) },
475469
fields: FieldPlacement::Arbitrary { offsets, memory_index },
476470
abi,
@@ -480,7 +474,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
480474
})
481475
}
482476

483-
fn layout_raw_uncached(&self, ty: Ty<'tcx>) -> Result<&'tcx LayoutDetails, LayoutError<'tcx>> {
477+
fn layout_raw_uncached(&self, ty: Ty<'tcx>) -> Result<&'tcx Layout, LayoutError<'tcx>> {
484478
let tcx = self.tcx;
485479
let param_env = self.param_env;
486480
let dl = self.data_layout();
@@ -489,8 +483,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
489483
assert!(bits <= 128);
490484
Scalar { value, valid_range: 0..=(!0 >> (128 - bits)) }
491485
};
492-
let scalar =
493-
|value: Primitive| tcx.intern_layout(LayoutDetails::scalar(self, scalar_unit(value)));
486+
let scalar = |value: Primitive| tcx.intern_layout(Layout::scalar(self, scalar_unit(value)));
494487

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

500493
Ok(match ty.kind {
501494
// Basic scalars.
502-
ty::Bool => tcx.intern_layout(LayoutDetails::scalar(
495+
ty::Bool => tcx.intern_layout(Layout::scalar(
503496
self,
504497
Scalar { value: Int(I8, false), valid_range: 0..=1 },
505498
)),
506-
ty::Char => tcx.intern_layout(LayoutDetails::scalar(
499+
ty::Char => tcx.intern_layout(Layout::scalar(
507500
self,
508501
Scalar { value: Int(I32, false), valid_range: 0..=0x10FFFF },
509502
)),
@@ -516,11 +509,11 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
516509
ty::FnPtr(_) => {
517510
let mut ptr = scalar_unit(Pointer);
518511
ptr.valid_range = 1..=*ptr.valid_range.end();
519-
tcx.intern_layout(LayoutDetails::scalar(self, ptr))
512+
tcx.intern_layout(Layout::scalar(self, ptr))
520513
}
521514

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

539532
let pointee = tcx.normalize_erasing_regions(param_env, pointee);
540533
if pointee.is_sized(tcx.at(DUMMY_SP), param_env) {
541-
return Ok(tcx.intern_layout(LayoutDetails::scalar(self, data_ptr)));
534+
return Ok(tcx.intern_layout(Layout::scalar(self, data_ptr)));
542535
}
543536

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

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

584-
tcx.intern_layout(LayoutDetails {
577+
tcx.intern_layout(Layout {
585578
variants: Variants::Single { index: VariantIdx::new(0) },
586579
fields: FieldPlacement::Array { stride: element.size, count },
587580
abi,
@@ -592,7 +585,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
592585
}
593586
ty::Slice(element) => {
594587
let element = self.layout_of(element)?;
595-
tcx.intern_layout(LayoutDetails {
588+
tcx.intern_layout(Layout {
596589
variants: Variants::Single { index: VariantIdx::new(0) },
597590
fields: FieldPlacement::Array { stride: element.size, count: 0 },
598591
abi: Abi::Aggregate { sized: false },
@@ -601,7 +594,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
601594
size: Size::ZERO,
602595
})
603596
}
604-
ty::Str => tcx.intern_layout(LayoutDetails {
597+
ty::Str => tcx.intern_layout(Layout {
605598
variants: Variants::Single { index: VariantIdx::new(0) },
606599
fields: FieldPlacement::Array { stride: Size::from_bytes(1), count: 0 },
607600
abi: Abi::Aggregate { sized: false },
@@ -670,7 +663,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
670663
let align = dl.vector_align(size);
671664
let size = size.align_to(align.abi);
672665

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

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

973-
return Ok(tcx.intern_layout(LayoutDetails {
966+
return Ok(tcx.intern_layout(Layout {
974967
variants: Variants::Multiple {
975968
discr: niche_scalar,
976969
discr_kind: DiscriminantKind::Niche {
@@ -1165,7 +1158,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
11651158
break;
11661159
}
11671160
};
1168-
let prim = match field.details.abi {
1161+
let prim = match field.abi {
11691162
Abi::Scalar(ref scalar) => scalar.value,
11701163
_ => {
11711164
common_prim = None;
@@ -1212,7 +1205,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
12121205

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

1215-
tcx.intern_layout(LayoutDetails {
1208+
tcx.intern_layout(Layout {
12161209
variants: Variants::Multiple {
12171210
discr: tag,
12181211
discr_kind: DiscriminantKind::Tag,
@@ -1243,7 +1236,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
12431236
| ty::Placeholder(..)
12441237
| ty::UnnormalizedProjection(..)
12451238
| ty::GeneratorWitness(..)
1246-
| ty::Infer(_) => bug!("LayoutDetails::compute: unexpected type `{}`", ty),
1239+
| ty::Infer(_) => bug!("Layout::compute: unexpected type `{}`", ty),
12471240

12481241
ty::Param(_) | ty::Error => {
12491242
return Err(LayoutError::Unknown(ty));
@@ -1390,7 +1383,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
13901383
ty: Ty<'tcx>,
13911384
def_id: hir::def_id::DefId,
13921385
substs: SubstsRef<'tcx>,
1393-
) -> Result<&'tcx LayoutDetails, LayoutError<'tcx>> {
1386+
) -> Result<&'tcx Layout, LayoutError<'tcx>> {
13941387
use SavedLocalEligibility::*;
13951388
let tcx = self.tcx;
13961389

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

14151408
let promoted_layouts = ineligible_locals
14161409
.iter()
@@ -1559,7 +1552,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
15591552
Abi::Aggregate { sized: true }
15601553
};
15611554

1562-
let layout = tcx.intern_layout(LayoutDetails {
1555+
let layout = tcx.intern_layout(Layout {
15631556
variants: Variants::Multiple {
15641557
discr,
15651558
discr_kind: DiscriminantKind::Tag,
@@ -1908,8 +1901,8 @@ impl<'tcx> LayoutOf for LayoutCx<'tcx, TyCtxt<'tcx>> {
19081901
fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyLayout {
19091902
let param_env = self.param_env.with_reveal_all();
19101903
let ty = self.tcx.normalize_erasing_regions(param_env, ty);
1911-
let details = self.tcx.layout_raw(param_env.and(ty))?;
1912-
let layout = TyLayout { ty, details };
1904+
let layout = self.tcx.layout_raw(param_env.and(ty))?;
1905+
let layout = TyLayout { ty, layout };
19131906

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

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

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

20021995
let fields = match this.ty.kind {
20031996
ty::Adt(def, _) => def.variants[variant_index].fields.len(),
20041997
_ => bug!(),
20051998
};
20061999
let tcx = cx.tcx();
2007-
tcx.intern_layout(LayoutDetails {
2000+
tcx.intern_layout(Layout {
20082001
variants: Variants::Single { index: variant_index },
20092002
fields: FieldPlacement::Union(fields),
20102003
abi: Abi::Uninhabited,
@@ -2017,17 +2010,17 @@ where
20172010
Variants::Multiple { ref variants, .. } => &variants[variant_index],
20182011
};
20192012

2020-
assert_eq!(details.variants, Variants::Single { index: variant_index });
2013+
assert_eq!(layout.variants, Variants::Single { index: variant_index });
20212014

2022-
TyLayout { ty: this.ty, details }
2015+
TyLayout { ty: this.ty, layout }
20232016
}
20242017

20252018
fn field(this: TyLayout<'tcx>, cx: &C, i: usize) -> C::TyLayout {
20262019
let tcx = cx.tcx();
20272020
let discr_layout = |discr: &Scalar| -> C::TyLayout {
2028-
let layout = LayoutDetails::scalar(cx, discr.clone());
2021+
let layout = Layout::scalar(cx, discr.clone());
20292022
MaybeResult::from(Ok(TyLayout {
2030-
details: tcx.intern_layout(layout),
2023+
layout: tcx.intern_layout(layout),
20312024
ty: discr.value.to_ty(tcx),
20322025
}))
20332026
};

src/librustc_error_codes/error_codes/E0458.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
An unknown "kind" was specified for a link attribute. Erroneous code example:
1+
An unknown "kind" was specified for a link attribute.
2+
3+
Erroneous code example:
24

35
```compile_fail,E0458
46
#[link(kind = "wonderful_unicorn")] extern {}

0 commit comments

Comments
 (0)