Skip to content

Commit da813f7

Browse files
committed
Auto merge of rust-lang#137944 - davidtwco:sized-hierarchy, r=<try>
Sized Hierarchy This patch implements rust-lang/rfcs#3729. It introduces two new traits to the standard library, `MetaSized` and `PointeeSized`, and makes `MetaSized` and `Sized` into const traits (relying on unstable `feature(const_trait_impl)`). See the RFC for the rationale behind these traits and to discuss whether this change makes sense in the abstract. These traits are unstable (as is their constness), so users cannot refer to them without opting-in to `feature(sized_hierarchy)`. These traits are not behind `cfg`s as this would make implementation unfeasible, there would simply be too many `cfg`s required to add the necessary bounds everywhere. So, like `Sized`, these traits are automatically implemented by the compiler. RFC 3729 describes migrations which are necessary to preserve backwards compatibility given the introduction of these traits, which are implemented and as follows: - On the current edition, `Sized` is rewritten as `const Sized` - If the `sized_hierarchy` feature is enabled, then an edition migration lint to rewrite the bound to `const Sized` will be emitted. - On the next edition, non-const `Sized` will resume being the default bound. - On the current edition, `?Sized` is rewritten as `const MetaSized` - If the `sized_hierarchy` feature is enabled, then an edition migration lint to rewrite the bound to `const MetaSized` will be emitted. - On the next edition, writing `?Sized` will be prohibited. - On the current edition, `const MetaSized` is added as a default supertrait for all traits w/out an explicit sizedness supertrait already. - If the `sized_hierarchy` feature is enabled, then an edition migration lint to add an explicit `const MetaSized` supertrait will be emitted. - On the next edition, there is no default `const MetaSized` supertrait. Each of these migrations is not conditional on whether the item being migrated *needs* the migration to the stricter bound - this would be preferable but is not yet implemented (if it is possible to implement). All diagnostic output should remain the same (showing `?Sized` even if the compiler sees `const MetaSized`) unless the `sized_hierarchy` feature is enabled. Due to the use of unstable extern types in the standard library and rustc, some bounds in both projects have had to be relaxed already - this is unfortunate but unavoidable so that these extern types can continue to be used where they were before. Performing these relaxations in the standard library and rustc are desirable longer-term anyway, but some bounds are not as relaxed as they ideally would be due to the inability to relax `Deref::Target` (this will be investigated separately). It is hoped that this is implemented such that it could be merged and these traits could exist "under the hood" without that being observable to the user (other than in any performance impact this has on the compiler, etc). Only once `sized_hierarchy` is stabilised would edition migration lints start to be emitted and diagnostic output show the "real" sizedness traits behind-the-scenes, rather than `?Sized`. Some details might leak through due to the standard library relaxations, but this has not been observed in test output. **Notes:** - Any commits starting with "upstream:" can be ignored, as these correspond to other upstream PRs that this is based on which have yet to be merged. - This best reviewed commit-by-commit. I've attempted to make the implementation easy to follow and keep similar changes and test output updates together. - Each commit has a short description describing its purpose. - This patch is large but it's primarily in the test suite (library: +573/-184, compiler: +1268/-310, tests: +3720/-452). - It is expected that this will have performance regressions initially and I'll aim to resolve those prior to merging if possible. - I'd appreciate feedback on how best to go about this from those familiar with the type system. - On my local machine, this passes all of the test suites, a stage two build and a tidy check. - `PointeeSized` is a different name from the RFC just to make it more obvious that it is different from `std::ptr::Pointee` but all the names are yet to be bikeshed anyway. - `@nikomatsakis` has confirmed [that this can proceed as an experiment from the t-lang side](https://rust-lang.zulipchat.com/#narrow/channel/435869-project-goals/topic/SVE.20and.20SME.20on.20AArch64.20.28goals.23270.29/near/506196491) Fixes rust-lang#79409. r? `@ghost` (I'll discuss this with relevant teams to find a reviewer)
2 parents 69b3959 + 004ce92 commit da813f7

File tree

398 files changed

+6314
-1617
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

398 files changed

+6314
-1617
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
254254
let place = &self.move_data.move_paths[mpi].place;
255255
let ty = place.ty(self.body, self.infcx.tcx).ty;
256256

257-
if self.infcx.param_env.caller_bounds().iter().any(|c| {
258-
c.as_trait_clause().is_some_and(|pred| {
259-
pred.skip_binder().self_ty() == ty && self.infcx.tcx.is_fn_trait(pred.def_id())
260-
})
257+
if self.infcx.param_env.trait_clauses().any(|pred| {
258+
pred.skip_binder().self_ty() == ty && self.infcx.tcx.is_fn_trait(pred.def_id())
261259
}) {
262260
// Suppress the next suggestion since we don't want to put more bounds onto
263261
// something that already has `Fn`-like bounds (or is a closure), so we can't

compiler/rustc_borrowck/src/type_check/free_region_relations.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -226,15 +226,13 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
226226
// Normalize the assumptions we use to borrowck the program.
227227
let mut constraints = vec![];
228228
let mut known_type_outlives_obligations = vec![];
229-
for bound in param_env.caller_bounds() {
230-
if let Some(outlives) = bound.as_type_outlives_clause() {
231-
self.normalize_and_push_type_outlives_obligation(
232-
outlives,
233-
span,
234-
&mut known_type_outlives_obligations,
235-
&mut constraints,
236-
);
237-
};
229+
for outlives in param_env.type_outlives_clauses() {
230+
self.normalize_and_push_type_outlives_obligation(
231+
outlives,
232+
span,
233+
&mut known_type_outlives_obligations,
234+
&mut constraints,
235+
);
238236
}
239237

240238
let unnormalized_input_output_tys = self

compiler/rustc_codegen_cranelift/example/mini_core.rs

+40-31
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,22 @@
99
transparent_unions,
1010
auto_traits,
1111
freeze_impls,
12-
thread_local
12+
thread_local,
13+
const_trait_impl
1314
)]
1415
#![no_core]
1516
#![allow(dead_code, internal_features, ambiguous_wide_pointer_comparisons)]
1617

18+
#[lang = "pointee_sized"]
19+
pub trait PointeeSized {}
20+
21+
#[lang = "meta_sized"]
22+
#[const_trait]
23+
pub trait MetaSized: PointeeSized {}
24+
1725
#[lang = "sized"]
18-
pub trait Sized {}
26+
#[const_trait]
27+
pub trait Sized: MetaSized {}
1928

2029
#[lang = "destruct"]
2130
pub trait Destruct {}
@@ -24,35 +33,35 @@ pub trait Destruct {}
2433
pub trait Tuple {}
2534

2635
#[lang = "unsize"]
27-
pub trait Unsize<T: ?Sized> {}
36+
pub trait Unsize<T: PointeeSized>: PointeeSized {}
2837

2938
#[lang = "coerce_unsized"]
3039
pub trait CoerceUnsized<T> {}
3140

32-
impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b T {}
33-
impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a mut U> for &'a mut T {}
34-
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*const U> for *const T {}
35-
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*mut U> for *mut T {}
41+
impl<'a, 'b: 'a, T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<&'a U> for &'b T {}
42+
impl<'a, T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<&'a mut U> for &'a mut T {}
43+
impl<T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<*const U> for *const T {}
44+
impl<T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<*mut U> for *mut T {}
3645

3746
#[lang = "dispatch_from_dyn"]
3847
pub trait DispatchFromDyn<T> {}
3948

4049
// &T -> &U
41-
impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<&'a U> for &'a T {}
50+
impl<'a, T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<&'a U> for &'a T {}
4251
// &mut T -> &mut U
43-
impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<&'a mut U> for &'a mut T {}
52+
impl<'a, T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<&'a mut U> for &'a mut T {}
4453
// *const T -> *const U
45-
impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<*const U> for *const T {}
54+
impl<T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<*const U> for *const T {}
4655
// *mut T -> *mut U
47-
impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<*mut U> for *mut T {}
48-
impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<Box<U>> for Box<T> {}
56+
impl<T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<*mut U> for *mut T {}
57+
impl<T: MetaSized + Unsize<U>, U: MetaSized> DispatchFromDyn<Box<U>> for Box<T> {}
4958

5059
#[lang = "legacy_receiver"]
5160
pub trait LegacyReceiver {}
5261

53-
impl<T: ?Sized> LegacyReceiver for &T {}
54-
impl<T: ?Sized> LegacyReceiver for &mut T {}
55-
impl<T: ?Sized> LegacyReceiver for Box<T> {}
62+
impl<T: PointeeSized> LegacyReceiver for &T {}
63+
impl<T: PointeeSized> LegacyReceiver for &mut T {}
64+
impl<T: MetaSized> LegacyReceiver for Box<T> {}
5665

5766
#[lang = "copy"]
5867
pub trait Copy {}
@@ -74,9 +83,9 @@ impl Copy for isize {}
7483
impl Copy for f32 {}
7584
impl Copy for f64 {}
7685
impl Copy for char {}
77-
impl<'a, T: ?Sized> Copy for &'a T {}
78-
impl<T: ?Sized> Copy for *const T {}
79-
impl<T: ?Sized> Copy for *mut T {}
86+
impl<'a, T: PointeeSized> Copy for &'a T {}
87+
impl<T: PointeeSized> Copy for *const T {}
88+
impl<T: PointeeSized> Copy for *mut T {}
8089
impl<T: Copy> Copy for Option<T> {}
8190

8291
#[lang = "sync"]
@@ -94,17 +103,17 @@ unsafe impl Sync for i32 {}
94103
unsafe impl Sync for isize {}
95104
unsafe impl Sync for char {}
96105
unsafe impl Sync for f32 {}
97-
unsafe impl<'a, T: ?Sized> Sync for &'a T {}
106+
unsafe impl<'a, T: PointeeSized> Sync for &'a T {}
98107
unsafe impl<T: Sync, const N: usize> Sync for [T; N] {}
99108

100109
#[lang = "freeze"]
101110
unsafe auto trait Freeze {}
102111

103-
unsafe impl<T: ?Sized> Freeze for PhantomData<T> {}
104-
unsafe impl<T: ?Sized> Freeze for *const T {}
105-
unsafe impl<T: ?Sized> Freeze for *mut T {}
106-
unsafe impl<T: ?Sized> Freeze for &T {}
107-
unsafe impl<T: ?Sized> Freeze for &mut T {}
112+
unsafe impl<T: PointeeSized> Freeze for PhantomData<T> {}
113+
unsafe impl<T: PointeeSized> Freeze for *const T {}
114+
unsafe impl<T: PointeeSized> Freeze for *mut T {}
115+
unsafe impl<T: PointeeSized> Freeze for &T {}
116+
unsafe impl<T: PointeeSized> Freeze for &mut T {}
108117

109118
#[lang = "structural_peq"]
110119
pub trait StructuralPartialEq {}
@@ -443,7 +452,7 @@ pub enum Option<T> {
443452
pub use Option::*;
444453

445454
#[lang = "phantom_data"]
446-
pub struct PhantomData<T: ?Sized>;
455+
pub struct PhantomData<T: PointeeSized>;
447456

448457
#[lang = "fn_once"]
449458
#[rustc_paren_sugar]
@@ -546,18 +555,18 @@ pub trait Deref {
546555
#[repr(transparent)]
547556
#[rustc_layout_scalar_valid_range_start(1)]
548557
#[rustc_nonnull_optimization_guaranteed]
549-
pub struct NonNull<T: ?Sized>(pub *const T);
558+
pub struct NonNull<T: PointeeSized>(pub *const T);
550559

551-
impl<T: ?Sized, U: ?Sized> CoerceUnsized<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
552-
impl<T: ?Sized, U: ?Sized> DispatchFromDyn<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
560+
impl<T: PointeeSized, U: PointeeSized> CoerceUnsized<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
561+
impl<T: PointeeSized, U: PointeeSized> DispatchFromDyn<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
553562

554-
pub struct Unique<T: ?Sized> {
563+
pub struct Unique<T: PointeeSized> {
555564
pub pointer: NonNull<T>,
556565
pub _marker: PhantomData<T>,
557566
}
558567

559-
impl<T: ?Sized, U: ?Sized> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U> {}
560-
impl<T: ?Sized, U: ?Sized> DispatchFromDyn<Unique<U>> for Unique<T> where T: Unsize<U> {}
568+
impl<T: PointeeSized, U: PointeeSized> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U> {}
569+
impl<T: PointeeSized, U: PointeeSized> DispatchFromDyn<Unique<U>> for Unique<T> where T: Unsize<U> {}
561570

562571
#[lang = "global_alloc_ty"]
563572
pub struct Global;

compiler/rustc_codegen_cranelift/src/abi/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
394394
let instance = if let ty::FnDef(def_id, fn_args) = *func.layout().ty.kind() {
395395
let instance = ty::Instance::expect_resolve(
396396
fx.tcx,
397-
ty::TypingEnv::fully_monomorphized(),
397+
ty::TypingEnv::fully_monomorphized(fx.tcx),
398398
def_id,
399399
fn_args,
400400
source_info.span,

compiler/rustc_codegen_cranelift/src/base.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ fn codegen_stmt<'tcx>(
679679
let func_ref = fx.get_function_ref(
680680
Instance::resolve_for_fn_ptr(
681681
fx.tcx,
682-
ty::TypingEnv::fully_monomorphized(),
682+
ty::TypingEnv::fully_monomorphized(fx.tcx),
683683
def_id,
684684
args,
685685
)
@@ -730,8 +730,10 @@ fn codegen_stmt<'tcx>(
730730

731731
fn is_wide_ptr<'tcx>(fx: &FunctionCx<'_, '_, 'tcx>, ty: Ty<'tcx>) -> bool {
732732
ty.builtin_deref(true).is_some_and(|pointee_ty| {
733-
fx.tcx
734-
.type_has_metadata(pointee_ty, ty::TypingEnv::fully_monomorphized())
733+
fx.tcx.type_has_metadata(
734+
pointee_ty,
735+
ty::TypingEnv::fully_monomorphized(fx.tcx),
736+
)
735737
})
736738
}
737739

@@ -862,7 +864,7 @@ fn codegen_stmt<'tcx>(
862864
NullOp::OffsetOf(fields) => fx
863865
.tcx
864866
.offset_of_subfield(
865-
ty::TypingEnv::fully_monomorphized(),
867+
ty::TypingEnv::fully_monomorphized(fx.tcx),
866868
layout,
867869
fields.iter(),
868870
)

compiler/rustc_codegen_cranelift/src/common.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ fn clif_type_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option<types::Typ
7171
},
7272
ty::FnPtr(..) => pointer_ty(tcx),
7373
ty::RawPtr(pointee_ty, _) | ty::Ref(_, pointee_ty, _) => {
74-
if tcx.type_has_metadata(*pointee_ty, ty::TypingEnv::fully_monomorphized()) {
74+
if tcx.type_has_metadata(*pointee_ty, ty::TypingEnv::fully_monomorphized(tcx)) {
7575
return None;
7676
} else {
7777
pointer_ty(tcx)
@@ -91,7 +91,7 @@ fn clif_pair_type_from_ty<'tcx>(
9191
(clif_type_from_ty(tcx, types[0])?, clif_type_from_ty(tcx, types[1])?)
9292
}
9393
ty::RawPtr(pointee_ty, _) | ty::Ref(_, pointee_ty, _) => {
94-
if tcx.type_has_metadata(*pointee_ty, ty::TypingEnv::fully_monomorphized()) {
94+
if tcx.type_has_metadata(*pointee_ty, ty::TypingEnv::fully_monomorphized(tcx)) {
9595
(pointer_ty(tcx), pointer_ty(tcx))
9696
} else {
9797
return None;
@@ -327,7 +327,7 @@ impl<'tcx> rustc_abi::HasDataLayout for FunctionCx<'_, '_, 'tcx> {
327327

328328
impl<'tcx> layout::HasTypingEnv<'tcx> for FunctionCx<'_, '_, 'tcx> {
329329
fn typing_env(&self) -> ty::TypingEnv<'tcx> {
330-
ty::TypingEnv::fully_monomorphized()
330+
ty::TypingEnv::fully_monomorphized(self.tcx)
331331
}
332332
}
333333

@@ -344,7 +344,7 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> {
344344
{
345345
self.instance.instantiate_mir_and_normalize_erasing_regions(
346346
self.tcx,
347-
ty::TypingEnv::fully_monomorphized(),
347+
ty::TypingEnv::fully_monomorphized(self.tcx),
348348
ty::EarlyBinder::bind(value),
349349
)
350350
}
@@ -490,7 +490,7 @@ impl<'tcx> rustc_abi::HasDataLayout for FullyMonomorphizedLayoutCx<'tcx> {
490490

491491
impl<'tcx> layout::HasTypingEnv<'tcx> for FullyMonomorphizedLayoutCx<'tcx> {
492492
fn typing_env(&self) -> ty::TypingEnv<'tcx> {
493-
ty::TypingEnv::fully_monomorphized()
493+
ty::TypingEnv::fully_monomorphized(self.0)
494494
}
495495
}
496496

compiler/rustc_codegen_cranelift/src/constant.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub(crate) fn eval_mir_constant<'tcx>(
7878
let cv = fx.monomorphize(constant.const_);
7979
// This cannot fail because we checked all required_consts in advance.
8080
let val = cv
81-
.eval(fx.tcx, ty::TypingEnv::fully_monomorphized(), constant.span)
81+
.eval(fx.tcx, ty::TypingEnv::fully_monomorphized(fx.tcx), constant.span)
8282
.expect("erroneous constant missed by mono item collection");
8383
(val, cv.ty())
8484
}
@@ -267,9 +267,9 @@ fn data_id_for_static(
267267
assert!(!definition);
268268
assert!(!tcx.is_mutable_static(def_id));
269269

270-
let ty = instance.ty(tcx, ty::TypingEnv::fully_monomorphized());
270+
let ty = instance.ty(tcx, ty::TypingEnv::fully_monomorphized(tcx));
271271
let align = tcx
272-
.layout_of(ty::TypingEnv::fully_monomorphized().as_query_input(ty))
272+
.layout_of(ty::TypingEnv::fully_monomorphized(tcx).as_query_input(ty))
273273
.unwrap()
274274
.align
275275
.abi

compiler/rustc_codegen_cranelift/src/debuginfo/mod.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ impl DebugContext {
210210

211211
type_names::push_generic_params(
212212
tcx,
213-
tcx.normalize_erasing_regions(ty::TypingEnv::fully_monomorphized(), args),
213+
tcx.normalize_erasing_regions(ty::TypingEnv::fully_monomorphized(tcx), args),
214214
&mut name,
215215
);
216216

@@ -275,9 +275,10 @@ impl DebugContext {
275275
let span = tcx.def_span(def_id);
276276
let (file_id, line, _column) = self.get_span_loc(tcx, span, span);
277277

278-
let static_type = Instance::mono(tcx, def_id).ty(tcx, ty::TypingEnv::fully_monomorphized());
278+
let static_type =
279+
Instance::mono(tcx, def_id).ty(tcx, ty::TypingEnv::fully_monomorphized(tcx));
279280
let static_layout = tcx
280-
.layout_of(ty::TypingEnv::fully_monomorphized().as_query_input(static_type))
281+
.layout_of(ty::TypingEnv::fully_monomorphized(tcx).as_query_input(static_type))
281282
.unwrap();
282283
// FIXME use the actual type layout
283284
let type_id = self.debug_type(tcx, type_dbg, static_type);

compiler/rustc_codegen_cranelift/src/debuginfo/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ impl DebugContext {
129129

130130
let name = type_names::compute_debuginfo_type_name(tcx, ptr_type, true);
131131

132-
if !tcx.type_has_metadata(ptr_type, ty::TypingEnv::fully_monomorphized()) {
132+
if !tcx.type_has_metadata(ptr_type, ty::TypingEnv::fully_monomorphized(tcx)) {
133133
let pointer_type_id =
134134
self.dwarf.unit.add(self.dwarf.unit.root(), gimli::DW_TAG_pointer_type);
135135
let pointer_entry = self.dwarf.unit.get_mut(pointer_type_id);

compiler/rustc_codegen_cranelift/src/inline_asm.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub(crate) fn codegen_inline_asm_terminator<'tcx>(
9292
if let ty::FnDef(def_id, args) = *const_.ty().kind() {
9393
let instance = ty::Instance::resolve_for_fn_ptr(
9494
fx.tcx,
95-
ty::TypingEnv::fully_monomorphized(),
95+
ty::TypingEnv::fully_monomorphized(fx.tcx),
9696
def_id,
9797
args,
9898
)
@@ -225,11 +225,11 @@ pub(crate) fn codegen_naked_asm<'tcx>(
225225
InlineAsmOperand::Const { ref value } => {
226226
let cv = instance.instantiate_mir_and_normalize_erasing_regions(
227227
tcx,
228-
ty::TypingEnv::fully_monomorphized(),
228+
ty::TypingEnv::fully_monomorphized(tcx),
229229
ty::EarlyBinder::bind(value.const_),
230230
);
231231
let const_value = cv
232-
.eval(tcx, ty::TypingEnv::fully_monomorphized(), value.span)
232+
.eval(tcx, ty::TypingEnv::fully_monomorphized(tcx), value.span)
233233
.expect("erroneous constant missed by mono item collection");
234234

235235
let value = rustc_codegen_ssa::common::asm_const_to_str(
@@ -248,13 +248,13 @@ pub(crate) fn codegen_naked_asm<'tcx>(
248248

249249
let const_ = instance.instantiate_mir_and_normalize_erasing_regions(
250250
tcx,
251-
ty::TypingEnv::fully_monomorphized(),
251+
ty::TypingEnv::fully_monomorphized(tcx),
252252
ty::EarlyBinder::bind(value.const_),
253253
);
254254
if let ty::FnDef(def_id, args) = *const_.ty().kind() {
255255
let instance = ty::Instance::resolve_for_fn_ptr(
256256
tcx,
257-
ty::TypingEnv::fully_monomorphized(),
257+
ty::TypingEnv::fully_monomorphized(tcx),
258258
def_id,
259259
args,
260260
)

compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
682682
.tcx
683683
.check_validity_requirement((
684684
requirement,
685-
ty::TypingEnv::fully_monomorphized().as_query_input(ty),
685+
ty::TypingEnv::fully_monomorphized(fx.tcx).as_query_input(ty),
686686
))
687687
.expect("expect to have layout during codegen");
688688

@@ -743,7 +743,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
743743
let const_val = fx
744744
.tcx
745745
.const_eval_instance(
746-
ty::TypingEnv::fully_monomorphized(),
746+
ty::TypingEnv::fully_monomorphized(fx.tcx),
747747
instance,
748748
source_info.span,
749749
)

0 commit comments

Comments
 (0)