Skip to content

Commit 99729e4

Browse files
committed
Remove GeneratorWitness and rename GeneratorWitnessMIR.
1 parent 0c6c4c6 commit 99729e4

File tree

59 files changed

+89
-329
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+89
-329
lines changed

compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs

-1
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,6 @@ fn push_debuginfo_type_name<'tcx>(
426426
| ty::Placeholder(..)
427427
| ty::Alias(..)
428428
| ty::Bound(..)
429-
| ty::GeneratorWitnessMIR(..)
430429
| ty::GeneratorWitness(..) => {
431430
bug!(
432431
"debuginfo: Trying to create type name for \

compiler/rustc_const_eval/src/const_eval/valtrees.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ pub(crate) fn const_to_valtree_inner<'tcx>(
152152
// FIXME(oli-obk): we can probably encode closures just like structs
153153
| ty::Closure(..)
154154
| ty::Generator(..)
155-
| ty::GeneratorWitness(..) |ty::GeneratorWitnessMIR(..)=> Err(ValTreeCreationError::NonSupportedType),
155+
| ty::GeneratorWitness(..) => Err(ValTreeCreationError::NonSupportedType),
156156
}
157157
}
158158

@@ -280,7 +280,6 @@ pub fn valtree_to_const_value<'tcx>(
280280
| ty::Closure(..)
281281
| ty::Generator(..)
282282
| ty::GeneratorWitness(..)
283-
| ty::GeneratorWitnessMIR(..)
284283
| ty::FnPtr(_)
285284
| ty::RawPtr(_)
286285
| ty::Str

compiler/rustc_const_eval/src/interpret/eval_context.rs

-1
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,6 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
963963
| ty::Ref(..)
964964
| ty::Generator(..)
965965
| ty::GeneratorWitness(..)
966-
| ty::GeneratorWitnessMIR(..)
967966
| ty::Array(..)
968967
| ty::Closure(..)
969968
| ty::Never

compiler/rustc_const_eval/src/interpret/intrinsics.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ pub(crate) fn eval_nullary_intrinsic<'tcx>(
100100
| ty::Dynamic(_, _, _)
101101
| ty::Closure(_, _)
102102
| ty::Generator(_, _, _)
103-
| ty::GeneratorWitness(_)
104-
| ty::GeneratorWitnessMIR(_, _)
103+
| ty::GeneratorWitness(..)
105104
| ty::Never
106105
| ty::Tuple(_)
107106
| ty::Error(_) => ConstValue::from_target_usize(0u64, &tcx),

compiler/rustc_const_eval/src/interpret/validity.rs

-1
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,6 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
583583
| ty::Bound(..)
584584
| ty::Param(..)
585585
| ty::Alias(..)
586-
| ty::GeneratorWitnessMIR(..)
587586
| ty::GeneratorWitness(..) => bug!("Encountered invalid type {:?}", ty),
588587
}
589588
}

compiler/rustc_const_eval/src/util/type_name.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
6464

6565
ty::Alias(ty::Weak, _) => bug!("type_name: unexpected weak projection"),
6666
ty::Alias(ty::Inherent, _) => bug!("type_name: unexpected inherent projection"),
67-
ty::GeneratorWitness(_) => bug!("type_name: unexpected `GeneratorWitness`"),
68-
ty::GeneratorWitnessMIR(..) => bug!("type_name: unexpected `GeneratorWitnessMIR`"),
67+
ty::GeneratorWitness(..) => bug!("type_name: unexpected `GeneratorWitness`"),
6968
}
7069
}
7170

compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs

