Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
let place = &self.move_data.move_paths[mpi].place;
let ty = place.ty(self.body, self.infcx.tcx).ty;

if self.infcx.param_env.caller_bounds().iter().any(|c| {
c.as_trait_clause().is_some_and(|pred| {
pred.skip_binder().self_ty() == ty && self.infcx.tcx.is_fn_trait(pred.def_id())
})
if self.infcx.param_env.trait_clauses().any(|pred| {
pred.skip_binder().self_ty() == ty && self.infcx.tcx.is_fn_trait(pred.def_id())
}) {
// Suppress the next suggestion since we don't want to put more bounds onto
// something that already has `Fn`-like bounds (or is a closure), so we can't
Expand Down
16 changes: 7 additions & 9 deletions compiler/rustc_borrowck/src/type_check/free_region_relations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,13 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
// Normalize the assumptions we use to borrowck the program.
let mut constraints = vec![];
let mut known_type_outlives_obligations = vec![];
for bound in param_env.caller_bounds() {
if let Some(outlives) = bound.as_type_outlives_clause() {
self.normalize_and_push_type_outlives_obligation(
outlives,
span,
&mut known_type_outlives_obligations,
&mut constraints,
);
};
for outlives in param_env.type_outlives_clauses() {
self.normalize_and_push_type_outlives_obligation(
outlives,
span,
&mut known_type_outlives_obligations,
&mut constraints,
);
}

let unnormalized_input_output_tys = self
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/abi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
let instance = if let ty::FnDef(def_id, fn_args) = *func.layout().ty.kind() {
let instance = ty::Instance::expect_resolve(
fx.tcx,
ty::TypingEnv::fully_monomorphized(),
ty::TypingEnv::fully_monomorphized(fx.tcx),
def_id,
fn_args,
source_info.span,
Expand Down
10 changes: 6 additions & 4 deletions compiler/rustc_codegen_cranelift/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ fn codegen_stmt<'tcx>(
let func_ref = fx.get_function_ref(
Instance::resolve_for_fn_ptr(
fx.tcx,
ty::TypingEnv::fully_monomorphized(),
ty::TypingEnv::fully_monomorphized(fx.tcx),
def_id,
args,
)
Expand Down Expand Up @@ -730,8 +730,10 @@ fn codegen_stmt<'tcx>(

fn is_wide_ptr<'tcx>(fx: &FunctionCx<'_, '_, 'tcx>, ty: Ty<'tcx>) -> bool {
ty.builtin_deref(true).is_some_and(|pointee_ty| {
fx.tcx
.type_has_metadata(pointee_ty, ty::TypingEnv::fully_monomorphized())
fx.tcx.type_has_metadata(
pointee_ty,
ty::TypingEnv::fully_monomorphized(fx.tcx),
)
})
}

Expand Down Expand Up @@ -862,7 +864,7 @@ fn codegen_stmt<'tcx>(
NullOp::OffsetOf(fields) => fx
.tcx
.offset_of_subfield(
ty::TypingEnv::fully_monomorphized(),
ty::TypingEnv::fully_monomorphized(fx.tcx),
layout,
fields.iter(),
)
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_codegen_cranelift/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fn clif_type_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option<types::Typ
},
ty::FnPtr(..) => pointer_ty(tcx),
ty::RawPtr(pointee_ty, _) | ty::Ref(_, pointee_ty, _) => {
if tcx.type_has_metadata(*pointee_ty, ty::TypingEnv::fully_monomorphized()) {
if tcx.type_has_metadata(*pointee_ty, ty::TypingEnv::fully_monomorphized(tcx)) {
return None;
} else {
pointer_ty(tcx)
Expand All @@ -91,7 +91,7 @@ fn clif_pair_type_from_ty<'tcx>(
(clif_type_from_ty(tcx, types[0])?, clif_type_from_ty(tcx, types[1])?)
}
ty::RawPtr(pointee_ty, _) | ty::Ref(_, pointee_ty, _) => {
if tcx.type_has_metadata(*pointee_ty, ty::TypingEnv::fully_monomorphized()) {
if tcx.type_has_metadata(*pointee_ty, ty::TypingEnv::fully_monomorphized(tcx)) {
(pointer_ty(tcx), pointer_ty(tcx))
} else {
return None;
Expand Down Expand Up @@ -327,7 +327,7 @@ impl<'tcx> rustc_abi::HasDataLayout for FunctionCx<'_, '_, 'tcx> {

impl<'tcx> layout::HasTypingEnv<'tcx> for FunctionCx<'_, '_, 'tcx> {
fn typing_env(&self) -> ty::TypingEnv<'tcx> {
ty::TypingEnv::fully_monomorphized()
ty::TypingEnv::fully_monomorphized(self.tcx)
}
}

Expand All @@ -344,7 +344,7 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> {
{
self.instance.instantiate_mir_and_normalize_erasing_regions(
self.tcx,
ty::TypingEnv::fully_monomorphized(),
ty::TypingEnv::fully_monomorphized(self.tcx),
ty::EarlyBinder::bind(value),
)
}
Expand Down Expand Up @@ -490,7 +490,7 @@ impl<'tcx> rustc_abi::HasDataLayout for FullyMonomorphizedLayoutCx<'tcx> {

impl<'tcx> layout::HasTypingEnv<'tcx> for FullyMonomorphizedLayoutCx<'tcx> {
fn typing_env(&self) -> ty::TypingEnv<'tcx> {
ty::TypingEnv::fully_monomorphized()
ty::TypingEnv::fully_monomorphized(self.0)
}
}

Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_codegen_cranelift/src/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub(crate) fn eval_mir_constant<'tcx>(
let cv = fx.monomorphize(constant.const_);
// This cannot fail because we checked all required_consts in advance.
let val = cv
.eval(fx.tcx, ty::TypingEnv::fully_monomorphized(), constant.span)
.eval(fx.tcx, ty::TypingEnv::fully_monomorphized(fx.tcx), constant.span)
.expect("erroneous constant missed by mono item collection");
(val, cv.ty())
}
Expand Down Expand Up @@ -267,9 +267,9 @@ fn data_id_for_static(
assert!(!definition);
assert!(!tcx.is_mutable_static(def_id));

let ty = instance.ty(tcx, ty::TypingEnv::fully_monomorphized());
let ty = instance.ty(tcx, ty::TypingEnv::fully_monomorphized(tcx));
let align = tcx
.layout_of(ty::TypingEnv::fully_monomorphized().as_query_input(ty))
.layout_of(ty::TypingEnv::fully_monomorphized(tcx).as_query_input(ty))
.unwrap()
.align
.abi
Expand Down
7 changes: 4 additions & 3 deletions compiler/rustc_codegen_cranelift/src/debuginfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl DebugContext {

type_names::push_generic_params(
tcx,
tcx.normalize_erasing_regions(ty::TypingEnv::fully_monomorphized(), args),
tcx.normalize_erasing_regions(ty::TypingEnv::fully_monomorphized(tcx), args),
&mut name,
);

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

let static_type = Instance::mono(tcx, def_id).ty(tcx, ty::TypingEnv::fully_monomorphized());
let static_type =
Instance::mono(tcx, def_id).ty(tcx, ty::TypingEnv::fully_monomorphized(tcx));
let static_layout = tcx
.layout_of(ty::TypingEnv::fully_monomorphized().as_query_input(static_type))
.layout_of(ty::TypingEnv::fully_monomorphized(tcx).as_query_input(static_type))
.unwrap();
// FIXME use the actual type layout
let type_id = self.debug_type(tcx, type_dbg, static_type);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/debuginfo/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl DebugContext {

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

if !tcx.type_has_metadata(ptr_type, ty::TypingEnv::fully_monomorphized()) {
if !tcx.type_has_metadata(ptr_type, ty::TypingEnv::fully_monomorphized(tcx)) {
let pointer_type_id =
self.dwarf.unit.add(self.dwarf.unit.root(), gimli::DW_TAG_pointer_type);
let pointer_entry = self.dwarf.unit.get_mut(pointer_type_id);
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_codegen_cranelift/src/inline_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub(crate) fn codegen_inline_asm_terminator<'tcx>(
if let ty::FnDef(def_id, args) = *const_.ty().kind() {
let instance = ty::Instance::resolve_for_fn_ptr(
fx.tcx,
ty::TypingEnv::fully_monomorphized(),
ty::TypingEnv::fully_monomorphized(fx.tcx),
def_id,
args,
)
Expand Down Expand Up @@ -225,11 +225,11 @@ pub(crate) fn codegen_naked_asm<'tcx>(
InlineAsmOperand::Const { ref value } => {
let cv = instance.instantiate_mir_and_normalize_erasing_regions(
tcx,
ty::TypingEnv::fully_monomorphized(),
ty::TypingEnv::fully_monomorphized(tcx),
ty::EarlyBinder::bind(value.const_),
);
let const_value = cv
.eval(tcx, ty::TypingEnv::fully_monomorphized(), value.span)
.eval(tcx, ty::TypingEnv::fully_monomorphized(tcx), value.span)
.expect("erroneous constant missed by mono item collection");

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

let const_ = instance.instantiate_mir_and_normalize_erasing_regions(
tcx,
ty::TypingEnv::fully_monomorphized(),
ty::TypingEnv::fully_monomorphized(tcx),
ty::EarlyBinder::bind(value.const_),
);
if let ty::FnDef(def_id, args) = *const_.ty().kind() {
let instance = ty::Instance::resolve_for_fn_ptr(
tcx,
ty::TypingEnv::fully_monomorphized(),
ty::TypingEnv::fully_monomorphized(tcx),
def_id,
args,
)
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
.tcx
.check_validity_requirement((
requirement,
ty::TypingEnv::fully_monomorphized().as_query_input(ty),
ty::TypingEnv::fully_monomorphized(fx.tcx).as_query_input(ty),
))
.expect("expect to have layout during codegen");

Expand Down Expand Up @@ -743,7 +743,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
let const_val = fx
.tcx
.const_eval_instance(
ty::TypingEnv::fully_monomorphized(),
ty::TypingEnv::fully_monomorphized(fx.tcx),
instance,
source_info.span,
)
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_codegen_cranelift/src/main_shim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub(crate) fn maybe_create_entry_wrapper(
// regions must appear in the argument
// listing.
let main_ret_ty = tcx.normalize_erasing_regions(
ty::TypingEnv::fully_monomorphized(),
ty::TypingEnv::fully_monomorphized(tcx),
main_ret_ty.no_bound_vars().unwrap(),
);

Expand Down Expand Up @@ -113,7 +113,7 @@ pub(crate) fn maybe_create_entry_wrapper(
.unwrap();
let report = Instance::expect_resolve(
tcx,
ty::TypingEnv::fully_monomorphized(),
ty::TypingEnv::fully_monomorphized(tcx),
report.def_id,
tcx.mk_args(&[GenericArg::from(main_ret_ty)]),
DUMMY_SP,
Expand All @@ -139,7 +139,7 @@ pub(crate) fn maybe_create_entry_wrapper(
let start_def_id = tcx.require_lang_item(LangItem::Start, None);
let start_instance = Instance::expect_resolve(
tcx,
ty::TypingEnv::fully_monomorphized(),
ty::TypingEnv::fully_monomorphized(tcx),
start_def_id,
tcx.mk_args(&[main_ret_ty.into()]),
DUMMY_SP,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ pub(crate) fn codegen_ptr_binop<'tcx>(
.layout()
.ty
.builtin_deref(true)
.map(|ty| !fx.tcx.type_has_metadata(ty, ty::TypingEnv::fully_monomorphized()))
.map(|ty| !fx.tcx.type_has_metadata(ty, ty::TypingEnv::fully_monomorphized(fx.tcx)))
.unwrap_or(true);

if is_thin_ptr {
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_codegen_cranelift/src/value_and_place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ impl<'tcx> CPlace<'tcx> {
};

let (field_ptr, field_layout) = codegen_field(fx, base, extra, layout, field);
if fx.tcx.type_has_metadata(field_layout.ty, ty::TypingEnv::fully_monomorphized()) {
if fx.tcx.type_has_metadata(field_layout.ty, ty::TypingEnv::fully_monomorphized(fx.tcx)) {
CPlace::for_ptr_with_extra(field_ptr, extra.unwrap(), field_layout)
} else {
CPlace::for_ptr(field_ptr, field_layout)
Expand Down Expand Up @@ -832,7 +832,7 @@ impl<'tcx> CPlace<'tcx> {

pub(crate) fn place_deref(self, fx: &mut FunctionCx<'_, '_, 'tcx>) -> CPlace<'tcx> {
let inner_layout = fx.layout_of(self.layout().ty.builtin_deref(true).unwrap());
if fx.tcx.type_has_metadata(inner_layout.ty, ty::TypingEnv::fully_monomorphized()) {
if fx.tcx.type_has_metadata(inner_layout.ty, ty::TypingEnv::fully_monomorphized(fx.tcx)) {
let (addr, extra) = self.to_cvalue(fx).load_scalar_pair(fx);
CPlace::for_ptr_with_extra(Pointer::new(addr), extra, inner_layout)
} else {
Expand All @@ -845,7 +845,7 @@ impl<'tcx> CPlace<'tcx> {
fx: &mut FunctionCx<'_, '_, 'tcx>,
layout: TyAndLayout<'tcx>,
) -> CValue<'tcx> {
if fx.tcx.type_has_metadata(self.layout().ty, ty::TypingEnv::fully_monomorphized()) {
if fx.tcx.type_has_metadata(self.layout().ty, ty::TypingEnv::fully_monomorphized(fx.tcx)) {
let (ptr, extra) = self.to_ptr_unsized();
CValue::by_val_pair(ptr.get_addr(fx), extra, layout)
} else {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
let gcc_type = if nested {
self.type_i8()
} else {
let ty = instance.ty(self.tcx, ty::TypingEnv::fully_monomorphized());
let ty = instance.ty(self.tcx, ty::TypingEnv::fully_monomorphized(self.tcx));
self.layout_of(ty).gcc_type(self)
};

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_gcc/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
) -> Self {
let create_type = |ctype, rust_type| {
let layout = tcx
.layout_of(ty::TypingEnv::fully_monomorphized().as_query_input(rust_type))
.layout_of(ty::TypingEnv::fully_monomorphized(tcx).as_query_input(rust_type))
.unwrap();
let align = layout.align.abi.bytes();
#[cfg(feature = "master")]
Expand Down Expand Up @@ -590,7 +590,7 @@ impl<'gcc, 'tcx> FnAbiOfHelpers<'tcx> for CodegenCx<'gcc, 'tcx> {

impl<'tcx, 'gcc> HasTypingEnv<'tcx> for CodegenCx<'gcc, 'tcx> {
fn typing_env(&self) -> ty::TypingEnv<'tcx> {
ty::TypingEnv::fully_monomorphized()
ty::TypingEnv::fully_monomorphized(self.tcx)
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/src/int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
};
let layout = self
.tcx
.layout_of(ty::TypingEnv::fully_monomorphized().as_query_input(res_ty))
.layout_of(ty::TypingEnv::fully_monomorphized(self.tcx).as_query_input(res_ty))
.unwrap();

let arg_abi = ArgAbi { layout, mode: PassMode::Direct(ArgAttributes::new()) };
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_codegen_gcc/src/intrinsic/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(

let tcx = bx.tcx();
let sig = tcx.normalize_erasing_late_bound_regions(
ty::TypingEnv::fully_monomorphized(),
ty::TypingEnv::fully_monomorphized(tcx),
callee_ty.fn_sig(tcx),
);
let arg_tys = sig.inputs();
Expand Down Expand Up @@ -469,7 +469,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
match *in_elem.kind() {
ty::RawPtr(p_ty, _) => {
let metadata = p_ty.ptr_metadata_ty(bx.tcx, |ty| {
bx.tcx.normalize_erasing_regions(ty::TypingEnv::fully_monomorphized(), ty)
bx.tcx.normalize_erasing_regions(ty::TypingEnv::fully_monomorphized(bx.tcx), ty)
});
require!(
metadata.is_unit(),
Expand All @@ -483,7 +483,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
match *out_elem.kind() {
ty::RawPtr(p_ty, _) => {
let metadata = p_ty.ptr_metadata_ty(bx.tcx, |ty| {
bx.tcx.normalize_erasing_regions(ty::TypingEnv::fully_monomorphized(), ty)
bx.tcx.normalize_erasing_regions(ty::TypingEnv::fully_monomorphized(bx.tcx), ty)
});
require!(
metadata.is_unit(),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1288,7 +1288,7 @@ impl<'tcx> ty::layout::HasTyCtxt<'tcx> for CodegenCx<'_, 'tcx> {

impl<'tcx, 'll> HasTypingEnv<'tcx> for CodegenCx<'ll, 'tcx> {
fn typing_env(&self) -> ty::TypingEnv<'tcx> {
ty::TypingEnv::fully_monomorphized()
ty::TypingEnv::fully_monomorphized(self.tcx)
}
}

Expand Down
Loading
Loading