Skip to content

Commit fcc8c1b

Browse files
committed
comnt
1 parent 586bd1f commit fcc8c1b

Some content is hidden

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

81 files changed

+464
-553
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -3830,15 +3830,14 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
38303830
tcx.get_diagnostic_item(sym::deref_target).and_then(|deref_target| {
38313831
Instance::try_resolve(
38323832
tcx,
3833-
self.infcx.typing_mode(self.param_env),
3834-
self.param_env,
3833+
self.infcx.typing_env(self.param_env),
38353834
deref_target,
38363835
method_args,
38373836
)
38383837
.transpose()
38393838
});
38403839
if let Some(Ok(instance)) = deref_target {
3841-
let deref_target_ty = instance.ty(tcx, self.param_env);
3840+
let deref_target_ty = instance.ty(tcx, self.infcx.typing_env(self.param_env));
38423841
err.note(format!("borrow occurs due to deref coercion to `{deref_target_ty}`"));
38433842
err.span_note(tcx.def_span(instance.def_id()), "deref defined here");
38443843
}

compiler/rustc_borrowck/src/diagnostics/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -864,8 +864,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
864864

865865
let kind = call_kind(
866866
self.infcx.tcx,
867-
self.infcx.typing_mode(self.param_env),
868-
self.param_env,
867+
self.infcx.typing_env(self.param_env),
869868
method_did,
870869
method_args,
871870
*fn_span,

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -952,8 +952,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
952952

953953
if let Ok(Some(instance)) = ty::Instance::try_resolve(
954954
tcx,
955-
self.infcx.typing_mode(self.param_env),
956-
self.param_env,
955+
self.infcx.typing_env(self.param_env),
957956
*fn_did,
958957
self.infcx.resolve_vars_if_possible(args),
959958
) {

compiler/rustc_borrowck/src/type_check/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1582,7 +1582,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
15821582
// The signature in this call can reference region variables,
15831583
// so erase them before calling a query.
15841584
let output_ty = self.tcx().erase_regions(sig.output());
1585-
if !output_ty.is_privately_uninhabited(self.tcx(), self.param_env) {
1585+
if !output_ty
1586+
.is_privately_uninhabited(self.tcx(), self.infcx.typing_env(self.param_env))
1587+
{
15861588
span_mirbug!(self, term, "call to converging function {:?} w/o dest", sig);
15871589
}
15881590
}

compiler/rustc_codegen_llvm/src/builder.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ impl<'tcx> ty::layout::HasTyCtxt<'tcx> for Builder<'_, '_, 'tcx> {
8181
}
8282
}
8383

84-
impl<'tcx> ty::layout::HasParamEnv<'tcx> for Builder<'_, '_, 'tcx> {
85-
fn param_env(&self) -> ty::ParamEnv<'tcx> {
86-
self.cx.param_env()
84+
impl<'tcx> ty::layout::HasTypingEnv<'tcx> for Builder<'_, '_, 'tcx> {
85+
fn typing_env(&self) -> ty::TypingEnv<'tcx> {
86+
self.cx.typing_env()
8787
}
8888
}
8989

