diff options
| author | Felix S. Klock II <pnkfelix@pnkfx.org> | 2018-11-03 01:53:57 +0100 |
|---|---|---|
| committer | Pietro Albini <pietro@pietroalbini.org> | 2018-11-10 15:29:59 +0100 |
| commit | bed6132b2fac89106940800cd4b2d87cb3a3a5a6 (patch) | |
| tree | 7307b1bd858b9536b08c909ea37ef974d443668b /src/librustc | |
| parent | 0db8330ca1854b35b4868f42f62e0cd3e2be8962 (diff) | |
| download | rust-bed6132b2fac89106940800cd4b2d87cb3a3a5a6.tar.gz rust-bed6132b2fac89106940800cd4b2d87cb3a3a5a6.zip | |
If we encounter `_` ascribed to structural pattern like `(a, b)`, just skip relate_types.
Diffstat (limited to 'src/librustc')
| -rw-r--r-- | src/librustc/mir/tcx.rs | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/librustc/mir/tcx.rs b/src/librustc/mir/tcx.rs index 473730c5489..69587195366 100644 --- a/src/librustc/mir/tcx.rs +++ b/src/librustc/mir/tcx.rs @@ -80,7 +80,8 @@ impl<'a, 'gcx, 'tcx> PlaceTy<'tcx> { elem: &PlaceElem<'tcx>) -> PlaceTy<'tcx> { - self.projection_ty_core(tcx, elem, |_, _, ty| ty) + self.projection_ty_core(tcx, elem, |_, _, ty| -> Result<Ty<'tcx>, ()> { Ok(ty) }) + .unwrap() } /// `place_ty.projection_ty_core(tcx, elem, |...| { ... })` @@ -88,11 +89,12 @@ impl<'a, 'gcx, 'tcx> PlaceTy<'tcx> { /// `Ty` or downcast variant corresponding to that projection. /// The `handle_field` callback must map a `Field` to its `Ty`, /// (which should be trivial when `T` = `Ty`). - pub fn projection_ty_core<V, T>(self, - tcx: TyCtxt<'a, 'gcx, 'tcx>, - elem: &ProjectionElem<'tcx, V, T>, - mut handle_field: impl FnMut(&Self, &Field, &T) -> Ty<'tcx>) - -> PlaceTy<'tcx> + pub fn projection_ty_core<V, T, E>( + self, + tcx: TyCtxt<'a, 'gcx, 'tcx>, + elem: &ProjectionElem<'tcx, V, T>, + mut handle_field: impl FnMut(&Self, &Field, &T) -> Result<Ty<'tcx>, E>) + -> Result<PlaceTy<'tcx>, E> where V: ::std::fmt::Debug, T: ::std::fmt::Debug { @@ -142,10 +144,11 @@ impl<'a, 'gcx, 'tcx> PlaceTy<'tcx> { bug!("cannot downcast non-ADT type: `{:?}`", self) } }, - ProjectionElem::Field(ref f, ref fty) => PlaceTy::Ty { ty: handle_field(&self, f, fty) } + ProjectionElem::Field(ref f, ref fty) => + PlaceTy::Ty { ty: handle_field(&self, f, fty)? }, }; debug!("projection_ty self: {:?} elem: {:?} yields: {:?}", self, elem, answer); - answer + Ok(answer) } } |
