Skip to content

Commit 847cd6c

Browse files
Use the right type for upvars
1 parent 07adee7 commit 847cd6c

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

compiler/rustc_middle/src/ty/instance.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -661,12 +661,10 @@ fn polymorphize<'tcx>(
661661
// the unpolymorphized upvar closure would result in a polymorphized closure producing
662662
// multiple mono items (and eventually symbol clashes).
663663
let def_id = instance.def_id();
664-
let upvars_ty = if tcx.is_closure_or_coroutine(def_id) {
665-
Some(args.as_closure().tupled_upvars_ty())
666-
} else if tcx.type_of(def_id).skip_binder().is_coroutine() {
667-
Some(args.as_coroutine().tupled_upvars_ty())
668-
} else {
669-
None
664+
let upvars_ty = match tcx.type_of(def_id).skip_binder().kind() {
665+
ty::Closure(..) => Some(args.as_closure().tupled_upvars_ty()),
666+
ty::Coroutine(..) => Some(args.as_coroutine().tupled_upvars_ty()),
667+
_ => None,
670668
};
671669
let has_upvars = upvars_ty.is_some_and(|ty| !ty.tuple_fields().is_empty());
672670
debug!("polymorphize: upvars_ty={:?} has_upvars={:?}", upvars_ty, has_upvars);

0 commit comments

Comments
 (0)