Skip to content

Commit a264440

Browse files
committed
outlives: convert outlives to use an exhaustive match, for better
reliability.
1 parent 9c5cfea commit a264440

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

src/librustc/middle/outlives.rs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,28 @@ fn compute_components<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>,
161161
compute_components(infcx, ty, out);
162162
}
163163
}
164-
_ => {
165-
// for all other types, just constrain the regions and
166-
// keep walking to find any other types.
164+
165+
// Most types do not introduce any region binders, nor
166+
// involve any other subtle cases, and so the WF relation
167+
// simply constraints any regions referenced directly by
168+
// the type and then visits the types that are lexically
169+
// contained within. (The comments refer to relevant rules
170+
// from RFC1214.)
171+
ty::TyBool(..) | // OutlivesScalar
172+
ty::TyChar(..) | // OutlivesScalar
173+
ty::TyInt(..) | // OutlivesScalar
174+
ty::TyUint(..) | // OutlivesScalar
175+
ty::TyFloat(..) | // OutlivesScalar
176+
ty::TyEnum(..) | // OutlivesNominalType
177+
ty::TyStruct(..) | // OutlivesNominalType
178+
ty::TyBox(..) | // OutlivesNominalType (ish)
179+
ty::TyStr(..) | // OutlivesScalar (ish)
180+
ty::TyArray(..) | // ...
181+
ty::TySlice(..) | // ...
182+
ty::TyRawPtr(..) | // ...
183+
ty::TyRef(..) | // OutlivesReference
184+
ty::TyTuple(..) | // ...
185+
ty::TyError(..) => {
167186
push_region_constraints(out, ty.regions());
168187
}
169188
}
@@ -188,4 +207,3 @@ fn push_region_constraints<'tcx>(out: &mut Vec<Component<'tcx>>, regions: Vec<ty
188207
}
189208
}
190209
}
191-

0 commit comments

Comments
 (0)