fn compile_all_suggestions<'tcx>(
        &self,
        body: &Body<'tcx>,
        region_infcx: &RegionInferenceContext<'tcx>,
        infcx: &InferCtxt<'_, 'tcx>,
        renctx: &mut RegionErrorNamingCtx,
    ) -> SmallVec<[SuggestedConstraint; 2]> {
        let mut suggested = SmallVec::new();

        // Keep track of variables that we have already suggested unifying so that we don't print
        // out silly duplicate messages.
        let mut unified_already = FxHashSet::default();

        let errctx = ErrorReportingCtx {
            region_infcx,
            infcx,
            body,
            mir_def_id: self.mir_def_id,
            local_names: self.local_names,

            // We should not be suggesting naming upvars, so we pass in a dummy set of upvars that
            // should never be used.
            upvars: &[],
        };

        for (fr, outlived) in &self.constraints_to_add {
            let fr_name = if let Some(fr_name) = self.region_vid_to_name(&errctx, renctx, *fr) {
                fr_name
            } else {
                continue;
            };

            let outlived = outlived
                .iter()
                // if there is a `None`, we will just omit that constraint
                .filter_map(|fr| {
                    self.region_vid_to_name(&errctx, renctx, *fr).map(|rname| (fr, rname))
                })
                .collect::<Vec<_>>();

            // No suggestable outlived lifetimes.
            if outlived.is_empty() {
                continue;
            }

            // There are three types of suggestions we can make:
            // 1) Suggest a bound: 'a: 'b
            // 2) Suggest replacing 'a with 'static. If any of `outlived` is `'static`, then we
            //    should just replace 'a with 'static.
            // 3) Suggest unifying 'a with 'b if we have both 'a: 'b and 'b: 'a

            if outlived.iter().any(|(_, outlived_name)| {
                if let RegionNameSource::Static = outlived_name.source {
                    true
                } else {
                    false
                }
            }) {
                suggested.push(SuggestedConstraint::Static(fr_name));
            } else {
                // We want to isolate out all lifetimes that should be unified and print out
                // separate messages for them.

                let (unified, other): (Vec<_>, Vec<_>) = outlived.into_iter().partition(
                    // Do we have both 'fr: 'r and 'r: 'fr?
                    |(r, _)| {
                        self.constraints_to_add
                            .get(r)
                            .map(|r_outlived| r_outlived.as_slice().contains(fr))
                            .unwrap_or(false)
                    },
                );

                for (r, bound) in unified.into_iter() {
                    if !unified_already.contains(fr) {
                        suggested.push(SuggestedConstraint::Equal(fr_name.clone(), bound));
                        unified_already.insert(r);
                    }
                }

                if !other.is_empty() {
                    let other =
                        other.iter().map(|(_, rname)| rname.clone()).collect::<SmallVec<_>>();
                    suggested.push(SuggestedConstraint::Outlives(fr_name, other))
                }
            }
        }

        suggested
    }
/// Compiles a list of all suggestions to be printed in the final big suggestion.
Compiles a list of all suggestions to be printed in the final big suggestion.
Compiles a list of all suggestions to be printed in the final big suggestion .
fn compile_all_suggestions<'tcx>(
        &self,
        body: &Body<'tcx>,
        region_infcx: &RegionInferenceContext<'tcx>,
        infcx: &InferCtxt<'_, 'tcx>,
        renctx: &mut RegionErrorNamingCtx,
    ) -> SmallVec<[SuggestedConstraint; 2]> {
        let mut suggested = SmallVec::new();
        // Keep track of variables that we have already suggested unifying so that we don't print
        // out silly duplicate messages.
        let mut unified_already = FxHashSet::default();
        let errctx = ErrorReportingCtx {
            region_infcx,
            infcx,
            body,
            mir_def_id: self.mir_def_id,
            local_names: self.local_names,
            // We should not be suggesting naming upvars, so we pass in a dummy set of upvars that
            // should never be used.
            upvars: &[],
        };
        for (fr, outlived) in &self.constraints_to_add {
            let fr_name = if let Some(fr_name) = self.region_vid_to_name(&errctx, renctx, *fr) {
                fr_name
            } else {
                continue;
            };
            let outlived = outlived
                .iter()
                // if there is a `None`, we will just omit that constraint
                .filter_map(|fr| {
                    self.region_vid_to_name(&errctx, renctx, *fr).map(|rname| (fr, rname))
                })
                .collect::<Vec<_>>();
            // No suggestable outlived lifetimes.
            if outlived.is_empty() {
                continue;
            }
            // There are three types of suggestions we can make:
            // 1) Suggest a bound: 'a: 'b
            // 2) Suggest replacing 'a with 'static. If any of `outlived` is `'static`, then we
            //    should just replace 'a with 'static.
            // 3) Suggest unifying 'a with 'b if we have both 'a: 'b and 'b: 'a
            if outlived.iter().any(|(_, outlived_name)| {
                if let RegionNameSource::Static = outlived_name.source {
                    true
                } else {
                    false
                }
            }) {
                suggested.push(SuggestedConstraint::Static(fr_name));
            } else {
                // We want to isolate out all lifetimes that should be unified and print out
                // separate messages for them.
                let (unified, other): (Vec<_>, Vec<_>) = outlived.into_iter().partition(
                    // Do we have both 'fr: 'r and 'r: 'fr?
                    |(r, _)| {
                        self.constraints_to_add
                            .get(r)
                            .map(|r_outlived| r_outlived.as_slice().contains(fr))
                            .unwrap_or(false)
                    },
                );
                for (r, bound) in unified.into_iter() {
                    if !unified_already.contains(fr) {
                        suggested.push(SuggestedConstraint::Equal(fr_name.clone(), bound));
                        unified_already.insert(r);
                    }
                }
                if !other.is_empty() {
                    let other =
                        other.iter().map(|(_, rname)| rname.clone()).collect::<SmallVec<_>>();
                    suggested.push(SuggestedConstraint::Outlives(fr_name, other))
                }
            }
        }
        suggested
    }
