From cf94bdc0742c13e2a0cac864c478b8626b266e1b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:11:38 +0200 Subject: Merging upstream version 1.66.0+dfsg1. Signed-off-by: Daniel Baumann --- compiler/rustc_infer/src/infer/mod.rs | 300 ++++++++++++++++------------------ 1 file changed, 138 insertions(+), 162 deletions(-) (limited to 'compiler/rustc_infer/src/infer/mod.rs') diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index 3abed1221..ffb020398 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -35,10 +35,11 @@ use rustc_middle::ty::{ConstVid, FloatVid, IntVid, TyVid}; use rustc_span::symbol::Symbol; use rustc_span::{Span, DUMMY_SP}; -use std::cell::{Cell, Ref, RefCell}; +use std::cell::{Cell, RefCell}; use std::fmt; use self::combine::CombineFields; +use self::error_reporting::TypeErrCtxt; use self::free_regions::RegionRelations; use self::lexical_region_resolve::LexicalRegionResolutions; use self::outlives::env::OutlivesEnvironment; @@ -252,7 +253,7 @@ pub enum DefiningAnchor { Error, } -pub struct InferCtxt<'a, 'tcx> { +pub struct InferCtxt<'tcx> { pub tcx: TyCtxt<'tcx>, /// The `DefId` of the item in whose context we are performing inference or typeck. @@ -272,12 +273,6 @@ pub struct InferCtxt<'a, 'tcx> { /// solving is left to borrowck instead. pub considering_regions: bool, - /// During type-checking/inference of a body, `in_progress_typeck_results` - /// contains a reference to the typeck results being built up, which are - /// used for reading closure kinds/signatures as they are inferred, - /// and for error reporting logic to read arbitrary node types. - pub in_progress_typeck_results: Option<&'a RefCell>>, - pub inner: RefCell>, /// If set, this flag causes us to skip the 'leak check' during @@ -340,7 +335,7 @@ pub struct InferCtxt<'a, 'tcx> { universe: Cell, normalize_fn_sig_for_diagnostic: - Option, ty::PolyFnSig<'tcx>) -> ty::PolyFnSig<'tcx>>>, + Option, ty::PolyFnSig<'tcx>) -> ty::PolyFnSig<'tcx>>>, } /// See the `error_reporting` module for more details. @@ -551,16 +546,13 @@ impl<'tcx> fmt::Display for FixupError<'tcx> { } } -/// A temporary returned by `tcx.infer_ctxt()`. This is necessary -/// for multiple `InferCtxt` to share the same `in_progress_typeck_results` -/// without using `Rc` or something similar. +/// Used to configure inference contexts before their creation pub struct InferCtxtBuilder<'tcx> { tcx: TyCtxt<'tcx>, defining_use_anchor: DefiningAnchor, considering_regions: bool, - fresh_typeck_results: Option>>, normalize_fn_sig_for_diagnostic: - Option, ty::PolyFnSig<'tcx>) -> ty::PolyFnSig<'tcx>>>, + Option, ty::PolyFnSig<'tcx>) -> ty::PolyFnSig<'tcx>>>, } pub trait TyCtxtInferExt<'tcx> { @@ -573,26 +565,17 @@ impl<'tcx> TyCtxtInferExt<'tcx> for TyCtxt<'tcx> { tcx: self, defining_use_anchor: DefiningAnchor::Error, considering_regions: true, - fresh_typeck_results: None, normalize_fn_sig_for_diagnostic: None, } } } impl<'tcx> InferCtxtBuilder<'tcx> { - /// Used only by `rustc_typeck` during body type-checking/inference, - /// will initialize `in_progress_typeck_results` with fresh `TypeckResults`. - /// Will also change the scope for opaque type defining use checks to the given owner. - pub fn with_fresh_in_progress_typeck_results(mut self, table_owner: LocalDefId) -> Self { - self.fresh_typeck_results = Some(RefCell::new(ty::TypeckResults::new(table_owner))); - self.with_opaque_type_inference(DefiningAnchor::Bind(table_owner)) - } - /// Whenever the `InferCtxt` should be able to handle defining uses of opaque types, /// you need to call this function. Otherwise the opaque type will be treated opaquely. /// /// It is only meant to be called in two places, for typeck - /// (via `with_fresh_in_progress_typeck_results`) and for the inference context used + /// (via `Inherited::build`) and for the inference context used /// in mir borrowck. pub fn with_opaque_type_inference(mut self, defining_use_anchor: DefiningAnchor) -> Self { self.defining_use_anchor = defining_use_anchor; @@ -606,7 +589,7 @@ impl<'tcx> InferCtxtBuilder<'tcx> { pub fn with_normalize_fn_sig_for_diagnostic( mut self, - fun: Lrc, ty::PolyFnSig<'tcx>) -> ty::PolyFnSig<'tcx>>, + fun: Lrc, ty::PolyFnSig<'tcx>) -> ty::PolyFnSig<'tcx>>, ) -> Self { self.normalize_fn_sig_for_diagnostic = Some(fun); self @@ -619,36 +602,30 @@ impl<'tcx> InferCtxtBuilder<'tcx> { /// `V` and a substitution `S`. This substitution `S` maps from /// the bound values in `C` to their instantiated values in `V` /// (in other words, `S(C) = V`). - pub fn enter_with_canonical( + pub fn build_with_canonical( &mut self, span: Span, canonical: &Canonical<'tcx, T>, - f: impl for<'a> FnOnce(InferCtxt<'a, 'tcx>, T, CanonicalVarValues<'tcx>) -> R, - ) -> R + ) -> (InferCtxt<'tcx>, T, CanonicalVarValues<'tcx>) where T: TypeFoldable<'tcx>, { - self.enter(|infcx| { - let (value, subst) = - infcx.instantiate_canonical_with_fresh_inference_vars(span, canonical); - f(infcx, value, subst) - }) + let infcx = self.build(); + let (value, subst) = infcx.instantiate_canonical_with_fresh_inference_vars(span, canonical); + (infcx, value, subst) } - pub fn enter(&mut self, f: impl for<'a> FnOnce(InferCtxt<'a, 'tcx>) -> R) -> R { + pub fn build(&mut self) -> InferCtxt<'tcx> { let InferCtxtBuilder { tcx, defining_use_anchor, considering_regions, - ref fresh_typeck_results, ref normalize_fn_sig_for_diagnostic, } = *self; - let in_progress_typeck_results = fresh_typeck_results.as_ref(); - f(InferCtxt { + InferCtxt { tcx, defining_use_anchor, considering_regions, - in_progress_typeck_results, inner: RefCell::new(InferCtxtInner::new()), lexical_region_resolutions: RefCell::new(None), selection_cache: Default::default(), @@ -663,7 +640,7 @@ impl<'tcx> InferCtxtBuilder<'tcx> { normalize_fn_sig_for_diagnostic: normalize_fn_sig_for_diagnostic .as_ref() .map(|f| f.clone()), - }) + } } } @@ -675,7 +652,7 @@ impl<'tcx, T> InferOk<'tcx, T> { /// Extracts `value`, registering any obligations into `fulfill_cx`. pub fn into_value_registering_obligations( self, - infcx: &InferCtxt<'_, 'tcx>, + infcx: &InferCtxt<'tcx>, fulfill_cx: &mut dyn TraitEngine<'tcx>, ) -> T { let InferOk { value, obligations } = self; @@ -691,29 +668,34 @@ impl<'tcx> InferOk<'tcx, ()> { } #[must_use = "once you start a snapshot, you should always consume it"] -pub struct CombinedSnapshot<'a, 'tcx> { +pub struct CombinedSnapshot<'tcx> { undo_snapshot: Snapshot<'tcx>, region_constraints_snapshot: RegionSnapshot, universe: ty::UniverseIndex, was_in_snapshot: bool, - _in_progress_typeck_results: Option>>, } -impl<'a, 'tcx> InferCtxt<'a, 'tcx> { +impl<'tcx> InferCtxt<'tcx> { + /// Creates a `TypeErrCtxt` for emitting various inference errors. + /// During typeck, use `FnCtxt::infer_err` instead. + pub fn err_ctxt(&self) -> TypeErrCtxt<'_, 'tcx> { + TypeErrCtxt { infcx: self, typeck_results: None } + } + /// calls `tcx.try_unify_abstract_consts` after /// canonicalizing the consts. #[instrument(skip(self), level = "debug")] pub fn try_unify_abstract_consts( &self, - a: ty::Unevaluated<'tcx, ()>, - b: ty::Unevaluated<'tcx, ()>, + a: ty::UnevaluatedConst<'tcx>, + b: ty::UnevaluatedConst<'tcx>, param_env: ty::ParamEnv<'tcx>, ) -> bool { // Reject any attempt to unify two unevaluated constants that contain inference // variables, since inference variables in queries lead to ICEs. - if a.substs.has_infer_types_or_consts() - || b.substs.has_infer_types_or_consts() - || param_env.has_infer_types_or_consts() + if a.substs.has_non_region_infer() + || b.substs.has_non_region_infer() + || param_env.has_non_region_infer() { debug!("a or b or param_env contain infer vars in its substs -> cannot unify"); return false; @@ -738,7 +720,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { /// if this is not a type variable. /// /// No attempt is made to resolve `ty`. - pub fn type_var_origin(&'a self, ty: Ty<'tcx>) -> Option { + pub fn type_var_origin(&self, ty: Ty<'tcx>) -> Option { match *ty.kind() { ty::Infer(ty::TyVar(vid)) => { Some(*self.inner.borrow_mut().type_variables().var_origin(vid)) @@ -779,7 +761,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { vars } - fn combine_fields( + fn combine_fields<'a>( &'a self, trace: TypeTrace<'tcx>, param_env: ty::ParamEnv<'tcx>, @@ -821,7 +803,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { result } - fn start_snapshot(&self) -> CombinedSnapshot<'a, 'tcx> { + fn start_snapshot(&self) -> CombinedSnapshot<'tcx> { debug!("start_snapshot()"); let in_snapshot = self.in_snapshot.replace(true); @@ -833,22 +815,16 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { region_constraints_snapshot: inner.unwrap_region_constraints().start_snapshot(), universe: self.universe(), was_in_snapshot: in_snapshot, - // Borrow typeck results "in progress" (i.e., during typeck) - // to ban writes from within a snapshot to them. - _in_progress_typeck_results: self - .in_progress_typeck_results - .map(|typeck_results| typeck_results.borrow()), } } #[instrument(skip(self, snapshot), level = "debug")] - fn rollback_to(&self, cause: &str, snapshot: CombinedSnapshot<'a, 'tcx>) { + fn rollback_to(&self, cause: &str, snapshot: CombinedSnapshot<'tcx>) { let CombinedSnapshot { undo_snapshot, region_constraints_snapshot, universe, was_in_snapshot, - _in_progress_typeck_results, } = snapshot; self.in_snapshot.set(was_in_snapshot); @@ -860,13 +836,12 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { } #[instrument(skip(self, snapshot), level = "debug")] - fn commit_from(&self, snapshot: CombinedSnapshot<'a, 'tcx>) { + fn commit_from(&self, snapshot: CombinedSnapshot<'tcx>) { let CombinedSnapshot { undo_snapshot, region_constraints_snapshot: _, universe: _, was_in_snapshot, - _in_progress_typeck_results, } = snapshot; self.in_snapshot.set(was_in_snapshot); @@ -878,7 +853,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { #[instrument(skip(self, f), level = "debug")] pub fn commit_if_ok(&self, f: F) -> Result where - F: FnOnce(&CombinedSnapshot<'a, 'tcx>) -> Result, + F: FnOnce(&CombinedSnapshot<'tcx>) -> Result, { let snapshot = self.start_snapshot(); let r = f(&snapshot); @@ -898,7 +873,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { #[instrument(skip(self, f), level = "debug")] pub fn probe(&self, f: F) -> R where - F: FnOnce(&CombinedSnapshot<'a, 'tcx>) -> R, + F: FnOnce(&CombinedSnapshot<'tcx>) -> R, { let snapshot = self.start_snapshot(); let r = f(&snapshot); @@ -910,7 +885,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { #[instrument(skip(self, f), level = "debug")] pub fn probe_maybe_skip_leak_check(&self, should_skip: bool, f: F) -> R where - F: FnOnce(&CombinedSnapshot<'a, 'tcx>) -> R, + F: FnOnce(&CombinedSnapshot<'tcx>) -> R, { let snapshot = self.start_snapshot(); let was_skip_leak_check = self.skip_leak_check.get(); @@ -930,7 +905,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { /// - `Some(false)` -- if there are `'a: 'b` constraints but none involve placeholders pub fn region_constraints_added_in_snapshot( &self, - snapshot: &CombinedSnapshot<'a, 'tcx>, + snapshot: &CombinedSnapshot<'tcx>, ) -> Option { self.inner .borrow_mut() @@ -938,7 +913,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { .region_constraints_added_in_snapshot(&snapshot.undo_snapshot) } - pub fn opaque_types_added_in_snapshot(&self, snapshot: &CombinedSnapshot<'a, 'tcx>) -> bool { + pub fn opaque_types_added_in_snapshot(&self, snapshot: &CombinedSnapshot<'tcx>) -> bool { self.inner.borrow().undo_log.opaque_types_in_snapshot(&snapshot.undo_snapshot) } @@ -1175,8 +1150,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { /// Return the universe that the region `r` was created in. For /// most regions (e.g., `'static`, named regions from the user, /// etc) this is the root universe U0. For inference variables or - /// placeholders, however, it will return the universe which which - /// they are associated. + /// placeholders, however, it will return the universe which they + /// are associated. pub fn universe_of_region(&self, r: ty::Region<'tcx>) -> ty::UniverseIndex { self.inner.borrow_mut().unwrap_region_constraints().universe(r) } @@ -1308,7 +1283,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { assert!(old_value.is_none()); } - /// Process the region constraints and return any any errors that + /// Process the region constraints and return any errors that /// result. After this, no more unification operations should be /// done -- or the compiler will panic -- but it is legal to use /// `resolve_vars_if_possible` as well as `fully_resolve`. @@ -1342,32 +1317,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { errors } - - /// Process the region constraints and report any errors that - /// result. After this, no more unification operations should be - /// done -- or the compiler will panic -- but it is legal to use - /// `resolve_vars_if_possible` as well as `fully_resolve`. - /// - /// Make sure to call [`InferCtxt::process_registered_region_obligations`] - /// first, or preferably use [`InferCtxt::check_region_obligations_and_report_errors`] - /// to do both of these operations together. - pub fn resolve_regions_and_report_errors( - &self, - generic_param_scope: LocalDefId, - outlives_env: &OutlivesEnvironment<'tcx>, - ) { - let errors = self.resolve_regions(outlives_env); - - if !self.is_tainted_by_errors() { - // As a heuristic, just skip reporting region errors - // altogether if other errors have been reported while - // this infcx was in use. This is totally hokey but - // otherwise we have a hard time separating legit region - // errors from silly ones. - self.report_region_errors(generic_param_scope, &errors); - } - } - /// Obtains (and clears) the current set of region /// constraints. The inference context is still usable: further /// unifications will simply add new constraints. @@ -1520,60 +1469,12 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { * except during the writeback phase. */ - resolve::fully_resolve(self, value) - } - - // [Note-Type-error-reporting] - // An invariant is that anytime the expected or actual type is Error (the special - // error type, meaning that an error occurred when typechecking this expression), - // this is a derived error. The error cascaded from another error (that was already - // reported), so it's not useful to display it to the user. - // The following methods implement this logic. - // They check if either the actual or expected type is Error, and don't print the error - // in this case. The typechecker should only ever report type errors involving mismatched - // types using one of these methods, and should not call span_err directly for such - // errors. - - pub fn type_error_struct_with_diag( - &self, - sp: Span, - mk_diag: M, - actual_ty: Ty<'tcx>, - ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> - where - M: FnOnce(String) -> DiagnosticBuilder<'tcx, ErrorGuaranteed>, - { - let actual_ty = self.resolve_vars_if_possible(actual_ty); - debug!("type_error_struct_with_diag({:?}, {:?})", sp, actual_ty); - - let mut err = mk_diag(self.ty_to_string(actual_ty)); - - // Don't report an error if actual type is `Error`. - if actual_ty.references_error() { - err.downgrade_to_delayed_bug(); - } - - err - } - - pub fn report_mismatched_types( - &self, - cause: &ObligationCause<'tcx>, - expected: Ty<'tcx>, - actual: Ty<'tcx>, - err: TypeError<'tcx>, - ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> { - self.report_and_explain_type_error(TypeTrace::types(cause, true, expected, actual), err) - } - - pub fn report_mismatched_consts( - &self, - cause: &ObligationCause<'tcx>, - expected: ty::Const<'tcx>, - actual: ty::Const<'tcx>, - err: TypeError<'tcx>, - ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> { - self.report_and_explain_type_error(TypeTrace::consts(cause, true, expected, actual), err) + let value = resolve::fully_resolve(self, value); + assert!( + value.as_ref().map_or(true, |value| !value.needs_infer()), + "`{value:?}` is not fully resolved" + ); + value } pub fn replace_bound_vars_with_fresh_vars( @@ -1590,7 +1491,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { } struct ToFreshVars<'a, 'tcx> { - infcx: &'a InferCtxt<'a, 'tcx>, + infcx: &'a InferCtxt<'tcx>, span: Span, lbrct: LateBoundRegionConversionTime, map: FxHashMap>, @@ -1690,7 +1591,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { pub fn try_const_eval_resolve( &self, param_env: ty::ParamEnv<'tcx>, - unevaluated: ty::Unevaluated<'tcx, ()>, + unevaluated: ty::UnevaluatedConst<'tcx>, ty: Ty<'tcx>, span: Option, ) -> Result, ErrorHandled> { @@ -1725,7 +1626,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { pub fn const_eval_resolve( &self, mut param_env: ty::ParamEnv<'tcx>, - unevaluated: ty::Unevaluated<'tcx, ()>, + unevaluated: ty::UnevaluatedConst<'tcx>, span: Option, ) -> EvalToValTreeResult<'tcx> { let mut substs = self.resolve_vars_if_possible(unevaluated.substs); @@ -1733,7 +1634,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { // Postpone the evaluation of constants whose substs depend on inference // variables - if substs.has_infer_types_or_consts() { + if substs.has_non_region_infer() { let ac = AbstractConst::new(self.tcx, unevaluated); match ac { Ok(None) => { @@ -1756,8 +1657,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { debug!(?param_env_erased); debug!(?substs_erased); - let unevaluated = - ty::Unevaluated { def: unevaluated.def, substs: substs_erased, promoted: () }; + let unevaluated = ty::UnevaluatedConst { def: unevaluated.def, substs: substs_erased }; // The return value is the evaluated value which doesn't contain any reference to inference // variables, thus we don't need to substitute back the original values. @@ -1816,6 +1716,86 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { } } +impl<'tcx> TypeErrCtxt<'_, 'tcx> { + /// Process the region constraints and report any errors that + /// result. After this, no more unification operations should be + /// done -- or the compiler will panic -- but it is legal to use + /// `resolve_vars_if_possible` as well as `fully_resolve`. + /// + /// Make sure to call [`InferCtxt::process_registered_region_obligations`] + /// first, or preferably use [`InferCtxt::check_region_obligations_and_report_errors`] + /// to do both of these operations together. + pub fn resolve_regions_and_report_errors( + &self, + generic_param_scope: LocalDefId, + outlives_env: &OutlivesEnvironment<'tcx>, + ) { + let errors = self.resolve_regions(outlives_env); + + if !self.is_tainted_by_errors() { + // As a heuristic, just skip reporting region errors + // altogether if other errors have been reported while + // this infcx was in use. This is totally hokey but + // otherwise we have a hard time separating legit region + // errors from silly ones. + self.report_region_errors(generic_param_scope, &errors); + } + } + + // [Note-Type-error-reporting] + // An invariant is that anytime the expected or actual type is Error (the special + // error type, meaning that an error occurred when typechecking this expression), + // this is a derived error. The error cascaded from another error (that was already + // reported), so it's not useful to display it to the user. + // The following methods implement this logic. + // They check if either the actual or expected type is Error, and don't print the error + // in this case. The typechecker should only ever report type errors involving mismatched + // types using one of these methods, and should not call span_err directly for such + // errors. + + pub fn type_error_struct_with_diag( + &self, + sp: Span, + mk_diag: M, + actual_ty: Ty<'tcx>, + ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> + where + M: FnOnce(String) -> DiagnosticBuilder<'tcx, ErrorGuaranteed>, + { + let actual_ty = self.resolve_vars_if_possible(actual_ty); + debug!("type_error_struct_with_diag({:?}, {:?})", sp, actual_ty); + + let mut err = mk_diag(self.ty_to_string(actual_ty)); + + // Don't report an error if actual type is `Error`. + if actual_ty.references_error() { + err.downgrade_to_delayed_bug(); + } + + err + } + + pub fn report_mismatched_types( + &self, + cause: &ObligationCause<'tcx>, + expected: Ty<'tcx>, + actual: Ty<'tcx>, + err: TypeError<'tcx>, + ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> { + self.report_and_explain_type_error(TypeTrace::types(cause, true, expected, actual), err) + } + + pub fn report_mismatched_consts( + &self, + cause: &ObligationCause<'tcx>, + expected: ty::Const<'tcx>, + actual: ty::Const<'tcx>, + err: TypeError<'tcx>, + ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> { + self.report_and_explain_type_error(TypeTrace::consts(cause, true, expected, actual), err) + } +} + /// Helper for `ty_or_const_infer_var_changed` (see comment on that), currently /// used only for `traits::fulfill`'s list of `stalled_on` inference variables. #[derive(Copy, Clone, Debug)] @@ -1885,7 +1865,7 @@ impl<'tcx> TypeFolder<'tcx> for InferenceLiteralEraser<'tcx> { } struct ShallowResolver<'a, 'tcx> { - infcx: &'a InferCtxt<'a, 'tcx>, + infcx: &'a InferCtxt<'tcx>, } impl<'a, 'tcx> TypeFolder<'tcx> for ShallowResolver<'a, 'tcx> { @@ -2072,21 +2052,17 @@ fn replace_param_and_infer_substs_with_placeholder<'tcx>( ) -> SubstsRef<'tcx> { tcx.mk_substs(substs.iter().enumerate().map(|(idx, arg)| { match arg.unpack() { - GenericArgKind::Type(_) - if arg.has_param_types_or_consts() || arg.has_infer_types_or_consts() => - { + GenericArgKind::Type(_) if arg.has_non_region_param() || arg.has_non_region_infer() => { tcx.mk_ty(ty::Placeholder(ty::PlaceholderType { universe: ty::UniverseIndex::ROOT, name: ty::BoundVar::from_usize(idx), })) .into() } - GenericArgKind::Const(ct) - if ct.has_infer_types_or_consts() || ct.has_param_types_or_consts() => - { + GenericArgKind::Const(ct) if ct.has_non_region_infer() || ct.has_non_region_param() => { let ty = ct.ty(); // If the type references param or infer, replace that too... - if ty.has_param_types_or_consts() || ty.has_infer_types_or_consts() { + if ty.has_non_region_param() || ty.has_non_region_infer() { bug!("const `{ct}`'s type should not reference params or types"); } tcx.mk_const(ty::ConstS { -- cgit v1.2.3