}
ty::BoundRegion::BrEnv => {
- let mir_hir_id = self.infcx.tcx.hir().as_local_hir_id(self.mir_def_id);
+ let mir_hir_id = self.infcx.tcx.hir().local_def_id_to_hir_id(self.mir_def_id);
let def_ty = self.regioncx.universal_regions().defining_ty;
if let DefiningTy::Closure(_, substs) = def_ty {
argument_index,
);
- self.highlight_if_we_can_match_hir_ty_from_argument(fr, arg_ty, argument_index)
+ self.get_argument_hir_ty_for_highlighting(argument_index)
+ .and_then(|arg_hir_ty| self.highlight_if_we_can_match_hir_ty(fr, arg_ty, arg_hir_ty))
.or_else(|| {
// `highlight_if_we_cannot_match_hir_ty` needs to know the number we will give to
// the anonymous region. If it succeeds, the `synthesize_region_name` call below
})
}
- fn highlight_if_we_can_match_hir_ty_from_argument(
+ fn get_argument_hir_ty_for_highlighting(
&self,
- needle_fr: RegionVid,
- argument_ty: Ty<'tcx>,
argument_index: usize,
- ) -> Option<RegionNameHighlight> {
- let mir_hir_id = self.infcx.tcx.hir().as_local_hir_id(self.mir_def_id);
+ ) -> Option<&hir::Ty<'tcx>> {
+ let mir_hir_id = self.infcx.tcx.hir().local_def_id_to_hir_id(self.mir_def_id);
let fn_decl = self.infcx.tcx.hir().fn_decl_by_hir_id(mir_hir_id)?;
let argument_hir_ty: &hir::Ty<'_> = fn_decl.inputs.get(argument_index)?;
match argument_hir_ty.kind {
// (`give_name_if_anonymous_region_appears_in_arguments`).
hir::TyKind::Infer => None,
- _ => self.highlight_if_we_can_match_hir_ty(needle_fr, argument_ty, argument_hir_ty),
+ _ => Some(argument_hir_ty),
}
}
/// | - let's call the lifetime of this reference `'1`
/// ```
///
- /// the way this works is that we match up `argument_ty`, which is
+ /// the way this works is that we match up `ty`, which is
/// a `Ty<'tcx>` (the internal form of the type) with
- /// `argument_hir_ty`, a `hir::Ty` (the syntax of the type
+ /// `hir_ty`, a `hir::Ty` (the syntax of the type
/// annotation). We are descending through the types stepwise,
/// looking in to find the region `needle_fr` in the internal
/// type. Once we find that, we can use the span of the `hir::Ty`
fn highlight_if_we_can_match_hir_ty(
&self,
needle_fr: RegionVid,
- argument_ty: Ty<'tcx>,
- argument_hir_ty: &hir::Ty<'_>,
+ ty: Ty<'tcx>,
+ hir_ty: &hir::Ty<'_>,
) -> Option<RegionNameHighlight> {
- let search_stack: &mut Vec<(Ty<'tcx>, &hir::Ty<'_>)> =
- &mut vec![(argument_ty, argument_hir_ty)];
+ let search_stack: &mut Vec<(Ty<'tcx>, &hir::Ty<'_>)> = &mut vec![(ty, hir_ty)];
while let Some((ty, hir_ty)) = search_stack.pop() {
match (&ty.kind, &hir_ty.kind) {
- // Check if the `argument_ty` is `&'X ..` where `'X`
+ // Check if the `ty` is `&'X ..` where `'X`
// is the region we are looking for -- if so, and we have a `&T`
// on the RHS, then we want to highlight the `&` like so:
//
highlight.highlighting_region_vid(fr, *self.next_region_name.try_borrow().unwrap());
let type_name = self.infcx.extract_type_name(&return_ty, Some(highlight)).0;
- let mir_hir_id = tcx.hir().as_local_hir_id(self.mir_def_id);
+ let mir_hir_id = tcx.hir().local_def_id_to_hir_id(self.mir_def_id);
let (return_span, mir_description) = match tcx.hir().get(mir_hir_id) {
hir::Node::Expr(hir::Expr {
highlight.highlighting_region_vid(fr, *self.next_region_name.try_borrow().unwrap());
let type_name = self.infcx.extract_type_name(&yield_ty, Some(highlight)).0;
- let mir_hir_id = tcx.hir().as_local_hir_id(self.mir_def_id);
+ let mir_hir_id = tcx.hir().local_def_id_to_hir_id(self.mir_def_id);
let yield_span = match tcx.hir().get(mir_hir_id) {
hir::Node::Expr(hir::Expr {