fn compile_all_suggestions < ' tcx > ( & self , body : & Body < ' tcx > , region_infcx : & RegionInferenceContext < ' tcx > , infcx : & InferCtxt < ' _ , ' tcx > , renctx : & mut RegionErrorNamingCtx , ) -> SmallVec < [ SuggestedConstraint ; 2 ] > { let mut suggested = SmallVec :: new ( ) ; // Keep track of variables that we have already suggested unifying so that we don't print // out silly duplicate messages. let mut unified_already = FxHashSet :: default ( ) ; let errctx = ErrorReportingCtx { region_infcx , infcx , body , mir_def_id : self . mir_def_id , local_names : self . local_names , // We should not be suggesting naming upvars, so we pass in a dummy set of upvars that // should never be used. upvars : & [ ] , } ; for ( fr , outlived ) in & self . constraints_to_add { let fr_name = if let Some ( fr_name ) = self . region_vid_to_name ( & errctx , renctx , * fr ) { fr_name } else { continue ; } ; let outlived = outlived . iter ( ) // if there is a `None`, we will just omit that constraint . filter_map ( | fr | { self . region_vid_to_name ( & errctx , renctx , * fr ) . map ( | rname | ( fr , rname ) ) } ) . collect :: < Vec < _ > > ( ) ; // No suggestable outlived lifetimes. if outlived . is_empty ( ) { continue ; } // There are three types of suggestions we can make: // 1) Suggest a bound: 'a: 'b // 2) Suggest replacing 'a with 'static. If any of `outlived` is `'static`, then we //    should just replace 'a with 'static. // 3) Suggest unifying 'a with 'b if we have both 'a: 'b and 'b: 'a if outlived . iter ( ) . any ( | ( _ , outlived_name ) | { if let RegionNameSource :: Static = outlived_name . source { true } else { false } } ) { suggested . push ( SuggestedConstraint :: Static ( fr_name ) ) ; } else { // We want to isolate out all lifetimes that should be unified and print out // separate messages for them. let ( unified , other ) : ( Vec < _ > , Vec < _ > ) = outlived . into_iter ( ) . partition ( // Do we have both 'fr: 'r and 'r: 'fr? | ( r , _ ) | { self . constraints_to_add . get ( r ) . map ( | r_outlived | r_outlived . as_slice ( ) . contains ( fr ) ) . unwrap_or ( false ) } , ) ; for ( r , bound ) in unified . into_iter ( ) { if ! unified_already . contains ( fr ) { suggested . push ( SuggestedConstraint :: Equal ( fr_name . clone ( ) , bound ) ) ; unified_already . insert ( r ) ; } } if ! other . is_empty ( ) { let other = other . iter ( ) . map ( | ( _ , rname ) | rname . clone ( ) ) . collect :: < SmallVec < _ > > ( ) ; suggested . push ( SuggestedConstraint :: Outlives ( fr_name , other ) ) } } } suggested }
Compiles a list of all suggestions to be printed in the final big suggestion.
Compiles a list of all suggestions to be printed in the final big suggestion .
&self
body
&Body<'tcx>
region_infcx
&RegionInferenceContext<'tcx>
infcx
&InferCtxt<'_, 'tcx>
renctx
&mut RegionErrorNamingCtx