Skip to content

Commit

Permalink
Avoid interning empty tuples.
Browse files Browse the repository at this point in the history
  • Loading branch information
nnethercote committed Feb 12, 2023
1 parent 7a72560 commit e261665
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1800,11 +1800,11 @@ impl<'tcx> TyCtxt<'tcx> {

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

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

#[inline]
Expand Down

0 comments on commit e261665

Please sign in to comment.