@@ -419,8 +419,16 @@ fn const_evaluatable_predicates_of<'tcx>(
419419 preds : FxIndexSet < ( ty:: Clause < ' tcx > , Span ) > ,
420420 }
421421
422- fn is_const_param_default ( tcx : TyCtxt < ' _ > , def : LocalDefId ) -> bool {
423- let hir_id = tcx. local_def_id_to_hir_id ( def) ;
422+ fn is_const_param_default ( tcx : TyCtxt < ' _ > , kind : ty:: UnevaluatedConstKind < ' _ > ) -> bool {
423+ let def_id = match kind {
424+ ty:: UnevaluatedConstKind :: Projection { def_id } => def_id,
425+ ty:: UnevaluatedConstKind :: Inherent { def_id } => def_id,
426+ ty:: UnevaluatedConstKind :: Free { def_id } => def_id,
427+ ty:: UnevaluatedConstKind :: Anon { def_id } => def_id,
428+ } ;
429+ let Some ( local) = def_id. as_local ( ) else { return false } ;
430+
431+ let hir_id = tcx. local_def_id_to_hir_id ( local) ;
424432 let ( _, parent_node) = tcx
425433 . hir_parent_iter ( hir_id)
426434 . skip_while ( |( _, n) | matches ! ( n, Node :: ConstArg ( ..) ) )
@@ -435,9 +443,7 @@ fn const_evaluatable_predicates_of<'tcx>(
435443 impl < ' tcx > TypeVisitor < TyCtxt < ' tcx > > for ConstCollector < ' tcx > {
436444 fn visit_const ( & mut self , c : ty:: Const < ' tcx > ) {
437445 if let ty:: ConstKind :: Unevaluated ( uv) = c. kind ( ) {
438- if let Some ( local) = uv. kind . def_id ( ) . as_local ( )
439- && is_const_param_default ( self . tcx , local)
440- {
446+ if is_const_param_default ( self . tcx , uv. kind ) {
441447 // Do not look into const param defaults,
442448 // these get checked when they are actually instantiated.
443449 //
@@ -449,11 +455,11 @@ fn const_evaluatable_predicates_of<'tcx>(
449455 }
450456
451457 // Skip type consts as mGCA doesn't support evaluatable clauses.
452- if self . tcx . is_type_const ( uv. kind . def_id ( ) ) {
458+ if uv. kind . is_type_const ( self . tcx ) {
453459 return ;
454460 }
455461
456- let span = self . tcx . def_span ( uv. kind . def_id ( ) ) ;
462+ let span = uv. kind . def_span ( self . tcx ) ;
457463 self . preds . insert ( ( ty:: ClauseKind :: ConstEvaluatable ( c) . upcast ( self . tcx ) , span) ) ;
458464 }
459465 }
0 commit comments