Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 66e0643

Browse files
committed
Auto merge of rust-lang#115787 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum
[stable] 1.72.1 release This backports: * Remove assert that checks type equality rust-lang#115215 * implied bounds: do not ICE on unconstrained region vars rust-lang#115559 * rustdoc: correctly deal with self ty params when eliding default object lifetimes rust-lang#115276 * Stop emitting non-power-of-two vectors in (non-portable-SIMD) codegen rust-lang#115236 * Normalize before checking if local is freeze in deduced_param_attrs rust-lang#114948 Some cherry-picks required merge conflict resolution, we'll see if I got it right based on CI (rustdoc fix and LLVM codegen test). r? `@Mark-Simulacrum`
2 parents 5680fa1 + 9c84757 commit 66e0643

File tree

20 files changed

+413
-55
lines changed

20 files changed

+413
-55
lines changed

RELEASES.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
Version 1.72.1 (2023-09-14)
2+
===========================
3+
4+
- [Adjust codegen change to improve LLVM codegen](https://github.com/rust-lang/rust/pull/115236)
5+
- [rustdoc: Fix self ty params in objects with lifetimes](https://github.com/rust-lang/rust/pull/115276)
6+
- [Fix regression in compile times](https://github.com/rust-lang/rust/pull/114948)
7+
- Resolve some ICE regressions in the compiler:
8+
- [#115215](https://github.com/rust-lang/rust/pull/115215)
9+
- [#115559](https://github.com/rust-lang/rust/pull/115559)
10+
111
Version 1.72.0 (2023-08-24)
212
==========================
313

compiler/rustc_codegen_llvm/src/type_of.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,11 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> {
431431

432432
// Vectors, even for non-power-of-two sizes, have the same layout as
433433
// arrays but don't count as aggregate types
434+
// While LLVM theoretically supports non-power-of-two sizes, and they
435+
// often work fine, sometimes x86-isel deals with them horribly
436+
// (see #115212) so for now only use power-of-two ones.
434437
if let FieldsShape::Array { count, .. } = self.layout.fields()
438+
&& count.is_power_of_two()
435439
&& let element = self.field(cx, 0)
436440
&& element.ty.is_integral()
437441
{

compiler/rustc_codegen_ssa/src/mir/locals.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use rustc_index::IndexVec;
77
use rustc_middle::mir;
88
use rustc_middle::ty::print::with_no_trimmed_paths;
99
use std::ops::{Index, IndexMut};
10-
1110
pub(super) struct Locals<'tcx, V> {
1211
values: IndexVec<mir::Local, LocalRef<'tcx, V>>,
1312
}
@@ -36,17 +35,18 @@ impl<'tcx, V> Locals<'tcx, V> {
3635
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
3736
pub(super) fn initialize_locals(&mut self, values: Vec<LocalRef<'tcx, Bx::Value>>) {
3837
assert!(self.locals.values.is_empty());
39-
38+
// FIXME(#115215): After #115025 get's merged this might not be necessary
4039
for (local, value) in values.into_iter().enumerate() {
4140
match value {
4241
LocalRef::Place(_) | LocalRef::UnsizedPlace(_) | LocalRef::PendingOperand => (),
4342
LocalRef::Operand(op) => {
4443
let local = mir::Local::from_usize(local);
4544
let expected_ty = self.monomorphize(self.mir.local_decls[local].ty);
46-
assert_eq!(expected_ty, op.layout.ty, "unexpected initial operand type");
45+
if expected_ty != op.layout.ty {
46+
warn!("Unexpected initial operand type. See the issues/114858");
47+
}
4748
}
4849
}
49-
5050
self.locals.values.push(value);
5151
}
5252
}

compiler/rustc_mir_transform/src/deduce_param_attrs.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,12 @@ pub fn deduced_param_attrs<'tcx>(
203203
body.local_decls.iter().skip(1).take(body.arg_count).enumerate().map(
204204
|(arg_index, local_decl)| DeducedParamAttrs {
205205
read_only: !deduce_read_only.mutable_args.contains(arg_index)
206-
&& local_decl.ty.is_freeze(tcx, param_env),
206+
// We must normalize here to reveal opaques and normalize
207+
// their substs, otherwise we'll see exponential blow-up in
208+
// compile times: #113372
209+
&& tcx
210+
.normalize_erasing_regions(param_env, local_decl.ty)
211+
.is_freeze(tcx, param_env),
207212
},
208213
),
209214
);

compiler/rustc_trait_selection/src/traits/outlives_bounds.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,12 @@ impl<'a, 'tcx: 'a> InferCtxtExt<'a, 'tcx> for InferCtxt<'tcx> {
5757
let ty = OpportunisticRegionResolver::new(self).fold_ty(ty);
5858

5959
// We do not expect existential variables in implied bounds.
60-
// We may however encounter unconstrained lifetime variables in invalid
61-
// code. See #110161 for context.
60+
// We may however encounter unconstrained lifetime variables
61+
// in very rare cases.
62+
//
63+
// See `ui/implied-bounds/implied-bounds-unconstrained-2.rs` for
64+
// an example.
6265
assert!(!ty.has_non_region_infer());
63-
if ty.has_infer() {
64-
self.tcx.sess.delay_span_bug(
65-
self.tcx.def_span(body_id),
66-
"skipped implied_outlives_bounds due to unconstrained lifetimes",
67-
);
68-
return vec![];
69-
}
7066

7167
let mut canonical_var_values = OriginalQueryValues::default();
7268
let canonical_ty =

src/ci/docker/host-x86_64/arm-android/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:22.10
1+
FROM ubuntu:23.04
22

33
ARG DEBIAN_FRONTEND=noninteractive
44
COPY scripts/android-base-apt-get.sh /scripts/

src/ci/docker/host-x86_64/dist-android/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:22.10
1+
FROM ubuntu:23.04
22

33
COPY scripts/android-base-apt-get.sh /scripts/
44
RUN sh /scripts/android-base-apt-get.sh

src/ci/docker/host-x86_64/x86_64-gnu-llvm-15/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:22.10
1+
FROM ubuntu:23.04
22

33
ARG DEBIAN_FRONTEND=noninteractive
44

src/librustdoc/clean/mod.rs

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,7 @@ fn clean_generic_bound<'tcx>(
167167
let trait_ref = ty::Binder::dummy(ty::TraitRef::identity(cx.tcx, def_id));
168168

169169
let generic_args = clean_generic_args(generic_args, cx);
170-
let GenericArgs::AngleBracketed { bindings, .. } = generic_args
171-
else {
170+
let GenericArgs::AngleBracketed { bindings, .. } = generic_args else {
172171
bug!("clean: parenthesized `GenericBound::LangItemTrait`");
173172
};
174173

@@ -1818,33 +1817,46 @@ fn can_elide_trait_object_lifetime_bound<'tcx>(
18181817
#[derive(Debug)]
18191818
pub(crate) enum ContainerTy<'tcx> {
18201819
Ref(ty::Region<'tcx>),
1821-
Regular { ty: DefId, substs: ty::Binder<'tcx, &'tcx [ty::GenericArg<'tcx>]>, arg: usize },
1820+
Regular {
1821+
ty: DefId,
1822+
args: ty::Binder<'tcx, &'tcx [ty::GenericArg<'tcx>]>,
1823+
has_self: bool,
1824+
arg: usize,
1825+
},
18221826
}
18231827

18241828
impl<'tcx> ContainerTy<'tcx> {
18251829
fn object_lifetime_default(self, tcx: TyCtxt<'tcx>) -> ObjectLifetimeDefault<'tcx> {
18261830
match self {
18271831
Self::Ref(region) => ObjectLifetimeDefault::Arg(region),
1828-
Self::Regular { ty: container, substs, arg: index } => {
1832+
Self::Regular { ty: container, args, has_self, arg: index } => {
18291833
let (DefKind::Struct
18301834
| DefKind::Union
18311835
| DefKind::Enum
1832-
| DefKind::TyAlias
1833-
| DefKind::Trait
1834-
| DefKind::AssocTy
1835-
| DefKind::Variant) = tcx.def_kind(container)
1836+
| DefKind::TyAlias { .. }
1837+
| DefKind::Trait) = tcx.def_kind(container)
18361838
else {
18371839
return ObjectLifetimeDefault::Empty;
18381840
};
18391841

18401842
let generics = tcx.generics_of(container);
1841-
let param = generics.params[index].def_id;
1842-
let default = tcx.object_lifetime_default(param);
1843+
debug_assert_eq!(generics.parent_count, 0);
1844+
1845+
// If the container is a trait object type, the arguments won't contain the self type but the
1846+
// generics of the corresponding trait will. In such a case, offset the index by one.
1847+
// For comparison, if the container is a trait inside a bound, the arguments do contain the
1848+
// self type.
1849+
let offset =
1850+
if !has_self && generics.parent.is_none() && generics.has_self { 1 } else { 0 };
1851+
let param = generics.params[index + offset].def_id;
18431852

1853+
let default = tcx.object_lifetime_default(param);
18441854
match default {
18451855
rbv::ObjectLifetimeDefault::Param(lifetime) => {
1856+
// The index is relative to the parent generics but since we don't have any,
1857+
// we don't need to translate it.
18461858
let index = generics.param_def_id_to_index[&lifetime];
1847-
let arg = substs.skip_binder()[index as usize].expect_region();
1859+
let arg = args.skip_binder()[index as usize].expect_region();
18481860
ObjectLifetimeDefault::Arg(arg)
18491861
}
18501862
rbv::ObjectLifetimeDefault::Empty => ObjectLifetimeDefault::Empty,

src/librustdoc/clean/utils.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ pub(crate) fn krate(cx: &mut DocContext<'_>) -> Crate {
5454
let primitives = local_crate.primitives(cx.tcx);
5555
let keywords = local_crate.keywords(cx.tcx);
5656
{
57-
let ItemKind::ModuleItem(ref mut m) = *module.kind
58-
else { unreachable!() };
57+
let ItemKind::ModuleItem(ref mut m) = *module.kind else { unreachable!() };
5958
m.items.extend(primitives.iter().map(|&(def_id, prim)| {
6059
Item::from_def_id_and_parts(
6160
def_id,
@@ -74,18 +73,15 @@ pub(crate) fn krate(cx: &mut DocContext<'_>) -> Crate {
7473

7574
pub(crate) fn substs_to_args<'tcx>(
7675
cx: &mut DocContext<'tcx>,
77-
substs: ty::Binder<'tcx, &'tcx [ty::subst::GenericArg<'tcx>]>,
78-
mut skip_first: bool,
76+
args: ty::Binder<'tcx, &'tcx [ty::GenericArg<'tcx>]>,
77+
has_self: bool,
7978
container: Option<DefId>,
8079
) -> Vec<GenericArg> {
80+
let mut skip_first = has_self;
8181
let mut ret_val =
82-
Vec::with_capacity(substs.skip_binder().len().saturating_sub(if skip_first {
83-
1
84-
} else {
85-
0
86-
}));
82+
Vec::with_capacity(args.skip_binder().len().saturating_sub(if skip_first { 1 } else { 0 }));
8783

88-
ret_val.extend(substs.iter().enumerate().filter_map(|(index, kind)| {
84+
ret_val.extend(args.iter().enumerate().filter_map(|(index, kind)| {
8985
match kind.skip_binder().unpack() {
9086
GenericArgKind::Lifetime(lt) => {
9187
Some(GenericArg::Lifetime(clean_middle_region(lt).unwrap_or(Lifetime::elided())))
@@ -100,7 +96,8 @@ pub(crate) fn substs_to_args<'tcx>(
10096
None,
10197
container.map(|container| crate::clean::ContainerTy::Regular {
10298
ty: container,
103-
substs,
99+
args,
100+
has_self,
104101
arg: index,
105102
}),
106103
))),

0 commit comments

Comments
 (0)