fix ICE when asm_const
and const_refs_to_static
are combined · rust-lang/rust@49e3b9a (original) (raw)
`@@ -29,7 +29,8 @@ use rustc_macros::extension;
`
29
29
`use rustc_middle::ty::fold::TypeFoldable;
`
30
30
`use rustc_middle::ty::print::with_no_trimmed_paths;
`
31
31
`use rustc_middle::ty::{
`
32
``
`-
self, GenericArgs, GenericArgsRef, InlineConstArgs, InlineConstArgsParts, RegionVid, Ty, TyCtxt,
`
``
32
`+
self, GenericArgs, GenericArgsRef, InlineConstArgs, InlineConstArgsParts, RegionVid, Ty,
`
``
33
`+
TyCtxt, TypeVisitableExt,
`
33
34
`};
`
34
35
`use rustc_middle::{bug, span_bug};
`
35
36
`use rustc_span::symbol::{kw, sym};
`
`@@ -688,7 +689,8 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
`
688
689
`defining_ty: DefiningTy<'tcx>,
`
689
690
`) -> ty::Binder<'tcx, &'tcx ty::List<Ty<'tcx>>> {
`
690
691
`let tcx = self.infcx.tcx;
`
691
``
`-
match defining_ty {
`
``
692
+
``
693
`+
let inputs_and_output = match defining_ty {
`
692
694
`DefiningTy::Closure(def_id, args) => {
`
693
695
`assert_eq!(self.mir_def.to_def_id(), def_id);
`
694
696
`let closure_sig = args.as_closure().sig();
`
`@@ -798,6 +800,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
`
798
800
`// "output" (the type of the constant).
`
799
801
`assert_eq!(self.mir_def.to_def_id(), def_id);
`
800
802
`let ty = tcx.type_of(self.mir_def).instantiate_identity();
`
``
803
+
801
804
`let ty = indices.fold_to_region_vids(tcx, ty);
`
802
805
` ty::Binder::dummy(tcx.mk_type_list(&[ty]))
`
803
806
`}
`
`@@ -807,7 +810,14 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
`
807
810
`let ty = args.as_inline_const().ty();
`
808
811
` ty::Binder::dummy(tcx.mk_type_list(&[ty]))
`
809
812
`}
`
``
813
`+
};
`
``
814
+
``
815
`+
// FIXME(#129952): We probably want a more principled approach here.
`
``
816
`+
if let Err(terr) = inputs_and_output.skip_binder().error_reported() {
`
``
817
`+
self.infcx.set_tainted_by_errors(terr);
`
810
818
`}
`
``
819
+
``
820
`+
inputs_and_output
`
811
821
`}
`
812
822
`}
`
813
823
``