Skip to content

Commit ba3ae28

Browse files
committed
FRTs are Sized
1 parent c45086b commit ba3ae28

File tree

9 files changed

+17
-1
lines changed

9 files changed

+17
-1
lines changed

compiler/rustc_hir_typeck/src/cast.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
142142
| ty::CoroutineClosure(..)
143143
| ty::Coroutine(..)
144144
| ty::Adt(..)
145+
| ty::Field(..)
145146
| ty::Never
146147
| ty::Error(_) => {
147148
let guar = self

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,6 +1625,7 @@ impl<'tcx> Ty<'tcx> {
16251625
| ty::Uint(_)
16261626
| ty::Float(_)
16271627
| ty::Adt(..)
1628+
| ty::Field(..)
16281629
| ty::Foreign(_)
16291630
| ty::Str
16301631
| ty::Array(..)
@@ -1683,6 +1684,7 @@ impl<'tcx> Ty<'tcx> {
16831684
// If returned by `struct_tail_raw` this is a unit struct
16841685
// without any fields, or not a struct, and therefore is Sized.
16851686
| ty::Adt(..)
1687+
| ty::Field(..)
16861688
// If returned by `struct_tail_raw` this is the empty tuple,
16871689
// a.k.a. unit type, which is Sized
16881690
| ty::Tuple(..) => Ok(tcx.types.unit),
@@ -1869,6 +1871,7 @@ impl<'tcx> Ty<'tcx> {
18691871
| ty::Closure(..)
18701872
| ty::CoroutineClosure(..)
18711873
| ty::Never
1874+
| ty::Field(..)
18721875
| ty::Error(_) => true,
18731876

18741877
ty::Str | ty::Slice(_) | ty::Dynamic(_, _, ty::Dyn) => match sizedness {

compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ where
119119
// impl {Meta,}Sized for u*, i*, bool, f*, FnDef, FnPtr, *(const/mut) T, char
120120
// impl {Meta,}Sized for &mut? T, [T; N], dyn* Trait, !, Coroutine, CoroutineWitness
121121
// impl {Meta,}Sized for Closure, CoroutineClosure
122+
// impl {Meta,}Sized for Field
122123
ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
123124
| ty::Uint(_)
124125
| ty::Int(_)
@@ -135,6 +136,7 @@ where
135136
| ty::Pat(..)
136137
| ty::Closure(..)
137138
| ty::CoroutineClosure(..)
139+
| ty::Field(..)
138140
| ty::Never
139141
| ty::Error(_) => Ok(ty::Binder::dummy(vec![])),
140142

compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,8 @@ where
660660
| ty::Coroutine(..)
661661
| ty::CoroutineWitness(..)
662662
| ty::Never
663-
| ty::Foreign(..) => Ty::new_unit(cx),
663+
| ty::Foreign(..)
664+
| ty::Field(..) => Ty::new_unit(cx),
664665

665666
ty::Error(e) => Ty::new_error(cx, e),
666667

@@ -915,6 +916,7 @@ where
915916
| ty::Never
916917
| ty::Foreign(..)
917918
| ty::Adt(_, _)
919+
| ty::Field(_, _)
918920
| ty::Str
919921
| ty::Slice(_)
920922
| ty::Dynamic(_, _, _)

compiler/rustc_trait_selection/src/traits/project.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,7 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
10251025
| ty::Uint(_)
10261026
| ty::Float(_)
10271027
| ty::Adt(..)
1028+
| ty::Field(..)
10281029
| ty::Foreign(_)
10291030
| ty::Str
10301031
| ty::Array(..)
@@ -1099,6 +1100,8 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
10991100
// If returned by `struct_tail` this is a unit struct
11001101
// without any fields, or not a struct, and therefore is Sized.
11011102
| ty::Adt(..)
1103+
// field traits are always sized
1104+
| ty::Field(..)
11021105
// If returned by `struct_tail` this is the empty tuple.
11031106
| ty::Tuple(..)
11041107
// Integers and floats are always Sized, and so have unit type metadata.

compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
12451245
| ty::Closure(..)
12461246
| ty::CoroutineClosure(..)
12471247
| ty::Never
1248+
| ty::Field(..)
12481249
| ty::Error(_) => {
12491250
candidates.vec.push(SizedCandidate);
12501251
}

compiler/rustc_trait_selection/src/traits/select/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2119,6 +2119,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
21192119
| ty::Closure(..)
21202120
| ty::CoroutineClosure(..)
21212121
| ty::Never
2122+
| ty::Field(..)
21222123
| ty::Error(_) => ty::Binder::dummy(vec![]),
21232124

21242125
ty::Str | ty::Slice(_) | ty::Dynamic(..) => match sizedness {

compiler/rustc_ty_utils/src/ty.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ fn sizedness_constraint_for_ty<'tcx>(
3838
| ty::CoroutineClosure(..)
3939
| ty::Coroutine(..)
4040
| ty::CoroutineWitness(..)
41+
| ty::Field(..)
4142
| ty::Never => None,
4243

4344
ty::Str | ty::Slice(..) | ty::Dynamic(_, _, ty::Dyn) => match sizedness {
@@ -370,6 +371,7 @@ fn impl_self_is_guaranteed_unsized<'tcx>(tcx: TyCtxt<'tcx>, impl_def_id: DefId)
370371
| ty::Uint(_)
371372
| ty::Float(_)
372373
| ty::Adt(_, _)
374+
| ty::Field(_, _)
373375
| ty::Foreign(_)
374376
| ty::Array(_, _)
375377
| ty::Pat(_, _)

compiler/rustc_type_ir/src/inherent.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ pub trait Ty<I: Interner<Ty = Self>>:
173173
| ty::Uint(_)
174174
| ty::Float(_)
175175
| ty::Adt(_, _)
176+
| ty::Field(_, _)
176177
| ty::Foreign(_)
177178
| ty::Array(_, _)
178179
| ty::Pat(_, _)

0 commit comments

Comments
 (0)