Skip to content

Commit 96cb18e

Browse files
Combine identical alias arms
1 parent 61adaf8 commit 96cb18e

File tree

29 files changed

+69
-120
lines changed

29 files changed

+69
-120
lines changed

compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,8 @@ fn push_debuginfo_type_name<'tcx>(
411411
ty::Error(_)
412412
| ty::Infer(_)
413413
| ty::Placeholder(..)
414-
| ty::Alias(ty::Projection, ..)
414+
| ty::Alias(..)
415415
| ty::Bound(..)
416-
| ty::Alias(ty::Opaque, ..)
417416
| ty::GeneratorWitness(..) => {
418417
bug!(
419418
"debuginfo: Trying to create type name for \

compiler/rustc_const_eval/src/const_eval/valtrees.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,11 @@ pub(crate) fn const_to_valtree_inner<'tcx>(
142142
| ty::Foreign(..)
143143
| ty::Infer(ty::FreshIntTy(_))
144144
| ty::Infer(ty::FreshFloatTy(_))
145-
| ty::Alias(ty::Projection, ..)
145+
// FIXME(oli-obk): we could look behind opaque types
146+
| ty::Alias(..)
146147
| ty::Param(_)
147148
| ty::Bound(..)
148149
| ty::Placeholder(..)
149-
// FIXME(oli-obk): we could look behind opaque types
150-
| ty::Alias(ty::Opaque, ..)
151150
| ty::Infer(_)
152151
// FIXME(oli-obk): we can probably encode closures just like structs
153152
| ty::Closure(..)
@@ -307,11 +306,10 @@ pub fn valtree_to_const_value<'tcx>(
307306
| ty::Foreign(..)
308307
| ty::Infer(ty::FreshIntTy(_))
309308
| ty::Infer(ty::FreshFloatTy(_))
310-
| ty::Alias(ty::Projection, ..)
309+
| ty::Alias(..)
311310
| ty::Param(_)
312311
| ty::Bound(..)
313312
| ty::Placeholder(..)
314-
| ty::Alias(ty::Opaque, ..)
315313
| ty::Infer(_)
316314
| ty::Closure(..)
317315
| ty::Generator(..)

compiler/rustc_const_eval/src/interpret/intrinsics.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,9 @@ pub(crate) fn eval_nullary_intrinsic<'tcx>(
8282
ty::Adt(ref adt, _) => {
8383
ConstValue::from_machine_usize(adt.variants().len() as u64, &tcx)
8484
}
85-
ty::Alias(ty::Projection, _)
86-
| ty::Alias(ty::Opaque, ty::AliasTy { def_id: _, substs: _ })
87-
| ty::Param(_)
88-
| ty::Placeholder(_)
89-
| ty::Infer(_) => throw_inval!(TooGeneric),
85+
ty::Alias(..) | ty::Param(_) | ty::Placeholder(_) | ty::Infer(_) => {
86+
throw_inval!(TooGeneric)
87+
}
9088
ty::Bound(_, _) => bug!("bound ty during ctfe"),
9189
ty::Bool
9290
| ty::Char

compiler/rustc_const_eval/src/interpret/validity.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
601601
| ty::Placeholder(..)
602602
| ty::Bound(..)
603603
| ty::Param(..)
604-
| ty::Alias(ty::Opaque, ..)
605-
| ty::Alias(ty::Projection, ..)
604+
| ty::Alias(..)
606605
| ty::GeneratorWitness(..) => bug!("Encountered invalid type {:?}", ty),
607606
}
608607
}

compiler/rustc_const_eval/src/util/type_name.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
5858
// Types with identity (print the module path).
5959
ty::Adt(ty::AdtDef(Interned(&ty::AdtDefData { did: def_id, .. }, _)), substs)
6060
| ty::FnDef(def_id, substs)
61-
| ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs })
62-
| ty::Alias(ty::Projection, ty::AliasTy { def_id, substs })
61+
| ty::Alias(_, ty::AliasTy { def_id, substs })
6362
| ty::Closure(def_id, substs)
6463
| ty::Generator(def_id, substs, _) => self.print_def_path(def_id, substs),
6564
ty::Foreign(def_id) => self.print_def_path(def_id, &[]),

compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ impl<'tcx> InherentCollect<'tcx> {
223223
| ty::Tuple(..) => {
224224
self.check_primitive_impl(item.owner_id.def_id, self_ty, items, ty.span)
225225
}
226-
ty::Alias(ty::Projection, ..) | ty::Alias(ty::Opaque, ..) | ty::Param(_) => {
226+
ty::Alias(..) | ty::Param(_) => {
227227
let mut err = struct_span_err!(
228228
self.tcx.sess,
229229
ty.span,

compiler/rustc_hir_analysis/src/variance/constraints.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,10 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
249249
self.add_constraints_from_substs(current, def.did(), substs, variance);
250250
}
251251

252-
ty::Alias(ty::Projection, ref data) => {
252+
ty::Alias(_, ref data) => {
253253
self.add_constraints_from_invariant_substs(current, data.substs, variance);
254254
}
255255

256-
ty::Alias(ty::Opaque, ty::AliasTy { def_id: _, substs }) => {
257-
self.add_constraints_from_invariant_substs(current, substs, variance);
258-
}
259-
260256
ty::Dynamic(data, r, _) => {
261257
// The type `Foo<T+'a>` is contravariant w/r/t `'a`:
262258
let contra = self.contravariant(variance);

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -453,10 +453,9 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
453453
| ty::Dynamic(..)
454454
| ty::Never
455455
| ty::Tuple(..)
456-
| ty::Alias(ty::Projection, ..)
456+
| ty::Alias(..)
457457
| ty::Foreign(..)
458-
| ty::Param(..)
459-
| ty::Alias(ty::Opaque, ..) => {
458+
| ty::Param(..) => {
460459
if t.flags().intersects(self.needs_canonical_flags) {
461460
t.super_fold_with(self)
462461
} else {

compiler/rustc_infer/src/infer/opaque_types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,8 +589,8 @@ impl<'tcx> InferCtxt<'tcx> {
589589
hidden_ty
590590
}
591591
// FIXME(RPITIT): This can go away when we move to associated types
592-
ty::Alias(ty::Projection, proj)
593-
if def_id.to_def_id() == proj.def_id && substs == proj.substs =>
592+
ty::Alias(ty::Projection, ty::AliasTy { def_id: def_id2, substs: substs2 })
593+
if def_id.to_def_id() == def_id2 && substs == substs2 =>
594594
{
595595
hidden_ty
596596
}

compiler/rustc_middle/src/ty/layout.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ impl<'tcx> SizeSkeleton<'tcx> {
349349
}
350350
}
351351

352-
ty::Alias(ty::Projection, _) | ty::Alias(ty::Opaque, ..) => {
352+
ty::Alias(..) => {
353353
let normalized = tcx.normalize_erasing_regions(param_env, ty);
354354
if ty == normalized {
355355
Err(err)
@@ -757,10 +757,9 @@ where
757757
}
758758
}
759759

760-
ty::Alias(ty::Projection, _)
760+
ty::Alias(..)
761761
| ty::Bound(..)
762762
| ty::Placeholder(..)
763-
| ty::Alias(ty::Opaque, ..)
764763
| ty::Param(_)
765764
| ty::Infer(_)
766765
| ty::Error(_) => bug!("TyAndLayout::field: unexpected type `{}`", this.ty),

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,9 @@ fn characteristic_def_id_of_type_cached<'a>(
275275
| ty::Uint(_)
276276
| ty::Str
277277
| ty::FnPtr(_)
278-
| ty::Alias(ty::Projection, _)
278+
| ty::Alias(..)
279279
| ty::Placeholder(..)
280280
| ty::Param(_)
281-
| ty::Alias(ty::Opaque, ..)
282281
| ty::Infer(_)
283282
| ty::Bound(..)
284283
| ty::Error(_)

compiler/rustc_middle/src/ty/structural_impls.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -651,12 +651,7 @@ impl<'tcx> TypeSuperFoldable<'tcx> for Ty<'tcx> {
651651
}
652652
ty::GeneratorWitness(types) => ty::GeneratorWitness(types.try_fold_with(folder)?),
653653
ty::Closure(did, substs) => ty::Closure(did, substs.try_fold_with(folder)?),
654-
ty::Alias(ty::Projection, data) => {
655-
ty::Alias(ty::Projection, data.try_fold_with(folder)?)
656-
}
657-
ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs }) => {
658-
ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs: substs.try_fold_with(folder)? })
659-
}
654+
ty::Alias(kind, data) => ty::Alias(kind, data.try_fold_with(folder)?),
660655

661656
ty::Bool
662657
| ty::Char
@@ -701,10 +696,7 @@ impl<'tcx> TypeSuperVisitable<'tcx> for Ty<'tcx> {
701696
ty::Generator(_did, ref substs, _) => substs.visit_with(visitor),
702697
ty::GeneratorWitness(ref types) => types.visit_with(visitor),
703698
ty::Closure(_did, ref substs) => substs.visit_with(visitor),
704-
ty::Alias(ty::Projection, ref data) => data.visit_with(visitor),
705-
ty::Alias(ty::Opaque, ty::AliasTy { def_id: _, ref substs }) => {
706-
substs.visit_with(visitor)
707-
}
699+
ty::Alias(_, ref data) => data.visit_with(visitor),
708700

709701
ty::Bool
710702
| ty::Char

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2047,10 +2047,7 @@ impl<'tcx> Ty<'tcx> {
20472047
ty::Adt(adt, _) if adt.is_enum() => adt.repr().discr_type().to_ty(tcx),
20482048
ty::Generator(_, substs, _) => substs.as_generator().discr_ty(tcx),
20492049

2050-
ty::Param(_)
2051-
| ty::Alias(ty::Projection, _)
2052-
| ty::Alias(ty::Opaque, ..)
2053-
| ty::Infer(ty::TyVar(_)) => {
2050+
ty::Param(_) | ty::Alias(..) | ty::Infer(ty::TyVar(_)) => {
20542051
let assoc_items = tcx.associated_item_def_ids(
20552052
tcx.require_lang_item(hir::LangItem::DiscriminantKind, None),
20562053
);
@@ -2130,7 +2127,7 @@ impl<'tcx> Ty<'tcx> {
21302127

21312128
// type parameters only have unit metadata if they're sized, so return true
21322129
// to make sure we double check this during confirmation
2133-
ty::Param(_) | ty::Alias(ty::Projection, _) | ty::Alias(ty::Opaque, ..) => (tcx.types.unit, true),
2130+
ty::Param(_) | ty::Alias(..) => (tcx.types.unit, true),
21342131

21352132
ty::Infer(ty::TyVar(_))
21362133
| ty::Bound(..)
@@ -2206,7 +2203,7 @@ impl<'tcx> Ty<'tcx> {
22062203

22072204
ty::Adt(def, _substs) => def.sized_constraint(tcx).0.is_empty(),
22082205

2209-
ty::Alias(ty::Projection, _) | ty::Param(_) | ty::Alias(ty::Opaque, ..) => false,
2206+
ty::Alias(..) | ty::Param(_) => false,
22102207

22112208
ty::Infer(ty::TyVar(_)) => false,
22122209

@@ -2262,9 +2259,12 @@ impl<'tcx> Ty<'tcx> {
22622259
ty::Generator(..) | ty::GeneratorWitness(..) => false,
22632260

22642261
// Might be, but not "trivial" so just giving the safe answer.
2265-
ty::Adt(..) | ty::Closure(..) | ty::Alias(ty::Opaque, ..) => false,
2262+
ty::Adt(..) | ty::Closure(..) => false,
22662263

2267-
ty::Alias(ty::Projection, ..) | ty::Param(..) | ty::Infer(..) | ty::Error(..) => false,
2264+
// Needs normalization or revealing to determine, so no is the safe answer.
2265+
ty::Alias(..) => false,
2266+
2267+
ty::Param(..) | ty::Infer(..) | ty::Error(..) => false,
22682268

22692269
ty::Bound(..) | ty::Placeholder(..) => {
22702270
bug!("`is_trivially_pure_clone_copy` applied to unexpected type: {:?}", self);

compiler/rustc_middle/src/ty/util.rs

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ impl<'tcx> TyCtxt<'tcx> {
259259

260260
ty::Tuple(_) => break,
261261

262-
ty::Alias(ty::Projection, _) | ty::Alias(ty::Opaque, ..) => {
262+
ty::Alias(..) => {
263263
let normalized = normalize(ty);
264264
if ty == normalized {
265265
return ty;
@@ -332,8 +332,7 @@ impl<'tcx> TyCtxt<'tcx> {
332332
break;
333333
}
334334
}
335-
(ty::Alias(ty::Projection, _) | ty::Alias(ty::Opaque, ..), _)
336-
| (_, ty::Alias(ty::Projection, _) | ty::Alias(ty::Opaque, ..)) => {
335+
(ty::Alias(..), _) | (_, ty::Alias(..)) => {
337336
// If either side is a projection, attempt to
338337
// progress via normalization. (Should be safe to
339338
// apply to both sides as normalization is
@@ -938,10 +937,9 @@ impl<'tcx> Ty<'tcx> {
938937
| ty::Generator(..)
939938
| ty::GeneratorWitness(_)
940939
| ty::Infer(_)
941-
| ty::Alias(ty::Opaque, ..)
940+
| ty::Alias(..)
942941
| ty::Param(_)
943-
| ty::Placeholder(_)
944-
| ty::Alias(ty::Projection, _) => false,
942+
| ty::Placeholder(_) => false,
945943
}
946944
}
947945

@@ -978,10 +976,9 @@ impl<'tcx> Ty<'tcx> {
978976
| ty::Generator(..)
979977
| ty::GeneratorWitness(_)
980978
| ty::Infer(_)
981-
| ty::Alias(ty::Opaque, ..)
979+
| ty::Alias(..)
982980
| ty::Param(_)
983-
| ty::Placeholder(_)
984-
| ty::Alias(ty::Projection, _) => false,
981+
| ty::Placeholder(_) => false,
985982
}
986983
}
987984

@@ -1101,12 +1098,9 @@ impl<'tcx> Ty<'tcx> {
11011098
//
11021099
// FIXME(ecstaticmorse): Maybe we should `bug` here? This should probably only be
11031100
// called for known, fully-monomorphized types.
1104-
ty::Alias(ty::Projection, _)
1105-
| ty::Alias(ty::Opaque, ..)
1106-
| ty::Param(_)
1107-
| ty::Bound(..)
1108-
| ty::Placeholder(_)
1109-
| ty::Infer(_) => false,
1101+
ty::Alias(..) | ty::Param(_) | ty::Bound(..) | ty::Placeholder(_) | ty::Infer(_) => {
1102+
false
1103+
}
11101104

11111105
ty::Foreign(_) | ty::GeneratorWitness(..) | ty::Error(_) => false,
11121106
}
@@ -1237,11 +1231,10 @@ pub fn needs_drop_components<'tcx>(
12371231

12381232
// These require checking for `Copy` bounds or `Adt` destructors.
12391233
ty::Adt(..)
1240-
| ty::Alias(ty::Projection, ..)
1234+
| ty::Alias(..)
12411235
| ty::Param(_)
12421236
| ty::Bound(..)
12431237
| ty::Placeholder(..)
1244-
| ty::Alias(ty::Opaque, ..)
12451238
| ty::Infer(_)
12461239
| ty::Closure(..)
12471240
| ty::Generator(..) => Ok(smallvec![ty]),
@@ -1265,13 +1258,12 @@ pub fn is_trivially_const_drop<'tcx>(ty: Ty<'tcx>) -> bool {
12651258
| ty::Never
12661259
| ty::Foreign(_) => true,
12671260

1268-
ty::Alias(ty::Opaque, ..)
1261+
ty::Alias(..)
12691262
| ty::Dynamic(..)
12701263
| ty::Error(_)
12711264
| ty::Bound(..)
12721265
| ty::Param(_)
12731266
| ty::Placeholder(_)
1274-
| ty::Alias(ty::Projection, _)
12751267
| ty::Infer(_) => false,
12761268

12771269
// Not trivial because they have components, and instead of looking inside,

compiler/rustc_middle/src/ty/visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ impl<'tcx> TypeVisitor<'tcx> for LateBoundRegionsCollector {
654654
// ignore the inputs to a projection, as they may not appear
655655
// in the normalized form
656656
if self.just_constrained {
657-
if let ty::Alias(ty::Projection, ..) | ty::Alias(ty::Opaque, ..) = t.kind() {
657+
if let ty::Alias(..) = t.kind() {
658658
return ControlFlow::CONTINUE;
659659
}
660660
}

compiler/rustc_middle/src/ty/walk.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ fn push_inner<'tcx>(stack: &mut TypeWalkerStack<'tcx>, parent: GenericArg<'tcx>)
165165
stack.push(ty.into());
166166
stack.push(lt.into());
167167
}
168-
ty::Alias(ty::Projection, data) => {
168+
ty::Alias(_, data) => {
169169
stack.extend(data.substs.iter().rev());
170170
}
171171
ty::Dynamic(obj, lt, _) => {
@@ -188,7 +188,6 @@ fn push_inner<'tcx>(stack: &mut TypeWalkerStack<'tcx>, parent: GenericArg<'tcx>)
188188
}));
189189
}
190190
ty::Adt(_, substs)
191-
| ty::Alias(ty::Opaque, ty::AliasTy { def_id: _, substs })
192191
| ty::Closure(_, substs)
193192
| ty::Generator(_, substs, _)
194193
| ty::FnDef(_, substs) => {

compiler/rustc_symbol_mangling/src/legacy.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,7 @@ impl<'tcx> Printer<'tcx> for &mut SymbolPrinter<'tcx> {
216216
match *ty.kind() {
217217
// Print all nominal types as paths (unlike `pretty_print_type`).
218218
ty::FnDef(def_id, substs)
219-
| ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs })
220-
| ty::Alias(ty::Projection, ty::AliasTy { def_id, substs })
219+
| ty::Alias(_, ty::AliasTy { def_id, substs })
221220
| ty::Closure(def_id, substs)
222221
| ty::Generator(def_id, substs, _) => self.print_def_path(def_id, substs),
223222

compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -646,10 +646,9 @@ fn encode_ty<'tcx>(
646646
| ty::Error(..)
647647
| ty::GeneratorWitness(..)
648648
| ty::Infer(..)
649-
| ty::Alias(ty::Opaque, ..)
649+
| ty::Alias(..)
650650
| ty::Param(..)
651-
| ty::Placeholder(..)
652-
| ty::Alias(ty::Projection, ..) => {
651+
| ty::Placeholder(..) => {
653652
bug!("encode_ty: unexpected `{:?}`", ty.kind());
654653
}
655654
};
@@ -799,10 +798,9 @@ fn transform_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, options: TransformTyOptio
799798
| ty::Error(..)
800799
| ty::GeneratorWitness(..)
801800
| ty::Infer(..)
802-
| ty::Alias(ty::Opaque, ..)
801+
| ty::Alias(..)
803802
| ty::Param(..)
804-
| ty::Placeholder(..)
805-
| ty::Alias(ty::Projection, ..) => {
803+
| ty::Placeholder(..) => {
806804
bug!("transform_ty: unexpected `{:?}`", ty.kind());
807805
}
808806
}

compiler/rustc_symbol_mangling/src/v0.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,7 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> {
439439
// Mangle all nominal types as paths.
440440
ty::Adt(ty::AdtDef(Interned(&ty::AdtDefData { did: def_id, .. }, _)), substs)
441441
| ty::FnDef(def_id, substs)
442-
| ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs })
443-
| ty::Alias(ty::Projection, ty::AliasTy { def_id, substs })
442+
| ty::Alias(_, ty::AliasTy { def_id, substs })
444443
| ty::Closure(def_id, substs)
445444
| ty::Generator(def_id, substs, _) => {
446445
self = self.print_def_path(def_id, substs)?;

0 commit comments

Comments
 (0)