Address comments
This commit is contained in:
parent
f0ae24e100
commit
5229571a05
3 changed files with 20 additions and 11 deletions
|
@ -3883,7 +3883,6 @@ version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"chalk-ir",
|
"chalk-ir",
|
||||||
"either",
|
|
||||||
"measureme 9.0.0",
|
"measureme 9.0.0",
|
||||||
"polonius-engine",
|
"polonius-engine",
|
||||||
"rustc-rayon-core",
|
"rustc-rayon-core",
|
||||||
|
|
|
@ -8,7 +8,6 @@ edition = "2018"
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
either = "1.5.0"
|
|
||||||
rustc_arena = { path = "../rustc_arena" }
|
rustc_arena = { path = "../rustc_arena" }
|
||||||
bitflags = "1.2.1"
|
bitflags = "1.2.1"
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
|
|
|
@ -5,8 +5,6 @@
|
||||||
use self::InferTy::*;
|
use self::InferTy::*;
|
||||||
use self::TyKind::*;
|
use self::TyKind::*;
|
||||||
|
|
||||||
use either::Either;
|
|
||||||
|
|
||||||
use crate::infer::canonical::Canonical;
|
use crate::infer::canonical::Canonical;
|
||||||
use crate::ty::subst::{GenericArg, InternalSubsts, Subst, SubstsRef};
|
use crate::ty::subst::{GenericArg, InternalSubsts, Subst, SubstsRef};
|
||||||
use crate::ty::{
|
use crate::ty::{
|
||||||
|
@ -396,11 +394,13 @@ impl<'tcx> ClosureSubsts<'tcx> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn upvar_tys(self) -> impl Iterator<Item = Ty<'tcx>> + 'tcx {
|
pub fn upvar_tys(self) -> impl Iterator<Item = Ty<'tcx>> + 'tcx {
|
||||||
match self.tupled_upvars_ty().kind() {
|
match self.tupled_upvars_ty().kind() {
|
||||||
TyKind::Error(_) => Either::Left(std::iter::empty()),
|
TyKind::Error(_) => None,
|
||||||
TyKind::Tuple(..) => Either::Right(self.tupled_upvars_ty().tuple_fields()),
|
TyKind::Tuple(..) => Some(self.tupled_upvars_ty().tuple_fields()),
|
||||||
TyKind::Infer(_) => bug!("upvar_tys called before capture types are inferred"),
|
TyKind::Infer(_) => bug!("upvar_tys called before capture types are inferred"),
|
||||||
ty => bug!("Unexpected representation of upvar types tuple {:?}", ty),
|
ty => bug!("Unexpected representation of upvar types tuple {:?}", ty),
|
||||||
}
|
}
|
||||||
|
.into_iter()
|
||||||
|
.flatten()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the tuple type representing the upvars for this closure.
|
/// Returns the tuple type representing the upvars for this closure.
|
||||||
|
@ -531,11 +531,13 @@ impl<'tcx> GeneratorSubsts<'tcx> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn upvar_tys(self) -> impl Iterator<Item = Ty<'tcx>> + 'tcx {
|
pub fn upvar_tys(self) -> impl Iterator<Item = Ty<'tcx>> + 'tcx {
|
||||||
match self.tupled_upvars_ty().kind() {
|
match self.tupled_upvars_ty().kind() {
|
||||||
TyKind::Error(_) => Either::Left(std::iter::empty()),
|
TyKind::Error(_) => None,
|
||||||
TyKind::Tuple(..) => Either::Right(self.tupled_upvars_ty().tuple_fields()),
|
TyKind::Tuple(..) => Some(self.tupled_upvars_ty().tuple_fields()),
|
||||||
TyKind::Infer(_) => bug!("upvar_tys called before capture types are inferred"),
|
TyKind::Infer(_) => bug!("upvar_tys called before capture types are inferred"),
|
||||||
ty => bug!("Unexpected representation of upvar types tuple {:?}", ty),
|
ty => bug!("Unexpected representation of upvar types tuple {:?}", ty),
|
||||||
}
|
}
|
||||||
|
.into_iter()
|
||||||
|
.flatten()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the tuple type representing the upvars for this generator.
|
/// Returns the tuple type representing the upvars for this generator.
|
||||||
|
@ -683,10 +685,19 @@ impl<'tcx> UpvarSubsts<'tcx> {
|
||||||
/// empty iterator is returned.
|
/// empty iterator is returned.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn upvar_tys(self) -> impl Iterator<Item = Ty<'tcx>> + 'tcx {
|
pub fn upvar_tys(self) -> impl Iterator<Item = Ty<'tcx>> + 'tcx {
|
||||||
match self {
|
let tupled_tys = match self {
|
||||||
UpvarSubsts::Closure(substs) => Either::Left(substs.as_closure().upvar_tys()),
|
UpvarSubsts::Closure(substs) => substs.as_closure().tupled_upvars_ty(),
|
||||||
UpvarSubsts::Generator(substs) => Either::Right(substs.as_generator().upvar_tys()),
|
UpvarSubsts::Generator(substs) => substs.as_generator().tupled_upvars_ty(),
|
||||||
|
};
|
||||||
|
|
||||||
|
match tupled_tys.kind() {
|
||||||
|
TyKind::Error(_) => None,
|
||||||
|
TyKind::Tuple(..) => Some(self.tupled_upvars_ty().tuple_fields()),
|
||||||
|
TyKind::Infer(_) => bug!("upvar_tys called before capture types are inferred"),
|
||||||
|
ty => bug!("Unexpected representation of upvar types tuple {:?}", ty),
|
||||||
}
|
}
|
||||||
|
.into_iter()
|
||||||
|
.flatten()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue