Skip to content

Commit 9664122

Browse files
committed
Simplify function signature in opaque_types
1 parent 43dae91 commit 9664122

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

src/librustc/infer/opaque_types/mod.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -550,13 +550,13 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
550550
/// # Parameters
551551
///
552552
/// - `def_id`, the `impl Trait` type
553-
/// - `opaque_defn`, the opaque definition created in `instantiate_opaque_types`
553+
/// - `substs`, the substs used to instantiate this opaque type
554554
/// - `instantiated_ty`, the inferred type C1 -- fully resolved, lifted version of
555555
/// `opaque_defn.concrete_ty`
556556
pub fn infer_opaque_definition_from_instantiation(
557557
&self,
558558
def_id: DefId,
559-
opaque_defn: &OpaqueTypeDecl<'tcx>,
559+
substs: SubstsRef<'tcx>,
560560
instantiated_ty: Ty<'tcx>,
561561
span: Span,
562562
) -> Ty<'tcx> {
@@ -572,12 +572,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
572572
// `impl Trait` return type, resulting in the parameters
573573
// shifting.
574574
let id_substs = InternalSubsts::identity_for_item(self.tcx, def_id);
575-
let map: FxHashMap<GenericArg<'tcx>, GenericArg<'tcx>> = opaque_defn
576-
.substs
577-
.iter()
578-
.enumerate()
579-
.map(|(index, subst)| (*subst, id_substs[index]))
580-
.collect();
575+
let map: FxHashMap<GenericArg<'tcx>, GenericArg<'tcx>> =
576+
substs.iter().enumerate().map(|(index, subst)| (*subst, id_substs[index])).collect();
581577

582578
// Convert the type from the function into a type valid outside
583579
// the function, by replacing invalid regions with 'static,

src/librustc_typeck/check/writeback.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
444444
// figures out the concrete type with `U`, but the stored type is with `T`.
445445
let definition_ty = self.fcx.infer_opaque_definition_from_instantiation(
446446
def_id,
447-
opaque_defn,
447+
opaque_defn.substs,
448448
instantiated_ty,
449449
span,
450450
);

0 commit comments

Comments
 (0)