-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ impl<'tcx> InherentCollect<'tcx> {
157157
| ty::Closure(..)
158158
| ty::Generator(..)
159159
| ty::GeneratorWitness(..)
160-
| ty::GeneratorWitnessMIR(..)
161160
| ty::Bound(..)
162161
| ty::Placeholder(_)
163162
| ty::Infer(_) => {

compiler/rustc_hir_analysis/src/coherence/orphan.rs

-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,6 @@ fn do_orphan_check_impl<'tcx>(
245245
ty::Closure(..)
246246
| ty::Generator(..)
247247
| ty::GeneratorWitness(..)
248-
| ty::GeneratorWitnessMIR(..)
249248
| ty::Bound(..)
250249
| ty::Placeholder(..)
251250
| ty::Infer(..) => {

compiler/rustc_hir_analysis/src/variance/constraints.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -314,11 +314,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
314314
// types, where we use Error as the Self type
315315
}
316316

317-
ty::Placeholder(..)
318-
| ty::GeneratorWitness(..)
319-
| ty::GeneratorWitnessMIR(..)
320-
| ty::Bound(..)
321-
| ty::Infer(..) => {
317+
ty::Placeholder(..) | ty::GeneratorWitness(..) | ty::Bound(..) | ty::Infer(..) => {
322318
bug!("unexpected type encountered in variance inference: {}", ty);
323319
}
324320
}

compiler/rustc_hir_typeck/src/cast.rs

-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
129129
| ty::Float(_)
130130
| ty::Array(..)
131131
| ty::GeneratorWitness(..)
132-
| ty::GeneratorWitnessMIR(..)
133132
| ty::RawPtr(_)
134133
| ty::Ref(..)
135134
| ty::FnDef(..)

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
535535
self.tcx,
536536
self.tcx.typeck_root_def_id(expr_def_id.to_def_id()),
537537
);
538-
let witness = Ty::new_generator_witness_mir(self.tcx, expr_def_id.to_def_id(), args);
538+
let witness = Ty::new_generator_witness(self.tcx, expr_def_id.to_def_id(), args);
539539

540540
// Unify `interior` with `witness` and collect all the resulting obligations.
541541
let span = self.tcx.hir().body(body_id).value.span;

compiler/rustc_infer/src/infer/canonical/canonicalizer.rs

-1
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,6 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
459459
ty::Closure(..)
460460
| ty::Generator(..)
461461
| ty::GeneratorWitness(..)
462-
| ty::GeneratorWitnessMIR(..)
463462
| ty::Bool
464463
| ty::Char
465464
| ty::Int(..)

compiler/rustc_infer/src/infer/equate.rs

-20
Original file line numberDiff line numberDiff line change
@@ -119,26 +119,6 @@ impl<'tcx> TypeRelation<'tcx> for Equate<'_, '_, 'tcx> {
119119
.obligations,
120120
);
121121
}
122-
// Optimization of GeneratorWitness relation since we know that all
123-
// free regions are replaced with bound regions during construction.
124-
// This greatly speeds up equating of GeneratorWitness.
125-
(&ty::GeneratorWitness(a_types), &ty::GeneratorWitness(b_types)) => {
126-
let a_types = infcx.tcx.anonymize_bound_vars(a_types);
127-
let b_types = infcx.tcx.anonymize_bound_vars(b_types);
128-
if a_types.bound_vars() == b_types.bound_vars() {
129-
let (a_types, b_types) = infcx.instantiate_binder_with_placeholders(
130-
a_types.map_bound(|a_types| (a_types, b_types.skip_binder())),
131-
);
132-
for (a, b) in std::iter::zip(a_types, b_types) {
133-
self.relate(a, b)?;
134-
}
135-
} else {
136-
return Err(ty::error::TypeError::Sorts(ty::relate::expected_found(
137-
self, a, b,
138-
)));
139-
}
140-
}
141-
142122
_ => {
143123
self.fields.infcx.super_combine_tys(self, a, b)?;
144124
}

compiler/rustc_infer/src/infer/outlives/components.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ fn compute_components<'tcx>(
112112
}
113113

114114
// All regions are bound inside a witness
115-
ty::GeneratorWitness(..) | ty::GeneratorWitnessMIR(..) => (),
115+
ty::GeneratorWitness(..) => (),
116116

117117
// OutlivesTypeParameterEnv -- the actual checking that `X:'a`
118118
// is implied by the environment is done in regionck.

compiler/rustc_infer/src/infer/sub.rs

-19
Original file line numberDiff line numberDiff line change
@@ -147,25 +147,6 @@ impl<'tcx> TypeRelation<'tcx> for Sub<'_, '_, 'tcx> {
147147
);
148148
Ok(a)
149149
}
150-
// Optimization of GeneratorWitness relation since we know that all
151-
// free regions are replaced with bound regions during construction.
152-
// This greatly speeds up subtyping of GeneratorWitness.
153-
(&ty::GeneratorWitness(a_types), &ty::GeneratorWitness(b_types)) => {
154-
let a_types = infcx.tcx.anonymize_bound_vars(a_types);
155-
let b_types = infcx.tcx.anonymize_bound_vars(b_types);
156-
if a_types.bound_vars() == b_types.bound_vars() {
157-
let (a_types, b_types) = infcx.instantiate_binder_with_placeholders(
158-
a_types.map_bound(|a_types| (a_types, b_types.skip_binder())),
159-
);
160-
for (a, b) in std::iter::zip(a_types, b_types) {
161-
self.relate(a, b)?;
162-
}
163-
Ok(a)
164-
} else {
165-
Err(ty::error::TypeError::Sorts(ty::relate::expected_found(self, a, b)))
166-
}
167-
}
168-
169150
_ => {
170151
self.fields.infcx.super_combine_tys(self, a, b)?;
171152
Ok(a)

compiler/rustc_lint/src/types.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1271,7 +1271,6 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
12711271
| ty::Closure(..)
12721272
| ty::Generator(..)
12731273
| ty::GeneratorWitness(..)
1274-
| ty::GeneratorWitnessMIR(..)
12751274
| ty::Placeholder(..)
12761275
| ty::FnDef(..) => bug!("unexpected type in foreign function: {:?}", ty),
12771276
}

compiler/rustc_middle/src/ty/context.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1378,7 +1378,6 @@ impl<'tcx> TyCtxt<'tcx> {
13781378
Placeholder,
13791379
Generator,
13801380
GeneratorWitness,
1381-
GeneratorWitnessMIR,
13821381
Dynamic,
13831382
Closure,
13841383
Tuple,

compiler/rustc_middle/src/ty/error.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,7 @@ impl<'tcx> Ty<'tcx> {
242242
ty::Dynamic(..) => "trait object".into(),
243243
ty::Closure(..) => "closure".into(),
244244
ty::Generator(def_id, ..) => tcx.generator_kind(def_id).unwrap().descr().into(),
245-
ty::GeneratorWitness(..) |
246-
ty::GeneratorWitnessMIR(..) => "generator witness".into(),
245+
ty::GeneratorWitness(..) => "generator witness".into(),
247246
ty::Infer(ty::TyVar(_)) => "inferred type".into(),
248247
ty::Infer(ty::IntVar(_)) => "integer".into(),
249248
ty::Infer(ty::FloatVar(_)) => "floating-point number".into(),
@@ -295,7 +294,7 @@ impl<'tcx> Ty<'tcx> {
295294
ty::Dynamic(..) => "trait object".into(),
296295
ty::Closure(..) => "closure".into(),
297296
ty::Generator(def_id, ..) => tcx.generator_kind(def_id).unwrap().descr().into(),
298-
ty::GeneratorWitness(..) | ty::GeneratorWitnessMIR(..) => "generator witness".into(),
297+
ty::GeneratorWitness(..) => "generator witness".into(),
299298
ty::Tuple(..) => "tuple".into(),
300299
ty::Placeholder(..) => "higher-ranked type".into(),
301300
ty::Bound(..) => "bound type variable".into(),

compiler/rustc_middle/src/ty/fast_reject.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ pub enum SimplifiedType {
2929
Trait(DefId),
3030
Closure(DefId),
3131
Generator(DefId),
32-
GeneratorWitness(usize),
33-
GeneratorWitnessMIR(DefId),
32+
GeneratorWitness(DefId),
3433
Function(usize),
3534
Placeholder,
3635
}
@@ -130,10 +129,7 @@ pub fn simplify_type<'tcx>(
130129
ty::Ref(_, _, mutbl) => Some(SimplifiedType::Ref(mutbl)),
131130
ty::FnDef(def_id, _) | ty::Closure(def_id, _) => Some(SimplifiedType::Closure(def_id)),
132131
ty::Generator(def_id, _, _) => Some(SimplifiedType::Generator(def_id)),
133-
ty::GeneratorWitness(tys) => {
134-
Some(SimplifiedType::GeneratorWitness(tys.skip_binder().len()))
135-
}
136-
ty::GeneratorWitnessMIR(def_id, _) => Some(SimplifiedType::GeneratorWitnessMIR(def_id)),
132+
ty::GeneratorWitness(def_id, _) => Some(SimplifiedType::GeneratorWitness(def_id)),
137133
ty::Never => Some(SimplifiedType::Never),
138134
ty::Tuple(tys) => Some(SimplifiedType::Tuple(tys.len())),
139135
ty::FnPtr(f) => Some(SimplifiedType::Function(f.skip_binder().inputs().len())),
@@ -169,7 +165,7 @@ impl SimplifiedType {
169165
| SimplifiedType::Trait(d)
170166
| SimplifiedType::Closure(d)
171167
| SimplifiedType::Generator(d)
172-
| SimplifiedType::GeneratorWitnessMIR(d) => Some(d),
168+
| SimplifiedType::GeneratorWitness(d) => Some(d),
173169
_ => None,
174170
}
175171
}
@@ -240,7 +236,6 @@ impl DeepRejectCtxt {
240236
| ty::Closure(..)
241237
| ty::Generator(..)
242238
| ty::GeneratorWitness(..)
243-
| ty::GeneratorWitnessMIR(..)
244239
| ty::Placeholder(..)
245240
| ty::Bound(..)
246241
| ty::Infer(_) => bug!("unexpected impl_ty: {impl_ty}"),
@@ -342,7 +337,7 @@ impl DeepRejectCtxt {
342337

343338
ty::Error(_) => true,
344339

345-
ty::GeneratorWitness(..) | ty::GeneratorWitnessMIR(..) => {
340+
ty::GeneratorWitness(..) => {
346341
bug!("unexpected obligation type: {:?}", obligation_ty)
347342
}
348343
}

compiler/rustc_middle/src/ty/flags.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,7 @@ impl FlagComputation {
127127
self.add_ty(args.tupled_upvars_ty());
128128
}
129129

130-
&ty::GeneratorWitness(ts) => {
131-
self.bound_computation(ts, |flags, ts| flags.add_tys(ts));
132-
}
133-
134-
ty::GeneratorWitnessMIR(_, args) => {
130+
ty::GeneratorWitness(_, args) => {
135131
let should_remove_further_specializable =
136132
!self.flags.contains(TypeFlags::STILL_FURTHER_SPECIALIZABLE);
137133
self.add_args(args);

compiler/rustc_middle/src/ty/layout.rs

-1
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,6 @@ where
810810
| ty::Never
811811
| ty::FnDef(..)
812812
| ty::GeneratorWitness(..)
813-
| ty::GeneratorWitnessMIR(..)
814813
| ty::Foreign(..)
815814
| ty::Dynamic(_, _, ty::Dyn) => {
816815
bug!("TyAndLayout::field({:?}): not applicable", this)

compiler/rustc_middle/src/ty/opaque_types.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseMapper<'tcx> {
157157
Ty::new_generator(self.tcx, def_id, args, movability)
158158
}
159159

160-
ty::GeneratorWitnessMIR(def_id, args) => {
160+
ty::GeneratorWitness(def_id, args) => {
161161
let args = self.fold_closure_args(def_id, args);
162-
Ty::new_generator_witness_mir(self.tcx, def_id, args)
162+
Ty::new_generator_witness(self.tcx, def_id, args)
163163
}
164164

165165
ty::Param(param) => {

compiler/rustc_middle/src/ty/print/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ fn characteristic_def_id_of_type_cached<'a>(
271271
ty::FnDef(def_id, _)
272272
| ty::Closure(def_id, _)
273273
| ty::Generator(def_id, _, _)
274-
| ty::GeneratorWitnessMIR(def_id, _)
274+
| ty::GeneratorWitness(def_id, _)
275275
| ty::Foreign(def_id) => Some(def_id),
276276

277277
ty::Bool
@@ -286,7 +286,6 @@ fn characteristic_def_id_of_type_cached<'a>(
286286
| ty::Infer(_)
287287
| ty::Bound(..)
288288
| ty::Error(_)
289-
| ty::GeneratorWitness(..)
290289
| ty::Never
291290
| ty::Float(_) => None,
292291
}

compiler/rustc_middle/src/ty/print/pretty.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -838,10 +838,7 @@ pub trait PrettyPrinter<'tcx>:
838838

839839
p!("]")
840840
}
841-
ty::GeneratorWitness(types) => {
842-
p!(in_binder(&types));
843-
}
844-
ty::GeneratorWitnessMIR(did, args) => {
841+
ty::GeneratorWitness(did, args) => {
845842
p!(write("["));
846843
if !self.tcx().sess.verbose() {
847844
p!("generator witness");

compiler/rustc_middle/src/ty/relate.rs

+2-12
Original file line numberDiff line numberDiff line change
@@ -453,24 +453,14 @@ pub fn structurally_relate_tys<'tcx, R: TypeRelation<'tcx>>(
453453
Ok(Ty::new_generator(tcx, a_id, args, movability))
454454
}
455455

456-
(&ty::GeneratorWitness(a_types), &ty::GeneratorWitness(b_types)) => {
457-
// Wrap our types with a temporary GeneratorWitness struct
458-
// inside the binder so we can related them
459-
let a_types = a_types.map_bound(GeneratorWitness);
460-
let b_types = b_types.map_bound(GeneratorWitness);
461-
// Then remove the GeneratorWitness for the result
462-
let types = relation.relate(a_types, b_types)?.map_bound(|witness| witness.0);
463-
Ok(Ty::new_generator_witness(tcx, types))
464-
}
465-
466-
(&ty::GeneratorWitnessMIR(a_id, a_args), &ty::GeneratorWitnessMIR(b_id, b_args))
456+
(&ty::GeneratorWitness(a_id, a_args), &ty::GeneratorWitness(b_id, b_args))
467457
if a_id == b_id =>
468458
{
469459
// All GeneratorWitness types with the same id represent
470460
// the (anonymous) type of the same generator expression. So
471461
// all of their regions should be equated.
472462
let args = relation.relate(a_args, b_args)?;
473-
Ok(Ty::new_generator_witness_mir(tcx, a_id, args))
463+
Ok(Ty::new_generator_witness(tcx, a_id, args))
474464
}
475465

476466
(&ty::Closure(a_id, a_args), &ty::Closure(b_id, b_args)) if a_id == b_id => {

compiler/rustc_middle/src/ty/structural_impls.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -657,9 +657,8 @@ impl<'tcx> TypeSuperFoldable<TyCtxt<'tcx>> for Ty<'tcx> {
657657
ty::Generator(did, args, movability) => {
658658
ty::Generator(did, args.try_fold_with(folder)?, movability)
659659
}
660-
ty::GeneratorWitness(types) => ty::GeneratorWitness(types.try_fold_with(folder)?),
661-
ty::GeneratorWitnessMIR(did, args) => {
662-
ty::GeneratorWitnessMIR(did, args.try_fold_with(folder)?)
660+
ty::GeneratorWitness(did, args) => {
661+
ty::GeneratorWitness(did, args.try_fold_with(folder)?)
663662
}
664663
ty::Closure(did, args) => ty::Closure(did, args.try_fold_with(folder)?),
665664
ty::Alias(kind, data) => ty::Alias(kind, data.try_fold_with(folder)?),
@@ -708,8 +707,7 @@ impl<'tcx> TypeSuperVisitable<TyCtxt<'tcx>> for Ty<'tcx> {
708707
ty.visit_with(visitor)
709708
}
710709
ty::Generator(_did, ref args, _) => args.visit_with(visitor),
711-
ty::GeneratorWitness(ref types) => types.visit_with(visitor),
712-
ty::GeneratorWitnessMIR(_did, ref args) => args.visit_with(visitor),
710+
ty::GeneratorWitness(_did, ref args) => args.visit_with(visitor),
713711
ty::Closure(_did, ref args) => args.visit_with(visitor),
714712
ty::Alias(_, ref data) => data.visit_with(visitor),
715713

0 commit comments

Comments
 (0)