Never,
/// A tuple type. For example, `(i32, bool)`.
- /// Use `Ty::tuple_fields` to iterate over the field types.
- Tuple(SubstsRef<'tcx>),
+ Tuple(&'tcx List<Ty<'tcx>>),
/// The projection of an associated type. For example,
/// `<T as Trait<..>>::N`.
/// Use this rather than `TyKind`, whenever possible.
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable)]
-#[cfg_attr(not(bootstrap), rustc_pass_by_value)]
+#[rustc_pass_by_value]
pub struct Region<'tcx>(pub Interned<'tcx, RegionKind>);
impl<'tcx> Deref for Region<'tcx> {
/// Iterates over tuple fields.
/// Panics when called on anything but a tuple.
- pub fn tuple_fields(self) -> impl DoubleEndedIterator<Item = Ty<'tcx>> {
+ pub fn tuple_fields(self) -> &'tcx List<Ty<'tcx>> {
match self.kind() {
- Tuple(substs) => substs.iter().map(|field| field.expect_ty()),
- _ => bug!("tuple_fields called on non-tuple"),
- }
- }
-
- /// Get the `i`-th element of a tuple.
- /// Panics when called on anything but a tuple.
- pub fn tuple_element_ty(self, i: usize) -> Option<Ty<'tcx>> {
- match self.kind() {
- Tuple(substs) => substs.iter().nth(i).map(|field| field.expect_ty()),
+ Tuple(substs) => substs,
_ => bug!("tuple_fields called on non-tuple"),
}
}
ty::Str | ty::Slice(_) | ty::Dynamic(..) | ty::Foreign(..) => false,
- ty::Tuple(tys) => tys.iter().all(|ty| ty.expect_ty().is_trivially_sized(tcx)),
+ ty::Tuple(tys) => tys.iter().all(|ty| ty.is_trivially_sized(tcx)),
ty::Adt(def, _substs) => def.sized_constraint(tcx).is_empty(),