/// Attempts to highlight the specific part of a type in an argument
/// that has no type annotation.
/// For example, we might produce an annotation like this:
///
/// ```
///  |     foo(|a, b| b)
///  |          -  -
///  |          |  |
///  |          |  has type `&'1 u32`
///  |          has type `&'2 u32`
/// ```
Attempts to highlight the specific part of a type in an argument
that has no type annotation.
For example, we might produce an annotation like this.


Attempts to highlight the specific part of a type in an argument that has no type annotation . For example we might produce an annotation like this .
fn give_name_if_we_cannot_match_hir_ty(
        &self,
        infcx: &InferCtxt<'_, '_, 'tcx>,
        mir: &Mir<'tcx>,
        needle_fr: RegionVid,
        argument_ty: Ty<'tcx>,
        counter: &mut usize,
        diag: &mut DiagnosticBuilder<'_>,
    ) -> Option<InternedString> {
        let type_name = with_highlight_region(needle_fr, *counter, || {
            infcx.extract_type_name(&argument_ty)
        });
        debug!("give_name_if_we_cannot_match_hir_ty: type_name={:?} needle_fr={:?}",
               type_name, needle_fr);
        let assigned_region_name = if type_name.find(&format!("'{}", counter)).is_some() {
            // Only add a label if we can confirm that a region was labelled.
            let argument_index = self.get_argument_index_for_region(infcx.tcx, needle_fr)?;
            let (_, span) = self.get_argument_name_and_span_for_region(mir, argument_index);
            diag.span_label(span, format!("has type `{}`", type_name));
            // This counter value will already have been used, so this function will increment it
            // so the next value will be used next and return the region name that would have been
            // used.
            Some(self.synthesize_region_name(counter))
        } else {
            None
        };
        assigned_region_name
    }
fn give_name_if_we_cannot_match_hir_ty ( & self , infcx : & InferCtxt < ' _ , ' _ , ' tcx > , mir : & Mir < ' tcx > , needle_fr : RegionVid , argument_ty : Ty < ' tcx > , counter : & mut usize , diag : & mut DiagnosticBuilder < ' _ > , ) -> Option < InternedString > { let type_name = with_highlight_region ( needle_fr , * counter , | | { infcx . extract_type_name ( & argument_ty ) } ) ; debug ! ( " " type_name needle_fr ) ; let assigned_region_name = if type_name . find ( & format ! ( " " counter ) ) . is_some ( ) { // Only add a label if we can confirm that a region was labelled. let argument_index = self . get_argument_index_for_region ( infcx . tcx , needle_fr ) ? ; let ( _ , span ) = self . get_argument_name_and_span_for_region ( mir , argument_index ) ; diag . span_label ( span , format ! ( " " type_name ) ) ; // This counter value will already have been used, so this function will increment it // so the next value will be used next and return the region name that would have been // used. Some ( self . synthesize_region_name ( counter ) ) } else { None } ; assigned_region_name }
Attempts to highlight the specific part of a type in an argument
that has no type annotation.
Attempts to highlight the specific part of a type in an argument that has no type annotation .
&self
infcx
&InferCtxt<'_, '_, 'tcx>
mir
&Mir<'tcx>
needle_fr
RegionVid
argument_ty
Ty<'tcx>
counter
&mut usize
diag
&mut DiagnosticBuilder<'_>