@@ -472,7 +472,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
472472
#[instrument(level = "trace", skip(self))]
473473
fn load_operand(&mut self, place: PlaceRef<'tcx, &'ll Value>) -> OperandRef<'tcx, &'ll Value> {
474474
if place.layout.is_unsized() {
475-
let tail = self.tcx.struct_tail_for_codegen(place.layout.ty, self.param_env());
475+
let tail = self.tcx.struct_tail_for_codegen(place.layout.ty, self.typing_env());
476476
if matches!(tail.kind(), ty::Foreign(..)) {
477477
// Unsized locals and, at least conceptually, even unsized arguments must be copied
478478
// around, which requires dynamically determining their size. Therefore, we cannot

compiler/rustc_codegen_llvm/src/callee.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub(crate) fn get_fn<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'t
3131
debug!(
3232
"get_fn({:?}: {:?}) => {}",
3333
instance,
34-
instance.ty(cx.tcx(), ty::ParamEnv::reveal_all()),
34+
instance.ty(cx.tcx(), ty::TypingEnv::fully_monomorphized()),
3535
sym
3636
);
3737

compiler/rustc_codegen_llvm/src/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ impl<'ll> CodegenCx<'ll, '_> {
250250
let llty = if nested {
251251
self.type_i8()
252252
} else {
253-
let ty = instance.ty(self.tcx, ty::ParamEnv::reveal_all());
253+
let ty = instance.ty(self.tcx, ty::TypingEnv::fully_monomorphized());
254254
trace!(?ty);
255255
self.layout_of(ty).llvm_type(self)
256256
};

compiler/rustc_codegen_llvm/src/context.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -642,8 +642,7 @@ impl<'ll, 'tcx> MiscCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
642642
let llfn = match tcx.lang_items().eh_personality() {
643643
Some(def_id) if name.is_none() => self.get_fn_addr(ty::Instance::expect_resolve(
644644
tcx,
645-
ty::TypingMode::PostAnalysis,
646-
ty::ParamEnv::reveal_all(),
645+
ty::TypingEnv::fully_monomorphized(),
647646
def_id,
648647
ty::List::empty(),
649648
DUMMY_SP,
@@ -1148,8 +1147,8 @@ impl<'tcx> ty::layout::HasTyCtxt<'tcx> for CodegenCx<'_, 'tcx> {
11481147
}
11491148

11501149
impl<'tcx, 'll> HasTypingEnv<'tcx> for CodegenCx<'ll, 'tcx> {
1151-
fn param_env(&self) -> ty::ParamEnv<'tcx> {
1152-
ty::ParamEnv::reveal_all()
1150+
fn typing_env(&self) -> ty::TypingEnv<'tcx> {
1151+
ty::TypingEnv::fully_monomorphized()
11531152
}
11541153
}
11551154

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

+11-9
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ use rustc_hir::def_id::{DefId, LOCAL_CRATE};
1313
use rustc_middle::bug;
1414
use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
1515
use rustc_middle::ty::{
16-
self, AdtKind, CoroutineArgsExt, Instance, ParamEnv, PolyExistentialTraitRef, Ty, TyCtxt,
17-
Visibility,
16+
self, AdtKind, CoroutineArgsExt, Instance, PolyExistentialTraitRef, Ty, TyCtxt, Visibility,
1817
};
1918
use rustc_session::config::{self, DebugInfo, Lto};
2019
use rustc_span::symbol::Symbol;
@@ -302,9 +301,10 @@ fn build_subroutine_type_di_node<'ll, 'tcx>(
302301
.insert(unique_type_id, recursion_marker_type_di_node(cx));
303302

304303
let fn_ty = unique_type_id.expect_ty();
305-
let signature = cx
306-
.tcx
307-
.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), fn_ty.fn_sig(cx.tcx));
304+
let signature = cx.tcx.normalize_erasing_late_bound_regions(
305+
ty::TypingEnv::fully_monomorphized(),
306+
fn_ty.fn_sig(cx.tcx),
307+
);
308308

309309
let signature_di_nodes: SmallVec<_> = iter::once(
310310
// return type
@@ -1136,7 +1136,7 @@ fn build_upvar_field_di_nodes<'ll, 'tcx>(
11361136
};
11371137

11381138
assert!(
1139-
up_var_tys.iter().all(|t| t == cx.tcx.normalize_erasing_regions(ParamEnv::reveal_all(), t))
1139+
up_var_tys.iter().all(|t| t == cx.tcx.normalize_erasing_regions(ty::TypingEnv::fully_monomorphized(), t))
11401140
);
11411141

11421142
let capture_names = cx.tcx.closure_saved_names_of_captured_variables(def_id);
@@ -1298,8 +1298,9 @@ fn build_generic_type_param_di_nodes<'ll, 'tcx>(
12981298
let template_params: SmallVec<_> = iter::zip(args, names)
12991299
.filter_map(|(kind, name)| {
13001300
kind.as_type().map(|ty| {
1301-
let actual_type =
1302-
cx.tcx.normalize_erasing_regions(ParamEnv::reveal_all(), ty);
1301+
let actual_type = cx
1302+
.tcx
1303+
.normalize_erasing_regions(ty::TypingEnv::fully_monomorphized(), ty);
13031304
let actual_type_di_node = type_di_node(cx, actual_type);
13041305
let name = name.as_str();
13051306
unsafe {
@@ -1367,7 +1368,8 @@ pub(crate) fn build_global_var_di_node<'ll>(
13671368
if nested {
13681369
return;
13691370
}
1370-
let variable_type = Instance::mono(cx.tcx, def_id).ty(cx.tcx, ty::ParamEnv::reveal_all());
1371+
let variable_type =
1372+
Instance::mono(cx.tcx, def_id).ty(cx.tcx, ty::TypingEnv::fully_monomorphized());
13711373
let type_di_node = type_di_node(cx, variable_type);
13721374
let var_name = tcx.item_name(def_id);
13731375
let var_name = var_name.as_str();

compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs

+19-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_data_structures::fx::FxHashMap;
55
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
66
use rustc_macros::HashStable;
77
use rustc_middle::bug;
8-
use rustc_middle::ty::{ParamEnv, PolyExistentialTraitRef, Ty, TyCtxt};
8+
use rustc_middle::ty::{self, PolyExistentialTraitRef, Ty, TyCtxt};
99
use rustc_target::abi::{Align, Size, VariantIdx};
1010

1111
use super::{SmallVec, UNKNOWN_LINE_NUMBER, unknown_file_metadata};
@@ -49,12 +49,15 @@ pub(super) enum UniqueTypeId<'tcx> {
4949

5050
impl<'tcx> UniqueTypeId<'tcx> {
5151
pub(crate) fn for_ty(tcx: TyCtxt<'tcx>, t: Ty<'tcx>) -> Self {
52-
assert_eq!(t, tcx.normalize_erasing_regions(ParamEnv::reveal_all(), t));
52+
assert_eq!(t, tcx.normalize_erasing_regions(ty::TypingEnv::fully_monomorphized(), t));
5353
UniqueTypeId::Ty(t, private::HiddenZst)
5454
}
5555

5656
pub(crate) fn for_enum_variant_part(tcx: TyCtxt<'tcx>, enum_ty: Ty<'tcx>) -> Self {
57-
assert_eq!(enum_ty, tcx.normalize_erasing_regions(ParamEnv::reveal_all(), enum_ty));
57+
assert_eq!(
58+
enum_ty,
59+
tcx.normalize_erasing_regions(ty::TypingEnv::fully_monomorphized(), enum_ty)
60+
);
5861
UniqueTypeId::VariantPart(enum_ty, private::HiddenZst)
5962
}
6063

@@ -63,7 +66,10 @@ impl<'tcx> UniqueTypeId<'tcx> {
6366
enum_ty: Ty<'tcx>,
6467
variant_idx: VariantIdx,
6568
) -> Self {
66-
assert_eq!(enum_ty, tcx.normalize_erasing_regions(ParamEnv::reveal_all(), enum_ty));
69+
assert_eq!(
70+
enum_ty,
71+
tcx.normalize_erasing_regions(ty::TypingEnv::fully_monomorphized(), enum_ty)
72+
);
6773
UniqueTypeId::VariantStructType(enum_ty, variant_idx, private::HiddenZst)
6874
}
6975

@@ -72,7 +78,10 @@ impl<'tcx> UniqueTypeId<'tcx> {
7278
enum_ty: Ty<'tcx>,
7379
variant_idx: VariantIdx,
7480
) -> Self {
75-
assert_eq!(enum_ty, tcx.normalize_erasing_regions(ParamEnv::reveal_all(), enum_ty));
81+
assert_eq!(
82+
enum_ty,
83+
tcx.normalize_erasing_regions(ty::TypingEnv::fully_monomorphized(), enum_ty)
84+
);
7685
UniqueTypeId::VariantStructTypeCppLikeWrapper(enum_ty, variant_idx, private::HiddenZst)
7786
}
7887

@@ -81,10 +90,13 @@ impl<'tcx> UniqueTypeId<'tcx> {
8190
self_type: Ty<'tcx>,
8291
implemented_trait: Option<PolyExistentialTraitRef<'tcx>>,
8392
) -> Self {
84-
assert_eq!(self_type, tcx.normalize_erasing_regions(ParamEnv::reveal_all(), self_type));
93+
assert_eq!(
94+
self_type,
95+
tcx.normalize_erasing_regions(ty::TypingEnv::fully_monomorphized(), self_type)
96+
);
8597
assert_eq!(
8698
implemented_trait,
87-
tcx.normalize_erasing_regions(ParamEnv::reveal_all(), implemented_trait)
99+
tcx.normalize_erasing_regions(ty::TypingEnv::fully_monomorphized(), implemented_trait)
88100
);
89101
UniqueTypeId::VTableTy(self_type, implemented_trait, private::HiddenZst)
90102
}

compiler/rustc_codegen_llvm/src/debuginfo/mod.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc_hir::def_id::{DefId, DefIdMap};
1515
use rustc_index::IndexVec;
1616
use rustc_middle::mir;
1717
use rustc_middle::ty::layout::LayoutOf;
18-
use rustc_middle::ty::{self, GenericArgsRef, Instance, ParamEnv, Ty, TypeVisitableExt};
18+
use rustc_middle::ty::{self, GenericArgsRef, Instance, Ty, TypeVisitableExt};
1919
use rustc_session::Session;
2020
use rustc_session::config::{self, DebugInfo};
2121
use rustc_span::symbol::Symbol;
@@ -343,7 +343,7 @@ impl<'ll, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
343343

344344
type_names::push_generic_params(
345345
tcx,
346-
tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), args),
346+
tcx.normalize_erasing_regions(ty::TypingEnv::fully_monomorphized(), args),
347347
&mut name,
348348
);
349349

@@ -480,8 +480,10 @@ impl<'ll, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
480480
iter::zip(args, names)
481481
.filter_map(|(kind, name)| {
482482
kind.as_type().map(|ty| {
483-
let actual_type =
484-
cx.tcx.normalize_erasing_regions(ParamEnv::reveal_all(), ty);
483+
let actual_type = cx.tcx.normalize_erasing_regions(
484+
ty::TypingEnv::fully_monomorphized(),
485+
ty,
486+
);
485487
let actual_type_metadata = type_di_node(cx, actual_type);
486488
let name = name.as_str();
487489
unsafe {

compiler/rustc_codegen_llvm/src/debuginfo/utils.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Utility Functions.
22

33
use rustc_hir::def_id::DefId;
4-
use rustc_middle::ty::layout::{HasParamEnv, LayoutOf};
4+
use rustc_middle::ty::layout::{HasTypingEnv, LayoutOf};
55
use rustc_middle::ty::{self, Ty};
66
use tracing::trace;
77

@@ -62,7 +62,7 @@ pub(crate) fn wide_pointer_kind<'ll, 'tcx>(
6262
cx: &CodegenCx<'ll, 'tcx>,
6363
pointee_ty: Ty<'tcx>,
6464
) -> Option<WidePtrKind> {
65-
let pointee_tail_ty = cx.tcx.struct_tail_for_codegen(pointee_ty, cx.param_env());
65+
let pointee_tail_ty = cx.tcx.struct_tail_for_codegen(pointee_ty, cx.typing_env());
6666
let layout = cx.layout_of(pointee_tail_ty);
6767
trace!(
6868
"wide_pointer_kind: {:?} has layout {:?} (is_unsized? {})",

compiler/rustc_codegen_llvm/src/intrinsic.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,15 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
163163
span: Span,
164164
) -> Result<(), ty::Instance<'tcx>> {
165165
let tcx = self.tcx;
166-
let callee_ty = instance.ty(tcx, ty::ParamEnv::reveal_all());
166+
let callee_ty = instance.ty(tcx, ty::TypingEnv::fully_monomorphized());
167167

168168
let ty::FnDef(def_id, fn_args) = *callee_ty.kind() else {
169169
bug!("expected fn item type, found {}", callee_ty);
170170
};
171171

172172
let sig = callee_ty.fn_sig(tcx);
173-
let sig = tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), sig);
173+
let sig =
174+
tcx.normalize_erasing_late_bound_regions(ty::TypingEnv::fully_monomorphized(), sig);
174175
let arg_tys = sig.inputs();
175176
let ret_ty = sig.output();
176177
let name = tcx.item_name(def_id);
@@ -1154,8 +1155,10 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
11541155
}
11551156

11561157
let tcx = bx.tcx();
1157-
let sig =
1158-
tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), callee_ty.fn_sig(tcx));
1158+
let sig = tcx.normalize_erasing_late_bound_regions(
1159+
ty::TypingEnv::fully_monomorphized(),
1160+
callee_ty.fn_sig(tcx),
1161+
);
11591162
let arg_tys = sig.inputs();
11601163

11611164
// Sanity-check: all vector arguments must be immediates.
@@ -2189,7 +2192,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
21892192
match in_elem.kind() {
21902193
ty::RawPtr(p_ty, _) => {
21912194
let metadata = p_ty.ptr_metadata_ty(bx.tcx, |ty| {
2192-
bx.tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), ty)
2195+
bx.tcx.normalize_erasing_regions(ty::TypingEnv::fully_monomorphized(), ty)
21932196
});
21942197
require!(metadata.is_unit(), InvalidMonomorphization::CastWidePointer {
21952198
span,
@@ -2204,7 +2207,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
22042207
match out_elem.kind() {
22052208
ty::RawPtr(p_ty, _) => {
22062209
let metadata = p_ty.ptr_metadata_ty(bx.tcx, |ty| {
2207-
bx.tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), ty)
2210+
bx.tcx.normalize_erasing_regions(ty::TypingEnv::fully_monomorphized(), ty)
22082211
});
22092212
require!(metadata.is_unit(), InvalidMonomorphization::CastWidePointer {
22102213
span,

compiler/rustc_codegen_llvm/src/mono_item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl<'tcx> PreDefineCodegenMethods<'tcx> for CodegenCx<'_, 'tcx> {
2929
let ty = if nested {
3030
self.tcx.types.unit
3131
} else {
32-
instance.ty(self.tcx, ty::ParamEnv::reveal_all())
32+
instance.ty(self.tcx, ty::TypingEnv::fully_monomorphized())
3333
};
3434
let llty = self.layout_of(ty).llvm_type(self);
3535

compiler/rustc_const_eval/src/check_consts/check.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
565565
_ => unreachable!(),
566566
};
567567

568-
let ConstCx { tcx, body, param_env, .. } = *self.ccx;
568+
let ConstCx { tcx, body, typing_env, .. } = *self.ccx;
569569
let caller = self.def_id();
570570

571571
let fn_ty = func.ty(body, tcx);
@@ -589,7 +589,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
589589
// Typeck only does a "non-const" check since it operates on HIR and cannot distinguish
590590
// which path expressions are getting called on and which path expressions are only used
591591
// as function pointers. This is required for correctness.
592-
let infcx = tcx.infer_ctxt().build(body.typing_mode(tcx));
592+
let (infcx, param_env) = tcx.infer_ctxt().build_with_typing_env(typing_env);
593593
let ocx = ObligationCtxt::new_with_diagnostics(&infcx);
594594

595595
let predicates = tcx.predicates_of(callee).instantiate(tcx, fn_args);
@@ -601,7 +601,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
601601
let normalized_predicates = ocx.normalize(&cause, param_env, predicates);
602602
ocx.register_obligations(traits::predicates_for_generics(
603603
|_, _| cause.clone(),
604-
self.param_env,
604+
param_env,
605605
normalized_predicates,
606606
));
607607

0 commit comments

Comments
 (0)