Use Places for captures in MIR
- Use closure_min_capture maps to capture precise paths - PlaceBuilder now searches for ancestors in min_capture list - Add API to `Ty` to allow access to the n-th element in a tuple in O(1) time. Co-authored-by: Roxane Fruytier <roxane.fruytier@hotmail.com>
This commit is contained in:
parent
d9523622ff
commit
6a1d0699a4
2 changed files with 137 additions and 22 deletions
|
@ -2174,6 +2174,15 @@ impl<'tcx> TyS<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Get the `i`-th element of a tuple.
|
||||
/// Panics when called on anything but a tuple.
|
||||
pub fn tuple_element_ty(&self, i: usize) -> Option<Ty<'tcx>> {
|
||||
match self.kind() {
|
||||
Tuple(substs) => substs.iter().nth(i).map(|field| field.expect_ty()),
|
||||
_ => bug!("tuple_fields called on non-tuple"),
|
||||
}
|
||||
}
|
||||
|
||||
/// If the type contains variants, returns the valid range of variant indices.
|
||||
//
|
||||
// FIXME: This requires the optimized MIR in the case of generators.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue