Skip to content

Commit 3128fd8

Browse files
committed
Auto merge of #110666 - JohnTitor:rollup-3pwilte, r=JohnTitor
Rollup of 7 pull requests Successful merges: - #109949 (rustdoc: migrate `document_type_layout` to askama) - #110622 (Stable hash tag (discriminant) of `GenericArg`) - #110635 (More `IS_ZST` in `library`) - #110640 (compiler/rustc_target: Raise m68k-linux-gnu baseline to 68020) - #110657 (nit: consistent naming for SimplifyConstCondition) - #110659 (rustdoc: clean up JS) - #110660 (Print ty placeholders pretty) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 37b22cf + 16e2096 commit 3128fd8

File tree

19 files changed

+200
-180
lines changed

19 files changed

+200
-180
lines changed

compiler/rustc_middle/src/ty/impls_ty.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -73,34 +73,6 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for ty::subst::GenericArg<'t
7373
}
7474
}
7575

76-
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for ty::subst::GenericArgKind<'tcx> {
77-
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
78-
match self {
79-
// WARNING: We dedup cache the `HashStable` results for `List`
80-
// while ignoring types and freely transmute
81-
// between `List<Ty<'tcx>>` and `List<GenericArg<'tcx>>`.
82-
// See `fn mk_type_list` for more details.
83-
//
84-
// We therefore hash types without adding a hash for their discriminant.
85-
//
86-
// In order to make it very unlikely for the sequence of bytes being hashed for
87-
// a `GenericArgKind::Type` to be the same as the sequence of bytes being
88-
// hashed for one of the other variants, we hash some very high number instead
89-
// of their actual discriminant since `TyKind` should never start with anything
90-
// that high.
91-
ty::subst::GenericArgKind::Type(ty) => ty.hash_stable(hcx, hasher),
92-
ty::subst::GenericArgKind::Const(ct) => {
93-
0xF3u8.hash_stable(hcx, hasher);
94-
ct.hash_stable(hcx, hasher);
95-
}
96-
ty::subst::GenericArgKind::Lifetime(lt) => {
97-
0xF5u8.hash_stable(hcx, hasher);
98-
lt.hash_stable(hcx, hasher);
99-
}
100-
}
101-
}
102-
}
103-
10476
// AllocIds get resolved to whatever they point to (to be stable)
10577
impl<'a> HashStable<StableHashingContext<'a>> for mir::interpret::AllocId {
10678
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {

compiler/rustc_middle/src/ty/print/pretty.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,9 @@ pub trait PrettyPrinter<'tcx>:
738738
}
739739
}
740740
ty::Placeholder(placeholder) => match placeholder.bound.kind {
741-
ty::BoundTyKind::Anon => p!(write("Placeholder({:?})", placeholder)),
741+
ty::BoundTyKind::Anon => {
742+
self.pretty_print_placeholder_var(placeholder.universe, placeholder.bound.var)?
743+
}
742744
ty::BoundTyKind::Param(_, name) => p!(write("{}", name)),
743745
},
744746
ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => {
@@ -1172,6 +1174,18 @@ pub trait PrettyPrinter<'tcx>:
11721174
}
11731175
}
11741176

1177+
fn pretty_print_placeholder_var(
1178+
&mut self,
1179+
ui: ty::UniverseIndex,
1180+
var: ty::BoundVar,
1181+
) -> Result<(), Self::Error> {
1182+
if ui == ty::UniverseIndex::ROOT {
1183+
write!(self, "!{}", var.index())
1184+
} else {
1185+
write!(self, "!{}_{}", ui.index(), var.index())
1186+
}
1187+
}
1188+
11751189
fn ty_infer_name(&self, _: ty::TyVid) -> Option<Symbol> {
11761190
None
11771191
}

compiler/rustc_middle/src/ty/subst.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const TYPE_TAG: usize = 0b00;
4747
const REGION_TAG: usize = 0b01;
4848
const CONST_TAG: usize = 0b10;
4949

