Remove GeneratorWitness and rename GeneratorWitnessMIR.
This commit is contained in:
parent
855a75b6d6
commit
44ac8dcc71
@ -426,7 +426,6 @@ fn push_debuginfo_type_name<'tcx>(
|
||||
| ty::Placeholder(..)
|
||||
| ty::Alias(..)
|
||||
| ty::Bound(..)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::GeneratorWitness(..) => {
|
||||
bug!(
|
||||
"debuginfo: Trying to create type name for \
|
||||
|
@ -152,7 +152,7 @@ pub(crate) fn const_to_valtree_inner<'tcx>(
|
||||
// FIXME(oli-obk): we can probably encode closures just like structs
|
||||
| ty::Closure(..)
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(..) |ty::GeneratorWitnessMIR(..)=> Err(ValTreeCreationError::NonSupportedType),
|
||||
| ty::GeneratorWitness(..) => Err(ValTreeCreationError::NonSupportedType),
|
||||
}
|
||||
}
|
||||
|
||||
@ -280,7 +280,6 @@ pub fn valtree_to_const_value<'tcx>(
|
||||
| ty::Closure(..)
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::FnPtr(_)
|
||||
| ty::RawPtr(_)
|
||||
| ty::Str
|
||||
|
@ -963,7 +963,6 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
| ty::Ref(..)
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::Array(..)
|
||||
| ty::Closure(..)
|
||||
| ty::Never
|
||||
|
@ -100,8 +100,7 @@ pub(crate) fn eval_nullary_intrinsic<'tcx>(
|
||||
| ty::Dynamic(_, _, _)
|
||||
| ty::Closure(_, _)
|
||||
| ty::Generator(_, _, _)
|
||||
| ty::GeneratorWitness(_)
|
||||
| ty::GeneratorWitnessMIR(_, _)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::Never
|
||||
| ty::Tuple(_)
|
||||
| ty::Error(_) => ConstValue::from_target_usize(0u64, &tcx),
|
||||
|
@ -583,7 +583,6 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
|
||||
| ty::Bound(..)
|
||||
| ty::Param(..)
|
||||
| ty::Alias(..)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::GeneratorWitness(..) => bug!("Encountered invalid type {:?}", ty),
|
||||
}
|
||||
}
|
||||
|
@ -64,8 +64,7 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
|
||||
|
||||
ty::Alias(ty::Weak, _) => bug!("type_name: unexpected weak projection"),
|
||||
ty::Alias(ty::Inherent, _) => bug!("type_name: unexpected inherent projection"),
|
||||
ty::GeneratorWitness(_) => bug!("type_name: unexpected `GeneratorWitness`"),
|
||||
ty::GeneratorWitnessMIR(..) => bug!("type_name: unexpected `GeneratorWitnessMIR`"),
|
||||
ty::GeneratorWitness(..) => bug!("type_name: unexpected `GeneratorWitness`"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,6 @@ impl<'tcx> InherentCollect<'tcx> {
|
||||
| ty::Closure(..)
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::Bound(..)
|
||||
| ty::Placeholder(_)
|
||||
| ty::Infer(_) => {
|
||||
|
@ -245,7 +245,6 @@ fn do_orphan_check_impl<'tcx>(
|
||||
ty::Closure(..)
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::Bound(..)
|
||||
| ty::Placeholder(..)
|
||||
| ty::Infer(..) => {
|
||||
|
@ -314,11 +314,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
|
||||
// types, where we use Error as the Self type
|
||||
}
|
||||
|
||||
ty::Placeholder(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::Bound(..)
|
||||
| ty::Infer(..) => {
|
||||
ty::Placeholder(..) | ty::GeneratorWitness(..) | ty::Bound(..) | ty::Infer(..) => {
|
||||
bug!("unexpected type encountered in variance inference: {}", ty);
|
||||
}
|
||||
}
|
||||
|
@ -129,7 +129,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
| ty::Float(_)
|
||||
| ty::Array(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::RawPtr(_)
|
||||
| ty::Ref(..)
|
||||
| ty::FnDef(..)
|
||||
|
@ -535,7 +535,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
self.tcx,
|
||||
self.tcx.typeck_root_def_id(expr_def_id.to_def_id()),
|
||||
);
|
||||
let witness = Ty::new_generator_witness_mir(self.tcx, expr_def_id.to_def_id(), args);
|
||||
let witness = Ty::new_generator_witness(self.tcx, expr_def_id.to_def_id(), args);
|
||||
|
||||
// Unify `interior` with `witness` and collect all the resulting obligations.
|
||||
let span = self.tcx.hir().body(body_id).value.span;
|
||||
|
@ -459,7 +459,6 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
|
||||
ty::Closure(..)
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::Bool
|
||||
| ty::Char
|
||||
| ty::Int(..)
|
||||
|
@ -119,26 +119,6 @@ impl<'tcx> TypeRelation<'tcx> for Equate<'_, '_, 'tcx> {
|
||||
.obligations,
|
||||
);
|
||||
}
|
||||
// Optimization of GeneratorWitness relation since we know that all
|
||||
// free regions are replaced with bound regions during construction.
|
||||
// This greatly speeds up equating of GeneratorWitness.
|
||||
(&ty::GeneratorWitness(a_types), &ty::GeneratorWitness(b_types)) => {
|
||||
let a_types = infcx.tcx.anonymize_bound_vars(a_types);
|
||||
let b_types = infcx.tcx.anonymize_bound_vars(b_types);
|
||||
if a_types.bound_vars() == b_types.bound_vars() {
|
||||
let (a_types, b_types) = infcx.instantiate_binder_with_placeholders(
|
||||
a_types.map_bound(|a_types| (a_types, b_types.skip_binder())),
|
||||
);
|
||||
for (a, b) in std::iter::zip(a_types, b_types) {
|
||||
self.relate(a, b)?;
|
||||
}
|
||||
} else {
|
||||
return Err(ty::error::TypeError::Sorts(ty::relate::expected_found(
|
||||
self, a, b,
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
_ => {
|
||||
self.fields.infcx.super_combine_tys(self, a, b)?;
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ fn compute_components<'tcx>(
|
||||
}
|
||||
|
||||
// All regions are bound inside a witness
|
||||
ty::GeneratorWitness(..) | ty::GeneratorWitnessMIR(..) => (),
|
||||
ty::GeneratorWitness(..) => (),
|
||||
|
||||
// OutlivesTypeParameterEnv -- the actual checking that `X:'a`
|
||||
// is implied by the environment is done in regionck.
|
||||
|
@ -147,25 +147,6 @@ impl<'tcx> TypeRelation<'tcx> for Sub<'_, '_, 'tcx> {
|
||||
);
|
||||
Ok(a)
|
||||
}
|
||||
// Optimization of GeneratorWitness relation since we know that all
|
||||
// free regions are replaced with bound regions during construction.
|
||||
// This greatly speeds up subtyping of GeneratorWitness.
|
||||
(&ty::GeneratorWitness(a_types), &ty::GeneratorWitness(b_types)) => {
|
||||
let a_types = infcx.tcx.anonymize_bound_vars(a_types);
|
||||
let b_types = infcx.tcx.anonymize_bound_vars(b_types);
|
||||
if a_types.bound_vars() == b_types.bound_vars() {
|
||||
let (a_types, b_types) = infcx.instantiate_binder_with_placeholders(
|
||||
a_types.map_bound(|a_types| (a_types, b_types.skip_binder())),
|
||||
);
|
||||
for (a, b) in std::iter::zip(a_types, b_types) {
|
||||
self.relate(a, b)?;
|
||||
}
|
||||
Ok(a)
|
||||
} else {
|
||||
Err(ty::error::TypeError::Sorts(ty::relate::expected_found(self, a, b)))
|
||||
}
|
||||
}
|
||||
|
||||
_ => {
|
||||
self.fields.infcx.super_combine_tys(self, a, b)?;
|
||||
Ok(a)
|
||||
|
@ -1271,7 +1271,6 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
||||
| ty::Closure(..)
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::Placeholder(..)
|
||||
| ty::FnDef(..) => bug!("unexpected type in foreign function: {:?}", ty),
|
||||
}
|
||||
|
@ -1384,7 +1384,6 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
Placeholder,
|
||||
Generator,
|
||||
GeneratorWitness,
|
||||
GeneratorWitnessMIR,
|
||||
Dynamic,
|
||||
Closure,
|
||||
Tuple,
|
||||
|
@ -242,8 +242,7 @@ impl<'tcx> Ty<'tcx> {
|
||||
ty::Dynamic(..) => "trait object".into(),
|
||||
ty::Closure(..) => "closure".into(),
|
||||
ty::Generator(def_id, ..) => tcx.generator_kind(def_id).unwrap().descr().into(),
|
||||
ty::GeneratorWitness(..) |
|
||||
ty::GeneratorWitnessMIR(..) => "generator witness".into(),
|
||||
ty::GeneratorWitness(..) => "generator witness".into(),
|
||||
ty::Infer(ty::TyVar(_)) => "inferred type".into(),
|
||||
ty::Infer(ty::IntVar(_)) => "integer".into(),
|
||||
ty::Infer(ty::FloatVar(_)) => "floating-point number".into(),
|
||||
@ -295,7 +294,7 @@ impl<'tcx> Ty<'tcx> {
|
||||
ty::Dynamic(..) => "trait object".into(),
|
||||
ty::Closure(..) => "closure".into(),
|
||||
ty::Generator(def_id, ..) => tcx.generator_kind(def_id).unwrap().descr().into(),
|
||||
ty::GeneratorWitness(..) | ty::GeneratorWitnessMIR(..) => "generator witness".into(),
|
||||
ty::GeneratorWitness(..) => "generator witness".into(),
|
||||
ty::Tuple(..) => "tuple".into(),
|
||||
ty::Placeholder(..) => "higher-ranked type".into(),
|
||||
ty::Bound(..) => "bound type variable".into(),
|
||||
|
@ -29,8 +29,7 @@ pub enum SimplifiedType {
|
||||
Trait(DefId),
|
||||
Closure(DefId),
|
||||
Generator(DefId),
|
||||
GeneratorWitness(usize),
|
||||
GeneratorWitnessMIR(DefId),
|
||||
GeneratorWitness(DefId),
|
||||
Function(usize),
|
||||
Placeholder,
|
||||
}
|
||||
@ -130,10 +129,7 @@ pub fn simplify_type<'tcx>(
|
||||
ty::Ref(_, _, mutbl) => Some(SimplifiedType::Ref(mutbl)),
|
||||
ty::FnDef(def_id, _) | ty::Closure(def_id, _) => Some(SimplifiedType::Closure(def_id)),
|
||||
ty::Generator(def_id, _, _) => Some(SimplifiedType::Generator(def_id)),
|
||||
ty::GeneratorWitness(tys) => {
|
||||
Some(SimplifiedType::GeneratorWitness(tys.skip_binder().len()))
|
||||
}
|
||||
ty::GeneratorWitnessMIR(def_id, _) => Some(SimplifiedType::GeneratorWitnessMIR(def_id)),
|
||||
ty::GeneratorWitness(def_id, _) => Some(SimplifiedType::GeneratorWitness(def_id)),
|
||||
ty::Never => Some(SimplifiedType::Never),
|
||||
ty::Tuple(tys) => Some(SimplifiedType::Tuple(tys.len())),
|
||||
ty::FnPtr(f) => Some(SimplifiedType::Function(f.skip_binder().inputs().len())),
|
||||
@ -169,7 +165,7 @@ impl SimplifiedType {
|
||||
| SimplifiedType::Trait(d)
|
||||
| SimplifiedType::Closure(d)
|
||||
| SimplifiedType::Generator(d)
|
||||
| SimplifiedType::GeneratorWitnessMIR(d) => Some(d),
|
||||
| SimplifiedType::GeneratorWitness(d) => Some(d),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@ -240,7 +236,6 @@ impl DeepRejectCtxt {
|
||||
| ty::Closure(..)
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::Placeholder(..)
|
||||
| ty::Bound(..)
|
||||
| ty::Infer(_) => bug!("unexpected impl_ty: {impl_ty}"),
|
||||
@ -342,7 +337,7 @@ impl DeepRejectCtxt {
|
||||
|
||||
ty::Error(_) => true,
|
||||
|
||||
ty::GeneratorWitness(..) | ty::GeneratorWitnessMIR(..) => {
|
||||
ty::GeneratorWitness(..) => {
|
||||
bug!("unexpected obligation type: {:?}", obligation_ty)
|
||||
}
|
||||
}
|
||||
|
@ -127,11 +127,7 @@ impl FlagComputation {
|
||||
self.add_ty(args.tupled_upvars_ty());
|
||||
}
|
||||
|
||||
&ty::GeneratorWitness(ts) => {
|
||||
self.bound_computation(ts, |flags, ts| flags.add_tys(ts));
|
||||
}
|
||||
|
||||
ty::GeneratorWitnessMIR(_, args) => {
|
||||
ty::GeneratorWitness(_, args) => {
|
||||
let should_remove_further_specializable =
|
||||
!self.flags.contains(TypeFlags::STILL_FURTHER_SPECIALIZABLE);
|
||||
self.add_args(args);
|
||||
|
@ -810,7 +810,6 @@ where
|
||||
| ty::Never
|
||||
| ty::FnDef(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::Foreign(..)
|
||||
| ty::Dynamic(_, _, ty::Dyn) => {
|
||||
bug!("TyAndLayout::field({:?}): not applicable", this)
|
||||
|
@ -157,9 +157,9 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseMapper<'tcx> {
|
||||
Ty::new_generator(self.tcx, def_id, args, movability)
|
||||
}
|
||||
|
||||
ty::GeneratorWitnessMIR(def_id, args) => {
|
||||
ty::GeneratorWitness(def_id, args) => {
|
||||
let args = self.fold_closure_args(def_id, args);
|
||||
Ty::new_generator_witness_mir(self.tcx, def_id, args)
|
||||
Ty::new_generator_witness(self.tcx, def_id, args)
|
||||
}
|
||||
|
||||
ty::Param(param) => {
|
||||
|
@ -271,7 +271,7 @@ fn characteristic_def_id_of_type_cached<'a>(
|
||||
ty::FnDef(def_id, _)
|
||||
| ty::Closure(def_id, _)
|
||||
| ty::Generator(def_id, _, _)
|
||||
| ty::GeneratorWitnessMIR(def_id, _)
|
||||
| ty::GeneratorWitness(def_id, _)
|
||||
| ty::Foreign(def_id) => Some(def_id),
|
||||
|
||||
ty::Bool
|
||||
@ -286,7 +286,6 @@ fn characteristic_def_id_of_type_cached<'a>(
|
||||
| ty::Infer(_)
|
||||
| ty::Bound(..)
|
||||
| ty::Error(_)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::Never
|
||||
| ty::Float(_) => None,
|
||||
}
|
||||
|
@ -838,10 +838,7 @@ pub trait PrettyPrinter<'tcx>:
|
||||
|
||||
p!("}}")
|
||||
}
|
||||
ty::GeneratorWitness(types) => {
|
||||
p!(in_binder(&types));
|
||||
}
|
||||
ty::GeneratorWitnessMIR(did, args) => {
|
||||
ty::GeneratorWitness(did, args) => {
|
||||
p!(write("{{"));
|
||||
if !self.tcx().sess.verbose() {
|
||||
p!("generator witness");
|
||||
|
@ -453,24 +453,14 @@ pub fn structurally_relate_tys<'tcx, R: TypeRelation<'tcx>>(
|
||||
Ok(Ty::new_generator(tcx, a_id, args, movability))
|
||||
}
|
||||
|
||||
(&ty::GeneratorWitness(a_types), &ty::GeneratorWitness(b_types)) => {
|
||||
// Wrap our types with a temporary GeneratorWitness struct
|
||||
// inside the binder so we can related them
|
||||
let a_types = a_types.map_bound(GeneratorWitness);
|
||||
let b_types = b_types.map_bound(GeneratorWitness);
|
||||
// Then remove the GeneratorWitness for the result
|
||||
let types = relation.relate(a_types, b_types)?.map_bound(|witness| witness.0);
|
||||
Ok(Ty::new_generator_witness(tcx, types))
|
||||
}
|
||||
|
||||
(&ty::GeneratorWitnessMIR(a_id, a_args), &ty::GeneratorWitnessMIR(b_id, b_args))
|
||||
(&ty::GeneratorWitness(a_id, a_args), &ty::GeneratorWitness(b_id, b_args))
|
||||
if a_id == b_id =>
|
||||
{
|
||||
// All GeneratorWitness types with the same id represent
|
||||
// the (anonymous) type of the same generator expression. So
|
||||
// all of their regions should be equated.
|
||||
let args = relation.relate(a_args, b_args)?;
|
||||
Ok(Ty::new_generator_witness_mir(tcx, a_id, args))
|
||||
Ok(Ty::new_generator_witness(tcx, a_id, args))
|
||||
}
|
||||
|
||||
(&ty::Closure(a_id, a_args), &ty::Closure(b_id, b_args)) if a_id == b_id => {
|
||||
|
@ -657,9 +657,8 @@ impl<'tcx> TypeSuperFoldable<TyCtxt<'tcx>> for Ty<'tcx> {
|
||||
ty::Generator(did, args, movability) => {
|
||||
ty::Generator(did, args.try_fold_with(folder)?, movability)
|
||||
}
|
||||
ty::GeneratorWitness(types) => ty::GeneratorWitness(types.try_fold_with(folder)?),
|
||||
ty::GeneratorWitnessMIR(did, args) => {
|
||||
ty::GeneratorWitnessMIR(did, args.try_fold_with(folder)?)
|
||||
ty::GeneratorWitness(did, args) => {
|
||||
ty::GeneratorWitness(did, args.try_fold_with(folder)?)
|
||||
}
|
||||
ty::Closure(did, args) => ty::Closure(did, args.try_fold_with(folder)?),
|
||||
ty::Alias(kind, data) => ty::Alias(kind, data.try_fold_with(folder)?),
|
||||
@ -708,8 +707,7 @@ impl<'tcx> TypeSuperVisitable<TyCtxt<'tcx>> for Ty<'tcx> {
|
||||
ty.visit_with(visitor)
|
||||
}
|
||||
ty::Generator(_did, ref args, _) => args.visit_with(visitor),
|
||||
ty::GeneratorWitness(ref types) => types.visit_with(visitor),
|
||||
ty::GeneratorWitnessMIR(_did, ref args) => args.visit_with(visitor),
|
||||
ty::GeneratorWitness(_did, ref args) => args.visit_with(visitor),
|
||||
ty::Closure(_did, ref args) => args.visit_with(visitor),
|
||||
ty::Alias(_, ref data) => data.visit_with(visitor),
|
||||
|
||||
|
@ -2164,19 +2164,11 @@ impl<'tcx> Ty<'tcx> {
|
||||
|
||||
#[inline]
|
||||
pub fn new_generator_witness(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
types: ty::Binder<'tcx, &'tcx List<Ty<'tcx>>>,
|
||||
) -> Ty<'tcx> {
|
||||
Ty::new(tcx, GeneratorWitness(types))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn new_generator_witness_mir(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
id: DefId,
|
||||
args: GenericArgsRef<'tcx>,
|
||||
) -> Ty<'tcx> {
|
||||
Ty::new(tcx, GeneratorWitnessMIR(id, args))
|
||||
Ty::new(tcx, GeneratorWitness(id, args))
|
||||
}
|
||||
|
||||
// misc
|
||||
@ -2706,7 +2698,6 @@ impl<'tcx> Ty<'tcx> {
|
||||
| ty::Dynamic(..)
|
||||
| ty::Closure(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::Never
|
||||
| ty::Tuple(_)
|
||||
| ty::Error(_)
|
||||
@ -2742,7 +2733,6 @@ impl<'tcx> Ty<'tcx> {
|
||||
| ty::Ref(..)
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::Array(..)
|
||||
| ty::Closure(..)
|
||||
| ty::Never
|
||||
@ -2831,7 +2821,6 @@ impl<'tcx> Ty<'tcx> {
|
||||
| ty::Ref(..)
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::Array(..)
|
||||
| ty::Closure(..)
|
||||
| ty::Never
|
||||
@ -2894,7 +2883,7 @@ impl<'tcx> Ty<'tcx> {
|
||||
// anything with custom metadata it might be more complicated.
|
||||
ty::Ref(_, _, hir::Mutability::Not) | ty::RawPtr(..) => false,
|
||||
|
||||
ty::Generator(..) | ty::GeneratorWitness(..) | ty::GeneratorWitnessMIR(..) => false,
|
||||
ty::Generator(..) | ty::GeneratorWitness(..) => false,
|
||||
|
||||
// Might be, but not "trivial" so just giving the safe answer.
|
||||
ty::Adt(..) | ty::Closure(..) => false,
|
||||
@ -2970,8 +2959,7 @@ impl<'tcx> Ty<'tcx> {
|
||||
| Dynamic(_, _, _)
|
||||
| Closure(_, _)
|
||||
| Generator(_, _, _)
|
||||
| GeneratorWitness(_)
|
||||
| GeneratorWitnessMIR(_, _)
|
||||
| GeneratorWitness(..)
|
||||
| Never
|
||||
| Tuple(_) => true,
|
||||
Error(_) | Infer(_) | Alias(_, _) | Param(_) | Bound(_, _) | Placeholder(_) => false,
|
||||
|
@ -855,7 +855,7 @@ impl<'tcx> OpaqueTypeExpander<'tcx> {
|
||||
let hidden_ty = bty.instantiate(self.tcx, args);
|
||||
self.fold_ty(hidden_ty);
|
||||
}
|
||||
let expanded_ty = Ty::new_generator_witness_mir(self.tcx, def_id, args);
|
||||
let expanded_ty = Ty::new_generator_witness(self.tcx, def_id, args);
|
||||
self.expanded_cache.insert((def_id, args), expanded_ty);
|
||||
expanded_ty
|
||||
}
|
||||
@ -888,7 +888,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for OpaqueTypeExpander<'tcx> {
|
||||
t
|
||||
};
|
||||
if self.expand_generators {
|
||||
if let ty::GeneratorWitnessMIR(def_id, args) = *t.kind() {
|
||||
if let ty::GeneratorWitness(def_id, args) = *t.kind() {
|
||||
t = self.expand_generator(def_id, args).unwrap_or(t);
|
||||
}
|
||||
}
|
||||
@ -1025,8 +1025,7 @@ impl<'tcx> Ty<'tcx> {
|
||||
| ty::Dynamic(..)
|
||||
| ty::Foreign(_)
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(_)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::Infer(_)
|
||||
| ty::Alias(..)
|
||||
| ty::Param(_)
|
||||
@ -1065,8 +1064,7 @@ impl<'tcx> Ty<'tcx> {
|
||||
| ty::Dynamic(..)
|
||||
| ty::Foreign(_)
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(_)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::Infer(_)
|
||||
| ty::Alias(..)
|
||||
| ty::Param(_)
|
||||
@ -1194,10 +1192,7 @@ impl<'tcx> Ty<'tcx> {
|
||||
false
|
||||
}
|
||||
|
||||
ty::Foreign(_)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::Error(_) => false,
|
||||
ty::Foreign(_) | ty::GeneratorWitness(..) | ty::Error(_) => false,
|
||||
}
|
||||
}
|
||||
|
||||
@ -1293,7 +1288,6 @@ pub fn needs_drop_components<'tcx>(
|
||||
| ty::FnPtr(_)
|
||||
| ty::Char
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::RawPtr(_)
|
||||
| ty::Ref(..)
|
||||
| ty::Str => Ok(SmallVec::new()),
|
||||
@ -1364,11 +1358,7 @@ pub fn is_trivially_const_drop(ty: Ty<'_>) -> bool {
|
||||
|
||||
// Not trivial because they have components, and instead of looking inside,
|
||||
// we'll just perform trait selection.
|
||||
ty::Closure(..)
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(_)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::Adt(..) => false,
|
||||
ty::Closure(..) | ty::Generator(..) | ty::GeneratorWitness(..) | ty::Adt(..) => false,
|
||||
|
||||
ty::Array(ty, _) | ty::Slice(ty) => is_trivially_const_drop(ty),
|
||||
|
||||
|
@ -190,14 +190,11 @@ fn push_inner<'tcx>(stack: &mut TypeWalkerStack<'tcx>, parent: GenericArg<'tcx>)
|
||||
ty::Adt(_, args)
|
||||
| ty::Closure(_, args)
|
||||
| ty::Generator(_, args, _)
|
||||
| ty::GeneratorWitnessMIR(_, args)
|
||||
| ty::GeneratorWitness(_, args)
|
||||
| ty::FnDef(_, args) => {
|
||||
stack.extend(args.iter().rev());
|
||||
}
|
||||
ty::Tuple(ts) => stack.extend(ts.iter().rev().map(GenericArg::from)),
|
||||
ty::GeneratorWitness(ts) => {
|
||||
stack.extend(ts.skip_binder().iter().rev().map(|ty| ty.into()));
|
||||
}
|
||||
ty::FnPtr(sig) => {
|
||||
stack.push(sig.skip_binder().output().into());
|
||||
stack.extend(sig.skip_binder().inputs().iter().copied().rev().map(|ty| ty.into()));
|
||||
|
@ -144,8 +144,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
|
||||
| ty::Dynamic(_, _, _)
|
||||
| ty::Closure(_, _)
|
||||
| ty::Generator(_, _, _)
|
||||
| ty::GeneratorWitness(_)
|
||||
| ty::GeneratorWitnessMIR(_, _)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::Never
|
||||
| ty::Tuple(_)
|
||||
| ty::Alias(_, _)
|
||||
@ -184,8 +183,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
|
||||
| ty::FnDef(_, _)
|
||||
| ty::FnPtr(_)
|
||||
| ty::Dynamic(_, _, _)
|
||||
| ty::GeneratorWitness(_)
|
||||
| ty::GeneratorWitnessMIR(_, _)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::Never
|
||||
| ty::Alias(_, _)
|
||||
| ty::Param(_)
|
||||
|
@ -291,8 +291,7 @@ where
|
||||
| ty::Param(..)
|
||||
| ty::Bound(..)
|
||||
| ty::Error(_)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::GeneratorWitnessMIR(..) => {}
|
||||
| ty::GeneratorWitness(..) => {}
|
||||
ty::Placeholder(..) | ty::Infer(..) => {
|
||||
bug!("unexpected type: {:?}", ty)
|
||||
}
|
||||
|
@ -1128,11 +1128,7 @@ impl<'tcx> Stable<'tcx> for Ty<'tcx> {
|
||||
ty::Bound(debruijn_idx, bound_ty) => {
|
||||
TyKind::Bound(debruijn_idx.as_usize(), bound_ty.stable(tables))
|
||||
}
|
||||
ty::Placeholder(..)
|
||||
| ty::GeneratorWitness(_)
|
||||
| ty::GeneratorWitnessMIR(_, _)
|
||||
| ty::Infer(_)
|
||||
| ty::Error(_) => {
|
||||
ty::Placeholder(..) | ty::GeneratorWitness(..) | ty::Infer(_) | ty::Error(_) => {
|
||||
unreachable!();
|
||||
}
|
||||
}
|
||||
|
@ -720,7 +720,6 @@ fn encode_ty<'tcx>(
|
||||
| ty::Bound(..)
|
||||
| ty::Error(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::Infer(..)
|
||||
| ty::Placeholder(..) => {
|
||||
bug!("encode_ty: unexpected `{:?}`", ty.kind());
|
||||
@ -779,7 +778,6 @@ fn transform_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, options: TransformTyOptio
|
||||
| ty::Str
|
||||
| ty::Never
|
||||
| ty::Foreign(..)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::GeneratorWitness(..) => {}
|
||||
|
||||
ty::Bool => {
|
||||
|
@ -484,8 +484,7 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> {
|
||||
|
||||
ty::Alias(ty::Inherent, _) => bug!("symbol_names: unexpected inherent projection"),
|
||||
ty::Alias(ty::Weak, _) => bug!("symbol_names: unexpected weak projection"),
|
||||
ty::GeneratorWitness(_) => bug!("symbol_names: unexpected `GeneratorWitness`"),
|
||||
ty::GeneratorWitnessMIR(..) => bug!("symbol_names: unexpected `GeneratorWitnessMIR`"),
|
||||
ty::GeneratorWitness(..) => bug!("symbol_names: unexpected `GeneratorWitness`"),
|
||||
}
|
||||
|
||||
// Only cache types that do not refer to an enclosing
|
||||
|
@ -469,7 +469,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
||||
// FIXME: These should ideally not exist as a self type. It would be nice for
|
||||
// the builtin auto trait impls of generators to instead directly recurse
|
||||
// into the witness.
|
||||
ty::GeneratorWitness(_) | ty::GeneratorWitnessMIR(_, _) => (),
|
||||
ty::GeneratorWitness(..) => (),
|
||||
|
||||
// These variants should not exist as a self type.
|
||||
ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_))
|
||||
@ -621,8 +621,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
||||
| ty::Dynamic(..)
|
||||
| ty::Closure(..)
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(_)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::Never
|
||||
| ty::Tuple(_)
|
||||
| ty::Param(_)
|
||||
@ -778,8 +777,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
||||
| ty::Alias(..)
|
||||
| ty::Closure(..)
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(_)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::Never
|
||||
| ty::Tuple(_)
|
||||
| ty::Param(_)
|
||||
|
@ -61,9 +61,7 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_auto_trait<'tcx>(
|
||||
Ok(vec![generator_args.tupled_upvars_ty(), generator_args.witness()])
|
||||
}
|
||||
|
||||
ty::GeneratorWitness(types) => Ok(ecx.instantiate_binder_with_placeholders(types).to_vec()),
|
||||
|
||||
ty::GeneratorWitnessMIR(def_id, args) => Ok(ecx
|
||||
ty::GeneratorWitness(def_id, args) => Ok(ecx
|
||||
.tcx()
|
||||
.generator_hidden_types(def_id)
|
||||
.map(|bty| {
|
||||
@ -127,7 +125,6 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_sized_trait<'tcx>(
|
||||
| ty::Ref(..)
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::Array(..)
|
||||
| ty::Closure(..)
|
||||
| ty::Never
|
||||
@ -204,9 +201,7 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_copy_clone_trait<'tcx>(
|
||||
}
|
||||
}
|
||||
|
||||
ty::GeneratorWitness(types) => Ok(ecx.instantiate_binder_with_placeholders(types).to_vec()),
|
||||
|
||||
ty::GeneratorWitnessMIR(def_id, args) => Ok(ecx
|
||||
ty::GeneratorWitness(def_id, args) => Ok(ecx
|
||||
.tcx()
|
||||
.generator_hidden_types(def_id)
|
||||
.map(|bty| {
|
||||
@ -282,8 +277,7 @@ pub(in crate::solve) fn extract_tupled_inputs_and_output_from_callable<'tcx>(
|
||||
| ty::Ref(_, _, _)
|
||||
| ty::Dynamic(_, _, _)
|
||||
| ty::Generator(_, _, _)
|
||||
| ty::GeneratorWitness(_)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::Never
|
||||
| ty::Tuple(_)
|
||||
| ty::Alias(_, _)
|
||||
|
@ -330,8 +330,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'_, 'tcx> {
|
||||
| ty::Dynamic(_, _, _)
|
||||
| ty::Closure(_, _)
|
||||
| ty::Generator(_, _, _)
|
||||
| ty::GeneratorWitness(_)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::Never
|
||||
| ty::Tuple(_)
|
||||
| ty::Alias(_, _)
|
||||
|
@ -388,7 +388,6 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
|
||||
| ty::Infer(ty::IntVar(..) | ty::FloatVar(..))
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::Never
|
||||
| ty::Foreign(..) => tcx.types.unit,
|
||||
|
||||
@ -556,7 +555,6 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
|
||||
| ty::Infer(ty::IntVar(..) | ty::FloatVar(..))
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::Never
|
||||
| ty::Foreign(..)
|
||||
| ty::Adt(_, _)
|
||||
|
@ -879,8 +879,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
||||
| ty::FnPtr(_)
|
||||
| ty::Closure(_, _)
|
||||
| ty::Generator(_, _, _)
|
||||
| ty::GeneratorWitness(_)
|
||||
| ty::GeneratorWitnessMIR(_, _)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::Never
|
||||
| ty::Tuple(_)
|
||||
| ty::Adt(_, _)
|
||||
|
@ -827,9 +827,7 @@ where
|
||||
// This should only be created when checking whether we have to check whether some
|
||||
// auto trait impl applies. There will never be multiple impls, so we can just
|
||||
// act as if it were a local type here.
|
||||
ty::GeneratorWitness(_) | ty::GeneratorWitnessMIR(..) => {
|
||||
ControlFlow::Break(OrphanCheckEarlyExit::LocalTy(ty))
|
||||
}
|
||||
ty::GeneratorWitness(..) => ControlFlow::Break(OrphanCheckEarlyExit::LocalTy(ty)),
|
||||
ty::Alias(ty::Opaque, ..) => {
|
||||
// This merits some explanation.
|
||||
// Normally, opaque types are not involved when performing
|
||||
|
@ -1847,7 +1847,6 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
ty::Generator(..) => Some(18),
|
||||
ty::Foreign(..) => Some(19),
|
||||
ty::GeneratorWitness(..) => Some(20),
|
||||
ty::GeneratorWitnessMIR(..) => Some(21),
|
||||
ty::Placeholder(..) | ty::Bound(..) | ty::Infer(..) | ty::Error(_) => None,
|
||||
}
|
||||
}
|
||||
|
@ -2173,11 +2173,10 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
);
|
||||
|
||||
match *ty.kind() {
|
||||
ty::Generator(did, ..) | ty::GeneratorWitnessMIR(did, _) => {
|
||||
ty::Generator(did, ..) | ty::GeneratorWitness(did, _) => {
|
||||
generator = generator.or(Some(did));
|
||||
outer_generator = Some(did);
|
||||
}
|
||||
ty::GeneratorWitness(..) => {}
|
||||
ty::Tuple(_) if !seen_upvar_tys_infer_tuple => {
|
||||
// By introducing a tuple of upvar types into the chain of obligations
|
||||
// of a generator, the first non-generator item is now the tuple itself,
|
||||
@ -2203,11 +2202,10 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
);
|
||||
|
||||
match *ty.kind() {
|
||||
ty::Generator(did, ..) | ty::GeneratorWitnessMIR(did, ..) => {
|
||||
ty::Generator(did, ..) | ty::GeneratorWitness(did, ..) => {
|
||||
generator = generator.or(Some(did));
|
||||
outer_generator = Some(did);
|
||||
}
|
||||
ty::GeneratorWitness(..) => {}
|
||||
ty::Tuple(_) if !seen_upvar_tys_infer_tuple => {
|
||||
// By introducing a tuple of upvar types into the chain of obligations
|
||||
// of a generator, the first non-generator item is now the tuple itself,
|
||||
@ -2987,20 +2985,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
}
|
||||
err.span_note(self.tcx.def_span(def_id), msg)
|
||||
}
|
||||
ty::GeneratorWitness(bound_tys) => {
|
||||
use std::fmt::Write;
|
||||
|
||||
// FIXME: this is kind of an unusual format for rustc, can we make it more clear?
|
||||
// Maybe we should just remove this note altogether?
|
||||
// FIXME: only print types which don't meet the trait requirement
|
||||
let mut msg =
|
||||
"required because it captures the following types: ".to_owned();
|
||||
for ty in bound_tys.skip_binder() {
|
||||
with_forced_trimmed_paths!(write!(msg, "`{ty}`, ").unwrap());
|
||||
}
|
||||
err.note(msg.trim_end_matches(", ").to_string())
|
||||
}
|
||||
ty::GeneratorWitnessMIR(def_id, args) => {
|
||||
ty::GeneratorWitness(def_id, args) => {
|
||||
use std::fmt::Write;
|
||||
|
||||
// FIXME: this is kind of an unusual format for rustc, can we make it more clear?
|
||||
|
@ -1813,7 +1813,6 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
|
||||
| ty::Closure(..)
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::Never
|
||||
| ty::Tuple(..)
|
||||
// Integers and floats always have `u8` as their discriminant.
|
||||
@ -1863,7 +1862,6 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
|
||||
| ty::Closure(..)
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::Never
|
||||
// Extern types have unit metadata, according to RFC 2850
|
||||
| ty::Foreign(_)
|
||||
|
@ -36,7 +36,6 @@ pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool {
|
||||
| ty::FnPtr(_)
|
||||
| ty::Char
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::RawPtr(_)
|
||||
| ty::Ref(..)
|
||||
| ty::Str
|
||||
@ -218,8 +217,7 @@ pub fn dtorck_constraint_for_ty_inner<'tcx>(
|
||||
| ty::Ref(..)
|
||||
| ty::FnDef(..)
|
||||
| ty::FnPtr(_)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::GeneratorWitnessMIR(..) => {
|
||||
| ty::GeneratorWitness(..) => {
|
||||
// these types never have a destructor
|
||||
}
|
||||
|
||||
|
@ -436,8 +436,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
| ty::Ref(_, _, _)
|
||||
| ty::Closure(_, _)
|
||||
| ty::Generator(_, _, _)
|
||||
| ty::GeneratorWitness(_)
|
||||
| ty::GeneratorWitnessMIR(_, _)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::Never
|
||||
| ty::Tuple(_)
|
||||
| ty::Error(_) => return true,
|
||||
@ -569,8 +568,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
| ty::Generator(..)
|
||||
| ty::Never
|
||||
| ty::Tuple(_)
|
||||
| ty::GeneratorWitness(_)
|
||||
| ty::GeneratorWitnessMIR(..) => {
|
||||
| ty::GeneratorWitness(..) => {
|
||||
// Only consider auto impls if there are no manual impls for the root of `self_ty`.
|
||||
//
|
||||
// For example, we only consider auto candidates for `&i32: Auto` if no explicit impl
|
||||
@ -946,8 +944,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
| ty::Closure(..)
|
||||
| ty::Generator(..)
|
||||
| ty::Tuple(_)
|
||||
| ty::GeneratorWitness(_)
|
||||
| ty::GeneratorWitnessMIR(..) => {
|
||||
| ty::GeneratorWitness(..) => {
|
||||
// These are built-in, and cannot have a custom `impl const Destruct`.
|
||||
candidates.vec.push(ConstDestructCandidate(None));
|
||||
}
|
||||
@ -1020,8 +1017,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
| ty::Dynamic(_, _, _)
|
||||
| ty::Closure(_, _)
|
||||
| ty::Generator(_, _, _)
|
||||
| ty::GeneratorWitness(_)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::Never
|
||||
| ty::Alias(..)
|
||||
| ty::Param(_)
|
||||
@ -1083,7 +1079,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
| ty::Closure(..)
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::Never
|
||||
| ty::Tuple(..)
|
||||
| ty::Alias(..)
|
||||
|
@ -1238,10 +1238,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
let generator = args.as_generator();
|
||||
stack.extend([generator.tupled_upvars_ty(), generator.witness()]);
|
||||
}
|
||||
ty::GeneratorWitness(tys) => {
|
||||
stack.extend(tcx.erase_late_bound_regions(tys).to_vec());
|
||||
}
|
||||
ty::GeneratorWitnessMIR(def_id, args) => {
|
||||
ty::GeneratorWitness(def_id, args) => {
|
||||
let tcx = self.tcx();
|
||||
stack.extend(tcx.generator_hidden_types(def_id).map(|bty| {
|
||||
let ty = bty.instantiate(tcx, args);
|
||||
|
@ -2131,7 +2131,6 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
||||
| ty::Ref(..)
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::Array(..)
|
||||
| ty::Closure(..)
|
||||
| ty::Never
|
||||
@ -2230,22 +2229,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
ty::GeneratorWitness(binder) => {
|
||||
let witness_tys = binder.skip_binder();
|
||||
for witness_ty in witness_tys.iter() {
|
||||
let resolved = self.infcx.shallow_resolve(witness_ty);
|
||||
if resolved.is_ty_var() {
|
||||
return Ambiguous;
|
||||
}
|
||||
}
|
||||
// (*) binder moved here
|
||||
let all_vars = self.tcx().mk_bound_variable_kinds_from_iter(
|
||||
obligation.predicate.bound_vars().iter().chain(binder.bound_vars().iter()),
|
||||
);
|
||||
Where(ty::Binder::bind_with_vars(witness_tys.to_vec(), all_vars))
|
||||
}
|
||||
|
||||
ty::GeneratorWitnessMIR(def_id, ref args) => {
|
||||
ty::GeneratorWitness(def_id, ref args) => {
|
||||
let hidden_types = bind_generator_hidden_types_above(
|
||||
self.infcx,
|
||||
def_id,
|
||||
@ -2350,12 +2334,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
||||
t.rebind([ty].into_iter().chain(iter::once(witness)).collect())
|
||||
}
|
||||
|
||||
ty::GeneratorWitness(types) => {
|
||||
debug_assert!(!types.has_escaping_bound_vars());
|
||||
types.map_bound(|types| types.to_vec())
|
||||
}
|
||||
|
||||
ty::GeneratorWitnessMIR(def_id, ref args) => {
|
||||
ty::GeneratorWitness(def_id, ref args) => {
|
||||
bind_generator_hidden_types_above(self.infcx, def_id, args, t.bound_vars())
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for Search<'tcx> {
|
||||
ty::Closure(..) => {
|
||||
return ControlFlow::Break(ty);
|
||||
}
|
||||
ty::Generator(..) | ty::GeneratorWitness(..) | ty::GeneratorWitnessMIR(..) => {
|
||||
ty::Generator(..) | ty::GeneratorWitness(..) => {
|
||||
return ControlFlow::Break(ty);
|
||||
}
|
||||
ty::FnDef(..) => {
|
||||
|
@ -609,7 +609,6 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
||||
| ty::Error(_)
|
||||
| ty::Str
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::Never
|
||||
| ty::Param(_)
|
||||
| ty::Bound(..)
|
||||
|
@ -577,11 +577,7 @@ fn layout_of_uncached<'tcx>(
|
||||
return Err(error(cx, LayoutError::Unknown(ty)));
|
||||
}
|
||||
|
||||
ty::Bound(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::Infer(_)
|
||||
| ty::Error(_) => {
|
||||
ty::Bound(..) | ty::GeneratorWitness(..) | ty::Infer(_) | ty::Error(_) => {
|
||||
bug!("Layout::compute: unexpected type `{}`", ty)
|
||||
}
|
||||
|
||||
|
@ -192,7 +192,6 @@ where
|
||||
| ty::Tuple(_)
|
||||
| ty::Bound(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::Never
|
||||
| ty::Infer(_)
|
||||
| ty::Error(_) => {
|
||||
|
@ -21,13 +21,7 @@ fn sized_constraint_for_ty<'tcx>(
|
||||
Bool | Char | Int(..) | Uint(..) | Float(..) | RawPtr(..) | Ref(..) | FnDef(..)
|
||||
| FnPtr(_) | Array(..) | Closure(..) | Generator(..) | Never => vec![],
|
||||
|
||||
Str
|
||||
| Dynamic(..)
|
||||
| Slice(_)
|
||||
| Foreign(..)
|
||||
| Error(_)
|
||||
| GeneratorWitness(..)
|
||||
| GeneratorWitnessMIR(..) => {
|
||||
Str | Dynamic(..) | Slice(_) | Foreign(..) | Error(_) | GeneratorWitness(..) => {
|
||||
// these are never sized - return the target type
|
||||
vec![ty]
|
||||
}
|
||||
|
@ -143,31 +143,6 @@ pub enum TyKind<I: Interner> {
|
||||
/// `GeneratorArgs`.
|
||||
Generator(I::DefId, I::GenericArgsRef, I::Movability),
|
||||
|
||||
/// A type representing the types stored inside a generator.
|
||||
/// This should only appear as part of the `GeneratorArgs`.
|
||||
///
|
||||
/// Note that the captured variables for generators are stored separately
|
||||
/// using a tuple in the same way as for closures.
|
||||
///
|
||||
/// Unlike upvars, the witness can reference lifetimes from
|
||||
/// inside of the generator itself. To deal with them in
|
||||
/// the type of the generator, we convert them to higher ranked
|
||||
/// lifetimes bound by the witness itself.
|
||||
///
|
||||
/// Looking at the following example, the witness for this generator
|
||||
/// may end up as something like `for<'a> [Vec<i32>, &'a Vec<i32>]`:
|
||||
///
|
||||
/// ```ignore UNSOLVED (ask @compiler-errors, should this error? can we just swap the yields?)
|
||||
/// #![feature(generators)]
|
||||
/// |a| {
|
||||
/// let x = &vec![3];
|
||||
/// yield a;
|
||||
/// yield x[0];
|
||||
/// }
|
||||
/// # ;
|
||||
/// ```
|
||||
GeneratorWitness(I::BinderListTy),
|
||||
|
||||
/// A type representing the types stored inside a generator.
|
||||
/// This should only appear as part of the `GeneratorArgs`.
|
||||
///
|
||||
@ -192,7 +167,7 @@ pub enum TyKind<I: Interner> {
|
||||
/// }
|
||||
/// # ;
|
||||
/// ```
|
||||
GeneratorWitnessMIR(I::DefId, I::GenericArgsRef),
|
||||
GeneratorWitness(I::DefId, I::GenericArgsRef),
|
||||
|
||||
/// The never type `!`.
|
||||
Never,
|
||||
@ -278,7 +253,7 @@ const fn tykind_discriminant<I: Interner>(value: &TyKind<I>) -> usize {
|
||||
Dynamic(..) => 14,
|
||||
Closure(_, _) => 15,
|
||||
Generator(_, _, _) => 16,
|
||||
GeneratorWitness(_) => 17,
|
||||
GeneratorWitness(_, _) => 17,
|
||||
Never => 18,
|
||||
Tuple(_) => 19,
|
||||
Alias(_, _) => 20,
|
||||
@ -287,7 +262,6 @@ const fn tykind_discriminant<I: Interner>(value: &TyKind<I>) -> usize {
|
||||
Placeholder(_) => 23,
|
||||
Infer(_) => 24,
|
||||
Error(_) => 25,
|
||||
GeneratorWitnessMIR(_, _) => 26,
|
||||
}
|
||||
}
|
||||
|
||||
@ -312,8 +286,7 @@ impl<I: Interner> Clone for TyKind<I> {
|
||||
Dynamic(p, r, repr) => Dynamic(p.clone(), r.clone(), *repr),
|
||||
Closure(d, s) => Closure(d.clone(), s.clone()),
|
||||
Generator(d, s, m) => Generator(d.clone(), s.clone(), m.clone()),
|
||||
GeneratorWitness(g) => GeneratorWitness(g.clone()),
|
||||
GeneratorWitnessMIR(d, s) => GeneratorWitnessMIR(d.clone(), s.clone()),
|
||||
GeneratorWitness(d, s) => GeneratorWitness(d.clone(), s.clone()),
|
||||
Never => Never,
|
||||
Tuple(t) => Tuple(t.clone()),
|
||||
Alias(k, p) => Alias(*k, p.clone()),
|
||||
@ -355,10 +328,7 @@ impl<I: Interner> PartialEq for TyKind<I> {
|
||||
(Generator(a_d, a_s, a_m), Generator(b_d, b_s, b_m)) => {
|
||||
a_d == b_d && a_s == b_s && a_m == b_m
|
||||
}
|
||||
(GeneratorWitness(a_g), GeneratorWitness(b_g)) => a_g == b_g,
|
||||
(GeneratorWitnessMIR(a_d, a_s), GeneratorWitnessMIR(b_d, b_s)) => {
|
||||
a_d == b_d && a_s == b_s
|
||||
}
|
||||
(GeneratorWitness(a_d, a_s), GeneratorWitness(b_d, b_s)) => a_d == b_d && a_s == b_s,
|
||||
(Tuple(a_t), Tuple(b_t)) => a_t == b_t,
|
||||
(Alias(a_i, a_p), Alias(b_i, b_p)) => a_i == b_i && a_p == b_p,
|
||||
(Param(a_p), Param(b_p)) => a_p == b_p,
|
||||
@ -415,10 +385,9 @@ impl<I: Interner> Ord for TyKind<I> {
|
||||
(Generator(a_d, a_s, a_m), Generator(b_d, b_s, b_m)) => {
|
||||
a_d.cmp(b_d).then_with(|| a_s.cmp(b_s).then_with(|| a_m.cmp(b_m)))
|
||||
}
|
||||
(GeneratorWitness(a_g), GeneratorWitness(b_g)) => a_g.cmp(b_g),
|
||||
(
|
||||
GeneratorWitnessMIR(a_d, a_s),
|
||||
GeneratorWitnessMIR(b_d, b_s),
|
||||
GeneratorWitness(a_d, a_s),
|
||||
GeneratorWitness(b_d, b_s),
|
||||
) => match Ord::cmp(a_d, b_d) {
|
||||
Ordering::Equal => Ord::cmp(a_s, b_s),
|
||||
cmp => cmp,
|
||||
@ -483,8 +452,7 @@ impl<I: Interner> hash::Hash for TyKind<I> {
|
||||
s.hash(state);
|
||||
m.hash(state)
|
||||
}
|
||||
GeneratorWitness(g) => g.hash(state),
|
||||
GeneratorWitnessMIR(d, s) => {
|
||||
GeneratorWitness(d, s) => {
|
||||
d.hash(state);
|
||||
s.hash(state);
|
||||
}
|
||||
@ -558,9 +526,8 @@ impl<I: Interner> DebugWithInfcx<I> for TyKind<I> {
|
||||
},
|
||||
Closure(d, s) => f.debug_tuple_field2_finish("Closure", d, &this.wrap(s)),
|
||||
Generator(d, s, m) => f.debug_tuple_field3_finish("Generator", d, &this.wrap(s), m),
|
||||
GeneratorWitness(g) => f.debug_tuple_field1_finish("GeneratorWitness", &this.wrap(g)),
|
||||
GeneratorWitnessMIR(d, s) => {
|
||||
f.debug_tuple_field2_finish("GeneratorWitnessMIR", d, &this.wrap(s))
|
||||
GeneratorWitness(d, s) => {
|
||||
f.debug_tuple_field2_finish("GeneratorWitness", d, &this.wrap(s))
|
||||
}
|
||||
Never => write!(f, "!"),
|
||||
Tuple(t) => {
|
||||
@ -682,10 +649,7 @@ where
|
||||
args.encode(e);
|
||||
m.encode(e);
|
||||
}),
|
||||
GeneratorWitness(b) => e.emit_enum_variant(disc, |e| {
|
||||
b.encode(e);
|
||||
}),
|
||||
GeneratorWitnessMIR(def_id, args) => e.emit_enum_variant(disc, |e| {
|
||||
GeneratorWitness(def_id, args) => e.emit_enum_variant(disc, |e| {
|
||||
def_id.encode(e);
|
||||
args.encode(e);
|
||||
}),
|
||||
@ -762,7 +726,7 @@ where
|
||||
14 => Dynamic(Decodable::decode(d), Decodable::decode(d), Decodable::decode(d)),
|
||||
15 => Closure(Decodable::decode(d), Decodable::decode(d)),
|
||||
16 => Generator(Decodable::decode(d), Decodable::decode(d), Decodable::decode(d)),
|
||||
17 => GeneratorWitness(Decodable::decode(d)),
|
||||
17 => GeneratorWitness(Decodable::decode(d), Decodable::decode(d)),
|
||||
18 => Never,
|
||||
19 => Tuple(Decodable::decode(d)),
|
||||
20 => Alias(Decodable::decode(d), Decodable::decode(d)),
|
||||
@ -771,12 +735,11 @@ where
|
||||
23 => Placeholder(Decodable::decode(d)),
|
||||
24 => Infer(Decodable::decode(d)),
|
||||
25 => Error(Decodable::decode(d)),
|
||||
26 => GeneratorWitnessMIR(Decodable::decode(d), Decodable::decode(d)),
|
||||
_ => panic!(
|
||||
"{}",
|
||||
format!(
|
||||
"invalid enum variant tag while decoding `{}`, expected 0..{}",
|
||||
"TyKind", 27,
|
||||
"TyKind", 26,
|
||||
)
|
||||
),
|
||||
}
|
||||
@ -870,10 +833,7 @@ where
|
||||
args.hash_stable(__hcx, __hasher);
|
||||
m.hash_stable(__hcx, __hasher);
|
||||
}
|
||||
GeneratorWitness(b) => {
|
||||
b.hash_stable(__hcx, __hasher);
|
||||
}
|
||||
GeneratorWitnessMIR(def_id, args) => {
|
||||
GeneratorWitness(def_id, args) => {
|
||||
def_id.hash_stable(__hcx, __hasher);
|
||||
args.hash_stable(__hcx, __hasher);
|
||||
}
|
||||
|
@ -2288,7 +2288,6 @@ pub(crate) fn clean_middle_ty<'tcx>(
|
||||
ty::Bound(..) => panic!("Bound"),
|
||||
ty::Placeholder(..) => panic!("Placeholder"),
|
||||
ty::GeneratorWitness(..) => panic!("GeneratorWitness"),
|
||||
ty::GeneratorWitnessMIR(..) => panic!("GeneratorWitnessMIR"),
|
||||
ty::Infer(..) => panic!("Infer"),
|
||||
ty::Error(_) => rustc_errors::FatalError.raise(),
|
||||
}
|
||||
|
@ -522,8 +522,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
|
||||
ty::Alias(..)
|
||||
| ty::Closure(..)
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(_)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::Dynamic(..)
|
||||
| ty::Param(_)
|
||||
| ty::Bound(..)
|
||||
|
@ -940,7 +940,6 @@ impl TyCoercionStability {
|
||||
| ty::FnDef(..)
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::GeneratorWitnessMIR(..)
|
||||
| ty::Closure(..)
|
||||
| ty::Never
|
||||
| ty::Tuple(_)
|
||||
|
@ -31,7 +31,6 @@ fn main() {
|
||||
TyKind::Closure(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
TyKind::Generator(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
TyKind::GeneratorWitness(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
TyKind::GeneratorWitnessMIR(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
TyKind::Never => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
TyKind::Tuple(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
TyKind::Alias(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
|
@ -121,65 +121,59 @@ LL | TyKind::GeneratorWitness(..) => (),
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:34:9
|
||||
|
|
||||
LL | TyKind::GeneratorWitnessMIR(..) => (),
|
||||
LL | TyKind::Never => (),
|
||||
| ^^^^^^ help: try using `ty::<kind>` directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:35:9
|
||||
|
|
||||
LL | TyKind::Never => (),
|
||||
LL | TyKind::Tuple(..) => (),
|
||||
| ^^^^^^ help: try using `ty::<kind>` directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:36:9
|
||||
|
|
||||
LL | TyKind::Tuple(..) => (),
|
||||
LL | TyKind::Alias(..) => (),
|
||||
| ^^^^^^ help: try using `ty::<kind>` directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:37:9
|
||||
|
|
||||
LL | TyKind::Alias(..) => (),
|
||||
LL | TyKind::Param(..) => (),
|
||||
| ^^^^^^ help: try using `ty::<kind>` directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:38:9
|
||||
|
|
||||
LL | TyKind::Param(..) => (),
|
||||
LL | TyKind::Bound(..) => (),
|
||||
| ^^^^^^ help: try using `ty::<kind>` directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:39:9
|
||||
|
|
||||
LL | TyKind::Bound(..) => (),
|
||||
LL | TyKind::Placeholder(..) => (),
|
||||
| ^^^^^^ help: try using `ty::<kind>` directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:40:9
|
||||
|
|
||||
LL | TyKind::Placeholder(..) => (),
|
||||
LL | TyKind::Infer(..) => (),
|
||||
| ^^^^^^ help: try using `ty::<kind>` directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:41:9
|
||||
|
|
||||
LL | TyKind::Infer(..) => (),
|
||||
| ^^^^^^ help: try using `ty::<kind>` directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:42:9
|
||||
|
|
||||
LL | TyKind::Error(_) => (),
|
||||
| ^^^^^^ help: try using `ty::<kind>` directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:47:12
|
||||
--> $DIR/ty_tykind_usage.rs:46:12
|
||||
|
|
||||
LL | if let TyKind::Int(int_ty) = kind {}
|
||||
| ^^^^^^ help: try using `ty::<kind>` directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind`
|
||||
--> $DIR/ty_tykind_usage.rs:49:24
|
||||
--> $DIR/ty_tykind_usage.rs:48:24
|
||||
|
|
||||
LL | fn ty_kind(ty_bad: TyKind<'_>, ty_good: Ty<'_>) {}
|
||||
| ^^^^^^^^^^
|
||||
@ -187,7 +181,7 @@ LL | fn ty_kind(ty_bad: TyKind<'_>, ty_good: Ty<'_>) {}
|
||||
= help: try using `Ty` instead
|
||||
|
||||
error: usage of `ty::TyKind`
|
||||
--> $DIR/ty_tykind_usage.rs:51:37
|
||||
--> $DIR/ty_tykind_usage.rs:50:37
|
||||
|
|
||||
LL | fn ir_ty_kind<I: Interner>(bad: IrTyKind<I>) -> IrTyKind<I> {
|
||||
| ^^^^^^^^^^^
|
||||
@ -195,7 +189,7 @@ LL | fn ir_ty_kind<I: Interner>(bad: IrTyKind<I>) -> IrTyKind<I> {
|
||||
= help: try using `Ty` instead
|
||||
|
||||
error: usage of `ty::TyKind`
|
||||
--> $DIR/ty_tykind_usage.rs:51:53
|
||||
--> $DIR/ty_tykind_usage.rs:50:53
|
||||
|
|
||||
LL | fn ir_ty_kind<I: Interner>(bad: IrTyKind<I>) -> IrTyKind<I> {
|
||||
| ^^^^^^^^^^^
|
||||
@ -203,12 +197,12 @@ LL | fn ir_ty_kind<I: Interner>(bad: IrTyKind<I>) -> IrTyKind<I> {
|
||||
= help: try using `Ty` instead
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:54:9
|
||||
--> $DIR/ty_tykind_usage.rs:53:9
|
||||
|
|
||||
LL | IrTyKind::Bool
|
||||
| --------^^^^^^
|
||||
| |
|
||||
| help: try using `ty::<kind>` directly: `ty`
|
||||
|
||||
error: aborting due to 33 previous errors
|
||||
error: aborting due to 32 previous errors
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
error: symbol-name(_ZN5basic4main17h6fc0c8d27b1a289fE)
|
||||
error: symbol-name(_ZN5basic4main17h9308686d0228fa1dE)
|
||||
--> $DIR/basic.rs:8:1
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: demangling(basic::main::h6fc0c8d27b1a289f)
|
||||
error: demangling(basic::main::h9308686d0228fa1d)
|
||||
--> $DIR/basic.rs:8:1
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
|
@ -1,10 +1,10 @@
|
||||
error: symbol-name(_ZN11issue_609253foo37Foo$LT$issue_60925..llv$u6d$..Foo$GT$3foo17hab58a402db4ebf3aE)
|
||||
error: symbol-name(_ZN11issue_609253foo37Foo$LT$issue_60925..llv$u6d$..Foo$GT$3foo17h84ab5dafbd2a1508E)
|
||||
--> $DIR/issue-60925.rs:21:9
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: demangling(issue_60925::foo::Foo<issue_60925::llvm::Foo>::foo::hab58a402db4ebf3a)
|
||||
error: demangling(issue_60925::foo::Foo<issue_60925::llvm::Foo>::foo::h84ab5dafbd2a1508)
|
||||
--> $DIR/issue-60925.rs:21:9
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
|
Loading…
x
Reference in New Issue
Block a user