Skip to content

Commit 63a81b0

Browse files
committed
Auto merge of #114585 - matthiaskrgr:rollup-h26pvus, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - #113568 (Fix spurious test failure with `panic=abort`) - #114196 (Bubble up nested goals from equation in `predicates_for_object_candidate`) - #114485 (Add trait decls to SMIR) - #114495 (Set max_atomic_width for AVR to 16) - #114496 (Set max_atomic_width for sparc-unknown-linux-gnu to 32) - #114510 (llvm-wrapper: adapt for LLVM API changes) - #114562 (stabilize abi_thiscall) - #114570 ([miri][typo] Fix a typo in a vector_block comment.) - #114573 (CI: do not hide error logs in a group) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 84ec263 + d9f3d49 commit 63a81b0

File tree

28 files changed

+208
-279
lines changed

28 files changed

+208
-279
lines changed

compiler/rustc_feature/src/accepted.rs

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ declare_features! (
5353
/// Allows the sysV64 ABI to be specified on all platforms
5454
/// instead of just the platforms on which it is the C ABI.
5555
(accepted, abi_sysv64, "1.24.0", Some(36167), None),
56+
/// Allows using the `thiscall` ABI.
57+
(accepted, abi_thiscall, "1.19.0", None, None),
5658
/// Allows using ADX intrinsics from `core::arch::{x86, x86_64}`.
5759
(accepted, adx_target_feature, "1.61.0", Some(44839), None),
5860
/// Allows explicit discriminants on non-unit enum variants.

compiler/rustc_feature/src/active.rs

-2
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,6 @@ declare_features! (
156156
// -------------------------------------------------------------------------
157157
// no-tracking-issue-start
158158

159-
/// Allows using the `thiscall` ABI.
160-
(active, abi_thiscall, "1.19.0", None, None),
161159
/// Allows using the `unadjusted` ABI; perma-unstable.
162160
(active, abi_unadjusted, "1.16.0", None, None),
163161
/// Allows using the `vectorcall` ABI.

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -1120,9 +1120,15 @@ struct LLVMRustThinLTOData {
11201120

11211121
// Not 100% sure what these are, but they impact what's internalized and
11221122
// what's inlined across modules, I believe.
1123+
#if LLVM_VERSION_GE(17, 0)
1124+
DenseMap<StringRef, FunctionImporter::ImportMapTy> ImportLists;
1125+
DenseMap<StringRef, FunctionImporter::ExportSetTy> ExportLists;
1126+
DenseMap<StringRef, GVSummaryMapTy> ModuleToDefinedGVSummaries;
1127+
#else
11231128
StringMap<FunctionImporter::ImportMapTy> ImportLists;
11241129
StringMap<FunctionImporter::ExportSetTy> ExportLists;
11251130
StringMap<GVSummaryMapTy> ModuleToDefinedGVSummaries;
1131+
#endif
11261132
StringMap<std::map<GlobalValue::GUID, GlobalValue::LinkageTypes>> ResolvedODR;
11271133

11281134
LLVMRustThinLTOData() : Index(/* HaveGVs = */ false) {}

compiler/rustc_smir/src/rustc_internal/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ impl<'tcx> Tables<'tcx> {
6868
self.def_ids[item.0]
6969
}
7070

71+
pub fn trait_def_id(&self, trait_def: &stable_mir::ty::TraitDef) -> DefId {
72+
self.def_ids[trait_def.0]
73+
}
74+
7175
pub fn crate_item(&mut self, did: DefId) -> stable_mir::CrateItem {
7276
stable_mir::CrateItem(self.create_def_id(did))
7377
}

compiler/rustc_smir/src/rustc_smir/mod.rs

+59-8
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,21 @@ impl<'tcx> Context for Tables<'tcx> {
4141
fn entry_fn(&mut self) -> Option<stable_mir::CrateItem> {
4242
Some(self.crate_item(self.tcx.entry_fn(())?.0))
4343
}
44+
45+
fn all_trait_decls(&mut self) -> stable_mir::TraitDecls {
46+
self.tcx
47+
.traits(LOCAL_CRATE)
48+
.iter()
49+
.map(|trait_def_id| self.trait_def(*trait_def_id))
50+
.collect()
51+
}
52+
53+
fn trait_decl(&mut self, trait_def: &stable_mir::ty::TraitDef) -> stable_mir::ty::TraitDecl {
54+
let def_id = self.trait_def_id(trait_def);
55+
let trait_def = self.tcx.trait_def(def_id);
56+
trait_def.stable(self)
57+
}
58+
4459
fn mir_body(&mut self, item: &stable_mir::CrateItem) -> stable_mir::mir::Body {
4560
let def_id = self.item_def_id(item);
4661
let mir = self.tcx.optimized_mir(def_id);
@@ -515,7 +530,7 @@ impl<'tcx> Stable<'tcx> for mir::RetagKind {
515530
}
516531
}
517532

518-
impl<'tcx> Stable<'tcx> for rustc_middle::ty::UserTypeAnnotationIndex {
533+
impl<'tcx> Stable<'tcx> for ty::UserTypeAnnotationIndex {
519534
type T = usize;
520535
fn stable(&self, _: &mut Tables<'tcx>) -> Self::T {
521536
self.as_usize()
@@ -826,7 +841,7 @@ impl<'tcx> Stable<'tcx> for ty::FnSig<'tcx> {
826841
type T = stable_mir::ty::FnSig;
827842
fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
828843
use rustc_target::spec::abi;
829-
use stable_mir::ty::{Abi, FnSig, Unsafety};
844+
use stable_mir::ty::{Abi, FnSig};
830845

831846
FnSig {
832847
inputs_and_output: self
@@ -835,10 +850,7 @@ impl<'tcx> Stable<'tcx> for ty::FnSig<'tcx> {
835850
.map(|ty| tables.intern_ty(ty))
836851
.collect(),
837852
c_variadic: self.c_variadic,
838-
unsafety: match self.unsafety {
839-
hir::Unsafety::Normal => Unsafety::Normal,
840-
hir::Unsafety::Unsafe => Unsafety::Unsafe,
841-
},
853+
unsafety: self.unsafety.stable(tables),
842854
abi: match self.abi {
843855
abi::Abi::Rust => Abi::Rust,
844856
abi::Abi::C { unwind } => Abi::C { unwind },
@@ -1048,15 +1060,15 @@ impl<'tcx> Stable<'tcx> for Ty<'tcx> {
10481060
}
10491061
}
10501062

1051-
impl<'tcx> Stable<'tcx> for rustc_middle::ty::ParamTy {
1063+
impl<'tcx> Stable<'tcx> for ty::ParamTy {
10521064
type T = stable_mir::ty::ParamTy;
10531065
fn stable(&self, _: &mut Tables<'tcx>) -> Self::T {
10541066
use stable_mir::ty::ParamTy;
10551067
ParamTy { index: self.index, name: self.name.to_string() }
10561068
}
10571069
}
10581070

1059-
impl<'tcx> Stable<'tcx> for rustc_middle::ty::BoundTy {
1071+
impl<'tcx> Stable<'tcx> for ty::BoundTy {
10601072
type T = stable_mir::ty::BoundTy;
10611073
fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
10621074
use stable_mir::ty::BoundTy;
@@ -1094,3 +1106,42 @@ impl<'tcx> Stable<'tcx> for mir::interpret::Allocation {
10941106
}
10951107
}
10961108
}
1109+
1110+
impl<'tcx> Stable<'tcx> for ty::trait_def::TraitSpecializationKind {
1111+
type T = stable_mir::ty::TraitSpecializationKind;
1112+
fn stable(&self, _: &mut Tables<'tcx>) -> Self::T {
1113+
use stable_mir::ty::TraitSpecializationKind;
1114+
1115+
match self {
1116+
ty::trait_def::TraitSpecializationKind::None => TraitSpecializationKind::None,
1117+
ty::trait_def::TraitSpecializationKind::Marker => TraitSpecializationKind::Marker,
1118+
ty::trait_def::TraitSpecializationKind::AlwaysApplicable => {
1119+
TraitSpecializationKind::AlwaysApplicable
1120+
}
1121+
}
1122+
}
1123+
}
1124+
1125+
impl<'tcx> Stable<'tcx> for ty::TraitDef {
1126+
type T = stable_mir::ty::TraitDecl;
1127+
fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
1128+
use stable_mir::ty::TraitDecl;
1129+
1130+
TraitDecl {
1131+
def_id: rustc_internal::trait_def(self.def_id),
1132+
unsafety: self.unsafety.stable(tables),
1133+
paren_sugar: self.paren_sugar,
1134+
has_auto_impl: self.has_auto_impl,
1135+
is_marker: self.is_marker,
1136+
is_coinductive: self.is_coinductive,
1137+
skip_array_during_method_dispatch: self.skip_array_during_method_dispatch,
1138+
specialization_kind: self.specialization_kind.stable(tables),
1139+
must_implement_one_of: self
1140+
.must_implement_one_of
1141+
.as_ref()
1142+
.map(|idents| idents.iter().map(|ident| opaque(ident)).collect()),
1143+
implement_via_object: self.implement_via_object,
1144+
deny_explicit_impl: self.deny_explicit_impl,
1145+
}
1146+
}
1147+
}

compiler/rustc_smir/src/stable_mir/mod.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::cell::Cell;
1515

1616
use crate::rustc_smir::Tables;
1717

18-
use self::ty::{Ty, TyKind};
18+
use self::ty::{TraitDecl, TraitDef, Ty, TyKind};
1919

2020
pub mod mir;
2121
pub mod ty;
@@ -32,6 +32,9 @@ pub type DefId = usize;
3232
/// A list of crate items.
3333
pub type CrateItems = Vec<CrateItem>;
3434

35+
/// A list of crate items.
36+
pub type TraitDecls = Vec<TraitDef>;
37+
3538
/// Holds information about a crate.
3639
#[derive(Clone, PartialEq, Eq, Debug)]
3740
pub struct Crate {
@@ -84,6 +87,8 @@ pub trait Context {
8487
/// Retrieve all items of the local crate that have a MIR associated with them.
8588
fn all_local_items(&mut self) -> CrateItems;
8689
fn mir_body(&mut self, item: &CrateItem) -> mir::Body;
90+
fn all_trait_decls(&mut self) -> TraitDecls;
91+
fn trait_decl(&mut self, trait_def: &TraitDef) -> TraitDecl;
8792
/// Get information about the local crate.
8893
fn local_crate(&self) -> Crate;
8994
/// Retrieve a list of all external crates.

compiler/rustc_smir/src/stable_mir/ty.rs

+29-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{mir::Mutability, with, DefId};
1+
use super::{mir::Mutability, mir::Safety, with, DefId};
22
use crate::rustc_internal::Opaque;
33

44
#[derive(Copy, Clone, Debug)]
@@ -11,6 +11,7 @@ impl Ty {
1111
}
1212

1313
pub(crate) type Const = Opaque;
14+
type Ident = Opaque;
1415
pub(crate) type Region = Opaque;
1516
type Span = Opaque;
1617

@@ -104,6 +105,12 @@ pub struct AliasDef(pub(crate) DefId);
104105
#[derive(Clone, PartialEq, Eq, Debug)]
105106
pub struct TraitDef(pub(crate) DefId);
106107

108+
impl TraitDef {
109+
pub fn trait_decl(&self) -> TraitDecl {
110+
with(|cx| cx.trait_decl(self))
111+
}
112+
}
113+
107114
#[derive(Clone, Debug)]
108115
pub struct GenericArgs(pub Vec<GenericArgKind>);
109116

@@ -140,16 +147,10 @@ pub type PolyFnSig = Binder<FnSig>;
140147
pub struct FnSig {
141148
pub inputs_and_output: Vec<Ty>,
142149
pub c_variadic: bool,
143-
pub unsafety: Unsafety,
150+
pub unsafety: Safety,
144151
pub abi: Abi,
145152
}
146153

147-
#[derive(Clone, PartialEq, Eq, Debug)]
148-
pub enum Unsafety {
149-
Unsafe,
150-
Normal,
151-
}
152-
153154
#[derive(Clone, PartialEq, Eq, Debug)]
154155
pub enum Abi {
155156
Rust,
@@ -264,3 +265,23 @@ pub struct Allocation {
264265
pub align: Align,
265266
pub mutability: Mutability,
266267
}
268+
269+
pub enum TraitSpecializationKind {
270+
None,
271+
Marker,
272+
AlwaysApplicable,
273+
}
274+
275+
pub struct TraitDecl {
276+
pub def_id: TraitDef,
277+
pub unsafety: Safety,
278+
pub paren_sugar: bool,
279+
pub has_auto_impl: bool,
280+
pub is_marker: bool,
281+
pub is_coinductive: bool,
282+
pub skip_array_during_method_dispatch: bool,
283+
pub specialization_kind: TraitSpecializationKind,
284+
pub must_implement_one_of: Option<Vec<Ident>>,
285+
pub implement_via_object: bool,
286+
pub deny_explicit_impl: bool,
287+
}

compiler/rustc_target/src/spec/abi.rs

+2-9
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ pub fn is_stable(name: &str) -> Result<(), AbiDisabled> {
150150
// Stable
151151
"Rust" | "C" | "C-unwind" | "cdecl" | "cdecl-unwind" | "stdcall" | "stdcall-unwind"
152152
| "fastcall" | "fastcall-unwind" | "aapcs" | "aapcs-unwind" | "win64" | "win64-unwind"
153-
| "sysv64" | "sysv64-unwind" | "system" | "system-unwind" | "efiapi" => Ok(()),
153+
| "sysv64" | "sysv64-unwind" | "system" | "system-unwind" | "efiapi" | "thiscall"
154+
| "thiscall-unwind" => Ok(()),
154155
"rust-intrinsic" => Err(AbiDisabled::Unstable {
155156
feature: sym::intrinsics,
156157
explain: "intrinsics are subject to change",
@@ -167,14 +168,6 @@ pub fn is_stable(name: &str) -> Result<(), AbiDisabled> {
167168
feature: sym::abi_vectorcall,
168169
explain: "vectorcall-unwind ABI is experimental and subject to change",
169170
}),
170-
"thiscall" => Err(AbiDisabled::Unstable {
171-
feature: sym::abi_thiscall,
172-
explain: "thiscall is experimental and subject to change",
173-
}),
174-
"thiscall-unwind" => Err(AbiDisabled::Unstable {
175-
feature: sym::abi_thiscall,
176-
explain: "thiscall-unwind ABI is experimental and subject to change",
177-
}),
178171
"rust-call" => Err(AbiDisabled::Unstable {
179172
feature: sym::unboxed_closures,
180173
explain: "rust-call ABI is subject to change",

compiler/rustc_target/src/spec/avr_gnu_base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub fn target(target_cpu: &'static str, mmcu: &'static str) -> Target {
2323
LinkerFlavor::Gnu(Cc::Yes, Lld::No),
2424
&["-lgcc"],
2525
),
26-
max_atomic_width: Some(0),
26+
max_atomic_width: Some(16),
2727
atomic_cas: false,
2828
relocation_model: RelocModel::Static,
2929
..TargetOptions::default()

compiler/rustc_target/src/spec/sparc_unknown_linux_gnu.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub fn target() -> Target {
55
let mut base = super::linux_gnu_base::opts();
66
base.endian = Endian::Big;
77
base.cpu = "v9".into();
8-
base.max_atomic_width = Some(64);
8+
base.max_atomic_width = Some(32);
99
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-mv8plus"]);
1010

1111
Target {

compiler/rustc_trait_selection/src/solve/assembly/mod.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -152,16 +152,12 @@ pub(super) trait GoalKind<'tcx>:
152152
let ty::Dynamic(bounds, _, _) = *goal.predicate.self_ty().kind() else {
153153
bug!("expected object type in `consider_object_bound_candidate`");
154154
};
155-
ecx.add_goals(
156-
structural_traits::predicates_for_object_candidate(
157-
&ecx,
158-
goal.param_env,
159-
goal.predicate.trait_ref(tcx),
160-
bounds,
161-
)
162-
.into_iter()
163-
.map(|pred| goal.with(tcx, pred)),
164-
);
155+
ecx.add_goals(structural_traits::predicates_for_object_candidate(
156+
&ecx,
157+
goal.param_env,
158+
goal.predicate.trait_ref(tcx),
159+
bounds,
160+
));
165161
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
166162
})
167163
}

compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs

+18-13
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use rustc_data_structures::fx::FxHashMap;
44
use rustc_hir::{def_id::DefId, Movability, Mutability};
55
use rustc_infer::traits::query::NoSolution;
6+
use rustc_middle::traits::solve::Goal;
67
use rustc_middle::ty::{
78
self, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitableExt,
89
};
@@ -345,7 +346,7 @@ pub(in crate::solve) fn predicates_for_object_candidate<'tcx>(
345346
param_env: ty::ParamEnv<'tcx>,
346347
trait_ref: ty::TraitRef<'tcx>,
347348
object_bound: &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
348-
) -> Vec<ty::Clause<'tcx>> {
349+
) -> Vec<Goal<'tcx, ty::Predicate<'tcx>>> {
349350
let tcx = ecx.tcx();
350351
let mut requirements = vec![];
351352
requirements.extend(
@@ -376,17 +377,22 @@ pub(in crate::solve) fn predicates_for_object_candidate<'tcx>(
376377
}
377378
}
378379

379-
requirements.fold_with(&mut ReplaceProjectionWith {
380-
ecx,
381-
param_env,
382-
mapping: replace_projection_with,
383-
})
380+
let mut folder =
381+
ReplaceProjectionWith { ecx, param_env, mapping: replace_projection_with, nested: vec![] };
382+
let folded_requirements = requirements.fold_with(&mut folder);
383+
384+
folder
385+
.nested
386+
.into_iter()
387+
.chain(folded_requirements.into_iter().map(|clause| Goal::new(tcx, param_env, clause)))
388+
.collect()
384389
}
385390

386391
struct ReplaceProjectionWith<'a, 'tcx> {
387392
ecx: &'a EvalCtxt<'a, 'tcx>,
388393
param_env: ty::ParamEnv<'tcx>,
389394
mapping: FxHashMap<DefId, ty::PolyProjectionPredicate<'tcx>>,
395+
nested: Vec<Goal<'tcx, ty::Predicate<'tcx>>>,
390396
}
391397

392398
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReplaceProjectionWith<'_, 'tcx> {
@@ -402,13 +408,12 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReplaceProjectionWith<'_, 'tcx> {
402408
// but the where clauses we instantiated are not. We can solve this by instantiating
403409
// the binder at the usage site.
404410
let proj = self.ecx.instantiate_binder_with_infer(*replacement);
405-
// FIXME: Technically this folder could be fallible?
406-
let nested = self
407-
.ecx
408-
.eq_and_get_goals(self.param_env, alias_ty, proj.projection_ty)
409-
.expect("expected to be able to unify goal projection with dyn's projection");
410-
// FIXME: Technically we could register these too..
411-
assert!(nested.is_empty(), "did not expect unification to have any nested goals");
411+
// FIXME: Technically this equate could be fallible...
412+
self.nested.extend(
413+
self.ecx
414+
.eq_and_get_goals(self.param_env, alias_ty, proj.projection_ty)
415+
.expect("expected to be able to unify goal projection with dyn's projection"),
416+
);
412417
proj.term.ty().unwrap()
413418
} else {
414419
ty.super_fold_with(self)

library/panic_unwind/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#![feature(panic_unwind)]
2020
#![feature(staged_api)]
2121
#![feature(std_internals)]
22-
#![feature(abi_thiscall)]
22+
#![cfg_attr(bootstrap, feature(abi_thiscall))]
2323
#![feature(rustc_attrs)]
2424
#![panic_runtime]
2525
#![feature(panic_runtime)]

0 commit comments

Comments
 (0)