diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index 86e5a6700b039..90f29b004a48e 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -680,7 +680,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { hir::ExprKind::Call(callee, _) if let &ty::FnDef(_, args) = typeck.node_type(callee.hir_id).kind() => { - args + args.no_bound_vars().unwrap() } _ => return None, }; diff --git a/compiler/rustc_borrowck/src/diagnostics/mod.rs b/compiler/rustc_borrowck/src/diagnostics/mod.rs index a5b7a26a10ab4..adf727eead01a 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mod.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mod.rs @@ -985,6 +985,8 @@ impl<'tcx> BorrowedContentSource<'tcx> { ty::FnDef(def_id, args) => { let trait_id = tcx.trait_of_assoc(def_id)?; + let args = args.no_bound_vars().unwrap(); + if tcx.is_lang_item(trait_id, LangItem::Deref) || tcx.is_lang_item(trait_id, LangItem::DerefMut) { diff --git a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs index cc02206c50649..e4faa63b301e1 100644 --- a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs @@ -647,7 +647,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { hir::ExprKind::Call(callee, _) => { let ty = typeck_result.node_type_opt(callee.hir_id)?; let ty::FnDef(fn_def_id, args) = *ty.kind() else { return None }; - tcx.predicates_of(fn_def_id).instantiate(tcx, args) + tcx.predicates_of(fn_def_id).instantiate(tcx, args.no_bound_vars().unwrap()) } hir::ExprKind::MethodCall(..) => { let (_, method) = typeck_result.type_dependent_def(parent.hir_id)?; diff --git a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs index a4025f28a5511..7fee8ec637216 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs @@ -1241,7 +1241,13 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { typeck_results.node_type_opt(expr.hir_id).as_ref().map(|ty| ty.kind()) { let arg_pos = args.iter().position(|arg| arg.hir_id == closure_id)?; - Some((*def_id, expr.span, arg_pos, arg_pos, generic_args)) + Some(( + *def_id, + expr.span, + arg_pos, + arg_pos, + generic_args.no_bound_vars().unwrap(), + )) } else { None } @@ -1914,7 +1920,7 @@ fn suggest_ampmut<'tcx>( let trait_ref = ty::TraitRef::from_assoc( tcx, tcx.require_lang_item(hir::LangItem::IndexMut, rhs_span), - method_args, + method_args.no_bound_vars().unwrap(), ); // The type only implements `Index` but not `IndexMut`, we must not suggest `&mut`. if !infcx diff --git a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs index a82cd5c74c330..10291e90d7d52 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs @@ -960,7 +960,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { tcx, self.infcx.typing_env(self.infcx.param_env), fn_did, - self.infcx.resolve_vars_if_possible(args), + self.infcx.resolve_vars_if_possible(args.no_bound_vars().unwrap()), ) else { return; }; diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index 33c45ebfdde4c..4d3e1cc498843 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -1828,6 +1828,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { } if let ty::FnDef(def_id, args) = *constant.const_.ty().kind() { + let args = args.no_bound_vars().unwrap(); let instantiated_predicates = tcx.predicates_of(def_id).instantiate(tcx, args); self.normalize_and_prove_instantiated_predicates( def_id, diff --git a/compiler/rustc_borrowck/src/universal_regions.rs b/compiler/rustc_borrowck/src/universal_regions.rs index b0adbcd6db4ef..d2e7c7c101f9a 100644 --- a/compiler/rustc_borrowck/src/universal_regions.rs +++ b/compiler/rustc_borrowck/src/universal_regions.rs @@ -603,7 +603,9 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> { ty::CoroutineClosure(def_id, args) => { DefiningTy::CoroutineClosure(def_id, args) } - ty::FnDef(def_id, args) => DefiningTy::FnDef(def_id, args), + ty::FnDef(def_id, args) => { + DefiningTy::FnDef(def_id, args.no_bound_vars().unwrap()) + } _ => span_bug!( tcx.def_span(self.mir_def), "expected defining type for `{:?}`: `{:?}`", diff --git a/compiler/rustc_codegen_cranelift/src/abi/mod.rs b/compiler/rustc_codegen_cranelift/src/abi/mod.rs index ec17e72900dfb..4871e80a75645 100644 --- a/compiler/rustc_codegen_cranelift/src/abi/mod.rs +++ b/compiler/rustc_codegen_cranelift/src/abi/mod.rs @@ -421,7 +421,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( fx.tcx, ty::TypingEnv::fully_monomorphized(), def_id, - fn_args, + fn_args.no_bound_vars().unwrap(), source_info.span, ); diff --git a/compiler/rustc_codegen_cranelift/src/base.rs b/compiler/rustc_codegen_cranelift/src/base.rs index bf6a98866cd12..9bf379c03687c 100644 --- a/compiler/rustc_codegen_cranelift/src/base.rs +++ b/compiler/rustc_codegen_cranelift/src/base.rs @@ -717,7 +717,7 @@ fn codegen_stmt<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, cur_block: Block, stmt: fx.tcx, ty::TypingEnv::fully_monomorphized(), def_id, - args, + args.no_bound_vars().unwrap(), ) .unwrap(), ); diff --git a/compiler/rustc_codegen_cranelift/src/inline_asm.rs b/compiler/rustc_codegen_cranelift/src/inline_asm.rs index f9fc7002be87b..cc849759754ee 100644 --- a/compiler/rustc_codegen_cranelift/src/inline_asm.rs +++ b/compiler/rustc_codegen_cranelift/src/inline_asm.rs @@ -117,7 +117,7 @@ pub(crate) fn codegen_inline_asm_terminator<'tcx>( fx.tcx, ty::TypingEnv::fully_monomorphized(), def_id, - args, + args.no_bound_vars().unwrap(), ) .unwrap(); let symbol = fx.tcx.symbol_name(instance); diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index 24e9a6cb3e2d4..4ec4d338d9d4b 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -919,7 +919,7 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> { let fn_ty = instance.ty(tcx, self.typing_env()); let fn_sig = match *fn_ty.kind() { ty::FnDef(def_id, args) => tcx.instantiate_bound_regions_with_erased( - tcx.fn_sig(def_id).instantiate(tcx, args).skip_norm_wip(), + tcx.fn_sig(def_id).instantiate(tcx, args.no_bound_vars().unwrap()).skip_norm_wip(), ), _ => unreachable!(), }; @@ -1762,7 +1762,7 @@ fn codegen_autodiff<'ll, 'tcx>( let fn_to_diff = args[0].immediate(); let (diff_id, diff_args) = match fn_args.into_type_list(tcx)[1].kind() { - ty::FnDef(def_id, diff_args) => (def_id, diff_args), + ty::FnDef(def_id, diff_args) => (def_id, diff_args.no_bound_vars().unwrap()), _ => bug!("invalid args"), }; @@ -1825,7 +1825,7 @@ fn codegen_offload<'ll, 'tcx>( let fn_args = instance.args; let (target_id, target_args) = match fn_args.into_type_list(tcx)[0].kind() { - ty::FnDef(def_id, params) => (def_id, params), + ty::FnDef(def_id, params) => (def_id, params.no_bound_vars().unwrap()), _ => bug!("invalid offload intrinsic arg"), }; diff --git a/compiler/rustc_codegen_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs index bd39466508226..3a9357d1a0f5e 100644 --- a/compiler/rustc_codegen_ssa/src/base.rs +++ b/compiler/rustc_codegen_ssa/src/base.rs @@ -446,7 +446,7 @@ where cx.tcx(), ty::TypingEnv::fully_monomorphized(), def_id, - args, + args.no_bound_vars().unwrap(), expr.span, ), _ => span_bug!(*op_sp, "asm sym is not a function"), diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs index fad93de43b272..ae2e6a2b14a33 100644 --- a/compiler/rustc_codegen_ssa/src/mir/block.rs +++ b/compiler/rustc_codegen_ssa/src/mir/block.rs @@ -949,7 +949,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { bx.tcx(), bx.typing_env(), def_id, - generic_args, + generic_args.no_bound_vars().unwrap(), fn_span, ); @@ -1098,7 +1098,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { bx.tcx(), bx.typing_env(), def_id, - generic_args, + generic_args.no_bound_vars().unwrap(), ) .unwrap(); @@ -1486,7 +1486,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { bx.tcx(), bx.typing_env(), def_id, - args, + args.no_bound_vars().unwrap(), ) .unwrap(); InlineAsmOperandRef::SymFn { instance } diff --git a/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs b/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs index 9ce8e6e48bbd1..c33c228cc5b2d 100644 --- a/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs +++ b/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs @@ -95,9 +95,13 @@ fn inline_to_global_operand<'a, 'tcx, Cx: LayoutOf<'tcx, LayoutOfResult = TyAndL ); let instance = match mono_type.kind() { - &ty::FnDef(def_id, args) => { - Instance::expect_resolve(cx.tcx(), cx.typing_env(), def_id, args, value.span) - } + &ty::FnDef(def_id, args) => Instance::expect_resolve( + cx.tcx(), + cx.typing_env(), + def_id, + args.no_bound_vars().unwrap(), + value.span, + ), _ => bug!("asm sym is not a function"), }; diff --git a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs index f417dfba746f1..125749f2c383c 100644 --- a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs +++ b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs @@ -434,7 +434,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { bx.tcx(), bx.typing_env(), def_id, - args, + args.no_bound_vars().unwrap(), ) .unwrap(); OperandValue::Immediate( diff --git a/compiler/rustc_const_eval/src/check_consts/check.rs b/compiler/rustc_const_eval/src/check_consts/check.rs index daf51dd967203..0e4dc708d389f 100644 --- a/compiler/rustc_const_eval/src/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/check_consts/check.rs @@ -757,7 +757,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { let fn_ty = func.ty(body, tcx); let (callee, fn_args) = match *fn_ty.kind() { - ty::FnDef(def_id, fn_args) => (def_id, fn_args), + ty::FnDef(def_id, fn_args) => (def_id, fn_args.no_bound_vars().unwrap()), ty::FnPtr(..) => { self.check_op(ops::FnCallIndirect); diff --git a/compiler/rustc_const_eval/src/interpret/cast.rs b/compiler/rustc_const_eval/src/interpret/cast.rs index faef782534280..77839302692e0 100644 --- a/compiler/rustc_const_eval/src/interpret/cast.rs +++ b/compiler/rustc_const_eval/src/interpret/cast.rs @@ -87,7 +87,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { *self.tcx, self.typing_env, def_id, - args, + args.no_bound_vars().unwrap(), ) .ok_or_else(|| err_inval!(TooGeneric))? }; diff --git a/compiler/rustc_const_eval/src/interpret/step.rs b/compiler/rustc_const_eval/src/interpret/step.rs index 0926476c9e01b..dd2477503fd6d 100644 --- a/compiler/rustc_const_eval/src/interpret/step.rs +++ b/compiler/rustc_const_eval/src/interpret/step.rs @@ -483,7 +483,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { (fn_val, self.fn_abi_of_fn_ptr(fn_sig_binder, extra_args)?, false) } ty::FnDef(def_id, args) => { - let instance = self.resolve(def_id, args)?; + let instance = self.resolve(def_id, args.no_bound_vars().unwrap())?; ( FnVal::Instance(instance), self.fn_abi_of_instance_no_deduced_attrs(instance, extra_args)?, diff --git a/compiler/rustc_const_eval/src/util/type_name.rs b/compiler/rustc_const_eval/src/util/type_name.rs index 56c41d7697e0c..b46bd86f0497a 100644 --- a/compiler/rustc_const_eval/src/util/type_name.rs +++ b/compiler/rustc_const_eval/src/util/type_name.rs @@ -52,7 +52,6 @@ impl<'tcx> Printer<'tcx> for TypeNamePrinter<'tcx> { // Types with identity (print the module path). ty::Adt(ty::AdtDef(Interned(&ty::AdtDefData { did: def_id, .. }, _)), args) - | ty::FnDef(def_id, args) | ty::Alias( _, ty::AliasTy { @@ -64,6 +63,7 @@ impl<'tcx> Printer<'tcx> for TypeNamePrinter<'tcx> { | ty::Coroutine(def_id, args) => self.print_def_path(def_id, args), ty::Foreign(def_id) => self.print_def_path(def_id, &[]), + ty::FnDef(def_id, args) => self.print_def_path(def_id, args.no_bound_vars().unwrap()), ty::Alias(_, ty::AliasTy { kind: ty::Free { .. }, .. }) => { bug!("type_name: unexpected free alias") } diff --git a/compiler/rustc_hir_analysis/src/collect/generics_of.rs b/compiler/rustc_hir_analysis/src/collect/generics_of.rs index d6a5db4c22f24..6427bf95f6189 100644 --- a/compiler/rustc_hir_analysis/src/collect/generics_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/generics_of.rs @@ -253,8 +253,9 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics { let generics = tcx.generics_of(def_id); assert!(!has_self); parent_has_self = generics.has_self; - own_start = generics.count() as u32; - generics.parent_count + generics.own_params.len() + let count = generics.count(); + own_start = count as u32; + count }); let mut own_params: Vec<_> = Vec::with_capacity(hir_generics.params.len() + has_self as usize); diff --git a/compiler/rustc_hir_analysis/src/collect/type_of.rs b/compiler/rustc_hir_analysis/src/collect/type_of.rs index 9c8e61d89da97..cdcd6d1dee37d 100644 --- a/compiler/rustc_hir_analysis/src/collect/type_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/type_of.rs @@ -67,7 +67,8 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_ Node::TraitItem(item) => match item.kind { TraitItemKind::Fn(..) => { let args = ty::GenericArgs::identity_for_item(tcx, def_id); - Ty::new_fn_def(tcx, def_id.to_def_id(), args) + // FIXME(156581): actually instantiate the binder correctly (turbofishing/fndef changes) + Ty::new_fn_def(tcx, def_id.to_def_id(), ty::Binder::dummy(args)) } TraitItemKind::Const(ty, rhs) => rhs .and_then(|rhs| { @@ -93,7 +94,8 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_ Node::ImplItem(item) => match item.kind { ImplItemKind::Fn(..) => { let args = ty::GenericArgs::identity_for_item(tcx, def_id); - Ty::new_fn_def(tcx, def_id.to_def_id(), args) + // FIXME(156581): actually instantiate the binder correctly (turbofishing/fndef changes) + Ty::new_fn_def(tcx, def_id.to_def_id(), ty::Binder::dummy(args)) } ImplItemKind::Const(ty, rhs) => { if ty.is_suggestable_infer_ty() { @@ -171,7 +173,8 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_ }, ItemKind::Fn { .. } => { let args = ty::GenericArgs::identity_for_item(tcx, def_id); - Ty::new_fn_def(tcx, def_id.to_def_id(), args) + // FIXME(156581): actually instantiate the binder correctly (turbofishing/fndef changes) + Ty::new_fn_def(tcx, def_id.to_def_id(), ty::Binder::dummy(args)) } ItemKind::Enum(..) | ItemKind::Struct(..) | ItemKind::Union(..) => { let def = tcx.adt_def(def_id); @@ -195,7 +198,8 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_ Node::ForeignItem(foreign_item) => match foreign_item.kind { ForeignItemKind::Fn(..) => { let args = ty::GenericArgs::identity_for_item(tcx, def_id); - Ty::new_fn_def(tcx, def_id.to_def_id(), args) + // FIXME(156581): actually instantiate the binder correctly (turbofishing/fndef changes) + Ty::new_fn_def(tcx, def_id.to_def_id(), ty::Binder::dummy(args)) } ForeignItemKind::Static(ty, _, _) => { let ty = icx.lower_ty(ty); @@ -217,7 +221,8 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_ } VariantData::Tuple(_, _, ctor) => { let args = ty::GenericArgs::identity_for_item(tcx, def_id); - Ty::new_fn_def(tcx, ctor.to_def_id(), args) + // FIXME(156581): actually instantiate the binder correctly (turbofishing/fndef changes) + Ty::new_fn_def(tcx, ctor.to_def_id(), ty::Binder::dummy(args)) } }, diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs index 79197c846071d..ed5c196762348 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs @@ -1480,7 +1480,11 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { } TypeRelativePath::Ctor { ctor_def_id, args } => match tcx.def_kind(ctor_def_id) { DefKind::Ctor(_, CtorKind::Fn) => { - Ok(ty::Const::zero_sized(tcx, Ty::new_fn_def(tcx, ctor_def_id, args))) + // FIXME(156581): actually instantiate the binder correctly (turbofishing/fndef changes) + Ok(ty::Const::zero_sized( + tcx, + Ty::new_fn_def(tcx, ctor_def_id, ty::Binder::dummy(args)), + )) } DefKind::Ctor(ctor_of, CtorKind::Const) => { Ok(self.construct_const_ctor_value(ctor_def_id, ctor_of, args)) @@ -2578,7 +2582,9 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { .map(|(field_def, arg)| { self.lower_const_arg( arg, - tcx.type_of(field_def.did).instantiate(tcx, adt_args).skip_norm_wip(), + tcx.type_of(field_def.did) + .instantiate(tcx, adt_args.no_bound_vars().unwrap()) + .skip_norm_wip(), ) }) .collect::>(); @@ -2591,7 +2597,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { }; let valtree = ty::ValTree::from_branches(tcx, opt_discr_const.into_iter().chain(fields)); - let adt_ty = Ty::new_adt(tcx, adt_def, adt_args); + let adt_ty = Ty::new_adt(tcx, adt_def, adt_args.no_bound_vars().unwrap()); ty::Const::new_value(tcx, valtree, adt_ty) } @@ -2903,7 +2909,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { &path.segments[generic_segments[0].1], ); - ty::Const::zero_sized(tcx, Ty::new_fn_def(tcx, did, args)) + // FIXME(156581): actually instantiate the binder correctly (turbofishing/fndef changes) + ty::Const::zero_sized(tcx, Ty::new_fn_def(tcx, did, ty::Binder::dummy(args))) } Res::Def(DefKind::AssocConst { .. }, did) => { let trait_segment = if let [modules @ .., trait_, _item] = path.segments { @@ -2934,7 +2941,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { ); if self.tcx().generics_of(did).own_synthetic_params_count() == 0 { - ty::Const::zero_sized(tcx, Ty::new_fn_def(tcx, did, args)) + // FIXME(156581): actually instantiate the binder correctly (turbofishing/fndef changes) + ty::Const::zero_sized(tcx, Ty::new_fn_def(tcx, did, ty::Binder::dummy(args))) } else { let tcx = self.tcx(); let generics = tcx.generics_of(did); @@ -2951,7 +2959,11 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { } }); - ty::Const::zero_sized(tcx, Ty::new_fn_def(tcx, did, args)) + // FIXME(156581): actually instantiate the binder correctly (turbofishing/fndef changes) + ty::Const::zero_sized( + tcx, + Ty::new_fn_def(tcx, did, ty::Binder::dummy(args.collect::>())), + ) } } diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index 3cc4dc5f9fb5e..60af3fb4fa1f0 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -550,6 +550,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) -> Ty<'tcx> { let (fn_sig, def_id, callee_generic_args) = match *callee_ty.kind() { ty::FnDef(def_id, args) => { + let args = args.no_bound_vars().unwrap(); self.enforce_context_effects(Some(call_expr.hir_id), call_expr.span, def_id, args); let fn_sig = self.tcx.fn_sig(def_id).instantiate(self.tcx, args).skip_norm_wip(); diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs index e10ee05e01d91..f8f229a372ceb 100644 --- a/compiler/rustc_lint/src/internal.rs +++ b/compiler/rustc_lint/src/internal.rs @@ -170,7 +170,13 @@ fn get_callee_span_generic_args_and_args<'tcx>( && let callee_ty = cx.typeck_results().expr_ty(callee) && let ty::FnDef(callee_def_id, generic_args) = callee_ty.kind() { - return Some((*callee_def_id, callee.span, generic_args, None, args)); + return Some(( + *callee_def_id, + callee.span, + generic_args.no_bound_vars().unwrap(), + None, + args, + )); } if let ExprKind::MethodCall(segment, recv, args, _) = expr.kind && let Some(method_def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id) diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index ce30b3fae47ae..ac8a4f7870cd1 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -1701,6 +1701,8 @@ pub fn find_self_call<'tcx>( && let [Spanned { node: Operand::Move(self_place) | Operand::Copy(self_place), .. }, ..] = **args { + let fn_args = fn_args.no_bound_vars().unwrap(); + if self_place.as_local() == Some(local) { return Some((def_id, fn_args)); } diff --git a/compiler/rustc_middle/src/mir/pretty.rs b/compiler/rustc_middle/src/mir/pretty.rs index 8e83d44fbb78b..33223d3a1a5db 100644 --- a/compiler/rustc_middle/src/mir/pretty.rs +++ b/compiler/rustc_middle/src/mir/pretty.rs @@ -2035,7 +2035,7 @@ fn pretty_print_const_value_tcx<'tcx>( (ConstValue::ZeroSized, ty::FnDef(d, s)) => { let mut p = FmtPrinter::new(tcx, Namespace::ValueNS); p.print_alloc_ids = true; - p.pretty_print_value_path(*d, s)?; + p.pretty_print_value_path(*d, s.no_bound_vars().unwrap())?; fmt.write_str(&p.into_buffer())?; return Ok(()); } diff --git a/compiler/rustc_middle/src/mir/statement.rs b/compiler/rustc_middle/src/mir/statement.rs index f25eaf3c6d32e..0bb1e67b0e422 100644 --- a/compiler/rustc_middle/src/mir/statement.rs +++ b/compiler/rustc_middle/src/mir/statement.rs @@ -620,7 +620,7 @@ impl<'tcx> Operand<'tcx> { pub fn function_handle( tcx: TyCtxt<'tcx>, def_id: DefId, - args: impl IntoIterator>, + args: ty::Binder<'tcx, impl IntoIterator>>, span: Span, ) -> Self { let ty = Ty::new_fn_def(tcx, def_id, args); @@ -707,7 +707,11 @@ impl<'tcx> Operand<'tcx> { /// find as the `func` in a [`TerminatorKind::Call`]. pub fn const_fn_def(&self) -> Option<(DefId, GenericArgsRef<'tcx>)> { let const_ty = self.constant()?.const_.ty(); - if let ty::FnDef(def_id, args) = *const_ty.kind() { Some((def_id, args)) } else { None } + if let ty::FnDef(def_id, args) = *const_ty.kind() { + Some((def_id, args.no_bound_vars().unwrap())) + } else { + None + } } pub fn ty(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> Ty<'tcx> diff --git a/compiler/rustc_middle/src/ty/diagnostics.rs b/compiler/rustc_middle/src/ty/diagnostics.rs index fadf1ee2ee384..f2e6678391fa0 100644 --- a/compiler/rustc_middle/src/ty/diagnostics.rs +++ b/compiler/rustc_middle/src/ty/diagnostics.rs @@ -698,7 +698,10 @@ impl<'tcx> FallibleTypeFolder> for MakeSuggestableFolder<'tcx> { FnDef(def_id, args) if self.placeholder.is_none() => Ty::new_fn_ptr( self.tcx, - self.tcx.fn_sig(def_id).instantiate(self.tcx, args).skip_norm_wip(), + self.tcx + .fn_sig(def_id) + .instantiate(self.tcx, args.no_bound_vars().unwrap()) + .skip_norm_wip(), ), Closure(..) diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 03d13e6a81a6e..eec87a4b73dd0 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -743,6 +743,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { write!(self, ")")?; } ty::FnDef(def_id, args) => { + let args = args.no_bound_vars().unwrap(); if with_reduced_queries() { self.print_def_path(def_id, args)?; } else { @@ -2031,7 +2032,8 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { } (_, ty::FnDef(def_id, args)) => { // Never allowed today, but we still encounter them in invalid const args. - self.pretty_print_value_path(def_id, args)?; + // FIXME(addiesh): fix wrt late-bound stuff + self.pretty_print_value_path(def_id, args.no_bound_vars().unwrap())?; return Ok(()); } // FIXME(oli-obk): also pretty print arrays and other aggregate constants by reading diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index ad3b8e009320d..cd9695c3718a6 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -737,13 +737,14 @@ impl<'tcx> Ty<'tcx> { pub fn new_fn_def( tcx: TyCtxt<'tcx>, def_id: DefId, - args: impl IntoIterator>>, + args: ty::Binder<'tcx, impl IntoIterator>>>, ) -> Ty<'tcx> { debug_assert_matches!( tcx.def_kind(def_id), DefKind::AssocFn | DefKind::Fn | DefKind::Ctor(_, CtorKind::Fn) ); - let args = tcx.check_and_mk_args(def_id, args); + // FIXME(156581): check that the binder is being used correctly (turbofishing/fndef changes) + let args = args.map_bound(|args| tcx.check_and_mk_args(def_id, args)); Ty::new(tcx, FnDef(def_id, args)) } @@ -1115,7 +1116,11 @@ impl<'tcx> rustc_type_ir::inherent::Ty> for Ty<'tcx> { Ty::from_coroutine_closure_kind(interner, kind) } - fn new_fn_def(interner: TyCtxt<'tcx>, def_id: DefId, args: ty::GenericArgsRef<'tcx>) -> Self { + fn new_fn_def( + interner: TyCtxt<'tcx>, + def_id: DefId, + args: ty::Binder<'tcx, ty::GenericArgsRef<'tcx>>, + ) -> Self { Ty::new_fn_def(interner, def_id, args) } diff --git a/compiler/rustc_mir_build/src/builder/expr/into.rs b/compiler/rustc_mir_build/src/builder/expr/into.rs index ecc14fe887f24..f04247491ccfa 100644 --- a/compiler/rustc_mir_build/src/builder/expr/into.rs +++ b/compiler/rustc_mir_build/src/builder/expr/into.rs @@ -403,6 +403,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { && let Some(intrinsic) = this.tcx.intrinsic(def_id) && matches!(intrinsic.name, sym::write_via_move | sym::write_box_via_move) => { + let generic_args = generic_args.no_bound_vars().unwrap(); // We still have to evaluate the callee expression as normal (but we don't care // about its result). let _fun = unpack!(block = this.as_local_operand(block, fun)); @@ -531,7 +532,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let success = this.cfg.start_new_block(); let clone_trait = this.tcx.require_lang_item(LangItem::Clone, span); let clone_fn = this.tcx.associated_item_def_ids(clone_trait)[0]; - let func = Operand::function_handle(this.tcx, clone_fn, [ty.into()], expr_span); + // FIXME(156581): actually instantiate the binder correctly (turbofishing/fndef changes) + let func = Operand::function_handle( + this.tcx, + clone_fn, + ty::Binder::dummy([ty.into()]), + expr_span, + ); let ref_ty = Ty::new_imm_ref(this.tcx, this.tcx.lifetimes.re_erased, ty); let ref_place = this.temp(ref_ty, span); this.cfg.push_assign( diff --git a/compiler/rustc_mir_build/src/builder/matches/test.rs b/compiler/rustc_mir_build/src/builder/matches/test.rs index ea1dcb80d4bb4..a1087b9ff98a0 100644 --- a/compiler/rustc_mir_build/src/builder/matches/test.rs +++ b/compiler/rustc_mir_build/src/builder/matches/test.rs @@ -348,7 +348,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let source_info = self.source_info(span); let re_erased = self.tcx.lifetimes.re_erased; let trait_item = self.tcx.require_lang_item(trait_item, span); - let method = trait_method(self.tcx, trait_item, method, [ty]); + // FIXME(156581): actually instantiate the binder correctly (turbofishing/fndef changes) + let method = trait_method(self.tcx, trait_item, method, ty::Binder::dummy([ty])); let ref_src = self.temp(Ty::new_ref(self.tcx, re_erased, ty, mutability), span); // `let ref_src = &src_place;` // or `let ref_src = &mut src_place;` @@ -421,7 +422,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { ) { let str_ty = self.tcx.types.str_; let eq_def_id = self.tcx.require_lang_item(LangItem::PartialEq, source_info.span); - let method = trait_method(self.tcx, eq_def_id, sym::eq, [str_ty, str_ty]); + let method = + // FIXME(156581): actually instantiate the binder correctly (turbofishing/fndef changes) + trait_method(self.tcx, eq_def_id, sym::eq, ty::Binder::dummy([str_ty, str_ty])); let bool_ty = self.tcx.types.bool; let eq_result = self.temp(bool_ty, source_info.span); @@ -468,7 +471,7 @@ fn trait_method<'tcx>( tcx: TyCtxt<'tcx>, trait_def_id: DefId, method_name: Symbol, - args: impl IntoIterator>>, + args: ty::Binder<'tcx, impl IntoIterator>>>, ) -> Const<'tcx> { // The unhygienic comparison here is acceptable because this is only // used on known traits. diff --git a/compiler/rustc_mir_build/src/check_tail_calls.rs b/compiler/rustc_mir_build/src/check_tail_calls.rs index 26deba3f58c5a..e148620cc62e2 100644 --- a/compiler/rustc_mir_build/src/check_tail_calls.rs +++ b/compiler/rustc_mir_build/src/check_tail_calls.rs @@ -94,6 +94,7 @@ impl<'tcx> TailCallCkVisitor<'_, 'tcx> { } if let &ty::FnDef(did, args) = ty.kind() { + let args = args.no_bound_vars().unwrap(); // Closures in thir look something akin to // `for<'a> extern "rust-call" fn(&'a [closure@...], ()) -> <[closure@...] as FnOnce<()>>::Output {<[closure@...] as Fn<()>>::call}` // So we have to check for them in this weird way... diff --git a/compiler/rustc_mir_build/src/thir/cx/expr.rs b/compiler/rustc_mir_build/src/thir/cx/expr.rs index 650dcf61c66ac..10dc59a8950fd 100644 --- a/compiler/rustc_mir_build/src/thir/cx/expr.rs +++ b/compiler/rustc_mir_build/src/thir/cx/expr.rs @@ -199,8 +199,12 @@ impl<'tcx> ThirBuildCx<'tcx> { // We don't need to do call adjust_span here since // deref coercions always start with a built-in deref. let call_def_id = deref.method_call(self.tcx); - let overloaded_callee = - Ty::new_fn_def(self.tcx, call_def_id, self.tcx.mk_args(&[expr.ty.into()])); + // FIXME(156581): actually instantiate the binder correctly (turbofishing/fndef changes) + let overloaded_callee = Ty::new_fn_def( + self.tcx, + call_def_id, + ty::Binder::dummy(self.tcx.mk_args(&[expr.ty.into()])), + ); expr = Expr { temp_scope_id, @@ -851,8 +855,12 @@ impl<'tcx> ThirBuildCx<'tcx> { }; let mk_call = |thir: &mut Thir<'tcx>, ty: Ty<'tcx>, variant: VariantIdx, field: FieldIdx| { - let fun_ty = - Ty::new_fn_def(tcx, offset_of_intrinsic, [ty::GenericArg::from(ty)]); + // FIXME(156581): actually instantiate the binder correctly (turbofishing/fndef changes) + let fun_ty = Ty::new_fn_def( + tcx, + offset_of_intrinsic, + ty::Binder::dummy([ty::GenericArg::from(ty)]), + ); let fun = thir .exprs .push(mk_expr(ExprKind::ZstLiteral { user_ty: None }, fun_ty)); @@ -1203,7 +1211,12 @@ impl<'tcx> ThirBuildCx<'tcx> { let user_ty = self.user_args_applied_to_res(expr.hir_id, Res::Def(kind, def_id)); debug!("method_callee: user_ty={:?}", user_ty); ( - Ty::new_fn_def(self.tcx, def_id, self.typeck_results.node_args(expr.hir_id)), + // FIXME: instantiate binder correctly (turbofish/fndex) + Ty::new_fn_def( + self.tcx, + def_id, + ty::Binder::dummy(self.typeck_results.node_args(expr.hir_id)), + ), user_ty, ) } @@ -1237,9 +1250,12 @@ impl<'tcx> ThirBuildCx<'tcx> { Expr { temp_scope_id: expr.hir_id.local_id, - // Create a new FnDef type, representing the splatted function arguments with - // user-supplied generic types applied - ty: Ty::new_fn_def(self.tcx, def_id, self.typeck_results.node_args(expr.hir_id)), + // FIXME(156581): actually instantiate the binder correctly (turbofishing/fndef changes) + ty: Ty::new_fn_def( + self.tcx, + def_id, + ty::Binder::dummy(self.typeck_results.node_args(expr.hir_id)), + ), span, kind: ExprKind::ZstLiteral { user_ty }, } diff --git a/compiler/rustc_mir_build/src/thir/pattern/mod.rs b/compiler/rustc_mir_build/src/thir/pattern/mod.rs index 11b31cb3976c9..07a3c8cc530e9 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/mod.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/mod.rs @@ -548,7 +548,8 @@ impl<'tcx, 'ptcx> PatCtxt<'tcx, 'ptcx> { let adt_def = self.tcx.adt_def(enum_id); if adt_def.is_enum() { let args = match ty.kind() { - ty::Adt(_, args) | ty::FnDef(_, args) => args, + ty::FnDef(_, args) => args.no_bound_vars().unwrap(), + ty::Adt(_, args) => args, ty::Error(e) => { // Avoid ICE (#50585) return Box::new(Pat { diff --git a/compiler/rustc_mir_dataflow/src/rustc_peek.rs b/compiler/rustc_mir_dataflow/src/rustc_peek.rs index 4eb38569e6d48..35c601f09acd4 100644 --- a/compiler/rustc_mir_dataflow/src/rustc_peek.rs +++ b/compiler/rustc_mir_dataflow/src/rustc_peek.rs @@ -163,6 +163,8 @@ impl PeekCall { &terminator.kind && let ty::FnDef(def_id, fn_args) = *func.const_.ty().kind() { + let fn_args = fn_args.no_bound_vars().unwrap(); + if tcx.intrinsic(def_id)?.name != sym::rustc_peek { return None; } diff --git a/compiler/rustc_mir_transform/src/check_call_recursion.rs b/compiler/rustc_mir_transform/src/check_call_recursion.rs index 73c1510b9a0e2..1a3f8fcf5f678 100644 --- a/compiler/rustc_mir_transform/src/check_call_recursion.rs +++ b/compiler/rustc_mir_transform/src/check_call_recursion.rs @@ -143,6 +143,7 @@ impl<'tcx> TerminatorClassifier<'tcx> for CallRecursion<'tcx> { let func_ty = func.ty(body, tcx); if let ty::FnDef(callee, args) = *func_ty.kind() { + let args = args.no_bound_vars().unwrap(); let Ok(normalized_args) = tcx.try_normalize_erasing_regions(typing_env, Unnormalized::new_wip(args)) else { diff --git a/compiler/rustc_mir_transform/src/elaborate_drop.rs b/compiler/rustc_mir_transform/src/elaborate_drop.rs index 7b33240e9e6e1..8b21e8284476b 100644 --- a/compiler/rustc_mir_transform/src/elaborate_drop.rs +++ b/compiler/rustc_mir_transform/src/elaborate_drop.rs @@ -250,7 +250,8 @@ where let fut_ty = tcx .instantiate_bound_regions_with_erased( - Ty::new_fn_def(tcx, async_drop_fn_def_id, [drop_ty]).fn_sig(tcx), + // FIXME(156581): actually instantiate the binder correctly (turbofishing/fndef changes) + Ty::new_fn_def(tcx, async_drop_fn_def_id, ty::Binder::dummy([drop_ty])).fn_sig(tcx), ) .output(); let fut = self.new_temp(fut_ty); @@ -372,7 +373,13 @@ where unwind_with_dead, vec![self.storage_live(fut)], TerminatorKind::Call { - func: Operand::function_handle(tcx, async_drop_fn_def_id, [drop_ty.into()], span), + // FIXME(156581): actually instantiate the binder correctly (turbofishing/fndef changes) + func: Operand::function_handle( + tcx, + async_drop_fn_def_id, + ty::Binder::dummy([drop_ty.into()]), + span, + ), args: [dummy_spanned(drop_arg)].into(), destination: fut.into(), target: Some(succ_yield_loop), @@ -400,7 +407,8 @@ where func: Operand::function_handle( tcx, pin_obj_new_unchecked_fn, - [obj_ref_ty.into()], + // FIXME(156581): actually instantiate the binder correctly (turbofishing/fndef changes) + ty::Binder::dummy([obj_ref_ty.into()]), span, ), args: [dummy_spanned(Operand::Move(obj_ref_place))].into(), @@ -565,7 +573,13 @@ where unwind, Vec::new(), TerminatorKind::Call { - func: Operand::function_handle(tcx, poll_fn, [fut_ty.into()], source_info.span), + // FIXME(156581): actually instantiate the binder correctly (turbofishing/fndef changes) + func: Operand::function_handle( + tcx, + poll_fn, + ty::Binder::dummy([fut_ty.into()]), + source_info.span, + ), args: [ dummy_spanned(Operand::Move(fut_pin_local.into())), dummy_spanned(Operand::Move(context_ref_local.into())), @@ -594,7 +608,11 @@ where func: Operand::function_handle( tcx, get_context_fn, - [tcx.lifetimes.re_erased.into(), tcx.lifetimes.re_erased.into()], + // FIXME(156581): actually instantiate the binder correctly (turbofishing/fndef changes) + ty::Binder::dummy([ + tcx.lifetimes.re_erased.into(), + tcx.lifetimes.re_erased.into(), + ]), source_info.span, ), args: [dummy_spanned(Operand::Move(entry_resume_local.into()))].into(), @@ -624,7 +642,7 @@ where func: Operand::function_handle( tcx, fut_pin_new_unchecked_fn, - [fut_ref_ty.into()], + ty::Binder::dummy([fut_ref_ty.into()]), source_info.span, ), args: [dummy_spanned(Operand::Move(fut_ref_local.into()))].into(), @@ -1246,7 +1264,13 @@ where ), )], TerminatorKind::Call { - func: Operand::function_handle(tcx, drop_fn, [ty.into()], self.source_info.span), + // FIXME(156581): actually instantiate the binder correctly (turbofishing/fndef changes) + func: Operand::function_handle( + tcx, + drop_fn, + ty::Binder::dummy([ty.into()]), + self.source_info.span, + ), args: [dummy_spanned(Operand::Move(Place::from(ref_place)))].into(), destination: unit_temp, target: Some(succ), diff --git a/compiler/rustc_mir_transform/src/function_item_references.rs b/compiler/rustc_mir_transform/src/function_item_references.rs index d88d9231c2009..41d16c00ff64b 100644 --- a/compiler/rustc_mir_transform/src/function_item_references.rs +++ b/compiler/rustc_mir_transform/src/function_item_references.rs @@ -52,7 +52,12 @@ impl<'tcx> Visitor<'tcx> for FunctionItemRefChecker<'_, 'tcx> { } } } else { - self.check_bound_args(def_id, args_ref, args, source_info); + self.check_bound_args( + def_id, + args_ref.no_bound_vars().unwrap(), + args, + source_info, + ); } } } @@ -127,7 +132,7 @@ impl<'tcx> FunctionItemRefChecker<'_, 'tcx> { referent_ty .map(|ref_ty| { if let ty::FnDef(def_id, args_ref) = *ref_ty.kind() { - Some((def_id, args_ref)) + Some((def_id, args_ref.no_bound_vars().unwrap())) } else { None } diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs index c36b687111c01..3249f196cc56d 100644 --- a/compiler/rustc_mir_transform/src/inline.rs +++ b/compiler/rustc_mir_transform/src/inline.rs @@ -560,7 +560,9 @@ fn resolve_callsite<'tcx, I: Inliner<'tcx>>( // To resolve an instance its args have to be fully normalized. let args = tcx .try_normalize_erasing_regions(inliner.typing_env(), Unnormalized::new_wip(args)) - .ok()?; + .ok()? + .no_bound_vars() + .unwrap(); let mut callee = Instance::try_resolve(tcx, inliner.typing_env(), def_id, args).ok().flatten()?; diff --git a/compiler/rustc_mir_transform/src/inline/cycle.rs b/compiler/rustc_mir_transform/src/inline/cycle.rs index b1a9258d48bb3..8c33b0930d438 100644 --- a/compiler/rustc_mir_transform/src/inline/cycle.rs +++ b/compiler/rustc_mir_transform/src/inline/cycle.rs @@ -223,5 +223,5 @@ pub(crate) fn mir_inliner_callees<'tcx>( calls.insert(call); } } - tcx.arena.alloc_from_iter(calls.iter().copied()) + tcx.arena.alloc_from_iter(calls.iter().map(|(did, args)| (*did, args.no_bound_vars().unwrap()))) } diff --git a/compiler/rustc_mir_transform/src/instsimplify.rs b/compiler/rustc_mir_transform/src/instsimplify.rs index 87104364da6af..c5a54d596b4e5 100644 --- a/compiler/rustc_mir_transform/src/instsimplify.rs +++ b/compiler/rustc_mir_transform/src/instsimplify.rs @@ -446,7 +446,7 @@ fn resolve_rust_intrinsic<'tcx>( ) -> Option<(Symbol, GenericArgsRef<'tcx>)> { let ty::FnDef(def_id, args) = *func_ty.kind() else { return None }; let intrinsic = tcx.intrinsic(def_id)?; - Some((intrinsic.name, args)) + Some((intrinsic.name, args.no_bound_vars().unwrap())) } struct SimplifyUbCheck<'tcx> { diff --git a/compiler/rustc_mir_transform/src/lower_intrinsics.rs b/compiler/rustc_mir_transform/src/lower_intrinsics.rs index fe53d301c5574..ba294038d702f 100644 --- a/compiler/rustc_mir_transform/src/lower_intrinsics.rs +++ b/compiler/rustc_mir_transform/src/lower_intrinsics.rs @@ -19,6 +19,7 @@ impl<'tcx> crate::MirPass<'tcx> for LowerIntrinsics { && let ty::FnDef(def_id, generic_args) = *func.ty(local_decls, tcx).kind() && let Some(intrinsic) = tcx.intrinsic(def_id) { + let generic_args = generic_args.no_bound_vars().unwrap(); match intrinsic.name { sym::unreachable => { terminator.kind = TerminatorKind::Unreachable; diff --git a/compiler/rustc_mir_transform/src/shim.rs b/compiler/rustc_mir_transform/src/shim.rs index 830129700a929..7c80201f4f07f 100644 --- a/compiler/rustc_mir_transform/src/shim.rs +++ b/compiler/rustc_mir_transform/src/shim.rs @@ -327,7 +327,13 @@ pub fn build_drop_shim<'tcx>( start.terminator = Some(Terminator { source_info, kind: TerminatorKind::Call { - func: Operand::function_handle(tcx, def_id, [ty::GenericArg::from(slice_ty)], span), + // FIXME(156581): actually instantiate the binder correctly (turbofishing/fndef changes) + func: Operand::function_handle( + tcx, + def_id, + ty::Binder::dummy([ty::GenericArg::from(slice_ty)]), + span, + ), args: Box::new([Spanned { span, node: Operand::Move(Place::from(erased_local)) }]), destination: Place::from(RETURN_PLACE), target: Some(return_block), @@ -618,7 +624,8 @@ impl<'tcx> CloneShimBuilder<'tcx> { let tcx = self.tcx; // `func == Clone::clone(&ty) -> ty` - let func_ty = Ty::new_fn_def(tcx, self.def_id, [ty]); + // FIXME(156581): actually instantiate the binder correctly (turbofishing/fndef changes) + let func_ty = Ty::new_fn_def(tcx, self.def_id, ty::Binder::dummy([ty])); let func = Operand::Constant(Box::new(ConstOperand { span: self.span, user_ty: None, diff --git a/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs b/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs index 1347fd21db057..ccb361cdb0804 100644 --- a/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs +++ b/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs @@ -371,7 +371,13 @@ fn build_adrop_for_adrop_shim<'tcx>( Some(Terminator { source_info, kind: TerminatorKind::Call { - func: Operand::function_handle(tcx, pin_fn, [cor_ref.into()], span), + // FIXME(156581): actually instantiate the binder correctly (turbofishing/fndef changes) + func: Operand::function_handle( + tcx, + pin_fn, + ty::Binder::dummy([cor_ref.into()]), + span, + ), args: [dummy_spanned(Operand::Move(cor_ref_place))].into(), destination: cor_pin_place, target: Some(call_bb), @@ -392,7 +398,13 @@ fn build_adrop_for_adrop_shim<'tcx>( Some(Terminator { source_info, kind: TerminatorKind::Call { - func: Operand::function_handle(tcx, poll_fn, [impl_ty.into()], span), + // FIXME(156581): actually instantiate the binder correctly (turbofishing/fndef changes) + func: Operand::function_handle( + tcx, + poll_fn, + ty::Binder::dummy([impl_ty.into()]), + span, + ), args: [ dummy_spanned(Operand::Move(cor_pin_place)), dummy_spanned(Operand::Move(resume_ctx)), diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index 9b18b22399ae8..f7c10a6ffed7c 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -843,7 +843,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirUsedCollector<'a, 'tcx> { self.tcx, ty::TypingEnv::fully_monomorphized(), def_id, - args, + args.no_bound_vars().unwrap(), source, ) && instance.def.requires_caller_location(self.tcx) @@ -952,6 +952,7 @@ fn visit_fn_use<'tcx>( output: &mut MonoItems<'tcx>, ) { if let ty::FnDef(def_id, args) = *ty.kind() { + let args = args.no_bound_vars().unwrap(); let instance = if is_direct_call { ty::Instance::expect_resolve( tcx, @@ -1400,6 +1401,7 @@ fn visit_mentioned_item<'tcx>( match *item { MentionedItem::Fn(ty) => { if let ty::FnDef(def_id, args) = *ty.kind() { + let args = args.no_bound_vars().unwrap(); let instance = Instance::expect_resolve( tcx, ty::TypingEnv::fully_monomorphized(), diff --git a/compiler/rustc_monomorphize/src/mono_checks/abi_check.rs b/compiler/rustc_monomorphize/src/mono_checks/abi_check.rs index 0e30f1f3828e6..4479ce2dba08b 100644 --- a/compiler/rustc_monomorphize/src/mono_checks/abi_check.rs +++ b/compiler/rustc_monomorphize/src/mono_checks/abi_check.rs @@ -215,7 +215,13 @@ fn check_call_site_abi<'tcx>( if tcx.intrinsic(def_id).is_some() { return; } - let instance = ty::Instance::expect_resolve(tcx, typing_env, def_id, args, DUMMY_SP); + let instance = ty::Instance::expect_resolve( + tcx, + typing_env, + def_id, + args.no_bound_vars().unwrap(), + DUMMY_SP, + ); tcx.fn_abi_of_instance(typing_env.as_query_input((instance, ty::List::empty()))) } _ => { diff --git a/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs b/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs index 5bc56eae7755d..2703848162b3d 100644 --- a/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs +++ b/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs @@ -291,7 +291,7 @@ pub(in crate::solve) fn extract_tupled_inputs_and_output_from_callable( ) -> Result<(ty::Binder, I::DefId, I::GenericArgs), NoSolution> { match self_ty.kind() { ty::FnDef(def_id, args) => { + // FIXME + let args = args.no_bound_vars().unwrap(); + let sig = cx.fn_sig(def_id); if sig.skip_binder().is_fn_trait_compatible() && !cx.has_target_features(def_id) diff --git a/compiler/rustc_public/src/unstable/convert/internal.rs b/compiler/rustc_public/src/unstable/convert/internal.rs index 181498443073d..2f174eeee0059 100644 --- a/compiler/rustc_public/src/unstable/convert/internal.rs +++ b/compiler/rustc_public/src/unstable/convert/internal.rs @@ -171,9 +171,10 @@ impl RustcInternal for RigidTy { mutability.internal(tables, tcx), ), RigidTy::Foreign(def) => rustc_ty::TyKind::Foreign(def.0.internal(tables, tcx)), - RigidTy::FnDef(def, args) => { - rustc_ty::TyKind::FnDef(def.0.internal(tables, tcx), args.internal(tables, tcx)) - } + RigidTy::FnDef(def, args) => rustc_ty::TyKind::FnDef( + def.0.internal(tables, tcx), + rustc_middle::ty::Binder::dummy(args.internal(tables, tcx)), + ), RigidTy::FnPtr(sig) => { let (sig_tys, hdr) = sig.internal(tables, tcx).split(); rustc_ty::TyKind::FnPtr(sig_tys, hdr) diff --git a/compiler/rustc_public/src/unstable/convert/stable/ty.rs b/compiler/rustc_public/src/unstable/convert/stable/ty.rs index e0e212ee47d59..640e83e0d2ee6 100644 --- a/compiler/rustc_public/src/unstable/convert/stable/ty.rs +++ b/compiler/rustc_public/src/unstable/convert/stable/ty.rs @@ -460,7 +460,7 @@ impl<'tcx> Stable<'tcx> for ty::TyKind<'tcx> { )), ty::FnDef(def_id, generic_args) => TyKind::RigidTy(RigidTy::FnDef( tables.fn_def(*def_id), - generic_args.stable(tables, cx), + generic_args.no_bound_vars().unwrap().stable(tables, cx), )), ty::FnPtr(sig_tys, hdr) => { TyKind::RigidTy(RigidTy::FnPtr(sig_tys.with(*hdr).stable(tables, cx))) diff --git a/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/encode.rs b/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/encode.rs index 873ed9bb10398..13ae0395035bd 100644 --- a/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/encode.rs +++ b/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/encode.rs @@ -508,7 +508,7 @@ pub(crate) fn encode_ty<'tcx>( } // Function types - ty::FnDef(def_id, args) | ty::Closure(def_id, args) => { + ty::Closure(def_id, args) => { // u[IE], where is , // as vendor extended type. let mut s = String::new(); @@ -519,6 +519,23 @@ pub(crate) fn encode_ty<'tcx>( typeid.push_str(&s); } + // FIXME: could stand to merge this and the prior match arm + ty::FnDef(def_id, args) => { + let mut s = String::new(); + let name = encode_ty_name(tcx, *def_id); + let _ = write!(s, "u{}{}", name.len(), name); + s.push_str(&encode_args( + tcx, + args.no_bound_vars().unwrap(), + *def_id, + false, + dict, + options, + )); + compress(dict, DictKey::Ty(ty, TyQ::None), &mut s); + typeid.push_str(&s); + } + ty::CoroutineClosure(def_id, args) => { // u[IE], where is , // as vendor extended type. diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 9ab27cd1a4918..8af05adcd08bf 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1173,6 +1173,7 @@ symbols! { large_assignments, last, lasx, + late_bound_turbofishing, lateout, lazy_normalization_consts, lazy_type_alias, diff --git a/compiler/rustc_symbol_mangling/src/legacy.rs b/compiler/rustc_symbol_mangling/src/legacy.rs index 5e021eb5667d4..4cce56cf90426 100644 --- a/compiler/rustc_symbol_mangling/src/legacy.rs +++ b/compiler/rustc_symbol_mangling/src/legacy.rs @@ -245,8 +245,7 @@ impl<'tcx> Printer<'tcx> for LegacySymbolMangler<'tcx> { fn print_type(&mut self, ty: Ty<'tcx>) -> Result<(), PrintError> { match *ty.kind() { // Print all nominal types as paths (unlike `pretty_print_type`). - ty::FnDef(def_id, args) - | ty::Alias( + ty::Alias( _, ty::AliasTy { kind: ty::Projection { def_id } | ty::Opaque { def_id }, args, .. @@ -256,6 +255,8 @@ impl<'tcx> Printer<'tcx> for LegacySymbolMangler<'tcx> { | ty::CoroutineClosure(def_id, args) | ty::Coroutine(def_id, args) => self.print_def_path(def_id, args), + ty::FnDef(def_id, args) => self.print_def_path(def_id, args.no_bound_vars().unwrap()), + // The `pretty_print_type` formatting of array size depends on // -Zverbose-internals flag, so we cannot reuse it here. ty::Array(ty, size) => { diff --git a/compiler/rustc_symbol_mangling/src/v0.rs b/compiler/rustc_symbol_mangling/src/v0.rs index b26545fa2b4b0..b543286aee2f7 100644 --- a/compiler/rustc_symbol_mangling/src/v0.rs +++ b/compiler/rustc_symbol_mangling/src/v0.rs @@ -545,13 +545,16 @@ impl<'tcx> Printer<'tcx> for V0SymbolMangler<'tcx> { // Mangle all nominal types as paths. ty::Adt(ty::AdtDef(Interned(&ty::AdtDefData { did: def_id, .. }, _)), args) - | ty::FnDef(def_id, args) | ty::Closure(def_id, args) | ty::CoroutineClosure(def_id, args) | ty::Coroutine(def_id, args) => { self.print_def_path(def_id, args)?; } + ty::FnDef(def_id, args) => { + self.print_def_path(def_id, args.no_bound_vars().unwrap())? + } + // We may still encounter projections here due to the printing // logic sometimes passing identity-substituted impl headers. ty::Alias(_, ty::AliasTy { kind: ty::Projection { def_id }, args, .. }) => { diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs index 63a55c32b54ce..581e960568cef 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs @@ -1284,17 +1284,23 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { } (ty::FnDef(did1, args1), ty::FnDef(did2, args2)) => { + let args1 = args1.no_bound_vars().unwrap(); + let args2 = args2.no_bound_vars().unwrap(); + let sig1 = self.tcx.fn_sig(*did1).instantiate(self.tcx, args1).skip_norm_wip(); let sig2 = self.tcx.fn_sig(*did2).instantiate(self.tcx, args2).skip_norm_wip(); self.cmp_fn_sig(sig1, Some((*did1, Some(args1))), sig2, Some((*did2, Some(args2)))) } (ty::FnDef(did1, args1), ty::FnPtr(sig_tys2, hdr2)) => { + let args1 = args1.no_bound_vars().unwrap(); let sig1 = self.tcx.fn_sig(*did1).instantiate(self.tcx, args1).skip_norm_wip(); self.cmp_fn_sig(sig1, Some((*did1, Some(args1))), sig_tys2.with(*hdr2), None) } (ty::FnPtr(sig_tys1, hdr1), ty::FnDef(did2, args2)) => { + let args2 = args2.no_bound_vars().unwrap(); + let sig2 = self.tcx.fn_sig(*did2).instantiate(self.tcx, args2).skip_norm_wip(); self.cmp_fn_sig(sig_tys1.with(*hdr1), None, sig2, Some((*did2, Some(args2)))) } diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs index 71f81bb633ba6..5bd9a9c52de7f 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs @@ -411,6 +411,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { } match (expected_inner.kind(), found_inner.kind()) { (ty::FnPtr(sig_tys, hdr), ty::FnDef(did, args)) => { + let args = args.no_bound_vars().unwrap(); + let sig = sig_tys.with(*hdr); let expected_sig = self.normalize_fn_sig(Unnormalized::new_wip(sig)); let found_sig = @@ -449,6 +451,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { diag.subdiagnostic(sugg); } (ty::FnDef(did1, args1), ty::FnDef(did2, args2)) => { + let args1 = args1.no_bound_vars().unwrap(); + let args2 = args2.no_bound_vars().unwrap(); + let expected_sig = self.normalize_fn_sig(self.tcx.fn_sig(*did1).instantiate(self.tcx, args1)); let found_sig = @@ -492,6 +497,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { diag.subdiagnostic(sug); } (ty::FnDef(did, args), ty::FnPtr(sig_tys, hdr)) => { + let args = args.no_bound_vars().unwrap(); + let expected_sig = self.normalize_fn_sig(self.tcx.fn_sig(*did).instantiate(self.tcx, args)); let found_sig = self.normalize_fn_sig(Unnormalized::new_wip(sig_tys.with(*hdr))); diff --git a/compiler/rustc_trait_selection/src/traits/effects.rs b/compiler/rustc_trait_selection/src/traits/effects.rs index 449fdbaca9abc..0244bb5c1de46 100644 --- a/compiler/rustc_trait_selection/src/traits/effects.rs +++ b/compiler/rustc_trait_selection/src/traits/effects.rs @@ -558,7 +558,7 @@ fn evaluate_host_effect_for_fn_goal<'tcx>( // but they don't really need to right now. ty::CoroutineClosure(_, _) => return Err(EvaluationFailure::NoSolution), - ty::Closure(def, args) => (def, args), + ty::Closure(def, args) => (def, ty::Binder::dummy(args)), // Everything else needs explicit impls or cannot have an impl _ => return Err(EvaluationFailure::NoSolution), @@ -569,7 +569,7 @@ fn evaluate_host_effect_for_fn_goal<'tcx>( hir::Constness::Const { always: true } => Err(EvaluationFailure::NoSolution), hir::Constness::Const { always: false } => Ok(tcx .const_conditions(def) - .instantiate(tcx, args) + .instantiate(tcx, args.no_bound_vars().unwrap()) .into_iter() .map(|(c, span)| { let code = ObligationCauseCode::WhereClause(def, span); diff --git a/compiler/rustc_trait_selection/src/traits/wf.rs b/compiler/rustc_trait_selection/src/traits/wf.rs index 8ecea8279aac1..b1d19d0cafbda 100644 --- a/compiler/rustc_trait_selection/src/traits/wf.rs +++ b/compiler/rustc_trait_selection/src/traits/wf.rs @@ -824,6 +824,7 @@ impl<'a, 'tcx> TypeVisitor> for WfPredicates<'a, 'tcx> { } ty::FnDef(did, args) => { + let args = args.no_bound_vars().unwrap(); // HACK: Check the return type of function definitions for // well-formedness to mostly fix #84533. This is still not // perfect and there may be ways to abuse the fact that we diff --git a/compiler/rustc_ty_utils/src/abi.rs b/compiler/rustc_ty_utils/src/abi.rs index 8873fb13efe03..9c067d917414d 100644 --- a/compiler/rustc_ty_utils/src/abi.rs +++ b/compiler/rustc_ty_utils/src/abi.rs @@ -46,7 +46,7 @@ fn fn_sig_for_fn_abi<'tcx>( match *ty.kind() { ty::FnDef(def_id, args) => { let mut sig = tcx.instantiate_bound_regions_with_erased( - tcx.fn_sig(def_id).instantiate(tcx, args).skip_norm_wip(), + tcx.fn_sig(def_id).instantiate(tcx, args.no_bound_vars().unwrap()).skip_norm_wip(), ); // Modify `fn(self, ...)` to `fn(self: *mut Self, ...)`. diff --git a/compiler/rustc_ty_utils/src/assoc.rs b/compiler/rustc_ty_utils/src/assoc.rs index 268386692dc3f..de94087498c75 100644 --- a/compiler/rustc_ty_utils/src/assoc.rs +++ b/compiler/rustc_ty_utils/src/assoc.rs @@ -343,7 +343,7 @@ fn associated_type_for_impl_trait_in_impl( let mut own_params = trait_assoc_generics.own_params.clone(); let parent_generics = tcx.generics_of(impl_local_def_id.to_def_id()); - let parent_count = parent_generics.parent_count + parent_generics.own_params.len(); + let parent_count = parent_generics.count(); for param in &mut own_params { param.index = param.index + parent_count as u32 - trait_assoc_parent_count as u32; diff --git a/compiler/rustc_type_ir/src/binder.rs b/compiler/rustc_type_ir/src/binder.rs index 6f41a608763e3..4266429002675 100644 --- a/compiler/rustc_type_ir/src/binder.rs +++ b/compiler/rustc_type_ir/src/binder.rs @@ -74,6 +74,32 @@ impl_binder_encode_decode! { ty::HostEffectPredicate, } +#[cfg(feature = "nightly")] +impl, I: Interner, E: rustc_serialize::Encoder> + rustc_serialize::Encodable for ty::Binder +where + T: rustc_serialize::Encodable, + I::BoundVarKinds: rustc_serialize::Encodable, +{ + fn encode(&self, e: &mut E) { + self.bound_vars().encode(e); + self.as_ref().skip_binder().encode(e); + } +} + +#[cfg(feature = "nightly")] +impl, I: Interner, D: rustc_serialize::Decoder> + rustc_serialize::Decodable for ty::Binder +where + T: TypeVisitable + rustc_serialize::Decodable, + I::BoundVarKinds: rustc_serialize::Decodable, +{ + fn decode(decoder: &mut D) -> Self { + let bound_vars = rustc_serialize::Decodable::decode(decoder); + ty::Binder::bind_with_vars(rustc_serialize::Decodable::decode(decoder), bound_vars) + } +} + impl Binder where T: TypeVisitable, diff --git a/compiler/rustc_type_ir/src/fast_reject.rs b/compiler/rustc_type_ir/src/fast_reject.rs index c0329b4f6226d..9b50657b6b8b1 100644 --- a/compiler/rustc_type_ir/src/fast_reject.rs +++ b/compiler/rustc_type_ir/src/fast_reject.rs @@ -425,7 +425,12 @@ impl match rhs.kind() { ty::FnDef(rhs_def_id, rhs_args) => { - lhs_def_id == rhs_def_id && self.args_may_unify_inner(lhs_args, rhs_args, depth) + lhs_def_id == rhs_def_id + && self.args_may_unify_inner( + lhs_args.no_bound_vars().unwrap(), + rhs_args.no_bound_vars().unwrap(), + depth, + ) } _ => false, }, diff --git a/compiler/rustc_type_ir/src/flags.rs b/compiler/rustc_type_ir/src/flags.rs index 214a83a9b491b..8c08691e4d1fe 100644 --- a/compiler/rustc_type_ir/src/flags.rs +++ b/compiler/rustc_type_ir/src/flags.rs @@ -360,7 +360,7 @@ impl FlagComputation { } ty::FnDef(_, args) => { - self.add_args(args.as_slice()); + self.add_binder_args(args); } ty::FnPtr(sig_tys, _) => self.bound_computation(sig_tys, |computation, sig_tys| { @@ -538,6 +538,18 @@ impl FlagComputation { } } + fn add_binder_args(&mut self, args: ty::Binder) { + self.bound_computation(args, |this, args| { + for arg in args.iter() { + match arg.kind() { + ty::GenericArgKind::Type(ty) => this.add_ty(ty), + ty::GenericArgKind::Lifetime(r) => this.add_region(r), + ty::GenericArgKind::Const(ct) => this.add_const(ct), + } + } + }); + } + fn add_is_rigid(&mut self, is_rigid: ty::IsRigid) { match is_rigid { ty::IsRigid::Yes => self.add_flags(TypeFlags::HAS_RIGID_ALIAS), diff --git a/compiler/rustc_type_ir/src/inherent.rs b/compiler/rustc_type_ir/src/inherent.rs index 6dcb5b5bceaa4..7e9e53e0a6190 100644 --- a/compiler/rustc_type_ir/src/inherent.rs +++ b/compiler/rustc_type_ir/src/inherent.rs @@ -122,7 +122,7 @@ pub trait Ty>: It: Iterator, T: CollectAndApply; - fn new_fn_def(interner: I, def_id: I::FunctionId, args: I::GenericArgs) -> Self; + fn new_fn_def(interner: I, def_id: I::FunctionId, args: ty::Binder) -> Self; fn new_fn_ptr(interner: I, sig: ty::Binder>) -> Self; diff --git a/compiler/rustc_type_ir/src/outlives.rs b/compiler/rustc_type_ir/src/outlives.rs index e8c32d0cc1f6f..876aef9d7f705 100644 --- a/compiler/rustc_type_ir/src/outlives.rs +++ b/compiler/rustc_type_ir/src/outlives.rs @@ -82,6 +82,7 @@ impl TypeVisitor for OutlivesCollector<'_, I> { // projection). match ty.kind() { ty::FnDef(_, args) => { + let args = args.no_bound_vars().unwrap(); // HACK(eddyb) ignore lifetimes found shallowly in `args`. // This is inconsistent with `ty::Adt` (including all args) // and with `ty::Closure` (ignoring all args other than diff --git a/compiler/rustc_type_ir/src/relate.rs b/compiler/rustc_type_ir/src/relate.rs index 1922cbd954cf8..b0a30773731eb 100644 --- a/compiler/rustc_type_ir/src/relate.rs +++ b/compiler/rustc_type_ir/src/relate.rs @@ -512,11 +512,14 @@ pub fn structurally_relate_tys>( } (ty::FnDef(a_def_id, a_args), ty::FnDef(b_def_id, b_args)) if a_def_id == b_def_id => { - if a_args.is_empty() { + if a_args.skip_binder().is_empty() { Ok(a) } else { + let a_args = a_args.no_bound_vars().unwrap(); + let b_args = b_args.no_bound_vars().unwrap(); relation.relate_ty_args(a, b, a_def_id.into(), a_args, b_args, |args| { - Ty::new_fn_def(cx, a_def_id, args) + // FIXME(156581): actually instantiate the binder correctly (turbofishing/fndef changes) + Ty::new_fn_def(cx, a_def_id, ty::Binder::dummy(args)) }) } } diff --git a/compiler/rustc_type_ir/src/ty_kind.rs b/compiler/rustc_type_ir/src/ty_kind.rs index 244c81c54af16..68eebb1122928 100644 --- a/compiler/rustc_type_ir/src/ty_kind.rs +++ b/compiler/rustc_type_ir/src/ty_kind.rs @@ -212,7 +212,7 @@ pub enum TyKind { /// fn foo() -> i32 { 1 } /// let bar = foo; // bar: fn() -> i32 {foo} /// ``` - FnDef(I::FunctionId, I::GenericArgs), + FnDef(I::FunctionId, ty::Binder), /// A pointer to a function. /// @@ -354,9 +354,10 @@ impl TyKind { pub fn fn_sig(self, interner: I) -> ty::Binder> { match self { ty::FnPtr(sig_tys, hdr) => sig_tys.with(hdr), - ty::FnDef(def_id, args) => { - interner.fn_sig(def_id).instantiate(interner, args).skip_norm_wip() - } + ty::FnDef(def_id, args) => interner + .fn_sig(def_id) + .instantiate(interner, args.no_bound_vars().unwrap()) + .skip_norm_wip(), ty::Error(_) => { // ignore errors (#54954) ty::Binder::dummy(ty::FnSig::dummy()) diff --git a/compiler/rustc_type_ir/src/walk.rs b/compiler/rustc_type_ir/src/walk.rs index d2442358b13cb..11c81c47b4cf5 100644 --- a/compiler/rustc_type_ir/src/walk.rs +++ b/compiler/rustc_type_ir/src/walk.rs @@ -135,10 +135,12 @@ fn push_inner(stack: &mut TypeWalkerStack, parent: I::GenericArg | ty::Closure(_, args) | ty::CoroutineClosure(_, args) | ty::Coroutine(_, args) - | ty::CoroutineWitness(_, args) - | ty::FnDef(_, args) => { + | ty::CoroutineWitness(_, args) => { stack.extend(args.iter().rev()); } + ty::FnDef(_, args) => { + stack.extend(args.no_bound_vars().unwrap().iter().rev()); + } ty::Tuple(ts) => stack.extend(ts.iter().rev().map(|ty| ty.into())), ty::FnPtr(sig_tys, _hdr) => { stack.extend( diff --git a/src/tools/clippy/clippy_lints/src/casts/confusing_method_to_numeric_cast.rs b/src/tools/clippy/clippy_lints/src/casts/confusing_method_to_numeric_cast.rs index 1dbcfafd6b3d3..740326d2f9420 100644 --- a/src/tools/clippy/clippy_lints/src/casts/confusing_method_to_numeric_cast.rs +++ b/src/tools/clippy/clippy_lints/src/casts/confusing_method_to_numeric_cast.rs @@ -65,7 +65,8 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>, if let ty::FnDef(def_id, generics) = cast_from.kind() && let Some(method_name) = cx.tcx.opt_item_name(*def_id) - && let Some((const_name, ty_name)) = get_const_name_and_ty_name(cx, method_name, *def_id, generics.as_slice()) + && let Some((const_name, ty_name)) = + get_const_name_and_ty_name(cx, method_name, *def_id, generics.no_bound_vars().unwrap().as_slice()) { let mut applicability = Applicability::MaybeIncorrect; let from_snippet = snippet_with_applicability(cx, cast_expr.span, "..", &mut applicability); diff --git a/src/tools/clippy/clippy_lints/src/methods/map_clone.rs b/src/tools/clippy/clippy_lints/src/methods/map_clone.rs index efbb094d49c79..b88a0fe2a7775 100644 --- a/src/tools/clippy/clippy_lints/src/methods/map_clone.rs +++ b/src/tools/clippy/clippy_lints/src/methods/map_clone.rs @@ -121,7 +121,7 @@ fn handle_path( && let Some(ty) = args.iter().find_map(|generic_arg| generic_arg.as_type()) && let ty::Ref(_, ty, Mutability::Not) = ty.kind() && let ty::FnDef(_, lst) = cx.typeck_results().expr_ty(arg).kind() - && lst.iter().all(|l| l.as_type() == Some(*ty)) + && lst.iter().all(|l| l.no_bound_vars().unwrap().as_type() == Some(*ty)) && !should_call_clone_as_function(cx, *ty) { lint_path(cx, e.span, recv.span, is_copy(cx, ty.peel_refs())); diff --git a/src/tools/clippy/clippy_lints/src/methods/or_fun_call.rs b/src/tools/clippy/clippy_lints/src/methods/or_fun_call.rs index 6f9e817490c12..7b2f2e9389e14 100644 --- a/src/tools/clippy/clippy_lints/src/methods/or_fun_call.rs +++ b/src/tools/clippy/clippy_lints/src/methods/or_fun_call.rs @@ -161,7 +161,7 @@ fn check_unwrap_or_default( let output_ty = cx .tcx .fn_sig(def_id) - .instantiate(cx.tcx, args) + .instantiate(cx.tcx, args.no_bound_vars().unwrap()) .skip_norm_wip() .skip_binder() .output(); diff --git a/src/tools/clippy/clippy_lints/src/useless_conversion.rs b/src/tools/clippy/clippy_lints/src/useless_conversion.rs index dcff26f7d6443..2961ee7081533 100644 --- a/src/tools/clippy/clippy_lints/src/useless_conversion.rs +++ b/src/tools/clippy/clippy_lints/src/useless_conversion.rs @@ -187,7 +187,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion { Some(sym::Into | sym::From) ) && let ty::FnDef(_, args) = cx.typeck_results().expr_ty(arg).kind() - && let &[from_ty, to_ty] = args.into_type_list(cx.tcx).as_slice() + && let &[from_ty, to_ty] = args.no_bound_vars().unwrap().into_type_list(cx.tcx).as_slice() && same_type_modulo_regions(from_ty, to_ty) { span_lint_and_then( diff --git a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs index 5c61f424adf1a..26adf25a348fc 100644 --- a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs +++ b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs @@ -369,7 +369,12 @@ fn check_terminator<'tcx>( // FIXME: when analyzing a function with generic parameters, we may not have enough information to // resolve to an instance. However, we could check if a host effect predicate can guarantee that // this can be made a `const` call. - let fn_def_id = match Instance::try_resolve(cx.tcx, cx.typing_env(), *fn_def_id, fn_substs) { + let fn_def_id = match Instance::try_resolve( + cx.tcx, + cx.typing_env(), + *fn_def_id, + fn_substs.no_bound_vars().unwrap(), + ) { Ok(Some(fn_inst)) => fn_inst.def_id(), Ok(None) => return Err((span, format!("cannot resolve instance for {func:?}").into())), Err(_) => return Err((span, format!("error during instance resolution of {func:?}").into())), diff --git a/src/tools/clippy/clippy_utils/src/ty/mod.rs b/src/tools/clippy/clippy_utils/src/ty/mod.rs index e4541eb2d6061..d7298b5de2a1b 100644 --- a/src/tools/clippy/clippy_utils/src/ty/mod.rs +++ b/src/tools/clippy/clippy_utils/src/ty/mod.rs @@ -713,7 +713,7 @@ pub fn ty_sig<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option Some(ExprFnSig::Sig( - cx.tcx.fn_sig(id).instantiate(cx.tcx, subs).skip_norm_wip(), + cx.tcx.fn_sig(id).instantiate(cx.tcx, subs.no_bound_vars().unwrap()).skip_norm_wip(), Some(id), )), ty::Alias(_, AliasTy { diff --git a/tests/ui/symbol-names/basic.legacy.stderr b/tests/ui/symbol-names/basic.legacy.stderr index 59085aeb3279b..9c30ebdf30b88 100644 --- a/tests/ui/symbol-names/basic.legacy.stderr +++ b/tests/ui/symbol-names/basic.legacy.stderr @@ -1,10 +1,10 @@ -error: symbol-name(_ZN5basic4main17h33f35fba43592008E) +error: symbol-name(_ZN5basic4main17hd30beb15618b9d64E) --> $DIR/basic.rs:8:1 | LL | #[rustc_dump_symbol_name] | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: demangling(basic::main::h33f35fba43592008) +error: demangling(basic::main::hd30beb15618b9d64) --> $DIR/basic.rs:8:1 | LL | #[rustc_dump_symbol_name] diff --git a/tests/ui/symbol-names/issue-60925.legacy.stderr b/tests/ui/symbol-names/issue-60925.legacy.stderr index 367c2d14011ac..0411d70119235 100644 --- a/tests/ui/symbol-names/issue-60925.legacy.stderr +++ b/tests/ui/symbol-names/issue-60925.legacy.stderr @@ -1,10 +1,10 @@ -error: symbol-name(_ZN11issue_609253foo37Foo$LT$issue_60925..llv$u6d$..Foo$GT$3foo17hc741419c44ba4d79E) +error: symbol-name(_ZN11issue_609253foo37Foo$LT$issue_60925..llv$u6d$..Foo$GT$3foo17heb0a993da0d0e50cE) --> $DIR/issue-60925.rs:21:9 | LL | #[rustc_dump_symbol_name] | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: demangling(issue_60925::foo::Foo::foo::hc741419c44ba4d79) +error: demangling(issue_60925::foo::Foo::foo::heb0a993da0d0e50c) --> $DIR/issue-60925.rs:21:9 | LL | #[rustc_dump_symbol_name] diff --git a/tests/ui/thir-print/offset_of.stdout b/tests/ui/thir-print/offset_of.stdout index 25c0994387543..7de24c33f6746 100644 --- a/tests/ui/thir-print/offset_of.stdout +++ b/tests/ui/thir-print/offset_of.stdout @@ -315,12 +315,12 @@ body: span: $SRC_DIR/core/src/mem/mod.rs:LL:COL (#4) kind: Call { - ty: FnDef(DefId(core::intrinsics::offset_of), [Alpha]) + ty: FnDef(DefId(core::intrinsics::offset_of), Binder { value: [Alpha], bound_vars: [] }) from_hir_call: false fn_span: $SRC_DIR/core/src/mem/mod.rs:LL:COL (#4) fun: Expr { - ty: FnDef(DefId(core::intrinsics::offset_of), [Alpha]) + ty: FnDef(DefId(core::intrinsics::offset_of), Binder { value: [Alpha], bound_vars: [] }) temp_scope_id: 7 span: $SRC_DIR/core/src/mem/mod.rs:LL:COL (#4) kind: @@ -398,12 +398,12 @@ body: span: $SRC_DIR/core/src/mem/mod.rs:LL:COL (#5) kind: Call { - ty: FnDef(DefId(core::intrinsics::offset_of), [Alpha]) + ty: FnDef(DefId(core::intrinsics::offset_of), Binder { value: [Alpha], bound_vars: [] }) from_hir_call: false fn_span: $SRC_DIR/core/src/mem/mod.rs:LL:COL (#5) fun: Expr { - ty: FnDef(DefId(core::intrinsics::offset_of), [Alpha]) + ty: FnDef(DefId(core::intrinsics::offset_of), Binder { value: [Alpha], bound_vars: [] }) temp_scope_id: 17 span: $SRC_DIR/core/src/mem/mod.rs:LL:COL (#5) kind: @@ -481,12 +481,12 @@ body: span: $SRC_DIR/core/src/mem/mod.rs:LL:COL (#6) kind: Call { - ty: FnDef(DefId(core::intrinsics::offset_of), [Blah]) + ty: FnDef(DefId(core::intrinsics::offset_of), Binder { value: [Blah], bound_vars: [] }) from_hir_call: false fn_span: $SRC_DIR/core/src/mem/mod.rs:LL:COL (#6) fun: Expr { - ty: FnDef(DefId(core::intrinsics::offset_of), [Blah]) + ty: FnDef(DefId(core::intrinsics::offset_of), Binder { value: [Blah], bound_vars: [] }) temp_scope_id: 27 span: $SRC_DIR/core/src/mem/mod.rs:LL:COL (#6) kind: @@ -572,12 +572,12 @@ body: span: $SRC_DIR/core/src/mem/mod.rs:LL:COL (#7) kind: Call { - ty: FnDef(DefId(core::intrinsics::offset_of), [Alpha]) + ty: FnDef(DefId(core::intrinsics::offset_of), Binder { value: [Alpha], bound_vars: [] }) from_hir_call: false fn_span: $SRC_DIR/core/src/mem/mod.rs:LL:COL (#7) fun: Expr { - ty: FnDef(DefId(core::intrinsics::offset_of), [Alpha]) + ty: FnDef(DefId(core::intrinsics::offset_of), Binder { value: [Alpha], bound_vars: [] }) temp_scope_id: 37 span: $SRC_DIR/core/src/mem/mod.rs:LL:COL (#7) kind: @@ -614,12 +614,12 @@ body: span: $SRC_DIR/core/src/mem/mod.rs:LL:COL (#7) kind: Call { - ty: FnDef(DefId(core::intrinsics::offset_of), [Beta]) + ty: FnDef(DefId(core::intrinsics::offset_of), Binder { value: [Beta], bound_vars: [] }) from_hir_call: false fn_span: $SRC_DIR/core/src/mem/mod.rs:LL:COL (#7) fun: Expr { - ty: FnDef(DefId(core::intrinsics::offset_of), [Beta]) + ty: FnDef(DefId(core::intrinsics::offset_of), Binder { value: [Beta], bound_vars: [] }) temp_scope_id: 37 span: $SRC_DIR/core/src/mem/mod.rs:LL:COL (#7) kind: @@ -707,12 +707,12 @@ body: span: $SRC_DIR/core/src/mem/mod.rs:LL:COL (#8) kind: Call { - ty: FnDef(DefId(core::intrinsics::offset_of), [Alpha]) + ty: FnDef(DefId(core::intrinsics::offset_of), Binder { value: [Alpha], bound_vars: [] }) from_hir_call: false fn_span: $SRC_DIR/core/src/mem/mod.rs:LL:COL (#8) fun: Expr { - ty: FnDef(DefId(core::intrinsics::offset_of), [Alpha]) + ty: FnDef(DefId(core::intrinsics::offset_of), Binder { value: [Alpha], bound_vars: [] }) temp_scope_id: 47 span: $SRC_DIR/core/src/mem/mod.rs:LL:COL (#8) kind: @@ -749,12 +749,12 @@ body: span: $SRC_DIR/core/src/mem/mod.rs:LL:COL (#8) kind: Call { - ty: FnDef(DefId(core::intrinsics::offset_of), [Beta]) + ty: FnDef(DefId(core::intrinsics::offset_of), Binder { value: [Beta], bound_vars: [] }) from_hir_call: false fn_span: $SRC_DIR/core/src/mem/mod.rs:LL:COL (#8) fun: Expr { - ty: FnDef(DefId(core::intrinsics::offset_of), [Beta]) + ty: FnDef(DefId(core::intrinsics::offset_of), Binder { value: [Beta], bound_vars: [] }) temp_scope_id: 47 span: $SRC_DIR/core/src/mem/mod.rs:LL:COL (#8) kind: @@ -1062,12 +1062,12 @@ body: span: $SRC_DIR/core/src/mem/mod.rs:LL:COL (#9) kind: Call { - ty: FnDef(DefId(core::intrinsics::offset_of), [Gamma]) + ty: FnDef(DefId(core::intrinsics::offset_of), Binder { value: [Gamma], bound_vars: [] }) from_hir_call: false fn_span: $SRC_DIR/core/src/mem/mod.rs:LL:COL (#9) fun: Expr { - ty: FnDef(DefId(core::intrinsics::offset_of), [Gamma]) + ty: FnDef(DefId(core::intrinsics::offset_of), Binder { value: [Gamma], bound_vars: [] }) temp_scope_id: 7 span: $SRC_DIR/core/src/mem/mod.rs:LL:COL (#9) kind: @@ -1145,12 +1145,12 @@ body: span: $SRC_DIR/core/src/mem/mod.rs:LL:COL (#10) kind: Call { - ty: FnDef(DefId(core::intrinsics::offset_of), [Gamma]) + ty: FnDef(DefId(core::intrinsics::offset_of), Binder { value: [Gamma], bound_vars: [] }) from_hir_call: false fn_span: $SRC_DIR/core/src/mem/mod.rs:LL:COL (#10) fun: Expr { - ty: FnDef(DefId(core::intrinsics::offset_of), [Gamma]) + ty: FnDef(DefId(core::intrinsics::offset_of), Binder { value: [Gamma], bound_vars: [] }) temp_scope_id: 19 span: $SRC_DIR/core/src/mem/mod.rs:LL:COL (#10) kind: @@ -1228,12 +1228,12 @@ body: span: $SRC_DIR/core/src/mem/mod.rs:LL:COL (#11) kind: Call { - ty: FnDef(DefId(core::intrinsics::offset_of), [Delta]) + ty: FnDef(DefId(core::intrinsics::offset_of), Binder { value: [Delta], bound_vars: [] }) from_hir_call: false fn_span: $SRC_DIR/core/src/mem/mod.rs:LL:COL (#11) fun: Expr { - ty: FnDef(DefId(core::intrinsics::offset_of), [Delta]) + ty: FnDef(DefId(core::intrinsics::offset_of), Binder { value: [Delta], bound_vars: [] }) temp_scope_id: 31 span: $SRC_DIR/core/src/mem/mod.rs:LL:COL (#11) kind: @@ -1311,12 +1311,12 @@ body: span: $SRC_DIR/core/src/mem/mod.rs:LL:COL (#12) kind: Call { - ty: FnDef(DefId(core::intrinsics::offset_of), [Delta]) + ty: FnDef(DefId(core::intrinsics::offset_of), Binder { value: [Delta], bound_vars: [] }) from_hir_call: false fn_span: $SRC_DIR/core/src/mem/mod.rs:LL:COL (#12) fun: Expr { - ty: FnDef(DefId(core::intrinsics::offset_of), [Delta]) + ty: FnDef(DefId(core::intrinsics::offset_of), Binder { value: [Delta], bound_vars: [] }) temp_scope_id: 43 span: $SRC_DIR/core/src/mem/mod.rs:LL:COL (#12) kind: diff --git a/tests/ui/thir-print/thir-tree-array-index.stdout b/tests/ui/thir-print/thir-tree-array-index.stdout index bbb2fd9578146..4e40bcbbf4e07 100644 --- a/tests/ui/thir-print/thir-tree-array-index.stdout +++ b/tests/ui/thir-print/thir-tree-array-index.stdout @@ -956,12 +956,12 @@ body: span: $DIR/thir-tree-array-index.rs:17:6: 17:19 (#0) kind: Call { - ty: FnDef(DefId(0:3 ~ thir_tree_array_index[2569]::index), []) + ty: FnDef(DefId(0:3 ~ thir_tree_array_index[2569]::index), Binder { value: [], bound_vars: [] }) from_hir_call: true fn_span: $DIR/thir-tree-array-index.rs:17:6: 17:19 (#0) fun: Expr { - ty: FnDef(DefId(0:3 ~ thir_tree_array_index[2569]::index), []) + ty: FnDef(DefId(0:3 ~ thir_tree_array_index[2569]::index), Binder { value: [], bound_vars: [] }) temp_scope_id: 80 span: $DIR/thir-tree-array-index.rs:17:6: 17:11 (#0) kind: @@ -970,7 +970,7 @@ body: hir_id: HirId(DefId(0:4 ~ thir_tree_array_index[2569]::indexing).80) value: Expr { - ty: FnDef(DefId(0:3 ~ thir_tree_array_index[2569]::index), []) + ty: FnDef(DefId(0:3 ~ thir_tree_array_index[2569]::index), Binder { value: [], bound_vars: [] }) temp_scope_id: 80 span: $DIR/thir-tree-array-index.rs:17:6: 17:11 (#0) kind: diff --git a/tests/ui/thir-print/thir-tree-match-for.stdout b/tests/ui/thir-print/thir-tree-match-for.stdout index 774261865802f..0cf759c40c4ff 100644 --- a/tests/ui/thir-print/thir-tree-match-for.stdout +++ b/tests/ui/thir-print/thir-tree-match-for.stdout @@ -378,12 +378,12 @@ body: span: $DIR/thir-tree-match-for.rs:16:12: 16:16 (#7) kind: Call { - ty: FnDef(DefId(N:M ~ core::iter::traits::collect::IntoIterator::into_iter), [std::ops::Range]) + ty: FnDef(DefId(N:M ~ core::iter::traits::collect::IntoIterator::into_iter), Binder { value: [std::ops::Range], bound_vars: [] }) from_hir_call: true fn_span: $DIR/thir-tree-match-for.rs:16:12: 16:16 (#7) fun: Expr { - ty: FnDef(DefId(N:M ~ core::iter::traits::collect::IntoIterator::into_iter), [std::ops::Range]) + ty: FnDef(DefId(N:M ~ core::iter::traits::collect::IntoIterator::into_iter), Binder { value: [std::ops::Range], bound_vars: [] }) temp_scope_id: 41 span: $DIR/thir-tree-match-for.rs:16:12: 16:16 (#7) kind: @@ -392,7 +392,7 @@ body: hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_from_for).41) value: Expr { - ty: FnDef(DefId(N:M ~ core::iter::traits::collect::IntoIterator::into_iter), [std::ops::Range]) + ty: FnDef(DefId(N:M ~ core::iter::traits::collect::IntoIterator::into_iter), Binder { value: [std::ops::Range], bound_vars: [] }) temp_scope_id: 41 span: $DIR/thir-tree-match-for.rs:16:12: 16:16 (#7) kind: @@ -560,12 +560,12 @@ body: span: $DIR/thir-tree-match-for.rs:16:12: 16:16 (#7) kind: Call { - ty: FnDef(DefId(N:M ~ core::iter::traits::iterator::Iterator::next), [std::ops::Range]) + ty: FnDef(DefId(N:M ~ core::iter::traits::iterator::Iterator::next), Binder { value: [std::ops::Range], bound_vars: [] }) from_hir_call: true fn_span: $DIR/thir-tree-match-for.rs:16:12: 16:16 (#7) fun: Expr { - ty: FnDef(DefId(N:M ~ core::iter::traits::iterator::Iterator::next), [std::ops::Range]) + ty: FnDef(DefId(N:M ~ core::iter::traits::iterator::Iterator::next), Binder { value: [std::ops::Range], bound_vars: [] }) temp_scope_id: 34 span: $DIR/thir-tree-match-for.rs:16:12: 16:16 (#7) kind: @@ -574,7 +574,7 @@ body: hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_from_for).34) value: Expr { - ty: FnDef(DefId(N:M ~ core::iter::traits::iterator::Iterator::next), [std::ops::Range]) + ty: FnDef(DefId(N:M ~ core::iter::traits::iterator::Iterator::next), Binder { value: [std::ops::Range], bound_vars: [] }) temp_scope_id: 34 span: $DIR/thir-tree-match-for.rs:16:12: 16:16 (#7) kind: @@ -935,12 +935,12 @@ body: span: $DIR/thir-tree-match-for.rs:23:9: 23:38 (#0) kind: Call { - ty: FnDef(DefId(N:M ~ core::iter::traits::collect::IntoIterator::into_iter), [std::ops::Range]) + ty: FnDef(DefId(N:M ~ core::iter::traits::collect::IntoIterator::into_iter), Binder { value: [std::ops::Range], bound_vars: [] }) from_hir_call: true fn_span: $DIR/thir-tree-match-for.rs:23:9: 23:38 (#0) fun: Expr { - ty: FnDef(DefId(N:M ~ core::iter::traits::collect::IntoIterator::into_iter), [std::ops::Range]) + ty: FnDef(DefId(N:M ~ core::iter::traits::collect::IntoIterator::into_iter), Binder { value: [std::ops::Range], bound_vars: [] }) temp_scope_id: 8 span: $DIR/thir-tree-match-for.rs:23:9: 23:32 (#0) kind: @@ -949,7 +949,7 @@ body: hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_loop_nonfor).8) value: Expr { - ty: FnDef(DefId(N:M ~ core::iter::traits::collect::IntoIterator::into_iter), [std::ops::Range]) + ty: FnDef(DefId(N:M ~ core::iter::traits::collect::IntoIterator::into_iter), Binder { value: [std::ops::Range], bound_vars: [] }) temp_scope_id: 8 span: $DIR/thir-tree-match-for.rs:23:9: 23:32 (#0) kind: @@ -1117,12 +1117,12 @@ body: span: $DIR/thir-tree-match-for.rs:25:13: 25:38 (#0) kind: Call { - ty: FnDef(DefId(N:M ~ core::iter::traits::iterator::Iterator::next), [std::ops::Range]) + ty: FnDef(DefId(N:M ~ core::iter::traits::iterator::Iterator::next), Binder { value: [std::ops::Range], bound_vars: [] }) from_hir_call: true fn_span: $DIR/thir-tree-match-for.rs:25:13: 25:38 (#0) fun: Expr { - ty: FnDef(DefId(N:M ~ core::iter::traits::iterator::Iterator::next), [std::ops::Range]) + ty: FnDef(DefId(N:M ~ core::iter::traits::iterator::Iterator::next), Binder { value: [std::ops::Range], bound_vars: [] }) temp_scope_id: 25 span: $DIR/thir-tree-match-for.rs:25:13: 25:27 (#0) kind: @@ -1131,7 +1131,7 @@ body: hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_loop_nonfor).25) value: Expr { - ty: FnDef(DefId(N:M ~ core::iter::traits::iterator::Iterator::next), [std::ops::Range]) + ty: FnDef(DefId(N:M ~ core::iter::traits::iterator::Iterator::next), Binder { value: [std::ops::Range], bound_vars: [] }) temp_scope_id: 25 span: $DIR/thir-tree-match-for.rs:25:13: 25:27 (#0) kind: