fn report_general_error(
        &self,
        mir: &Mir<'tcx>,
        infcx: &InferCtxt<'_, '_, 'tcx>,
        mir_def_id: DefId,
        fr: RegionVid,
        fr_is_local: bool,
        outlived_fr: RegionVid,
        outlived_fr_is_local: bool,
        category: ConstraintCategory,
        span: Span,
        errors_buffer: &mut Vec<Diagnostic>,
    ) {
        let mut diag = infcx.tcx.sess.struct_span_err(
            span,
            "unsatisfied lifetime constraints", // FIXME
        );

        let counter = &mut 1;
        let fr_name = self.give_region_a_name(infcx, mir, mir_def_id, fr, counter);
        fr_name.highlight_region_name(&mut diag);
        let outlived_fr_name = self.give_region_a_name(
            infcx, mir, mir_def_id, outlived_fr, counter);
        outlived_fr_name.highlight_region_name(&mut diag);

        let mir_def_name = if infcx.tcx.is_closure(mir_def_id) { "closure" } else { "function" };

        match (category, outlived_fr_is_local, fr_is_local) {
            (ConstraintCategory::Return, true, _) => {
                diag.span_label(span, format!(
                    "{} was supposed to return data with lifetime `{}` but it is returning \
                    data with lifetime `{}`",
                    mir_def_name, outlived_fr_name, fr_name
                ));
            },
            _ => {
                diag.span_label(span, format!(
                    "{}requires that `{}` must outlive `{}`",
                    category.description(), fr_name, outlived_fr_name,
                ));
            },
        }

        self.add_static_impl_trait_suggestion(
            infcx, &mut diag, fr, fr_name, outlived_fr,
        );

        diag.buffer(errors_buffer);
    }
/// Reports a region inference error for the general case with named/synthesized lifetimes to
/// explain what is happening.
///
/// ```text
/// error: unsatisfied lifetime constraints
///   --> $DIR/regions-creating-enums3.rs:17:5
///    |
/// LL | fn mk_add_bad1<'a,'b>(x: &'a ast<'a>, y: &'b ast<'b>) -> ast<'a> {
///    |                -- -- lifetime `'b` defined here
///    |                |
///    |                lifetime `'a` defined here
/// LL |     ast::add(x, y)
///    |     ^^^^^^^^^^^^^^ function was supposed to return data with lifetime `'a` but it
///    |                    is returning data with lifetime `'b`
/// ```
Reports a region inference error for the general case with named/synthesized lifetimes to
explain what is happening.


Reports a region inference error for the general case with named / synthesized lifetimes to explain what is happening .
fn report_general_error(
        &self,
        mir: &Mir<'tcx>,
        infcx: &InferCtxt<'_, '_, 'tcx>,
        mir_def_id: DefId,
        fr: RegionVid,
        fr_is_local: bool,
        outlived_fr: RegionVid,
        outlived_fr_is_local: bool,
        category: ConstraintCategory,
        span: Span,
        errors_buffer: &mut Vec<Diagnostic>,
    ) {
        let mut diag = infcx.tcx.sess.struct_span_err(
            span,
            "unsatisfied lifetime constraints", // FIXME
        );
        let counter = &mut 1;
        let fr_name = self.give_region_a_name(infcx, mir, mir_def_id, fr, counter);
        fr_name.highlight_region_name(&mut diag);
        let outlived_fr_name = self.give_region_a_name(
            infcx, mir, mir_def_id, outlived_fr, counter);
        outlived_fr_name.highlight_region_name(&mut diag);
        let mir_def_name = if infcx.tcx.is_closure(mir_def_id) { "closure" } else { "function" };
        match (category, outlived_fr_is_local, fr_is_local) {
            (ConstraintCategory::Return, true, _) => {
                diag.span_label(span, format!(
                    "{} was supposed to return data with lifetime `{}` but it is returning \
                    data with lifetime `{}`",
                    mir_def_name, outlived_fr_name, fr_name
                ));
            },
            _ => {
                diag.span_label(span, format!(
                    "{}requires that `{}` must outlive `{}`",
                    category.description(), fr_name, outlived_fr_name,
                ));
            },
        }
        self.add_static_impl_trait_suggestion(
            infcx, &mut diag, fr, fr_name, outlived_fr,
        );
        diag.buffer(errors_buffer);
    }
fn report_general_error ( & self , mir : & Mir < ' tcx > , infcx : & InferCtxt < ' _ , ' _ , ' tcx > , mir_def_id : DefId , fr : RegionVid , fr_is_local : bool , outlived_fr : RegionVid , outlived_fr_is_local : bool , category : ConstraintCategory , span : Span , errors_buffer : & mut Vec < Diagnostic > , ) { let mut diag = infcx . tcx . sess . struct_span_err ( span , " " , // FIXME ) ; let counter = & mut 1 ; let fr_name = self . give_region_a_name ( infcx , mir , mir_def_id , fr , counter ) ; fr_name . highlight_region_name ( & mut diag ) ; let outlived_fr_name = self . give_region_a_name ( infcx , mir , mir_def_id , outlived_fr , counter ) ; outlived_fr_name . highlight_region_name ( & mut diag ) ; let mir_def_name = if infcx . tcx . is_closure ( mir_def_id ) { " " } else { " " } ; match ( category , outlived_fr_is_local , fr_is_local ) { ( ConstraintCategory :: Return , true , _ ) => { diag . span_label ( span , format ! ( " \
 " mir_def_name outlived_fr_name fr_name ) ) ; } , _ => { diag . span_label ( span , format ! ( " " category description ( ) fr_name outlived_fr_name ) ) ; } , } self . add_static_impl_trait_suggestion ( infcx , & mut diag , fr , fr_name , outlived_fr , ) ; diag . buffer ( errors_buffer ) ; }
Reports a region inference error for the general case with named/synthesized lifetimes to
explain what is happening.
Reports a region inference error for the general case with named / synthesized lifetimes to explain what is happening .
&self
mir
&Mir<'tcx>
infcx
&InferCtxt<'_, '_, 'tcx>
mir_def_id
DefId
fr
RegionVid
fr_is_local
bool
outlived_fr
RegionVid
outlived_fr_is_local
bool
category
ConstraintCategory
span
Span
errors_buffer
&mut Vec<Diagnostic>