crate fn give_region_a_name(
        &self,
        infcx: &InferCtxt<'_, '_, 'tcx>,
        mir: &Mir<'tcx>,
        mir_def_id: DefId,
        fr: RegionVid,
        counter: &mut usize,
        diag: &mut DiagnosticBuilder,
    ) -> InternedString {
        debug!("give_region_a_name(fr={:?}, counter={})", fr, counter);

        assert!(self.universal_regions.is_universal_region(fr));

        self.give_name_from_error_region(infcx.tcx, mir_def_id, fr, counter, diag)
            .or_else(|| {
                self.give_name_if_anonymous_region_appears_in_arguments(
                    infcx, mir, mir_def_id, fr, counter, diag)
            })
            .or_else(|| {
                self.give_name_if_anonymous_region_appears_in_upvars(
                    infcx.tcx, mir, fr, counter, diag)
            })
            .or_else(|| {
                self.give_name_if_anonymous_region_appears_in_output(
                    infcx, mir, mir_def_id, fr, counter, diag)
            })
            .unwrap_or_else(|| span_bug!(mir.span, "can't make a name for free region {:?}", fr))
    }
/// Maps from an internal MIR region vid to something that we can
/// report to the user. In some cases, the region vids will map
/// directly to lifetimes that the user has a name for (e.g.,
/// `'static`). But frequently they will not, in which case we
/// have to find some way to identify the lifetime to the user. To
/// that end, this function takes a "diagnostic" so that it can
/// create auxiliary notes as needed.
///
/// Example (function arguments):
///
/// Suppose we are trying to give a name to the lifetime of the
/// reference `x`:
///
/// ```
/// fn foo(x: &u32) { .. }
/// ```
///
/// This function would create a label like this:
///
/// ```
///  | fn foo(x: &u32) { .. }
///           ------- fully elaborated type of `x` is `&'1 u32`
/// ```
///
/// and then return the name `'1` for us to use.
Maps from an internal MIR region vid to something that we can
report to the user. In some cases, the region vids will map
directly to lifetimes that the user has a name for . But frequently they will not, in which case we
have to find some way to identify the lifetime to the user. To
that end, this function takes a "diagnostic" so that it can
create auxiliary notes as needed.

Example (function arguments).

Suppose we are trying to give a name to the lifetime of the
reference `x`.



This function would create a label like this.



and then return the name `'1` for us to use.
Maps from an internal MIR region vid to something that we can report to the user . In some cases the region vids will map directly to lifetimes that the user has a name for . But frequently they will not in which case we have to find some way to identify the lifetime to the user . To that end this function takes a " diagnostic " so that it can create auxiliary notes as needed . Example ( function arguments ) . Suppose we are trying to give a name to the lifetime of the reference ` x ` . This function would create a label like this . and then return the name ` ' 1 ` for us to use .
crate fn give_region_a_name(
        &self,
        infcx: &InferCtxt<'_, '_, 'tcx>,
        mir: &Mir<'tcx>,
        mir_def_id: DefId,
        fr: RegionVid,
        counter: &mut usize,
        diag: &mut DiagnosticBuilder,
    ) -> InternedString {
        debug!("give_region_a_name(fr={:?}, counter={})", fr, counter);
        assert!(self.universal_regions.is_universal_region(fr));
        self.give_name_from_error_region(infcx.tcx, mir_def_id, fr, counter, diag)
            .or_else(|| {
                self.give_name_if_anonymous_region_appears_in_arguments(
                    infcx, mir, mir_def_id, fr, counter, diag)
            })
            .or_else(|| {
                self.give_name_if_anonymous_region_appears_in_upvars(
                    infcx.tcx, mir, fr, counter, diag)
            })
            .or_else(|| {
                self.give_name_if_anonymous_region_appears_in_output(
                    infcx, mir, mir_def_id, fr, counter, diag)
            })
            .unwrap_or_else(|| span_bug!(mir.span, "can't make a name for free region {:?}", fr))
    }
crate fn give_region_a_name ( & self , infcx : & InferCtxt < ' _ , ' _ , ' tcx > , mir : & Mir < ' tcx > , mir_def_id : DefId , fr : RegionVid , counter : & mut usize , diag : & mut DiagnosticBuilder , ) -> InternedString { debug ! ( " " fr counter ) ; assert ! ( self universal_regions is_universal_region ( fr ) ) ; self . give_name_from_error_region ( infcx . tcx , mir_def_id , fr , counter , diag ) . or_else ( | | { self . give_name_if_anonymous_region_appears_in_arguments ( infcx , mir , mir_def_id , fr , counter , diag ) } ) . or_else ( | | { self . give_name_if_anonymous_region_appears_in_upvars ( infcx . tcx , mir , fr , counter , diag ) } ) . or_else ( | | { self . give_name_if_anonymous_region_appears_in_output ( infcx , mir , mir_def_id , fr , counter , diag ) } ) . unwrap_or_else ( | | span_bug ! ( mir span " " fr ) ) }
Maps from an internal MIR region vid to something that we can
report to the user.
Maps from an internal MIR region vid to something that we can report to the user .
&self
infcx
&InferCtxt<'_, '_, 'tcx>
mir
&Mir<'tcx>
mir_def_id
DefId
fr
RegionVid
counter
&mut usize
diag
&mut DiagnosticBuilder
&self
infcx
&InferCtxt<'_, '_, 'tcx>
mir
&Mir<'tcx>
mir_def_id
DefId
fr
RegionVid
counter
&mut usize
diag
&mut DiagnosticBuilder