diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index 3f5d9fb62066d..79cc070113f14 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -2359,8 +2359,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // If a closure captured our `target` and then assigned // into a place then we should annotate the closure in // case it ends up being assigned into the return place. - annotated_closure = - self.annotate_fn_sig(def_id, substs.as_closure().sig()); + annotated_closure = self.annotate_fn_sig( + def_id, + substs.as_closure().sig().skip_binder(), + ); debug!( "annotate_argument_and_return_for_borrow: \ annotated_closure={:?} assigned_from_local={:?} \ @@ -2483,7 +2485,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { fn annotate_fn_sig( &self, did: LocalDefId, - sig: ty::PolyFnSig<'tcx>, + sig: ty::FnSig<'tcx>, ) -> Option> { debug!("annotate_fn_sig: did={:?} sig={:?}", did, sig); let is_closure = self.infcx.tcx.is_closure(did.to_def_id()); @@ -2513,12 +2515,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // 3. The return type is not a reference. In this case, we don't highlight // anything. let return_ty = sig.output(); - match return_ty.skip_binder().kind() { + match return_ty.kind() { ty::Ref(return_region, _, _) if return_region.has_name() && !is_closure => { // This is case 1 from above, return type is a named reference so we need to // search for relevant arguments. let mut arguments = Vec::new(); - for (index, argument) in sig.inputs().skip_binder().iter().enumerate() { + for (index, argument) in sig.inputs().iter().enumerate() { if let ty::Ref(argument_region, _, _) = argument.kind() { if argument_region == return_region { // Need to use the `rustc_middle::ty` types to compare against the @@ -2542,7 +2544,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // We use a mix of the HIR and the Ty types to get information // as the HIR doesn't have full types for closure arguments. - let return_ty = sig.output().skip_binder(); + let return_ty = sig.output(); let mut return_span = fn_decl.output.span(); if let hir::FnRetTy::Return(ty) = &fn_decl.output { if let hir::TyKind::Rptr(lifetime, _) = ty.kind { @@ -2561,7 +2563,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // reference so we select // the first argument. let argument_span = fn_decl.inputs.first()?.span; - let argument_ty = sig.inputs().skip_binder().first()?; + let argument_ty = sig.inputs().first()?; // Closure arguments are wrapped in a tuple, so we need to get the first // from that. @@ -2581,10 +2583,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // This is also case 2 from above but for functions, return type is still an // anonymous reference so we select the first argument. let argument_span = fn_decl.inputs.first()?.span; - let argument_ty = *sig.inputs().skip_binder().first()?; + let argument_ty = *sig.inputs().first()?; let return_span = fn_decl.output.span(); - let return_ty = sig.output().skip_binder(); + let return_ty = sig.output(); // We expect the first argument to be a reference. match argument_ty.kind() { diff --git a/compiler/rustc_borrowck/src/universal_regions.rs b/compiler/rustc_borrowck/src/universal_regions.rs index 2beb5e0ab5d20..34cf7528046fd 100644 --- a/compiler/rustc_borrowck/src/universal_regions.rs +++ b/compiler/rustc_borrowck/src/universal_regions.rs @@ -457,7 +457,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> { // C-variadic fns also have a `VaList` input that's not listed in the signature // (as it's created inside the body itself, not passed in from outside). if let DefiningTy::FnDef(def_id, _) = defining_ty { - if self.infcx.tcx.fn_sig(def_id).c_variadic() { + if self.infcx.tcx.fn_sig(def_id).c_variadic { let va_list_did = self.infcx.tcx.require_lang_item( LangItem::VaList, Some(self.infcx.tcx.def_span(self.mir_def.did)), @@ -652,7 +652,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> { DefiningTy::FnDef(def_id, _) => { let sig = tcx.fn_sig(def_id); let sig = indices.fold_to_region_vids(tcx, sig); - sig.inputs_and_output() + ty::Binder::dummy(sig.inputs_and_output) } DefiningTy::Const(def_id, _) => { diff --git a/compiler/rustc_codegen_cranelift/src/main_shim.rs b/compiler/rustc_codegen_cranelift/src/main_shim.rs index cae6312a60735..4b91d78e392ca 100644 --- a/compiler/rustc_codegen_cranelift/src/main_shim.rs +++ b/compiler/rustc_codegen_cranelift/src/main_shim.rs @@ -52,10 +52,7 @@ pub(crate) fn maybe_create_entry_wrapper( // late-bound regions, since late-bound // regions must appear in the argument // listing. - let main_ret_ty = tcx.normalize_erasing_regions( - ty::ParamEnv::reveal_all(), - main_ret_ty.no_bound_vars().unwrap(), - ); + let main_ret_ty = tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), main_ret_ty); let cmain_sig = Signature { params: vec![ diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs index eff2436d41cac..d7dc75e012e20 100644 --- a/compiler/rustc_codegen_llvm/src/attributes.rs +++ b/compiler/rustc_codegen_llvm/src/attributes.rs @@ -431,7 +431,7 @@ pub fn from_fn_attrs<'ll, 'tcx>( // the WebAssembly specification, which has this feature. This won't be // needed when LLVM enables this `multivalue` feature by default. if !cx.tcx.is_closure(instance.def_id()) { - let abi = cx.tcx.fn_sig(instance.def_id()).abi(); + let abi = cx.tcx.fn_sig(instance.def_id()).abi; if abi == Abi::Wasm { function_features.push("+multivalue".to_string()); } diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs index 964a632b6eedd..39434f1c9797f 100644 --- a/compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs +++ b/compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs @@ -189,7 +189,7 @@ fn declare_unused_fn<'tcx>(cx: &CodegenCx<'_, 'tcx>, def_id: DefId) -> Instance< let instance = Instance::new( def_id, InternalSubsts::for_item(tcx, def_id, |param, _| { - if let ty::GenericParamDefKind::Lifetime = param.kind { + if let ty::GenericParamDefKind::Lifetime { .. } = param.kind { tcx.lifetimes.re_erased.into() } else { tcx.mk_param_from_def(param) diff --git a/compiler/rustc_codegen_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs index 84b89cd71a6d3..939290d7e5891 100644 --- a/compiler/rustc_codegen_ssa/src/base.rs +++ b/compiler/rustc_codegen_ssa/src/base.rs @@ -445,10 +445,8 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( // late-bound regions, since late-bound // regions must appear in the argument // listing. - let main_ret_ty = cx.tcx().normalize_erasing_regions( - ty::ParamEnv::reveal_all(), - main_ret_ty.no_bound_vars().unwrap(), - ); + let main_ret_ty = + cx.tcx().normalize_erasing_regions(ty::ParamEnv::reveal_all(), main_ret_ty); let Some(llfn) = cx.declare_c_main(llfty) else { // FIXME: We should be smart and show a better diagnostic here. diff --git a/compiler/rustc_const_eval/src/const_eval/fn_queries.rs b/compiler/rustc_const_eval/src/const_eval/fn_queries.rs index f1674d04f8d15..5028a20d66cda 100644 --- a/compiler/rustc_const_eval/src/const_eval/fn_queries.rs +++ b/compiler/rustc_const_eval/src/const_eval/fn_queries.rs @@ -65,7 +65,7 @@ fn is_promotable_const_fn(tcx: TyCtxt<'_>, def_id: DefId) -> bool { if cfg!(debug_assertions) && stab.promotable { let sig = tcx.fn_sig(def_id); assert_eq!( - sig.unsafety(), + sig.unsafety, hir::Unsafety::Normal, "don't mark const unsafe fns as promotable", // https://github.com/rust-lang/rust/pull/53851#issuecomment-418760682 diff --git a/compiler/rustc_const_eval/src/const_eval/machine.rs b/compiler/rustc_const_eval/src/const_eval/machine.rs index e5acacd918888..d9f9694dbf3c1 100644 --- a/compiler/rustc_const_eval/src/const_eval/machine.rs +++ b/compiler/rustc_const_eval/src/const_eval/machine.rs @@ -58,7 +58,7 @@ impl<'mir, 'tcx> InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>> { *self.tcx, ty::ParamEnv::reveal_all(), const_panic_fmt, - self.tcx.intern_substs(&[]), + self.tcx.intern_substs(&[self.tcx.lifetimes.re_erased.into()]), ) .unwrap() .unwrap(), diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics/type_name.rs b/compiler/rustc_const_eval/src/interpret/intrinsics/type_name.rs index 7e4c5fcb031b0..6a47bab39928d 100644 --- a/compiler/rustc_const_eval/src/interpret/intrinsics/type_name.rs +++ b/compiler/rustc_const_eval/src/interpret/intrinsics/type_name.rs @@ -135,6 +135,7 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> { fn path_generic_args( mut self, + _: bool, print_prefix: impl FnOnce(Self) -> Result, args: &[GenericArg<'tcx>], ) -> Result { diff --git a/compiler/rustc_const_eval/src/transform/check_consts/check.rs b/compiler/rustc_const_eval/src/transform/check_consts/check.rs index 22a61774e8cf7..0d966c324ad54 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/check.rs @@ -246,7 +246,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> { // instead of the type of the return place. self.span = body.local_decls[RETURN_PLACE].source_info.span; let return_ty = tcx.fn_sig(def_id).output(); - self.check_local_or_return_ty(return_ty.skip_binder(), RETURN_PLACE); + self.check_local_or_return_ty(return_ty, RETURN_PLACE); } if !tcx.has_attr(def_id.to_def_id(), sym::rustc_do_not_const_check) { diff --git a/compiler/rustc_const_eval/src/transform/validate.rs b/compiler/rustc_const_eval/src/transform/validate.rs index 7f78d963e9f0a..5adde58a4a294 100644 --- a/compiler/rustc_const_eval/src/transform/validate.rs +++ b/compiler/rustc_const_eval/src/transform/validate.rs @@ -808,7 +808,23 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { TerminatorKind::Call { func, args, destination, target, cleanup, .. } => { let func_ty = func.ty(&self.body.local_decls, self.tcx); match func_ty.kind() { - ty::FnPtr(..) | ty::FnDef(..) => {} + ty::FnPtr(..) => {} + ty::FnDef(def_id, substs) => { + if cfg!(debug_assertions) { + debug!(?def_id, ?substs); + let generics = self.tcx.generics_of(def_id); + debug_assert_eq!(generics.count(), substs.len()); + let fn_sig = self.tcx.bound_fn_sig(*def_id); + let _ = fn_sig.subst(self.tcx, *substs); + for arg in substs.iter() { + if let ty::GenericArgKind::Lifetime(lt) = arg.unpack() + && lt != self.tcx.lifetimes.re_erased + { + panic!("{substs:?} contains non-erased lifetimes"); + } + } + } + } _ => self.fail( location, format!("encountered non-callable type {} in `Call` terminator", func_ty), diff --git a/compiler/rustc_hir_analysis/src/astconv/generics.rs b/compiler/rustc_hir_analysis/src/astconv/generics.rs index 47915b4bd4e6c..c3fda8554ed07 100644 --- a/compiler/rustc_hir_analysis/src/astconv/generics.rs +++ b/compiler/rustc_hir_analysis/src/astconv/generics.rs @@ -6,7 +6,7 @@ use crate::astconv::{ use crate::errors::AssocTypeBindingNotAllowed; use crate::structured_errors::{GenericArgsInfo, StructuredDiagnostic, WrongNumberOfGenericArgs}; use rustc_ast::ast::ParamKindOrd; -use rustc_errors::{struct_span_err, Applicability, Diagnostic, MultiSpan}; +use rustc_errors::{struct_span_err, Applicability, Diagnostic}; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::DefId; @@ -15,7 +15,6 @@ use rustc_infer::infer::TyCtxtInferExt; use rustc_middle::ty::{ self, subst, subst::SubstsRef, GenericParamDef, GenericParamDefKind, IsSuggestable, Ty, TyCtxt, }; -use rustc_session::lint::builtin::LATE_BOUND_LIFETIME_ARGUMENTS; use rustc_span::{symbol::kw, Span}; use smallvec::SmallVec; @@ -255,7 +254,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { match (args.peek(), params.peek()) { (Some(&arg), Some(¶m)) => { match (arg, ¶m.kind, arg_count.explicit_late_bound) { - (GenericArg::Lifetime(_), GenericParamDefKind::Lifetime, _) + (GenericArg::Lifetime(_), GenericParamDefKind::Lifetime { .. }, _) | ( GenericArg::Type(_) | GenericArg::Infer(_), GenericParamDefKind::Type { .. }, @@ -272,7 +271,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { } ( GenericArg::Infer(_) | GenericArg::Type(_) | GenericArg::Const(_), - GenericParamDefKind::Lifetime, + GenericParamDefKind::Lifetime { .. }, _, ) => { // We expected a lifetime argument, but got a type or const @@ -623,36 +622,38 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { args: &hir::GenericArgs<'_>, position: GenericArgPosition, ) -> ExplicitLateBound { - let param_counts = def.own_counts(); let infer_lifetimes = position != GenericArgPosition::Type && !args.has_lifetime_params(); if infer_lifetimes { return ExplicitLateBound::No; } - if let Some(span_late) = def.has_late_bound_regions { + let has_late_bound_regions = def + .params + .iter() + .find(|param| { + matches!(param.kind, ty::GenericParamDefKind::Lifetime { late_bound: true }) + }) + .map(|param| tcx.def_span(param.def_id)); + + if let Some(span_late) = has_late_bound_regions { let msg = "cannot specify lifetime arguments explicitly \ if late bound lifetime parameters are present"; let note = "the late bound lifetime parameter is introduced here"; - let span = args.args[0].span(); - - if position == GenericArgPosition::Value - && args.num_lifetime_params() != param_counts.lifetimes - { - let mut err = tcx.sess.struct_span_err(span, msg); - err.span_note(span_late, note); - err.emit(); - } else { - let mut multispan = MultiSpan::from_span(span); - multispan.push_span_label(span_late, note); - tcx.struct_span_lint_hir( - LATE_BOUND_LIFETIME_ARGUMENTS, - args.args[0].hir_id(), - multispan, - msg, - |lint| lint, - ); - } + let help = format!( + "remove the explicit lifetime argument{}", + rustc_errors::pluralize!(args.num_lifetime_params()) + ); + let spans: Vec<_> = args + .args + .iter() + .filter_map(|arg| match arg { + hir::GenericArg::Lifetime(l) => Some(l.span), + _ => None, + }) + .collect(); + + tcx.sess.struct_span_err(spans, msg).span_note(span_late, note).help(help).emit(); ExplicitLateBound::Yes } else { diff --git a/compiler/rustc_hir_analysis/src/astconv/mod.rs b/compiler/rustc_hir_analysis/src/astconv/mod.rs index a0350c26d827c..2ed6d692f91c9 100644 --- a/compiler/rustc_hir_analysis/src/astconv/mod.rs +++ b/compiler/rustc_hir_analysis/src/astconv/mod.rs @@ -418,7 +418,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { }; match (¶m.kind, arg) { - (GenericParamDefKind::Lifetime, GenericArg::Lifetime(lt)) => { + (GenericParamDefKind::Lifetime { .. }, GenericArg::Lifetime(lt)) => { self.astconv.ast_region_to_region(lt, Some(param)).into() } (&GenericParamDefKind::Type { has_default, .. }, GenericArg::Type(ty)) => { @@ -458,7 +458,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { ) -> subst::GenericArg<'tcx> { let tcx = self.astconv.tcx(); match param.kind { - GenericParamDefKind::Lifetime => self + GenericParamDefKind::Lifetime { .. } => self .astconv .re_infer(Some(param), self.span) .unwrap_or_else(|| { @@ -2720,7 +2720,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { let substs = InternalSubsts::for_item(tcx, def_id, |param, _| { if let Some(i) = (param.index as usize).checked_sub(generics.parent_count) { // Our own parameters are the resolved lifetimes. - if let GenericParamDefKind::Lifetime = param.kind { + if let GenericParamDefKind::Lifetime { .. } = param.kind { if let hir::GenericArg::Lifetime(lifetime) = &lifetimes[i] { self.ast_region_to_region(lifetime, None).into() } else { @@ -2739,7 +2739,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { // For `impl Trait` in the types of statics, constants, // locals and type aliases. These capture all parent // lifetimes, so they can use their identity subst. - GenericParamDefKind::Lifetime + GenericParamDefKind::Lifetime { .. } if matches!( origin, hir::OpaqueTyOrigin::FnReturn(..) | hir::OpaqueTyOrigin::AsyncFn(..) @@ -2919,8 +2919,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { ); let ty = if let Some(arg_idx) = arg_idx { fn_sig.input(arg_idx) } else { fn_sig.output() }; - - Some(tcx.liberate_late_bound_regions(fn_hir_id.expect_owner().to_def_id(), ty)) + Some(ty) } fn validate_late_bound_regions( diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index a1faf80251957..051fe2290b7c4 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -290,7 +290,7 @@ pub(super) fn check_opaque_for_inheriting_lifetimes<'tcx>( type BreakTy = Ty<'tcx>; fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow { - debug!("check_opaque_for_inheriting_lifetimes: (visit_ty) t={:?}", t); + debug!("(visit_ty) t={:?}", t); if t == self.opaque_identity_ty { ControlFlow::CONTINUE } else { @@ -328,14 +328,18 @@ pub(super) fn check_opaque_for_inheriting_lifetimes<'tcx>( if let ItemKind::OpaqueTy(hir::OpaqueTy { origin: hir::OpaqueTyOrigin::AsyncFn(..) | hir::OpaqueTyOrigin::FnReturn(..), + in_trait, .. }) = item.kind { + let substs = InternalSubsts::identity_for_item(tcx, def_id.to_def_id()); + let opaque_identity_ty = if in_trait { + tcx.mk_projection(def_id.to_def_id(), substs) + } else { + tcx.mk_opaque(def_id.to_def_id(), substs) + }; let mut visitor = ProhibitOpaqueVisitor { - opaque_identity_ty: tcx.mk_opaque( - def_id.to_def_id(), - InternalSubsts::identity_for_item(tcx, def_id.to_def_id()), - ), + opaque_identity_ty, generics: tcx.generics_of(def_id), tcx, selftys: vec![], @@ -344,10 +348,7 @@ pub(super) fn check_opaque_for_inheriting_lifetimes<'tcx>( .explicit_item_bounds(def_id) .iter() .try_for_each(|(predicate, _)| predicate.visit_with(&mut visitor)); - debug!( - "check_opaque_for_inheriting_lifetimes: prohibit_opaque={:?}, visitor.opaque_identity_ty={:?}, visitor.generics={:?}", - prohibit_opaque, visitor.opaque_identity_ty, visitor.generics - ); + debug!(?prohibit_opaque); if let Some(ty) = prohibit_opaque.break_value() { visitor.visit_item(&item); diff --git a/compiler/rustc_hir_analysis/src/check/compare_method.rs b/compiler/rustc_hir_analysis/src/check/compare_method.rs index e72f18012ab33..39a013c0c5c9a 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_method.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_method.rs @@ -149,6 +149,7 @@ fn compare_predicate_entailment<'tcx>( impl_trait_ref: ty::TraitRef<'tcx>, ) -> Result<(), ErrorGuaranteed> { let trait_to_impl_substs = impl_trait_ref.substs; + debug!(?trait_to_impl_substs); // This node-id should be used for the `body_id` field on each // `ObligationCause` (and the `FnCtxt`). @@ -173,7 +174,7 @@ fn compare_predicate_entailment<'tcx>( // Create mapping from trait to placeholder. let trait_to_placeholder_substs = impl_to_placeholder_substs.rebase_onto(tcx, impl_m.container_id(tcx), trait_to_impl_substs); - debug!("compare_impl_method: trait_to_placeholder_substs={:?}", trait_to_placeholder_substs); + debug!(?trait_to_placeholder_substs); let impl_m_generics = tcx.generics_of(impl_m.def_id); let trait_m_generics = tcx.generics_of(trait_m.def_id); @@ -191,7 +192,7 @@ fn compare_predicate_entailment<'tcx>( let impl_predicates = tcx.predicates_of(impl_m_predicates.parent.unwrap()); let mut hybrid_preds = impl_predicates.instantiate_identity(tcx); - debug!("compare_impl_method: impl_bounds={:?}", hybrid_preds); + debug!("impl_bounds={:?}", hybrid_preds); // This is the only tricky bit of the new way we check implementation methods // We need to build a set of predicates where only the method-level bounds @@ -218,7 +219,7 @@ fn compare_predicate_entailment<'tcx>( let infcx = &tcx.infer_ctxt().build(); let ocx = ObligationCtxt::new(infcx); - debug!("compare_impl_method: caller_bounds={:?}", param_env.caller_bounds()); + debug!("caller_bounds={:?}", param_env.caller_bounds()); let mut selcx = traits::SelectionContext::new(&infcx); let impl_m_own_bounds = impl_m_predicates.instantiate_own(tcx, impl_to_placeholder_substs); @@ -258,18 +259,17 @@ fn compare_predicate_entailment<'tcx>( let mut wf_tys = FxHashSet::default(); - let impl_sig = infcx.replace_bound_vars_with_fresh_vars( - impl_m_span, - infer::HigherRankedType, - tcx.fn_sig(impl_m.def_id), - ); + let impl_sig = tcx.mk_fn_def(impl_m.def_id, impl_to_placeholder_substs).fn_sig(tcx); + let impl_sig = + infcx.replace_bound_vars_with_fresh_vars(impl_m_span, infer::HigherRankedType, impl_sig); let norm_cause = ObligationCause::misc(impl_m_span, impl_m_hir_id); let impl_sig = ocx.normalize(norm_cause.clone(), param_env, impl_sig); let impl_fty = tcx.mk_fn_ptr(ty::Binder::dummy(impl_sig)); - debug!("compare_impl_method: impl_fty={:?}", impl_fty); + debug!(?impl_fty); - let trait_sig = tcx.bound_fn_sig(trait_m.def_id).subst(tcx, trait_to_placeholder_substs); + let trait_sig = tcx.type_of(trait_m.def_id).fn_sig(tcx); + let trait_sig = ty::EarlyBinder(trait_sig).subst(tcx, trait_to_placeholder_substs); let trait_sig = tcx.liberate_late_bound_regions(impl_m.def_id, trait_sig); // Next, add all inputs and output as well-formed tys. Importantly, @@ -281,8 +281,7 @@ fn compare_predicate_entailment<'tcx>( // as we don't normalize during implied bounds computation. wf_tys.extend(trait_sig.inputs_and_output.iter()); let trait_fty = tcx.mk_fn_ptr(ty::Binder::dummy(trait_sig)); - - debug!("compare_impl_method: trait_fty={:?}", trait_fty); + debug!(?trait_fty); // FIXME: We'd want to keep more accurate spans than "the method signature" when // processing the comparison between the trait and impl fn, but we sadly lose them @@ -431,6 +430,7 @@ fn compare_predicate_entailment<'tcx>( Ok(()) } +#[instrument(level = "debug", skip(tcx), ret)] pub fn collect_trait_impl_trait_tys<'tcx>( tcx: TyCtxt<'tcx>, def_id: DefId, @@ -464,25 +464,23 @@ pub fn collect_trait_impl_trait_tys<'tcx>( let infcx = &tcx.infer_ctxt().build(); let ocx = ObligationCtxt::new(infcx); + let impl_sig = tcx.mk_fn_def(impl_m.def_id, impl_to_placeholder_substs).fn_sig(tcx); + let impl_sig = + infcx.replace_bound_vars_with_fresh_vars(return_span, infer::HigherRankedType, impl_sig); + let norm_cause = ObligationCause::misc(return_span, impl_m_hir_id); - let impl_sig = ocx.normalize( - norm_cause.clone(), - param_env, - infcx.replace_bound_vars_with_fresh_vars( - return_span, - infer::HigherRankedType, - tcx.fn_sig(impl_m.def_id), - ), - ); + let impl_sig = ocx.normalize(norm_cause.clone(), param_env, impl_sig); let impl_return_ty = impl_sig.output(); + let unnormalized_trait_sig = tcx.type_of(trait_m.def_id).fn_sig(tcx); + let unnormalized_trait_sig = + ty::EarlyBinder(unnormalized_trait_sig).subst(tcx, trait_to_placeholder_substs); + let unnormalized_trait_sig = + tcx.liberate_late_bound_regions(impl_m.def_id, unnormalized_trait_sig); + let mut collector = ImplTraitInTraitCollector::new(&ocx, return_span, param_env, impl_m_hir_id); - let unnormalized_trait_sig = tcx - .liberate_late_bound_regions( - impl_m.def_id, - tcx.bound_fn_sig(trait_m.def_id).subst(tcx, trait_to_placeholder_substs), - ) - .fold_with(&mut collector); + let unnormalized_trait_sig = unnormalized_trait_sig.fold_with(&mut collector); + let trait_sig = ocx.normalize(norm_cause.clone(), param_env, unnormalized_trait_sig); let trait_return_ty = trait_sig.output(); @@ -704,15 +702,11 @@ fn check_region_bounds_on_impl_item<'tcx>( trait_generics: &ty::Generics, impl_generics: &ty::Generics, ) -> Result<(), ErrorGuaranteed> { - let trait_params = trait_generics.own_counts().lifetimes; - let impl_params = impl_generics.own_counts().lifetimes; - - debug!( - "check_region_bounds_on_impl_item: \ - trait_generics={:?} \ - impl_generics={:?}", - trait_generics, impl_generics - ); + // For backwards compatibility reasons, we can only check that we have the correct amount + // of early-bound lifetimes. The user is allowed to introduce as many late-bound lifetime + // as they want. + let trait_params = trait_generics.own_counts().early_lifetimes; + let impl_params = impl_generics.own_counts().early_lifetimes; // Must have same number of early-bound lifetime parameters. // Unfortunately, if the user screws up the bounds, then this @@ -810,7 +804,6 @@ fn compare_self_type<'tcx>( let param_env = ty::ParamEnv::reveal_all(); let infcx = tcx.infer_ctxt().build(); - let self_arg_ty = tcx.liberate_late_bound_regions(method.def_id, self_arg_ty); let can_eq_self = |ty| infcx.can_eq(param_env, untransformed_self_ty, ty).is_ok(); match ExplicitSelf::determine(self_arg_ty, can_eq_self) { ExplicitSelf::ByValue => "self".to_owned(), @@ -1040,8 +1033,8 @@ fn compare_number_of_method_arguments<'tcx>( ) -> Result<(), ErrorGuaranteed> { let impl_m_fty = tcx.fn_sig(impl_m.def_id); let trait_m_fty = tcx.fn_sig(trait_m.def_id); - let trait_number_args = trait_m_fty.inputs().skip_binder().len(); - let impl_number_args = impl_m_fty.inputs().skip_binder().len(); + let trait_number_args = trait_m_fty.inputs().len(); + let impl_number_args = impl_m_fty.inputs().len(); if trait_number_args != impl_number_args { let trait_span = if let Some(def_id) = trait_m.def_id.as_local() { match tcx.hir().expect_trait_item(def_id).kind { @@ -1128,11 +1121,11 @@ fn compare_synthetic_generics<'tcx>( let trait_m_generics = tcx.generics_of(trait_m.def_id); let impl_m_type_params = impl_m_generics.params.iter().filter_map(|param| match param.kind { GenericParamDefKind::Type { synthetic, .. } => Some((param.def_id, synthetic)), - GenericParamDefKind::Lifetime | GenericParamDefKind::Const { .. } => None, + GenericParamDefKind::Lifetime { .. } | GenericParamDefKind::Const { .. } => None, }); let trait_m_type_params = trait_m_generics.params.iter().filter_map(|param| match param.kind { GenericParamDefKind::Type { synthetic, .. } => Some((param.def_id, synthetic)), - GenericParamDefKind::Lifetime | GenericParamDefKind::Const { .. } => None, + GenericParamDefKind::Lifetime { .. } | GenericParamDefKind::Const { .. } => None, }); for ((impl_def_id, impl_synthetic), (trait_def_id, trait_synthetic)) in iter::zip(impl_m_type_params, trait_m_type_params) @@ -1652,7 +1645,7 @@ pub fn check_type_bounds<'tcx>( )) .into() } - GenericParamDefKind::Lifetime => { + GenericParamDefKind::Lifetime { .. } => { let kind = ty::BoundRegionKind::BrNamed(param.def_id, param.name); let bound_var = ty::BoundVariableKind::Region(kind); bound_vars.push(bound_var); diff --git a/compiler/rustc_hir_analysis/src/check/intrinsic.rs b/compiler/rustc_hir_analysis/src/check/intrinsic.rs index 8be1cf04f8b69..ea01fcb054e7e 100644 --- a/compiler/rustc_hir_analysis/src/check/intrinsic.rs +++ b/compiler/rustc_hir_analysis/src/check/intrinsic.rs @@ -17,6 +17,7 @@ use rustc_target::spec::abi::Abi; use std::iter; +#[instrument(level = "trace", skip(tcx))] fn equate_intrinsic_type<'tcx>( tcx: TyCtxt<'tcx>, it: &hir::ForeignItem<'_>, @@ -24,18 +25,15 @@ fn equate_intrinsic_type<'tcx>( n_lts: usize, sig: ty::PolyFnSig<'tcx>, ) { - let (own_counts, span) = match &it.kind { - hir::ForeignItemKind::Fn(.., generics) => { - let own_counts = tcx.generics_of(it.def_id.to_def_id()).own_counts(); - (own_counts, generics.span) - } - _ => { - struct_span_err!(tcx.sess, it.span, E0622, "intrinsic must be a function") - .span_label(it.span, "expected a function") - .emit(); - return; - } + let hir::ForeignItemKind::Fn(.., generics) = &it.kind else { + struct_span_err!(tcx.sess, it.span, E0622, "intrinsic must be a function") + .span_label(it.span, "expected a function") + .emit(); + return; }; + let span = generics.span; + let generics = tcx.generics_of(it.def_id.to_def_id()); + let own_counts = generics.own_counts(); let gen_count_ok = |found: usize, expected: usize, descr: &str| -> bool { if found != expected { @@ -51,13 +49,15 @@ fn equate_intrinsic_type<'tcx>( } }; - if gen_count_ok(own_counts.lifetimes, n_lts, "lifetime") + if gen_count_ok(own_counts.early_lifetimes, n_lts, "lifetime") && gen_count_ok(own_counts.types, n_tps, "type") && gen_count_ok(own_counts.consts, 0, "const") { let fty = tcx.mk_fn_ptr(sig); let cause = ObligationCause::new(it.span, it.hir_id(), ObligationCauseCode::IntrinsicType); - require_same_types(tcx, &cause, tcx.mk_fn_ptr(tcx.fn_sig(it.def_id)), fty); + let fn_def = tcx.type_of(it.def_id).fn_sig(tcx); + debug!(?fn_def); + require_same_types(tcx, &cause, tcx.mk_fn_ptr(fn_def), fty); } } diff --git a/compiler/rustc_hir_analysis/src/check/mod.rs b/compiler/rustc_hir_analysis/src/check/mod.rs index 2e7b102576407..5c825eb09af80 100644 --- a/compiler/rustc_hir_analysis/src/check/mod.rs +++ b/compiler/rustc_hir_analysis/src/check/mod.rs @@ -449,7 +449,7 @@ fn suggestion_signature(assoc: &ty::AssocItem, tcx: TyCtxt<'_>) -> String { // regions just fine, showing `fn(&MyType)`. fn_sig_suggestion( tcx, - tcx.fn_sig(assoc.def_id).skip_binder(), + tcx.fn_sig(assoc.def_id), assoc.ident(tcx), tcx.predicates_of(assoc.def_id), assoc, diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index 33ed3b96aa81f..8f47a2939d9a4 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -380,10 +380,7 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, associated_items: &[hir::TraitItemRe // For methods, we check the function signature's return type for any GATs // to constrain. In the `into_iter` case, we see that the return type // `Self::Iter<'a>` is a GAT we want to gather any potential missing bounds from. - let sig: ty::FnSig<'_> = tcx.liberate_late_bound_regions( - item_def_id.to_def_id(), - tcx.fn_sig(item_def_id), - ); + let sig = tcx.fn_sig(item_def_id); gather_gat_bounds( tcx, param_env, @@ -1296,7 +1293,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id | GenericParamDefKind::Const { has_default } => { has_default && def.index >= generics.parent_count as u32 } - GenericParamDefKind::Lifetime => unreachable!(), + GenericParamDefKind::Lifetime { .. } => unreachable!(), }; // Check that concrete defaults are well-formed. See test `type-check-defaults.rs`. @@ -1339,7 +1336,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id } } // Doesn't have defaults. - GenericParamDefKind::Lifetime => {} + GenericParamDefKind::Lifetime { .. } => {} } } @@ -1353,7 +1350,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id // First we build the defaulted substitution. let substs = InternalSubsts::for_item(tcx, def_id.to_def_id(), |param, _| { match param.kind { - GenericParamDefKind::Lifetime => { + GenericParamDefKind::Lifetime { .. } => { // All regions are identity. tcx.mk_param_from_def(param) } @@ -1477,12 +1474,11 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id fn check_fn_or_method<'tcx>( wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, - sig: ty::PolyFnSig<'tcx>, + sig: ty::FnSig<'tcx>, hir_decl: &hir::FnDecl<'_>, def_id: LocalDefId, ) { let tcx = wfcx.tcx(); - let sig = tcx.liberate_late_bound_regions(def_id.to_def_id(), sig); // Normalize the input and output types one at a time, using a different // `WellFormedLoc` for each. We cannot call `normalize_associated_types` @@ -1596,7 +1592,6 @@ fn check_method_receiver<'tcx>( let span = fn_sig.decl.inputs[0].span; let sig = tcx.fn_sig(method.def_id); - let sig = tcx.liberate_late_bound_regions(method.def_id, sig); let sig = wfcx.normalize(span, None, sig); debug!("check_method_receiver: sig={:?}", sig); diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index 66ca7d7aa08f9..7bd6249b1b073 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -20,7 +20,6 @@ use crate::errors; use rustc_ast as ast; use rustc_ast::{MetaItemKind, NestedMetaItem}; use rustc_attr::{list_contains_name, InlineAttr, InstructionSetAttr, OptimizeAttr}; -use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed, StashKey}; use rustc_hir as hir; @@ -28,7 +27,7 @@ use rustc_hir::def::CtorKind; use rustc_hir::def_id::{DefId, LocalDefId, LOCAL_CRATE}; use rustc_hir::intravisit::{self, Visitor}; use rustc_hir::weak_lang_items; -use rustc_hir::{GenericParamKind, Node}; +use rustc_hir::Node; use rustc_middle::hir::nested_filter; use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs}; use rustc_middle::mir::mono::Linkage; @@ -1123,7 +1122,7 @@ pub fn get_infer_ret_ty<'hir>(output: &'hir hir::FnRetTy<'hir>) -> Option<&'hir } #[instrument(level = "debug", skip(tcx))] -fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> { +fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::FnSig<'_> { use rustc_hir::Node::*; use rustc_hir::*; @@ -1156,7 +1155,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> { sig.decl, Some(generics), None, - ) + ).no_bound_vars().unwrap() } else { infer_return_ty_for_fn_sig(tcx, sig, generics, def_id, &icx) } @@ -1174,7 +1173,9 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> { decl, Some(generics), None, - ), + ) + .no_bound_vars() + .unwrap(), ForeignItem(&hir::ForeignItem { kind: ForeignItemKind::Fn(fn_decl, _, _), .. }) => { let abi = tcx.hir().get_foreign_abi(hir_id); @@ -1185,13 +1186,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> { let ty = tcx.type_of(tcx.hir().get_parent_item(hir_id)); let inputs = data.fields().iter().map(|f| tcx.type_of(tcx.hir().local_def_id(f.hir_id))); - ty::Binder::dummy(tcx.mk_fn_sig( - inputs, - ty, - false, - hir::Unsafety::Normal, - abi::Abi::Rust, - )) + tcx.mk_fn_sig(inputs, ty, false, hir::Unsafety::Normal, abi::Abi::Rust) } Expr(&hir::Expr { kind: hir::ExprKind::Closure { .. }, .. }) => { @@ -1222,7 +1217,7 @@ fn infer_return_ty_for_fn_sig<'tcx>( generics: &hir::Generics<'_>, def_id: LocalDefId, icx: &ItemCtxt<'tcx>, -) -> ty::PolyFnSig<'tcx> { +) -> ty::FnSig<'tcx> { let hir_id = tcx.hir().local_def_id_to_hir_id(def_id); match get_infer_ret_ty(&sig.decl.output) { @@ -1233,12 +1228,11 @@ fn infer_return_ty_for_fn_sig<'tcx>( ty::ReErased => tcx.lifetimes.re_static, _ => r, }); - let fn_sig = ty::Binder::dummy(fn_sig); let mut visitor = HirPlaceholderCollector::default(); visitor.visit_ty(ty); let mut diag = bad_placeholder(tcx, visitor.0, "return type"); - let ret_ty = fn_sig.skip_binder().output(); + let ret_ty = fn_sig.output(); if ret_ty.is_suggestable(tcx, false) { diag.span_suggestion( ty.span, @@ -1280,7 +1274,9 @@ fn infer_return_ty_for_fn_sig<'tcx>( sig.decl, Some(generics), None, - ), + ) + .no_bound_vars() + .unwrap(), } } @@ -1335,21 +1331,6 @@ fn impl_polarity(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ImplPolarity { } } -/// Returns the early-bound lifetimes declared in this generics -/// listing. For anything other than fns/methods, this is just all -/// the lifetimes that are declared. For fns or methods, we have to -/// screen out those that do not appear in any where-clauses etc using -/// `resolve_lifetime::early_bound_lifetimes`. -fn early_bound_lifetimes_from_generics<'a, 'tcx: 'a>( - tcx: TyCtxt<'tcx>, - generics: &'a hir::Generics<'a>, -) -> impl Iterator> + Captures<'tcx> { - generics.params.iter().filter(move |param| match param.kind { - GenericParamKind::Lifetime { .. } => !tcx.is_late_bound(param.hir_id), - _ => false, - }) -} - /// Returns a list of type predicates for the definition with ID `def_id`, including inferred /// lifetime constraints. This includes all predicates returned by `explicit_predicates_of`, plus /// inferred constraints concerning which regions outlive other regions. @@ -1381,7 +1362,7 @@ fn compute_sig_of_foreign_fn_decl<'tcx>( def_id: DefId, decl: &'tcx hir::FnDecl<'tcx>, abi: abi::Abi, -) -> ty::PolyFnSig<'tcx> { +) -> ty::FnSig<'tcx> { let unsafety = if abi == abi::Abi::RustIntrinsic { intrinsic_operation_unsafety(tcx, def_id) } else { @@ -1396,7 +1377,9 @@ fn compute_sig_of_foreign_fn_decl<'tcx>( decl, None, None, - ); + ) + .no_bound_vars() + .unwrap(); // Feature gate SIMD types in FFI, since I am not sure that the // ABIs are handled at all correctly. -huonw @@ -1424,11 +1407,11 @@ fn compute_sig_of_foreign_fn_decl<'tcx>( .emit(); } }; - for (input, ty) in iter::zip(decl.inputs, fty.inputs().skip_binder()) { + for (input, ty) in iter::zip(decl.inputs, fty.inputs()) { check(input, *ty) } if let hir::FnRetTy::Return(ref ty) = decl.output { - check(ty, fty.output().skip_binder()) + check(ty, fty.output()) } } @@ -1720,7 +1703,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: DefId) -> CodegenFnAttrs { } } } else if attr.has_name(sym::cmse_nonsecure_entry) { - if !matches!(tcx.fn_sig(did).abi(), abi::Abi::C { .. }) { + if !matches!(tcx.fn_sig(did).abi, abi::Abi::C { .. }) { struct_span_err!( tcx.sess, attr.span, @@ -1737,7 +1720,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: DefId) -> CodegenFnAttrs { } else if attr.has_name(sym::thread_local) { codegen_fn_attrs.flags |= CodegenFnAttrFlags::THREAD_LOCAL; } else if attr.has_name(sym::track_caller) { - if !tcx.is_closure(did.to_def_id()) && tcx.fn_sig(did).abi() != abi::Abi::Rust { + if !tcx.is_closure(did.to_def_id()) && tcx.fn_sig(did).abi != abi::Abi::Rust { struct_span_err!(tcx.sess, attr.span, E0737, "`#[track_caller]` requires Rust ABI") .emit(); } @@ -1767,8 +1750,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: DefId) -> CodegenFnAttrs { codegen_fn_attrs.export_name = Some(s); } } else if attr.has_name(sym::target_feature) { - if !tcx.is_closure(did.to_def_id()) - && tcx.fn_sig(did).unsafety() == hir::Unsafety::Normal + if !tcx.is_closure(did.to_def_id()) && tcx.fn_sig(did).unsafety == hir::Unsafety::Normal { if tcx.sess.target.is_like_wasm || tcx.sess.opts.actually_rustdoc { // The `#[target_feature]` attribute is allowed on diff --git a/compiler/rustc_hir_analysis/src/collect/generics_of.rs b/compiler/rustc_hir_analysis/src/collect/generics_of.rs index 707fd6c75278d..d4fbe1a107fec 100644 --- a/compiler/rustc_hir_analysis/src/collect/generics_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/generics_of.rs @@ -1,15 +1,11 @@ -use crate::middle::resolve_lifetime as rl; -use hir::{ - intravisit::{self, Visitor}, - GenericParamKind, HirId, Node, -}; +use hir::intravisit::{self, Visitor}; +use hir::{GenericParamKind, HirId}; use rustc_hir as hir; use rustc_hir::def::DefKind; use rustc_hir::def_id::DefId; use rustc_middle::ty::{self, TyCtxt}; use rustc_session::lint; use rustc_span::symbol::{kw, Symbol}; -use rustc_span::Span; pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::Generics { use rustc_hir::*; @@ -93,7 +89,6 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::Generics { params, param_def_id_to_index, has_self: generics.has_self, - has_late_bound_regions: generics.has_late_bound_regions, }; } @@ -237,77 +232,105 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::Generics { params.push(opt_self); } - let early_lifetimes = super::early_bound_lifetimes_from_generics(tcx, ast_generics); - params.extend(early_lifetimes.enumerate().map(|(i, param)| ty::GenericParamDef { - name: param.name.ident().name, - index: own_start + i as u32, - def_id: tcx.hir().local_def_id(param.hir_id).to_def_id(), - pure_wrt_drop: param.pure_wrt_drop, - kind: ty::GenericParamDefKind::Lifetime, - })); - - // Now create the real type and const parameters. - let type_start = own_start - has_self as u32 + params.len() as u32; - let mut i = 0; - + // Now create the real lifetime, type and const parameters. const TYPE_DEFAULT_NOT_ALLOWED: &'static str = "defaults for type parameters are only allowed in \ `struct`, `enum`, `type`, or `trait` definitions"; - params.extend(ast_generics.params.iter().filter_map(|param| match param.kind { - GenericParamKind::Lifetime { .. } => None, - GenericParamKind::Type { ref default, synthetic, .. } => { - if default.is_some() { - match allow_defaults { - Defaults::Allowed => {} - Defaults::FutureCompatDisallowed - if tcx.features().default_type_parameter_fallback => {} - Defaults::FutureCompatDisallowed => { - tcx.struct_span_lint_hir( - lint::builtin::INVALID_TYPE_PARAM_DEFAULT, - param.hir_id, - param.span, - TYPE_DEFAULT_NOT_ALLOWED, - |lint| lint, - ); + // When late-bound lifetimes did not appear in generics, the user was allowed to introduce as + // many late-bound lifetimes as they wanted, and they were not counted in the substs. + // In order to keep this possibility while having substs behaving reasonably, we push + // late-bound lifetimes to the end of the generics. That way, we can keep the behaviour of + // trait to impl substitution rebase with hopefully minimal breakage. + params.extend( + ast_generics + .params + .iter() + .filter(|param| match param.kind { + GenericParamKind::Lifetime { .. } => !tcx.is_late_bound(param.hir_id), + GenericParamKind::Type { .. } | GenericParamKind::Const { .. } => true, + }) + .enumerate() + .map(|(i, param)| { + let kind = match param.kind { + GenericParamKind::Lifetime { .. } => { + ty::GenericParamDefKind::Lifetime { late_bound: false } } - Defaults::Deny => { - tcx.sess.span_err(param.span, TYPE_DEFAULT_NOT_ALLOWED); - } - } - } + GenericParamKind::Type { ref default, synthetic, .. } => { + if default.is_some() { + match allow_defaults { + Defaults::Allowed => {} + Defaults::FutureCompatDisallowed + if tcx.features().default_type_parameter_fallback => {} + Defaults::FutureCompatDisallowed => { + tcx.struct_span_lint_hir( + lint::builtin::INVALID_TYPE_PARAM_DEFAULT, + param.hir_id, + param.span, + TYPE_DEFAULT_NOT_ALLOWED, + |lint| lint, + ); + } + Defaults::Deny => { + tcx.sess.span_err(param.span, TYPE_DEFAULT_NOT_ALLOWED); + } + } + } - let kind = ty::GenericParamDefKind::Type { has_default: default.is_some(), synthetic }; - - let param_def = ty::GenericParamDef { - index: type_start + i as u32, - name: param.name.ident().name, - def_id: tcx.hir().local_def_id(param.hir_id).to_def_id(), - pure_wrt_drop: param.pure_wrt_drop, - kind, - }; - i += 1; - Some(param_def) - } - GenericParamKind::Const { default, .. } => { - if !matches!(allow_defaults, Defaults::Allowed) && default.is_some() { - tcx.sess.span_err( - param.span, - "defaults for const parameters are only allowed in \ + ty::GenericParamDefKind::Type { has_default: default.is_some(), synthetic } + } + GenericParamKind::Const { default, .. } => { + if !matches!(allow_defaults, Defaults::Allowed) && default.is_some() { + tcx.sess.span_err( + param.span, + "defaults for const parameters are only allowed in \ `struct`, `enum`, `type`, or `trait` definitions", - ); - } + ); + } - let param_def = ty::GenericParamDef { - index: type_start + i as u32, - name: param.name.ident().name, - def_id: tcx.hir().local_def_id(param.hir_id).to_def_id(), - pure_wrt_drop: param.pure_wrt_drop, - kind: ty::GenericParamDefKind::Const { has_default: default.is_some() }, - }; - i += 1; - Some(param_def) - } - })); + ty::GenericParamDefKind::Const { has_default: default.is_some() } + } + }; + + ty::GenericParamDef { + name: param.name.ident().name, + index: own_start + i as u32, + def_id: tcx.hir().local_def_id(param.hir_id).to_def_id(), + pure_wrt_drop: param.pure_wrt_drop, + kind, + } + }), + ); + + let own_start = (parent_count + params.len()) as u32; + + params.extend( + ast_generics + .params + .iter() + .filter(|param| match param.kind { + GenericParamKind::Lifetime { .. } => tcx.is_late_bound(param.hir_id), + GenericParamKind::Type { .. } | GenericParamKind::Const { .. } => false, + }) + .enumerate() + .map(|(i, param)| { + let kind = match param.kind { + GenericParamKind::Lifetime { .. } => { + ty::GenericParamDefKind::Lifetime { late_bound: true } + } + GenericParamKind::Type { .. } | GenericParamKind::Const { .. } => bug!(), + }; + + ty::GenericParamDef { + name: param.name.ident().name, + index: own_start + i as u32, + def_id: tcx.hir().local_def_id(param.hir_id).to_def_id(), + pure_wrt_drop: param.pure_wrt_drop, + kind, + } + }), + ); + + let type_start = (parent_count + params.len()) as u32; // provide junk type parameter defs - the only place that // cares about anything but the length is instantiation, @@ -354,103 +377,6 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::Generics { params, param_def_id_to_index, has_self: has_self || parent_has_self, - has_late_bound_regions: has_late_bound_regions(tcx, node), - } -} - -fn has_late_bound_regions<'tcx>(tcx: TyCtxt<'tcx>, node: Node<'tcx>) -> Option { - struct LateBoundRegionsDetector<'tcx> { - tcx: TyCtxt<'tcx>, - outer_index: ty::DebruijnIndex, - has_late_bound_regions: Option, - } - - impl<'tcx> Visitor<'tcx> for LateBoundRegionsDetector<'tcx> { - fn visit_ty(&mut self, ty: &'tcx hir::Ty<'tcx>) { - if self.has_late_bound_regions.is_some() { - return; - } - match ty.kind { - hir::TyKind::BareFn(..) => { - self.outer_index.shift_in(1); - intravisit::walk_ty(self, ty); - self.outer_index.shift_out(1); - } - _ => intravisit::walk_ty(self, ty), - } - } - - fn visit_poly_trait_ref(&mut self, tr: &'tcx hir::PolyTraitRef<'tcx>) { - if self.has_late_bound_regions.is_some() { - return; - } - self.outer_index.shift_in(1); - intravisit::walk_poly_trait_ref(self, tr); - self.outer_index.shift_out(1); - } - - fn visit_lifetime(&mut self, lt: &'tcx hir::Lifetime) { - if self.has_late_bound_regions.is_some() { - return; - } - - match self.tcx.named_region(lt.hir_id) { - Some(rl::Region::Static | rl::Region::EarlyBound(..)) => {} - Some(rl::Region::LateBound(debruijn, _, _)) if debruijn < self.outer_index => {} - Some(rl::Region::LateBound(..) | rl::Region::Free(..)) | None => { - self.has_late_bound_regions = Some(lt.span); - } - } - } - } - - fn has_late_bound_regions<'tcx>( - tcx: TyCtxt<'tcx>, - generics: &'tcx hir::Generics<'tcx>, - decl: &'tcx hir::FnDecl<'tcx>, - ) -> Option { - let mut visitor = LateBoundRegionsDetector { - tcx, - outer_index: ty::INNERMOST, - has_late_bound_regions: None, - }; - for param in generics.params { - if let GenericParamKind::Lifetime { .. } = param.kind { - if tcx.is_late_bound(param.hir_id) { - return Some(param.span); - } - } - } - visitor.visit_fn_decl(decl); - visitor.has_late_bound_regions - } - - match node { - Node::TraitItem(item) => match item.kind { - hir::TraitItemKind::Fn(ref sig, _) => { - has_late_bound_regions(tcx, &item.generics, sig.decl) - } - _ => None, - }, - Node::ImplItem(item) => match item.kind { - hir::ImplItemKind::Fn(ref sig, _) => { - has_late_bound_regions(tcx, &item.generics, sig.decl) - } - _ => None, - }, - Node::ForeignItem(item) => match item.kind { - hir::ForeignItemKind::Fn(fn_decl, _, ref generics) => { - has_late_bound_regions(tcx, generics, fn_decl) - } - _ => None, - }, - Node::Item(item) => match item.kind { - hir::ItemKind::Fn(ref sig, .., ref generics, _) => { - has_late_bound_regions(tcx, generics, sig.decl) - } - _ => None, - }, - _ => None, } } diff --git a/compiler/rustc_hir_analysis/src/collect/lifetimes.rs b/compiler/rustc_hir_analysis/src/collect/lifetimes.rs index c1214698cf770..2ad5ab6d86a92 100644 --- a/compiler/rustc_hir_analysis/src/collect/lifetimes.rs +++ b/compiler/rustc_hir_analysis/src/collect/lifetimes.rs @@ -1241,38 +1241,16 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { ) where F: for<'b, 'c> FnOnce(&'b mut LifetimeContext<'c, 'tcx>), { - let mut named_late_bound_vars = 0; let lifetimes: FxIndexMap = generics .params .iter() .filter_map(|param| match param.kind { - GenericParamKind::Lifetime { .. } => { - if self.tcx.is_late_bound(param.hir_id) { - let late_bound_idx = named_late_bound_vars; - named_late_bound_vars += 1; - Some(Region::late(late_bound_idx, self.tcx.hir(), param)) - } else { - Some(Region::early(self.tcx.hir(), param)) - } - } + GenericParamKind::Lifetime { .. } => Some(Region::early(self.tcx.hir(), param)), GenericParamKind::Type { .. } | GenericParamKind::Const { .. } => None, }) .collect(); - let binders: Vec<_> = generics - .params - .iter() - .filter(|param| { - matches!(param.kind, GenericParamKind::Lifetime { .. }) - && self.tcx.is_late_bound(param.hir_id) - }) - .enumerate() - .map(|(late_bound_idx, param)| { - let pair = Region::late(late_bound_idx as u32, self.tcx.hir(), param); - late_region_as_bound_region(self.tcx, &pair.1) - }) - .collect(); - self.record_late_bound_vars(hir_id, binders); + self.record_late_bound_vars(hir_id, vec![]); let scope = Scope::Binder { hir_id, lifetimes, diff --git a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs index 2e84e1d016007..c4bdc2deb3868 100644 --- a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs @@ -149,8 +149,6 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP }; let generics = tcx.generics_of(def_id); - let parent_count = generics.parent_count as u32; - let has_own_self = generics.has_self && parent_count == 0; // Below we'll consider the bounds on the type parameters (including `Self`) // and the explicit where-clauses, but to get the full set of predicates @@ -172,13 +170,6 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP predicates.insert((trait_ref.without_const().to_predicate(tcx), tcx.def_span(def_id))); } - // Collect the region predicates that were declared inline as - // well. In the case of parameters declared on a fn or method, we - // have to be careful to only iterate over early-bound regions. - let mut index = parent_count - + has_own_self as u32 - + super::early_bound_lifetimes_from_generics(tcx, ast_generics).count() as u32; - trace!(?predicates); trace!(?ast_generics); @@ -186,12 +177,12 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP // type parameter (e.g., ``). for param in ast_generics.params { match param.kind { - // We already dealt with early bound lifetimes above. - GenericParamKind::Lifetime { .. } => (), GenericParamKind::Type { .. } => { + let def_id = tcx.hir().local_def_id(param.hir_id); + let index = generics.param_def_id_to_index[&def_id.to_def_id()]; let name = param.name.ident().name; + let param_ty = ty::ParamTy::new(index, name).to_ty(tcx); - index += 1; let mut bounds = Bounds::default(); // Params are implicitly sized unless a `?Sized` bound is found @@ -206,10 +197,9 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP predicates.extend(bounds.predicates(tcx, param_ty)); trace!(?predicates); } - GenericParamKind::Const { .. } => { - // Bounds on const parameters are currently not possible. - index += 1; - } + GenericParamKind::Lifetime { .. } => {} + // Bounds on const parameters are currently not possible. + GenericParamKind::Const { .. } => {} } } diff --git a/compiler/rustc_hir_analysis/src/collect/type_of.rs b/compiler/rustc_hir_analysis/src/collect/type_of.rs index 32f359a815819..86d940fa57a1d 100644 --- a/compiler/rustc_hir_analysis/src/collect/type_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/type_of.rs @@ -853,7 +853,7 @@ fn infer_placeholder_type<'a>( } match ty.kind() { - ty::FnDef(def_id, _) => self.tcx.mk_fn_ptr(self.tcx.fn_sig(*def_id)), + ty::FnDef(..) => self.tcx.mk_fn_ptr(ty.fn_sig(self.tcx)), // FIXME: non-capturing closures should also suggest a function pointer ty::Closure(..) | ty::Generator(..) => { self.success = false; diff --git a/compiler/rustc_hir_analysis/src/impl_wf_check.rs b/compiler/rustc_hir_analysis/src/impl_wf_check.rs index a84257b939c52..8bef0bba8a89e 100644 --- a/compiler/rustc_hir_analysis/src/impl_wf_check.rs +++ b/compiler/rustc_hir_analysis/src/impl_wf_check.rs @@ -123,7 +123,7 @@ fn enforce_impl_params_are_constrained(tcx: TyCtxt<'_>, impl_def_id: LocalDefId) report_unused_parameter(tcx, tcx.def_span(param.def_id), "type", param_ty.name); } } - ty::GenericParamDefKind::Lifetime => { + ty::GenericParamDefKind::Lifetime { .. } => { let param_lt = cgp::Parameter::from(param.to_early_bound_region_data()); if lifetimes_in_associated_types.contains(¶m_lt) && // (*) !input_parameters.contains(¶m_lt) diff --git a/compiler/rustc_hir_analysis/src/lib.rs b/compiler/rustc_hir_analysis/src/lib.rs index dba505149de87..8ad95b33a16c9 100644 --- a/compiler/rustc_hir_analysis/src/lib.rs +++ b/compiler/rustc_hir_analysis/src/lib.rs @@ -134,6 +134,7 @@ fn require_c_abi_if_c_variadic(tcx: TyCtxt<'_>, decl: &hir::FnDecl<'_>, abi: Abi } } +#[instrument(level = "trace", skip(tcx), ret)] fn require_same_types<'tcx>( tcx: TyCtxt<'tcx>, cause: &ObligationCause<'tcx>, @@ -160,7 +161,7 @@ fn require_same_types<'tcx>( } fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) { - let main_fnsig = tcx.fn_sig(main_def_id); + let main_fnsig = tcx.type_of(main_def_id).fn_sig(tcx); let main_span = tcx.def_span(main_def_id); fn main_fn_diagnostics_hir_id(tcx: TyCtxt<'_>, def_id: DefId, sp: Span) -> hir::HirId { @@ -236,7 +237,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) { let main_diagnostics_hir_id = main_fn_diagnostics_hir_id(tcx, main_def_id, main_span); let main_fn_generics = tcx.generics_of(main_def_id); let main_fn_predicates = tcx.predicates_of(main_def_id); - if main_fn_generics.count() != 0 || !main_fnsig.bound_vars().is_empty() { + if main_fn_generics.count() != 0 { let generics_param_span = main_fn_generics_params_span(tcx, main_def_id); let msg = "`main` function is not allowed to have generic \ parameters"; @@ -294,15 +295,8 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) { let expected_return_type; if let Some(term_did) = tcx.lang_items().termination() { - let return_ty = main_fnsig.output(); + let return_ty = main_fnsig.output().skip_binder(); let return_ty_span = main_fn_return_type_span(tcx, main_def_id).unwrap_or(main_span); - if !return_ty.bound_vars().is_empty() { - let msg = "`main` function return type is not allowed to have generic \ - parameters"; - struct_span_err!(tcx.sess, return_ty_span, E0131, "{}", msg).emit(); - error = true; - } - let return_ty = return_ty.skip_binder(); let infcx = tcx.infer_ctxt().build(); // Main should have no WC, so empty param env is OK here. let param_env = ty::ParamEnv::empty(); @@ -320,19 +314,23 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) { error = true; } // now we can take the return type of the given main function - expected_return_type = main_fnsig.output(); + expected_return_type = return_ty; } else { // standard () main return type - expected_return_type = ty::Binder::dummy(tcx.mk_unit()); + expected_return_type = tcx.mk_unit(); } if error { return; } - let se_ty = tcx.mk_fn_ptr(expected_return_type.map_bound(|expected_return_type| { - tcx.mk_fn_sig(iter::empty(), expected_return_type, false, hir::Unsafety::Normal, Abi::Rust) - })); + let se_ty = tcx.mk_fn_ptr(ty::Binder::dummy(tcx.mk_fn_sig( + iter::empty(), + expected_return_type, + false, + hir::Unsafety::Normal, + Abi::Rust, + ))); require_same_types( tcx, @@ -428,7 +426,7 @@ fn check_start_fn_ty(tcx: TyCtxt<'_>, start_def_id: DefId) { tcx, &ObligationCause::new(start_span, start_id, ObligationCauseCode::StartFunctionType), se_ty, - tcx.mk_fn_ptr(tcx.fn_sig(start_def_id)), + tcx.mk_fn_ptr(tcx.type_of(start_def_id).fn_sig(tcx)), ); } _ => { diff --git a/compiler/rustc_hir_analysis/src/variance/constraints.rs b/compiler/rustc_hir_analysis/src/variance/constraints.rs index eaf0310d57aec..2ae878fba653e 100644 --- a/compiler/rustc_hir_analysis/src/variance/constraints.rs +++ b/compiler/rustc_hir_analysis/src/variance/constraints.rs @@ -287,7 +287,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { } ty::FnPtr(sig) => { - self.add_constraints_from_sig(current, sig, variance); + self.add_constraints_from_sig(current, sig.skip_binder(), variance); } ty::Error(_) => { @@ -381,14 +381,14 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { fn add_constraints_from_sig( &mut self, current: &CurrentItem, - sig: ty::PolyFnSig<'tcx>, + sig: ty::FnSig<'tcx>, variance: VarianceTermPtr<'a>, ) { let contra = self.contravariant(variance); - for &input in sig.skip_binder().inputs() { + for &input in sig.inputs() { self.add_constraints_from_ty(current, input, contra); } - self.add_constraints_from_ty(current, sig.skip_binder().output(), variance); + self.add_constraints_from_ty(current, sig.output(), variance); } /// Adds constraints appropriate for a region appearing in a diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index 1b33f2f02b8ad..7b007166cf2bd 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -371,7 +371,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) -> Ty<'tcx> { let (fn_sig, def_id) = match *callee_ty.kind() { ty::FnDef(def_id, subst) => { - let fn_sig = self.tcx.bound_fn_sig(def_id).subst(self.tcx, subst); + let fn_sig = callee_ty.fn_sig(self.tcx); // Unit testing: function items annotated with // `#[rustc_evaluate_where_clauses]` trigger special output diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs index 86597a703e833..b01772813709f 100644 --- a/compiler/rustc_hir_typeck/src/coercion.rs +++ b/compiler/rustc_hir_typeck/src/coercion.rs @@ -805,6 +805,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { }) } + #[instrument(level = "trace", skip(self, to_unsafe, normal))] fn coerce_from_safe_fn( &self, a: Ty<'tcx>, @@ -874,6 +875,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { match b.kind() { ty::FnPtr(b_sig) => { let a_sig = a.fn_sig(self.tcx); + debug!(?a_sig); if let ty::FnDef(def_id, _) = *a.kind() { // Intrinsics are not coercible to function pointers if self.tcx.is_intrinsic(def_id) { @@ -891,6 +893,8 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { let InferOk { value: a_sig, obligations: o1 } = self.normalize_associated_types_in_as_infer_ok(self.cause.span, a_sig); + debug!(?a_sig); + debug!(?o1); obligations.extend(o1); let a_fn_pointer = self.tcx.mk_fn_ptr(a_sig); diff --git a/compiler/rustc_hir_typeck/src/demand.rs b/compiler/rustc_hir_typeck/src/demand.rs index be14234afe28d..6ef6baf2d12a5 100644 --- a/compiler/rustc_hir_typeck/src/demand.rs +++ b/compiler/rustc_hir_typeck/src/demand.rs @@ -556,8 +556,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn has_only_self_parameter(&self, method: &AssocItem) -> bool { match method.kind { ty::AssocKind::Fn => { - method.fn_has_self_parameter - && self.tcx.fn_sig(method.def_id).inputs().skip_binder().len() == 1 + method.fn_has_self_parameter && self.tcx.fn_sig(method.def_id).inputs().len() == 1 } _ => false, } diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index 41b00fda03ebf..86ee10ac5539b 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -536,7 +536,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let ty::FnDef(did, ..) = *ty.kind() { let fn_sig = ty.fn_sig(tcx); - if tcx.fn_sig(did).abi() == RustIntrinsic && tcx.item_name(did) == sym::transmute { + if fn_sig.abi() == RustIntrinsic && tcx.item_name(did) == sym::transmute { let from = fn_sig.inputs().skip_binder()[0]; let to = fn_sig.output().skip_binder(); // We defer the transmute to the end of typeck, once all inference vars have diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index 6a1cffe3e6025..1942d4b862a51 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -1026,9 +1026,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { found: Ty<'tcx>, ) { let (sig, did, substs) = match (&expected.kind(), &found.kind()) { - (ty::FnDef(did1, substs1), ty::FnDef(did2, substs2)) => { - let sig1 = self.tcx.bound_fn_sig(*did1).subst(self.tcx, substs1); - let sig2 = self.tcx.bound_fn_sig(*did2).subst(self.tcx, substs2); + (ty::FnDef(did1, substs1), ty::FnDef(..)) => { + let sig1 = expected.fn_sig(self.tcx); + let sig2 = found.fn_sig(self.tcx); if sig1 != sig2 { return; } @@ -1039,7 +1039,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { (sig1, *did1, substs1) } (ty::FnDef(did, substs), ty::FnPtr(sig2)) => { - let sig1 = self.tcx.bound_fn_sig(*did).subst(self.tcx, substs); + let sig1 = expected.fn_sig(self.tcx); if sig1 != *sig2 { return; } @@ -1273,7 +1273,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { arg: &GenericArg<'_>, ) -> ty::GenericArg<'tcx> { match (¶m.kind, arg) { - (GenericParamDefKind::Lifetime, GenericArg::Lifetime(lt)) => { + (GenericParamDefKind::Lifetime { .. }, GenericArg::Lifetime(lt)) => { >::ast_region_to_region(self.fcx, lt, Some(param)).into() } (GenericParamDefKind::Type { .. }, GenericArg::Type(ty)) => { @@ -1301,7 +1301,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) -> ty::GenericArg<'tcx> { let tcx = self.fcx.tcx(); match param.kind { - GenericParamDefKind::Lifetime => { + GenericParamDefKind::Lifetime { .. } => { self.fcx.re_infer(Some(param), self.span).unwrap().into() } GenericParamDefKind::Type { has_default, .. } => { diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs index 08a3cbccfb05e..95f6e6a31207b 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs @@ -1909,7 +1909,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { receiver: Option<&'tcx hir::Expr<'tcx>>, args: &'tcx [hir::Expr<'tcx>], ) -> bool { - let sig = self.tcx.fn_sig(def_id).skip_binder(); + let sig = self.tcx.fn_sig(def_id); let args_referencing_param: Vec<_> = sig .inputs() .iter() diff --git a/compiler/rustc_hir_typeck/src/lib.rs b/compiler/rustc_hir_typeck/src/lib.rs index e862d577573b4..97ddff1cb880e 100644 --- a/compiler/rustc_hir_typeck/src/lib.rs +++ b/compiler/rustc_hir_typeck/src/lib.rs @@ -236,14 +236,15 @@ fn typeck_with_fallback<'tcx>( let fn_sig = if rustc_hir_analysis::collect::get_infer_ret_ty(&decl.output).is_some() { let fcx = FnCtxt::new(&inh, param_env, body.value.hir_id); >::ty_of_fn(&fcx, id, header.unsafety, header.abi, decl, None, None) + .no_bound_vars() + .unwrap() } else { tcx.fn_sig(def_id) }; - check_abi(tcx, id, span, fn_sig.abi()); + check_abi(tcx, id, span, fn_sig.abi); // Compute the function signature from point of view of inside the fn. - let fn_sig = tcx.liberate_late_bound_regions(def_id.to_def_id(), fn_sig); let fn_sig = inh.normalize_associated_types_in( body.value.span, body_id.hir_id, diff --git a/compiler/rustc_hir_typeck/src/method/confirm.rs b/compiler/rustc_hir_typeck/src/method/confirm.rs index be4ea99862222..cb19de37640e0 100644 --- a/compiler/rustc_hir_typeck/src/method/confirm.rs +++ b/compiler/rustc_hir_typeck/src/method/confirm.rs @@ -371,7 +371,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { arg: &GenericArg<'_>, ) -> subst::GenericArg<'tcx> { match (¶m.kind, arg) { - (GenericParamDefKind::Lifetime, GenericArg::Lifetime(lt)) => { + (GenericParamDefKind::Lifetime { .. }, GenericArg::Lifetime(lt)) => { >::ast_region_to_region(self.cfcx.fcx, lt, Some(param)) .into() } @@ -469,9 +469,6 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { let sig = sig.subst(self.tcx, all_substs); debug!("type scheme substituted, sig={:?}", sig); - let sig = self.replace_bound_vars_with_fresh_vars(sig); - debug!("late-bound lifetimes from method instantiated, sig={:?}", sig); - (sig, method_predicates) } diff --git a/compiler/rustc_hir_typeck/src/method/mod.rs b/compiler/rustc_hir_typeck/src/method/mod.rs index a1278edefbb71..0bbcf193f0743 100644 --- a/compiler/rustc_hir_typeck/src/method/mod.rs +++ b/compiler/rustc_hir_typeck/src/method/mod.rs @@ -135,7 +135,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) .map(|pick| { let sig = self.tcx.fn_sig(pick.item.def_id); - sig.inputs().skip_binder().len().saturating_sub(1) + sig.inputs().len().saturating_sub(1) }) .unwrap_or(0); @@ -277,7 +277,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Construct a trait-reference `self_ty : Trait` let substs = InternalSubsts::for_item(self.tcx, trait_def_id, |param, _| { match param.kind { - GenericParamDefKind::Lifetime | GenericParamDefKind::Const { .. } => {} + GenericParamDefKind::Lifetime { .. } | GenericParamDefKind::Const { .. } => {} GenericParamDefKind::Type { .. } => { if param.index == 0 { return self_ty.into(); @@ -317,7 +317,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Construct a trait-reference `self_ty : Trait` let substs = InternalSubsts::for_item(self.tcx, trait_def_id, |param, _| { match param.kind { - GenericParamDefKind::Lifetime | GenericParamDefKind::Const { .. } => {} + GenericParamDefKind::Lifetime { .. } | GenericParamDefKind::Const { .. } => {} GenericParamDefKind::Type { .. } => { if param.index == 0 { return self_ty.into(); @@ -413,18 +413,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // FIXME(#18741): it seems likely that we can consolidate some of this // code with the other method-lookup code. In particular, the second half // of this method is basically the same as confirmation. + #[instrument(level = "trace", skip(self), ret)] fn construct_obligation_for_trait( &self, span: Span, m_name: Ident, trait_def_id: DefId, obligation: traits::PredicateObligation<'tcx>, - substs: &'tcx ty::List>, + trait_substs: &'tcx ty::List>, opt_input_expr: Option<&'tcx hir::Expr<'tcx>>, is_op: bool, ) -> Option>> { - debug!(?obligation); - // Now we want to know if this can be matched if !self.predicate_may_hold(&obligation) { debug!("--> Cannot match obligation"); @@ -442,11 +441,22 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); return None; }; + debug!(?method_item); + let def_id = method_item.def_id; - let generics = tcx.generics_of(def_id); - assert_eq!(generics.params.len(), 0); + #[cfg(debug_assertions)] + { + let generics = tcx.generics_of(def_id).own_counts(); + assert_eq!(generics.types, 0); + assert_eq!(generics.consts, 0); + } + let method_substs = trait_substs.extend_to(self.tcx, def_id, |param, _| match param.kind { + GenericParamDefKind::Lifetime { .. } => self.var_for_def(span, param).into(), + GenericParamDefKind::Const { .. } | GenericParamDefKind::Type { .. } => { + bug!() + } + }); - debug!("lookup_in_trait_adjusted: method_item={:?}", method_item); let mut obligations = vec![]; // Instantiate late-bound regions and substitute the trait @@ -455,8 +465,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // N.B., instantiate late-bound regions first so that // `instantiate_type_scheme` can normalize associated types that // may reference those regions. - let fn_sig = tcx.bound_fn_sig(def_id); - let fn_sig = fn_sig.subst(self.tcx, substs); + let fn_sig = tcx.mk_fn_def(def_id, method_substs).fn_sig(self.tcx); let fn_sig = self.replace_bound_vars_with_fresh_vars(span, infer::FnCall, fn_sig); let InferOk { value, obligations: o } = if is_op { @@ -477,7 +486,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // // Note that as the method comes from a trait, it should not have // any late-bound regions appearing in its bounds. - let bounds = self.tcx.predicates_of(def_id).instantiate(self.tcx, substs); + let bounds = self.tcx.predicates_of(def_id).instantiate(self.tcx, method_substs); let InferOk { value, obligations: o } = if is_op { self.normalize_op_associated_types_in_as_infer_ok(span, bounds, opt_input_expr) @@ -524,7 +533,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ty::Binder::dummy(ty::PredicateKind::WellFormed(method_ty.into())).to_predicate(tcx), )); - let callee = MethodCallee { def_id, substs, sig: fn_sig }; + let callee = MethodCallee { def_id, substs: method_substs, sig: fn_sig }; debug!("callee = {:?}", callee); diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs index 74cf2ac32aab2..30d5ae81a2e9a 100644 --- a/compiler/rustc_hir_typeck/src/method/probe.rs +++ b/compiler/rustc_hir_typeck/src/method/probe.rs @@ -13,7 +13,7 @@ use rustc_hir::def::Namespace; use rustc_infer::infer::canonical::OriginalQueryValues; use rustc_infer::infer::canonical::{Canonical, QueryResponse}; use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; -use rustc_infer::infer::{self, InferOk, TyCtxtInferExt}; +use rustc_infer::infer::{InferOk, TyCtxtInferExt}; use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind}; use rustc_middle::middle::stability; use rustc_middle::ty::fast_reject::{simplify_type, TreatParams}; @@ -893,8 +893,6 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { self.probe(|_| { let substs = self.fresh_substs_for_item(self.span, method.def_id); let fty = fty.subst(self.tcx, substs); - let fty = - self.replace_bound_vars_with_fresh_vars(self.span, infer::FnCall, fty); if let Some(self_ty) = self_ty { if self @@ -1778,7 +1776,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { let generics = self.tcx.generics_of(method); assert_eq!(substs.len(), generics.parent_count as usize); - let xform_fn_sig = if generics.params.is_empty() { + if generics.params.is_empty() { fn_sig.subst(self.tcx, substs) } else { let substs = InternalSubsts::for_item(self.tcx, method, |param, _| { @@ -1787,7 +1785,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { substs[i] } else { match param.kind { - GenericParamDefKind::Lifetime => { + GenericParamDefKind::Lifetime { .. } => { // In general, during probe we erase regions. self.tcx.lifetimes.re_erased.into() } @@ -1798,9 +1796,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { } }); fn_sig.subst(self.tcx, substs) - }; - - self.erase_late_bound_regions(xform_fn_sig) + } } /// Gets the type of an impl and generate substitutions with inference vars. @@ -1813,7 +1809,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { fn fresh_item_substs(&self, def_id: DefId) -> SubstsRef<'tcx> { InternalSubsts::for_item(self.tcx, def_id, |param, _| match param.kind { - GenericParamDefKind::Lifetime => self.tcx.lifetimes.re_erased.into(), + GenericParamDefKind::Lifetime { .. } => self.tcx.lifetimes.re_erased.into(), GenericParamDefKind::Type { .. } => self .next_ty_var(TypeVariableOrigin { kind: TypeVariableOriginKind::SubstitutionPlaceholder, diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index f4351bfa84aed..8bfd386309103 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -177,7 +177,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .tcx .fn_sig(item.def_id) .inputs() - .skip_binder() .get(0) .filter(|ty| ty.is_region_ptr() && !rcvr_ty.is_region_ptr()) .copied() @@ -1851,7 +1850,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // just changing the path. && pick.item.fn_has_self_parameter && let Some(self_ty) = - self.tcx.fn_sig(pick.item.def_id).inputs().skip_binder().get(0) + self.tcx.fn_sig(pick.item.def_id).inputs().get(0) && self_ty.is_ref() { let suggested_path = match deref_ty.kind() { @@ -2085,7 +2084,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // implement the `AsRef` trait. let skip = skippable.contains(&did) || (("Pin::new" == *pre) && (sym::as_ref == item_name.name)) - || inputs_len.map_or(false, |inputs_len| pick.item.kind == ty::AssocKind::Fn && self.tcx.fn_sig(pick.item.def_id).skip_binder().inputs().len() != inputs_len); + || inputs_len.map_or(false, |inputs_len| pick.item.kind == ty::AssocKind::Fn && self.tcx.fn_sig(pick.item.def_id).inputs().len() != inputs_len); // Make sure the method is defined for the *actual* receiver: we don't // want to treat `Box` as a receiver if it only works because of // an autoderef to `&self` @@ -2448,10 +2447,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); // check the method arguments number - if let Ok(pick) = probe && - let fn_sig = self.tcx.fn_sig(pick.item.def_id) && - let fn_args = fn_sig.skip_binder().inputs() && - fn_args.len() == args.len() + 1 { + if let Ok(pick) = probe + && let fn_sig = self.tcx.fn_sig(pick.item.def_id) + && let fn_args = fn_sig.inputs() + && fn_args.len() == args.len() + 1 + { err.span_suggestion_verbose( method_name.span.shrink_to_hi(), &format!("try calling `{}` instead", new_name.name.as_str()), diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index 9ff703e521ff6..4ce6cfd3f438e 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -574,6 +574,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { } fn path_generic_args( self, + _: bool, print_prefix: impl FnOnce(Self) -> Result, _args: &[GenericArg<'tcx>], ) -> Result { @@ -1419,8 +1420,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { } (ty::FnDef(did1, substs1), ty::FnDef(did2, substs2)) => { - let sig1 = self.tcx.bound_fn_sig(*did1).subst(self.tcx, substs1); - let sig2 = self.tcx.bound_fn_sig(*did2).subst(self.tcx, substs2); + let sig1 = t1.fn_sig(self.tcx); + let sig2 = t2.fn_sig(self.tcx); let mut values = self.cmp_fn_sig(&sig1, &sig2); let path1 = format!(" {{{}}}", self.tcx.def_path_str_with_substs(*did1, substs1)); let path2 = format!(" {{{}}}", self.tcx.def_path_str_with_substs(*did2, substs2)); @@ -1431,7 +1432,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { } (ty::FnDef(did1, substs1), ty::FnPtr(sig2)) => { - let sig1 = self.tcx.bound_fn_sig(*did1).subst(self.tcx, substs1); + let sig1 = t1.fn_sig(self.tcx); let mut values = self.cmp_fn_sig(&sig1, sig2); values.0.push_highlighted(format!( " {{{}}}", @@ -1441,7 +1442,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { } (ty::FnPtr(sig1), ty::FnDef(did2, substs2)) => { - let sig2 = self.tcx.bound_fn_sig(*did2).subst(self.tcx, substs2); + let sig2 = t2.fn_sig(self.tcx); let mut values = self.cmp_fn_sig(sig1, &sig2); values.1.push_normal(format!( " {{{}}}", @@ -2517,7 +2518,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { let lts_names = iter::successors(Some(generics), |g| g.parent.map(|p| self.tcx.generics_of(p))) .flat_map(|g| &g.params) - .filter(|p| matches!(p.kind, ty::GenericParamDefKind::Lifetime)) + .filter(|p| matches!(p.kind, ty::GenericParamDefKind::Lifetime { .. })) .map(|p| p.name.as_str()) .collect::>(); possible diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/util.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/util.rs index f1461d7010d5b..6bb3fd018339f 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/util.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/util.rs @@ -65,9 +65,8 @@ pub fn find_param_with_region<'tcx>( let owner_id = hir.body_owner(body_id); let fn_decl = hir.fn_decl_by_hir_id(owner_id).unwrap(); - let poly_fn_sig = tcx.fn_sig(id); + let fn_sig = tcx.fn_sig(id); - let fn_sig = tcx.liberate_late_bound_regions(id, poly_fn_sig); let body = hir.body(body_id); body.params .iter() diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index 7e2ea6c0e269c..13963ebc8621e 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -1177,7 +1177,7 @@ impl<'tcx> InferCtxt<'tcx> { pub fn var_for_def(&self, span: Span, param: &ty::GenericParamDef) -> GenericArg<'tcx> { match param.kind { - GenericParamDefKind::Lifetime => { + GenericParamDefKind::Lifetime { .. } => { // Create a region inference variable for the given // region parameter definition. self.next_region_var(EarlyBoundRegion(span, param.name)).into() diff --git a/compiler/rustc_infer/src/infer/region_constraints/leak_check.rs b/compiler/rustc_infer/src/infer/region_constraints/leak_check.rs index 90858e3072ac0..62c7eae6178ad 100644 --- a/compiler/rustc_infer/src/infer/region_constraints/leak_check.rs +++ b/compiler/rustc_infer/src/infer/region_constraints/leak_check.rs @@ -61,6 +61,7 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> { /// /// * R: P1, even if R cannot name P1, because R = 'static is a valid sol'n /// * R: P1, R: P2, as above + #[instrument(level = "debug", skip(self, tcx, snapshot))] pub fn leak_check( &mut self, tcx: TyCtxt<'tcx>, @@ -68,10 +69,7 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> { max_universe: ty::UniverseIndex, snapshot: &CombinedSnapshot<'tcx>, ) -> RelateResult<'tcx, ()> { - debug!( - "leak_check(max_universe={:?}, snapshot.universe={:?}, overly_polymorphic={:?})", - max_universe, snapshot.universe, overly_polymorphic - ); + debug!("snapshot.universe={:?}", snapshot.universe,); assert!(UndoLogs::>::in_snapshot(&self.undo_log)); diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index 63a11877333ef..584c331b63e8d 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -1232,6 +1232,7 @@ impl<'tcx> LateContext<'tcx> { fn path_generic_args( self, + _: bool, print_prefix: impl FnOnce(Self) -> Result, _args: &[GenericArg<'tcx>], ) -> Result { diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index fee6e080c4fc7..314fe02aa0284 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -530,6 +530,11 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) { "converted into hard error, see issue #71800 \ for more information", ); + store.register_removed( + "late_bound_lifetime_arguments", + "converted into hard error, see issue #42868 \ + for more information", + ); } fn register_internals(store: &mut LintStore) { diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index 7c99bb2790fd0..355cbb841df9f 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -1285,7 +1285,6 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { fn check_foreign_fn(&mut self, id: hir::HirId, decl: &hir::FnDecl<'_>) { let def_id = self.cx.tcx.hir().local_def_id(id); let sig = self.cx.tcx.fn_sig(def_id); - let sig = self.cx.tcx.erase_late_bound_regions(sig); for (input_ty, input_hir) in iter::zip(sig.inputs(), decl.inputs) { self.check_type_for_ffi_and_report_errors(input_hir.span, *input_ty, false, false); diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 61ee467f59577..79d8126679783 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -1354,47 +1354,6 @@ declare_lint! { }; } -declare_lint! { - /// The `late_bound_lifetime_arguments` lint detects generic lifetime - /// arguments in path segments with late bound lifetime parameters. - /// - /// ### Example - /// - /// ```rust - /// struct S; - /// - /// impl S { - /// fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} - /// } - /// - /// fn main() { - /// S.late::<'static>(&0, &0); - /// } - /// ``` - /// - /// {{produces}} - /// - /// ### Explanation - /// - /// It is not clear how to provide arguments for early-bound lifetime - /// parameters if they are intermixed with late-bound parameters in the - /// same list. For now, providing any explicit arguments will trigger this - /// lint if late-bound parameters are present, so in the future a solution - /// can be adopted without hitting backward compatibility issues. This is - /// a [future-incompatible] lint to transition this to a hard error in the - /// future. See [issue #42868] for more details, along with a description - /// of the difference between early and late-bound parameters. - /// - /// [issue #42868]: https://github.com/rust-lang/rust/issues/42868 - /// [future-incompatible]: ../index.md#future-incompatible-lints - pub LATE_BOUND_LIFETIME_ARGUMENTS, - Warn, - "detects generic lifetime arguments in path segments with late bound lifetime parameters", - @future_incompatible = FutureIncompatibleInfo { - reference: "issue #42868 ", - }; -} - declare_lint! { /// The `order_dependent_trait_objects` lint detects a trait coherency /// violation that would allow creating two trait impls for the same @@ -3270,7 +3229,6 @@ declare_lint_pass! { CONST_ITEM_MUTATION, PATTERNS_IN_FNS_WITHOUT_BODY, MISSING_FRAGMENT_SPECIFIER, - LATE_BOUND_LIFETIME_ARGUMENTS, ORDER_DEPENDENT_TRAIT_OBJECTS, COHERENCE_LEAK_CHECK, DEPRECATED, diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 73f2a3e0b636e..ac4a508018ff3 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -1110,7 +1110,7 @@ fn should_encode_trait_impl_trait_tys<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> // of the trait fn to look for any RPITITs, but that's kinda doing a lot // of work. We can probably remove this when we refactor RPITITs to be // associated types. - tcx.fn_sig(trait_item_def_id).skip_binder().output().walk().any(|arg| { + tcx.fn_sig(trait_item_def_id).output().walk().any(|arg| { if let ty::GenericArgKind::Type(ty) = arg.unpack() && let ty::Projection(data) = ty.kind() && tcx.def_kind(data.item_def_id) == DefKind::ImplTraitPlaceholder @@ -1711,9 +1711,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { record!(self.tables.generator_diagnostic_data[def_id.to_def_id()] <- generator_diagnostic_data); } - ty::Closure(_, substs) => { - record!(self.tables.fn_sig[def_id.to_def_id()] <- substs.as_closure().sig()); - } + ty::Closure(..) => {} _ => bug!("closure that is neither generator nor closure"), } diff --git a/compiler/rustc_metadata/src/rmeta/mod.rs b/compiler/rustc_metadata/src/rmeta/mod.rs index 27dc8ff16ac56..3ef236f4aa829 100644 --- a/compiler/rustc_metadata/src/rmeta/mod.rs +++ b/compiler/rustc_metadata/src/rmeta/mod.rs @@ -356,7 +356,7 @@ define_tables! { super_predicates_of: Table>>, type_of: Table>>, variances_of: Table>, - fn_sig: Table>>, + fn_sig: Table>>, codegen_fn_attrs: Table>, impl_trait_ref: Table>>, const_param_default: Table>>, diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index 67c85ef0d3b50..5d373acbe2a0e 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -808,7 +808,7 @@ rustc_queries! { } /// Computes the signature of the function. - query fn_sig(key: DefId) -> ty::PolyFnSig<'tcx> { + query fn_sig(key: DefId) -> ty::FnSig<'tcx> { desc { |tcx| "computing function signature of `{}`", tcx.def_path_str(key) } cache_on_disk_if { key.is_local() } separate_provide_extern diff --git a/compiler/rustc_middle/src/ty/adjustment.rs b/compiler/rustc_middle/src/ty/adjustment.rs index 4682ac96b5297..4a7aeed5a67f4 100644 --- a/compiler/rustc_middle/src/ty/adjustment.rs +++ b/compiler/rustc_middle/src/ty/adjustment.rs @@ -132,7 +132,9 @@ impl<'tcx> OverloadedDeref<'tcx> { .find(|m| m.kind == ty::AssocKind::Fn) .unwrap() .def_id; - (method_def_id, tcx.mk_substs_trait(source, &[])) + let substs = + tcx.mk_substs_trait(source, &[]).extend_with_region(tcx, method_def_id, self.region); + (method_def_id, substs) } } diff --git a/compiler/rustc_middle/src/ty/assoc.rs b/compiler/rustc_middle/src/ty/assoc.rs index 55ee5bd2f810d..bb27c3961f680 100644 --- a/compiler/rustc_middle/src/ty/assoc.rs +++ b/compiler/rustc_middle/src/ty/assoc.rs @@ -74,7 +74,7 @@ impl AssocItem { // late-bound regions, and we don't want method signatures to show up // `as for<'r> fn(&'r MyType)`. Pretty-printing handles late-bound // regions just fine, showing `fn(&MyType)`. - tcx.fn_sig(self.def_id).skip_binder().to_string() + tcx.fn_sig(self.def_id).to_string() } ty::AssocKind::Type => format!("type {};", self.name), ty::AssocKind::Const => { diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 94e3f3b63c813..6c66a7c256e66 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -2434,7 +2434,7 @@ impl<'tcx> TyCtxt<'tcx> { let adt_def = self.adt_def(wrapper_def_id); let substs = InternalSubsts::for_item(self, wrapper_def_id, |param, substs| match param.kind { - GenericParamDefKind::Lifetime | GenericParamDefKind::Const { .. } => bug!(), + GenericParamDefKind::Lifetime { .. } | GenericParamDefKind::Const { .. } => bug!(), GenericParamDefKind::Type { has_default, .. } => { if param.index == 0 { ty_param.into() @@ -2532,6 +2532,7 @@ impl<'tcx> TyCtxt<'tcx> { #[inline] pub fn mk_fn_def(self, def_id: DefId, substs: SubstsRef<'tcx>) -> Ty<'tcx> { + debug_assert_eq!(self.generics_of(def_id).count(), substs.len()); self.mk_ty(FnDef(def_id, substs)) } @@ -2617,7 +2618,7 @@ impl<'tcx> TyCtxt<'tcx> { pub fn mk_param_from_def(self, param: &ty::GenericParamDef) -> GenericArg<'tcx> { match param.kind { - GenericParamDefKind::Lifetime => { + GenericParamDefKind::Lifetime { .. } => { self.mk_region(ty::ReEarlyBound(param.to_early_bound_region_data())).into() } GenericParamDefKind::Type { .. } => self.mk_ty_param(param.index, param.name).into(), diff --git a/compiler/rustc_middle/src/ty/error.rs b/compiler/rustc_middle/src/ty/error.rs index 52f16ad88f693..38b7d24155483 100644 --- a/compiler/rustc_middle/src/ty/error.rs +++ b/compiler/rustc_middle/src/ty/error.rs @@ -813,7 +813,7 @@ fn foo(&self) -> Self::T { String::new() } }) .filter_map(|(_, item)| { let method = self.fn_sig(item.def_id); - match *method.output().skip_binder().kind() { + match *method.output().kind() { ty::Projection(ty::ProjectionTy { item_def_id, .. }) if item_def_id == proj_ty_item_def_id => { @@ -985,7 +985,7 @@ fn foo(&self) -> Self::T { String::new() } fn format_generic_args(self, args: &[ty::GenericArg<'tcx>]) -> String { FmtPrinter::new(self, hir::def::Namespace::TypeNS) - .path_generic_args(Ok, args) + .path_generic_args(true, Ok, args) .expect("could not write to `String`.") .into_buffer() } diff --git a/compiler/rustc_middle/src/ty/generics.rs b/compiler/rustc_middle/src/ty/generics.rs index 19754d1453f89..12fd55dd26f95 100644 --- a/compiler/rustc_middle/src/ty/generics.rs +++ b/compiler/rustc_middle/src/ty/generics.rs @@ -10,7 +10,7 @@ use super::{EarlyBoundRegion, InstantiatedPredicates, ParamConst, ParamTy, Predi #[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable)] pub enum GenericParamDefKind { - Lifetime, + Lifetime { late_bound: bool }, Type { has_default: bool, synthetic: bool }, Const { has_default: bool }, } @@ -18,14 +18,14 @@ pub enum GenericParamDefKind { impl GenericParamDefKind { pub fn descr(&self) -> &'static str { match self { - GenericParamDefKind::Lifetime => "lifetime", + GenericParamDefKind::Lifetime { .. } => "lifetime", GenericParamDefKind::Type { .. } => "type", GenericParamDefKind::Const { .. } => "constant", } } pub fn to_ord(&self) -> ast::ParamKindOrd { match self { - GenericParamDefKind::Lifetime => ast::ParamKindOrd::Lifetime, + GenericParamDefKind::Lifetime { .. } => ast::ParamKindOrd::Lifetime, GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { .. } => { ast::ParamKindOrd::TypeOrConst } @@ -34,7 +34,7 @@ impl GenericParamDefKind { pub fn is_ty_or_const(&self) -> bool { match self { - GenericParamDefKind::Lifetime => false, + GenericParamDefKind::Lifetime { .. } => false, GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { .. } => true, } } @@ -63,7 +63,7 @@ pub struct GenericParamDef { impl GenericParamDef { pub fn to_early_bound_region_data(&self) -> ty::EarlyBoundRegion { - if let GenericParamDefKind::Lifetime = self.kind { + if let GenericParamDefKind::Lifetime { .. } = self.kind { ty::EarlyBoundRegion { def_id: self.def_id, index: self.index, name: self.name } } else { bug!("cannot convert a non-lifetime parameter def to an early bound region") @@ -74,7 +74,7 @@ impl GenericParamDef { match self.kind { GenericParamDefKind::Type { has_default, .. } | GenericParamDefKind::Const { has_default } => has_default, - GenericParamDefKind::Lifetime => false, + GenericParamDefKind::Lifetime { .. } => false, } } @@ -97,6 +97,7 @@ impl GenericParamDef { #[derive(Default)] pub struct GenericParamCount { pub lifetimes: usize, + pub early_lifetimes: usize, pub types: usize, pub consts: usize, } @@ -117,7 +118,6 @@ pub struct Generics { pub param_def_id_to_index: FxHashMap, pub has_self: bool, - pub has_late_bound_regions: Option, } impl<'tcx> Generics { @@ -149,7 +149,10 @@ impl<'tcx> Generics { for param in &self.params { match param.kind { - GenericParamDefKind::Lifetime => own_counts.lifetimes += 1, + GenericParamDefKind::Lifetime { late_bound } => { + own_counts.lifetimes += 1; + own_counts.early_lifetimes += !late_bound as usize; + } GenericParamDefKind::Type { .. } => own_counts.types += 1, GenericParamDefKind::Const { .. } => own_counts.consts += 1, } @@ -163,7 +166,7 @@ impl<'tcx> Generics { for param in &self.params { match param.kind { - GenericParamDefKind::Lifetime => (), + GenericParamDefKind::Lifetime { .. } => (), GenericParamDefKind::Type { has_default, .. } => { own_defaults.types += has_default as usize; } @@ -195,7 +198,7 @@ impl<'tcx> Generics { GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { .. } => { return true; } - GenericParamDefKind::Lifetime => {} + GenericParamDefKind::Lifetime { .. } => {} } } false @@ -219,7 +222,7 @@ impl<'tcx> Generics { ) -> &'tcx GenericParamDef { let param = self.param_at(param.index as usize, tcx); match param.kind { - GenericParamDefKind::Lifetime => param, + GenericParamDefKind::Lifetime { .. } => param, _ => bug!("expected lifetime parameter, but found another generic parameter"), } } diff --git a/compiler/rustc_middle/src/ty/instance.rs b/compiler/rustc_middle/src/ty/instance.rs index 6c1414f7b8ac8..fa6885b11085f 100644 --- a/compiler/rustc_middle/src/ty/instance.rs +++ b/compiler/rustc_middle/src/ty/instance.rs @@ -314,7 +314,7 @@ impl<'tcx> Instance<'tcx> { pub fn mono(tcx: TyCtxt<'tcx>, def_id: DefId) -> Instance<'tcx> { let substs = InternalSubsts::for_item(tcx, def_id, |param, _| match param.kind { - ty::GenericParamDefKind::Lifetime => tcx.lifetimes.re_erased.into(), + ty::GenericParamDefKind::Lifetime { .. } => tcx.lifetimes.re_erased.into(), ty::GenericParamDefKind::Type { .. } => { bug!("Instance::mono: {:?} has type parameters", def_id) } @@ -427,8 +427,8 @@ impl<'tcx> Instance<'tcx> { ) -> Option> { debug!("resolve_for_vtable(def_id={:?}, substs={:?})", def_id, substs); let fn_sig = tcx.fn_sig(def_id); - let is_vtable_shim = !fn_sig.inputs().skip_binder().is_empty() - && fn_sig.input(0).skip_binder().is_param(0) + let is_vtable_shim = !fn_sig.inputs().is_empty() + && fn_sig.input(0).is_param(0) && tcx.generics_of(def_id).has_self; if is_vtable_shim { debug!(" => associated item with unsizeable self: Self"); diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 9671d3a32f945..5ff5830c74080 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -1417,7 +1417,7 @@ impl<'tcx> OpaqueHiddenType<'tcx> { /// identified by both a universe, as well as a name residing within that universe. Distinct bound /// regions/types/consts within the same universe simply have an unknown relationship to one /// another. -#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] #[derive(HashStable, TyEncodable, TyDecodable)] pub struct Placeholder { pub universe: UniverseIndex, diff --git a/compiler/rustc_middle/src/ty/print/mod.rs b/compiler/rustc_middle/src/ty/print/mod.rs index 44b9548db89c8..26b721ca42d69 100644 --- a/compiler/rustc_middle/src/ty/print/mod.rs +++ b/compiler/rustc_middle/src/ty/print/mod.rs @@ -3,6 +3,7 @@ use crate::ty::{self, DefIdTree, Ty, TyCtxt}; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::sso::SsoHashSet; +use rustc_hir::def::DefKind; use rustc_hir::def_id::{CrateNum, DefId, LocalDefId}; use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData}; @@ -92,6 +93,7 @@ pub trait Printer<'tcx>: Sized { fn path_generic_args( self, + forbid_lifetime_elision: bool, print_prefix: impl FnOnce(Self) -> Result, args: &[GenericArg<'tcx>], ) -> Result; @@ -150,7 +152,12 @@ pub trait Printer<'tcx>: Sized { _ => { if !generics.params.is_empty() && substs.len() >= generics.count() { let args = generics.own_substs_no_defaults(self.tcx(), substs); + let forbid_elision = !matches!( + self.tcx().def_kind(def_id), + DefKind::Fn | DefKind::AssocFn + ); return self.path_generic_args( + forbid_elision, |cx| cx.print_def_path(def_id, parent_substs), args, ); diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index b8ee2b994b1e4..4dae673182140 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -1845,12 +1845,18 @@ impl<'tcx> Printer<'tcx> for FmtPrinter<'_, 'tcx> { fn path_generic_args( mut self, + forbid_lifetime_elision: bool, print_prefix: impl FnOnce(Self) -> Result, args: &[GenericArg<'tcx>], ) -> Result { self = print_prefix(self)?; - if args.first().is_some() { + let all_elided = args.iter().all(|arg| match arg.unpack() { + ty::GenericArgKind::Lifetime(lt) => !lt.has_name(), + _ => false, + }); + + if !args.is_empty() && (forbid_lifetime_elision || self.tcx.sess.verbose() || !all_elided) { if self.in_value { write!(self, "::")?; } @@ -2218,32 +2224,27 @@ impl<'tcx> FmtPrinter<'_, 'tcx> { let regions: Vec<_> = value .bound_vars() .into_iter() - .map(|var| { + .enumerate() + .map(|(index, var)| { let ty::BoundVariableKind::Region(var) = var else { - // This doesn't really matter because it doesn't get used, - // it's just an empty value - return ty::BrAnon(0); - }; - match var { + // This doesn't really matter because it doesn't get used, + // it's just an empty value + return ty::BrAnon(0); + }; + start_or_continue(&mut self, "for<", ", "); + let (def_id, name) = match var { ty::BrAnon(_) | ty::BrEnv => { - start_or_continue(&mut self, "for<", ", "); let name = next_name(&self); - debug!(?name); - do_continue(&mut self, name); - ty::BrNamed(CRATE_DEF_ID.to_def_id(), name) + (CRATE_DEF_ID.to_def_id(), name) } ty::BrNamed(def_id, kw::UnderscoreLifetime) => { - start_or_continue(&mut self, "for<", ", "); let name = next_name(&self); - do_continue(&mut self, name); - ty::BrNamed(def_id, name) + (def_id, name) } - ty::BrNamed(def_id, name) => { - start_or_continue(&mut self, "for<", ", "); - do_continue(&mut self, name); - ty::BrNamed(def_id, name) - } - } + ty::BrNamed(def_id, name) => (def_id, name), + }; + let _ = write!(&mut self, "{}^{}", name, index); + ty::BrNamed(def_id, name) }) .collect(); start_or_continue(&mut self, "", "> "); diff --git a/compiler/rustc_middle/src/ty/structural_impls.rs b/compiler/rustc_middle/src/ty/structural_impls.rs index 2cad333e3f52a..0fceeee68fe28 100644 --- a/compiler/rustc_middle/src/ty/structural_impls.rs +++ b/compiler/rustc_middle/src/ty/structural_impls.rs @@ -11,6 +11,7 @@ use crate::ty::{self, InferConst, Lift, Term, TermKind, Ty, TyCtxt}; use rustc_data_structures::functor::IdFunctor; use rustc_hir::def::Namespace; use rustc_index::vec::{Idx, IndexVec}; +use rustc_span::symbol::kw; use std::fmt; use std::mem::ManuallyDrop; @@ -65,25 +66,47 @@ impl<'tcx> fmt::Debug for ty::adjustment::Adjustment<'tcx> { } } +impl fmt::Debug for ty::EarlyBoundRegion { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + if self.name != kw::Empty && self.name != kw::UnderscoreLifetime { + write!(f, "{}/{}", self.name, self.index) + } else { + write!(f, "BrNamed({:?})/{}", self.def_id, self.index) + } + } +} + +impl fmt::Debug for ty::BoundRegion { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{:?}^{:?}", self.kind, self.var) + } +} + impl fmt::Debug for ty::BoundRegionKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { - ty::BrAnon(n) => write!(f, "BrAnon({:?})", n), + ty::BrAnon(n) => write!(f, "'{}", n), ty::BrNamed(did, name) => { - if did.is_crate_root() { - write!(f, "BrNamed({})", name) + if name != kw::Empty && name != kw::UnderscoreLifetime { + write!(f, "{}", name) } else { - write!(f, "BrNamed({:?}, {})", did, name) + write!(f, "BrNamed({:?})", did) } } - ty::BrEnv => write!(f, "BrEnv"), + ty::BrEnv => write!(f, "'env"), } } } impl fmt::Debug for ty::FreeRegion { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "ReFree({:?}, {:?})", self.scope, self.bound_region) + write!(f, "ReFree({:?}, {:?})", self.bound_region, self.scope) + } +} + +impl fmt::Debug for ty::Placeholder { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "Placeholder({:?}, {:?})", self.name, self.universe) } } diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index cf420bafeb12f..a786f3fbcd478 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -14,6 +14,7 @@ use crate::ty::{List, ParamEnv}; use hir::def::DefKind; use polonius_engine::Atom; use rustc_data_structures::captures::Captures; +use rustc_data_structures::fx::FxIndexSet; use rustc_data_structures::intern::Interned; use rustc_hir as hir; use rustc_hir::def_id::DefId; @@ -71,7 +72,7 @@ pub enum BoundRegionKind { BrEnv, } -#[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable, Debug, PartialOrd, Ord)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable, PartialOrd, Ord)] #[derive(HashStable)] pub struct BoundRegion { pub var: BoundVar, @@ -1215,6 +1216,11 @@ impl<'tcx> FnSig<'tcx> { &self.inputs_and_output[..self.inputs_and_output.len() - 1] } + #[inline] + pub fn input(&self, index: usize) -> Ty<'tcx> { + self.inputs()[index] + } + pub fn output(&self) -> Ty<'tcx> { self.inputs_and_output[self.inputs_and_output.len() - 1] } @@ -1239,6 +1245,10 @@ impl<'tcx> PolyFnSig<'tcx> { self.map_bound_ref_unchecked(|fn_sig| fn_sig.inputs()) } #[inline] + pub fn iter_inputs(&self) -> impl Iterator>> + '_ { + self.skip_binder().inputs().iter().map(|&ty| self.rebind(ty)) + } + #[inline] pub fn input(&self, index: usize) -> ty::Binder<'tcx, Ty<'tcx>> { self.map_bound_ref(|fn_sig| fn_sig.inputs()[index]) } @@ -1329,12 +1339,6 @@ pub struct EarlyBoundRegion { pub name: Symbol, } -impl fmt::Debug for EarlyBoundRegion { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}, {}", self.index, self.name) - } -} - /// A **`const`** **v**ariable **ID**. #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[derive(HashStable, TyEncodable, TyDecodable)] @@ -1929,7 +1933,31 @@ impl<'tcx> Ty<'tcx> { pub fn fn_sig(self, tcx: TyCtxt<'tcx>) -> PolyFnSig<'tcx> { match self.kind() { - FnDef(def_id, substs) => tcx.bound_fn_sig(*def_id).subst(tcx, substs), + FnDef(def_id, substs) => { + let fn_sig = tcx.fn_sig(*def_id); + let generics = tcx.generics_of(*def_id); + let mut bound_vars = FxIndexSet::default(); + let fn_sig = tcx.fold_regions(fn_sig, |region, debruijn| { + if let ty::ReEarlyBound(ebr) = region.kind() + && let def = generics.region_param(&ebr, tcx) + && let ty::GenericParamDefKind::Lifetime { late_bound } = def.kind + && late_bound + { + let kind = BoundRegionKind::BrNamed(ebr.def_id, ebr.name); + let (index, _) = + bound_vars.insert_full(ty::BoundVariableKind::Region(kind)); + tcx.mk_region(ty::ReLateBound( + debruijn, + BoundRegion { var: BoundVar::from_usize(index), kind }, + )) + } else { + region + } + }); + let fn_sig = ty::EarlyBinder(fn_sig).subst(tcx, substs); + let bound_vars = tcx.mk_bound_variable_kinds(bound_vars.into_iter()); + ty::Binder::bind_with_vars(fn_sig, bound_vars) + } FnPtr(f) => *f, Error(_) => { // ignore errors (#54954) diff --git a/compiler/rustc_middle/src/ty/subst.rs b/compiler/rustc_middle/src/ty/subst.rs index 0660e9b79a700..d036f05e06814 100644 --- a/compiler/rustc_middle/src/ty/subst.rs +++ b/compiler/rustc_middle/src/ty/subst.rs @@ -314,6 +314,18 @@ impl<'tcx> InternalSubsts<'tcx> { }) } + pub fn extend_with_region( + &self, + tcx: TyCtxt<'tcx>, + def_id: DefId, + region: ty::Region<'tcx>, + ) -> SubstsRef<'tcx> { + self.extend_to(tcx, def_id, |param, _| match param.kind { + ty::GenericParamDefKind::Lifetime { .. } => region.into(), + _ => bug!("unexpected parameter {:?}", param), + }) + } + pub fn fill_item( substs: &mut SmallVec<[GenericArg<'tcx>; 8]>, tcx: TyCtxt<'tcx>, @@ -599,7 +611,8 @@ impl Iterator for EarlyBinderIter { } } -impl<'tcx, T: TypeFoldable<'tcx>> ty::EarlyBinder { +impl<'tcx, T: TypeFoldable<'tcx> + fmt::Debug> ty::EarlyBinder { + #[instrument(level = "trace", skip(tcx))] pub fn subst(self, tcx: TyCtxt<'tcx>, substs: &[GenericArg<'tcx>]) -> T { let mut folder = SubstFolder { tcx, substs, binders_passed: 0 }; self.0.fold_with(&mut folder) diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index f73d062ba30a6..8265b5311e939 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -658,7 +658,7 @@ impl<'tcx> TyCtxt<'tcx> { ty::EarlyBinder(self.collect_trait_impl_trait_tys(def_id)) } - pub fn bound_fn_sig(self, def_id: DefId) -> ty::EarlyBinder> { + pub fn bound_fn_sig(self, def_id: DefId) -> ty::EarlyBinder> { ty::EarlyBinder(self.fn_sig(def_id)) } @@ -1298,7 +1298,7 @@ pub fn is_doc_notable_trait(tcx: TyCtxt<'_>, def_id: DefId) -> bool { /// Determines whether an item is an intrinsic by Abi. pub fn is_intrinsic(tcx: TyCtxt<'_>, def_id: DefId) -> bool { - matches!(tcx.fn_sig(def_id).abi(), Abi::RustIntrinsic | Abi::PlatformIntrinsic) + matches!(tcx.fn_sig(def_id).abi, Abi::RustIntrinsic | Abi::PlatformIntrinsic) } pub fn provide(providers: &mut ty::query::Providers) { diff --git a/compiler/rustc_middle/src/values.rs b/compiler/rustc_middle/src/values.rs index f4b4c3fb05a7c..baf465246b666 100644 --- a/compiler/rustc_middle/src/values.rs +++ b/compiler/rustc_middle/src/values.rs @@ -31,23 +31,23 @@ impl<'tcx> Value> for ty::SymbolName<'_> { } } -impl<'tcx> Value> for ty::Binder<'_, ty::FnSig<'_>> { +impl<'tcx> Value> for ty::FnSig<'_> { fn from_cycle_error(tcx: TyCtxt<'tcx>, _: &[QueryInfo]) -> Self { let err = tcx.ty_error(); // FIXME(compiler-errors): It would be nice if we could get the // query key, so we could at least generate a fn signature that // has the right arity. - let fn_sig = ty::Binder::dummy(tcx.mk_fn_sig( + let fn_sig = tcx.mk_fn_sig( [].into_iter(), err, false, rustc_hir::Unsafety::Normal, rustc_target::spec::abi::Abi::Rust, - )); + ); // SAFETY: This is never called when `Self` is not `ty::Binder<'tcx, ty::FnSig<'tcx>>`. // FIXME: Represent the above fact in the trait system somehow. - unsafe { std::mem::transmute::, ty::Binder<'_, ty::FnSig<'_>>>(fn_sig) } + unsafe { std::mem::transmute::, ty::FnSig<'_>>(fn_sig) } } } diff --git a/compiler/rustc_mir_build/src/build/matches/test.rs b/compiler/rustc_mir_build/src/build/matches/test.rs index b597ecfaa4d6d..a3b74f61cfbca 100644 --- a/compiler/rustc_mir_build/src/build/matches/test.rs +++ b/compiler/rustc_mir_build/src/build/matches/test.rs @@ -818,6 +818,13 @@ fn trait_method<'tcx>( .expect("trait method not found"); let method_ty = tcx.bound_type_of(item.def_id); + let substs = substs.extend_to(tcx, item.def_id, |param, _| { + if let ty::GenericParamDefKind::Lifetime { .. } = param.kind { + tcx.lifetimes.re_erased.into() + } else { + tcx.mk_param_from_def(param) + } + }); let method_ty = method_ty.subst(tcx, substs); ConstantKind::zero_sized(method_ty) diff --git a/compiler/rustc_mir_build/src/build/mod.rs b/compiler/rustc_mir_build/src/build/mod.rs index cbcf9cd129f3f..fc91037bb7d91 100644 --- a/compiler/rustc_mir_build/src/build/mod.rs +++ b/compiler/rustc_mir_build/src/build/mod.rs @@ -620,7 +620,7 @@ fn construct_error<'tcx>( let ty = tcx.ty_error(); let num_params = match body_owner_kind { - hir::BodyOwnerKind::Fn => tcx.fn_sig(def).inputs().skip_binder().len(), + hir::BodyOwnerKind::Fn => tcx.fn_sig(def).inputs().len(), hir::BodyOwnerKind::Closure => { let ty = tcx.type_of(def); match ty.kind() { diff --git a/compiler/rustc_mir_build/src/thir/cx/expr.rs b/compiler/rustc_mir_build/src/thir/cx/expr.rs index c7a7c3e3fa8ee..8e946c21fe7a0 100644 --- a/compiler/rustc_mir_build/src/thir/cx/expr.rs +++ b/compiler/rustc_mir_build/src/thir/cx/expr.rs @@ -818,6 +818,9 @@ impl<'tcx> Cx<'tcx> { (def_id, self.typeck_results().node_substs(expr.hir_id), user_ty) } }; + debug!(?overloaded_callee); + debug!(?def_id); + debug!(?substs); let ty = self.tcx().mk_fn_def(def_id, substs); Expr { temp_lifetime, ty, span, kind: ExprKind::ZstLiteral { user_ty } } } diff --git a/compiler/rustc_mir_dataflow/src/elaborate_drops.rs b/compiler/rustc_mir_dataflow/src/elaborate_drops.rs index 23403628c53fa..ab905e97e4184 100644 --- a/compiler/rustc_mir_dataflow/src/elaborate_drops.rs +++ b/compiler/rustc_mir_dataflow/src/elaborate_drops.rs @@ -616,7 +616,8 @@ where let drop_trait = tcx.require_lang_item(LangItem::Drop, None); let drop_fn = tcx.associated_item_def_ids(drop_trait)[0]; let ty = self.place_ty(self.place); - let substs = tcx.mk_substs_trait(ty, &[]); + let substs = + tcx.mk_substs_trait(ty, &[]).extend_with_region(tcx, drop_fn, tcx.lifetimes.re_erased); let ref_ty = tcx.mk_ref(tcx.lifetimes.re_erased, ty::TypeAndMut { ty, mutbl: hir::Mutability::Mut }); diff --git a/compiler/rustc_mir_transform/src/function_item_references.rs b/compiler/rustc_mir_transform/src/function_item_references.rs index 469566694a3ef..9c9c8575f7f37 100644 --- a/compiler/rustc_mir_transform/src/function_item_references.rs +++ b/compiler/rustc_mir_transform/src/function_item_references.rs @@ -79,7 +79,7 @@ impl<'tcx> FunctionItemRefChecker<'_, 'tcx> { for bound in bounds { if let Some(bound_ty) = self.is_pointer_trait(&bound.kind().skip_binder()) { // Get the argument types as they appear in the function signature. - let arg_defs = self.tcx.fn_sig(def_id).skip_binder().inputs(); + let arg_defs = self.tcx.fn_sig(def_id).inputs(); for (arg_num, arg_def) in arg_defs.iter().enumerate() { // For all types reachable from the argument type in the fn sig for generic_inner_ty in arg_def.walk() { @@ -162,8 +162,8 @@ impl<'tcx> FunctionItemRefChecker<'_, 'tcx> { .assert_crate_local() .lint_root; let fn_sig = self.tcx.fn_sig(fn_id); - let unsafety = fn_sig.unsafety().prefix_str(); - let abi = match fn_sig.abi() { + let unsafety = fn_sig.unsafety.prefix_str(); + let abi = match fn_sig.abi { Abi::Rust => String::from(""), other_abi => { let mut s = String::from("extern \""); @@ -176,9 +176,9 @@ impl<'tcx> FunctionItemRefChecker<'_, 'tcx> { let ty_params = fn_substs.types().map(|ty| format!("{}", ty)); let const_params = fn_substs.consts().map(|c| format!("{}", c)); let params = ty_params.chain(const_params).join(", "); - let num_args = fn_sig.inputs().map_bound(|inputs| inputs.len()).skip_binder(); - let variadic = if fn_sig.c_variadic() { ", ..." } else { "" }; - let ret = if fn_sig.output().skip_binder().is_unit() { "" } else { " -> _" }; + let num_args = fn_sig.inputs().len(); + let variadic = if fn_sig.c_variadic { ", ..." } else { "" }; + let ret = if fn_sig.output().is_unit() { "" } else { " -> _" }; self.tcx.struct_span_lint_hir( FUNCTION_ITEM_REFERENCES, lint_root, diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs index 780b91d9215d5..734f1d7d6fcc2 100644 --- a/compiler/rustc_mir_transform/src/inline.rs +++ b/compiler/rustc_mir_transform/src/inline.rs @@ -33,7 +33,7 @@ pub struct Inline; #[derive(Copy, Clone, Debug)] struct CallSite<'tcx> { callee: Instance<'tcx>, - fn_sig: ty::PolyFnSig<'tcx>, + fn_sig: ty::FnSig<'tcx>, block: BasicBlock, target: Option, source_info: SourceInfo, @@ -184,7 +184,7 @@ impl<'tcx> Inliner<'tcx> { trace!(?output_type, ?destination_ty); return Err("failed to normalize return type"); } - if callsite.fn_sig.abi() == Abi::RustCall { + if callsite.fn_sig.abi == Abi::RustCall { let (arg_tuple, skipped_args) = match &args[..] { [arg_tuple] => (arg_tuple, 0), [_, arg_tuple] => (arg_tuple, 1), @@ -305,7 +305,9 @@ impl<'tcx> Inliner<'tcx> { let func_ty = func.ty(caller_body, self.tcx); if let ty::FnDef(def_id, substs) = *func_ty.kind() { // To resolve an instance its substs have to be fully normalized. + debug!(?def_id, ?substs); let substs = self.tcx.try_normalize_erasing_regions(self.param_env, substs).ok()?; + debug!(?def_id, ?substs); let callee = Instance::resolve(self.tcx, self.param_env, def_id, substs).ok().flatten()?; @@ -318,7 +320,6 @@ impl<'tcx> Inliner<'tcx> { } let fn_sig = self.tcx.bound_fn_sig(def_id).subst(self.tcx, substs); - return Some(CallSite { callee, fn_sig, @@ -359,7 +360,7 @@ impl<'tcx> Inliner<'tcx> { } } - if callsite.fn_sig.c_variadic() { + if callsite.fn_sig.c_variadic { return Err("C variadic"); } @@ -647,7 +648,7 @@ impl<'tcx> Inliner<'tcx> { // tmp2 = tuple_tmp.2 // // and the vector is `[closure_ref, tmp0, tmp1, tmp2]`. - if callsite.fn_sig.abi() == Abi::RustCall && callee_body.spread_arg.is_none() { + if callsite.fn_sig.abi == Abi::RustCall && callee_body.spread_arg.is_none() { let mut args = args.into_iter(); let self_ = self.create_temp_if_necessary(args.next().unwrap(), callsite, caller_body); let tuple = self.create_temp_if_necessary(args.next().unwrap(), callsite, caller_body); diff --git a/compiler/rustc_mir_transform/src/shim.rs b/compiler/rustc_mir_transform/src/shim.rs index c19380ef89cc5..4062e450355cc 100644 --- a/compiler/rustc_mir_transform/src/shim.rs +++ b/compiler/rustc_mir_transform/src/shim.rs @@ -27,9 +27,8 @@ pub fn provide(providers: &mut Providers) { providers.mir_shims = make_shim; } +#[instrument(level = "debug", skip(tcx), ret)] fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> Body<'tcx> { - debug!("make_shim({:?})", instance); - let mut result = match instance { ty::InstanceDef::Item(..) => bug!("item {:?} passed to make_shim", instance), ty::InstanceDef::VTableShim(def_id) => { @@ -71,7 +70,7 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> Body<' if let Some(ty::Generator(gen_def_id, substs, _)) = ty.map(Ty::kind) { let body = tcx.optimized_mir(*gen_def_id).generator_drop().unwrap(); let body = EarlyBinder(body.clone()).subst(tcx, substs); - debug!("make_shim({:?}) = {:?}", instance, body); + debug!(?body); return body; } @@ -85,7 +84,7 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> Body<' bug!("creating shims from intrinsics ({:?}) is unsupported", instance) } }; - debug!("make_shim({:?}) = untransformed {:?}", instance, result); + debug!(untransformed = ?result); pm::run_passes( tcx, @@ -101,8 +100,6 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> Body<' Some(MirPhase::Runtime(RuntimePhase::Optimized)), ); - debug!("make_shim({:?}) = {:?}", instance, result); - result } @@ -153,7 +150,6 @@ fn build_drop_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, ty: Option>) InternalSubsts::identity_for_item(tcx, def_id) }; let sig = tcx.bound_fn_sig(def_id).subst(tcx, substs); - let sig = tcx.erase_late_bound_regions(sig); let span = tcx.def_span(def_id); let source_info = SourceInfo::outermost(span); @@ -346,9 +342,12 @@ impl<'tcx> CloneShimBuilder<'tcx> { // we must subst the self_ty because it's // otherwise going to be TySelf and we can't index // or access fields of a Place of type TySelf. - let substs = tcx.mk_substs_trait(self_ty, &[]); + let substs = tcx.mk_substs_trait(self_ty, &[]).extend_with_region( + tcx, + def_id, + tcx.lifetimes.re_erased, + ); let sig = tcx.bound_fn_sig(def_id).subst(tcx, substs); - let sig = tcx.erase_late_bound_regions(sig); let span = tcx.def_span(def_id); CloneShimBuilder { @@ -427,7 +426,11 @@ impl<'tcx> CloneShimBuilder<'tcx> { ) { let tcx = self.tcx; - let substs = tcx.mk_substs_trait(ty, &[]); + let substs = tcx.mk_substs_trait(ty, &[]).extend_with_region( + tcx, + self.def_id, + tcx.lifetimes.re_erased, + ); // `func == Clone::clone(&ty) -> ty` let func_ty = tcx.mk_fn_def(self.def_id, substs); @@ -569,17 +572,13 @@ impl<'tcx> CloneShimBuilder<'tcx> { /// Builds a "call" shim for `instance`. The shim calls the function specified by `call_kind`, /// first adjusting its first argument according to `rcvr_adjustment`. +#[instrument(level = "trace", skip(tcx), ret)] fn build_call_shim<'tcx>( tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>, rcvr_adjustment: Option, call_kind: CallKind<'tcx>, ) -> Body<'tcx> { - debug!( - "build_call_shim(instance={:?}, rcvr_adjustment={:?}, call_kind={:?})", - instance, rcvr_adjustment, call_kind - ); - // `FnPtrShim` contains the fn pointer type that a call shim is being built for - this is used // to substitute into the signature of the shim. It is not necessary for users of this // MIR body to perform further substitutions (see `InstanceDef::has_polymorphic_mir_body`). @@ -591,6 +590,8 @@ fn build_call_shim<'tcx>( // Create substitutions for the `Self` and `Args` generic parameters of the shim body. let arg_tup = tcx.mk_tup(untuple_args.iter()); let sig_substs = tcx.mk_substs_trait(ty, &[ty::subst::GenericArg::from(arg_tup)]); + let sig_substs = + sig_substs.extend_with_region(tcx, instance.def_id(), tcx.lifetimes.re_erased); (Some(sig_substs), Some(untuple_args)) } else { @@ -599,7 +600,6 @@ fn build_call_shim<'tcx>( let def_id = instance.def_id(); let sig = tcx.bound_fn_sig(def_id); - let sig = sig.map_bound(|sig| tcx.erase_late_bound_regions(sig)); assert_eq!(sig_substs.is_some(), !instance.has_polymorphic_mir_body()); let mut sig = @@ -641,7 +641,7 @@ fn build_call_shim<'tcx>( let span = tcx.def_span(def_id); - debug!("build_call_shim: sig={:?}", sig); + debug!(?sig); let mut local_decls = local_decls_for_sig(&sig, span); let source_info = SourceInfo::outermost(span); @@ -686,6 +686,7 @@ fn build_call_shim<'tcx>( // `FnDef` call with optional receiver. CallKind::Direct(def_id) => { let ty = tcx.type_of(def_id); + let ty = tcx.erase_regions(ty); ( Operand::Constant(Box::new(Constant { span, @@ -790,7 +791,7 @@ pub fn build_adt_ctor(tcx: TyCtxt<'_>, ctor_id: DefId) -> Body<'_> { let param_env = tcx.param_env(ctor_id); // Normalize the sig. - let sig = tcx.fn_sig(ctor_id).no_bound_vars().expect("LBR in ADT constructor signature"); + let sig = tcx.fn_sig(ctor_id); let sig = tcx.normalize_erasing_regions(param_env, sig); let ty::Adt(adt_def, substs) = sig.output().kind() else { diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index 5cd7a7f760f5d..77fb446638a6a 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -662,9 +662,10 @@ struct MirNeighborCollector<'a, 'tcx> { } impl<'a, 'tcx> MirNeighborCollector<'a, 'tcx> { + #[instrument(level = "debug", skip(self))] pub fn monomorphize(&self, value: T) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable<'tcx> + std::fmt::Debug, { debug!("monomorphize: self.instance={:?}", self.instance); self.instance.subst_mir_and_normalize_erasing_regions( @@ -1311,10 +1312,8 @@ impl<'v> RootCollector<'_, 'v> { // late-bound regions, since late-bound // regions must appear in the argument // listing. - let main_ret_ty = self.tcx.normalize_erasing_regions( - ty::ParamEnv::reveal_all(), - main_ret_ty.no_bound_vars().unwrap(), - ); + let main_ret_ty = + self.tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), main_ret_ty); let start_instance = Instance::resolve( self.tcx, @@ -1370,7 +1369,7 @@ fn create_mono_items_for_default_impls<'tcx>( let substs = InternalSubsts::for_item(tcx, method.def_id, |param, _| match param.kind { - GenericParamDefKind::Lifetime => tcx.lifetimes.re_erased.into(), + GenericParamDefKind::Lifetime { .. } => tcx.lifetimes.re_erased.into(), GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { .. } => { trait_ref.substs[param.index as usize] diff --git a/compiler/rustc_monomorphize/src/polymorphize.rs b/compiler/rustc_monomorphize/src/polymorphize.rs index 650076c2213a3..2ca1d26954826 100644 --- a/compiler/rustc_monomorphize/src/polymorphize.rs +++ b/compiler/rustc_monomorphize/src/polymorphize.rs @@ -178,7 +178,7 @@ fn mark_used_by_default_parameters<'tcx>( | DefKind::Impl => { for param in &generics.params { debug!(?param, "(other)"); - if let ty::GenericParamDefKind::Lifetime = param.kind { + if let ty::GenericParamDefKind::Lifetime { .. } = param.kind { unused_parameters.clear(param.index); } } diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index 4db58d92bd5e3..9977facb4cc84 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -855,7 +855,7 @@ impl ReachEverythingInTheInterfaceVisitor<'_, '_> { fn generics(&mut self) -> &mut Self { for param in &self.ev.tcx.generics_of(self.item_def_id).params { match param.kind { - GenericParamDefKind::Lifetime => {} + GenericParamDefKind::Lifetime { .. } => {} GenericParamDefKind::Type { has_default, .. } => { if has_default { self.visit(self.ev.tcx.type_of(param.def_id)); @@ -1753,7 +1753,7 @@ impl SearchInterfaceForPrivateItemsVisitor<'_> { fn generics(&mut self) -> &mut Self { for param in &self.tcx.generics_of(self.item_def_id).params { match param.kind { - GenericParamDefKind::Lifetime => {} + GenericParamDefKind::Lifetime { .. } => {} GenericParamDefKind::Type { has_default, .. } => { if has_default { self.visit(self.tcx.type_of(param.def_id)); diff --git a/compiler/rustc_symbol_mangling/src/legacy.rs b/compiler/rustc_symbol_mangling/src/legacy.rs index 46c5fe78ffbf6..a75d39adb20fd 100644 --- a/compiler/rustc_symbol_mangling/src/legacy.rs +++ b/compiler/rustc_symbol_mangling/src/legacy.rs @@ -350,6 +350,7 @@ impl<'tcx> Printer<'tcx> for &mut SymbolPrinter<'tcx> { } fn path_generic_args( mut self, + _: bool, print_prefix: impl FnOnce(Self) -> Result, args: &[GenericArg<'tcx>], ) -> Result { diff --git a/compiler/rustc_symbol_mangling/src/v0.rs b/compiler/rustc_symbol_mangling/src/v0.rs index ecfe6861e84cb..1daec5fa41a48 100644 --- a/compiler/rustc_symbol_mangling/src/v0.rs +++ b/compiler/rustc_symbol_mangling/src/v0.rs @@ -303,6 +303,7 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> { // polymorphization is enabled) and this isn't an inherent impl. if impl_trait_ref.is_some() && substs.iter().any(|a| a.has_non_region_param()) { self = self.path_generic_args( + false, |this| { this.path_append_ns( |cx| cx.print_def_path(parent_def_id, &[]), @@ -808,6 +809,7 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> { fn path_generic_args( mut self, + _: bool, print_prefix: impl FnOnce(Self) -> Result, args: &[GenericArg<'tcx>], ) -> Result { diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs index 5eef54c6330db..a2b42c1f612ef 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs @@ -186,7 +186,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { .. } => { substs[param.index as usize].to_string() } - GenericParamDefKind::Lifetime => continue, + GenericParamDefKind::Lifetime { .. } => continue, }; let name = param.name; flags.push((name, Some(value))); diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs index 0bf54c096cd40..4f0e38fdf0581 100644 --- a/compiler/rustc_trait_selection/src/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/mod.rs @@ -815,7 +815,7 @@ fn vtable_entries<'tcx>( // The method may have some early-bound lifetimes; add regions for those. let substs = trait_ref.map_bound(|trait_ref| { InternalSubsts::for_item(tcx, def_id, |param, _| match param.kind { - GenericParamDefKind::Lifetime => tcx.lifetimes.re_erased.into(), + GenericParamDefKind::Lifetime { .. } => tcx.lifetimes.re_erased.into(), GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { .. } => { trait_ref.substs[param.index as usize] diff --git a/compiler/rustc_trait_selection/src/traits/object_safety.rs b/compiler/rustc_trait_selection/src/traits/object_safety.rs index 0bb25a74dc8b0..95c98c18cfa7c 100644 --- a/compiler/rustc_trait_selection/src/traits/object_safety.rs +++ b/compiler/rustc_trait_selection/src/traits/object_safety.rs @@ -420,8 +420,8 @@ fn virtual_call_violation_for_method<'tcx>( return Some(MethodViolationCode::StaticMethod(sugg)); } - for (i, &input_ty) in sig.skip_binder().inputs().iter().enumerate().skip(1) { - if contains_illegal_self_type_reference(tcx, trait_def_id, sig.rebind(input_ty)) { + for (i, &input_ty) in sig.inputs().iter().enumerate().skip(1) { + if contains_illegal_self_type_reference(tcx, trait_def_id, input_ty) { let span = if let Some(hir::Node::TraitItem(hir::TraitItem { kind: hir::TraitItemKind::Fn(sig, _), .. @@ -447,7 +447,7 @@ fn virtual_call_violation_for_method<'tcx>( return Some(MethodViolationCode::Generic); } - let receiver_ty = tcx.liberate_late_bound_regions(method.def_id, sig.input(0)); + let receiver_ty = sig.input(0); // Until `unsized_locals` is fully implemented, `self: Self` can't be dispatched on. // However, this is already considered object-safe. We allow it as a special case here. @@ -863,12 +863,9 @@ fn contains_illegal_self_type_reference<'tcx, T: TypeVisitable<'tcx>>( .is_break() } -pub fn contains_illegal_impl_trait_in_trait<'tcx>( - tcx: TyCtxt<'tcx>, - ty: ty::Binder<'tcx, Ty<'tcx>>, -) -> bool { +pub fn contains_illegal_impl_trait_in_trait<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { // FIXME(RPITIT): Perhaps we should use a visitor here? - ty.skip_binder().walk().any(|arg| { + ty.walk().any(|arg| { if let ty::GenericArgKind::Type(ty) = arg.unpack() && let ty::Projection(proj) = ty.kind() { diff --git a/compiler/rustc_trait_selection/src/traits/on_unimplemented.rs b/compiler/rustc_trait_selection/src/traits/on_unimplemented.rs index 4a4f34b768059..759755890a33b 100644 --- a/compiler/rustc_trait_selection/src/traits/on_unimplemented.rs +++ b/compiler/rustc_trait_selection/src/traits/on_unimplemented.rs @@ -338,7 +338,7 @@ impl<'tcx> OnUnimplementedFormatString { GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { .. } => { trait_ref.substs[param.index as usize].to_string() } - GenericParamDefKind::Lifetime => return None, + GenericParamDefKind::Lifetime { .. } => return None, }; let name = param.name; Some((name, value)) diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index c8276854016f0..306a0bfaf98c1 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -2215,7 +2215,7 @@ fn check_substs_compatible<'tcx>( for (param, arg) in std::iter::zip(&generics.params, own_args) { match (¶m.kind, arg.unpack()) { (ty::GenericParamDefKind::Type { .. }, ty::GenericArgKind::Type(_)) - | (ty::GenericParamDefKind::Lifetime, ty::GenericArgKind::Lifetime(_)) + | (ty::GenericParamDefKind::Lifetime { .. }, ty::GenericArgKind::Lifetime(_)) | (ty::GenericParamDefKind::Const { .. }, ty::GenericArgKind::Const(_)) => {} _ => return false, } @@ -2253,25 +2253,35 @@ fn confirm_impl_trait_in_trait_candidate<'tcx>( }; } + debug!(?trait_fn_def_id, generics=?tcx.generics_of(trait_fn_def_id)); + debug!(?obligation.predicate.substs); + debug!(?data.substs); + let impl_fn_def_id = leaf_def.item.def_id; // Rebase from {trait}::{fn}::{opaque} to {impl}::{fn}::{opaque}, // since `data.substs` are the impl substs. let impl_fn_substs = obligation.predicate.substs.rebase_onto(tcx, tcx.parent(trait_fn_def_id), data.substs); + debug!(?impl_fn_substs); let cause = ObligationCause::new( obligation.cause.span, obligation.cause.body_id, super::ItemObligation(impl_fn_def_id), ); + let predicates = tcx.predicates_of(impl_fn_def_id); + debug!(?predicates); + let predicates = predicates.instantiate(tcx, impl_fn_substs); + debug!(?predicates); let predicates = normalize_with_depth_to( selcx, obligation.param_env, cause.clone(), obligation.recursion_depth + 1, - tcx.predicates_of(impl_fn_def_id).instantiate(tcx, impl_fn_substs), + predicates, &mut obligations, ); + debug!(?predicates); obligations.extend(std::iter::zip(predicates.predicates, predicates.spans).map( |(pred, span)| { Obligation::with_depth( @@ -2291,17 +2301,16 @@ fn confirm_impl_trait_in_trait_candidate<'tcx>( }, )); - let ty = super::normalize_to( - selcx, - obligation.param_env, - cause.clone(), - tcx.bound_trait_impl_trait_tys(impl_fn_def_id) - .map_bound(|tys| { - tys.map_or_else(|_| tcx.ty_error(), |tys| tys[&obligation.predicate.item_def_id]) - }) - .subst(tcx, impl_fn_substs), - &mut obligations, - ); + let tys = tcx.bound_trait_impl_trait_tys(impl_fn_def_id); + debug!(?tys); + let ty = tys.map_bound(|tys| { + tys.map_or_else(|_| tcx.ty_error(), |tys| tys[&obligation.predicate.item_def_id]) + }); + debug!(?ty); + let ty = ty.subst(tcx, impl_fn_substs); + debug!(?ty); + let ty = super::normalize_to(selcx, obligation.param_env, cause.clone(), ty, &mut obligations); + debug!(?ty); Progress { term: ty.into(), obligations } } diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs index ed22058c64615..74ca47c0d62be 100644 --- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs +++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs @@ -539,7 +539,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { )) .into() } - GenericParamDefKind::Lifetime => { + GenericParamDefKind::Lifetime { .. } => { let kind = ty::BoundRegionKind::BrNamed(param.def_id, param.name); let bound_var = ty::BoundVariableKind::Region(kind); bound_vars.push(bound_var); diff --git a/compiler/rustc_traits/src/chalk/db.rs b/compiler/rustc_traits/src/chalk/db.rs index 0de28b826616e..2a518fccba156 100644 --- a/compiler/rustc_traits/src/chalk/db.rs +++ b/compiler/rustc_traits/src/chalk/db.rs @@ -272,7 +272,7 @@ impl<'tcx> chalk_solve::RustIrDatabase> for RustIrDatabase<'t let (inputs_and_output, iobinders, _) = crate::chalk::lowering::collect_bound_vars( self.interner, self.interner.tcx, - sig.map_bound(|s| s.inputs_and_output()).subst(self.interner.tcx, bound_vars), + sig.map_bound(|s| s.inputs_and_output).subst(self.interner.tcx, bound_vars), ); let argument_types = inputs_and_output[..inputs_and_output.len() - 1] @@ -725,7 +725,7 @@ fn bound_vars_for_item<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> SubstsRef<'tcx )) .into(), - ty::GenericParamDefKind::Lifetime => { + ty::GenericParamDefKind::Lifetime { .. } => { let br = ty::BoundRegion { var: ty::BoundVar::from_usize(substs.len()), kind: ty::BrAnon(substs.len() as u32), diff --git a/compiler/rustc_traits/src/chalk/lowering.rs b/compiler/rustc_traits/src/chalk/lowering.rs index 45d5ea93d547f..da8a6aaf87b63 100644 --- a/compiler/rustc_traits/src/chalk/lowering.rs +++ b/compiler/rustc_traits/src/chalk/lowering.rs @@ -84,7 +84,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::InEnvironment chalk_ir::InEnvironment>> { let clauses = self.environment.into_iter().map(|predicate| { let (predicate, binders, _named_regions) = - collect_bound_vars(interner, interner.tcx, predicate.kind()); + collect_bound_vars(interner, interner.tcx, predicate.kind().skip_binder()); let consequence = match predicate { ty::PredicateKind::TypeWellFormedFromEnv(ty) => { chalk_ir::DomainGoal::FromEnv(chalk_ir::FromEnv::Ty(ty.lower_into(interner))) @@ -145,7 +145,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::InEnvironment LowerInto<'tcx, chalk_ir::GoalData>> for ty::Predicate<'tcx> { fn lower_into(self, interner: RustInterner<'tcx>) -> chalk_ir::GoalData> { let (predicate, binders, _named_regions) = - collect_bound_vars(interner, interner.tcx, self.kind()); + collect_bound_vars(interner, interner.tcx, self.kind().skip_binder()); let value = match predicate { ty::PredicateKind::Trait(predicate) => { @@ -313,8 +313,11 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Ty>> for Ty<'tcx> { chalk_ir::TyKind::FnDef(chalk_ir::FnDefId(def_id), substs.lower_into(interner)) } ty::FnPtr(sig) => { - let (inputs_and_outputs, binders, _named_regions) = - collect_bound_vars(interner, interner.tcx, sig.inputs_and_output()); + let (inputs_and_outputs, binders, _named_regions) = collect_bound_vars( + interner, + interner.tcx, + sig.inputs_and_output().skip_binder(), + ); chalk_ir::TyKind::Function(chalk_ir::FnPointer { num_binders: binders.len(interner), sig: sig.lower_into(interner), @@ -600,7 +603,7 @@ impl<'tcx> LowerInto<'tcx, Option, ) -> Option>> { let (predicate, binders, _named_regions) = - collect_bound_vars(interner, interner.tcx, self.kind()); + collect_bound_vars(interner, interner.tcx, self.kind().skip_binder()); let value = match predicate { ty::PredicateKind::Trait(predicate) => { Some(chalk_ir::WhereClause::Implemented(predicate.trait_ref.lower_into(interner))) @@ -658,7 +661,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Binders { chalk_ir::Binders::new( @@ -709,21 +712,27 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Binders LowerInto<'tcx, chalk_ir::FnSig>> - for ty::Binder<'tcx, ty::FnSig<'tcx>> -{ - fn lower_into(self, _interner: RustInterner<'_>) -> FnSig> { +impl<'tcx> LowerInto<'tcx, chalk_ir::FnSig>> for ty::FnSig<'tcx> { + fn lower_into(self, _interner: RustInterner<'tcx>) -> FnSig> { chalk_ir::FnSig { - abi: self.abi(), - safety: match self.unsafety() { + abi: self.abi, + safety: match self.unsafety { Unsafety::Normal => chalk_ir::Safety::Safe, Unsafety::Unsafe => chalk_ir::Safety::Unsafe, }, - variadic: self.c_variadic(), + variadic: self.c_variadic, } } } +impl<'tcx> LowerInto<'tcx, chalk_ir::FnSig>> + for ty::Binder<'tcx, ty::FnSig<'tcx>> +{ + fn lower_into(self, interner: RustInterner<'tcx>) -> FnSig> { + self.skip_binder().lower_into(interner) + } +} + // We lower into an Option here since there are some predicates which Chalk // doesn't have a representation for yet (as an `InlineBound`). The `Option` will // eventually be removed. @@ -735,7 +744,7 @@ impl<'tcx> LowerInto<'tcx, Option, ) -> Option>> { let (predicate, binders, _named_regions) = - collect_bound_vars(interner, interner.tcx, self.kind()); + collect_bound_vars(interner, interner.tcx, self.kind().skip_binder()); match predicate { ty::PredicateKind::Trait(predicate) => Some(chalk_ir::Binders::new( binders, @@ -843,33 +852,32 @@ impl<'tcx> LowerInto<'tcx, chalk_solve::rust_ir::AliasEqBound /// It's important to note that because of prior substitution, we may have /// late-bound regions, even outside of fn contexts, since this is the best way /// to prep types for chalk lowering. -pub(crate) fn collect_bound_vars<'tcx, T: TypeFoldable<'tcx>>( +pub(crate) fn collect_bound_vars<'tcx, T: TypeFoldable<'tcx> + std::fmt::Debug>( interner: RustInterner<'tcx>, tcx: TyCtxt<'tcx>, - ty: Binder<'tcx, T>, + ty: T, ) -> (T, chalk_ir::VariableKinds>, BTreeMap) { + debug!(?ty); let mut bound_vars_collector = BoundVarsCollector::new(); - ty.as_ref().skip_binder().visit_with(&mut bound_vars_collector); + ty.visit_with(&mut bound_vars_collector); let mut parameters = bound_vars_collector.parameters; + debug!(?parameters); let named_parameters: BTreeMap = bound_vars_collector .named_parameters .into_iter() .enumerate() .map(|(i, def_id)| (def_id, (i + parameters.len()) as u32)) .collect(); + debug!(?named_parameters); let mut bound_var_substitutor = NamedBoundVarSubstitutor::new(tcx, &named_parameters); - let new_ty = ty.skip_binder().fold_with(&mut bound_var_substitutor); + let new_ty = ty.fold_with(&mut bound_var_substitutor); + debug!(?new_ty); for var in named_parameters.values() { parameters.insert(*var, chalk_ir::VariableKind::Lifetime); } - - (0..parameters.len()).for_each(|i| { - parameters - .get(&(i as u32)) - .or_else(|| bug!("Skipped bound var index: parameters={:?}", parameters)); - }); + debug!(?parameters); let binders = chalk_ir::VariableKinds::from_iter(interner, parameters.into_iter().map(|(_, v)| v)); diff --git a/compiler/rustc_ty_utils/src/abi.rs b/compiler/rustc_ty_utils/src/abi.rs index 73c7eb6992f07..def1d51b5f863 100644 --- a/compiler/rustc_ty_utils/src/abi.rs +++ b/compiler/rustc_ty_utils/src/abi.rs @@ -28,7 +28,7 @@ fn fn_sig_for_fn_abi<'tcx>( tcx: TyCtxt<'tcx>, instance: ty::Instance<'tcx>, param_env: ty::ParamEnv<'tcx>, -) -> ty::PolyFnSig<'tcx> { +) -> ty::FnSig<'tcx> { let ty = instance.ty(tcx, param_env); match *ty.kind() { ty::FnDef(..) => { @@ -51,52 +51,29 @@ fn fn_sig_for_fn_abi<'tcx>( if let ty::InstanceDef::VTableShim(..) = instance.def { // Modify `fn(self, ...)` to `fn(self: *mut Self, ...)`. - sig = sig.map_bound(|mut sig| { - let mut inputs_and_output = sig.inputs_and_output.to_vec(); - inputs_and_output[0] = tcx.mk_mut_ptr(inputs_and_output[0]); - sig.inputs_and_output = tcx.intern_type_list(&inputs_and_output); - sig - }); + let mut inputs_and_output = sig.inputs_and_output.to_vec(); + inputs_and_output[0] = tcx.mk_mut_ptr(inputs_and_output[0]); + sig.inputs_and_output = tcx.intern_type_list(&inputs_and_output); } sig } ty::Closure(def_id, substs) => { - let sig = substs.as_closure().sig(); - - let bound_vars = tcx.mk_bound_variable_kinds( - sig.bound_vars().iter().chain(iter::once(ty::BoundVariableKind::Region(ty::BrEnv))), - ); - let br = ty::BoundRegion { - var: ty::BoundVar::from_usize(bound_vars.len() - 1), - kind: ty::BoundRegionKind::BrEnv, - }; - let env_region = ty::ReLateBound(ty::INNERMOST, br); - let env_ty = tcx.closure_env_ty(def_id, substs, env_region).unwrap(); - - let sig = sig.skip_binder(); - ty::Binder::bind_with_vars( - tcx.mk_fn_sig( - iter::once(env_ty).chain(sig.inputs().iter().cloned()), - sig.output(), - sig.c_variadic, - sig.unsafety, - sig.abi, - ), - bound_vars, + let sig = tcx.erase_late_bound_regions(substs.as_closure().sig()); + let env_ty = tcx.closure_env_ty(def_id, substs, ty::ReErased).unwrap(); + let env_ty = tcx.erase_regions(env_ty); + + tcx.mk_fn_sig( + iter::once(env_ty).chain(sig.inputs().iter().cloned()), + sig.output(), + sig.c_variadic, + sig.unsafety, + sig.abi, ) } ty::Generator(_, substs, _) => { let sig = substs.as_generator().poly_sig(); - let bound_vars = tcx.mk_bound_variable_kinds( - sig.bound_vars().iter().chain(iter::once(ty::BoundVariableKind::Region(ty::BrEnv))), - ); - let br = ty::BoundRegion { - var: ty::BoundVar::from_usize(bound_vars.len() - 1), - kind: ty::BoundRegionKind::BrEnv, - }; - let env_region = ty::ReLateBound(ty::INNERMOST, br); - let env_ty = tcx.mk_mut_ref(tcx.mk_region(env_region), ty); + let env_ty = tcx.mk_mut_ref(tcx.lifetimes.re_erased, ty); let pin_did = tcx.require_lang_item(LangItem::Pin, None); let pin_adt_ref = tcx.adt_def(pin_did); @@ -108,15 +85,12 @@ fn fn_sig_for_fn_abi<'tcx>( let state_adt_ref = tcx.adt_def(state_did); let state_substs = tcx.intern_substs(&[sig.yield_ty.into(), sig.return_ty.into()]); let ret_ty = tcx.mk_adt(state_adt_ref, state_substs); - ty::Binder::bind_with_vars( - tcx.mk_fn_sig( - [env_ty, sig.resume_ty].iter(), - &ret_ty, - false, - hir::Unsafety::Normal, - rustc_target::spec::abi::Abi::Rust, - ), - bound_vars, + tcx.mk_fn_sig( + [env_ty, sig.resume_ty].iter(), + &ret_ty, + false, + hir::Unsafety::Normal, + rustc_target::spec::abi::Abi::Rust, ) } _ => bug!("unexpected type {:?} in Instance::fn_sig", ty), @@ -164,7 +138,7 @@ fn fn_abi_of_fn_ptr<'tcx>( let (param_env, (sig, extra_args)) = query.into_parts(); let cx = LayoutCx { tcx, param_env }; - fn_abi_new_uncached(&cx, sig, extra_args, None, None, false) + fn_abi_new_uncached(&cx, tcx.erase_late_bound_regions(sig), extra_args, None, None, false) } fn fn_abi_of_instance<'tcx>( @@ -192,6 +166,7 @@ fn fn_abi_of_instance<'tcx>( } // Handle safe Rust thin and fat pointers. +#[instrument(level = "trace", skip(cx))] fn adjust_for_rust_scalar<'tcx>( cx: LayoutCx<'tcx, TyCtxt<'tcx>>, attrs: &mut ArgAttributes, @@ -280,17 +255,18 @@ fn adjust_for_rust_scalar<'tcx>( // FIXME(eddyb) perhaps group the signature/type-containing (or all of them?) // arguments of this method, into a separate `struct`. -#[tracing::instrument(level = "debug", skip(cx, caller_location, fn_def_id, force_thin_self_ptr))] +#[tracing::instrument(level = "debug", skip(cx), ret)] fn fn_abi_new_uncached<'tcx>( cx: &LayoutCx<'tcx, TyCtxt<'tcx>>, - sig: ty::PolyFnSig<'tcx>, + sig: ty::FnSig<'tcx>, extra_args: &[Ty<'tcx>], caller_location: Option>, fn_def_id: Option, // FIXME(eddyb) replace this with something typed, like an `enum`. force_thin_self_ptr: bool, ) -> Result<&'tcx FnAbi<'tcx, Ty<'tcx>>, FnAbiError<'tcx>> { - let sig = cx.tcx.normalize_erasing_late_bound_regions(cx.param_env, sig); + let sig = cx.tcx.normalize_erasing_regions(cx.param_env, sig); + debug!(?sig); let conv = conv_from_spec_abi(cx.tcx(), sig.abi); @@ -334,6 +310,9 @@ fn fn_abi_new_uncached<'tcx>( let arg_of = |ty: Ty<'tcx>, arg_idx: Option| -> Result<_, FnAbiError<'tcx>> { let span = tracing::debug_span!("arg_of"); let _entered = span.enter(); + debug!(?ty); + debug!(?arg_idx); + let is_return = arg_idx.is_none(); let layout = cx.layout_of(ty)?; @@ -386,8 +365,7 @@ fn fn_abi_new_uncached<'tcx>( can_unwind: fn_can_unwind(cx.tcx(), fn_def_id, sig.abi), }; fn_abi_adjust_for_abi(cx, &mut fn_abi, sig.abi, fn_def_id)?; - debug!("fn_abi_new_uncached = {:?}", fn_abi); - Ok(cx.tcx.arena.alloc(fn_abi)) + Ok(&*cx.tcx.arena.alloc(fn_abi)) } #[tracing::instrument(level = "trace", skip(cx))] diff --git a/compiler/rustc_ty_utils/src/common_traits.rs b/compiler/rustc_ty_utils/src/common_traits.rs index d3169b6d962ec..5fab6a120f5d3 100644 --- a/compiler/rustc_ty_utils/src/common_traits.rs +++ b/compiler/rustc_ty_utils/src/common_traits.rs @@ -22,6 +22,7 @@ fn is_unpin_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) is_item_raw(tcx, query, LangItem::Unpin) } +#[instrument(level = "trace", skip(tcx), ret)] fn is_item_raw<'tcx>( tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>, diff --git a/compiler/rustc_ty_utils/src/implied_bounds.rs b/compiler/rustc_ty_utils/src/implied_bounds.rs index f0d8c240ea588..2dfe847064d5e 100644 --- a/compiler/rustc_ty_utils/src/implied_bounds.rs +++ b/compiler/rustc_ty_utils/src/implied_bounds.rs @@ -8,17 +8,12 @@ pub fn provide(providers: &mut ty::query::Providers) { fn assumed_wf_types<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx ty::List> { match tcx.def_kind(def_id) { - DefKind::Fn => { - let sig = tcx.fn_sig(def_id); - let liberated_sig = tcx.liberate_late_bound_regions(def_id, sig); - liberated_sig.inputs_and_output - } + DefKind::Fn => tcx.fn_sig(def_id).inputs_and_output, DefKind::AssocFn => { let sig = tcx.fn_sig(def_id); - let liberated_sig = tcx.liberate_late_bound_regions(def_id, sig); let mut assumed_wf_types: Vec<_> = tcx.assumed_wf_types(tcx.parent(def_id)).as_slice().into(); - assumed_wf_types.extend(liberated_sig.inputs_and_output); + assumed_wf_types.extend(sig.inputs_and_output); tcx.intern_type_list(&assumed_wf_types) } DefKind::Impl => match tcx.impl_trait_ref(def_id) { diff --git a/compiler/rustc_ty_utils/src/instance.rs b/compiler/rustc_ty_utils/src/instance.rs index 416c1ec510b0e..21bd02af2d91b 100644 --- a/compiler/rustc_ty_utils/src/instance.rs +++ b/compiler/rustc_ty_utils/src/instance.rs @@ -36,6 +36,7 @@ fn resolve_instance_of_const_arg<'tcx>( ) } +#[instrument(level = "trace", skip(tcx), ret)] fn inner_resolve_instance<'tcx>( tcx: TyCtxt<'tcx>, key: ty::ParamEnvAnd<'tcx, (ty::WithOptConstParam, SubstsRef<'tcx>)>, @@ -179,6 +180,8 @@ fn resolve_associated_item<'tcx>( } let substs = tcx.erase_regions(substs); + let substs = + substs.extend_with_region(tcx, leaf_def.item.def_id, tcx.lifetimes.re_erased); // Check if we just resolved an associated `const` declaration from // a `trait` to an associated `const` definition in an `impl`, where diff --git a/compiler/rustc_ty_utils/src/ty.rs b/compiler/rustc_ty_utils/src/ty.rs index 3eebb4ace477f..3923924208620 100644 --- a/compiler/rustc_ty_utils/src/ty.rs +++ b/compiler/rustc_ty_utils/src/ty.rs @@ -317,8 +317,6 @@ fn well_formed_types_in_env<'tcx>( // well-formed. NodeKind::Fn => { let fn_sig = tcx.fn_sig(def_id); - let fn_sig = tcx.liberate_late_bound_regions(def_id, fn_sig); - inputs.extend(fn_sig.inputs().iter().flat_map(|ty| ty.walk())); } diff --git a/compiler/rustc_type_ir/src/sty.rs b/compiler/rustc_type_ir/src/sty.rs index a4fb1480fa448..2037eaa5b1a8f 100644 --- a/compiler/rustc_type_ir/src/sty.rs +++ b/compiler/rustc_type_ir/src/sty.rs @@ -1217,21 +1217,19 @@ impl hash::Hash for RegionKind { impl fmt::Debug for RegionKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - ReEarlyBound(ref data) => write!(f, "ReEarlyBound({:?})", data), - - ReLateBound(binder_id, ref bound_region) => { - write!(f, "ReLateBound({:?}, {:?})", binder_id, bound_region) + ReEarlyBound(ref data) => write!(f, "{:?}", data), + ReLateBound(debruijn, ref bound_region) => { + if *debruijn == super::INNERMOST { + write!(f, "{:?}", bound_region) + } else { + write!(f, "{:?}_{}", bound_region, debruijn.as_u32()) + } } - ReFree(ref fr) => fr.fmt(f), - - ReStatic => write!(f, "ReStatic"), - ReVar(ref vid) => vid.fmt(f), - - RePlaceholder(placeholder) => write!(f, "RePlaceholder({:?})", placeholder), - - ReErased => write!(f, "ReErased"), + RePlaceholder(placeholder) => write!(f, "Re{:?}", placeholder), + ReStatic => write!(f, "'static"), + ReErased => write!(f, "'erased"), } } } diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index efa9242a46784..1669a0d0917cb 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -57,7 +57,7 @@ where .params .iter() .filter_map(|param| match param.kind { - ty::GenericParamDefKind::Lifetime => Some(param.name), + ty::GenericParamDefKind::Lifetime { .. } => Some(param.name), _ => None, }) .map(|name| (name, Lifetime(name))) diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 432d318907fa0..94e4407065746 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -235,7 +235,7 @@ fn build_external_function<'tcx>(cx: &mut DocContext<'tcx>, did: DefId) -> Box( cx: &mut DocContext<'tcx>, ) -> GenericParamDef { let (name, kind) = match def.kind { - ty::GenericParamDefKind::Lifetime => { + ty::GenericParamDefKind::Lifetime { .. } => { (def.name, GenericParamDefKind::Lifetime { outlives: vec![] }) } ty::GenericParamDefKind::Type { has_default, synthetic, .. } => { @@ -650,8 +650,10 @@ fn clean_ty_generics<'tcx>( .params .iter() .filter_map(|param| match param.kind { - ty::GenericParamDefKind::Lifetime if param.name == kw::UnderscoreLifetime => None, - ty::GenericParamDefKind::Lifetime => Some(clean_generic_param_def(param, cx)), + ty::GenericParamDefKind::Lifetime { .. } if param.name == kw::UnderscoreLifetime => { + None + } + ty::GenericParamDefKind::Lifetime { .. } => Some(clean_generic_param_def(param, cx)), ty::GenericParamDefKind::Type { synthetic, .. } => { if param.name == kw::SelfUpper { assert_eq!(param.index, 0); @@ -1148,14 +1150,15 @@ pub(crate) fn clean_middle_assoc_item<'tcx>( tcx.explicit_predicates_of(assoc_item.def_id), ); let sig = tcx.fn_sig(assoc_item.def_id); - let mut decl = clean_fn_decl_from_did_and_sig(cx, Some(assoc_item.def_id), sig); + let mut decl = + clean_fn_decl_from_did_and_sig(cx, Some(assoc_item.def_id), ty::Binder::dummy(sig)); if assoc_item.fn_has_self_parameter { let self_ty = match assoc_item.container { ty::ImplContainer => tcx.type_of(assoc_item.container_id(tcx)), ty::TraitContainer => tcx.types.self_param, }; - let self_arg_ty = sig.input(0).skip_binder(); + let self_arg_ty = sig.input(0); if self_arg_ty == self_ty { decl.inputs.values[0].type_ = Generic(kw::SelfUpper); } else if let ty::Ref(_, ty, _) = *self_arg_ty.kind() { diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 4c130b2ffec75..978ef2dc9032c 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -675,11 +675,11 @@ impl Item { } else { hir::Constness::NotConst }; - hir::FnHeader { unsafety: sig.unsafety(), abi: sig.abi(), constness, asyncness } + hir::FnHeader { unsafety: sig.unsafety, abi: sig.abi, constness, asyncness } } let header = match *self.kind { ItemKind::ForeignFunctionItem(_) => { - let abi = tcx.fn_sig(self.item_id.as_def_id().unwrap()).abi(); + let abi = tcx.fn_sig(self.item_id.as_def_id().unwrap()).abi; hir::FnHeader { unsafety: if abi == Abi::RustIntrinsic { intrinsic_operation_unsafety(tcx, self.item_id.as_def_id().unwrap()) diff --git a/src/test/codegen-units/item-collection/trait-implementations.rs b/src/test/codegen-units/item-collection/trait-implementations.rs index a816cb0324135..8b00aa49e0f10 100644 --- a/src/test/codegen-units/item-collection/trait-implementations.rs +++ b/src/test/codegen-units/item-collection/trait-implementations.rs @@ -48,13 +48,13 @@ impl SomeGenericTrait for f32 { //~ MONO_ITEM fn start #[start] fn start(_: isize, _: *const *const u8) -> isize { - //~ MONO_ITEM fn ::bar:: + //~ MONO_ITEM fn ::bar:: 0i32.bar('x'); - //~ MONO_ITEM fn >::bar::<&str> + //~ MONO_ITEM fn >::bar::<&str, '_> 0f64.bar(0u32, "&str"); - //~ MONO_ITEM fn >::bar::<()> + //~ MONO_ITEM fn >::bar::<(), '_> 0f64.bar(0u32, ()); //~ MONO_ITEM fn >::foo @@ -63,10 +63,10 @@ fn start(_: isize, _: *const *const u8) -> isize { //~ MONO_ITEM fn >::foo 0f32.foo(-1i64); - //~ MONO_ITEM fn >::bar::<()> + //~ MONO_ITEM fn >::bar::<(), '_> 0f32.bar(0u32, ()); - //~ MONO_ITEM fn >::bar::<&str> + //~ MONO_ITEM fn >::bar::<&str, '_> 0f32.bar("&str", "&str"); 0 diff --git a/src/test/codegen-units/item-collection/trait-method-default-impl.rs b/src/test/codegen-units/item-collection/trait-method-default-impl.rs index bfcdb6fa142bc..ba9d880047591 100644 --- a/src/test/codegen-units/item-collection/trait-method-default-impl.rs +++ b/src/test/codegen-units/item-collection/trait-method-default-impl.rs @@ -39,22 +39,22 @@ impl SomeGenericTrait for u32 { //~ MONO_ITEM fn start #[start] fn start(_: isize, _: *const *const u8) -> isize { - //~ MONO_ITEM fn ::bar:: + //~ MONO_ITEM fn ::bar:: let _ = 1i8.bar('c'); - //~ MONO_ITEM fn ::bar::<&str> + //~ MONO_ITEM fn ::bar::<&str, '_> let _ = 2i8.bar("&str"); - //~ MONO_ITEM fn >::bar:: + //~ MONO_ITEM fn >::bar:: 0i32.bar(0u64, 'c'); - //~ MONO_ITEM fn >::bar::<&str> + //~ MONO_ITEM fn >::bar::<&str, '_> 0i32.bar(0u64, "&str"); - //~ MONO_ITEM fn >::bar::<&[char; 1]> + //~ MONO_ITEM fn >::bar::<&[char; 1], '_> 0u32.bar(0i8, &['c']); - //~ MONO_ITEM fn >::bar::<()> + //~ MONO_ITEM fn >::bar::<(), '_> 0u32.bar(0i16, ()); 0 diff --git a/src/test/codegen/sanitizer-cfi-emit-type-metadata-id-itanium-cxx-abi.rs b/src/test/codegen/sanitizer-cfi-emit-type-metadata-id-itanium-cxx-abi.rs index ece2adbdf4325..32668a13733dd 100644 --- a/src/test/codegen/sanitizer-cfi-emit-type-metadata-id-itanium-cxx-abi.rs +++ b/src/test/codegen/sanitizer-cfi-emit-type-metadata-id-itanium-cxx-abi.rs @@ -534,9 +534,9 @@ pub fn foo146(_: Type13, _: Type13, _: Type13) { } // CHECK: ![[TYPE105]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtC{{[[:print:]]+}}_4core6marker4Sendu6regionEEE"} // CHECK: ![[TYPE106]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtC{{[[:print:]]+}}_4core6marker4Sendu6regionEES2_E"} // CHECK: ![[TYPE107]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtC{{[[:print:]]+}}_4core6marker4Sendu6regionEES2_S2_E"} -// CHECK: ![[TYPE108]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NCNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn111{{[{}][{}]}}closure{{[}][}]}}Iu2i8PFvvEvEE"} -// CHECK: ![[TYPE109]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NCNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn111{{[{}][{}]}}closure{{[}][}]}}Iu2i8PFvvEvES1_E"} -// CHECK: ![[TYPE110]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NCNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn111{{[{}][{}]}}closure{{[}][}]}}Iu2i8PFvvEvES1_S1_E"} +// CHECK: ![[TYPE108]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NCNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn111{{[{}][{}]}}closure{{[}][}]}}Iu6regionu2i8PFvvEvEE"} +// CHECK: ![[TYPE109]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NCNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn111{{[{}][{}]}}closure{{[}][}]}}Iu6regionu2i8PFvvEvES2_E"} +// CHECK: ![[TYPE110]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NCNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn111{{[{}][{}]}}closure{{[}][}]}}Iu6regionu2i8PFvvEvES2_S2_E"} // CHECK: ![[TYPE111]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NcNtNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn13Foo15{{[{}][{}]}}constructor{{[}][}]}}E"} // CHECK: ![[TYPE112]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NcNtNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn13Foo15{{[{}][{}]}}constructor{{[}][}]}}S_E"} // CHECK: ![[TYPE113]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NcNtNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn13Foo15{{[{}][{}]}}constructor{{[}][}]}}S_S_E"} @@ -549,18 +549,18 @@ pub fn foo146(_: Type13, _: Type13, _: Type13) { } // CHECK: ![[TYPE120]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNkNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn112{{[{}][{}]}}constant{{[}][}]}}3FooE"} // CHECK: ![[TYPE121]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNkNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn112{{[{}][{}]}}constant{{[}][}]}}3FooS_E"} // CHECK: ![[TYPE122]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNkNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn112{{[{}][{}]}}constant{{[}][}]}}3FooS_S_E"} -// CHECK: ![[TYPE123]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNINvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn18{{[{}][{}]}}impl{{[}][}]}}3fooIu3i32EE"} -// CHECK: ![[TYPE124]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNINvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn18{{[{}][{}]}}impl{{[}][}]}}3fooIu3i32ES0_E"} -// CHECK: ![[TYPE125]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNINvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn18{{[{}][{}]}}impl{{[}][}]}}3fooIu3i32ES0_S0_E"} -// CHECK: ![[TYPE126]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu3dynIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait1Iu3i32Eu6regionES_EE"} -// CHECK: ![[TYPE127]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu3dynIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait1Iu3i32Eu6regionES_ES3_E"} -// CHECK: ![[TYPE128]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu3dynIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait1Iu3i32Eu6regionES_ES3_S3_E"} -// CHECK: ![[TYPE129]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu3i32S_EE"} -// CHECK: ![[TYPE130]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu3i32S_ES0_E"} -// CHECK: ![[TYPE131]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu3i32S_ES0_S0_E"} -// CHECK: ![[TYPE132]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi7Struct1Iu3i32ES_EE"} -// CHECK: ![[TYPE133]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi7Struct1Iu3i32ES_ES1_E"} -// CHECK: ![[TYPE134]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi7Struct1Iu3i32ES_ES1_S1_E"} +// CHECK: ![[TYPE123]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNINvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn18{{[{}][{}]}}impl{{[}][}]}}3fooIu3i32u6regionEE"} +// CHECK: ![[TYPE124]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNINvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn18{{[{}][{}]}}impl{{[}][}]}}3fooIu3i32u6regionES1_E"} +// CHECK: ![[TYPE125]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNINvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn18{{[{}][{}]}}impl{{[}][}]}}3fooIu3i32u6regionES1_S1_E"} +// CHECK: ![[TYPE126]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu3dynIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait1Iu3i32Eu6regionES_S1_EE"} +// CHECK: ![[TYPE127]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu3dynIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait1Iu3i32Eu6regionES_S1_ES3_E"} +// CHECK: ![[TYPE128]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu3dynIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait1Iu3i32Eu6regionES_S1_ES3_S3_E"} +// CHECK: ![[TYPE129]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu3i32S_u6regionEE"} +// CHECK: ![[TYPE130]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu3i32S_u6regionES1_E"} +// CHECK: ![[TYPE131]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu3i32S_u6regionES1_S1_E"} +// CHECK: ![[TYPE132]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi7Struct1Iu3i32ES_u6regionEE"} +// CHECK: ![[TYPE133]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi7Struct1Iu3i32ES_u6regionES2_E"} +// CHECK: ![[TYPE134]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi7Struct1Iu3i32ES_u6regionES2_S2_E"} // CHECK: ![[TYPE135]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn13QuxIu3i32Lu5usize32EEE"} // CHECK: ![[TYPE136]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn13QuxIu3i32Lu5usize32EES2_E"} // CHECK: ![[TYPE137]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn13QuxIu3i32Lu5usize32EES2_S2_E"} diff --git a/src/test/incremental/hashes/function_interfaces.rs b/src/test/incremental/hashes/function_interfaces.rs index 3ff949fbb3f80..74864109d4d21 100644 --- a/src/test/incremental/hashes/function_interfaces.rs +++ b/src/test/incremental/hashes/function_interfaces.rs @@ -158,9 +158,9 @@ pub fn type_parameter() {} pub fn lifetime_parameter () {} #[cfg(not(any(cfail1,cfail4)))] -#[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, generics_of,fn_sig")] +#[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, generics_of, type_of")] #[rustc_clean(cfg = "cfail3")] -#[rustc_clean(cfg = "cfail5", except = "hir_owner, hir_owner_nodes, generics_of,fn_sig")] +#[rustc_clean(cfg = "cfail5", except = "hir_owner, hir_owner_nodes, generics_of, type_of")] #[rustc_clean(cfg = "cfail6")] pub fn lifetime_parameter<'a>() {} @@ -194,12 +194,12 @@ pub fn lifetime_bound<'a, T>() {} #[cfg(not(any(cfail1,cfail4)))] #[rustc_clean( cfg = "cfail2", - except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of,fn_sig" + except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of" )] #[rustc_clean(cfg = "cfail3")] #[rustc_clean( cfg = "cfail5", - except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of,fn_sig,optimized_mir" + except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of, optimized_mir" )] #[rustc_clean(cfg = "cfail6")] pub fn lifetime_bound<'a, T: 'a>() {} @@ -234,12 +234,12 @@ pub fn second_lifetime_bound<'a, 'b, T: 'a >() {} #[cfg(not(any(cfail1,cfail4)))] #[rustc_clean( cfg = "cfail2", - except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of,fn_sig" + except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of" )] #[rustc_clean(cfg = "cfail3")] #[rustc_clean( cfg = "cfail5", - except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of,fn_sig" + except = "hir_owner, hir_owner_nodes, generics_of, type_of, predicates_of" )] #[rustc_clean(cfg = "cfail6")] pub fn second_lifetime_bound<'a, 'b, T: 'a + 'b>() {} diff --git a/src/test/incremental/hashes/inherent_impls.rs b/src/test/incremental/hashes/inherent_impls.rs index 1abbff32c6f34..9d7f73ecab48a 100644 --- a/src/test/incremental/hashes/inherent_impls.rs +++ b/src/test/incremental/hashes/inherent_impls.rs @@ -1,3 +1,5 @@ +// ignore-tidy-linelength + // This test case tests the incremental compilation hash (ICH) implementation // for let expressions. @@ -141,12 +143,12 @@ impl Foo { impl Foo { //------------ //--------------- - //--------------------------------------------------------------------------------------------- + //----------------------------------------------------------------------------------------------------- // //-------------------------- //------------ //--------------- - //--------------------------------------------------------------------------------------------- + //----------------------------------------------------------------------------------------------------- // //-------------------------- pub fn method_selfness() { } @@ -160,12 +162,12 @@ impl Foo { impl Foo { #[rustc_clean( cfg="cfail2", - except="hir_owner,hir_owner_nodes,fn_sig,generics_of,typeck,associated_item,optimized_mir", + except="hir_owner,hir_owner_nodes,type_of,fn_sig,generics_of,typeck,associated_item,optimized_mir", )] #[rustc_clean(cfg="cfail3")] #[rustc_clean( cfg="cfail5", - except="hir_owner,hir_owner_nodes,fn_sig,generics_of,typeck,associated_item,optimized_mir", + except="hir_owner,hir_owner_nodes,type_of,fn_sig,generics_of,typeck,associated_item,optimized_mir", )] #[rustc_clean(cfg="cfail6")] pub fn method_selfness(&self) { } @@ -435,9 +437,9 @@ impl Foo { // ---------------------------------------------------------- // ----------------------------------------------------------- // ---------------------------------------------------------- - // -------------------------------------------------------------------- + // ---------------------------------------------------------------------------------------- // ------------------------- - // -------------------------------------------------------------------------------- + // ---------------------------------------------------------------------------------------- // ------------------------- pub fn add_lifetime_parameter_to_method (&self) { } } @@ -457,9 +459,9 @@ impl Foo { // if we lower generics before the body, then the `HirId` for // things in the body will be affected. So if you start to see // `typeck` appear dirty, that might be the cause. -nmatsakis - #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,fn_sig")] + #[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,type_of,fn_sig,generics_of")] #[rustc_clean(cfg="cfail3")] - #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,fn_sig,generics_of")] + #[rustc_clean(cfg="cfail5", except="hir_owner,hir_owner_nodes,type_of,fn_sig,generics_of")] #[rustc_clean(cfg="cfail6")] pub fn add_lifetime_parameter_to_method<'a>(&self) { } } @@ -480,12 +482,12 @@ impl Foo { // ------------------------------------------------- // ----------- // -------------- - // ---------------------------------------------------------------------- + // ----------------------------------------------------------------------------- // // ------------------------- // ----------- // -------------- - // ---------------------------------------------------------------------- + // ----------------------------------------------------------------------------- // // ------------------------- pub fn add_type_parameter_to_method (&self) { } @@ -508,12 +510,12 @@ impl Foo { // appear dirty, that might be the cause. -nmatsakis #[rustc_clean( cfg="cfail2", - except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of", + except="hir_owner,hir_owner_nodes,fn_sig,generics_of,predicates_of,type_of", )] #[rustc_clean(cfg="cfail3")] #[rustc_clean( cfg="cfail5", - except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of", + except="hir_owner,hir_owner_nodes,fn_sig,generics_of,predicates_of,type_of", )] #[rustc_clean(cfg="cfail6")] pub fn add_type_parameter_to_method(&self) { } @@ -526,12 +528,12 @@ impl Foo { impl Foo { //------------ //--------------- - //----------------------------------------------------------------------------- + //-------------------------------------------------------------- // //-------------------------- //------------ //--------------- - //----------------------------------------------------------------------------- + //-------------------------------------------------------------- // //-------------------------- pub fn add_lifetime_bound_to_lifetime_param_of_method<'a, 'b >(&self) { } @@ -545,12 +547,12 @@ impl Foo { impl Foo { #[rustc_clean( cfg="cfail2", - except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of,fn_sig" + except="hir_owner,hir_owner_nodes,generics_of,predicates_of" )] #[rustc_clean(cfg="cfail3")] #[rustc_clean( cfg="cfail5", - except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of,fn_sig" + except="hir_owner,hir_owner_nodes,generics_of,predicates_of" )] #[rustc_clean(cfg="cfail6")] pub fn add_lifetime_bound_to_lifetime_param_of_method<'a, 'b: 'a>(&self) { } @@ -572,12 +574,12 @@ impl Foo { // ------------------------------------------------- // ----------- // -------------- - // ---------------------------------------------------------------------------- + // --------------------------------------------------------------------- // // ------------------------- // ----------- // -------------- - // ---------------------------------------------------------------------------- + // --------------------------------------------------------------------- // // ------------------------- pub fn add_lifetime_bound_to_type_param_of_method<'a, T >(&self) { } @@ -600,12 +602,12 @@ impl Foo { // appear dirty, that might be the cause. -nmatsakis #[rustc_clean( cfg="cfail2", - except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of,fn_sig" + except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of" )] #[rustc_clean(cfg="cfail3")] #[rustc_clean( cfg="cfail5", - except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of,fn_sig" + except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of" )] #[rustc_clean(cfg="cfail6")] pub fn add_lifetime_bound_to_type_param_of_method<'a, T: 'a>(&self) { } diff --git a/src/test/incremental/hashes/trait_defs.rs b/src/test/incremental/hashes/trait_defs.rs index c453eeceb77f5..7be1487b2e96c 100644 --- a/src/test/incremental/hashes/trait_defs.rs +++ b/src/test/incremental/hashes/trait_defs.rs @@ -369,9 +369,9 @@ trait TraitChangeModeSelfOwnToMut: Sized { #[cfg(any(cfail1,cfail4))] trait TraitChangeModeSelfOwnToRef { - // -------------------------------------------------------------------------------- + // ---------------------------------------------------------------------------------------- // ------------------------- - // -------------------------------------------------------------------------------- + // ---------------------------------------------------------------------------------------- // ------------------------- fn method( self); } @@ -382,9 +382,9 @@ trait TraitChangeModeSelfOwnToRef { #[rustc_clean(cfg="cfail5")] #[rustc_clean(cfg="cfail6")] trait TraitChangeModeSelfOwnToRef { - #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig,generics_of", cfg="cfail2")] + #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig,type_of,generics_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] - #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig,generics_of", cfg="cfail5")] + #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig,type_of,generics_of", cfg="cfail5")] #[rustc_clean(cfg="cfail6")] fn method(&self); } @@ -498,9 +498,9 @@ trait TraitAddTypeParameterToMethod { // Add lifetime parameter to method #[cfg(any(cfail1,cfail4))] trait TraitAddLifetimeParameterToMethod { - // -------------------------------------------------------------------------------- + // --------------------------------------------------------------------------------- // ------------------------- - // -------------------------------------------------------------------------------- + // --------------------------------------------------------------------------------- // ------------------------- fn method (); } @@ -511,9 +511,9 @@ trait TraitAddLifetimeParameterToMethod { #[rustc_clean(cfg="cfail5")] #[rustc_clean(cfg="cfail6")] trait TraitAddLifetimeParameterToMethod { - #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig,generics_of", cfg="cfail2")] + #[rustc_clean(except="hir_owner,hir_owner_nodes,type_of,generics_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] - #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig,generics_of", cfg="cfail5")] + #[rustc_clean(except="hir_owner,hir_owner_nodes,type_of,generics_of", cfg="cfail5")] #[rustc_clean(cfg="cfail6")] fn method<'a>(); } @@ -578,12 +578,12 @@ trait TraitAddBuiltinBoundToMethodTypeParameter { #[cfg(any(cfail1,cfail4))] trait TraitAddLifetimeBoundToMethodLifetimeParameter { // ----------- - // ----------------------------------------------------------------------------- + // -------------------------------------------------------------- // -------------- // // ------------------------- // ----------- - // ----------------------------------------------------------------------------- + // -------------------------------------------------------------- // -------------- // // ------------------------- @@ -597,12 +597,12 @@ trait TraitAddLifetimeBoundToMethodLifetimeParameter { #[rustc_clean(cfg="cfail6")] trait TraitAddLifetimeBoundToMethodLifetimeParameter { #[rustc_clean( - except="hir_owner,hir_owner_nodes,generics_of,predicates_of,fn_sig,type_of", + except="hir_owner,hir_owner_nodes,generics_of,predicates_of", cfg="cfail2", )] #[rustc_clean(cfg="cfail3")] #[rustc_clean( - except="hir_owner,hir_owner_nodes,generics_of,predicates_of,fn_sig,type_of", + except="hir_owner,hir_owner_nodes,generics_of,predicates_of", cfg="cfail5", )] #[rustc_clean(cfg="cfail6")] diff --git a/src/test/incremental/hashes/trait_impls.rs b/src/test/incremental/hashes/trait_impls.rs index f555f555f9236..48b9c16a07ab8 100644 --- a/src/test/incremental/hashes/trait_impls.rs +++ b/src/test/incremental/hashes/trait_impls.rs @@ -1,3 +1,5 @@ +// ignore-tidy-linelength + // This test case tests the incremental compilation hash (ICH) implementation // for let expressions. @@ -150,12 +152,12 @@ pub trait ChangeMethodSelfnessTrait { #[rustc_clean(cfg="cfail6")] impl ChangeMethodSelfnessTrait for Foo { #[rustc_clean( - except="hir_owner,hir_owner_nodes,associated_item,generics_of,fn_sig,typeck,optimized_mir", + except="hir_owner,hir_owner_nodes,associated_item,generics_of,type_of,fn_sig,typeck,optimized_mir", cfg="cfail2", )] #[rustc_clean(cfg="cfail3")] #[rustc_clean( - except="hir_owner,hir_owner_nodes,associated_item,generics_of,fn_sig,typeck,optimized_mir", + except="hir_owner,hir_owner_nodes,associated_item,generics_of,type_of,fn_sig,typeck,optimized_mir", cfg="cfail5", )] #[rustc_clean(cfg="cfail6")] @@ -188,12 +190,12 @@ pub trait RemoveMethodSelfnessTrait { #[rustc_clean(cfg="cfail6")] impl RemoveMethodSelfnessTrait for Foo { #[rustc_clean( - except="hir_owner,hir_owner_nodes,associated_item,generics_of,fn_sig,typeck,optimized_mir", + except="hir_owner,hir_owner_nodes,associated_item,generics_of,type_of,fn_sig,typeck,optimized_mir", cfg="cfail2", )] #[rustc_clean(cfg="cfail3")] #[rustc_clean( - except="hir_owner,hir_owner_nodes,associated_item,generics_of,fn_sig,typeck,optimized_mir", + except="hir_owner,hir_owner_nodes,associated_item,generics_of,type_of,fn_sig,typeck,optimized_mir", cfg="cfail5", )] #[rustc_clean(cfg="cfail6")] diff --git a/src/test/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstCombine.diff b/src/test/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstCombine.diff index 6f01553eef6da..4a0f3dddbd848 100644 --- a/src/test/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstCombine.diff +++ b/src/test/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstCombine.diff @@ -24,7 +24,7 @@ _2 = ::clone(move _3) -> bb1; // scope 0 at $DIR/combine_clone_of_primitives.rs:8:5: 8:9 // mir::Constant // + span: $DIR/combine_clone_of_primitives.rs:8:5: 8:9 - // + literal: Const { ty: for<'a> fn(&'a T) -> T {::clone}, val: Value() } + // + literal: Const { ty: fn(&T) -> T {::clone}, val: Value() } } bb1: { @@ -34,13 +34,11 @@ StorageLive(_7); // scope 0 at $DIR/combine_clone_of_primitives.rs:9:5: 9:11 _7 = &((*_1).1: u64); // scope 0 at $DIR/combine_clone_of_primitives.rs:9:5: 9:11 - _6 = &(*_7); // scope 0 at $DIR/combine_clone_of_primitives.rs:9:5: 9:11 -- _5 = ::clone(move _6) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/combine_clone_of_primitives.rs:9:5: 9:11 -- // mir::Constant -- // + span: $DIR/combine_clone_of_primitives.rs:9:5: 9:11 -- // + literal: Const { ty: for<'a> fn(&'a u64) -> u64 {::clone}, val: Value() } + _6 = _7; // scope 0 at $DIR/combine_clone_of_primitives.rs:9:5: 9:11 -+ _5 = (*_6); // scope 0 at $DIR/combine_clone_of_primitives.rs:9:5: 9:11 -+ goto -> bb2; // scope 0 at $DIR/combine_clone_of_primitives.rs:9:5: 9:11 + _5 = ::clone(move _6) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/combine_clone_of_primitives.rs:9:5: 9:11 + // mir::Constant + // + span: $DIR/combine_clone_of_primitives.rs:9:5: 9:11 + // + literal: Const { ty: fn(&u64) -> u64 {::clone}, val: Value() } } bb2: { @@ -50,13 +48,11 @@ StorageLive(_10); // scope 0 at $DIR/combine_clone_of_primitives.rs:10:5: 10:16 _10 = &((*_1).2: [f32; 3]); // scope 0 at $DIR/combine_clone_of_primitives.rs:10:5: 10:16 - _9 = &(*_10); // scope 0 at $DIR/combine_clone_of_primitives.rs:10:5: 10:16 -- _8 = <[f32; 3] as Clone>::clone(move _9) -> [return: bb3, unwind: bb4]; // scope 0 at $DIR/combine_clone_of_primitives.rs:10:5: 10:16 -- // mir::Constant -- // + span: $DIR/combine_clone_of_primitives.rs:10:5: 10:16 -- // + literal: Const { ty: for<'a> fn(&'a [f32; 3]) -> [f32; 3] {<[f32; 3] as Clone>::clone}, val: Value() } + _9 = _10; // scope 0 at $DIR/combine_clone_of_primitives.rs:10:5: 10:16 -+ _8 = (*_9); // scope 0 at $DIR/combine_clone_of_primitives.rs:10:5: 10:16 -+ goto -> bb3; // scope 0 at $DIR/combine_clone_of_primitives.rs:10:5: 10:16 + _8 = <[f32; 3] as Clone>::clone(move _9) -> [return: bb3, unwind: bb4]; // scope 0 at $DIR/combine_clone_of_primitives.rs:10:5: 10:16 + // mir::Constant + // + span: $DIR/combine_clone_of_primitives.rs:10:5: 10:16 + // + literal: Const { ty: fn(&[f32; 3]) -> [f32; 3] {<[f32; 3] as Clone>::clone}, val: Value() } } bb3: { diff --git a/src/test/mir-opt/const_promotion_extern_static.BAR.PromoteTemps.diff b/src/test/mir-opt/const_promotion_extern_static.BAR.PromoteTemps.diff index f8a7c687e124a..5c8f2bfdd2302 100644 --- a/src/test/mir-opt/const_promotion_extern_static.BAR.PromoteTemps.diff +++ b/src/test/mir-opt/const_promotion_extern_static.BAR.PromoteTemps.diff @@ -33,7 +33,7 @@ _0 = core::slice::::as_ptr(move _1) -> [return: bb1, unwind: bb2]; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:44 // mir::Constant // + span: $DIR/const-promotion-extern-static.rs:9:36: 9:42 - // + literal: Const { ty: for<'a> fn(&'a [&i32]) -> *const &i32 {core::slice::::as_ptr}, val: Value() } + // + literal: Const { ty: fn(&[&i32]) -> *const &i32 {core::slice::::as_ptr}, val: Value() } } bb1: { diff --git a/src/test/mir-opt/const_promotion_extern_static.FOO.PromoteTemps.diff b/src/test/mir-opt/const_promotion_extern_static.FOO.PromoteTemps.diff index e938ca28af5d6..b1a24fdb677c4 100644 --- a/src/test/mir-opt/const_promotion_extern_static.FOO.PromoteTemps.diff +++ b/src/test/mir-opt/const_promotion_extern_static.FOO.PromoteTemps.diff @@ -35,7 +35,7 @@ _0 = core::slice::::as_ptr(move _1) -> [return: bb1, unwind: bb2]; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:55 // mir::Constant // + span: $DIR/const-promotion-extern-static.rs:13:47: 13:53 - // + literal: Const { ty: for<'a> fn(&'a [&i32]) -> *const &i32 {core::slice::::as_ptr}, val: Value() } + // + literal: Const { ty: fn(&[&i32]) -> *const &i32 {core::slice::::as_ptr}, val: Value() } } bb1: { diff --git a/src/test/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.diff b/src/test/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.diff index 995611f0e9664..1e99fcd795540 100644 --- a/src/test/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.diff +++ b/src/test/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.diff @@ -20,7 +20,7 @@ _2 = core::str::::as_bytes(move _3) -> bb1; // scope 0 at $DIR/deduplicate_blocks.rs:+1:11: +1:23 // mir::Constant // + span: $DIR/deduplicate_blocks.rs:5:13: 5:21 - // + literal: Const { ty: for<'a> fn(&'a str) -> &'a [u8] {core::str::::as_bytes}, val: Value() } + // + literal: Const { ty: fn(&str) -> &[u8] {core::str::::as_bytes}, val: Value() } } bb1: { diff --git a/src/test/mir-opt/derefer_complex_case.main.Derefer.diff b/src/test/mir-opt/derefer_complex_case.main.Derefer.diff index 713d56c383613..58ceeba7fb57a 100644 --- a/src/test/mir-opt/derefer_complex_case.main.Derefer.diff +++ b/src/test/mir-opt/derefer_complex_case.main.Derefer.diff @@ -56,7 +56,7 @@ _7 = as Iterator>::next(move _8) -> bb3; // scope 1 at $DIR/derefer_complex_case.rs:+1:17: +1:26 // mir::Constant // + span: $DIR/derefer_complex_case.rs:6:17: 6:26 - // + literal: Const { ty: for<'a> fn(&'a mut std::slice::Iter<'_, i32>) -> Option< as Iterator>::Item> { as Iterator>::next}, val: Value() } + // + literal: Const { ty: fn(&mut std::slice::Iter<'_, i32>) -> Option< as Iterator>::Item> { as Iterator>::next}, val: Value() } } bb3: { diff --git a/src/test/mir-opt/funky_arms.float_to_exponential_common.ConstProp.diff b/src/test/mir-opt/funky_arms.float_to_exponential_common.ConstProp.diff index 6ab63e82e35d2..8a77f015ab344 100644 --- a/src/test/mir-opt/funky_arms.float_to_exponential_common.ConstProp.diff +++ b/src/test/mir-opt/funky_arms.float_to_exponential_common.ConstProp.diff @@ -41,7 +41,7 @@ _4 = Formatter::<'_>::sign_plus(move _5) -> bb1; // scope 0 at $DIR/funky_arms.rs:+4:22: +4:37 // mir::Constant // + span: $DIR/funky_arms.rs:15:26: 15:35 - // + literal: Const { ty: for<'a> fn(&'a Formatter<'_>) -> bool {Formatter::<'_>::sign_plus}, val: Value() } + // + literal: Const { ty: fn(&Formatter<'_>) -> bool {Formatter::<'_>::sign_plus}, val: Value() } } bb1: { @@ -69,7 +69,7 @@ _7 = Formatter::<'_>::precision(move _8) -> bb5; // scope 3 at $DIR/funky_arms.rs:+13:30: +13:45 // mir::Constant // + span: $DIR/funky_arms.rs:24:34: 24:43 - // + literal: Const { ty: for<'a> fn(&'a Formatter<'_>) -> Option {Formatter::<'_>::precision}, val: Value() } + // + literal: Const { ty: fn(&Formatter<'_>) -> Option {Formatter::<'_>::precision}, val: Value() } } bb5: { @@ -97,10 +97,10 @@ StorageDead(_15); // scope 3 at $DIR/funky_arms.rs:+15:78: +15:79 StorageLive(_17); // scope 3 at $DIR/funky_arms.rs:+15:81: +15:86 _17 = _3; // scope 3 at $DIR/funky_arms.rs:+15:81: +15:86 - _0 = float_to_exponential_common_exact::(move _11, move _12, move _13, move _14, move _17) -> bb7; // scope 3 at $DIR/funky_arms.rs:+15:9: +15:87 + _0 = float_to_exponential_common_exact::(move _11, move _12, move _13, move _14, move _17) -> bb7; // scope 3 at $DIR/funky_arms.rs:+15:9: +15:87 // mir::Constant // + span: $DIR/funky_arms.rs:26:9: 26:42 - // + literal: Const { ty: for<'a, 'b, 'c> fn(&'a mut Formatter<'b>, &'c T, Sign, u32, bool) -> Result<(), std::fmt::Error> {float_to_exponential_common_exact::}, val: Value() } + // + literal: Const { ty: fn(&mut Formatter<'_>, &T, Sign, u32, bool) -> Result<(), std::fmt::Error> {float_to_exponential_common_exact::}, val: Value() } } bb7: { @@ -122,10 +122,10 @@ _20 = _6; // scope 2 at $DIR/funky_arms.rs:+17:56: +17:60 StorageLive(_21); // scope 2 at $DIR/funky_arms.rs:+17:62: +17:67 _21 = _3; // scope 2 at $DIR/funky_arms.rs:+17:62: +17:67 - _0 = float_to_exponential_common_shortest::(move _18, move _19, move _20, move _21) -> bb9; // scope 2 at $DIR/funky_arms.rs:+17:9: +17:68 + _0 = float_to_exponential_common_shortest::(move _18, move _19, move _20, move _21) -> bb9; // scope 2 at $DIR/funky_arms.rs:+17:9: +17:68 // mir::Constant // + span: $DIR/funky_arms.rs:28:9: 28:45 - // + literal: Const { ty: for<'a, 'b, 'c> fn(&'a mut Formatter<'b>, &'c T, Sign, bool) -> Result<(), std::fmt::Error> {float_to_exponential_common_shortest::}, val: Value() } + // + literal: Const { ty: fn(&mut Formatter<'_>, &T, Sign, bool) -> Result<(), std::fmt::Error> {float_to_exponential_common_shortest::}, val: Value() } } bb9: { diff --git a/src/test/mir-opt/inline/cycle.f.Inline.diff b/src/test/mir-opt/inline/cycle.f.Inline.diff index 75ea69a42eb59..52decac7812a4 100644 --- a/src/test/mir-opt/inline/cycle.f.Inline.diff +++ b/src/test/mir-opt/inline/cycle.f.Inline.diff @@ -17,7 +17,7 @@ _2 = >::call(move _3, move _4) -> [return: bb1, unwind: bb3]; // scope 0 at $DIR/cycle.rs:+1:5: +1:8 // mir::Constant // + span: $DIR/cycle.rs:6:5: 6:6 - // + literal: Const { ty: for<'a> extern "rust-call" fn(&'a impl Fn(), ()) -> >::Output {>::call}, val: Value() } + // + literal: Const { ty: extern "rust-call" fn(&impl Fn(), ()) -> >::Output {>::call}, val: Value() } } bb1: { diff --git a/src/test/mir-opt/inline/dyn_trait.get_query.Inline.diff b/src/test/mir-opt/inline/dyn_trait.get_query.Inline.diff index 1e95b5b29ff4e..c3ec74f79c8f6 100644 --- a/src/test/mir-opt/inline/dyn_trait.get_query.Inline.diff +++ b/src/test/mir-opt/inline/dyn_trait.get_query.Inline.diff @@ -9,11 +9,11 @@ let mut _4: &::C; // in scope 0 at $DIR/dyn-trait.rs:+2:23: +2:24 scope 1 { debug c => _2; // in scope 1 at $DIR/dyn-trait.rs:+1:9: +1:10 -+ scope 2 (inlined try_execute_query::<::C>) { // at $DIR/dyn-trait.rs:34:5: 34:25 ++ scope 2 (inlined try_execute_query::<::C, '_>) { // at $DIR/dyn-trait.rs:34:5: 34:25 + debug c => _4; // in scope 2 at $DIR/dyn-trait.rs:26:36: 26:37 + let mut _5: &dyn Cache::V>; // in scope 2 at $DIR/dyn-trait.rs:27:14: 27:15 + let mut _6: &::C; // in scope 2 at $DIR/dyn-trait.rs:27:14: 27:15 -+ scope 3 (inlined mk_cycle::<::V>) { // at $DIR/dyn-trait.rs:27:5: 27:16 ++ scope 3 (inlined mk_cycle::<::V, '_>) { // at $DIR/dyn-trait.rs:27:5: 27:16 + debug c => _5; // in scope 3 at $DIR/dyn-trait.rs:20:27: 20:28 + let mut _7: &dyn Cache::V>; // in scope 3 at $DIR/dyn-trait.rs:21:5: 21:22 + } @@ -24,18 +24,18 @@ StorageLive(_2); // scope 0 at $DIR/dyn-trait.rs:+1:9: +1:10 StorageLive(_3); // scope 0 at $DIR/dyn-trait.rs:+1:22: +1:23 _3 = &(*_1); // scope 0 at $DIR/dyn-trait.rs:+1:22: +1:23 - _2 = ::cache::(move _3) -> bb1; // scope 0 at $DIR/dyn-trait.rs:+1:13: +1:24 + _2 = ::cache::(move _3) -> bb1; // scope 0 at $DIR/dyn-trait.rs:+1:13: +1:24 // mir::Constant // + span: $DIR/dyn-trait.rs:33:13: 33:21 // + user_ty: UserType(0) - // + literal: Const { ty: for<'a> fn(&'a T) -> &'a ::C {::cache::}, val: Value() } + // + literal: Const { ty: fn(&T) -> &::C {::cache::}, val: Value() } } bb1: { StorageDead(_3); // scope 0 at $DIR/dyn-trait.rs:+1:23: +1:24 StorageLive(_4); // scope 1 at $DIR/dyn-trait.rs:+2:23: +2:24 _4 = &(*_2); // scope 1 at $DIR/dyn-trait.rs:+2:23: +2:24 -- _0 = try_execute_query::<::C>(move _4) -> bb2; // scope 1 at $DIR/dyn-trait.rs:+2:5: +2:25 +- _0 = try_execute_query::<::C, '_>(move _4) -> bb2; // scope 1 at $DIR/dyn-trait.rs:+2:5: +2:25 + StorageLive(_5); // scope 2 at $DIR/dyn-trait.rs:27:14: 27:15 + StorageLive(_6); // scope 2 at $DIR/dyn-trait.rs:27:14: 27:15 + _6 = _4; // scope 2 at $DIR/dyn-trait.rs:27:14: 27:15 @@ -46,9 +46,9 @@ + _0 = ::V> as Cache>::store_nocache(move _7) -> bb2; // scope 3 at $DIR/dyn-trait.rs:21:5: 21:22 // mir::Constant - // + span: $DIR/dyn-trait.rs:34:5: 34:22 -- // + literal: Const { ty: for<'a> fn(&'a ::C) {try_execute_query::<::C>}, val: Value() } +- // + literal: Const { ty: fn(&::C) {try_execute_query::<::C, '_>}, val: Value() } + // + span: $DIR/dyn-trait.rs:21:7: 21:20 -+ // + literal: Const { ty: for<'a> fn(&'a dyn Cache::V>) {::V> as Cache>::store_nocache}, val: Value() } ++ // + literal: Const { ty: fn(&dyn Cache::V>) {::V> as Cache>::store_nocache}, val: Value() } } bb2: { diff --git a/src/test/mir-opt/inline/dyn_trait.mk_cycle.Inline.diff b/src/test/mir-opt/inline/dyn_trait.mk_cycle.Inline.diff index 7421db4d063af..611d2d25f06f9 100644 --- a/src/test/mir-opt/inline/dyn_trait.mk_cycle.Inline.diff +++ b/src/test/mir-opt/inline/dyn_trait.mk_cycle.Inline.diff @@ -12,7 +12,7 @@ _0 = as Cache>::store_nocache(move _2) -> bb1; // scope 0 at $DIR/dyn-trait.rs:+1:5: +1:22 // mir::Constant // + span: $DIR/dyn-trait.rs:21:7: 21:20 - // + literal: Const { ty: for<'a> fn(&'a dyn Cache) { as Cache>::store_nocache}, val: Value() } + // + literal: Const { ty: fn(&dyn Cache) { as Cache>::store_nocache}, val: Value() } } bb1: { diff --git a/src/test/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff b/src/test/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff index e6e783744227e..460c73cbf52ca 100644 --- a/src/test/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff +++ b/src/test/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff @@ -6,7 +6,7 @@ let mut _0: (); // return place in scope 0 at $DIR/dyn-trait.rs:+0:43: +0:43 let mut _2: &dyn Cache::V>; // in scope 0 at $DIR/dyn-trait.rs:+1:14: +1:15 let mut _3: &C; // in scope 0 at $DIR/dyn-trait.rs:+1:14: +1:15 -+ scope 1 (inlined mk_cycle::<::V>) { // at $DIR/dyn-trait.rs:27:5: 27:16 ++ scope 1 (inlined mk_cycle::<::V, '_>) { // at $DIR/dyn-trait.rs:27:5: 27:16 + debug c => _2; // in scope 1 at $DIR/dyn-trait.rs:20:27: 20:28 + let mut _4: &dyn Cache::V>; // in scope 1 at $DIR/dyn-trait.rs:21:5: 21:22 + } @@ -17,15 +17,15 @@ _3 = &(*_1); // scope 0 at $DIR/dyn-trait.rs:+1:14: +1:15 _2 = move _3 as &dyn Cache::V> (Pointer(Unsize)); // scope 0 at $DIR/dyn-trait.rs:+1:14: +1:15 StorageDead(_3); // scope 0 at $DIR/dyn-trait.rs:+1:14: +1:15 -- _0 = mk_cycle::<::V>(move _2) -> bb1; // scope 0 at $DIR/dyn-trait.rs:+1:5: +1:16 +- _0 = mk_cycle::<::V, '_>(move _2) -> bb1; // scope 0 at $DIR/dyn-trait.rs:+1:5: +1:16 + StorageLive(_4); // scope 1 at $DIR/dyn-trait.rs:21:5: 21:22 + _4 = _2; // scope 1 at $DIR/dyn-trait.rs:21:5: 21:22 + _0 = ::V> as Cache>::store_nocache(move _4) -> bb1; // scope 1 at $DIR/dyn-trait.rs:21:5: 21:22 // mir::Constant - // + span: $DIR/dyn-trait.rs:27:5: 27:13 -- // + literal: Const { ty: for<'a> fn(&'a (dyn Cache::V> + 'a)) {mk_cycle::<::V>}, val: Value() } +- // + literal: Const { ty: fn(&dyn Cache::V>) {mk_cycle::<::V, '_>}, val: Value() } + // + span: $DIR/dyn-trait.rs:21:7: 21:20 -+ // + literal: Const { ty: for<'a> fn(&'a dyn Cache::V>) {::V> as Cache>::store_nocache}, val: Value() } ++ // + literal: Const { ty: fn(&dyn Cache::V>) {::V> as Cache>::store_nocache}, val: Value() } } bb1: { diff --git a/src/test/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir b/src/test/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir index 4069e9f89c8d8..39d56d46a77f5 100644 --- a/src/test/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir +++ b/src/test/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir @@ -4,8 +4,8 @@ fn foo(_1: T, _2: &i32) -> i32 { debug _t => _1; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:+0:17: +0:19 debug q => _2; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:+0:24: +0:25 let mut _0: i32; // return place in scope 0 at $DIR/inline-closure-borrows-arg.rs:+0:36: +0:39 - let _3: [closure@foo::{closure#0}]; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:+1:9: +1:10 - let mut _4: &[closure@foo::{closure#0}]; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:+5:5: +5:6 + let _3: [closure@foo::{closure#0}]; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:+1:9: +1:10 + let mut _4: &[closure@foo::{closure#0}]; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:+5:5: +5:6 let mut _5: (&i32, &i32); // in scope 0 at $DIR/inline-closure-borrows-arg.rs:+5:5: +5:12 let mut _6: &i32; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:+5:7: +5:8 let mut _7: &i32; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:+5:10: +5:11 @@ -13,7 +13,7 @@ fn foo(_1: T, _2: &i32) -> i32 { let mut _9: &i32; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:+5:5: +5:12 scope 1 { debug x => _3; // in scope 1 at $DIR/inline-closure-borrows-arg.rs:+1:9: +1:10 - scope 2 (inlined foo::::{closure#0}) { // at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + scope 2 (inlined foo::::{closure#0}) { // at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 debug r => _8; // in scope 2 at $DIR/inline-closure-borrows-arg.rs:+1:14: +1:15 debug _s => _9; // in scope 2 at $DIR/inline-closure-borrows-arg.rs:+1:23: +1:25 let _10: &i32; // in scope 2 at $DIR/inline-closure-borrows-arg.rs:+2:13: +2:21 diff --git a/src/test/mir-opt/inline/inline_generator.main.Inline.diff b/src/test/mir-opt/inline/inline_generator.main.Inline.diff index 3fd8aad723880..843cb10cae749 100644 --- a/src/test/mir-opt/inline/inline_generator.main.Inline.diff +++ b/src/test/mir-opt/inline/inline_generator.main.Inline.diff @@ -70,7 +70,7 @@ - _1 = <[generator@$DIR/inline-generator.rs:15:5: 15:8] as Generator>::resume(move _2, const false) -> [return: bb3, unwind: bb4]; // scope 0 at $DIR/inline-generator.rs:+1:14: +1:46 - // mir::Constant - // + span: $DIR/inline-generator.rs:9:33: 9:39 -- // + literal: Const { ty: for<'a> fn(Pin<&'a mut [generator@$DIR/inline-generator.rs:15:5: 15:8]>, bool) -> GeneratorState<<[generator@$DIR/inline-generator.rs:15:5: 15:8] as Generator>::Yield, <[generator@$DIR/inline-generator.rs:15:5: 15:8] as Generator>::Return> {<[generator@$DIR/inline-generator.rs:15:5: 15:8] as Generator>::resume}, val: Value() } +- // + literal: Const { ty: fn(Pin<&mut [generator@$DIR/inline-generator.rs:15:5: 15:8]>, bool) -> GeneratorState<<[generator@$DIR/inline-generator.rs:15:5: 15:8] as Generator>::Yield, <[generator@$DIR/inline-generator.rs:15:5: 15:8] as Generator>::Return> {<[generator@$DIR/inline-generator.rs:15:5: 15:8] as Generator>::resume}, val: Value() } + StorageLive(_7); // scope 0 at $DIR/inline-generator.rs:+1:14: +1:46 + _7 = const false; // scope 0 at $DIR/inline-generator.rs:+1:14: +1:46 + StorageLive(_10); // scope 0 at $DIR/inline-generator.rs:+1:14: +1:46 diff --git a/src/test/mir-opt/inline/inline_retag.bar.Inline.after.mir b/src/test/mir-opt/inline/inline_retag.bar.Inline.after.mir index 169e7f5c5d936..c562da0dd8e31 100644 --- a/src/test/mir-opt/inline/inline_retag.bar.Inline.after.mir +++ b/src/test/mir-opt/inline/inline_retag.bar.Inline.after.mir @@ -2,8 +2,8 @@ fn bar() -> bool { let mut _0: bool; // return place in scope 0 at $DIR/inline-retag.rs:+0:13: +0:17 - let _1: for<'a, 'b> fn(&'a i32, &'b i32) -> bool {foo}; // in scope 0 at $DIR/inline-retag.rs:+1:9: +1:10 - let mut _2: for<'a, 'b> fn(&'a i32, &'b i32) -> bool {foo}; // in scope 0 at $DIR/inline-retag.rs:+2:5: +2:6 + let _1: fn(&i32, &i32) -> bool {foo}; // in scope 0 at $DIR/inline-retag.rs:+1:9: +1:10 + let mut _2: fn(&i32, &i32) -> bool {foo}; // in scope 0 at $DIR/inline-retag.rs:+2:5: +2:6 let mut _3: &i32; // in scope 0 at $DIR/inline-retag.rs:+2:7: +2:9 let _4: &i32; // in scope 0 at $DIR/inline-retag.rs:+2:7: +2:9 let _5: i32; // in scope 0 at $DIR/inline-retag.rs:+2:8: +2:9 @@ -27,7 +27,7 @@ fn bar() -> bool { _1 = foo; // scope 0 at $DIR/inline-retag.rs:+1:13: +1:16 // mir::Constant // + span: $DIR/inline-retag.rs:11:13: 11:16 - // + literal: Const { ty: for<'a, 'b> fn(&'a i32, &'b i32) -> bool {foo}, val: Value() } + // + literal: Const { ty: fn(&i32, &i32) -> bool {foo}, val: Value() } StorageLive(_2); // scope 1 at $DIR/inline-retag.rs:+2:5: +2:6 _2 = _1; // scope 1 at $DIR/inline-retag.rs:+2:5: +2:6 StorageLive(_3); // scope 1 at $DIR/inline-retag.rs:+2:7: +2:9 diff --git a/src/test/mir-opt/inline/inline_shims.clone.Inline.diff b/src/test/mir-opt/inline/inline_shims.clone.Inline.diff index d691e90b7dac6..f801586b3e346 100644 --- a/src/test/mir-opt/inline/inline_shims.clone.Inline.diff +++ b/src/test/mir-opt/inline/inline_shims.clone.Inline.diff @@ -14,7 +14,7 @@ - _0 = ::clone(move _2) -> bb1; // scope 0 at $DIR/inline-shims.rs:+1:5: +1:14 - // mir::Constant - // + span: $DIR/inline-shims.rs:6:7: 6:12 -- // + literal: Const { ty: for<'a> fn(&'a fn(A, B)) -> fn(A, B) {::clone}, val: Value() } +- // + literal: Const { ty: fn(&fn(A, B)) -> fn(A, B) {::clone}, val: Value() } - } - - bb1: { diff --git a/src/test/mir-opt/inline/inline_trait_method.test.Inline.after.mir b/src/test/mir-opt/inline/inline_trait_method.test.Inline.after.mir index 89eefc2926911..060f2deb1f5b0 100644 --- a/src/test/mir-opt/inline/inline_trait_method.test.Inline.after.mir +++ b/src/test/mir-opt/inline/inline_trait_method.test.Inline.after.mir @@ -11,7 +11,7 @@ fn test(_1: &dyn X) -> u32 { _0 = ::y(move _2) -> bb1; // scope 0 at $DIR/inline-trait-method.rs:+1:5: +1:10 // mir::Constant // + span: $DIR/inline-trait-method.rs:9:7: 9:8 - // + literal: Const { ty: for<'a> fn(&'a dyn X) -> u32 {::y}, val: Value() } + // + literal: Const { ty: fn(&dyn X) -> u32 {::y}, val: Value() } } bb1: { diff --git a/src/test/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir b/src/test/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir index 3d05869fa513e..57d0002ab442c 100644 --- a/src/test/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir +++ b/src/test/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir @@ -21,7 +21,7 @@ fn test2(_1: &dyn X) -> bool { _0 = ::y(move _4) -> bb1; // scope 1 at $DIR/inline-trait-method_2.rs:10:5: 10:10 // mir::Constant // + span: $DIR/inline-trait-method_2.rs:10:7: 10:8 - // + literal: Const { ty: for<'a> fn(&'a dyn X) -> bool {::y}, val: Value() } + // + literal: Const { ty: fn(&dyn X) -> bool {::y}, val: Value() } } bb1: { diff --git a/src/test/mir-opt/inline/issue_78442.bar.Inline.diff b/src/test/mir-opt/inline/issue_78442.bar.Inline.diff index 4186650dfabe0..1691e37c66638 100644 --- a/src/test/mir-opt/inline/issue_78442.bar.Inline.diff +++ b/src/test/mir-opt/inline/issue_78442.bar.Inline.diff @@ -29,7 +29,7 @@ - _2 = >::call(move _3, move _5) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/issue-78442.rs:+4:5: +4:17 - // mir::Constant - // + span: $DIR/issue-78442.rs:11:5: 11:15 -- // + literal: Const { ty: for<'a> extern "rust-call" fn(&'a fn() {foo}, ()) -> >::Output {>::call}, val: Value() } +- // + literal: Const { ty: extern "rust-call" fn(&fn() {foo}, ()) -> >::Output {>::call}, val: Value() } + _2 = move (*_3)() -> [return: bb5, unwind: bb3]; // scope 1 at $SRC_DIR/core/src/ops/function.rs:LL:COL } diff --git a/src/test/mir-opt/inline/issue_78442.bar.RevealAll.diff b/src/test/mir-opt/inline/issue_78442.bar.RevealAll.diff index 24e9a3df15acd..a184783272d6c 100644 --- a/src/test/mir-opt/inline/issue_78442.bar.RevealAll.diff +++ b/src/test/mir-opt/inline/issue_78442.bar.RevealAll.diff @@ -29,8 +29,8 @@ + _2 = >::call(move _3, move _5) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/issue-78442.rs:+4:5: +4:17 // mir::Constant // + span: $DIR/issue-78442.rs:11:5: 11:15 -- // + literal: Const { ty: for<'a> extern "rust-call" fn(&'a impl Fn(), ()) -> >::Output {>::call}, val: Value() } -+ // + literal: Const { ty: for<'a> extern "rust-call" fn(&'a fn() {foo}, ()) -> >::Output {>::call}, val: Value() } +- // + literal: Const { ty: extern "rust-call" fn(&impl Fn(), ()) -> >::Output {>::call}, val: Value() } ++ // + literal: Const { ty: extern "rust-call" fn(&fn() {foo}, ()) -> >::Output {>::call}, val: Value() } } bb2: { diff --git a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.diff b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.diff index 269e4e3261751..5ae9f6b556bd8 100644 --- a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.diff +++ b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.diff @@ -136,10 +136,10 @@ StorageLive(_27); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL Deinit(_27); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL discriminant(_27) = 0; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _21 = core::panicking::assert_failed::(const core::panicking::AssertKind::Eq, move _23, move _25, move _27); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _21 = core::panicking::assert_failed::(const core::panicking::AssertKind::Eq, move _23, move _25, move _27); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL - // + literal: Const { ty: for<'a, 'b, 'c> fn(core::panicking::AssertKind, &'a i32, &'b i32, Option>) -> ! {core::panicking::assert_failed::}, val: Value() } + // + literal: Const { ty: fn(core::panicking::AssertKind, &i32, &i32, Option>) -> ! {core::panicking::assert_failed::}, val: Value() } // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: core::panicking::AssertKind, val: Value(Scalar(0x00)) } diff --git a/src/test/mir-opt/issue_91633.bar.mir_map.0.mir b/src/test/mir-opt/issue_91633.bar.mir_map.0.mir index 625f6c7361ac8..42e1d97459b1d 100644 --- a/src/test/mir-opt/issue_91633.bar.mir_map.0.mir +++ b/src/test/mir-opt/issue_91633.bar.mir_map.0.mir @@ -15,7 +15,7 @@ fn bar(_1: Box<[T]>) -> () { _2 = <[T] as Index>::index(move _3, const 0_usize) -> [return: bb1, unwind: bb3]; // scope 0 at $DIR/issue-91633.rs:+4:14: +4:19 // mir::Constant // + span: $DIR/issue-91633.rs:15:14: 15:19 - // + literal: Const { ty: for<'a> fn(&'a [T], usize) -> &'a <[T] as Index>::Output {<[T] as Index>::index}, val: Value() } + // + literal: Const { ty: fn(&[T], usize) -> &<[T] as Index>::Output {<[T] as Index>::index}, val: Value() } } bb1: { diff --git a/src/test/mir-opt/issue_91633.foo.mir_map.0.mir b/src/test/mir-opt/issue_91633.foo.mir_map.0.mir index 9903e203a2312..defa5fc980213 100644 --- a/src/test/mir-opt/issue_91633.foo.mir_map.0.mir +++ b/src/test/mir-opt/issue_91633.foo.mir_map.0.mir @@ -27,7 +27,7 @@ fn foo(_1: Box<[T]>) -> T { _2 = ::clone(move _3) -> [return: bb2, unwind: bb5]; // scope 0 at $DIR/issue-91633.rs:+2:14: +2:27 // mir::Constant // + span: $DIR/issue-91633.rs:28:20: 28:25 - // + literal: Const { ty: for<'a> fn(&'a T) -> T {::clone}, val: Value() } + // + literal: Const { ty: fn(&T) -> T {::clone}, val: Value() } } bb2: { diff --git a/src/test/mir-opt/issue_91633.hey.mir_map.0.mir b/src/test/mir-opt/issue_91633.hey.mir_map.0.mir index 37c3b3fcacafb..374a9266e12d3 100644 --- a/src/test/mir-opt/issue_91633.hey.mir_map.0.mir +++ b/src/test/mir-opt/issue_91633.hey.mir_map.0.mir @@ -17,7 +17,7 @@ fn hey(_1: &[T]) -> () { _3 = <[T] as Index>::index(move _4, const 0_usize) -> [return: bb1, unwind: bb2]; // scope 0 at $DIR/issue-91633.rs:+4:15: +4:20 // mir::Constant // + span: $DIR/issue-91633.rs:7:15: 7:20 - // + literal: Const { ty: for<'a> fn(&'a [T], usize) -> &'a <[T] as Index>::Output {<[T] as Index>::index}, val: Value() } + // + literal: Const { ty: fn(&[T], usize) -> &<[T] as Index>::Output {<[T] as Index>::index}, val: Value() } } bb1: { diff --git a/src/test/mir-opt/issue_99325.main.mir_map.0.mir b/src/test/mir-opt/issue_99325.main.mir_map.0.mir index 165efa9df4118..c0884ecda9b85 100644 --- a/src/test/mir-opt/issue_99325.main.mir_map.0.mir +++ b/src/test/mir-opt/issue_99325.main.mir_map.0.mir @@ -101,7 +101,7 @@ fn main() -> () { _11 = <&[u8] as PartialEq<&[u8; 4]>>::eq(move _12, move _13) -> [return: bb2, unwind: bb19]; // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL - // + literal: Const { ty: for<'a, 'b> fn(&'a &[u8], &'b &[u8; 4]) -> bool {<&[u8] as PartialEq<&[u8; 4]>>::eq}, val: Value() } + // + literal: Const { ty: fn(&&[u8], &&[u8; 4]) -> bool {<&[u8] as PartialEq<&[u8; 4]>>::eq}, val: Value() } } bb2: { @@ -129,10 +129,10 @@ fn main() -> () { _20 = &(*_21); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_22); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _22 = Option::>::None; // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _16 = core::panicking::assert_failed::<&[u8], &[u8; 4]>(move _17, move _18, move _20, move _22) -> bb19; // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _16 = core::panicking::assert_failed::<&[u8], &[u8; 4], '_, '_, '_>(move _17, move _18, move _20, move _22) -> bb19; // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL - // + literal: Const { ty: for<'a, 'b, 'c> fn(core::panicking::AssertKind, &'a &[u8], &'b &[u8; 4], Option>) -> ! {core::panicking::assert_failed::<&[u8], &[u8; 4]>}, val: Value() } + // + literal: Const { ty: fn(core::panicking::AssertKind, &&[u8], &&[u8; 4], Option>) -> ! {core::panicking::assert_failed::<&[u8], &[u8; 4], '_, '_, '_>}, val: Value() } } bb4: { @@ -210,7 +210,7 @@ fn main() -> () { _32 = <&[u8] as PartialEq<&[u8; 4]>>::eq(move _33, move _34) -> [return: bb11, unwind: bb19]; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL - // + literal: Const { ty: for<'a, 'b> fn(&'a &[u8], &'b &[u8; 4]) -> bool {<&[u8] as PartialEq<&[u8; 4]>>::eq}, val: Value() } + // + literal: Const { ty: fn(&&[u8], &&[u8; 4]) -> bool {<&[u8] as PartialEq<&[u8; 4]>>::eq}, val: Value() } } bb11: { @@ -238,10 +238,10 @@ fn main() -> () { _41 = &(*_42); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_43); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _43 = Option::>::None; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _37 = core::panicking::assert_failed::<&[u8], &[u8; 4]>(move _38, move _39, move _41, move _43) -> bb19; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _37 = core::panicking::assert_failed::<&[u8], &[u8; 4], '_, '_, '_>(move _38, move _39, move _41, move _43) -> bb19; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL - // + literal: Const { ty: for<'a, 'b, 'c> fn(core::panicking::AssertKind, &'a &[u8], &'b &[u8; 4], Option>) -> ! {core::panicking::assert_failed::<&[u8], &[u8; 4]>}, val: Value() } + // + literal: Const { ty: fn(core::panicking::AssertKind, &&[u8], &&[u8; 4], Option>) -> ! {core::panicking::assert_failed::<&[u8], &[u8; 4], '_, '_, '_>}, val: Value() } } bb13: { diff --git a/src/test/mir-opt/lower_intrinsics.discriminant.LowerIntrinsics.diff b/src/test/mir-opt/lower_intrinsics.discriminant.LowerIntrinsics.diff index d962ef8cb12dc..770c4b1f6523d 100644 --- a/src/test/mir-opt/lower_intrinsics.discriminant.LowerIntrinsics.diff +++ b/src/test/mir-opt/lower_intrinsics.discriminant.LowerIntrinsics.diff @@ -29,10 +29,10 @@ StorageLive(_4); // scope 0 at $DIR/lower_intrinsics.rs:+1:42: +1:44 _4 = &_1; // scope 0 at $DIR/lower_intrinsics.rs:+1:42: +1:44 _3 = &(*_4); // scope 0 at $DIR/lower_intrinsics.rs:+1:42: +1:44 -- _2 = discriminant_value::(move _3) -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:45 +- _2 = discriminant_value::(move _3) -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:45 - // mir::Constant - // + span: $DIR/lower_intrinsics.rs:49:5: 49:41 -- // + literal: Const { ty: for<'a> extern "rust-intrinsic" fn(&'a T) -> ::Discriminant {discriminant_value::}, val: Value() } +- // + literal: Const { ty: extern "rust-intrinsic" fn(&T) -> ::Discriminant {discriminant_value::}, val: Value() } + _2 = discriminant((*_3)); // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:45 + goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:45 } @@ -50,10 +50,10 @@ // + literal: Const { ty: &i32, val: Unevaluated(discriminant, [T], Some(promoted[2])) } _7 = &(*_19); // scope 0 at $DIR/lower_intrinsics.rs:+2:42: +2:44 _6 = &(*_7); // scope 0 at $DIR/lower_intrinsics.rs:+2:42: +2:44 -- _5 = discriminant_value::(move _6) -> bb2; // scope 0 at $DIR/lower_intrinsics.rs:+2:5: +2:45 +- _5 = discriminant_value::(move _6) -> bb2; // scope 0 at $DIR/lower_intrinsics.rs:+2:5: +2:45 - // mir::Constant - // + span: $DIR/lower_intrinsics.rs:50:5: 50:41 -- // + literal: Const { ty: for<'a> extern "rust-intrinsic" fn(&'a i32) -> ::Discriminant {discriminant_value::}, val: Value() } +- // + literal: Const { ty: extern "rust-intrinsic" fn(&i32) -> ::Discriminant {discriminant_value::}, val: Value() } + _5 = discriminant((*_6)); // scope 0 at $DIR/lower_intrinsics.rs:+2:5: +2:45 + goto -> bb2; // scope 0 at $DIR/lower_intrinsics.rs:+2:5: +2:45 } @@ -71,10 +71,10 @@ // + literal: Const { ty: &(), val: Unevaluated(discriminant, [T], Some(promoted[1])) } _11 = &(*_18); // scope 0 at $DIR/lower_intrinsics.rs:+3:42: +3:45 _10 = &(*_11); // scope 0 at $DIR/lower_intrinsics.rs:+3:42: +3:45 -- _9 = discriminant_value::<()>(move _10) -> bb3; // scope 0 at $DIR/lower_intrinsics.rs:+3:5: +3:46 +- _9 = discriminant_value::<(), '_>(move _10) -> bb3; // scope 0 at $DIR/lower_intrinsics.rs:+3:5: +3:46 - // mir::Constant - // + span: $DIR/lower_intrinsics.rs:51:5: 51:41 -- // + literal: Const { ty: for<'a> extern "rust-intrinsic" fn(&'a ()) -> <() as DiscriminantKind>::Discriminant {discriminant_value::<()>}, val: Value() } +- // + literal: Const { ty: extern "rust-intrinsic" fn(&()) -> <() as DiscriminantKind>::Discriminant {discriminant_value::<(), '_>}, val: Value() } + _9 = discriminant((*_10)); // scope 0 at $DIR/lower_intrinsics.rs:+3:5: +3:46 + goto -> bb3; // scope 0 at $DIR/lower_intrinsics.rs:+3:5: +3:46 } @@ -92,10 +92,10 @@ // + literal: Const { ty: &E, val: Unevaluated(discriminant, [T], Some(promoted[0])) } _15 = &(*_17); // scope 0 at $DIR/lower_intrinsics.rs:+4:42: +4:47 _14 = &(*_15); // scope 0 at $DIR/lower_intrinsics.rs:+4:42: +4:47 -- _13 = discriminant_value::(move _14) -> bb4; // scope 0 at $DIR/lower_intrinsics.rs:+4:5: +4:48 +- _13 = discriminant_value::(move _14) -> bb4; // scope 0 at $DIR/lower_intrinsics.rs:+4:5: +4:48 - // mir::Constant - // + span: $DIR/lower_intrinsics.rs:52:5: 52:41 -- // + literal: Const { ty: for<'a> extern "rust-intrinsic" fn(&'a E) -> ::Discriminant {discriminant_value::}, val: Value() } +- // + literal: Const { ty: extern "rust-intrinsic" fn(&E) -> ::Discriminant {discriminant_value::}, val: Value() } + _13 = discriminant((*_14)); // scope 0 at $DIR/lower_intrinsics.rs:+4:5: +4:48 + goto -> bb4; // scope 0 at $DIR/lower_intrinsics.rs:+4:5: +4:48 } diff --git a/src/test/mir-opt/lower_slice_len.bound.LowerSliceLenCalls.diff b/src/test/mir-opt/lower_slice_len.bound.LowerSliceLenCalls.diff index 5f5d6e68fdc17..b98cc31795fde 100644 --- a/src/test/mir-opt/lower_slice_len.bound.LowerSliceLenCalls.diff +++ b/src/test/mir-opt/lower_slice_len.bound.LowerSliceLenCalls.diff @@ -23,7 +23,7 @@ - _5 = core::slice::::len(move _6) -> bb1; // scope 0 at $DIR/lower_slice_len.rs:+1:16: +1:27 - // mir::Constant - // + span: $DIR/lower_slice_len.rs:5:22: 5:25 -- // + literal: Const { ty: for<'a> fn(&'a [u8]) -> usize {core::slice::::len}, val: Value() } +- // + literal: Const { ty: fn(&[u8]) -> usize {core::slice::::len}, val: Value() } + _5 = Len((*_6)); // scope 0 at $DIR/lower_slice_len.rs:+1:16: +1:27 + goto -> bb1; // scope 0 at $DIR/lower_slice_len.rs:+1:16: +1:27 } diff --git a/src/test/mir-opt/nll/named_lifetimes_basic.use_x.nll.0.mir b/src/test/mir-opt/nll/named_lifetimes_basic.use_x.nll.0.mir index 0ab9d712d9f69..fc526d7e79a82 100644 --- a/src/test/mir-opt/nll/named_lifetimes_basic.use_x.nll.0.mir +++ b/src/test/mir-opt/nll/named_lifetimes_basic.use_x.nll.0.mir @@ -1,22 +1,24 @@ // MIR for `use_x` 0 nll | Free Region Mapping -| '_#0r | Global | ['_#2r, '_#1r, '_#0r, '_#4r, '_#3r] -| '_#1r | Local | ['_#1r, '_#4r] -| '_#2r | Local | ['_#2r, '_#1r, '_#4r] -| '_#3r | Local | ['_#4r, '_#3r] -| '_#4r | Local | ['_#4r] +| '_#0r | Global | ['_#2r, '_#1r, '_#0r, '_#5r, '_#3r, '_#4r] +| '_#1r | Local | ['_#1r, '_#5r] +| '_#2r | Local | ['_#2r, '_#1r, '_#5r] +| '_#3r | Local | ['_#5r, '_#3r] +| '_#4r | Local | ['_#5r, '_#4r] +| '_#5r | Local | ['_#5r] | | Inferred Region Values -| '_#0r | U0 | {bb0[0..=1], '_#0r, '_#1r, '_#2r, '_#3r, '_#4r} +| '_#0r | U0 | {bb0[0..=1], '_#0r, '_#1r, '_#2r, '_#3r, '_#4r, '_#5r} | '_#1r | U0 | {bb0[0..=1], '_#1r} | '_#2r | U0 | {bb0[0..=1], '_#2r} | '_#3r | U0 | {bb0[0..=1], '_#3r} | '_#4r | U0 | {bb0[0..=1], '_#4r} -| '_#5r | U0 | {bb0[0..=1], '_#1r} -| '_#6r | U0 | {bb0[0..=1], '_#2r} -| '_#7r | U0 | {bb0[0..=1], '_#1r} -| '_#8r | U0 | {bb0[0..=1], '_#3r} +| '_#5r | U0 | {bb0[0..=1], '_#5r} +| '_#6r | U0 | {bb0[0..=1], '_#1r} +| '_#7r | U0 | {bb0[0..=1], '_#2r} +| '_#8r | U0 | {bb0[0..=1], '_#1r} +| '_#9r | U0 | {bb0[0..=1], '_#3r} | | Inference Constraints | '_#0r live at {bb0[0..=1]} @@ -24,16 +26,17 @@ | '_#2r live at {bb0[0..=1]} | '_#3r live at {bb0[0..=1]} | '_#4r live at {bb0[0..=1]} -| '_#1r: '_#5r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:26: 12:27) ($DIR/named-lifetimes-basic.rs:12:26: 12:27 (#0) -| '_#1r: '_#7r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:54: 12:55) ($DIR/named-lifetimes-basic.rs:12:54: 12:55 (#0) -| '_#2r: '_#6r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:42: 12:43) ($DIR/named-lifetimes-basic.rs:12:42: 12:43 (#0) -| '_#3r: '_#8r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:66: 12:67) ($DIR/named-lifetimes-basic.rs:12:66: 12:67 (#0) -| '_#5r: '_#1r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:26: 12:27) ($DIR/named-lifetimes-basic.rs:12:26: 12:27 (#0) -| '_#6r: '_#2r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:42: 12:43) ($DIR/named-lifetimes-basic.rs:12:42: 12:43 (#0) -| '_#7r: '_#1r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:54: 12:55) ($DIR/named-lifetimes-basic.rs:12:54: 12:55 (#0) -| '_#8r: '_#3r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:66: 12:67) ($DIR/named-lifetimes-basic.rs:12:66: 12:67 (#0) +| '_#5r live at {bb0[0..=1]} +| '_#1r: '_#6r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:26: 12:27) ($DIR/named-lifetimes-basic.rs:12:26: 12:27 (#0) +| '_#1r: '_#8r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:54: 12:55) ($DIR/named-lifetimes-basic.rs:12:54: 12:55 (#0) +| '_#2r: '_#7r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:42: 12:43) ($DIR/named-lifetimes-basic.rs:12:42: 12:43 (#0) +| '_#3r: '_#9r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:66: 12:67) ($DIR/named-lifetimes-basic.rs:12:66: 12:67 (#0) +| '_#6r: '_#1r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:26: 12:27) ($DIR/named-lifetimes-basic.rs:12:26: 12:27 (#0) +| '_#7r: '_#2r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:42: 12:43) ($DIR/named-lifetimes-basic.rs:12:42: 12:43 (#0) +| '_#8r: '_#1r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:54: 12:55) ($DIR/named-lifetimes-basic.rs:12:54: 12:55 (#0) +| '_#9r: '_#3r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:66: 12:67) ($DIR/named-lifetimes-basic.rs:12:66: 12:67 (#0) | -fn use_x(_1: &'_#5r mut i32, _2: &'_#6r u32, _3: &'_#7r u32, _4: &'_#8r u32) -> bool { +fn use_x(_1: &'_#6r mut i32, _2: &'_#7r u32, _3: &'_#8r u32, _4: &'_#9r u32) -> bool { debug w => _1; // in scope 0 at $DIR/named-lifetimes-basic.rs:+0:26: +0:27 debug x => _2; // in scope 0 at $DIR/named-lifetimes-basic.rs:+0:42: +0:43 debug y => _3; // in scope 0 at $DIR/named-lifetimes-basic.rs:+0:54: +0:55 diff --git a/src/test/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.mir b/src/test/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.mir index 963e7cde6567b..d9e6480c52375 100644 --- a/src/test/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.mir +++ b/src/test/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.mir @@ -20,7 +20,7 @@ fn main() -> () { _2 = ::to_string(move _3) -> bb1; // scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:20: +1:34 // mir::Constant // + span: $DIR/no-spurious-drop-after-call.rs:9:23: 9:32 - // + literal: Const { ty: for<'a> fn(&'a str) -> String {::to_string}, val: Value() } + // + literal: Const { ty: fn(&str) -> String {::to_string}, val: Value() } } bb1: { diff --git a/src/test/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.diff b/src/test/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.diff index 188aa55649069..b0264e50be7c4 100644 --- a/src/test/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.diff +++ b/src/test/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.diff @@ -57,7 +57,7 @@ _7 = as Iterator>::next(move _8) -> bb3; // scope 2 at $DIR/remove_storage_markers.rs:+2:14: +2:19 // mir::Constant // + span: $DIR/remove_storage_markers.rs:10:14: 10:19 - // + literal: Const { ty: for<'a> fn(&'a mut std::ops::Range) -> Option< as Iterator>::Item> { as Iterator>::next}, val: Value() } + // + literal: Const { ty: fn(&mut std::ops::Range) -> Option< as Iterator>::Item> { as Iterator>::next}, val: Value() } } bb3: { diff --git a/src/test/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.mir index fe57e32a7acc2..f673669468cab 100644 --- a/src/test/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.mir +++ b/src/test/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.mir @@ -177,10 +177,10 @@ fn array_casts() -> () { Deinit(_34); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL discriminant(_34) = 0; // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL Retag(_34); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _28 = core::panicking::assert_failed::(move _29, move _30, move _32, move _34); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _28 = core::panicking::assert_failed::(move _29, move _30, move _32, move _34); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL - // + literal: Const { ty: for<'a, 'b, 'c> fn(core::panicking::AssertKind, &'a usize, &'b usize, Option>) -> ! {core::panicking::assert_failed::}, val: Value() } + // + literal: Const { ty: fn(core::panicking::AssertKind, &usize, &usize, Option>) -> ! {core::panicking::assert_failed::}, val: Value() } } bb4: { diff --git a/src/test/mir-opt/retag.core.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.mir b/src/test/mir-opt/retag.core.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.mir index cdc413c568f18..3331253169bb6 100644 --- a/src/test/mir-opt/retag.core.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.mir +++ b/src/test/mir-opt/retag.core.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.mir @@ -11,7 +11,7 @@ fn std::ptr::drop_in_place(_1: *mut Test) -> () { _3 = ::drop(move _2) -> bb1; // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 // mir::Constant // + span: $SRC_DIR/core/src/ptr/mod.rs:LL:COL - // + literal: Const { ty: for<'a> fn(&'a mut Test) {::drop}, val: Value() } + // + literal: Const { ty: fn(&mut Test) {::drop}, val: Value() } } bb1: { diff --git a/src/test/mir-opt/retag.main.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/retag.main.SimplifyCfg-elaborate-drops.after.mir index 81225b44ebf9f..c04acb0390995 100644 --- a/src/test/mir-opt/retag.main.SimplifyCfg-elaborate-drops.after.mir +++ b/src/test/mir-opt/retag.main.SimplifyCfg-elaborate-drops.after.mir @@ -75,7 +75,7 @@ fn main() -> () { _3 = Test::foo(move _4, move _6) -> [return: bb1, unwind: bb8]; // scope 1 at $DIR/retag.rs:+3:17: +3:36 // mir::Constant // + span: $DIR/retag.rs:33:25: 33:28 - // + literal: Const { ty: for<'a, 'x> fn(&'a Test, &'x mut i32) -> &'x mut i32 {Test::foo}, val: Value() } + // + literal: Const { ty: fn(&Test, &mut i32) -> &mut i32 {Test::foo}, val: Value() } } bb1: { @@ -154,7 +154,7 @@ fn main() -> () { _19 = Test::foo_shr(move _20, move _22) -> [return: bb4, unwind: bb7]; // scope 7 at $DIR/retag.rs:+18:5: +18:24 // mir::Constant // + span: $DIR/retag.rs:48:13: 48:20 - // + literal: Const { ty: for<'a, 'x> fn(&'a Test, &'x i32) -> &'x i32 {Test::foo_shr}, val: Value() } + // + literal: Const { ty: fn(&Test, &i32) -> &i32 {Test::foo_shr}, val: Value() } } bb4: { diff --git a/src/test/mir-opt/unusual_item_types.core.ptr-drop_in_place.Vec_i32_.AddMovesForPackedDrops.before.mir b/src/test/mir-opt/unusual_item_types.core.ptr-drop_in_place.Vec_i32_.AddMovesForPackedDrops.before.mir index ed9f3bdbdf4d6..8ca0cbb137b4b 100644 --- a/src/test/mir-opt/unusual_item_types.core.ptr-drop_in_place.Vec_i32_.AddMovesForPackedDrops.before.mir +++ b/src/test/mir-opt/unusual_item_types.core.ptr-drop_in_place.Vec_i32_.AddMovesForPackedDrops.before.mir @@ -34,6 +34,6 @@ fn std::ptr::drop_in_place(_1: *mut Vec) -> () { _3 = as Drop>::drop(move _2) -> [return: bb5, unwind: bb4]; // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 // mir::Constant // + span: $SRC_DIR/core/src/ptr/mod.rs:LL:COL - // + literal: Const { ty: for<'a> fn(&'a mut Vec) { as Drop>::drop}, val: Value() } + // + literal: Const { ty: fn(&mut Vec) { as Drop>::drop}, val: Value() } } } diff --git a/src/test/pretty/issue-4264.pp b/src/test/pretty/issue-4264.pp index 18e6d75b1d5ad..1793052ee910e 100644 --- a/src/test/pretty/issue-4264.pp +++ b/src/test/pretty/issue-4264.pp @@ -32,7 +32,7 @@ ({ let res = ((::alloc::fmt::format as - for<'a> fn(Arguments<'a>) -> String {format})(((::core::fmt::Arguments::new_v1 + fn(Arguments<'_>) -> String {format})(((::core::fmt::Arguments::new_v1 as fn(&[&'static str], &[ArgumentV1<'_>]) -> Arguments<'_> {Arguments::<'_>::new_v1})((&([("test" as &str)] as [&str; 1]) as &[&str; 1]), diff --git a/src/test/rustdoc/issue-20727.rs b/src/test/rustdoc/issue-20727.rs index f7acffcb4e56a..c1a98cd57daf8 100644 --- a/src/test/rustdoc/issue-20727.rs +++ b/src/test/rustdoc/issue-20727.rs @@ -19,6 +19,6 @@ pub mod reexport { // @has - '//*[@class="rust trait"]' 'trait Deref {' // @has - '//*[@class="rust trait"]' 'type Target: ?Sized;' // @has - '//*[@class="rust trait"]' \ - // "fn deref(&'a self) -> &'a Self::Target;" + // "fn deref<'a>(&'a self) -> &'a Self::Target;" pub use issue_20727::Deref; } diff --git a/src/test/ui/associated-types/substs-ppaux.normal.stderr b/src/test/ui/associated-types/substs-ppaux.normal.stderr index 3f180cf4f1f89..9201692048cc8 100644 --- a/src/test/ui/associated-types/substs-ppaux.normal.stderr +++ b/src/test/ui/associated-types/substs-ppaux.normal.stderr @@ -17,7 +17,7 @@ LL | let x: () = >::bar::<'static, char>(); | ++ error[E0308]: mismatched types - --> $DIR/substs-ppaux.rs:25:17 + --> $DIR/substs-ppaux.rs:22:17 | LL | fn bar<'a, T>() where T: 'a {} | --------------------------- fn() {>::bar::<'static, char>} defined here @@ -35,7 +35,7 @@ LL | let x: () = >::bar::<'static, char>() | ++ error[E0308]: mismatched types - --> $DIR/substs-ppaux.rs:33:17 + --> $DIR/substs-ppaux.rs:27:17 | LL | fn baz() {} | -------- fn() {>::baz} defined here @@ -53,7 +53,7 @@ LL | let x: () = >::baz(); | ++ error[E0308]: mismatched types - --> $DIR/substs-ppaux.rs:41:17 + --> $DIR/substs-ppaux.rs:32:17 | LL | fn foo<'z>() where &'z (): Sized { | -------------------------------- fn() {foo::<'static>} defined here @@ -71,7 +71,7 @@ LL | let x: () = foo::<'static>(); | ++ error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/substs-ppaux.rs:49:5 + --> $DIR/substs-ppaux.rs:37:5 | LL | >::bar; | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time diff --git a/src/test/ui/associated-types/substs-ppaux.rs b/src/test/ui/associated-types/substs-ppaux.rs index 66cd94d7a1b37..033ef83a3bb75 100644 --- a/src/test/ui/associated-types/substs-ppaux.rs +++ b/src/test/ui/associated-types/substs-ppaux.rs @@ -14,39 +14,26 @@ fn main() {} fn foo<'z>() where &'z (): Sized { let x: () = >::bar::<'static, char>; - //[verbose]~^ ERROR mismatched types - //[verbose]~| expected unit type `()` - //[verbose]~| found fn item `fn() {>::bar::}` - //[normal]~^^^^ ERROR mismatched types - //[normal]~| expected unit type `()` - //[normal]~| found fn item `fn() {>::bar::<'static, char>}` + //~^ ERROR mismatched types + //~| expected unit type `()` + //~| found fn item `fn() {>::bar::<'static, char>}` let x: () = >::bar::<'static, char>; - //[verbose]~^ ERROR mismatched types - //[verbose]~| expected unit type `()` - //[verbose]~| found fn item `fn() {>::bar::}` - //[normal]~^^^^ ERROR mismatched types - //[normal]~| expected unit type `()` - //[normal]~| found fn item `fn() {>::bar::<'static, char>}` + //~^ ERROR mismatched types + //~| expected unit type `()` + //~| found fn item `fn() {>::bar::<'static, char>}` let x: () = >::baz; - //[verbose]~^ ERROR mismatched types - //[verbose]~| expected unit type `()` - //[verbose]~| found fn item `fn() {>::baz}` - //[normal]~^^^^ ERROR mismatched types - //[normal]~| expected unit type `()` - //[normal]~| found fn item `fn() {>::baz}` + //~^ ERROR mismatched types + //~| expected unit type `()` + //~| found fn item `fn() {>::baz}` let x: () = foo::<'static>; - //[verbose]~^ ERROR mismatched types - //[verbose]~| expected unit type `()` - //[verbose]~| found fn item `fn() {foo::}` - //[normal]~^^^^ ERROR mismatched types - //[normal]~| expected unit type `()` - //[normal]~| found fn item `fn() {foo::<'static>}` + //~^ ERROR mismatched types + //~| expected unit type `()` + //~| found fn item `fn() {foo::<'static>}` >::bar; - //[verbose]~^ ERROR the size for values of type - //[normal]~^^ ERROR the size for values of type + //~^ ERROR the size for values of type } diff --git a/src/test/ui/associated-types/substs-ppaux.verbose.stderr b/src/test/ui/associated-types/substs-ppaux.verbose.stderr index 16dd29de2c543..88fc6a896cf73 100644 --- a/src/test/ui/associated-types/substs-ppaux.verbose.stderr +++ b/src/test/ui/associated-types/substs-ppaux.verbose.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/substs-ppaux.rs:16:17 | LL | fn bar<'a, T>() where T: 'a {} - | --------------------------- fn() {>::bar::} defined here + | --------------------------- fn() {>::bar::<'static, char>} defined here ... LL | let x: () = >::bar::<'static, char>; | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item @@ -10,17 +10,17 @@ LL | let x: () = >::bar::<'static, char>; | expected due to this | = note: expected unit type `()` - found fn item `fn() {>::bar::}` + found fn item `fn() {>::bar::<'static, char>}` help: use parentheses to call this associated function | LL | let x: () = >::bar::<'static, char>(); | ++ error[E0308]: mismatched types - --> $DIR/substs-ppaux.rs:25:17 + --> $DIR/substs-ppaux.rs:22:17 | LL | fn bar<'a, T>() where T: 'a {} - | --------------------------- fn() {>::bar::} defined here + | --------------------------- fn() {>::bar::<'static, char>} defined here ... LL | let x: () = >::bar::<'static, char>; | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item @@ -28,17 +28,17 @@ LL | let x: () = >::bar::<'static, char>; | expected due to this | = note: expected unit type `()` - found fn item `fn() {>::bar::}` + found fn item `fn() {>::bar::<'static, char>}` help: use parentheses to call this associated function | LL | let x: () = >::bar::<'static, char>(); | ++ error[E0308]: mismatched types - --> $DIR/substs-ppaux.rs:33:17 + --> $DIR/substs-ppaux.rs:27:17 | LL | fn baz() {} - | -------- fn() {>::baz} defined here + | -------- fn() {>::baz} defined here ... LL | let x: () = >::baz; | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item @@ -46,17 +46,17 @@ LL | let x: () = >::baz; | expected due to this | = note: expected unit type `()` - found fn item `fn() {>::baz}` + found fn item `fn() {>::baz}` help: use parentheses to call this associated function | LL | let x: () = >::baz(); | ++ error[E0308]: mismatched types - --> $DIR/substs-ppaux.rs:41:17 + --> $DIR/substs-ppaux.rs:32:17 | LL | fn foo<'z>() where &'z (): Sized { - | -------------------------------- fn() {foo::} defined here + | -------------------------------- fn() {foo::<'static>} defined here ... LL | let x: () = foo::<'static>; | -- ^^^^^^^^^^^^^^ expected `()`, found fn item @@ -64,14 +64,14 @@ LL | let x: () = foo::<'static>; | expected due to this | = note: expected unit type `()` - found fn item `fn() {foo::}` + found fn item `fn() {foo::<'static>}` help: use parentheses to call this function | LL | let x: () = foo::<'static>(); | ++ error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/substs-ppaux.rs:49:5 + --> $DIR/substs-ppaux.rs:37:5 | LL | >::bar; | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time diff --git a/src/test/ui/async-await/issue-74072-lifetime-name-annotations.stderr b/src/test/ui/async-await/issue-74072-lifetime-name-annotations.stderr index b96cab9f0f51a..80504613eb4e3 100644 --- a/src/test/ui/async-await/issue-74072-lifetime-name-annotations.stderr +++ b/src/test/ui/async-await/issue-74072-lifetime-name-annotations.stderr @@ -1,14 +1,10 @@ error[E0506]: cannot assign to `*x` because it is borrowed --> $DIR/issue-74072-lifetime-name-annotations.rs:9:5 | -LL | pub async fn async_fn(x: &mut i32) -> &i32 { - | - let's call the lifetime of this reference `'1` LL | let y = &*x; | --- borrow of `*x` occurs here LL | *x += 1; | ^^^^^^^ assignment to borrowed `*x` occurs here -LL | y - | - returning this value requires that `*x` is borrowed for `'1` error[E0506]: cannot assign to `*x` because it is borrowed --> $DIR/issue-74072-lifetime-name-annotations.rs:16:9 diff --git a/src/test/ui/async-await/issue-75785-confusing-named-region.stderr b/src/test/ui/async-await/issue-75785-confusing-named-region.stderr index 3b731d9c60a6a..06660b7c182b3 100644 --- a/src/test/ui/async-await/issue-75785-confusing-named-region.stderr +++ b/src/test/ui/async-await/issue-75785-confusing-named-region.stderr @@ -1,14 +1,10 @@ error[E0506]: cannot assign to `*x` because it is borrowed --> $DIR/issue-75785-confusing-named-region.rs:9:5 | -LL | pub async fn async_fn(x: &mut i32) -> (&i32, &i32) { - | - let's call the lifetime of this reference `'1` LL | let y = &*x; | --- borrow of `*x` occurs here LL | *x += 1; | ^^^^^^^ assignment to borrowed `*x` occurs here -LL | (&32, y) - | -------- returning this value requires that `*x` is borrowed for `'1` error: aborting due to previous error diff --git a/src/test/ui/binop/issue-77910-1.rs b/src/test/ui/binop/issue-77910-1.rs index 95bbd6a60ec86..e2080a9703d6e 100644 --- a/src/test/ui/binop/issue-77910-1.rs +++ b/src/test/ui/binop/issue-77910-1.rs @@ -7,5 +7,5 @@ fn main() { // we shouldn't ice with the bound var here. assert_eq!(foo, y); //~^ ERROR binary operation `==` cannot be applied to type - //~| ERROR `for<'a> fn(&'a i32) -> &'a i32 {foo}` doesn't implement `Debug` + //~| ERROR `fn(&i32) -> &i32 {foo}` doesn't implement `Debug` } diff --git a/src/test/ui/binop/issue-77910-1.stderr b/src/test/ui/binop/issue-77910-1.stderr index 263a35d982911..d0bd001eaa6d9 100644 --- a/src/test/ui/binop/issue-77910-1.stderr +++ b/src/test/ui/binop/issue-77910-1.stderr @@ -1,24 +1,24 @@ -error[E0369]: binary operation `==` cannot be applied to type `for<'a> fn(&'a i32) -> &'a i32 {foo}` +error[E0369]: binary operation `==` cannot be applied to type `fn(&i32) -> &i32 {foo}` --> $DIR/issue-77910-1.rs:8:5 | LL | assert_eq!(foo, y); | ^^^^^^^^^^^^^^^^^^ | | - | for<'a> fn(&'a i32) -> &'a i32 {foo} + | fn(&i32) -> &i32 {foo} | _ | = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: `for<'a> fn(&'a i32) -> &'a i32 {foo}` doesn't implement `Debug` +error[E0277]: `fn(&i32) -> &i32 {foo}` doesn't implement `Debug` --> $DIR/issue-77910-1.rs:8:5 | LL | fn foo(s: &i32) -> &i32 { | --- consider calling this function ... LL | assert_eq!(foo, y); - | ^^^^^^^^^^^^^^^^^^ `for<'a> fn(&'a i32) -> &'a i32 {foo}` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | ^^^^^^^^^^^^^^^^^^ `fn(&i32) -> &i32 {foo}` cannot be formatted using `{:?}` because it doesn't implement `Debug` | - = help: the trait `Debug` is not implemented for fn item `for<'a> fn(&'a i32) -> &'a i32 {foo}` + = help: the trait `Debug` is not implemented for fn item `fn(&i32) -> &i32 {foo}` = help: use parentheses to call this function: `foo(/* &i32 */)` = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/src/test/ui/binop/issue-77910-2.stderr b/src/test/ui/binop/issue-77910-2.stderr index b3856b6ae1681..b3c5e7e546b26 100644 --- a/src/test/ui/binop/issue-77910-2.stderr +++ b/src/test/ui/binop/issue-77910-2.stderr @@ -1,10 +1,10 @@ -error[E0369]: binary operation `==` cannot be applied to type `for<'a> fn(&'a i32) -> &'a i32 {foo}` +error[E0369]: binary operation `==` cannot be applied to type `fn(&i32) -> &i32 {foo}` --> $DIR/issue-77910-2.rs:7:12 | LL | if foo == y {} | --- ^^ - _ | | - | for<'a> fn(&'a i32) -> &'a i32 {foo} + | fn(&i32) -> &i32 {foo} | help: use parentheses to call this function | diff --git a/src/test/ui/borrowck/issue-81899.stderr b/src/test/ui/borrowck/issue-81899.stderr index 12e80b9df8289..ae76c280883d0 100644 --- a/src/test/ui/borrowck/issue-81899.stderr +++ b/src/test/ui/borrowck/issue-81899.stderr @@ -8,7 +8,7 @@ LL | panic!() | ^^^^^^^^ | | | the evaluated program panicked at 'explicit panic', $DIR/issue-81899.rs:11:5 - | inside `f::<[closure@$DIR/issue-81899.rs:4:31: 4:34]>` at $SRC_DIR/std/src/panic.rs:LL:COL + | inside `f::<[closure@$DIR/issue-81899.rs:4:31: 4:34], '_>` at $SRC_DIR/std/src/panic.rs:LL:COL | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/src/test/ui/borrowck/issue-88434-minimal-example.stderr b/src/test/ui/borrowck/issue-88434-minimal-example.stderr index dc87c4c2b077b..24773fa8b1d28 100644 --- a/src/test/ui/borrowck/issue-88434-minimal-example.stderr +++ b/src/test/ui/borrowck/issue-88434-minimal-example.stderr @@ -8,7 +8,7 @@ LL | panic!() | ^^^^^^^^ | | | the evaluated program panicked at 'explicit panic', $DIR/issue-88434-minimal-example.rs:10:5 - | inside `f::<[closure@$DIR/issue-88434-minimal-example.rs:3:25: 3:28]>` at $SRC_DIR/std/src/panic.rs:LL:COL + | inside `f::<[closure@$DIR/issue-88434-minimal-example.rs:3:25: 3:28], '_>` at $SRC_DIR/std/src/panic.rs:LL:COL | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/src/test/ui/borrowck/issue-88434-removal-index-should-be-less.stderr b/src/test/ui/borrowck/issue-88434-removal-index-should-be-less.stderr index 4b4a25d7be121..9d5fad1fb4ce9 100644 --- a/src/test/ui/borrowck/issue-88434-removal-index-should-be-less.stderr +++ b/src/test/ui/borrowck/issue-88434-removal-index-should-be-less.stderr @@ -8,7 +8,7 @@ LL | panic!() | ^^^^^^^^ | | | the evaluated program panicked at 'explicit panic', $DIR/issue-88434-removal-index-should-be-less.rs:10:5 - | inside `f::<[closure@$DIR/issue-88434-removal-index-should-be-less.rs:3:31: 3:34]>` at $SRC_DIR/std/src/panic.rs:LL:COL + | inside `f::<[closure@$DIR/issue-88434-removal-index-should-be-less.rs:3:31: 3:34], '_>` at $SRC_DIR/std/src/panic.rs:LL:COL | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr b/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr index e6ddc60689779..2f4f498e44fbf 100644 --- a/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr +++ b/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr @@ -11,13 +11,13 @@ LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {}); | requires that `'1` must outlive `'x` error: lifetime may not live long enough - --> $DIR/expect-fn-supply-fn.rs:16:49 + --> $DIR/expect-fn-supply-fn.rs:16:48 | LL | fn expect_free_supply_free_from_fn<'x>(x: &'x u32) { | -- lifetime `'x` defined here ... LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {}); - | ^ requires that `'x` must outlive `'static` + | ^^^^^^^^^^^^^^^^^^^^^^ requires that `'x` must outlive `'static` error[E0308]: mismatched types --> $DIR/expect-fn-supply-fn.rs:32:49 diff --git a/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.stderr b/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.stderr index 9aab51c986cac..8228dfaf8bbdf 100644 --- a/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.stderr +++ b/src/test/ui/closures/closure-expected-type/expect-region-supply-region-2.stderr @@ -10,13 +10,20 @@ LL | closure_expecting_bound(|x: &'x u32| { | requires that `'1` must outlive `'x` error: lifetime may not live long enough - --> $DIR/expect-region-supply-region-2.rs:14:30 + --> $DIR/expect-region-supply-region-2.rs:14:29 | -LL | fn expect_bound_supply_named<'x>() { - | -- lifetime `'x` defined here +LL | fn expect_bound_supply_named<'x>() { + | -- lifetime `'x` defined here ... -LL | closure_expecting_bound(|x: &'x u32| { - | ^ requires that `'x` must outlive `'static` +LL | closure_expecting_bound(|x: &'x u32| { + | _____________________________^ +LL | | +LL | | +LL | | +... | +LL | | f = Some(x); +LL | | }); + | |_____^ requires that `'x` must outlive `'static` error: aborting due to 2 previous errors diff --git a/src/test/ui/const-generics/argument_order.rs b/src/test/ui/const-generics/argument_order.rs index 196d9b8a1e210..7a5647d37a2e2 100644 --- a/src/test/ui/const-generics/argument_order.rs +++ b/src/test/ui/const-generics/argument_order.rs @@ -11,5 +11,4 @@ struct AlsoBad { fn main() { let _: AlsoBad<7, 'static, u32, 'static, 17, u16>; - //~^ ERROR lifetime provided when a type was expected } diff --git a/src/test/ui/const-generics/argument_order.stderr b/src/test/ui/const-generics/argument_order.stderr index 99122c6f5e362..01c3cb9455092 100644 --- a/src/test/ui/const-generics/argument_order.stderr +++ b/src/test/ui/const-generics/argument_order.stderr @@ -4,15 +4,5 @@ error: lifetime parameters must be declared prior to type and const parameters LL | struct AlsoBad { | -----------------^^-----^^-------------------- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, const N: usize, T, const M: usize, U>` -error[E0747]: lifetime provided when a type was expected - --> $DIR/argument_order.rs:13:23 - | -LL | let _: AlsoBad<7, 'static, u32, 'static, 17, u16>; - | ^^^^^^^ - | - = note: lifetime arguments must be provided before type arguments - = help: reorder the arguments: lifetimes, then type and consts: `<'a, 'b, N, T, M, U>` - -error: aborting due to 2 previous errors +error: aborting due to previous error -For more information about this error, try `rustc --explain E0747`. diff --git a/src/test/ui/const-generics/const-arg-in-const-arg.full.stderr b/src/test/ui/const-generics/const-arg-in-const-arg.full.stderr index 8672e79b3e8c8..9a12ec91580ba 100644 --- a/src/test/ui/const-generics/const-arg-in-const-arg.full.stderr +++ b/src/test/ui/const-generics/const-arg-in-const-arg.full.stderr @@ -9,6 +9,7 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ + = help: remove the explicit lifetime argument error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:21:23 @@ -21,6 +22,7 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ + = help: remove the explicit lifetime argument error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:41:24 @@ -33,6 +35,7 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ + = help: remove the explicit lifetime argument error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:44:24 @@ -45,6 +48,7 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ + = help: remove the explicit lifetime argument error: unconstrained generic constant --> $DIR/const-arg-in-const-arg.rs:13:12 @@ -105,6 +109,7 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ + = help: remove the explicit lifetime argument error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:33:23 @@ -117,6 +122,7 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ + = help: remove the explicit lifetime argument error: unconstrained generic constant --> $DIR/const-arg-in-const-arg.rs:47:19 @@ -145,6 +151,7 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ + = help: remove the explicit lifetime argument error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:55:27 @@ -157,6 +164,7 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ + = help: remove the explicit lifetime argument error: aborting due to 16 previous errors diff --git a/src/test/ui/const-generics/const-arg-in-const-arg.min.stderr b/src/test/ui/const-generics/const-arg-in-const-arg.min.stderr index f1353aa99437d..fc719e2e0cc28 100644 --- a/src/test/ui/const-generics/const-arg-in-const-arg.min.stderr +++ b/src/test/ui/const-generics/const-arg-in-const-arg.min.stderr @@ -227,6 +227,7 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ + = help: remove the explicit lifetime argument error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:21:23 @@ -239,6 +240,7 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ + = help: remove the explicit lifetime argument error[E0747]: unresolved item provided when a constant was expected --> $DIR/const-arg-in-const-arg.rs:38:24 @@ -262,6 +264,7 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ + = help: remove the explicit lifetime argument error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:44:24 @@ -274,6 +277,7 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ + = help: remove the explicit lifetime argument error: constant expression depends on a generic parameter --> $DIR/const-arg-in-const-arg.rs:25:17 @@ -305,6 +309,7 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ + = help: remove the explicit lifetime argument error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:33:23 @@ -317,6 +322,7 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ + = help: remove the explicit lifetime argument error[E0747]: unresolved item provided when a constant was expected --> $DIR/const-arg-in-const-arg.rs:49:27 @@ -340,6 +346,7 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ + = help: remove the explicit lifetime argument error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:55:27 @@ -352,6 +359,7 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ + = help: remove the explicit lifetime argument error: aborting due to 36 previous errors diff --git a/src/test/ui/const-generics/generic_const_exprs/object-safety-ok-infer-err.stderr b/src/test/ui/const-generics/generic_const_exprs/object-safety-ok-infer-err.stderr index 59e9fee1eaf41..21ca8195140e7 100644 --- a/src/test/ui/const-generics/generic_const_exprs/object-safety-ok-infer-err.stderr +++ b/src/test/ui/const-generics/generic_const_exprs/object-safety-ok-infer-err.stderr @@ -11,8 +11,8 @@ LL | fn use_dyn(v: &dyn Foo) where [u8; N + 1]: Sized { | ^^^^^ required by this bound in `use_dyn` help: consider specifying the generic argument | -LL | use_dyn::(&()); - | +++++ +LL | use_dyn::<'_>(&()); + | ++++++ error: aborting due to previous error diff --git a/src/test/ui/const-generics/infer/issue-77092.stderr b/src/test/ui/const-generics/infer/issue-77092.stderr index 1682b26ac8777..2a370db6d801e 100644 --- a/src/test/ui/const-generics/infer/issue-77092.stderr +++ b/src/test/ui/const-generics/infer/issue-77092.stderr @@ -6,8 +6,8 @@ LL | println!("{:?}", take_array_from_mut(&mut arr, i)); | help: consider specifying the generic arguments | -LL | println!("{:?}", take_array_from_mut::(&mut arr, i)); - | ++++++++++ +LL | println!("{:?}", take_array_from_mut::(&mut arr, i)); + | +++++++++ error: aborting due to previous error diff --git a/src/test/ui/const-generics/issues/issue-83466.rs b/src/test/ui/const-generics/issues/issue-83466.rs index 73c9301011d58..79a109da4b46a 100644 --- a/src/test/ui/const-generics/issues/issue-83466.rs +++ b/src/test/ui/const-generics/issues/issue-83466.rs @@ -9,9 +9,8 @@ impl S { } fn dont_crash<'a, U>() { S.func::<'a, 10_u32>() - //~^ WARNING cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - //~^^ WARNING this was previously accepted by - //~^^^ ERROR constant provided when a type was expected [E0747] + //~^ ERROR cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + //~| ERROR constant provided when a type was expected [E0747] } fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-83466.stderr b/src/test/ui/const-generics/issues/issue-83466.stderr index bcfd706398966..f0df1c7eb6da6 100644 --- a/src/test/ui/const-generics/issues/issue-83466.stderr +++ b/src/test/ui/const-generics/issues/issue-83466.stderr @@ -1,15 +1,15 @@ -warning: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/issue-83466.rs:11:14 | -LL | fn func<'a, U>(self) -> U { - | -- the late bound lifetime parameter is introduced here -... LL | S.func::<'a, 10_u32>() | ^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42868 - = note: `#[warn(late_bound_lifetime_arguments)]` on by default +note: the late bound lifetime parameter is introduced here + --> $DIR/issue-83466.rs:6:13 + | +LL | fn func<'a, U>(self) -> U { + | ^^ + = help: remove the explicit lifetime argument error[E0747]: constant provided when a type was expected --> $DIR/issue-83466.rs:11:18 @@ -17,6 +17,6 @@ error[E0747]: constant provided when a type was expected LL | S.func::<'a, 10_u32>() | ^^^^^^ -error: aborting due to previous error; 1 warning emitted +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0747`. diff --git a/src/test/ui/error-codes/E0311.stderr b/src/test/ui/error-codes/E0311.stderr index 9873b5ae6ff13..19cba7dfcfa4f 100644 --- a/src/test/ui/error-codes/E0311.stderr +++ b/src/test/ui/error-codes/E0311.stderr @@ -4,11 +4,11 @@ error[E0311]: the parameter type `T` may not live long enough LL | with_restriction::(x) | ^^^^^^^^^^^^^^^^^^^^^ | -note: the parameter type `T` must be valid for the anonymous lifetime defined here... +note: the parameter type `T` must be valid for the anonymous lifetime as defined here... --> $DIR/E0311.rs:1:25 | LL | fn no_restriction(x: &()) -> &() { - | ^^^ + | ^ note: ...so that the type `T` will meet its required lifetime bounds --> $DIR/E0311.rs:2:5 | diff --git a/src/test/ui/generic-associated-types/bugs/issue-88382.stderr b/src/test/ui/generic-associated-types/bugs/issue-88382.stderr index a9a70bb7130cb..20757895416a9 100644 --- a/src/test/ui/generic-associated-types/bugs/issue-88382.stderr +++ b/src/test/ui/generic-associated-types/bugs/issue-88382.stderr @@ -10,7 +10,7 @@ LL | fn test<'a, I: Iterable>(_: &mut I::Iterator<'a>) {} | ------------------------------------------------- found signature defined here | = note: expected function signature `for<'a> fn(&'a mut std::iter::Empty) -> _` - found function signature `for<'a, 'b> fn(&'b mut <_ as Iterable>::Iterator<'a>) -> _` + found function signature `for<'b, 'a> fn(&'b mut <_ as Iterable>::Iterator<'a>) -> _` note: required by a bound in `do_something` --> $DIR/issue-88382.rs:20:48 | diff --git a/src/test/ui/higher-rank-trait-bounds/issue-30786.stderr b/src/test/ui/higher-rank-trait-bounds/issue-30786.stderr index c1e235441d65d..c5a2d3caec46c 100644 --- a/src/test/ui/higher-rank-trait-bounds/issue-30786.stderr +++ b/src/test/ui/higher-rank-trait-bounds/issue-30786.stderr @@ -19,7 +19,7 @@ note: the following trait bounds were not satisfied: LL | impl StreamExt for T where for<'a> &'a mut T: Stream {} | --------- - ^^^^^^ unsatisfied trait bound introduced here -error[E0599]: the method `countx` exists for struct `Filter fn(&'a u64) -> &'a u64 {identity::}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>`, but its trait bounds were not satisfied +error[E0599]: the method `countx` exists for struct `Filter &u64 {identity::}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>`, but its trait bounds were not satisfied --> $DIR/issue-30786.rs:130:24 | LL | pub struct Filter { @@ -29,12 +29,12 @@ LL | pub struct Filter { | doesn't satisfy `_: StreamExt` ... LL | let count = filter.countx(); - | ^^^^^^ method cannot be called on `Filter fn(&'a u64) -> &'a u64 {identity::}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>` due to unsatisfied trait bounds + | ^^^^^^ method cannot be called on `Filter &u64 {identity::}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>` due to unsatisfied trait bounds | note: the following trait bounds were not satisfied: - `&'a mut &Filter fn(&'a u64) -> &'a u64 {identity::}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>: Stream` - `&'a mut &mut Filter fn(&'a u64) -> &'a u64 {identity::}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>: Stream` - `&'a mut Filter fn(&'a u64) -> &'a u64 {identity::}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>: Stream` + `&'a mut &Filter &u64 {identity::}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>: Stream` + `&'a mut &mut Filter &u64 {identity::}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>: Stream` + `&'a mut Filter &u64 {identity::}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>: Stream` --> $DIR/issue-30786.rs:96:50 | LL | impl StreamExt for T where for<'a> &'a mut T: Stream {} diff --git a/src/test/ui/hygiene/impl_items.rs b/src/test/ui/hygiene/impl_items.rs index ddb25c06b1b17..b5da606794bb6 100644 --- a/src/test/ui/hygiene/impl_items.rs +++ b/src/test/ui/hygiene/impl_items.rs @@ -9,7 +9,7 @@ mod foo { } pub macro m() { - let _: () = S.f(); //~ ERROR type `for<'a> fn(&'a foo::S) {foo::S::f}` is private + let _: () = S.f(); //~ ERROR type `fn(&foo::S) {foo::S::f}` is private } } diff --git a/src/test/ui/hygiene/impl_items.stderr b/src/test/ui/hygiene/impl_items.stderr index 46a2500386e0f..94bcccb2cc6f2 100644 --- a/src/test/ui/hygiene/impl_items.stderr +++ b/src/test/ui/hygiene/impl_items.stderr @@ -1,4 +1,4 @@ -error: type `for<'a> fn(&'a foo::S) {foo::S::f}` is private +error: type `fn(&foo::S) {foo::S::f}` is private --> $DIR/impl_items.rs:12:23 | LL | let _: () = S.f(); diff --git a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr index 9c81791fbcba5..fa655a2698503 100644 --- a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr +++ b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr @@ -2,9 +2,9 @@ error[E0700]: hidden type for `impl Copy` captures lifetime that does not appear --> $DIR/must_outlive_least_region_or_bound.rs:3:35 | LL | fn elided(x: &i32) -> impl Copy { x } - | ---- ^ + | - ^ | | - | hidden type `&i32` captures the anonymous lifetime defined here + | hidden type `&i32` captures the anonymous lifetime as defined here | help: to declare that `impl Copy` captures `'_`, you can add an explicit `'_` lifetime bound | diff --git a/src/test/ui/impl-trait/static-return-lifetime-infered.stderr b/src/test/ui/impl-trait/static-return-lifetime-infered.stderr index b365bd8845480..09d9c48d883f7 100644 --- a/src/test/ui/impl-trait/static-return-lifetime-infered.stderr +++ b/src/test/ui/impl-trait/static-return-lifetime-infered.stderr @@ -2,7 +2,7 @@ error[E0700]: hidden type for `impl Iterator` captures lifetime that --> $DIR/static-return-lifetime-infered.rs:7:9 | LL | fn iter_values_anon(&self) -> impl Iterator { - | ----- hidden type `Map, [closure@$DIR/static-return-lifetime-infered.rs:7:27: 7:30]>` captures the anonymous lifetime defined here + | - hidden type `Map, [closure@$DIR/static-return-lifetime-infered.rs:7:27: 7:30]>` captures the anonymous lifetime as defined here LL | self.x.iter().map(|a| a.0) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | @@ -15,7 +15,7 @@ error[E0700]: hidden type for `impl Iterator` captures lifetime that --> $DIR/static-return-lifetime-infered.rs:7:9 | LL | fn iter_values_anon(&self) -> impl Iterator { - | ----- hidden type `Map, [closure@$DIR/static-return-lifetime-infered.rs:7:27: 7:30]>` captures the anonymous lifetime defined here + | - hidden type `Map, [closure@$DIR/static-return-lifetime-infered.rs:7:27: 7:30]>` captures the anonymous lifetime as defined here LL | self.x.iter().map(|a| a.0) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/src/test/ui/inference/issue-71732.stderr b/src/test/ui/inference/issue-71732.stderr index 79bee33280d2e..02e6473faef97 100644 --- a/src/test/ui/inference/issue-71732.stderr +++ b/src/test/ui/inference/issue-71732.stderr @@ -17,8 +17,8 @@ LL | K: Borrow, | ^^^^^^^^^ required by this bound in `HashMap::::get` help: consider specifying the generic argument | -LL | .get::(&"key".into()) - | +++++ +LL | .get::<'_>(&"key".into()) + | ++++++ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-17740.stderr b/src/test/ui/issues/issue-17740.stderr index d177380415591..d0df8dd744c05 100644 --- a/src/test/ui/issues/issue-17740.stderr +++ b/src/test/ui/issues/issue-17740.stderr @@ -6,11 +6,11 @@ LL | fn bar(self: &mut Foo) { | = note: expected struct `Foo<'a>` found struct `Foo<'_>` -note: the anonymous lifetime defined here... - --> $DIR/issue-17740.rs:6:23 +note: the anonymous lifetime as defined here... + --> $DIR/issue-17740.rs:6:18 | LL | fn bar(self: &mut Foo) { - | ^^^ + | ^ note: ...does not necessarily outlive the lifetime `'a` as defined here --> $DIR/issue-17740.rs:5:7 | @@ -30,11 +30,11 @@ note: the lifetime `'a` as defined here... | LL | impl <'a> Foo<'a>{ | ^^ -note: ...does not necessarily outlive the anonymous lifetime defined here - --> $DIR/issue-17740.rs:6:23 +note: ...does not necessarily outlive the anonymous lifetime as defined here + --> $DIR/issue-17740.rs:6:18 | LL | fn bar(self: &mut Foo) { - | ^^^ + | ^ error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-17905-2.stderr b/src/test/ui/issues/issue-17905-2.stderr index 88b5fbec6cf03..d19c83145688b 100644 --- a/src/test/ui/issues/issue-17905-2.stderr +++ b/src/test/ui/issues/issue-17905-2.stderr @@ -6,11 +6,11 @@ LL | fn say(self: &Pair<&str, isize>) { | = note: expected struct `Pair<&str, _>` found struct `Pair<&str, _>` -note: the anonymous lifetime defined here... - --> $DIR/issue-17905-2.rs:8:24 +note: the anonymous lifetime as defined here... + --> $DIR/issue-17905-2.rs:8:18 | LL | fn say(self: &Pair<&str, isize>) { - | ^^^^ + | ^ note: ...does not necessarily outlive the anonymous lifetime as defined here --> $DIR/issue-17905-2.rs:5:5 | @@ -30,11 +30,11 @@ note: the anonymous lifetime as defined here... | LL | &str, | ^ -note: ...does not necessarily outlive the anonymous lifetime defined here - --> $DIR/issue-17905-2.rs:8:24 +note: ...does not necessarily outlive the anonymous lifetime as defined here + --> $DIR/issue-17905-2.rs:8:18 | LL | fn say(self: &Pair<&str, isize>) { - | ^^^^ + | ^ error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-20831-debruijn.stderr b/src/test/ui/issues/issue-20831-debruijn.stderr index ef62dece83640..3ddacbb24b6a5 100644 --- a/src/test/ui/issues/issue-20831-debruijn.stderr +++ b/src/test/ui/issues/issue-20831-debruijn.stderr @@ -10,16 +10,16 @@ LL | | self.sub = t; LL | | } | |_____^ | -note: first, the lifetime cannot outlive the anonymous lifetime defined here... - --> $DIR/issue-20831-debruijn.rs:28:58 - | -LL | fn subscribe(&mut self, t : Box::Output> + 'a>) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...but the lifetime must also be valid for the lifetime `'a` as defined here... +note: first, the lifetime cannot outlive the lifetime `'a` as defined here... --> $DIR/issue-20831-debruijn.rs:26:6 | LL | impl<'a> Publisher<'a> for MyStruct<'a> { | ^^ +note: ...but the lifetime must also be valid for the anonymous lifetime as defined here... + --> $DIR/issue-20831-debruijn.rs:28:18 + | +LL | fn subscribe(&mut self, t : Box::Output> + 'a>) { + | ^ note: ...so that the types are compatible --> $DIR/issue-20831-debruijn.rs:28:5 | diff --git a/src/test/ui/issues/issue-23041.stderr b/src/test/ui/issues/issue-23041.stderr index 6592b76a39f7a..cb350251c991b 100644 --- a/src/test/ui/issues/issue-23041.stderr +++ b/src/test/ui/issues/issue-23041.stderr @@ -6,8 +6,8 @@ LL | b.downcast_ref::_>(); | help: consider specifying the generic argument | -LL | b.downcast_ref:: _>(); - | ~~~~~~~~~~~~~~ +LL | b.downcast_ref::<'_>(); + | ~~~~~~ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-24322.stderr b/src/test/ui/issues/issue-24322.stderr index 1e4c8ac7c356c..4b83e8a2af75c 100644 --- a/src/test/ui/issues/issue-24322.stderr +++ b/src/test/ui/issues/issue-24322.stderr @@ -7,7 +7,7 @@ LL | let x: &fn(&B) -> u32 = &B::func; | expected due to this | = note: expected reference `&for<'a> fn(&'a B) -> u32` - found reference `&for<'a> fn(&'a B) -> u32 {B::func}` + found reference `&fn(&B) -> u32 {B::func}` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-27942.stderr b/src/test/ui/issues/issue-27942.stderr index 7ea9345a668a8..5333d6b8a66ff 100644 --- a/src/test/ui/issues/issue-27942.stderr +++ b/src/test/ui/issues/issue-27942.stderr @@ -6,11 +6,11 @@ LL | fn select(&self) -> BufferViewHandle; | = note: expected trait `Resources<'_>` found trait `Resources<'a>` -note: the anonymous lifetime defined here... +note: the anonymous lifetime as defined here... --> $DIR/issue-27942.rs:5:15 | LL | fn select(&self) -> BufferViewHandle; - | ^^^^^ + | ^ note: ...does not necessarily outlive the lifetime `'a` as defined here --> $DIR/issue-27942.rs:3:18 | @@ -30,11 +30,11 @@ note: the lifetime `'a` as defined here... | LL | pub trait Buffer<'a, R: Resources<'a>> { | ^^ -note: ...does not necessarily outlive the anonymous lifetime defined here +note: ...does not necessarily outlive the anonymous lifetime as defined here --> $DIR/issue-27942.rs:5:15 | LL | fn select(&self) -> BufferViewHandle; - | ^^^^^ + | ^ error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-47511.rs b/src/test/ui/issues/issue-47511.rs index eb4860e75d758..6cc1c7f75a3ac 100644 --- a/src/test/ui/issues/issue-47511.rs +++ b/src/test/ui/issues/issue-47511.rs @@ -1,5 +1,4 @@ -// check-fail -// known-bug: #47511 +// check-pass // Regression test for #47511: anonymous lifetimes can appear // unconstrained in a return type, but only if they appear just once diff --git a/src/test/ui/issues/issue-47511.stderr b/src/test/ui/issues/issue-47511.stderr deleted file mode 100644 index 9998ee0e8d0c6..0000000000000 --- a/src/test/ui/issues/issue-47511.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0581]: return type references an anonymous lifetime, which is not constrained by the fn input types - --> $DIR/issue-47511.rs:8:15 - | -LL | fn f(_: X) -> X { - | ^ - | - = note: lifetimes appearing in an associated or opaque type are not considered constrained - = note: consider introducing a named lifetime parameter - -error[E0581]: return type references lifetime `'a`, which is not constrained by the fn input types - --> $DIR/issue-47511.rs:12:23 - | -LL | fn g<'a>(_: X<'a>) -> X<'a> { - | ^^^^^ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0581`. diff --git a/src/test/ui/issues/issue-54302-cases.stderr b/src/test/ui/issues/issue-54302-cases.stderr index 6e8b69c4beebb..baa75f28d37f3 100644 --- a/src/test/ui/issues/issue-54302-cases.stderr +++ b/src/test/ui/issues/issue-54302-cases.stderr @@ -2,7 +2,7 @@ error: implementation of `Foo` is not general enough --> $DIR/issue-54302-cases.rs:63:5 | LL | >::ref_foo(a) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough | = note: `Foo<'static, u32>` would have to be implemented for the type `&'0 u32`, for any lifetime `'0`... = note: ...but `Foo<'_, u32>` is actually implemented for the type `&'1 u32`, for some specific lifetime `'1` @@ -11,7 +11,7 @@ error: implementation of `Foo` is not general enough --> $DIR/issue-54302-cases.rs:69:5 | LL | >::ref_foo(a) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough | = note: `Foo<'static, i32>` would have to be implemented for the type `&'0 i32`, for any lifetime `'0`... = note: ...but `Foo<'_, i32>` is actually implemented for the type `&'1 i32`, for some specific lifetime `'1` @@ -20,7 +20,7 @@ error: implementation of `Foo` is not general enough --> $DIR/issue-54302-cases.rs:75:5 | LL | >::ref_foo(a) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough | = note: `Foo<'static, u64>` would have to be implemented for the type `&'0 u64`, for any lifetime `'0`... = note: ...but `Foo<'_, u64>` is actually implemented for the type `&'1 u64`, for some specific lifetime `'1` @@ -29,7 +29,7 @@ error: implementation of `Foo` is not general enough --> $DIR/issue-54302-cases.rs:81:5 | LL | >::ref_foo(a) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough | = note: `Foo<'static, i64>` would have to be implemented for the type `&'0 i64`, for any lifetime `'0`... = note: ...but `Foo<'_, i64>` is actually implemented for the type `&'1 i64`, for some specific lifetime `'1` diff --git a/src/test/ui/issues/issue-60622.rs b/src/test/ui/issues/issue-60622.rs index 8e230c615bc93..0a1b18d0ff94a 100644 --- a/src/test/ui/issues/issue-60622.rs +++ b/src/test/ui/issues/issue-60622.rs @@ -10,7 +10,6 @@ fn run_wild(b: &Borked) { b.a::<'_, T>(); //~^ ERROR cannot specify lifetime arguments explicitly if late bound lifetime parameters are present //~| ERROR this associated function takes 0 generic arguments but 1 generic argument - //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! } fn main() {} diff --git a/src/test/ui/issues/issue-60622.stderr b/src/test/ui/issues/issue-60622.stderr index ecf1ae758dde3..8c107b50cb4db 100644 --- a/src/test/ui/issues/issue-60622.stderr +++ b/src/test/ui/issues/issue-60622.stderr @@ -1,20 +1,15 @@ error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/issue-60622.rs:10:11 | -LL | fn a(&self) {} - | - the late bound lifetime parameter is introduced here -... LL | b.a::<'_, T>(); | ^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42868 -note: the lint level is defined here - --> $DIR/issue-60622.rs:1:9 +note: the late bound lifetime parameter is introduced here + --> $DIR/issue-60622.rs:6:10 | -LL | #![deny(warnings)] - | ^^^^^^^^ - = note: `#[deny(late_bound_lifetime_arguments)]` implied by `#[deny(warnings)]` +LL | fn a(&self) {} + | ^ + = help: remove the explicit lifetime argument error[E0107]: this associated function takes 0 generic arguments but 1 generic argument was supplied --> $DIR/issue-60622.rs:10:7 diff --git a/src/test/ui/issues/issue-69455.stderr b/src/test/ui/issues/issue-69455.stderr index 9d11cf19ea77c..648e79787b635 100644 --- a/src/test/ui/issues/issue-69455.stderr +++ b/src/test/ui/issues/issue-69455.stderr @@ -7,8 +7,8 @@ LL | println!("{}", 23u64.test(xs.iter().sum())); = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider specifying the generic argument | -LL | println!("{}", 23u64.test(xs.iter().sum())::); - | +++++ +LL | println!("{}", 23u64.test(xs.iter().sum())::<'_>); + | ++++++ error[E0283]: type annotations needed --> $DIR/issue-69455.rs:29:41 diff --git a/src/test/ui/issues/issue-72278.rs b/src/test/ui/issues/issue-72278.rs index 92fd1f73a937f..7685bf29c910c 100644 --- a/src/test/ui/issues/issue-72278.rs +++ b/src/test/ui/issues/issue-72278.rs @@ -1,5 +1,3 @@ -// run-pass - #![allow(unused)] struct S; @@ -12,8 +10,7 @@ impl S { fn dont_crash<'a, U>() -> U { S.func::<'a, U>() - //~^ WARN cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted + //~^ ERROR cannot specify lifetime arguments explicitly } fn main() {} diff --git a/src/test/ui/issues/issue-72278.stderr b/src/test/ui/issues/issue-72278.stderr index 5468837a30591..85e03b4ddc44d 100644 --- a/src/test/ui/issues/issue-72278.stderr +++ b/src/test/ui/issues/issue-72278.stderr @@ -1,15 +1,15 @@ -warning: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/issue-72278.rs:14:14 +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/issue-72278.rs:12:14 | -LL | fn func<'a, U>(&'a self) -> U { - | -- the late bound lifetime parameter is introduced here -... LL | S.func::<'a, U>() | ^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42868 - = note: `#[warn(late_bound_lifetime_arguments)]` on by default +note: the late bound lifetime parameter is introduced here + --> $DIR/issue-72278.rs:6:13 + | +LL | fn func<'a, U>(&'a self) -> U { + | ^^ + = help: remove the explicit lifetime argument -warning: 1 warning emitted +error: aborting due to previous error diff --git a/src/test/ui/lifetimes/suggest-introducing-and-adding-missing-lifetime.stderr b/src/test/ui/lifetimes/suggest-introducing-and-adding-missing-lifetime.stderr index 31fd8a4d633e9..12fbe7df0eccc 100644 --- a/src/test/ui/lifetimes/suggest-introducing-and-adding-missing-lifetime.stderr +++ b/src/test/ui/lifetimes/suggest-introducing-and-adding-missing-lifetime.stderr @@ -4,11 +4,11 @@ error[E0311]: the parameter type `T` may not live long enough LL | with_restriction::(x) | ^^^^^^^^^^^^^^^^^^^^^ | -note: the parameter type `T` must be valid for the anonymous lifetime defined here... +note: the parameter type `T` must be valid for the anonymous lifetime as defined here... --> $DIR/suggest-introducing-and-adding-missing-lifetime.rs:1:25 | LL | fn no_restriction(x: &()) -> &() { - | ^^^ + | ^ note: ...so that the type `T` will meet its required lifetime bounds --> $DIR/suggest-introducing-and-adding-missing-lifetime.rs:2:5 | diff --git a/src/test/ui/methods/method-call-lifetime-args-fail.stderr b/src/test/ui/methods/method-call-lifetime-args-fail.stderr index 835edb4b0ae94..b6371c54a10ca 100644 --- a/src/test/ui/methods/method-call-lifetime-args-fail.stderr +++ b/src/test/ui/methods/method-call-lifetime-args-fail.stderr @@ -41,54 +41,59 @@ note: the late bound lifetime parameter is introduced here | LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} | ^^ + = help: remove the explicit lifetime argument error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:29:15 | LL | S::late::<'static, 'static>(S, &0, &0); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ | note: the late bound lifetime parameter is introduced here --> $DIR/method-call-lifetime-args-fail.rs:4:13 | LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} | ^^ + = help: remove the explicit lifetime arguments error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:31:15 | LL | S::late::<'static, 'static, 'static>(S, &0, &0); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ ^^^^^^^ | note: the late bound lifetime parameter is introduced here --> $DIR/method-call-lifetime-args-fail.rs:4:13 | LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} | ^^ + = help: remove the explicit lifetime arguments error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:34:21 | LL | S::late_early::<'static, 'static>(S, &0); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ | note: the late bound lifetime parameter is introduced here --> $DIR/method-call-lifetime-args-fail.rs:7:19 | LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } | ^^ + = help: remove the explicit lifetime arguments error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:36:21 | LL | S::late_early::<'static, 'static, 'static>(S, &0); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ ^^^^^^^ | note: the late bound lifetime parameter is introduced here --> $DIR/method-call-lifetime-args-fail.rs:7:19 | LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } | ^^ + = help: remove the explicit lifetime arguments error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:40:24 @@ -101,102 +106,111 @@ note: the late bound lifetime parameter is introduced here | LL | fn late_implicit(self, _: &u8, _: &u8) {} | ^ + = help: remove the explicit lifetime argument error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:42:24 | LL | S::late_implicit::<'static, 'static>(S, &0, &0); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ | note: the late bound lifetime parameter is introduced here --> $DIR/method-call-lifetime-args-fail.rs:5:31 | LL | fn late_implicit(self, _: &u8, _: &u8) {} | ^ + = help: remove the explicit lifetime arguments error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:44:24 | LL | S::late_implicit::<'static, 'static, 'static>(S, &0, &0); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ ^^^^^^^ | note: the late bound lifetime parameter is introduced here --> $DIR/method-call-lifetime-args-fail.rs:5:31 | LL | fn late_implicit(self, _: &u8, _: &u8) {} | ^ + = help: remove the explicit lifetime arguments error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:47:30 | LL | S::late_implicit_early::<'static, 'static>(S, &0); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ | note: the late bound lifetime parameter is introduced here --> $DIR/method-call-lifetime-args-fail.rs:8:41 | LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } | ^ + = help: remove the explicit lifetime arguments error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:49:30 | LL | S::late_implicit_early::<'static, 'static, 'static>(S, &0); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ ^^^^^^^ | note: the late bound lifetime parameter is introduced here --> $DIR/method-call-lifetime-args-fail.rs:8:41 | LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } | ^ + = help: remove the explicit lifetime arguments error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:52:35 | LL | S::late_implicit_self_early::<'static, 'static>(&S); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ | note: the late bound lifetime parameter is introduced here --> $DIR/method-call-lifetime-args-fail.rs:9:37 | LL | fn late_implicit_self_early<'b>(&self) -> &'b u8 { loop {} } | ^ + = help: remove the explicit lifetime arguments error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:54:35 | LL | S::late_implicit_self_early::<'static, 'static, 'static>(&S); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ ^^^^^^^ | note: the late bound lifetime parameter is introduced here --> $DIR/method-call-lifetime-args-fail.rs:9:37 | LL | fn late_implicit_self_early<'b>(&self) -> &'b u8 { loop {} } | ^ + = help: remove the explicit lifetime arguments error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:57:28 | LL | S::late_unused_early::<'static, 'static>(S); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ | note: the late bound lifetime parameter is introduced here --> $DIR/method-call-lifetime-args-fail.rs:10:26 | LL | fn late_unused_early<'a, 'b>(self) -> &'b u8 { loop {} } | ^^ + = help: remove the explicit lifetime arguments error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:59:28 | LL | S::late_unused_early::<'static, 'static, 'static>(S); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ ^^^^^^^ | note: the late bound lifetime parameter is introduced here --> $DIR/method-call-lifetime-args-fail.rs:10:26 | LL | fn late_unused_early<'a, 'b>(self) -> &'b u8 { loop {} } | ^^ + = help: remove the explicit lifetime arguments error[E0107]: this associated function takes 2 lifetime arguments but 1 lifetime argument was supplied --> $DIR/method-call-lifetime-args-fail.rs:63:8 diff --git a/src/test/ui/methods/method-call-lifetime-args-lint-fail.rs b/src/test/ui/methods/method-call-lifetime-args-lint-fail.rs index 23893911eabd9..db8d1953cfa36 100644 --- a/src/test/ui/methods/method-call-lifetime-args-lint-fail.rs +++ b/src/test/ui/methods/method-call-lifetime-args-lint-fail.rs @@ -1,4 +1,3 @@ -#![deny(late_bound_lifetime_arguments)] #![allow(unused)] struct S; @@ -22,44 +21,32 @@ fn method_call() { S.late(&0, &0); // OK S.late::<'static>(&0, &0); //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted S.late::<'static, 'static>(&0, &0); //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted S.late::<'static, 'static, 'static>(&0, &0); //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted S.late_early(&0); // OK S.late_early::<'static>(&0); //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted S.late_early::<'static, 'static>(&0); //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted S.late_early::<'static, 'static, 'static>(&0); //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted S.late_implicit(&0, &0); // OK S.late_implicit::<'static>(&0, &0); //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted S.late_implicit::<'static, 'static>(&0, &0); //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted S.late_implicit::<'static, 'static, 'static>(&0, &0); //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted S.late_implicit_early(&0); // OK S.late_implicit_early::<'static>(&0); //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted S.late_implicit_early::<'static, 'static>(&0); //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted S.late_implicit_early::<'static, 'static, 'static>(&0); //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted S::early_tricky_explicit::<'static>(loop {}, loop {}); // OK S::early_tricky_implicit::<'static>(loop {}, loop {}); // OK @@ -68,11 +55,9 @@ fn method_call() { fn ufcs() { S::late_early::<'static>(S, &0); //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted S::late_implicit_early::<'static>(S, &0); //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted } fn lint_not_inference_error() { @@ -81,7 +66,6 @@ fn lint_not_inference_error() { // Make sure `u8` is substituted and not replaced with an inference variable f::<'static, u8>; //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted } fn main() {} diff --git a/src/test/ui/methods/method-call-lifetime-args-lint-fail.stderr b/src/test/ui/methods/method-call-lifetime-args-lint-fail.stderr index 394c1ac3c09ee..0aacae2eea001 100644 --- a/src/test/ui/methods/method-call-lifetime-args-lint-fail.stderr +++ b/src/test/ui/methods/method-call-lifetime-args-lint-fail.stderr @@ -1,187 +1,197 @@ error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-lint-fail.rs:23:14 + --> $DIR/method-call-lifetime-args-lint-fail.rs:22:14 | -LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} - | -- the late bound lifetime parameter is introduced here -... LL | S.late::<'static>(&0, &0); | ^^^^^^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42868 -note: the lint level is defined here - --> $DIR/method-call-lifetime-args-lint-fail.rs:1:9 +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args-lint-fail.rs:6:13 | -LL | #![deny(late_bound_lifetime_arguments)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} + | ^^ + = help: remove the explicit lifetime argument error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-lint-fail.rs:26:14 + --> $DIR/method-call-lifetime-args-lint-fail.rs:24:14 | -LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} - | -- the late bound lifetime parameter is introduced here -... LL | S.late::<'static, 'static>(&0, &0); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args-lint-fail.rs:6:13 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42868 +LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} + | ^^ + = help: remove the explicit lifetime arguments error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-lint-fail.rs:29:14 + --> $DIR/method-call-lifetime-args-lint-fail.rs:26:14 | -LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} - | -- the late bound lifetime parameter is introduced here -... LL | S.late::<'static, 'static, 'static>(&0, &0); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args-lint-fail.rs:6:13 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42868 +LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} + | ^^ + = help: remove the explicit lifetime arguments error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-lint-fail.rs:33:20 + --> $DIR/method-call-lifetime-args-lint-fail.rs:29:20 | -LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } - | -- the late bound lifetime parameter is introduced here -... LL | S.late_early::<'static>(&0); | ^^^^^^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42868 +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args-lint-fail.rs:8:19 + | +LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } + | ^^ + = help: remove the explicit lifetime argument error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-lint-fail.rs:36:20 + --> $DIR/method-call-lifetime-args-lint-fail.rs:31:20 | -LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } - | -- the late bound lifetime parameter is introduced here -... LL | S.late_early::<'static, 'static>(&0); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42868 +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args-lint-fail.rs:8:19 + | +LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } + | ^^ + = help: remove the explicit lifetime arguments error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-lint-fail.rs:39:20 + --> $DIR/method-call-lifetime-args-lint-fail.rs:33:20 | -LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } - | -- the late bound lifetime parameter is introduced here -... LL | S.late_early::<'static, 'static, 'static>(&0); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ ^^^^^^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42868 +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args-lint-fail.rs:8:19 + | +LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } + | ^^ + = help: remove the explicit lifetime arguments error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-lint-fail.rs:44:23 + --> $DIR/method-call-lifetime-args-lint-fail.rs:37:23 | -LL | fn late_implicit(self, _: &u8, _: &u8) {} - | - the late bound lifetime parameter is introduced here -... LL | S.late_implicit::<'static>(&0, &0); | ^^^^^^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42868 +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args-lint-fail.rs:7:31 + | +LL | fn late_implicit(self, _: &u8, _: &u8) {} + | ^ + = help: remove the explicit lifetime argument error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-lint-fail.rs:47:23 + --> $DIR/method-call-lifetime-args-lint-fail.rs:39:23 | -LL | fn late_implicit(self, _: &u8, _: &u8) {} - | - the late bound lifetime parameter is introduced here -... LL | S.late_implicit::<'static, 'static>(&0, &0); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42868 +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args-lint-fail.rs:7:31 + | +LL | fn late_implicit(self, _: &u8, _: &u8) {} + | ^ + = help: remove the explicit lifetime arguments error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-lint-fail.rs:50:23 + --> $DIR/method-call-lifetime-args-lint-fail.rs:41:23 | -LL | fn late_implicit(self, _: &u8, _: &u8) {} - | - the late bound lifetime parameter is introduced here -... LL | S.late_implicit::<'static, 'static, 'static>(&0, &0); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args-lint-fail.rs:7:31 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42868 +LL | fn late_implicit(self, _: &u8, _: &u8) {} + | ^ + = help: remove the explicit lifetime arguments error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-lint-fail.rs:54:29 + --> $DIR/method-call-lifetime-args-lint-fail.rs:44:29 | -LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } - | - the late bound lifetime parameter is introduced here -... LL | S.late_implicit_early::<'static>(&0); | ^^^^^^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42868 +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args-lint-fail.rs:9:41 + | +LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } + | ^ + = help: remove the explicit lifetime argument error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-lint-fail.rs:57:29 + --> $DIR/method-call-lifetime-args-lint-fail.rs:46:29 | -LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } - | - the late bound lifetime parameter is introduced here -... LL | S.late_implicit_early::<'static, 'static>(&0); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args-lint-fail.rs:9:41 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42868 +LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } + | ^ + = help: remove the explicit lifetime arguments error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-lint-fail.rs:60:29 + --> $DIR/method-call-lifetime-args-lint-fail.rs:48:29 | -LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } - | - the late bound lifetime parameter is introduced here -... LL | S.late_implicit_early::<'static, 'static, 'static>(&0); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args-lint-fail.rs:9:41 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42868 +LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } + | ^ + = help: remove the explicit lifetime arguments error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-lint-fail.rs:69:21 + --> $DIR/method-call-lifetime-args-lint-fail.rs:56:21 | -LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } - | -- the late bound lifetime parameter is introduced here -... LL | S::late_early::<'static>(S, &0); | ^^^^^^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42868 +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args-lint-fail.rs:8:19 + | +LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } + | ^^ + = help: remove the explicit lifetime argument error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-lint-fail.rs:73:30 + --> $DIR/method-call-lifetime-args-lint-fail.rs:59:30 | -LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } - | - the late bound lifetime parameter is introduced here -... LL | S::late_implicit_early::<'static>(S, &0); | ^^^^^^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42868 +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args-lint-fail.rs:9:41 + | +LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } + | ^ + = help: remove the explicit lifetime argument error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-lint-fail.rs:82:9 + --> $DIR/method-call-lifetime-args-lint-fail.rs:67:9 | -LL | fn f<'early, 'late, T: 'early>() {} - | ----- the late bound lifetime parameter is introduced here -... LL | f::<'static, u8>; | ^^^^^^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42868 +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args-lint-fail.rs:64:18 + | +LL | fn f<'early, 'late, T: 'early>() {} + | ^^^^^ + = help: remove the explicit lifetime argument error: aborting due to 15 previous errors diff --git a/src/test/ui/methods/method-call-lifetime-args-lint.rs b/src/test/ui/methods/method-call-lifetime-args-lint.rs index 14729e1e27e3c..a9907efeafaa1 100644 --- a/src/test/ui/methods/method-call-lifetime-args-lint.rs +++ b/src/test/ui/methods/method-call-lifetime-args-lint.rs @@ -1,4 +1,3 @@ -#![deny(late_bound_lifetime_arguments)] #![allow(unused)] struct S; @@ -11,11 +10,9 @@ impl S { fn method_call() { S.late::<'static>(&0, &0); //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted S.late_implicit::<'static>(&0, &0); //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted } fn main() {} diff --git a/src/test/ui/methods/method-call-lifetime-args-lint.stderr b/src/test/ui/methods/method-call-lifetime-args-lint.stderr index b4fc2d71761c7..f54a63e085627 100644 --- a/src/test/ui/methods/method-call-lifetime-args-lint.stderr +++ b/src/test/ui/methods/method-call-lifetime-args-lint.stderr @@ -1,31 +1,28 @@ error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-lint.rs:12:14 + --> $DIR/method-call-lifetime-args-lint.rs:11:14 | -LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} - | -- the late bound lifetime parameter is introduced here -... LL | S.late::<'static>(&0, &0); | ^^^^^^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42868 -note: the lint level is defined here - --> $DIR/method-call-lifetime-args-lint.rs:1:9 +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args-lint.rs:6:13 | -LL | #![deny(late_bound_lifetime_arguments)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} + | ^^ + = help: remove the explicit lifetime argument error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-lint.rs:16:23 + --> $DIR/method-call-lifetime-args-lint.rs:14:23 | -LL | fn late_implicit(self, _: &u8, _: &u8) {} - | - the late bound lifetime parameter is introduced here -... LL | S.late_implicit::<'static>(&0, &0); | ^^^^^^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42868 +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args-lint.rs:7:31 + | +LL | fn late_implicit(self, _: &u8, _: &u8) {} + | ^ + = help: remove the explicit lifetime argument error: aborting due to 2 previous errors diff --git a/src/test/ui/methods/method-call-lifetime-args-unresolved.rs b/src/test/ui/methods/method-call-lifetime-args-unresolved.rs index ba7231070a0f4..51901ecfcc384 100644 --- a/src/test/ui/methods/method-call-lifetime-args-unresolved.rs +++ b/src/test/ui/methods/method-call-lifetime-args-unresolved.rs @@ -1,6 +1,5 @@ fn main() { 0.clone::<'a>(); //~^ ERROR use of undeclared lifetime name `'a` - //~| WARN cannot specify lifetime arguments explicitly if late bound - //~| WARN this was previously accepted by the compiler + //~| ERROR cannot specify lifetime arguments explicitly if late bound } diff --git a/src/test/ui/methods/method-call-lifetime-args-unresolved.stderr b/src/test/ui/methods/method-call-lifetime-args-unresolved.stderr index 62f20d6d50c04..8b895daf0418d 100644 --- a/src/test/ui/methods/method-call-lifetime-args-unresolved.stderr +++ b/src/test/ui/methods/method-call-lifetime-args-unresolved.stderr @@ -6,21 +6,19 @@ LL | fn main() { LL | 0.clone::<'a>(); | ^^ undeclared lifetime -warning: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-unresolved.rs:2:15 | LL | 0.clone::<'a>(); | ^^ | - ::: $SRC_DIR/core/src/clone.rs:LL:COL +note: the late bound lifetime parameter is introduced here + --> $SRC_DIR/core/src/clone.rs:LL:COL | LL | fn clone(&self) -> Self; - | - the late bound lifetime parameter is introduced here - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #42868 - = note: `#[warn(late_bound_lifetime_arguments)]` on by default + | ^ + = help: remove the explicit lifetime argument -error: aborting due to previous error; 1 warning emitted +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0261`. diff --git a/src/test/ui/methods/method-call-lifetime-args.stderr b/src/test/ui/methods/method-call-lifetime-args.stderr index 64ae79e9bb2b7..625a8bcfb7ac3 100644 --- a/src/test/ui/methods/method-call-lifetime-args.stderr +++ b/src/test/ui/methods/method-call-lifetime-args.stderr @@ -9,6 +9,7 @@ note: the late bound lifetime parameter is introduced here | LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} | ^^ + = help: remove the explicit lifetime argument error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args.rs:11:24 @@ -21,6 +22,7 @@ note: the late bound lifetime parameter is introduced here | LL | fn late_implicit(self, _: &u8, _: &u8) {} | ^ + = help: remove the explicit lifetime argument error: aborting due to 2 previous errors diff --git a/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr b/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr index d2d26b23d646e..fa31807008483 100644 --- a/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr +++ b/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr @@ -6,7 +6,7 @@ LL | let mut closure = expect_sig(|p, y| *p = y); | = note: defining type: test::{closure#0} with closure substs [ i16, - for<'a, 'b, 'c> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) mut &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) i32, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrNamed('c) }) i32)), + for<'a^0, 'b^1, 'c^2> extern "rust-call" fn((&'a^0 mut &'b^1 i32, &'c^2 i32)), (), ] diff --git a/src/test/ui/nll/closure-requirements/escape-argument.stderr b/src/test/ui/nll/closure-requirements/escape-argument.stderr index 6355d3295247f..d51c0820c8b97 100644 --- a/src/test/ui/nll/closure-requirements/escape-argument.stderr +++ b/src/test/ui/nll/closure-requirements/escape-argument.stderr @@ -6,7 +6,7 @@ LL | let mut closure = expect_sig(|p, y| *p = y); | = note: defining type: test::{closure#0} with closure substs [ i16, - for<'a, 'b> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) mut &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) i32, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) i32)), + for<'a^0, 'b^1> extern "rust-call" fn((&'a^0 mut &'b^1 i32, &'b^1 i32)), (), ] diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr index 5f9724ce3db19..c2ab88a36a07c 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr @@ -4,22 +4,22 @@ note: no external requirements LL | |_outlives1, _outlives2, _outlives3, x, y| { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: defining type: supply::{closure#0} with closure substs [ + = note: defining type: supply::<'_#1r, '_#2r, '_#3r>::{closure#0} with closure substs [ i16, - for<'a, 'b> extern "rust-call" fn((std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) u32>, std::cell::Cell<&'_#2r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) &'_#3r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) u32>)), + for<'a^0, 'b^1> extern "rust-call" fn((std::cell::Cell<&'_#4r &'a^0 u32>, std::cell::Cell<&'_#5r &'a^0 u32>, std::cell::Cell<&'b^1 &'_#6r u32>, std::cell::Cell<&'a^0 u32>, std::cell::Cell<&'b^1 u32>)), (), ] - = note: late-bound region is '_#4r - = note: late-bound region is '_#5r - = note: late-bound region is '_#6r + = note: late-bound region is '_#7r + = note: late-bound region is '_#8r + = note: late-bound region is '_#9r error: lifetime may not live long enough --> $DIR/propagate-approximated-fail-no-postdom.rs:46:13 | LL | |_outlives1, _outlives2, _outlives3, x, y| { - | ---------- ---------- has type `Cell<&'2 &'_#3r u32>` + | ---------- ---------- has type `Cell<&'2 &'_#6r u32>` | | - | has type `Cell<&'_#1r &'1 u32>` + | has type `Cell<&'_#4r &'1 u32>` ... LL | demand_y(x, y, p) | ^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2` @@ -30,7 +30,7 @@ note: no external requirements LL | fn supply<'a, 'b, 'c>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>, cell_c: Cell<&'c u32>) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: defining type: supply + = note: defining type: supply::<'_#1r, '_#2r, '_#3r> error: aborting due to previous error diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr index ec728ebd5adf5..2f09e70220ab8 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr @@ -4,15 +4,15 @@ note: external requirements LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: defining type: supply::{closure#0} with closure substs [ + = note: defining type: supply::<'_#1r, '_#2r>::{closure#0} with closure substs [ i16, - for<'a, 'b, 'c, 'd, 'e, 'f> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrNamed('c) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrNamed('d) }) &'_#2r u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrNamed('e) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrNamed('f) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrNamed('d) }) u32>)), + for<'a^0, 'b^1, 'c^2, 'd^3, 'e^4, 'f^5> extern "rust-call" fn((&'a^0 std::cell::Cell<&'_#3r &'b^1 u32>, &'c^2 std::cell::Cell<&'d^3 &'_#4r u32>, &'e^4 std::cell::Cell<&'b^1 u32>, &'f^5 std::cell::Cell<&'d^3 u32>)), (), ] - = note: late-bound region is '_#3r - = note: late-bound region is '_#4r - = note: number of external vids: 5 - = note: where '_#1r: '_#2r + = note: late-bound region is '_#5r + = note: late-bound region is '_#6r + = note: number of external vids: 7 + = note: where '_#3r: '_#4r note: no external requirements --> $DIR/propagate-approximated-ref.rs:42:1 @@ -20,7 +20,7 @@ note: no external requirements LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: defining type: supply + = note: defining type: supply::<'_#1r, '_#2r> error: lifetime may not live long enough --> $DIR/propagate-approximated-ref.rs:45:9 diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr index da4bc499c7e51..0c78965720004 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr @@ -6,7 +6,7 @@ LL | foo(cell, |cell_a, cell_x| { | = note: defining type: case1::{closure#0} with closure substs [ i32, - for<'a> extern "rust-call" fn((std::cell::Cell<&'_#1r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) u32>)), + for<'a^0> extern "rust-call" fn((std::cell::Cell<&'_#1r u32>, std::cell::Cell<&'a^0 u32>)), (), ] @@ -36,7 +36,7 @@ LL | foo(cell, |cell_a, cell_x| { | = note: defining type: case2::{closure#0} with closure substs [ i32, - for<'a> extern "rust-call" fn((std::cell::Cell<&'_#1r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) u32>)), + for<'a^0> extern "rust-call" fn((std::cell::Cell<&'_#1r u32>, std::cell::Cell<&'a^0 u32>)), (), ] = note: number of external vids: 2 diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr index ce85b20b344e2..c8c83c0df6b25 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr @@ -4,15 +4,15 @@ note: external requirements LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { | ^^^^^^^^^^^^^^^^^ | - = note: defining type: supply::{closure#0} with closure substs [ + = note: defining type: supply::<'_#1r, '_#2r>::{closure#0} with closure substs [ i16, - for<'a, 'b, 'c, 'd, 'e> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrNamed('c) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrNamed('d) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrNamed('e) }) u32>)), + for<'a^0, 'b^1, 'c^2, 'd^3, 'e^4> extern "rust-call" fn((&'a^0 std::cell::Cell<&'_#3r &'b^1 u32>, &'c^2 std::cell::Cell<&'b^1 u32>, &'d^3 std::cell::Cell<&'e^4 u32>)), (), ] - = note: late-bound region is '_#2r - = note: late-bound region is '_#3r - = note: number of external vids: 4 - = note: where '_#1r: '_#0r + = note: late-bound region is '_#4r + = note: late-bound region is '_#5r + = note: number of external vids: 6 + = note: where '_#3r: '_#0r note: no external requirements --> $DIR/propagate-approximated-shorter-to-static-no-bound.rs:31:1 @@ -20,7 +20,7 @@ note: no external requirements LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: defining type: supply + = note: defining type: supply::<'_#1r, '_#2r> error[E0521]: borrowed data escapes outside of function --> $DIR/propagate-approximated-shorter-to-static-no-bound.rs:32:5 @@ -40,7 +40,7 @@ LL | | }); | |______`cell_a` escapes the function body here | argument requires that `'a` must outlive `'static` | - = note: requirement occurs because of the type `Cell<&'_#9r u32>`, which makes the generic argument `&'_#9r u32` invariant + = note: requirement occurs because of the type `Cell<&'_#13r u32>`, which makes the generic argument `&'_#13r u32` invariant = note: the struct `Cell` is invariant over the parameter `T` = help: see for more information about variance diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr index 20c7967b78bc9..0f5c85119ea90 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr @@ -4,15 +4,15 @@ note: external requirements LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: defining type: supply::{closure#0} with closure substs [ + = note: defining type: supply::<'_#1r, '_#2r>::{closure#0} with closure substs [ i16, - for<'a, 'b, 'c, 'd, 'e, 'f> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrNamed('c) }) std::cell::Cell<&'_#2r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrNamed('d) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrNamed('e) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrNamed('f) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrNamed('d) }) u32>)), + for<'a^0, 'b^1, 'c^2, 'd^3, 'e^4, 'f^5> extern "rust-call" fn((&'a^0 std::cell::Cell<&'_#3r &'b^1 u32>, &'c^2 std::cell::Cell<&'_#4r &'d^3 u32>, &'e^4 std::cell::Cell<&'b^1 u32>, &'f^5 std::cell::Cell<&'d^3 u32>)), (), ] - = note: late-bound region is '_#3r - = note: late-bound region is '_#4r - = note: number of external vids: 5 - = note: where '_#1r: '_#0r + = note: late-bound region is '_#5r + = note: late-bound region is '_#6r + = note: number of external vids: 7 + = note: where '_#3r: '_#0r note: no external requirements --> $DIR/propagate-approximated-shorter-to-static-wrong-bound.rs:34:1 @@ -20,7 +20,7 @@ note: no external requirements LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: defining type: supply + = note: defining type: supply::<'_#1r, '_#2r> error[E0521]: borrowed data escapes outside of function --> $DIR/propagate-approximated-shorter-to-static-wrong-bound.rs:35:5 @@ -40,7 +40,7 @@ LL | | }); | |______`cell_a` escapes the function body here | argument requires that `'a` must outlive `'static` | - = note: requirement occurs because of the type `Cell<&'_#10r u32>`, which makes the generic argument `&'_#10r u32` invariant + = note: requirement occurs because of the type `Cell<&'_#14r u32>`, which makes the generic argument `&'_#14r u32` invariant = note: the struct `Cell` is invariant over the parameter `T` = help: see for more information about variance diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr index f7db5ab1f27a0..dd793733b710f 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr @@ -4,15 +4,15 @@ note: external requirements LL | establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: defining type: test::{closure#0} with closure substs [ + = note: defining type: test::<'_#1r, '_#2r>::{closure#0} with closure substs [ i16, - for<'a, 'b> extern "rust-call" fn((std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) &'_#2r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) u32>)), + for<'a^0, 'b^1> extern "rust-call" fn((std::cell::Cell<&'_#3r &'a^0 u32>, std::cell::Cell<&'b^1 &'_#4r u32>, std::cell::Cell<&'a^0 u32>, std::cell::Cell<&'b^1 u32>)), (), ] - = note: late-bound region is '_#3r - = note: late-bound region is '_#4r - = note: number of external vids: 5 - = note: where '_#1r: '_#2r + = note: late-bound region is '_#5r + = note: late-bound region is '_#6r + = note: number of external vids: 7 + = note: where '_#3r: '_#4r note: no external requirements --> $DIR/propagate-approximated-val.rs:35:1 @@ -20,7 +20,7 @@ note: no external requirements LL | fn test<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: defining type: test + = note: defining type: test::<'_#1r, '_#2r> error: lifetime may not live long enough --> $DIR/propagate-approximated-val.rs:38:9 diff --git a/src/test/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr b/src/test/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr index 3488edc75e102..aa6ba8aac7da6 100644 --- a/src/test/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr @@ -4,14 +4,14 @@ note: external requirements LL | |_outlives1, _outlives2, x, y| { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: defining type: supply::{closure#0} with closure substs [ + = note: defining type: supply::<'_#1r>::{closure#0} with closure substs [ i16, - for<'a, 'b> extern "rust-call" fn((std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) &'_#2r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) u32>)), + for<'a^0, 'b^1> extern "rust-call" fn((std::cell::Cell<&'_#2r &'a^0 u32>, std::cell::Cell<&'b^1 &'_#3r u32>, std::cell::Cell<&'a^0 u32>, std::cell::Cell<&'b^1 u32>)), (), ] - = note: late-bound region is '_#3r - = note: number of external vids: 4 - = note: where '_#1r: '_#2r + = note: late-bound region is '_#4r + = note: number of external vids: 5 + = note: where '_#2r: '_#3r note: no external requirements --> $DIR/propagate-despite-same-free-region.rs:39:1 @@ -19,5 +19,5 @@ note: no external requirements LL | fn supply<'a>(cell_a: Cell<&'a u32>) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: defining type: supply + = note: defining type: supply::<'_#1r> diff --git a/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr b/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr index 0dc2d0de98fe7..3ebbe2212a997 100644 --- a/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr @@ -4,21 +4,21 @@ note: no external requirements LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { | ^^^^^^^^^^^^^^^^^ | - = note: defining type: supply::{closure#0} with closure substs [ + = note: defining type: supply::<'_#1r, '_#2r>::{closure#0} with closure substs [ i16, - for<'a, 'b, 'c, 'd, 'e> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) &'_#1r u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrNamed('c) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrNamed('d) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrNamed('e) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) u32>)), + for<'a^0, 'b^1, 'c^2, 'd^3, 'e^4> extern "rust-call" fn((&'a^0 std::cell::Cell<&'b^1 &'_#3r u32>, &'c^2 std::cell::Cell<&'d^3 u32>, &'e^4 std::cell::Cell<&'b^1 u32>)), (), ] - = note: late-bound region is '_#2r - = note: late-bound region is '_#3r + = note: late-bound region is '_#4r + = note: late-bound region is '_#5r error: lifetime may not live long enough --> $DIR/propagate-fail-to-approximate-longer-no-bounds.rs:37:9 | LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { - | --------- - has type `&'_#7r Cell<&'1 u32>` + | --------- - has type `&'_#9r Cell<&'1 u32>` | | - | has type `&'_#5r Cell<&'2 &'_#1r u32>` + | has type `&'_#7r Cell<&'2 &'_#3r u32>` LL | // Only works if 'x: 'y: LL | demand_y(x, y, x.get()) | ^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2` @@ -29,7 +29,7 @@ note: no external requirements LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: defining type: supply + = note: defining type: supply::<'_#1r, '_#2r> error: aborting due to previous error diff --git a/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr b/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr index 4c9e026ea522c..57e996b21cf5c 100644 --- a/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr @@ -4,21 +4,21 @@ note: no external requirements LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: defining type: supply::{closure#0} with closure substs [ + = note: defining type: supply::<'_#1r, '_#2r>::{closure#0} with closure substs [ i16, - for<'a, 'b, 'c, 'd, 'e, 'f> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) &'_#1r u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrNamed('c) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrNamed('d) }) &'_#2r u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrNamed('e) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrNamed('f) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrNamed('d) }) u32>)), + for<'a^0, 'b^1, 'c^2, 'd^3, 'e^4, 'f^5> extern "rust-call" fn((&'a^0 std::cell::Cell<&'b^1 &'_#3r u32>, &'c^2 std::cell::Cell<&'d^3 &'_#4r u32>, &'e^4 std::cell::Cell<&'b^1 u32>, &'f^5 std::cell::Cell<&'d^3 u32>)), (), ] - = note: late-bound region is '_#3r - = note: late-bound region is '_#4r + = note: late-bound region is '_#5r + = note: late-bound region is '_#6r error: lifetime may not live long enough --> $DIR/propagate-fail-to-approximate-longer-wrong-bounds.rs:41:9 | LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { - | ---------- ---------- has type `&'_#8r Cell<&'2 &'_#2r u32>` + | ---------- ---------- has type `&'_#10r Cell<&'2 &'_#4r u32>` | | - | has type `&'_#6r Cell<&'1 &'_#1r u32>` + | has type `&'_#8r Cell<&'1 &'_#3r u32>` LL | // Only works if 'x: 'y: LL | demand_y(x, y, x.get()) | ^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2` @@ -29,7 +29,7 @@ note: no external requirements LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: defining type: supply + = note: defining type: supply::<'_#1r, '_#2r> error: aborting due to previous error diff --git a/src/test/ui/nll/closure-requirements/return-wrong-bound-region.stderr b/src/test/ui/nll/closure-requirements/return-wrong-bound-region.stderr index 68429142edecd..ce482e3b36be9 100644 --- a/src/test/ui/nll/closure-requirements/return-wrong-bound-region.stderr +++ b/src/test/ui/nll/closure-requirements/return-wrong-bound-region.stderr @@ -6,7 +6,7 @@ LL | expect_sig(|a, b| b); // ought to return `a` | = note: defining type: test::{closure#0} with closure substs [ i16, - for<'a, 'b> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) i32, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) i32)) -> &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('a) }) i32, + for<'a^0, 'b^1> extern "rust-call" fn((&'a^0 i32, &'b^1 i32)) -> &'a^0 i32, (), ] diff --git a/src/test/ui/nll/issue-98589-closures-relate-named-regions.stderr b/src/test/ui/nll/issue-98589-closures-relate-named-regions.stderr index 6def5602e70b3..627f82456047f 100644 --- a/src/test/ui/nll/issue-98589-closures-relate-named-regions.stderr +++ b/src/test/ui/nll/issue-98589-closures-relate-named-regions.stderr @@ -11,26 +11,26 @@ LL | || { None::<&'a &'b ()>; }; = help: consider adding the following bound: `'b: 'a` error: lifetime may not live long enough - --> $DIR/issue-98589-closures-relate-named-regions.rs:15:10 + --> $DIR/issue-98589-closures-relate-named-regions.rs:15:5 | LL | fn test_early_late<'a: 'a, 'b>() { | -- -- lifetime `'b` defined here | | | lifetime `'a` defined here LL | || { None::<&'a &'b ()>; }; - | ^^^^^^^^^^^^^^^^^^ requires that `'b` must outlive `'a` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'b` must outlive `'a` | = help: consider adding the following bound: `'b: 'a` error: lifetime may not live long enough - --> $DIR/issue-98589-closures-relate-named-regions.rs:21:10 + --> $DIR/issue-98589-closures-relate-named-regions.rs:21:5 | LL | fn test_late_late<'a, 'b>() { | -- -- lifetime `'b` defined here | | | lifetime `'a` defined here LL | || { None::<&'a &'b ()>; }; - | ^^^^^^^^^^^^^^^^^^ requires that `'b` must outlive `'a` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'b` must outlive `'a` | = help: consider adding the following bound: `'b: 'a` diff --git a/src/test/ui/nll/ty-outlives/impl-trait-captures.stderr b/src/test/ui/nll/ty-outlives/impl-trait-captures.stderr index 737cb35841cf5..047c8f81a7528 100644 --- a/src/test/ui/nll/ty-outlives/impl-trait-captures.stderr +++ b/src/test/ui/nll/ty-outlives/impl-trait-captures.stderr @@ -1,15 +1,15 @@ -error[E0700]: hidden type for `Opaque(DefId(0:13 ~ impl_trait_captures[1afc]::foo::{opaque#0}), [ReStatic, T, ReEarlyBound(0, 'a)])` captures lifetime that does not appear in bounds +error[E0700]: hidden type for `Opaque(DefId(0:13 ~ impl_trait_captures[1afc]::foo::{opaque#0}), ['static, T, 'static, 'a/0])` captures lifetime that does not appear in bounds --> $DIR/impl-trait-captures.rs:11:5 | LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> { - | -- hidden type `&ReFree(DefId(0:8 ~ impl_trait_captures[1afc]::foo), BrNamed(DefId(0:12 ~ impl_trait_captures[1afc]::foo::'_), '_)) T` captures the anonymous lifetime defined here + | - hidden type `&BrNamed(DefId(0:12 ~ impl_trait_captures[1afc]::foo::'_))/2 T` captures the anonymous lifetime as defined here LL | x | ^ | -help: to declare that `Opaque(DefId(0:13 ~ impl_trait_captures[1afc]::foo::{opaque#0}), [ReEarlyBound(0, 'a), T, ReEarlyBound(2, 'a)])` captures `ReFree(DefId(0:8 ~ impl_trait_captures[1afc]::foo), BrNamed(DefId(0:12 ~ impl_trait_captures[1afc]::foo::'_), '_))`, you can add an explicit `ReFree(DefId(0:8 ~ impl_trait_captures[1afc]::foo), BrNamed(DefId(0:12 ~ impl_trait_captures[1afc]::foo::'_), '_))` lifetime bound +help: to declare that `Opaque(DefId(0:13 ~ impl_trait_captures[1afc]::foo::{opaque#0}), ['a/0, T, BrNamed(DefId(0:12 ~ impl_trait_captures[1afc]::foo::'_))/2, 'a/3])` captures `BrNamed(DefId(0:12 ~ impl_trait_captures[1afc]::foo::'_))/2`, you can add an explicit `BrNamed(DefId(0:12 ~ impl_trait_captures[1afc]::foo::'_))/2` lifetime bound | -LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> + ReFree(DefId(0:8 ~ impl_trait_captures[1afc]::foo), BrNamed(DefId(0:12 ~ impl_trait_captures[1afc]::foo::'_), '_)) { - | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> + BrNamed(DefId(0:12 ~ impl_trait_captures[1afc]::foo::'_))/2 { + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ error: aborting due to previous error diff --git a/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr b/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr index 4e57dfad794e3..9bc12b7b7c168 100644 --- a/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr +++ b/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr @@ -4,15 +4,15 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: no_relationships_late::<'_#1r, T>::{closure#0} with closure substs [ + = note: defining type: no_relationships_late::<'_#1r, T, '_#2r>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::cell::Cell<&'_#2r ()>, T)), + extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T)), (), ] - = note: late-bound region is '_#3r - = note: number of external vids: 4 - = note: where T: '_#2r - = note: where '_#1r: '_#2r + = note: late-bound region is '_#4r + = note: number of external vids: 5 + = note: where T: '_#3r + = note: where '_#1r: '_#3r note: no external requirements --> $DIR/projection-one-region-closure.rs:41:1 @@ -22,7 +22,7 @@ LL | | where LL | | T: Anything<'b>, | |____________________^ | - = note: defining type: no_relationships_late::<'_#1r, T> + = note: defining type: no_relationships_late::<'_#1r, T, '_#2r> error[E0309]: the parameter type `T` may not live long enough --> $DIR/projection-one-region-closure.rs:45:29 @@ -110,7 +110,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); (), ] = note: number of external vids: 4 - = note: where >::AssocType: '_#3r + = note: where >::AssocType: '_#3r note: no external requirements --> $DIR/projection-one-region-closure.rs:62:1 diff --git a/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr b/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr index 250c796e2c71e..62de596d0b45a 100644 --- a/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr +++ b/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr @@ -4,14 +4,14 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: no_relationships_late::<'_#1r, T>::{closure#0} with closure substs [ + = note: defining type: no_relationships_late::<'_#1r, T, '_#2r>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::cell::Cell<&'_#2r ()>, T)), + extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T)), (), ] - = note: late-bound region is '_#3r - = note: number of external vids: 4 - = note: where '_#1r: '_#2r + = note: late-bound region is '_#4r + = note: number of external vids: 5 + = note: where '_#1r: '_#3r note: no external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:33:1 @@ -21,7 +21,7 @@ LL | | where LL | | T: Anything<'b>, | |____________________^ | - = note: defining type: no_relationships_late::<'_#1r, T> + = note: defining type: no_relationships_late::<'_#1r, T, '_#2r> error: lifetime may not live long enough --> $DIR/projection-one-region-trait-bound-closure.rs:37:39 @@ -86,7 +86,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); (), ] = note: number of external vids: 4 - = note: where >::AssocType: '_#3r + = note: where >::AssocType: '_#3r note: no external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:52:1 diff --git a/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-static-closure.stderr b/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-static-closure.stderr index b27186b053735..bc099f1490c89 100644 --- a/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-static-closure.stderr +++ b/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-static-closure.stderr @@ -4,12 +4,12 @@ note: no external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: no_relationships_late::<'_#1r, T>::{closure#0} with closure substs [ + = note: defining type: no_relationships_late::<'_#1r, T, '_#2r>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::cell::Cell<&'_#2r ()>, T)), + extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T)), (), ] - = note: late-bound region is '_#3r + = note: late-bound region is '_#4r note: no external requirements --> $DIR/projection-one-region-trait-bound-static-closure.rs:32:1 @@ -19,7 +19,7 @@ LL | | where LL | | T: Anything<'b>, | |____________________^ | - = note: defining type: no_relationships_late::<'_#1r, T> + = note: defining type: no_relationships_late::<'_#1r, T, '_#2r> note: no external requirements --> $DIR/projection-one-region-trait-bound-static-closure.rs:45:29 diff --git a/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr b/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr index 0195a693e5ffb..2e8754aa4c3dc 100644 --- a/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr +++ b/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr @@ -4,14 +4,14 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: no_relationships_late::<'_#1r, '_#2r, T>::{closure#0} with closure substs [ + = note: defining type: no_relationships_late::<'_#1r, '_#2r, T, '_#3r>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T)), + extern "rust-call" fn((std::cell::Cell<&'_#4r ()>, T)), (), ] - = note: late-bound region is '_#4r - = note: number of external vids: 5 - = note: where >::AssocType: '_#3r + = note: late-bound region is '_#5r + = note: number of external vids: 6 + = note: where >::AssocType: '_#4r note: no external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:34:1 @@ -21,16 +21,16 @@ LL | | where LL | | T: Anything<'b, 'c>, | |________________________^ | - = note: defining type: no_relationships_late::<'_#1r, '_#2r, T> + = note: defining type: no_relationships_late::<'_#1r, '_#2r, T, '_#3r> -error[E0309]: the associated type `>::AssocType` may not live long enough +error[E0309]: the associated type `>::AssocType` may not live long enough --> $DIR/projection-two-region-trait-bound-closure.rs:38:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: consider adding an explicit lifetime bound `>::AssocType: 'a`... - = note: ...so that the type `>::AssocType` will meet its required lifetime bounds + = help: consider adding an explicit lifetime bound `>::AssocType: 'a`... + = note: ...so that the type `>::AssocType` will meet its required lifetime bounds note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:48:29 @@ -44,7 +44,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); (), ] = note: number of external vids: 5 - = note: where >::AssocType: '_#4r + = note: where >::AssocType: '_#4r note: no external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:43:1 @@ -57,14 +57,14 @@ LL | | 'a: 'a, | = note: defining type: no_relationships_early::<'_#1r, '_#2r, '_#3r, T> -error[E0309]: the associated type `>::AssocType` may not live long enough +error[E0309]: the associated type `>::AssocType` may not live long enough --> $DIR/projection-two-region-trait-bound-closure.rs:48:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: consider adding an explicit lifetime bound `>::AssocType: 'a`... - = note: ...so that the type `>::AssocType` will meet its required lifetime bounds + = help: consider adding an explicit lifetime bound `>::AssocType: 'a`... + = note: ...so that the type `>::AssocType` will meet its required lifetime bounds note: external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:61:29 @@ -78,7 +78,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); (), ] = note: number of external vids: 5 - = note: where >::AssocType: '_#4r + = note: where >::AssocType: '_#4r note: no external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:53:1 @@ -103,7 +103,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); (), ] = note: number of external vids: 5 - = note: where >::AssocType: '_#4r + = note: where >::AssocType: '_#4r note: no external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:65:1 @@ -128,7 +128,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); (), ] = note: number of external vids: 5 - = note: where >::AssocType: '_#4r + = note: where >::AssocType: '_#4r note: no external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:74:1 @@ -147,14 +147,14 @@ note: external requirements LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^ | - = note: defining type: two_regions::<'_#1r, T>::{closure#0} with closure substs [ + = note: defining type: two_regions::<'_#1r, T, '_#2r>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::cell::Cell<&'_#2r ()>, T)), + extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T)), (), ] - = note: late-bound region is '_#3r - = note: number of external vids: 4 - = note: where >::AssocType: '_#2r + = note: late-bound region is '_#4r + = note: number of external vids: 5 + = note: where >::AssocType: '_#3r note: no external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:83:1 @@ -164,7 +164,7 @@ LL | | where LL | | T: Anything<'b, 'b>, | |________________________^ | - = note: defining type: two_regions::<'_#1r, T> + = note: defining type: two_regions::<'_#1r, T, '_#2r> error: lifetime may not live long enough --> $DIR/projection-two-region-trait-bound-closure.rs:87:29 @@ -191,7 +191,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); (), ] = note: number of external vids: 4 - = note: where >::AssocType: '_#3r + = note: where >::AssocType: '_#3r note: no external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:92:1 @@ -216,7 +216,7 @@ LL | with_signature(cell, t, |cell, t| require(cell, t)); (), ] = note: number of external vids: 3 - = note: where >::AssocType: '_#2r + = note: where >::AssocType: '_#2r note: no external requirements --> $DIR/projection-two-region-trait-bound-closure.rs:101:1 diff --git a/src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr b/src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr index 61c7d2550caad..0676308309a8c 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr +++ b/src/test/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr @@ -6,7 +6,7 @@ LL | twice(cell, value, |a, b| invoke(a, b)); | = note: defining type: generic::::{closure#0} with closure substs [ i16, - for<'a, 'b> extern "rust-call" fn((std::option::Option>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) T)), + for<'a^0, 'b^1> extern "rust-call" fn((std::option::Option>, &'b^1 T)), (), ] = note: number of external vids: 2 @@ -26,14 +26,14 @@ note: external requirements LL | twice(cell, value, |a, b| invoke(a, b)); | ^^^^^^ | - = note: defining type: generic_fail::::{closure#0} with closure substs [ + = note: defining type: generic_fail::::{closure#0} with closure substs [ i16, - for<'a, 'b> extern "rust-call" fn((std::option::Option>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrNamed('b) }) T)), + for<'a^0, 'b^1> extern "rust-call" fn((std::option::Option>, &'b^1 T)), (), ] - = note: late-bound region is '_#2r - = note: number of external vids: 3 - = note: where T: '_#1r + = note: late-bound region is '_#3r + = note: number of external vids: 4 + = note: where T: '_#2r note: no external requirements --> $DIR/ty-param-closure-approximate-lower-bound.rs:28:1 @@ -41,7 +41,7 @@ note: no external requirements LL | fn generic_fail<'a, T>(cell: Cell<&'a ()>, value: T) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: defining type: generic_fail:: + = note: defining type: generic_fail:: error[E0309]: the parameter type `T` may not live long enough --> $DIR/ty-param-closure-approximate-lower-bound.rs:29:24 diff --git a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr index 14c55e32a3ebe..bd80a6f288ba5 100644 --- a/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr +++ b/src/test/ui/nll/ty-outlives/ty-param-closure-outlives-from-where-clause.stderr @@ -4,14 +4,14 @@ note: external requirements LL | with_signature(a, b, |x, y| { | ^^^^^^ | - = note: defining type: no_region::::{closure#0} with closure substs [ + = note: defining type: no_region::::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::cell::Cell<&'_#1r ()>, T)), + extern "rust-call" fn((std::cell::Cell<&'_#2r ()>, T)), (), ] - = note: late-bound region is '_#2r - = note: number of external vids: 3 - = note: where T: '_#1r + = note: late-bound region is '_#3r + = note: number of external vids: 4 + = note: where T: '_#2r note: no external requirements --> $DIR/ty-param-closure-outlives-from-where-clause.rs:26:1 @@ -19,7 +19,7 @@ note: no external requirements LL | fn no_region<'a, T>(a: Cell<&'a ()>, b: T) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: defining type: no_region:: + = note: defining type: no_region:: error[E0309]: the parameter type `T` may not live long enough --> $DIR/ty-param-closure-outlives-from-where-clause.rs:27:26 @@ -69,14 +69,14 @@ note: external requirements LL | with_signature(a, b, |x, y| { | ^^^^^^ | - = note: defining type: wrong_region::<'_#1r, T>::{closure#0} with closure substs [ + = note: defining type: wrong_region::<'_#1r, T, '_#2r>::{closure#0} with closure substs [ i32, - extern "rust-call" fn((std::cell::Cell<&'_#2r ()>, T)), + extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T)), (), ] - = note: late-bound region is '_#3r - = note: number of external vids: 4 - = note: where T: '_#2r + = note: late-bound region is '_#4r + = note: number of external vids: 5 + = note: where T: '_#3r note: no external requirements --> $DIR/ty-param-closure-outlives-from-where-clause.rs:60:1 @@ -86,7 +86,7 @@ LL | | where LL | | T: 'b, | |__________^ | - = note: defining type: wrong_region::<'_#1r, T> + = note: defining type: wrong_region::<'_#1r, T, '_#2r> error[E0309]: the parameter type `T` may not live long enough --> $DIR/ty-param-closure-outlives-from-where-clause.rs:64:26 diff --git a/src/test/ui/nll/user-annotations/dump-adt-brace-struct.rs b/src/test/ui/nll/user-annotations/dump-adt-brace-struct.rs index ccda9129dabae..5f4acc57c2a71 100644 --- a/src/test/ui/nll/user-annotations/dump-adt-brace-struct.rs +++ b/src/test/ui/nll/user-annotations/dump-adt-brace-struct.rs @@ -16,5 +16,5 @@ fn main() { SomeStruct:: { t: 22 }; // No lifetime bounds given. - SomeStruct::<&'static u32> { t: &22 }; //~ ERROR [&ReStatic u32] + SomeStruct::<&'static u32> { t: &22 }; //~ ERROR [&'static u32] } diff --git a/src/test/ui/nll/user-annotations/dump-adt-brace-struct.stderr b/src/test/ui/nll/user-annotations/dump-adt-brace-struct.stderr index 5860621909ce4..e270cb1d24dc7 100644 --- a/src/test/ui/nll/user-annotations/dump-adt-brace-struct.stderr +++ b/src/test/ui/nll/user-annotations/dump-adt-brace-struct.stderr @@ -1,4 +1,4 @@ -error: user substs: UserSubsts { substs: [&ReStatic u32], user_self_ty: None } +error: user substs: UserSubsts { substs: [&'static u32], user_self_ty: None } --> $DIR/dump-adt-brace-struct.rs:19:5 | LL | SomeStruct::<&'static u32> { t: &22 }; diff --git a/src/test/ui/nll/user-annotations/dump-fn-method.rs b/src/test/ui/nll/user-annotations/dump-fn-method.rs index 148d63d848f80..bb7cd3874e816 100644 --- a/src/test/ui/nll/user-annotations/dump-fn-method.rs +++ b/src/test/ui/nll/user-annotations/dump-fn-method.rs @@ -23,25 +23,25 @@ fn main() { // Here: `u32` is given, which doesn't contain any lifetimes, so we don't // have any annotation. - let x = foo::; + let x = foo::; //~ ERROR [u32, '0^0] x(22); - let x = foo::<&'static u32>; //~ ERROR [&ReStatic u32] + let x = foo::<&'static u32>; //~ ERROR [&'static u32, '0^0] x(&22); // Here: we only want the `T` to be given, the rest should be variables. // // (`T` refers to the declaration of `Bazoom`) - let x = <_ as Bazoom>::method::<_>; //~ ERROR [^0, u32, ^1] + let x = <_ as Bazoom>::method::<_>; //~ ERROR [^0, u32, ^1, '2^2] x(&22, 44, 66); // Here: all are given and definitely contain no lifetimes, so we // don't have any annotation. - let x = >::method::; + let x = >::method::; //~ ERROR [u8, u16, u32, '0^0] x(&22, 44, 66); // Here: all are given and we have a lifetime. - let x = >::method::; //~ ERROR [u8, &ReStatic u16, u32] + let x = >::method::; //~ ERROR [u8, &'static u16, u32, '0^0] x(&22, &44, 66); // Here: we want in particular that *only* the method `U` @@ -49,7 +49,7 @@ fn main() { // // (`U` refers to the declaration of `Bazoom`) let y = 22_u32; - y.method::(44, 66); //~ ERROR [^0, ^1, u32] + y.method::(44, 66); //~ ERROR [^0, ^1, u32, '2^2] // Here: nothing is given, so we don't have any annotation. let y = 22_u32; diff --git a/src/test/ui/nll/user-annotations/dump-fn-method.stderr b/src/test/ui/nll/user-annotations/dump-fn-method.stderr index d139efa888ff7..7ed3c42504780 100644 --- a/src/test/ui/nll/user-annotations/dump-fn-method.stderr +++ b/src/test/ui/nll/user-annotations/dump-fn-method.stderr @@ -1,26 +1,38 @@ -error: user substs: UserSubsts { substs: [&ReStatic u32], user_self_ty: None } +error: user substs: UserSubsts { substs: [u32, '0^0], user_self_ty: None } + --> $DIR/dump-fn-method.rs:26:13 + | +LL | let x = foo::; + | ^^^^^^^^^^ + +error: user substs: UserSubsts { substs: [&'static u32, '0^0], user_self_ty: None } --> $DIR/dump-fn-method.rs:29:13 | LL | let x = foo::<&'static u32>; | ^^^^^^^^^^^^^^^^^^^ -error: user substs: UserSubsts { substs: [^0, u32, ^1], user_self_ty: None } +error: user substs: UserSubsts { substs: [^0, u32, ^1, '2^2], user_self_ty: None } --> $DIR/dump-fn-method.rs:35:13 | LL | let x = <_ as Bazoom>::method::<_>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: user substs: UserSubsts { substs: [u8, &ReStatic u16, u32], user_self_ty: None } +error: user substs: UserSubsts { substs: [u8, u16, u32, '0^0], user_self_ty: None } + --> $DIR/dump-fn-method.rs:40:13 + | +LL | let x = >::method::; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: user substs: UserSubsts { substs: [u8, &'static u16, u32, '0^0], user_self_ty: None } --> $DIR/dump-fn-method.rs:44:13 | LL | let x = >::method::; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: user substs: UserSubsts { substs: [^0, ^1, u32], user_self_ty: None } +error: user substs: UserSubsts { substs: [^0, ^1, u32, '2^2], user_self_ty: None } --> $DIR/dump-fn-method.rs:52:5 | LL | y.method::(44, 66); | ^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 4 previous errors +error: aborting due to 6 previous errors diff --git a/src/test/ui/nll/user-annotations/issue-54124.stderr b/src/test/ui/nll/user-annotations/issue-54124.stderr index 2556af2dd7de2..9c884ebf39c84 100644 --- a/src/test/ui/nll/user-annotations/issue-54124.stderr +++ b/src/test/ui/nll/user-annotations/issue-54124.stderr @@ -9,12 +9,12 @@ LL | let _:fn(&()) = |_:&'a ()| {}; | requires that `'1` must outlive `'a` error: lifetime may not live long enough - --> $DIR/issue-54124.rs:2:22 + --> $DIR/issue-54124.rs:2:21 | LL | fn test<'a>() { | -- lifetime `'a` defined here LL | let _:fn(&()) = |_:&'a ()| {}; - | ^ requires that `'a` must outlive `'static` + | ^^^^^^^^^^^^^ requires that `'a` must outlive `'static` error: aborting due to 2 previous errors diff --git a/src/test/ui/privacy/associated-item-privacy-inherent.rs b/src/test/ui/privacy/associated-item-privacy-inherent.rs index 7b7c734a99a1c..9807dfaa05de9 100644 --- a/src/test/ui/privacy/associated-item-privacy-inherent.rs +++ b/src/test/ui/privacy/associated-item-privacy-inherent.rs @@ -11,11 +11,11 @@ mod priv_nominal { pub macro mac() { let value = Pub::method; - //~^ ERROR type `for<'a> fn(&'a priv_nominal::Pub) {priv_nominal::Pub::method}` is private + //~^ ERROR type `fn(&priv_nominal::Pub) {priv_nominal::Pub::method}` is private value; - //~^ ERROR type `for<'a> fn(&'a priv_nominal::Pub) {priv_nominal::Pub::method}` is private + //~^ ERROR type `fn(&priv_nominal::Pub) {priv_nominal::Pub::method}` is private Pub.method(); - //~^ ERROR type `for<'a> fn(&'a priv_nominal::Pub) {priv_nominal::Pub::method}` is private + //~^ ERROR type `fn(&priv_nominal::Pub) {priv_nominal::Pub::method}` is private Pub::CONST; //~^ ERROR associated constant `CONST` is private // let _: Pub::AssocTy; diff --git a/src/test/ui/privacy/associated-item-privacy-inherent.stderr b/src/test/ui/privacy/associated-item-privacy-inherent.stderr index f4d4ee459204d..b9a1006822eab 100644 --- a/src/test/ui/privacy/associated-item-privacy-inherent.stderr +++ b/src/test/ui/privacy/associated-item-privacy-inherent.stderr @@ -1,4 +1,4 @@ -error: type `for<'a> fn(&'a priv_nominal::Pub) {priv_nominal::Pub::method}` is private +error: type `fn(&priv_nominal::Pub) {priv_nominal::Pub::method}` is private --> $DIR/associated-item-privacy-inherent.rs:13:21 | LL | let value = Pub::method; @@ -9,7 +9,7 @@ LL | priv_nominal::mac!(); | = note: this error originates in the macro `priv_nominal::mac` (in Nightly builds, run with -Z macro-backtrace for more info) -error: type `for<'a> fn(&'a priv_nominal::Pub) {priv_nominal::Pub::method}` is private +error: type `fn(&priv_nominal::Pub) {priv_nominal::Pub::method}` is private --> $DIR/associated-item-privacy-inherent.rs:15:9 | LL | value; @@ -20,7 +20,7 @@ LL | priv_nominal::mac!(); | = note: this error originates in the macro `priv_nominal::mac` (in Nightly builds, run with -Z macro-backtrace for more info) -error: type `for<'a> fn(&'a priv_nominal::Pub) {priv_nominal::Pub::method}` is private +error: type `fn(&priv_nominal::Pub) {priv_nominal::Pub::method}` is private --> $DIR/associated-item-privacy-inherent.rs:17:13 | LL | Pub.method(); diff --git a/src/test/ui/privacy/associated-item-privacy-trait.rs b/src/test/ui/privacy/associated-item-privacy-trait.rs index ad9a5e15c4e6e..54d1af9a0ad44 100644 --- a/src/test/ui/privacy/associated-item-privacy-trait.rs +++ b/src/test/ui/privacy/associated-item-privacy-trait.rs @@ -13,11 +13,11 @@ mod priv_trait { pub macro mac() { let value = ::method; - //~^ ERROR type `for<'a> fn(&'a priv_trait::Pub) {::method}` is private + //~^ ERROR type `fn(&priv_trait::Pub) {::method}` is private value; - //~^ ERROR type `for<'a> fn(&'a priv_trait::Pub) {::method}` is private + //~^ ERROR type `fn(&priv_trait::Pub) {::method}` is private Pub.method(); - //~^ ERROR type `for<'a> fn(&'a Self) {::method}` is private + //~^ ERROR type `fn(&Self) {::method}` is private ::CONST; //~^ ERROR associated constant `::CONST` is private let _: ::AssocTy; diff --git a/src/test/ui/privacy/associated-item-privacy-trait.stderr b/src/test/ui/privacy/associated-item-privacy-trait.stderr index c4be1a9d9a202..6a0da707d983a 100644 --- a/src/test/ui/privacy/associated-item-privacy-trait.stderr +++ b/src/test/ui/privacy/associated-item-privacy-trait.stderr @@ -1,4 +1,4 @@ -error: type `for<'a> fn(&'a priv_trait::Pub) {::method}` is private +error: type `fn(&priv_trait::Pub) {::method}` is private --> $DIR/associated-item-privacy-trait.rs:15:21 | LL | let value = ::method; @@ -9,7 +9,7 @@ LL | priv_trait::mac!(); | = note: this error originates in the macro `priv_trait::mac` (in Nightly builds, run with -Z macro-backtrace for more info) -error: type `for<'a> fn(&'a priv_trait::Pub) {::method}` is private +error: type `fn(&priv_trait::Pub) {::method}` is private --> $DIR/associated-item-privacy-trait.rs:17:9 | LL | value; @@ -20,7 +20,7 @@ LL | priv_trait::mac!(); | = note: this error originates in the macro `priv_trait::mac` (in Nightly builds, run with -Z macro-backtrace for more info) -error: type `for<'a> fn(&'a Self) {::method}` is private +error: type `fn(&Self) {::method}` is private --> $DIR/associated-item-privacy-trait.rs:19:13 | LL | Pub.method(); diff --git a/src/test/ui/privacy/private-inferred-type-3.rs b/src/test/ui/privacy/private-inferred-type-3.rs index 0337aedd00881..87fe53f6381e2 100644 --- a/src/test/ui/privacy/private-inferred-type-3.rs +++ b/src/test/ui/privacy/private-inferred-type-3.rs @@ -1,17 +1,16 @@ // aux-build:private-inferred-type.rs -// error-pattern:type `fn() {ext::priv_fn}` is private -// error-pattern:static `PRIV_STATIC` is private -// error-pattern:type `ext::PrivEnum` is private -// error-pattern:type `fn() {::method}` is private -// error-pattern:type `fn(u8) -> ext::PrivTupleStruct {ext::PrivTupleStruct}` is private -// error-pattern:type `fn(u8) -> PubTupleStruct {PubTupleStruct}` is private -// error-pattern:type `for<'a> fn(&'a Pub) {Pub::::priv_method}` is private - #![feature(decl_macro)] extern crate private_inferred_type as ext; fn main() { ext::m!(); + //~^ ERROR type `fn() {ext::priv_fn}` is private + //~| ERROR static `PRIV_STATIC` is private + //~| ERROR type `ext::PrivEnum` is private + //~| ERROR type `fn() {::method}` is private + //~| ERROR type `fn(u8) -> ext::PrivTupleStruct {ext::PrivTupleStruct}` is private + //~| ERROR type `fn(u8) -> PubTupleStruct {PubTupleStruct}` is private + //~| ERROR type `fn(&Pub) {Pub::::priv_method}` is private } diff --git a/src/test/ui/privacy/private-inferred-type-3.stderr b/src/test/ui/privacy/private-inferred-type-3.stderr index 00b61512de6b4..26f844bf17e72 100644 --- a/src/test/ui/privacy/private-inferred-type-3.stderr +++ b/src/test/ui/privacy/private-inferred-type-3.stderr @@ -1,5 +1,5 @@ error: type `fn() {ext::priv_fn}` is private - --> $DIR/private-inferred-type-3.rs:16:5 + --> $DIR/private-inferred-type-3.rs:8:5 | LL | ext::m!(); | ^^^^^^^^^ private type @@ -7,7 +7,7 @@ LL | ext::m!(); = note: this error originates in the macro `ext::m` (in Nightly builds, run with -Z macro-backtrace for more info) error: static `PRIV_STATIC` is private - --> $DIR/private-inferred-type-3.rs:16:5 + --> $DIR/private-inferred-type-3.rs:8:5 | LL | ext::m!(); | ^^^^^^^^^ private static @@ -15,7 +15,7 @@ LL | ext::m!(); = note: this error originates in the macro `ext::m` (in Nightly builds, run with -Z macro-backtrace for more info) error: type `ext::PrivEnum` is private - --> $DIR/private-inferred-type-3.rs:16:5 + --> $DIR/private-inferred-type-3.rs:8:5 | LL | ext::m!(); | ^^^^^^^^^ private type @@ -23,7 +23,7 @@ LL | ext::m!(); = note: this error originates in the macro `ext::m` (in Nightly builds, run with -Z macro-backtrace for more info) error: type `fn() {::method}` is private - --> $DIR/private-inferred-type-3.rs:16:5 + --> $DIR/private-inferred-type-3.rs:8:5 | LL | ext::m!(); | ^^^^^^^^^ private type @@ -31,7 +31,7 @@ LL | ext::m!(); = note: this error originates in the macro `ext::m` (in Nightly builds, run with -Z macro-backtrace for more info) error: type `fn(u8) -> ext::PrivTupleStruct {ext::PrivTupleStruct}` is private - --> $DIR/private-inferred-type-3.rs:16:5 + --> $DIR/private-inferred-type-3.rs:8:5 | LL | ext::m!(); | ^^^^^^^^^ private type @@ -39,15 +39,15 @@ LL | ext::m!(); = note: this error originates in the macro `ext::m` (in Nightly builds, run with -Z macro-backtrace for more info) error: type `fn(u8) -> PubTupleStruct {PubTupleStruct}` is private - --> $DIR/private-inferred-type-3.rs:16:5 + --> $DIR/private-inferred-type-3.rs:8:5 | LL | ext::m!(); | ^^^^^^^^^ private type | = note: this error originates in the macro `ext::m` (in Nightly builds, run with -Z macro-backtrace for more info) -error: type `for<'a> fn(&'a Pub) {Pub::::priv_method}` is private - --> $DIR/private-inferred-type-3.rs:16:5 +error: type `fn(&Pub) {Pub::::priv_method}` is private + --> $DIR/private-inferred-type-3.rs:8:5 | LL | ext::m!(); | ^^^^^^^^^ private type diff --git a/src/test/ui/privacy/private-inferred-type.rs b/src/test/ui/privacy/private-inferred-type.rs index e8743dd968feb..09543a5a931c1 100644 --- a/src/test/ui/privacy/private-inferred-type.rs +++ b/src/test/ui/privacy/private-inferred-type.rs @@ -47,7 +47,7 @@ mod m { PubTupleStruct; //~^ ERROR type `fn(u8) -> PubTupleStruct {PubTupleStruct}` is private Pub(0u8).priv_method(); - //~^ ERROR type `for<'a> fn(&'a Pub) {Pub::::priv_method}` is private + //~^ ERROR type `fn(&Pub) {Pub::::priv_method}` is private } trait Trait {} diff --git a/src/test/ui/privacy/private-inferred-type.stderr b/src/test/ui/privacy/private-inferred-type.stderr index fc3f9ab62bfa9..f5c3c9e9a504b 100644 --- a/src/test/ui/privacy/private-inferred-type.stderr +++ b/src/test/ui/privacy/private-inferred-type.stderr @@ -161,7 +161,7 @@ LL | m::m!(); | = note: this error originates in the macro `m::m` (in Nightly builds, run with -Z macro-backtrace for more info) -error: type `for<'a> fn(&'a Pub) {Pub::::priv_method}` is private +error: type `fn(&Pub) {Pub::::priv_method}` is private --> $DIR/private-inferred-type.rs:49:18 | LL | Pub(0u8).priv_method(); diff --git a/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.stderr b/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.stderr index 3b62c7b61c1b1..cde78659db1a9 100644 --- a/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.stderr +++ b/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.stderr @@ -5,7 +5,7 @@ LL | let _: fn(&mut &isize, &mut &isize) = a; | ^ one type is more general than the other | = note: expected fn pointer `for<'a, 'b, 'c, 'd> fn(&'a mut &'b isize, &'c mut &'d isize)` - found fn item `for<'a, 'b> fn(&'a mut &isize, &'b mut &isize) {a::<'_, '_>}` + found fn item `for<'a, 'b> fn(&'a mut &isize, &'b mut &isize) {a}` error: aborting due to previous error diff --git a/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.stderr b/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.stderr index 8a18a234b5c4e..84c28c90cfc49 100644 --- a/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.stderr +++ b/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.stderr @@ -5,7 +5,7 @@ LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; | ^ one type is more general than the other | = note: expected fn pointer `for<'a, 'b, 'c, 'd, 'e, 'f> fn(&'a mut &'b isize, &'c mut &'d isize, &'e mut &'f isize)` - found fn item `for<'a, 'b, 'c> fn(&'a mut &isize, &'b mut &isize, &'c mut &isize) {a::<'_, '_, '_>}` + found fn item `for<'a, 'b, 'c> fn(&'a mut &isize, &'b mut &isize, &'c mut &isize) {a}` error: aborting due to previous error diff --git a/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.stderr b/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.stderr index 66f592c34dd07..04b38c73b7a1b 100644 --- a/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.stderr +++ b/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.stderr @@ -14,10 +14,10 @@ LL | fn callee<'x, 'y, T: for<'z> Trait2<'y, 'z>>(t: &'x dyn for<'z> Trait1< T: Trait2<'y, 'z>` is not satisfied - --> $DIR/regions-implied-bounds-projection-gap-hr-1.rs:21:49 + --> $DIR/regions-implied-bounds-projection-gap-hr-1.rs:21:4 | LL | fn callee<'x, 'y, T>(t: &'x dyn for<'z> Trait1< >::Foo >) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'z> Trait2<'y, 'z>` is not implemented for `T` + | ^^^^^^ the trait `for<'z> Trait2<'y, 'z>` is not implemented for `T` | help: consider restricting type parameter `T` | diff --git a/src/test/ui/regions/regions-lifetime-bounds-on-fns.stderr b/src/test/ui/regions/regions-lifetime-bounds-on-fns.stderr index 17a9019436a1e..09614745e0d8b 100644 --- a/src/test/ui/regions/regions-lifetime-bounds-on-fns.stderr +++ b/src/test/ui/regions/regions-lifetime-bounds-on-fns.stderr @@ -5,7 +5,7 @@ LL | let _: fn(&mut &isize, &mut &isize) = a; | ^ one type is more general than the other | = note: expected fn pointer `for<'a, 'b, 'c, 'd> fn(&'a mut &'b isize, &'c mut &'d isize)` - found fn item `for<'a, 'b> fn(&'a mut &isize, &'b mut &isize) {a::<'_, '_>}` + found fn item `for<'a, 'b> fn(&'a mut &isize, &'b mut &isize) {a}` error: aborting due to previous error diff --git a/src/test/ui/rfc1623-2.stderr b/src/test/ui/rfc1623-2.stderr index 945c6533c797b..448e0c2f44b3b 100644 --- a/src/test/ui/rfc1623-2.stderr +++ b/src/test/ui/rfc1623-2.stderr @@ -23,7 +23,7 @@ help: consider making the type lifetime-generic with a new `'a` lifetime LL | &(non_elidable as for<'a> fn(&'a u8, &'a u8) -> &'a u8); | +++++++ ++ ++ ++ -error[E0605]: non-primitive cast: `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8 {non_elidable}` as `for<'a, 'b> fn(&'a u8, &'b u8) -> &u8` +error[E0605]: non-primitive cast: `fn(&u8, &u8) -> &u8 {non_elidable}` as `for<'a, 'b> fn(&'a u8, &'b u8) -> &u8` --> $DIR/rfc1623-2.rs:10:6 | LL | &(non_elidable as fn(&u8, &u8) -> &u8); diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr b/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr index eb3d3e4a67a98..9a649034e7667 100644 --- a/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr +++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr @@ -2,9 +2,9 @@ error[E0700]: hidden type for `impl Clone` captures lifetime that does not appea --> $DIR/arbitrary_self_types_pin_lifetime_impl_trait-async.rs:8:48 | LL | async fn f(self: Pin<&Self>) -> impl Clone { self } - | ----- ^^^^^^^^ + | - ^^^^^^^^ | | - | hidden type `Pin<&Foo>` captures the anonymous lifetime defined here + | hidden type `Pin<&Foo>` captures the anonymous lifetime as defined here | help: to declare that `impl Clone` captures `'_`, you can add an explicit `'_` lifetime bound | diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait.stderr b/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait.stderr index 2c0b2a0d91938..4658d70862121 100644 --- a/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait.stderr +++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait.stderr @@ -2,9 +2,9 @@ error[E0700]: hidden type for `impl Clone` captures lifetime that does not appea --> $DIR/arbitrary_self_types_pin_lifetime_impl_trait.rs:6:44 | LL | fn f(self: Pin<&Self>) -> impl Clone { self } - | ----- ^^^^ + | - ^^^^ | | - | hidden type `Pin<&Foo>` captures the anonymous lifetime defined here + | hidden type `Pin<&Foo>` captures the anonymous lifetime as defined here | help: to declare that `impl Clone` captures `'_`, you can add an explicit `'_` lifetime bound | diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.stderr b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.stderr index 6180e1e0f2d7e..295455018d216 100644 --- a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.stderr +++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.stderr @@ -30,9 +30,8 @@ error: lifetime may not live long enough --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:17:64 | LL | async fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg } - | -- - ^^^ associated function was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a` - | | | - | | let's call the lifetime of this reference `'1` + | -- ---- has type `Pin<&'1 Foo>` ^^^ associated function was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a` + | | | lifetime `'a` defined here error: aborting due to 3 previous errors diff --git a/src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr b/src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr index 597dc61c3f7e2..5e0a8be9e561a 100644 --- a/src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr +++ b/src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr @@ -220,7 +220,7 @@ error[E0308]: mismatched types --> $DIR/fn-or-tuple-struct-without-args.rs:41:20 | LL | fn ban(&self) -> usize { 42 } - | ---------------------- for<'a> fn(&'a X) -> usize {::ban} defined here + | ---------------------- fn(&X) -> usize {::ban} defined here ... LL | let _: usize = X::ban; | ----- ^^^^^^ expected `usize`, found fn item @@ -228,7 +228,7 @@ LL | let _: usize = X::ban; | expected due to this | = note: expected type `usize` - found fn item `for<'a> fn(&'a X) -> usize {::ban}` + found fn item `fn(&X) -> usize {::ban}` help: use parentheses to call this associated function | LL | let _: usize = X::ban(/* &X */); @@ -238,7 +238,7 @@ error[E0308]: mismatched types --> $DIR/fn-or-tuple-struct-without-args.rs:42:20 | LL | fn bal(&self) -> usize; - | ----------------------- for<'a> fn(&'a X) -> usize {::bal} defined here + | ----------------------- fn(&X) -> usize {::bal} defined here ... LL | let _: usize = X::bal; | ----- ^^^^^^ expected `usize`, found fn item @@ -246,7 +246,7 @@ LL | let _: usize = X::bal; | expected due to this | = note: expected type `usize` - found fn item `for<'a> fn(&'a X) -> usize {::bal}` + found fn item `fn(&X) -> usize {::bal}` help: use parentheses to call this associated function | LL | let _: usize = X::bal(/* &X */); diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr index 872263fd7311b..323504d0b16b7 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr +++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr @@ -7,11 +7,11 @@ LL | | t.test(); LL | | }); | |______^ | -note: the parameter type `T` must be valid for the anonymous lifetime defined here... - --> $DIR/missing-lifetimes-in-signature-2.rs:19:24 +note: the parameter type `T` must be valid for the anonymous lifetime as defined here... + --> $DIR/missing-lifetimes-in-signature-2.rs:19:23 | LL | fn func(foo: &Foo, t: T) { - | ^^^ + | ^ note: ...so that the type `T` will meet its required lifetime bounds --> $DIR/missing-lifetimes-in-signature-2.rs:20:5 | diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr index fa758bf05df5a..4a5e7f3b795f6 100644 --- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr +++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr @@ -10,7 +10,7 @@ error[E0700]: hidden type for `impl FnOnce()` captures lifetime that does not ap --> $DIR/missing-lifetimes-in-signature.rs:19:5 | LL | fn foo(g: G, dest: &mut T) -> impl FnOnce() - | ------ hidden type `[closure@$DIR/missing-lifetimes-in-signature.rs:19:5: 19:12]` captures the anonymous lifetime defined here + | - hidden type `[closure@$DIR/missing-lifetimes-in-signature.rs:19:5: 19:12]` captures the anonymous lifetime as defined here ... LL | / move || { LL | | @@ -32,11 +32,11 @@ LL | | *dest = g.get(); LL | | } | |_____^ | -note: the parameter type `G` must be valid for the anonymous lifetime defined here... +note: the parameter type `G` must be valid for the anonymous lifetime as defined here... --> $DIR/missing-lifetimes-in-signature.rs:26:26 | LL | fn bar(g: G, dest: &mut T) -> impl FnOnce() + '_ - | ^^^^^^ + | ^ note: ...so that the type `G` will meet its required lifetime bounds --> $DIR/missing-lifetimes-in-signature.rs:30:5 | @@ -61,11 +61,11 @@ LL | | *dest = g.get(); LL | | } | |_____^ | -note: the parameter type `G` must be valid for the anonymous lifetime defined here... +note: the parameter type `G` must be valid for the anonymous lifetime as defined here... --> $DIR/missing-lifetimes-in-signature.rs:48:34 | LL | fn qux<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ - | ^^^^^^ + | ^ note: ...so that the type `G` will meet its required lifetime bounds --> $DIR/missing-lifetimes-in-signature.rs:52:5 | @@ -88,11 +88,11 @@ LL | | *dest = g.get(); LL | | } | |_________^ | -note: the parameter type `G` must be valid for the anonymous lifetime defined here... +note: the parameter type `G` must be valid for the anonymous lifetime as defined here... --> $DIR/missing-lifetimes-in-signature.rs:60:47 | LL | fn qux<'b, G: Get + 'b, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ { - | ^^^^^^ + | ^ note: ...so that the type `G` will meet its required lifetime bounds --> $DIR/missing-lifetimes-in-signature.rs:61:9 | @@ -116,11 +116,11 @@ LL | | *dest = g.get(); LL | | } | |_____^ | -note: the parameter type `G` must be valid for the anonymous lifetime defined here... +note: the parameter type `G` must be valid for the anonymous lifetime as defined here... --> $DIR/missing-lifetimes-in-signature.rs:69:34 | LL | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a - | ^^^^^^ + | ^ note: ...so that the type `G` will meet its required lifetime bounds --> $DIR/missing-lifetimes-in-signature.rs:73:5 | diff --git a/src/test/ui/traits/issue-77982.stderr b/src/test/ui/traits/issue-77982.stderr index e210f11b3e0c1..06d78ca8b85e9 100644 --- a/src/test/ui/traits/issue-77982.stderr +++ b/src/test/ui/traits/issue-77982.stderr @@ -17,8 +17,8 @@ LL | K: Borrow, | ^^^^^^^^^ required by this bound in `HashMap::::get` help: consider specifying the generic argument | -LL | opts.get::(opt.as_ref()); - | +++++ +LL | opts.get::<'_>(opt.as_ref()); + | ++++++ error[E0283]: type annotations needed --> $DIR/issue-77982.rs:8:10 @@ -35,8 +35,8 @@ LL | opts.get(opt.as_ref()); - impl AsRef for String; help: consider specifying the generic argument | -LL | opts.get::(opt.as_ref()); - | +++++ +LL | opts.get::<'_>(opt.as_ref()); + | ++++++ error[E0283]: type annotations needed --> $DIR/issue-77982.rs:13:59 diff --git a/src/test/ui/traits/test-2.stderr b/src/test/ui/traits/test-2.stderr index eaa20b0b4f4f1..fd89558896ffa 100644 --- a/src/test/ui/traits/test-2.stderr +++ b/src/test/ui/traits/test-2.stderr @@ -20,11 +20,11 @@ LL | 10.blah::(); | | | expected 1 generic argument | -note: associated function defined here, with 1 generic parameter: `X` +note: associated function defined here, with 1 generic parameter: `'_` --> $DIR/test-2.rs:4:39 | LL | trait bar { fn dup(&self) -> Self; fn blah(&self); } - | ^^^^ - + | ^^^^ - error[E0038]: the trait `bar` cannot be made into an object --> $DIR/test-2.rs:13:22 diff --git a/src/test/ui/type-alias-impl-trait/constrain_inputs.rs b/src/test/ui/type-alias-impl-trait/constrain_inputs.rs index 03fb64b7b94d7..1d2d98cebc772 100644 --- a/src/test/ui/type-alias-impl-trait/constrain_inputs.rs +++ b/src/test/ui/type-alias-impl-trait/constrain_inputs.rs @@ -4,7 +4,6 @@ mod lifetime_params { type Ty<'a> = impl Sized; fn defining(s: &str) -> Ty<'_> { s } fn execute(ty: Ty<'_>) -> &str { todo!() } - //~^ ERROR return type references an anonymous lifetime, which is not constrained by the fn input types type BadFnSig = fn(Ty<'_>) -> &str; //~^ ERROR return type references an anonymous lifetime, which is not constrained by the fn input types @@ -16,7 +15,6 @@ mod lifetime_params_2 { type Ty<'a> = impl FnOnce() -> &'a str; fn defining(s: &str) -> Ty<'_> { move || s } fn execute(ty: Ty<'_>) -> &str { ty() } - //~^ ERROR return type references an anonymous lifetime, which is not constrained by the fn input types } // regression test for https://github.com/rust-lang/rust/issues/97104 diff --git a/src/test/ui/type-alias-impl-trait/constrain_inputs.stderr b/src/test/ui/type-alias-impl-trait/constrain_inputs.stderr index 93953fd06d1fd..5721611e013bf 100644 --- a/src/test/ui/type-alias-impl-trait/constrain_inputs.stderr +++ b/src/test/ui/type-alias-impl-trait/constrain_inputs.stderr @@ -1,14 +1,5 @@ error[E0581]: return type references an anonymous lifetime, which is not constrained by the fn input types - --> $DIR/constrain_inputs.rs:6:31 - | -LL | fn execute(ty: Ty<'_>) -> &str { todo!() } - | ^^^^ - | - = note: lifetimes appearing in an associated or opaque type are not considered constrained - = note: consider introducing a named lifetime parameter - -error[E0581]: return type references an anonymous lifetime, which is not constrained by the fn input types - --> $DIR/constrain_inputs.rs:9:35 + --> $DIR/constrain_inputs.rs:8:35 | LL | type BadFnSig = fn(Ty<'_>) -> &str; | ^^^^ @@ -17,7 +8,7 @@ LL | type BadFnSig = fn(Ty<'_>) -> &str; = note: consider introducing a named lifetime parameter error[E0582]: binding for associated type `Output` references an anonymous lifetime, which does not appear in the trait input types - --> $DIR/constrain_inputs.rs:11:42 + --> $DIR/constrain_inputs.rs:10:42 | LL | type BadTraitRef = dyn Fn(Ty<'_>) -> &str; | ^^^^ @@ -26,16 +17,7 @@ LL | type BadTraitRef = dyn Fn(Ty<'_>) -> &str; = note: consider introducing a named lifetime parameter error[E0581]: return type references an anonymous lifetime, which is not constrained by the fn input types - --> $DIR/constrain_inputs.rs:18:31 - | -LL | fn execute(ty: Ty<'_>) -> &str { ty() } - | ^^^^ - | - = note: lifetimes appearing in an associated or opaque type are not considered constrained - = note: consider introducing a named lifetime parameter - -error[E0581]: return type references an anonymous lifetime, which is not constrained by the fn input types - --> $DIR/constrain_inputs.rs:27:37 + --> $DIR/constrain_inputs.rs:25:37 | LL | type BadFnSig = fn(Ty<&str>) -> &str; | ^^^^ @@ -44,7 +26,7 @@ LL | type BadFnSig = fn(Ty<&str>) -> &str; = note: consider introducing a named lifetime parameter error[E0582]: binding for associated type `Output` references an anonymous lifetime, which does not appear in the trait input types - --> $DIR/constrain_inputs.rs:29:44 + --> $DIR/constrain_inputs.rs:27:44 | LL | type BadTraitRef = dyn Fn(Ty<&str>) -> &str; | ^^^^ @@ -52,7 +34,7 @@ LL | type BadTraitRef = dyn Fn(Ty<&str>) -> &str; = note: lifetimes appearing in an associated or opaque type are not considered constrained = note: consider introducing a named lifetime parameter -error: aborting due to 6 previous errors +error: aborting due to 4 previous errors Some errors have detailed explanations: E0581, E0582. For more information about an error, try `rustc --explain E0581`. diff --git a/src/test/ui/ufcs/ufcs-explicit-self-bad.stderr b/src/test/ui/ufcs/ufcs-explicit-self-bad.stderr index f325d1d8182f1..22075cf3e7591 100644 --- a/src/test/ui/ufcs/ufcs-explicit-self-bad.stderr +++ b/src/test/ui/ufcs/ufcs-explicit-self-bad.stderr @@ -33,11 +33,11 @@ LL | fn dummy2(self: &Bar) {} | = note: expected reference `&'a Bar` found reference `&Bar` -note: the anonymous lifetime defined here... +note: the anonymous lifetime as defined here... --> $DIR/ufcs-explicit-self-bad.rs:37:21 | LL | fn dummy2(self: &Bar) {} - | ^^^^^^^ + | ^ note: ...does not necessarily outlive the lifetime `'a` as defined here --> $DIR/ufcs-explicit-self-bad.rs:35:6 | @@ -57,11 +57,11 @@ note: the lifetime `'a` as defined here... | LL | impl<'a, T> SomeTrait for &'a Bar { | ^^ -note: ...does not necessarily outlive the anonymous lifetime defined here +note: ...does not necessarily outlive the anonymous lifetime as defined here --> $DIR/ufcs-explicit-self-bad.rs:37:21 | LL | fn dummy2(self: &Bar) {} - | ^^^^^^^ + | ^ error[E0308]: mismatched `self` parameter type --> $DIR/ufcs-explicit-self-bad.rs:39:21 @@ -71,11 +71,11 @@ LL | fn dummy3(self: &&Bar) {} | = note: expected reference `&'a Bar` found reference `&Bar` -note: the anonymous lifetime defined here... - --> $DIR/ufcs-explicit-self-bad.rs:39:22 +note: the anonymous lifetime as defined here... + --> $DIR/ufcs-explicit-self-bad.rs:39:21 | LL | fn dummy3(self: &&Bar) {} - | ^^^^^^^ + | ^ note: ...does not necessarily outlive the lifetime `'a` as defined here --> $DIR/ufcs-explicit-self-bad.rs:35:6 | @@ -95,11 +95,11 @@ note: the lifetime `'a` as defined here... | LL | impl<'a, T> SomeTrait for &'a Bar { | ^^ -note: ...does not necessarily outlive the anonymous lifetime defined here - --> $DIR/ufcs-explicit-self-bad.rs:39:22 +note: ...does not necessarily outlive the anonymous lifetime as defined here + --> $DIR/ufcs-explicit-self-bad.rs:39:21 | LL | fn dummy3(self: &&Bar) {} - | ^^^^^^^ + | ^ error: aborting due to 7 previous errors diff --git a/src/test/ui/unboxed-closures/unboxed-closures-unsafe-extern-fn.stderr b/src/test/ui/unboxed-closures/unboxed-closures-unsafe-extern-fn.stderr index 802696e1b2f94..c17269294db6c 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-unsafe-extern-fn.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-unsafe-extern-fn.stderr @@ -1,4 +1,4 @@ -error[E0277]: expected a `Fn<(&isize,)>` closure, found `for<'a> unsafe fn(&'a isize) -> isize {square}` +error[E0277]: expected a `Fn<(&isize,)>` closure, found `unsafe fn(&isize) -> isize {square}` --> $DIR/unboxed-closures-unsafe-extern-fn.rs:20:21 | LL | let x = call_it(&square, 22); @@ -6,7 +6,7 @@ LL | let x = call_it(&square, 22); | | | required by a bound introduced by this call | - = help: the trait `for<'a> Fn<(&'a isize,)>` is not implemented for fn item `for<'a> unsafe fn(&'a isize) -> isize {square}` + = help: the trait `for<'a> Fn<(&'a isize,)>` is not implemented for fn item `unsafe fn(&isize) -> isize {square}` = note: unsafe function cannot be called generically without an unsafe block note: required by a bound in `call_it` --> $DIR/unboxed-closures-unsafe-extern-fn.rs:9:15 @@ -14,7 +14,7 @@ note: required by a bound in `call_it` LL | fn call_it isize>(_: &F, _: isize) -> isize { | ^^^^^^^^^^^^^^^^^^^ required by this bound in `call_it` -error[E0277]: expected a `FnMut<(&isize,)>` closure, found `for<'a> unsafe fn(&'a isize) -> isize {square}` +error[E0277]: expected a `FnMut<(&isize,)>` closure, found `unsafe fn(&isize) -> isize {square}` --> $DIR/unboxed-closures-unsafe-extern-fn.rs:25:25 | LL | let y = call_it_mut(&mut square, 22); @@ -22,7 +22,7 @@ LL | let y = call_it_mut(&mut square, 22); | | | required by a bound introduced by this call | - = help: the trait `for<'a> FnMut<(&'a isize,)>` is not implemented for fn item `for<'a> unsafe fn(&'a isize) -> isize {square}` + = help: the trait `for<'a> FnMut<(&'a isize,)>` is not implemented for fn item `unsafe fn(&isize) -> isize {square}` = note: unsafe function cannot be called generically without an unsafe block note: required by a bound in `call_it_mut` --> $DIR/unboxed-closures-unsafe-extern-fn.rs:12:19 @@ -30,7 +30,7 @@ note: required by a bound in `call_it_mut` LL | fn call_it_mut isize>(_: &mut F, _: isize) -> isize { | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `call_it_mut` -error[E0277]: expected a `FnOnce<(&isize,)>` closure, found `for<'a> unsafe fn(&'a isize) -> isize {square}` +error[E0277]: expected a `FnOnce<(&isize,)>` closure, found `unsafe fn(&isize) -> isize {square}` --> $DIR/unboxed-closures-unsafe-extern-fn.rs:30:26 | LL | let z = call_it_once(square, 22); @@ -38,7 +38,7 @@ LL | let z = call_it_once(square, 22); | | | required by a bound introduced by this call | - = help: the trait `for<'a> FnOnce<(&'a isize,)>` is not implemented for fn item `for<'a> unsafe fn(&'a isize) -> isize {square}` + = help: the trait `for<'a> FnOnce<(&'a isize,)>` is not implemented for fn item `unsafe fn(&isize) -> isize {square}` = note: unsafe function cannot be called generically without an unsafe block note: required by a bound in `call_it_once` --> $DIR/unboxed-closures-unsafe-extern-fn.rs:15:20 diff --git a/src/test/ui/unboxed-closures/unboxed-closures-wrong-abi.stderr b/src/test/ui/unboxed-closures/unboxed-closures-wrong-abi.stderr index 0bbb9836c5840..4f864ea19b6bf 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-wrong-abi.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-wrong-abi.stderr @@ -1,42 +1,42 @@ -error[E0277]: expected a `Fn<(&isize,)>` closure, found `for<'a> extern "C" fn(&'a isize) -> isize {square}` +error[E0277]: expected a `Fn<(&isize,)>` closure, found `extern "C" fn(&isize) -> isize {square}` --> $DIR/unboxed-closures-wrong-abi.rs:20:21 | LL | let x = call_it(&square, 22); - | ------- ^^^^^^^ expected an `Fn<(&isize,)>` closure, found `for<'a> extern "C" fn(&'a isize) -> isize {square}` + | ------- ^^^^^^^ expected an `Fn<(&isize,)>` closure, found `extern "C" fn(&isize) -> isize {square}` | | | required by a bound introduced by this call | - = help: the trait `for<'a> Fn<(&'a isize,)>` is not implemented for fn item `for<'a> extern "C" fn(&'a isize) -> isize {square}` + = help: the trait `for<'a> Fn<(&'a isize,)>` is not implemented for fn item `extern "C" fn(&isize) -> isize {square}` note: required by a bound in `call_it` --> $DIR/unboxed-closures-wrong-abi.rs:9:15 | LL | fn call_it isize>(_: &F, _: isize) -> isize { | ^^^^^^^^^^^^^^^^^^^ required by this bound in `call_it` -error[E0277]: expected a `FnMut<(&isize,)>` closure, found `for<'a> extern "C" fn(&'a isize) -> isize {square}` +error[E0277]: expected a `FnMut<(&isize,)>` closure, found `extern "C" fn(&isize) -> isize {square}` --> $DIR/unboxed-closures-wrong-abi.rs:25:25 | LL | let y = call_it_mut(&mut square, 22); - | ----------- ^^^^^^^^^^^ expected an `FnMut<(&isize,)>` closure, found `for<'a> extern "C" fn(&'a isize) -> isize {square}` + | ----------- ^^^^^^^^^^^ expected an `FnMut<(&isize,)>` closure, found `extern "C" fn(&isize) -> isize {square}` | | | required by a bound introduced by this call | - = help: the trait `for<'a> FnMut<(&'a isize,)>` is not implemented for fn item `for<'a> extern "C" fn(&'a isize) -> isize {square}` + = help: the trait `for<'a> FnMut<(&'a isize,)>` is not implemented for fn item `extern "C" fn(&isize) -> isize {square}` note: required by a bound in `call_it_mut` --> $DIR/unboxed-closures-wrong-abi.rs:12:19 | LL | fn call_it_mut isize>(_: &mut F, _: isize) -> isize { | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `call_it_mut` -error[E0277]: expected a `FnOnce<(&isize,)>` closure, found `for<'a> extern "C" fn(&'a isize) -> isize {square}` +error[E0277]: expected a `FnOnce<(&isize,)>` closure, found `extern "C" fn(&isize) -> isize {square}` --> $DIR/unboxed-closures-wrong-abi.rs:30:26 | LL | let z = call_it_once(square, 22); - | ------------ ^^^^^^ expected an `FnOnce<(&isize,)>` closure, found `for<'a> extern "C" fn(&'a isize) -> isize {square}` + | ------------ ^^^^^^ expected an `FnOnce<(&isize,)>` closure, found `extern "C" fn(&isize) -> isize {square}` | | | required by a bound introduced by this call | - = help: the trait `for<'a> FnOnce<(&'a isize,)>` is not implemented for fn item `for<'a> extern "C" fn(&'a isize) -> isize {square}` + = help: the trait `for<'a> FnOnce<(&'a isize,)>` is not implemented for fn item `extern "C" fn(&isize) -> isize {square}` note: required by a bound in `call_it_once` --> $DIR/unboxed-closures-wrong-abi.rs:15:20 | diff --git a/src/test/ui/where-clauses/higher-ranked-fn-type.rs b/src/test/ui/where-clauses/higher-ranked-fn-type.rs index ab6edde4ee7ea..cb5c17a770955 100644 --- a/src/test/ui/where-clauses/higher-ranked-fn-type.rs +++ b/src/test/ui/where-clauses/higher-ranked-fn-type.rs @@ -19,7 +19,7 @@ where { called() //[quiet]~^ ERROR the trait bound `for<'b> fn(&'b ()): Foo` is not satisfied - //[verbose]~^^ ERROR the trait bound `for<'b> fn(&ReLateBound( + //[verbose]~^^ ERROR the trait bound `for<'b^0> fn(&'b^0_1 ()): Foo` is not satisfied } fn main() {} diff --git a/src/test/ui/where-clauses/higher-ranked-fn-type.verbose.stderr b/src/test/ui/where-clauses/higher-ranked-fn-type.verbose.stderr index 24660ec3539e6..397bde617c2f0 100644 --- a/src/test/ui/where-clauses/higher-ranked-fn-type.verbose.stderr +++ b/src/test/ui/where-clauses/higher-ranked-fn-type.verbose.stderr @@ -1,8 +1,8 @@ -error[E0277]: the trait bound `for<'b> fn(&ReLateBound(DebruijnIndex(1), BoundRegion { var: 0, kind: BrNamed(DefId(0:6 ~ higher_ranked_fn_type[1209]::called::'b), 'b) }) ()): Foo` is not satisfied +error[E0277]: the trait bound `for<'b^0> fn(&'b^0_1 ()): Foo` is not satisfied --> $DIR/higher-ranked-fn-type.rs:20:5 | LL | called() - | ^^^^^^ the trait `for<'b> Foo` is not implemented for `fn(&ReLateBound(DebruijnIndex(1), BoundRegion { var: 0, kind: BrNamed(DefId(0:6 ~ higher_ranked_fn_type[1209]::called::'b), 'b) }) ())` + | ^^^^^^ the trait `for<'b^0> Foo` is not implemented for `fn(&'b^0_1 ())` | note: required by a bound in `called` --> $DIR/higher-ranked-fn-type.rs:12:25 diff --git a/src/tools/clippy/clippy_lints/src/casts/as_ptr_cast_mut.rs b/src/tools/clippy/clippy_lints/src/casts/as_ptr_cast_mut.rs index 9409f4844f54b..4776518419d86 100644 --- a/src/tools/clippy/clippy_lints/src/casts/as_ptr_cast_mut.rs +++ b/src/tools/clippy/clippy_lints/src/casts/as_ptr_cast_mut.rs @@ -18,7 +18,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>, && method_name.ident.name == rustc_span::sym::as_ptr && let Some(as_ptr_did) = cx.typeck_results().type_dependent_def_id(cast_expr.peel_blocks().hir_id) && let as_ptr_sig = cx.tcx.fn_sig(as_ptr_did) - && let Some(first_param_ty) = as_ptr_sig.skip_binder().inputs().iter().next() + && let Some(first_param_ty) = as_ptr_sig.inputs().iter().next() && let ty::Ref(_, _, Mutability::Not) = first_param_ty.kind() && let Some(recv) = snippet_opt(cx, receiver.span) { diff --git a/src/tools/clippy/clippy_lints/src/default_numeric_fallback.rs b/src/tools/clippy/clippy_lints/src/default_numeric_fallback.rs index 03460689e19ad..477aaccd884c9 100644 --- a/src/tools/clippy/clippy_lints/src/default_numeric_fallback.rs +++ b/src/tools/clippy/clippy_lints/src/default_numeric_fallback.rs @@ -129,7 +129,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NumericFallbackVisitor<'a, 'tcx> { match &expr.kind { ExprKind::Call(func, args) => { if let Some(fn_sig) = fn_sig_opt(self.cx, func.hir_id) { - for (expr, bound) in iter::zip(*args, fn_sig.skip_binder().inputs()) { + for (expr, bound) in iter::zip(*args, fn_sig.inputs().skip_binder()) { // Push found arg type, then visit arg. self.ty_bounds.push((*bound).into()); self.visit_expr(expr); @@ -141,7 +141,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NumericFallbackVisitor<'a, 'tcx> { ExprKind::MethodCall(_, receiver, args, _) => { if let Some(def_id) = self.cx.typeck_results().type_dependent_def_id(expr.hir_id) { - let fn_sig = self.cx.tcx.fn_sig(def_id).skip_binder(); + let fn_sig = self.cx.tcx.fn_sig(def_id); for (expr, bound) in iter::zip(std::iter::once(*receiver).chain(args.iter()), fn_sig.inputs()) { self.ty_bounds.push((*bound).into()); self.visit_expr(expr); @@ -215,7 +215,7 @@ fn fn_sig_opt<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId) -> Option Some(cx.tcx.fn_sig(*def_id)), + ty::FnDef(def_id, _) => Some(ty::Binder::dummy(cx.tcx.fn_sig(*def_id))), ty::FnPtr(fn_sig) => Some(*fn_sig), _ => None, } diff --git a/src/tools/clippy/clippy_lints/src/dereference.rs b/src/tools/clippy/clippy_lints/src/dereference.rs index a95d9f5390de3..e949e8483a86c 100644 --- a/src/tools/clippy/clippy_lints/src/dereference.rs +++ b/src/tools/clippy/clippy_lints/src/dereference.rs @@ -753,9 +753,7 @@ fn walk_parents<'tcx>( span, .. }) if span.ctxt() == ctxt => { - let output = cx - .tcx - .erase_late_bound_regions(cx.tcx.fn_sig(def_id.to_def_id()).output()); + let output = cx.tcx.fn_sig(def_id.to_def_id()).output(); Some(ty_auto_deref_stability(cx, output, precedence).position_for_result(cx)) }, @@ -785,9 +783,7 @@ fn walk_parents<'tcx>( { closure_result_position(cx, closure, cx.typeck_results().expr_ty(closure_expr), precedence) } else { - let output = cx - .tcx - .erase_late_bound_regions(cx.tcx.fn_sig(cx.tcx.hir().local_def_id(owner_id)).output()); + let output = cx.tcx.fn_sig(cx.tcx.hir().local_def_id(owner_id)).output(); ty_auto_deref_stability(cx, output, precedence).position_for_result(cx) }, ) @@ -849,7 +845,7 @@ fn walk_parents<'tcx>( { Some(subs) => cx.tcx.mk_substs(subs.iter().copied()), None => cx.tcx.mk_substs(std::iter::empty::>()), - } && let impl_ty = if cx.tcx.fn_sig(id).skip_binder().inputs()[0].is_ref() { + } && let impl_ty = if cx.tcx.fn_sig(id).input(0).is_ref() { // Trait methods taking `&self` sub_ty } else { @@ -866,7 +862,7 @@ fn walk_parents<'tcx>( return Some(Position::MethodReceiver); } args.iter().position(|arg| arg.hir_id == child_id).map(|i| { - let ty = cx.tcx.fn_sig(id).skip_binder().inputs()[i + 1]; + let ty = cx.tcx.fn_sig(id).input(i + 1); if let ty::Param(param_ty) = ty.kind() { needless_borrow_impl_arg_position( cx, @@ -879,12 +875,7 @@ fn walk_parents<'tcx>( msrv, ) } else { - ty_auto_deref_stability( - cx, - cx.tcx.erase_late_bound_regions(cx.tcx.fn_sig(id).input(i + 1)), - precedence, - ) - .position_for_arg() + ty_auto_deref_stability(cx, cx.tcx.fn_sig(id).input(i + 1), precedence).position_for_arg() } }) }, @@ -1066,7 +1057,7 @@ fn needless_borrow_impl_arg_position<'tcx>( let sized_trait_def_id = cx.tcx.lang_items().sized_trait(); let Some(callee_def_id) = fn_def_id(cx, parent) else { return Position::Other(precedence) }; - let fn_sig = cx.tcx.fn_sig(callee_def_id).skip_binder(); + let fn_sig = cx.tcx.fn_sig(callee_def_id); let substs_with_expr_ty = cx .typeck_results() .node_substs(if let ExprKind::Call(callee, _) = parent.kind { @@ -1184,7 +1175,7 @@ fn has_ref_mut_self_method(cx: &LateContext<'_>, trait_def_id: DefId) -> bool { .in_definition_order() .any(|assoc_item| { if assoc_item.fn_has_self_parameter { - let self_ty = cx.tcx.fn_sig(assoc_item.def_id).skip_binder().inputs()[0]; + let self_ty = cx.tcx.fn_sig(assoc_item.def_id).input(0); matches!(self_ty.kind(), ty::Ref(_, _, Mutability::Mut)) } else { false diff --git a/src/tools/clippy/clippy_lints/src/eta_reduction.rs b/src/tools/clippy/clippy_lints/src/eta_reduction.rs index 7b9786d7e570f..8ce91a59c721b 100644 --- a/src/tools/clippy/clippy_lints/src/eta_reduction.rs +++ b/src/tools/clippy/clippy_lints/src/eta_reduction.rs @@ -111,8 +111,6 @@ impl<'tcx> LateLintPass<'tcx> for EtaReduction { .map_or(callee_ty, |id| cx.tcx.type_of(id)); if check_sig(cx, closure_ty, call_ty); let substs = cx.typeck_results().node_substs(callee.hir_id); - // This fixes some false positives that I don't entirely understand - if substs.is_empty() || !cx.typeck_results().expr_ty(expr).has_late_bound_regions(); // A type param function ref like `T::f` is not 'static, however // it is if cast like `T::f as fn()`. This seems like a rustc bug. if !substs.types().any(|t| matches!(t.kind(), ty::Param(_))); @@ -217,7 +215,7 @@ fn check_sig<'tcx>(cx: &LateContext<'tcx>, closure_ty: Ty<'tcx>, call_ty: Ty<'tc return false; }; let closure_sig = cx.tcx.signature_unclosure(substs.as_closure().sig(), Unsafety::Normal); - cx.tcx.erase_late_bound_regions(closure_sig) == cx.tcx.erase_late_bound_regions(call_sig) + cx.tcx.anonymize_late_bound_regions(closure_sig) == cx.tcx.anonymize_late_bound_regions(call_sig) } fn get_ufcs_type_name(cx: &LateContext<'_>, method_def_id: DefId) -> String { diff --git a/src/tools/clippy/clippy_lints/src/functions/not_unsafe_ptr_arg_deref.rs b/src/tools/clippy/clippy_lints/src/functions/not_unsafe_ptr_arg_deref.rs index b7595d101e0fa..5096a0acd4a7f 100644 --- a/src/tools/clippy/clippy_lints/src/functions/not_unsafe_ptr_arg_deref.rs +++ b/src/tools/clippy/clippy_lints/src/functions/not_unsafe_ptr_arg_deref.rs @@ -58,7 +58,7 @@ fn check_raw_ptr<'tcx>( }, hir::ExprKind::MethodCall(_, recv, args, _) => { let def_id = typeck.type_dependent_def_id(e.hir_id).unwrap(); - if cx.tcx.fn_sig(def_id).skip_binder().unsafety == hir::Unsafety::Unsafe { + if cx.tcx.fn_sig(def_id).unsafety == hir::Unsafety::Unsafe { check_arg(cx, &raw_ptrs, recv); for arg in args { check_arg(cx, &raw_ptrs, arg); diff --git a/src/tools/clippy/clippy_lints/src/functions/result.rs b/src/tools/clippy/clippy_lints/src/functions/result.rs index 113c4e9f50910..db90d648de433 100644 --- a/src/tools/clippy/clippy_lints/src/functions/result.rs +++ b/src/tools/clippy/clippy_lints/src/functions/result.rs @@ -21,7 +21,7 @@ fn result_err_ty<'tcx>( ) -> Option<(&'tcx hir::Ty<'tcx>, Ty<'tcx>)> { if !in_external_macro(cx.sess(), item_span) && let hir::FnRetTy::Return(hir_ty) = decl.output - && let ty = cx.tcx.erase_late_bound_regions(cx.tcx.fn_sig(id).output()) + && let ty = cx.tcx.fn_sig(id).output() && is_type_diagnostic_item(cx, ty, sym::Result) && let ty::Adt(_, substs) = ty.kind() { diff --git a/src/tools/clippy/clippy_lints/src/inherent_to_string.rs b/src/tools/clippy/clippy_lints/src/inherent_to_string.rs index 676136df572bd..171e5fa162686 100644 --- a/src/tools/clippy/clippy_lints/src/inherent_to_string.rs +++ b/src/tools/clippy/clippy_lints/src/inherent_to_string.rs @@ -125,7 +125,7 @@ fn show_lint(cx: &LateContext<'_>, item: &ImplItem<'_>) { // Get the real type of 'self' let self_type = cx.tcx.fn_sig(item.def_id).input(0); - let self_type = self_type.skip_binder().peel_refs(); + let self_type = self_type.peel_refs(); // Emit either a warning or an error if implements_trait(cx, self_type, display_trait_id, &[]) { diff --git a/src/tools/clippy/clippy_lints/src/iter_not_returning_iterator.rs b/src/tools/clippy/clippy_lints/src/iter_not_returning_iterator.rs index ea9f046fb9736..6a50adc5696a1 100644 --- a/src/tools/clippy/clippy_lints/src/iter_not_returning_iterator.rs +++ b/src/tools/clippy/clippy_lints/src/iter_not_returning_iterator.rs @@ -66,7 +66,7 @@ impl<'tcx> LateLintPass<'tcx> for IterNotReturningIterator { fn check_sig(cx: &LateContext<'_>, name: &str, sig: &FnSig<'_>, fn_id: LocalDefId) { if sig.decl.implicit_self.has_implicit_self() { - let ret_ty = cx.tcx.erase_late_bound_regions(cx.tcx.fn_sig(fn_id).output()); + let ret_ty = cx.tcx.fn_sig(fn_id).output(); let ret_ty = cx .tcx .try_normalize_erasing_regions(cx.param_env, ret_ty) diff --git a/src/tools/clippy/clippy_lints/src/len_zero.rs b/src/tools/clippy/clippy_lints/src/len_zero.rs index 3a563736fb077..6a8597e963283 100644 --- a/src/tools/clippy/clippy_lints/src/len_zero.rs +++ b/src/tools/clippy/clippy_lints/src/len_zero.rs @@ -143,7 +143,7 @@ impl<'tcx> LateLintPass<'tcx> for LenZero { if let Some(local_id) = ty_id.as_local(); let ty_hir_id = cx.tcx.hir().local_def_id_to_hir_id(local_id); if !is_lint_allowed(cx, LEN_WITHOUT_IS_EMPTY, ty_hir_id); - if let Some(output) = parse_len_output(cx, cx.tcx.fn_sig(item.def_id).skip_binder()); + if let Some(output) = parse_len_output(cx, cx.tcx.fn_sig(item.def_id)); then { let (name, kind) = match cx.tcx.hir().find(ty_hir_id) { Some(Node::ForeignItem(x)) => (x.ident.name, "extern type"), @@ -195,7 +195,7 @@ fn check_trait_items(cx: &LateContext<'_>, visited_trait: &Item<'_>, trait_items fn is_named_self(cx: &LateContext<'_>, item: &TraitItemRef, name: Symbol) -> bool { item.ident.name == name && if let AssocItemKind::Fn { has_self } = item.kind { - has_self && { cx.tcx.fn_sig(item.id.def_id).inputs().skip_binder().len() == 1 } + has_self && { cx.tcx.fn_sig(item.id.def_id).inputs().len() == 1 } } else { false } @@ -221,9 +221,7 @@ fn check_trait_items(cx: &LateContext<'_>, visited_trait: &Item<'_>, trait_items .iter() .flat_map(|&i| cx.tcx.associated_items(i).filter_by_name_unhygienic(is_empty)) .any(|i| { - i.kind == ty::AssocKind::Fn - && i.fn_has_self_parameter - && cx.tcx.fn_sig(i.def_id).inputs().skip_binder().len() == 1 + i.kind == ty::AssocKind::Fn && i.fn_has_self_parameter && cx.tcx.fn_sig(i.def_id).inputs().len() == 1 }); if !is_empty_method_found { @@ -341,7 +339,7 @@ fn check_for_is_empty<'tcx>( ), Some(is_empty) if !(is_empty.fn_has_self_parameter - && check_is_empty_sig(cx.tcx.fn_sig(is_empty.def_id).skip_binder(), self_kind, output)) => + && check_is_empty_sig(cx.tcx.fn_sig(is_empty.def_id), self_kind, output)) => { ( format!( @@ -467,8 +465,7 @@ fn has_is_empty(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { fn is_is_empty(cx: &LateContext<'_>, item: &ty::AssocItem) -> bool { if item.kind == ty::AssocKind::Fn { let sig = cx.tcx.fn_sig(item.def_id); - let ty = sig.skip_binder(); - ty.inputs().len() == 1 + sig.inputs().len() == 1 } else { false } diff --git a/src/tools/clippy/clippy_lints/src/loops/needless_range_loop.rs b/src/tools/clippy/clippy_lints/src/loops/needless_range_loop.rs index 27ba27202bf7e..2527ab06f651b 100644 --- a/src/tools/clippy/clippy_lints/src/loops/needless_range_loop.rs +++ b/src/tools/clippy/clippy_lints/src/loops/needless_range_loop.rs @@ -370,7 +370,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> { ExprKind::MethodCall(_, receiver, args, _) => { let def_id = self.cx.typeck_results().type_dependent_def_id(expr.hir_id).unwrap(); for (ty, expr) in iter::zip( - self.cx.tcx.fn_sig(def_id).inputs().skip_binder(), + self.cx.tcx.fn_sig(def_id).inputs(), std::iter::once(receiver).chain(args.iter()), ) { self.prefer_mutable = false; diff --git a/src/tools/clippy/clippy_lints/src/map_unit_fn.rs b/src/tools/clippy/clippy_lints/src/map_unit_fn.rs index 32da37a862d8c..16ac42ade3d1f 100644 --- a/src/tools/clippy/clippy_lints/src/map_unit_fn.rs +++ b/src/tools/clippy/clippy_lints/src/map_unit_fn.rs @@ -104,9 +104,8 @@ fn is_unit_function(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> bool { let ty = cx.typeck_results().expr_ty(expr); if let ty::FnDef(id, _) = *ty.kind() { - if let Some(fn_type) = cx.tcx.fn_sig(id).no_bound_vars() { - return is_unit_type(fn_type.output()); - } + let fn_type = cx.tcx.fn_sig(id); + return is_unit_type(fn_type.output()); } false } diff --git a/src/tools/clippy/clippy_lints/src/methods/expect_fun_call.rs b/src/tools/clippy/clippy_lints/src/methods/expect_fun_call.rs index d0cf411dfd34c..07ab719f495ce 100644 --- a/src/tools/clippy/clippy_lints/src/methods/expect_fun_call.rs +++ b/src/tools/clippy/clippy_lints/src/methods/expect_fun_call.rs @@ -70,7 +70,7 @@ pub(super) fn check<'tcx>( if let hir::ExprKind::Path(ref p) = fun.kind { match cx.qpath_res(p, fun.hir_id) { hir::def::Res::Def(hir::def::DefKind::Fn | hir::def::DefKind::AssocFn, def_id) => matches!( - cx.tcx.fn_sig(def_id).output().skip_binder().kind(), + cx.tcx.fn_sig(def_id).output().kind(), ty::Ref(re, ..) if re.is_static(), ), _ => false, @@ -84,7 +84,7 @@ pub(super) fn check<'tcx>( .type_dependent_def_id(arg.hir_id) .map_or(false, |method_id| { matches!( - cx.tcx.fn_sig(method_id).output().skip_binder().kind(), + cx.tcx.fn_sig(method_id).output().kind(), ty::Ref(re, ..) if re.is_static() ) }) diff --git a/src/tools/clippy/clippy_lints/src/methods/mod.rs b/src/tools/clippy/clippy_lints/src/methods/mod.rs index fb92779be2a7a..720fe0a1dd0f4 100644 --- a/src/tools/clippy/clippy_lints/src/methods/mod.rs +++ b/src/tools/clippy/clippy_lints/src/methods/mod.rs @@ -3255,7 +3255,6 @@ impl<'tcx> LateLintPass<'tcx> for Methods { let implements_trait = matches!(item.kind, hir::ItemKind::Impl(hir::Impl { of_trait: Some(_), .. })); if let hir::ImplItemKind::Fn(ref sig, id) = impl_item.kind { let method_sig = cx.tcx.fn_sig(impl_item.def_id); - let method_sig = cx.tcx.erase_late_bound_regions(method_sig); let first_arg_ty_opt = method_sig.inputs().iter().next().copied(); // if this impl block implements a trait, lint in trait definition instead if !implements_trait && cx.access_levels.is_exported(impl_item.def_id.def_id) { diff --git a/src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs b/src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs index 3566fe9a0bbc9..b817bbcd4416a 100644 --- a/src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs +++ b/src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs @@ -249,7 +249,7 @@ fn check_other_call_arg<'tcx>( if_chain! { if let Some((maybe_call, maybe_arg)) = skip_addr_of_ancestors(cx, expr); if let Some((callee_def_id, _, recv, call_args)) = get_callee_substs_and_args(cx, maybe_call); - let fn_sig = cx.tcx.fn_sig(callee_def_id).skip_binder(); + let fn_sig = cx.tcx.fn_sig(callee_def_id); if let Some(i) = recv.into_iter().chain(call_args).position(|arg| arg.hir_id == maybe_arg.hir_id); if let Some(input) = fn_sig.inputs().get(i); let (input, n_refs) = peel_mid_ty_refs(*input); @@ -382,7 +382,7 @@ fn can_change_type<'a>(cx: &LateContext<'a>, mut expr: &'a Expr<'a>, mut ty: Ty< return false; } - let fn_sig = cx.tcx.fn_sig(callee_def_id).skip_binder(); + let fn_sig = cx.tcx.fn_sig(callee_def_id); if let Some(arg_index) = recv.into_iter().chain(call_args).position(|arg| arg.hir_id == expr.hir_id) && let Some(param_ty) = fn_sig.inputs().get(arg_index) && let ty::Param(ParamTy { index: param_index , ..}) = param_ty.kind() @@ -486,7 +486,9 @@ fn is_to_string_on_string_like<'a>( } if let Some(substs) = cx.typeck_results().node_substs_opt(call_expr.hir_id) - && let [generic_arg] = substs.as_slice() + && let substs = substs.as_slice() + && let Some(generic_arg) = substs.get(0) + && substs.iter().skip(1).all(|arg| matches!(arg.unpack(), ty::GenericArgKind::Lifetime(_))) && let GenericArgKind::Type(ty) = generic_arg.unpack() && let Some(deref_trait_id) = cx.tcx.get_diagnostic_item(sym::Deref) && let Some(as_ref_trait_id) = cx.tcx.get_diagnostic_item(sym::AsRef) diff --git a/src/tools/clippy/clippy_lints/src/mut_key.rs b/src/tools/clippy/clippy_lints/src/mut_key.rs index 25d6ca83a94bc..3c5633baa3f06 100644 --- a/src/tools/clippy/clippy_lints/src/mut_key.rs +++ b/src/tools/clippy/clippy_lints/src/mut_key.rs @@ -112,10 +112,10 @@ impl<'tcx> LateLintPass<'tcx> for MutableKeyType { fn check_sig<'tcx>(cx: &LateContext<'tcx>, item_hir_id: hir::HirId, decl: &hir::FnDecl<'_>) { let fn_def_id = cx.tcx.hir().local_def_id(item_hir_id); let fn_sig = cx.tcx.fn_sig(fn_def_id); - for (hir_ty, ty) in iter::zip(decl.inputs, fn_sig.inputs().skip_binder()) { + for (hir_ty, ty) in iter::zip(decl.inputs, fn_sig.inputs()) { check_ty(cx, hir_ty.span, *ty); } - check_ty(cx, decl.output.span(), cx.tcx.erase_late_bound_regions(fn_sig.output())); + check_ty(cx, decl.output.span(), fn_sig.output()); } // We want to lint 1. sets or maps with 2. not immutable key types and 3. no unerased diff --git a/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs b/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs index 9c949a28f44d5..506ff12539db4 100644 --- a/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs +++ b/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs @@ -144,7 +144,6 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue { }; let fn_sig = cx.tcx.fn_sig(fn_def_id); - let fn_sig = cx.tcx.erase_late_bound_regions(fn_sig); for (idx, ((input, &ty), arg)) in decl.inputs.iter().zip(fn_sig.inputs()).zip(body.params).enumerate() { // All spans generated from a proc-macro invocation are the same... @@ -340,11 +339,5 @@ impl<'tcx> euv::Delegate<'tcx> for MovedVariablesCtxt { fn mutate(&mut self, _: &euv::PlaceWithHirId<'tcx>, _: HirId) {} - fn fake_read( - &mut self, - _: &rustc_hir_typeck::expr_use_visitor::PlaceWithHirId<'tcx>, - _: FakeReadCause, - _: HirId, - ) { - } + fn fake_read(&mut self, _: &rustc_hir_typeck::expr_use_visitor::PlaceWithHirId<'tcx>, _: FakeReadCause, _: HirId) {} } diff --git a/src/tools/clippy/clippy_lints/src/only_used_in_recursion.rs b/src/tools/clippy/clippy_lints/src/only_used_in_recursion.rs index d64a9cf71e17a..ee7743bba243e 100644 --- a/src/tools/clippy/clippy_lints/src/only_used_in_recursion.rs +++ b/src/tools/clippy/clippy_lints/src/only_used_in_recursion.rs @@ -247,9 +247,12 @@ impl<'tcx> LateLintPass<'tcx> for OnlyUsedInRecursion { && let Some(trait_ref) = cx.tcx.impl_trait_ref(item.def_id) && let Some(trait_item_id) = cx.tcx.associated_item(def_id).trait_item_def_id { + let substs = ty::InternalSubsts::identity_for_item(cx.tcx, trait_item_id) + .rebase_onto(cx.tcx, trait_ref.def_id, trait_ref.substs); + let substs = cx.tcx.erase_regions(substs); ( trait_item_id, - FnKind::ImplTraitFn(cx.tcx.erase_regions(trait_ref.substs) as *const _ as usize), + FnKind::ImplTraitFn(substs as *const _ as usize), usize::from(sig.decl.implicit_self.has_implicit_self()), ) } else { diff --git a/src/tools/clippy/clippy_lints/src/pass_by_ref_or_value.rs b/src/tools/clippy/clippy_lints/src/pass_by_ref_or_value.rs index 45e98de10ace4..41311b6f6225f 100644 --- a/src/tools/clippy/clippy_lints/src/pass_by_ref_or_value.rs +++ b/src/tools/clippy/clippy_lints/src/pass_by_ref_or_value.rs @@ -143,7 +143,7 @@ impl<'tcx> PassByRefOrValue { return; } - let fn_sig = cx.tcx.fn_sig(def_id); + let fn_sig = cx.tcx.type_of(def_id).fn_sig(cx.tcx); let fn_body = cx.enclosing_body.map(|id| cx.tcx.hir().body(id)); // Gather all the lifetimes found in the output type which may affect whether @@ -154,12 +154,7 @@ impl<'tcx> PassByRefOrValue { ControlFlow::Continue(()) }); - for (index, (input, ty)) in iter::zip( - decl.inputs, - fn_sig.skip_binder().inputs().iter().map(|&ty| fn_sig.rebind(ty)), - ) - .enumerate() - { + for (index, (input, ty)) in iter::zip(decl.inputs, fn_sig.iter_inputs()).enumerate() { // All spans generated from a proc-macro invocation are the same... match span { Some(s) if s == input.span => continue, diff --git a/src/tools/clippy/clippy_lints/src/ptr.rs b/src/tools/clippy/clippy_lints/src/ptr.rs index 40db315bf2726..6e8fad3a16594 100644 --- a/src/tools/clippy/clippy_lints/src/ptr.rs +++ b/src/tools/clippy/clippy_lints/src/ptr.rs @@ -162,13 +162,8 @@ impl<'tcx> LateLintPass<'tcx> for Ptr { } check_mut_from_ref(cx, sig, None); - for arg in check_fn_args( - cx, - cx.tcx.fn_sig(item.def_id).skip_binder().inputs(), - sig.decl.inputs, - &[], - ) - .filter(|arg| arg.mutability() == Mutability::Not) + for arg in check_fn_args(cx, cx.tcx.fn_sig(item.def_id).inputs(), sig.decl.inputs, &[]) + .filter(|arg| arg.mutability() == Mutability::Not) { span_lint_hir_and_then(cx, PTR_ARG, arg.emission_id, arg.span, &arg.build_msg(), |diag| { diag.span_suggestion( @@ -217,7 +212,7 @@ impl<'tcx> LateLintPass<'tcx> for Ptr { check_mut_from_ref(cx, sig, Some(body)); let decl = sig.decl; - let sig = cx.tcx.fn_sig(item_id).skip_binder(); + let sig = cx.tcx.fn_sig(item_id); let lint_args: Vec<_> = check_fn_args(cx, sig.inputs(), decl.inputs, body.params) .filter(|arg| !is_trait_item || arg.mutability() == Mutability::Not) .collect(); @@ -629,7 +624,7 @@ fn check_ptr_arg_usage<'tcx>(cx: &LateContext<'tcx>, body: &'tcx Body<'_>, args: return; }; - match *self.cx.tcx.fn_sig(id).skip_binder().inputs()[i].peel_refs().kind() { + match *self.cx.tcx.fn_sig(id).input(i).peel_refs().kind() { ty::Dynamic(preds, _, _) if !matches_preds(self.cx, args.deref_ty.ty(self.cx), preds) => { set_skip_flag(); }, diff --git a/src/tools/clippy/clippy_lints/src/returns.rs b/src/tools/clippy/clippy_lints/src/returns.rs index 2b2a41d160117..3ece7f818fdec 100644 --- a/src/tools/clippy/clippy_lints/src/returns.rs +++ b/src/tools/clippy/clippy_lints/src/returns.rs @@ -277,7 +277,6 @@ fn last_statement_borrows<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) && cx .tcx .fn_sig(def_id) - .skip_binder() .output() .walk() .any(|arg| matches!(arg.unpack(), GenericArgKind::Lifetime(_))) diff --git a/src/tools/clippy/clippy_lints/src/unit_return_expecting_ord.rs b/src/tools/clippy/clippy_lints/src/unit_return_expecting_ord.rs index 1307288623f95..6bf3b73389c13 100644 --- a/src/tools/clippy/clippy_lints/src/unit_return_expecting_ord.rs +++ b/src/tools/clippy/clippy_lints/src/unit_return_expecting_ord.rs @@ -82,37 +82,27 @@ fn get_args_to_check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> Ve let ord_preds = get_trait_predicates_for_trait_id(cx, generics, cx.tcx.get_diagnostic_item(sym::Ord)); let partial_ord_preds = get_trait_predicates_for_trait_id(cx, generics, cx.tcx.lang_items().partial_ord_trait()); - // Trying to call erase_late_bound_regions on fn_sig.inputs() gives the following error - // The trait `rustc::ty::TypeFoldable<'_>` is not implemented for - // `&[rustc_middle::ty::Ty<'_>]` - let inputs_output = cx.tcx.erase_late_bound_regions(fn_sig.inputs_and_output()); - inputs_output - .iter() - .rev() - .skip(1) - .rev() - .enumerate() - .for_each(|(i, inp)| { - for trait_pred in &fn_mut_preds { - if_chain! { - if trait_pred.self_ty() == inp; - if let Some(return_ty_pred) = get_projection_pred(cx, generics, *trait_pred); - then { - if ord_preds - .iter() - .any(|ord| Some(ord.self_ty()) == return_ty_pred.term.ty()) - { - args_to_check.push((i, "Ord".to_string())); - } else if partial_ord_preds - .iter() - .any(|pord| pord.self_ty() == return_ty_pred.term.ty().unwrap()) - { - args_to_check.push((i, "PartialOrd".to_string())); - } + fn_sig.inputs().iter().enumerate().for_each(|(i, &inp)| { + for trait_pred in &fn_mut_preds { + if_chain! { + if trait_pred.self_ty() == inp; + if let Some(return_ty_pred) = get_projection_pred(cx, generics, *trait_pred); + then { + if ord_preds + .iter() + .any(|ord| Some(ord.self_ty()) == return_ty_pred.term.ty()) + { + args_to_check.push((i, "Ord".to_string())); + } else if partial_ord_preds + .iter() + .any(|pord| pord.self_ty() == return_ty_pred.term.ty().unwrap()) + { + args_to_check.push((i, "PartialOrd".to_string())); } } } - }); + } + }); } args_to_check } diff --git a/src/tools/clippy/clippy_lints/src/unit_types/let_unit_value.rs b/src/tools/clippy/clippy_lints/src/unit_types/let_unit_value.rs index ce9ebad8c89a8..f7e8df4395fb0 100644 --- a/src/tools/clippy/clippy_lints/src/unit_types/let_unit_value.rs +++ b/src/tools/clippy/clippy_lints/src/unit_types/let_unit_value.rs @@ -156,7 +156,7 @@ fn needs_inferred_result_ty( }, _ => return false, }; - let sig = cx.tcx.fn_sig(id).skip_binder(); + let sig = cx.tcx.fn_sig(id); if let ty::Param(output_ty) = *sig.output().kind() { let args: Vec<&Expr<'_>> = if let Some(receiver) = receiver { std::iter::once(receiver).chain(args.iter()).collect() diff --git a/src/tools/clippy/clippy_lints/src/use_self.rs b/src/tools/clippy/clippy_lints/src/use_self.rs index 65f1b54620819..f8ba08acbc73c 100644 --- a/src/tools/clippy/clippy_lints/src/use_self.rs +++ b/src/tools/clippy/clippy_lints/src/use_self.rs @@ -147,7 +147,6 @@ impl<'tcx> LateLintPass<'tcx> for UseSelf { .trait_item_def_id .expect("impl method matches a trait method"); let trait_method_sig = cx.tcx.fn_sig(trait_method); - let trait_method_sig = cx.tcx.erase_late_bound_regions(trait_method_sig); // `impl_inputs_outputs` is an iterator over the types (`hir::Ty`) declared in the // implementation of the trait. diff --git a/src/tools/clippy/clippy_utils/src/eager_or_lazy.rs b/src/tools/clippy/clippy_utils/src/eager_or_lazy.rs index 95b3e651e2b53..56c15d4b6fd76 100644 --- a/src/tools/clippy/clippy_utils/src/eager_or_lazy.rs +++ b/src/tools/clippy/clippy_utils/src/eager_or_lazy.rs @@ -79,7 +79,7 @@ fn fn_eagerness(cx: &LateContext<'_>, fn_id: DefId, name: Symbol, have_one_arg: && subs.types().all(|x| matches!(x.peel_refs().kind(), ty::Param(_))) { // Limit the function to either `(self) -> bool` or `(&self) -> bool` - match &**cx.tcx.fn_sig(fn_id).skip_binder().inputs_and_output { + match &**cx.tcx.fn_sig(fn_id).inputs_and_output { [arg, res] if !arg.is_mutable_ptr() && arg.peel_refs() == ty && res.is_bool() => NoChange, _ => Lazy, } diff --git a/src/tools/clippy/clippy_utils/src/lib.rs b/src/tools/clippy/clippy_utils/src/lib.rs index 052db3f3a0391..6d02d84ce8786 100644 --- a/src/tools/clippy/clippy_utils/src/lib.rs +++ b/src/tools/clippy/clippy_utils/src/lib.rs @@ -1345,7 +1345,7 @@ pub fn get_enclosing_loop_or_multi_call_closure<'tcx>( .chain(args.iter()) .position(|arg| arg.hir_id == id)?; let id = cx.typeck_results().type_dependent_def_id(e.hir_id)?; - let ty = cx.tcx.fn_sig(id).skip_binder().inputs()[i]; + let ty = cx.tcx.fn_sig(id).input(i); ty_is_fn_once_param(cx.tcx, ty, cx.tcx.param_env(id).caller_bounds()).then_some(()) }, _ => None, @@ -1546,15 +1546,13 @@ pub fn is_direct_expn_of(span: Span, name: &str) -> Option { /// Convenience function to get the return type of a function. pub fn return_ty<'tcx>(cx: &LateContext<'tcx>, fn_item: hir::HirId) -> Ty<'tcx> { let fn_def_id = cx.tcx.hir().local_def_id(fn_item); - let ret_ty = cx.tcx.fn_sig(fn_def_id).output(); - cx.tcx.erase_late_bound_regions(ret_ty) + cx.tcx.fn_sig(fn_def_id).output() } /// Convenience function to get the nth argument type of a function. pub fn nth_arg<'tcx>(cx: &LateContext<'tcx>, fn_item: hir::HirId, nth: usize) -> Ty<'tcx> { let fn_def_id = cx.tcx.hir().local_def_id(fn_item); - let arg = cx.tcx.fn_sig(fn_def_id).input(nth); - cx.tcx.erase_late_bound_regions(arg) + cx.tcx.fn_sig(fn_def_id).input(nth) } /// Checks if an expression is constructing a tuple-like enum variant or struct 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 45b63a4aa5df8..2d128bcdd6e68 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 @@ -51,7 +51,7 @@ pub fn is_min_const_fn<'a, 'tcx>(tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, msrv: // impl trait is gone in MIR, so check the return type manually check_ty( tcx, - tcx.fn_sig(def_id).output().skip_binder(), + tcx.fn_sig(def_id).output(), body.local_decls.iter().next().unwrap().source_info.span, )?; diff --git a/src/tools/clippy/clippy_utils/src/sugg.rs b/src/tools/clippy/clippy_utils/src/sugg.rs index aad7da61a8a54..650f2ba21636f 100644 --- a/src/tools/clippy/clippy_utils/src/sugg.rs +++ b/src/tools/clippy/clippy_utils/src/sugg.rs @@ -877,7 +877,7 @@ impl<'tcx> DerefDelegate<'_, 'tcx> { .cx .typeck_results() .type_dependent_def_id(parent_expr.hir_id) - .map(|did| self.cx.tcx.fn_sig(did).skip_binder()) + .map(|did| self.cx.tcx.fn_sig(did)) { std::iter::once(receiver) .chain(call_args.iter()) diff --git a/src/tools/clippy/clippy_utils/src/ty.rs b/src/tools/clippy/clippy_utils/src/ty.rs index 3b5a9ba83568c..3f063c4df8585 100644 --- a/src/tools/clippy/clippy_utils/src/ty.rs +++ b/src/tools/clippy/clippy_utils/src/ty.rs @@ -563,7 +563,7 @@ impl<'tcx> ExprFnSig<'tcx> { /// If the expression is function like, get the signature for it. pub fn expr_sig<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>) -> Option> { if let Res::Def(DefKind::Fn | DefKind::Ctor(_, CtorKind::Fn) | DefKind::AssocFn, id) = path_res(cx, expr) { - Some(ExprFnSig::Sig(cx.tcx.fn_sig(id), Some(id))) + Some(ExprFnSig::Sig(ty::Binder::dummy(cx.tcx.fn_sig(id)), Some(id))) } else { ty_sig(cx, cx.typeck_results().expr_ty_adjusted(expr).peel_refs()) } @@ -581,7 +581,7 @@ pub fn ty_sig<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option Some(ExprFnSig::Sig(cx.tcx.bound_fn_sig(id).subst(cx.tcx, subs), Some(id))), + ty::FnDef(id, _) => Some(ExprFnSig::Sig(ty.fn_sig(cx.tcx), Some(id))), ty::Opaque(id, _) => sig_from_bounds(cx, ty, cx.tcx.item_bounds(id), cx.tcx.opt_parent(id)), ty::FnPtr(sig) => Some(ExprFnSig::Sig(sig, None)), ty::Dynamic(bounds, _, _) => { diff --git a/src/tools/clippy/clippy_utils/src/visitors.rs b/src/tools/clippy/clippy_utils/src/visitors.rs index d4294f18fd501..9b7190b66fd7e 100644 --- a/src/tools/clippy/clippy_utils/src/visitors.rs +++ b/src/tools/clippy/clippy_utils/src/visitors.rs @@ -392,12 +392,12 @@ pub fn is_expr_unsafe<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) -> bool { .cx .typeck_results() .type_dependent_def_id(e.hir_id) - .map_or(false, |id| self.cx.tcx.fn_sig(id).unsafety() == Unsafety::Unsafe) => + .map_or(false, |id| self.cx.tcx.fn_sig(id).unsafety == Unsafety::Unsafe) => { self.is_unsafe = true; }, ExprKind::Call(func, _) => match *self.cx.typeck_results().expr_ty(func).peel_refs().kind() { - ty::FnDef(id, _) if self.cx.tcx.fn_sig(id).unsafety() == Unsafety::Unsafe => self.is_unsafe = true, + ty::FnDef(id, _) if self.cx.tcx.fn_sig(id).unsafety == Unsafety::Unsafe => self.is_unsafe = true, ty::FnPtr(sig) if sig.unsafety() == Unsafety::Unsafe => self.is_unsafe = true, _ => walk_expr(self, e), }, diff --git a/src/tools/miri/src/eval.rs b/src/tools/miri/src/eval.rs index a3fc343f8b67c..ad6acc1a9af08 100644 --- a/src/tools/miri/src/eval.rs +++ b/src/tools/miri/src/eval.rs @@ -279,7 +279,6 @@ pub fn create_ecx<'mir, 'tcx: 'mir>( EntryFnType::Main { .. } => { let start_id = tcx.lang_items().start_fn().unwrap(); let main_ret_ty = tcx.fn_sig(entry_id).output(); - let main_ret_ty = main_ret_ty.no_bound_vars().unwrap(); let start_instance = ty::Instance::resolve( tcx, ty::ParamEnv::reveal_all(), diff --git a/src/tools/miri/tests/fail/shims/fs/isolated_file.stderr b/src/tools/miri/tests/fail/shims/fs/isolated_file.stderr index 269b1383aad68..ed1f4c63900b4 100644 --- a/src/tools/miri/tests/fail/shims/fs/isolated_file.stderr +++ b/src/tools/miri/tests/fail/shims/fs/isolated_file.stderr @@ -11,11 +11,11 @@ LL | let fd = cvt_r(|| unsafe { open64(path.as_ptr(), flags, opts.mode a = note: inside `std::sys::PLATFORM::cvt_r::` at RUSTLIB/std/src/sys/PLATFORM/mod.rs:LL:CC = note: inside `std::sys::PLATFORM::fs::File::open_c` at RUSTLIB/std/src/sys/PLATFORM/fs.rs:LL:CC = note: inside closure at RUSTLIB/std/src/sys/PLATFORM/fs.rs:LL:CC - = note: inside `std::sys::PLATFORM::small_c_string::run_with_cstr::` at RUSTLIB/std/src/sys/PLATFORM/small_c_string.rs:LL:CC - = note: inside `std::sys::PLATFORM::small_c_string::run_path_with_cstr::` at RUSTLIB/std/src/sys/PLATFORM/small_c_string.rs:LL:CC + = note: inside `std::sys::PLATFORM::small_c_string::run_with_cstr::` at RUSTLIB/std/src/sys/PLATFORM/small_c_string.rs:LL:CC + = note: inside `std::sys::PLATFORM::small_c_string::run_path_with_cstr::` at RUSTLIB/std/src/sys/PLATFORM/small_c_string.rs:LL:CC = note: inside `std::sys::PLATFORM::fs::File::open` at RUSTLIB/std/src/sys/PLATFORM/fs.rs:LL:CC = note: inside `std::fs::OpenOptions::_open` at RUSTLIB/std/src/fs.rs:LL:CC - = note: inside `std::fs::OpenOptions::open::<&std::path::Path>` at RUSTLIB/std/src/fs.rs:LL:CC + = note: inside `std::fs::OpenOptions::open::<&std::path::Path, '_>` at RUSTLIB/std/src/fs.rs:LL:CC = note: inside `std::fs::File::open::<&str>` at RUSTLIB/std/src/fs.rs:LL:CC note: inside `main` at $DIR/isolated_file.rs:LL:CC --> $DIR/isolated_file.rs:LL:CC diff --git a/src/tools/miri/tests/fail/stacked_borrows/newtype_retagging.stderr b/src/tools/miri/tests/fail/stacked_borrows/newtype_retagging.stderr index 06a9b86c6f45a..869c7010145ba 100644 --- a/src/tools/miri/tests/fail/stacked_borrows/newtype_retagging.stderr +++ b/src/tools/miri/tests/fail/stacked_borrows/newtype_retagging.stderr @@ -24,7 +24,7 @@ note: inside closure at $DIR/newtype_retagging.rs:LL:CC | LL | || drop(Box::from_raw(ptr)), | ^^^^^^^^^^^^^^^^^^ -note: inside `dealloc_while_running::<[closure@$DIR/newtype_retagging.rs:LL:CC]>` at $DIR/newtype_retagging.rs:LL:CC +note: inside `dealloc_while_running::<[closure@$DIR/newtype_retagging.rs:LL:CC], '_>` at $DIR/newtype_retagging.rs:LL:CC --> $DIR/newtype_retagging.rs:LL:CC | LL | dealloc(); diff --git a/src/tools/miri/tests/fail/stacked_borrows/zst_slice.stderr b/src/tools/miri/tests/fail/stacked_borrows/zst_slice.stderr index 86f1da1f70a33..60e5faf93729c 100644 --- a/src/tools/miri/tests/fail/stacked_borrows/zst_slice.stderr +++ b/src/tools/miri/tests/fail/stacked_borrows/zst_slice.stderr @@ -15,7 +15,7 @@ help: would have been created here, but this is a zero-size retag ([0x0..0 LL | assert_eq!(*s.get_unchecked(1), 2); | ^^^^^^^^^^^^^^^^^^ = note: BACKTRACE: - = note: inside `core::slice::::get_unchecked::` at RUSTLIB/core/src/slice/mod.rs:LL:CC + = note: inside `core::slice::::get_unchecked::` at RUSTLIB/core/src/slice/mod.rs:LL:CC note: inside `main` at $DIR/zst_slice.rs:LL:CC --> $DIR/zst_slice.rs:LL:CC |