Skip to content

Commit d912c03

Browse files
committed
Reuse parent_args
1 parent 961c746 commit d912c03

File tree

1 file changed

+3
-12
lines changed
  • compiler/rustc_mir_build/src/thir/pattern

1 file changed

+3
-12
lines changed

compiler/rustc_mir_build/src/thir/pattern/mod.rs

+3-12
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ use rustc_middle::thir::{
1919
Ascription, FieldPat, LocalVarId, Pat, PatKind, PatRange, PatRangeBoundary,
2020
};
2121
use rustc_middle::ty::layout::IntegerExt;
22-
use rustc_middle::ty::{
23-
self, CanonicalUserTypeAnnotation, Ty, TyCtxt, TypeVisitableExt, TypingMode,
24-
};
22+
use rustc_middle::ty::{self, CanonicalUserTypeAnnotation, Ty, TyCtxt, TypingMode};
2523
use rustc_middle::{bug, span_bug};
2624
use rustc_span::def_id::DefId;
2725
use rustc_span::{ErrorGuaranteed, Span};
@@ -600,26 +598,19 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
600598
let ty = tcx.typeck(def_id).node_type(block.hir_id);
601599

602600
let typeck_root_def_id = tcx.typeck_root_def_id(def_id.to_def_id());
603-
let parent_args =
604-
tcx.erase_regions(ty::GenericArgs::identity_for_item(tcx, typeck_root_def_id));
601+
let parent_args = ty::GenericArgs::identity_for_item(tcx, typeck_root_def_id);
605602
let args = ty::InlineConstArgs::new(tcx, ty::InlineConstArgsParts { parent_args, ty }).args;
606603

607-
debug_assert!(!args.has_free_regions());
608-
609604
let ct = ty::UnevaluatedConst { def: def_id.to_def_id(), args };
610605
let c = ty::Const::new_unevaluated(self.tcx, ct);
611606
let pattern = self.const_to_pat(c, ty, id, span);
612607

613608
// Apply a type ascription for the inline constant.
614-
// FIXME: reusing the `args` above causes an ICE
615609
let annotation = {
616610
let infcx = tcx.infer_ctxt().build(TypingMode::non_body_analysis());
617611
let args = ty::InlineConstArgs::new(
618612
tcx,
619-
ty::InlineConstArgsParts {
620-
parent_args: ty::GenericArgs::identity_for_item(tcx, typeck_root_def_id),
621-
ty: infcx.next_ty_var(span),
622-
},
613+
ty::InlineConstArgsParts { parent_args, ty: infcx.next_ty_var(span) },
623614
)
624615
.args;
625616
infcx.canonicalize_user_type_annotation(ty::UserType::new(ty::UserTypeKind::TypeOf(

0 commit comments

Comments
 (0)