Skip to content

Commit e261665

Browse files
committed
Avoid interning empty tuples.
1 parent 7a72560 commit e261665

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

compiler/rustc_middle/src/ty/context.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1800,11 +1800,11 @@ impl<'tcx> TyCtxt<'tcx> {
18001800

18011801
#[inline]
18021802
pub fn intern_tup(self, ts: &[Ty<'tcx>]) -> Ty<'tcx> {
1803-
self.mk_ty(Tuple(self.intern_type_list(&ts)))
1803+
if ts.is_empty() { self.types.unit } else { self.mk_ty(Tuple(self.intern_type_list(&ts))) }
18041804
}
18051805

18061806
pub fn mk_tup<I: InternAs<Ty<'tcx>, Ty<'tcx>>>(self, iter: I) -> I::Output {
1807-
iter.intern_with(|ts| self.mk_ty(Tuple(self.intern_type_list(&ts))))
1807+
iter.intern_with(|ts| self.intern_tup(ts))
18081808
}
18091809

18101810
#[inline]

0 commit comments

Comments
 (0)