50-
#[derive(Debug, TyEncodable, TyDecodable, PartialEq, Eq, PartialOrd, Ord)]
50+
#[derive(Debug, TyEncodable, TyDecodable, PartialEq, Eq, PartialOrd, Ord, HashStable)]
5151
pub enum GenericArgKind<'tcx> {
5252
Lifetime(ty::Region<'tcx>),
5353
Type(Ty<'tcx>),

compiler/rustc_mir_transform/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,12 +507,12 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
507507
//
508508
// Const-prop runs unconditionally, but doesn't mutate the MIR at mir-opt-level=0.
509509
&const_debuginfo::ConstDebugInfo,
510-
&o1(simplify_branches::SimplifyConstConditionPassName::AfterConstProp),
510+
&o1(simplify_branches::SimplifyConstCondition::AfterConstProp),
511511
&early_otherwise_branch::EarlyOtherwiseBranch,
512512
&simplify_comparison_integral::SimplifyComparisonIntegral,
513513
&dead_store_elimination::DeadStoreElimination,
514514
&dest_prop::DestinationPropagation,
515-
&o1(simplify_branches::SimplifyConstConditionPassName::Final),
515+
&o1(simplify_branches::SimplifyConstCondition::Final),
516516
&o1(remove_noop_landing_pads::RemoveNoopLandingPads),
517517
&o1(simplify::SimplifyCfg::Final),
518518
&nrvo::RenameReturnPlace,

compiler/rustc_mir_transform/src/simplify_branches.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@ use crate::MirPass;
22
use rustc_middle::mir::*;
33
use rustc_middle::ty::TyCtxt;
44

5-
pub enum SimplifyConstConditionPassName {
5+
pub enum SimplifyConstCondition {
66
AfterConstProp,
77
Final,
88
}
99
/// A pass that replaces a branch with a goto when its condition is known.
10-
impl<'tcx> MirPass<'tcx> for SimplifyConstConditionPassName {
10+
impl<'tcx> MirPass<'tcx> for SimplifyConstCondition {
1111
fn name(&self) -> &'static str {
1212
match self {
13-
SimplifyConstConditionPassName::AfterConstProp => {
14-
"SimplifyConstCondition-after-const-prop"
15-
}
16-
SimplifyConstConditionPassName::Final => "SimplifyConstCondition-final",
13+
SimplifyConstCondition::AfterConstProp => "SimplifyConstCondition-after-const-prop",
14+
SimplifyConstCondition::Final => "SimplifyConstCondition-final",
1715
}
1816
}
1917

compiler/rustc_target/src/spec/m68k_unknown_linux_gnu.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::spec::{Target, TargetOptions};
33

44
pub fn target() -> Target {
55
let mut base = super::linux_gnu_base::opts();
6+
base.cpu = "M68020".into();
67
base.max_atomic_width = Some(32);
78

89
Target {

compiler/rustc_type_ir/src/sty.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ pub enum TyKind<I: Interner> {
203203
/// `for<'a, T> &'a (): Trait<T>` and then convert the introduced bound variables
204204
/// back to inference variables in a new inference context when inside of the query.
205205
///
206+
/// It is conventional to render anonymous bound types like `^N` or `^D_N`,
207+
/// where `N` is the bound variable's anonymous index into the binder, and
208+
/// `D` is the debruijn index, or totally omitted if the debruijn index is zero.
209+
///
206210
/// See the `rustc-dev-guide` for more details about
207211
/// [higher-ranked trait bounds][1] and [canonical queries][2].
208212
///
@@ -212,6 +216,12 @@ pub enum TyKind<I: Interner> {
212216

213217
/// A placeholder type, used during higher ranked subtyping to instantiate
214218
/// bound variables.
219+
///
220+
/// It is conventional to render anonymous placeholer types like `!N` or `!U_N`,
221+
/// where `N` is the placeholder variable's anonymous index (which corresponds
222+
/// to the bound variable's index from the binder from which it was instantiated),
223+
/// and `U` is the universe index in which it is instantiated, or totally omitted
224+
/// if the universe index is zero.
215225
Placeholder(I::PlaceholderType),
216226

217227
/// A type variable used during type checking.

library/alloc/src/boxed/thin.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use core::fmt::{self, Debug, Display, Formatter};
77
use core::marker::PhantomData;
88
#[cfg(not(no_global_oom_handling))]
99
use core::marker::Unsize;
10-
use core::mem;
10+
use core::mem::{self, SizedTypeProperties};
1111
use core::ops::{Deref, DerefMut};
1212
use core::ptr::Pointee;
1313
use core::ptr::{self, NonNull};
@@ -202,9 +202,7 @@ impl<H> WithHeader<H> {
202202
let ptr = if layout.size() == 0 {
203203
// Some paranoia checking, mostly so that the ThinBox tests are
204204
// more able to catch issues.
205-
debug_assert!(
206-
value_offset == 0 && mem::size_of::<T>() == 0 && mem::size_of::<H>() == 0
207-
);
205+
debug_assert!(value_offset == 0 && T::IS_ZST && H::IS_ZST);
208206
layout.dangling()
209207
} else {
210208
let ptr = alloc::alloc(layout);
@@ -249,9 +247,7 @@ impl<H> WithHeader<H> {
249247
alloc::dealloc(self.ptr.as_ptr().sub(value_offset), layout);
250248
} else {
251249
debug_assert!(
252-
value_offset == 0
253-
&& mem::size_of::<H>() == 0
254-
&& self.value_layout.size() == 0
250+
value_offset == 0 && H::IS_ZST && self.value_layout.size() == 0
255251
);
256252
}
257253
}

library/alloc/src/vec/drain.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,7 @@ impl<'a, T, A: Allocator> Drain<'a, T, A> {
112112
let unyielded_ptr = this.iter.as_slice().as_ptr();
113113

114114
// ZSTs have no identity, so we don't need to move them around.
115-
let needs_move = mem::size_of::<T>() != 0;
116-
117-
if needs_move {
115+
if !T::IS_ZST {
118116
let start_ptr = source_vec.as_mut_ptr().add(start);
119117

120118
// memmove back unyielded elements

library/alloc/src/vec/drain_filter.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::alloc::{Allocator, Global};
2-
use core::mem::{self, ManuallyDrop};
2+
use core::mem::{ManuallyDrop, SizedTypeProperties};
33
use core::ptr;
44
use core::slice;
55

@@ -96,9 +96,7 @@ where
9696

9797
unsafe {
9898
// ZSTs have no identity, so we don't need to move them around.
99-
let needs_move = mem::size_of::<T>() != 0;
100-
101-
if needs_move && this.idx < this.old_len && this.del > 0 {
99+
if !T::IS_ZST && this.idx < this.old_len && this.del > 0 {
102100
let ptr = this.vec.as_mut_ptr();
103101
let src = ptr.add(this.idx);
104102
let dst = src.sub(this.del);

0 commit comments

Comments
 (0)