Skip to main content

rustc_trait_selection/
errors.rs

1use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
2use rustc_errors::codes::*;
3use rustc_errors::formatting::DiagMessageAddArg;
4use rustc_errors::{
5    Applicability, Diag, DiagCtxtHandle, DiagMessage, DiagStyledString, Diagnostic,
6    EmissionGuarantee, IntoDiagArg, Level, MultiSpan, Subdiagnostic, msg,
7};
8use rustc_hir::def::DefKind;
9use rustc_hir::def_id::{DefId, LocalDefId};
10use rustc_hir::intravisit::{Visitor, VisitorExt, walk_ty};
11use rustc_hir::{self as hir, AmbigArg, FnRetTy, GenericParamKind, Node};
12use rustc_macros::{Diagnostic, Subdiagnostic};
13use rustc_middle::ty::print::{PrintTraitRefExt as _, TraitRefPrintOnlyTraitPath};
14use rustc_middle::ty::{self, Binder, ClosureKind, FnSig, GenericArg, Region, Ty, TyCtxt};
15use rustc_span::{BytePos, Ident, Span, Symbol, kw, sym};
16
17use crate::error_reporting::infer::ObligationCauseAsDiagArg;
18use crate::error_reporting::infer::need_type_info::UnderspecifiedArgKind;
19use crate::error_reporting::infer::nice_region_error::placeholder_error::Highlighted;
20
21pub(crate) mod note_and_explain;
22
23#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            UnableToConstructConstantValue<'a> where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    UnableToConstructConstantValue {
                        span: __binding_0, unevaluated: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("unable to construct a constant value for the unevaluated constant {$unevaluated}")));
                        ;
                        diag.arg("unevaluated", __binding_1);
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
24#[diag("unable to construct a constant value for the unevaluated constant {$unevaluated}")]
25pub(crate) struct UnableToConstructConstantValue<'a> {
26    #[primary_span]
27    pub span: Span,
28    pub unevaluated: ty::UnevaluatedConst<'a>,
29}
30
31pub(crate) struct NegativePositiveConflict<'tcx> {
32    pub impl_span: Span,
33    pub trait_desc: ty::TraitRef<'tcx>,
34    pub self_ty: Option<Ty<'tcx>>,
35    pub negative_impl_span: Result<Span, Symbol>,
36    pub positive_impl_span: Result<Span, Symbol>,
37}
38
39impl<G: EmissionGuarantee> Diagnostic<'_, G> for NegativePositiveConflict<'_> {
40    #[track_caller]
41    fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
42        let mut diag = Diag::new(
43            dcx,
44            level,
45            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("found both positive and negative implementation of trait `{$trait_desc}`{$self_desc ->\n                [none] {\"\"}\n                *[default] {\" \"}for type `{$self_desc}`\n            }:"))msg!(
46            "found both positive and negative implementation of trait `{$trait_desc}`{$self_desc ->
47                [none] {\"\"}
48                *[default] {\" \"}for type `{$self_desc}`
49            }:"
50        ),
51        );
52        diag.arg("trait_desc", self.trait_desc.print_only_trait_path().to_string());
53        diag.arg("self_desc", self.self_ty.map_or_else(|| "none".to_string(), |ty| ty.to_string()));
54        diag.span(self.impl_span);
55        diag.code(E0751);
56        match self.negative_impl_span {
57            Ok(span) => {
58                diag.span_label(span, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("negative implementation here"))msg!("negative implementation here"));
59            }
60            Err(cname) => {
61                diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("negative implementation in crate `{$negative_impl_cname}`"))msg!("negative implementation in crate `{$negative_impl_cname}`"));
62                diag.arg("negative_impl_cname", cname.to_string());
63            }
64        }
65        match self.positive_impl_span {
66            Ok(span) => {
67                diag.span_label(span, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("positive implementation here"))msg!("positive implementation here"));
68            }
69            Err(cname) => {
70                diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("positive implementation in crate `{$positive_impl_cname}`"))msg!("positive implementation in crate `{$positive_impl_cname}`"));
71                diag.arg("positive_impl_cname", cname.to_string());
72            }
73        }
74        diag
75    }
76}
77
78#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            InherentProjectionNormalizationOverflow where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    InherentProjectionNormalizationOverflow {
                        span: __binding_0, ty: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("overflow evaluating associated type `{$ty}`")));
                        ;
                        diag.arg("ty", __binding_1);
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
79#[diag("overflow evaluating associated type `{$ty}`")]
80pub(crate) struct InherentProjectionNormalizationOverflow {
81    #[primary_span]
82    pub span: Span,
83    pub ty: String,
84}
85
86pub(crate) enum AdjustSignatureBorrow {
87    Borrow { to_borrow: Vec<(Span, String)> },
88    RemoveBorrow { remove_borrow: Vec<(Span, String)> },
89}
90
91impl Subdiagnostic for AdjustSignatureBorrow {
92    fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
93        match self {
94            AdjustSignatureBorrow::Borrow { to_borrow } => {
95                diag.arg("borrow_len", to_borrow.len());
96                diag.multipart_suggestion(
97                    rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider adjusting the signature so it borrows its {$borrow_len ->\n                            [one] argument\n                            *[other] arguments\n                        }"))msg!(
98                        "consider adjusting the signature so it borrows its {$borrow_len ->
99                            [one] argument
100                            *[other] arguments
101                        }"
102                    ),
103                    to_borrow,
104                    Applicability::MaybeIncorrect,
105                );
106            }
107            AdjustSignatureBorrow::RemoveBorrow { remove_borrow } => {
108                diag.arg("remove_borrow_len", remove_borrow.len());
109                diag.multipart_suggestion(
110                    rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider adjusting the signature so it does not borrow its {$remove_borrow_len ->\n                            [one] argument\n                            *[other] arguments\n                        }"))msg!(
111                        "consider adjusting the signature so it does not borrow its {$remove_borrow_len ->
112                            [one] argument
113                            *[other] arguments
114                        }"
115                    ),
116                    remove_borrow,
117                    Applicability::MaybeIncorrect,
118                );
119            }
120        }
121    }
122}
123
124#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            ClosureKindMismatch where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    ClosureKindMismatch {
                        closure_span: __binding_0,
                        expected: __binding_1,
                        found: __binding_2,
                        cause_span: __binding_3,
                        trait_prefix: __binding_4,
                        fn_once_label: __binding_5,
                        fn_mut_label: __binding_6 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected a closure that implements the `{$trait_prefix}{$expected}` trait, but this closure only implements `{$trait_prefix}{$found}`")));
                        diag.code(E0525);
                        ;
                        diag.arg("expected", __binding_1);
                        diag.arg("found", __binding_2);
                        diag.arg("trait_prefix", __binding_4);
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this closure implements `{$trait_prefix}{$found}`, not `{$trait_prefix}{$expected}`")));
                        diag.span_label(__binding_3,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the requirement to implement `{$trait_prefix}{$expected}` derives from here")));
                        if let Some(__binding_5) = __binding_5 {
                            diag.subdiagnostic(__binding_5);
                        }
                        if let Some(__binding_6) = __binding_6 {
                            diag.subdiagnostic(__binding_6);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
125#[diag("expected a closure that implements the `{$trait_prefix}{$expected}` trait, but this closure only implements `{$trait_prefix}{$found}`", code = E0525)]
126pub(crate) struct ClosureKindMismatch {
127    #[primary_span]
128    #[label("this closure implements `{$trait_prefix}{$found}`, not `{$trait_prefix}{$expected}`")]
129    pub closure_span: Span,
130    pub expected: ClosureKind,
131    pub found: ClosureKind,
132    #[label("the requirement to implement `{$trait_prefix}{$expected}` derives from here")]
133    pub cause_span: Span,
134
135    pub trait_prefix: &'static str,
136
137    #[subdiagnostic]
138    pub fn_once_label: Option<ClosureFnOnceLabel>,
139
140    #[subdiagnostic]
141    pub fn_mut_label: Option<ClosureFnMutLabel>,
142}
143
144#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for ClosureFnOnceLabel {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    ClosureFnOnceLabel {
                        span: __binding_0,
                        place: __binding_1,
                        trait_prefix: __binding_2 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("place".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        sub_args.insert("trait_prefix".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("closure is `{$trait_prefix}FnOnce` because it moves the variable `{$place}` out of its environment")),
                                &sub_args);
                        diag.span_label(__binding_0, __message);
                    }
                }
            }
        }
    };Subdiagnostic)]
145#[label(
146    "closure is `{$trait_prefix}FnOnce` because it moves the variable `{$place}` out of its environment"
147)]
148pub(crate) struct ClosureFnOnceLabel {
149    #[primary_span]
150    pub span: Span,
151    pub place: String,
152    pub trait_prefix: &'static str,
153}
154
155#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for ClosureFnMutLabel {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    ClosureFnMutLabel {
                        span: __binding_0,
                        place: __binding_1,
                        trait_prefix: __binding_2 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("place".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        sub_args.insert("trait_prefix".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("closure is `{$trait_prefix}FnMut` because it mutates the variable `{$place}` here")),
                                &sub_args);
                        diag.span_label(__binding_0, __message);
                    }
                }
            }
        }
    };Subdiagnostic)]
156#[label("closure is `{$trait_prefix}FnMut` because it mutates the variable `{$place}` here")]
157pub(crate) struct ClosureFnMutLabel {
158    #[primary_span]
159    pub span: Span,
160    pub place: String,
161    pub trait_prefix: &'static str,
162}
163
164#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            CoroClosureNotFn where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    CoroClosureNotFn {
                        span: __binding_0, kind: __binding_1, coro_kind: __binding_2
                        } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$coro_kind}closure does not implement `{$kind}` because it captures state from its environment")));
                        ;
                        diag.arg("kind", __binding_1);
                        diag.arg("coro_kind", __binding_2);
                        diag.span(__binding_0);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
165#[diag(
166    "{$coro_kind}closure does not implement `{$kind}` because it captures state from its environment"
167)]
168pub(crate) struct CoroClosureNotFn {
169    #[primary_span]
170    pub span: Span,
171    pub kind: &'static str,
172    pub coro_kind: String,
173}
174
175#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            AnnotationRequired<'a> where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    AnnotationRequired {
                        span: __binding_0,
                        source_kind: __binding_1,
                        source_name: __binding_2,
                        failure_span: __binding_3,
                        bad_label: __binding_4,
                        infer_subdiags: __binding_5,
                        multi_suggestions: __binding_6 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$source_kind ->\n[closure] type annotations needed for the closure `{$source_name}`\n[normal] type annotations needed for `{$source_name}`\n*[other] type annotations needed\n}")));
                        diag.code(E0282);
                        ;
                        diag.arg("source_kind", __binding_1);
                        diag.arg("source_name", __binding_2);
                        diag.span(__binding_0);
                        if let Some(__binding_3) = __binding_3 {
                            diag.span_label(__binding_3,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type must be known at this point")));
                        }
                        if let Some(__binding_4) = __binding_4 {
                            diag.subdiagnostic(__binding_4);
                        }
                        for __binding_5 in __binding_5 {
                            diag.subdiagnostic(__binding_5);
                        }
                        for __binding_6 in __binding_6 {
                            diag.subdiagnostic(__binding_6);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
176#[diag("{$source_kind ->
177[closure] type annotations needed for the closure `{$source_name}`
178[normal] type annotations needed for `{$source_name}`
179*[other] type annotations needed
180}", code = E0282)]
181pub(crate) struct AnnotationRequired<'a> {
182    #[primary_span]
183    pub span: Span,
184    pub source_kind: &'static str,
185    pub source_name: &'a str,
186    #[label("type must be known at this point")]
187    pub failure_span: Option<Span>,
188    #[subdiagnostic]
189    pub bad_label: Option<InferenceBadError<'a>>,
190    #[subdiagnostic]
191    pub infer_subdiags: Vec<SourceKindSubdiag<'a>>,
192    #[subdiagnostic]
193    pub multi_suggestions: Vec<SourceKindMultiSuggestion<'a>>,
194}
195
196// Copy of `AnnotationRequired` for E0283
197#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            AmbiguousImpl<'a> where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    AmbiguousImpl {
                        span: __binding_0,
                        source_kind: __binding_1,
                        source_name: __binding_2,
                        failure_span: __binding_3,
                        bad_label: __binding_4,
                        infer_subdiags: __binding_5,
                        multi_suggestions: __binding_6 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$source_kind ->\n[closure] type annotations needed for the closure `{$source_name}`\n[normal] type annotations needed for `{$source_name}`\n*[other] type annotations needed\n}")));
                        diag.code(E0283);
                        ;
                        diag.arg("source_kind", __binding_1);
                        diag.arg("source_name", __binding_2);
                        diag.span(__binding_0);
                        if let Some(__binding_3) = __binding_3 {
                            diag.span_label(__binding_3,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type must be known at this point")));
                        }
                        if let Some(__binding_4) = __binding_4 {
                            diag.subdiagnostic(__binding_4);
                        }
                        for __binding_5 in __binding_5 {
                            diag.subdiagnostic(__binding_5);
                        }
                        for __binding_6 in __binding_6 {
                            diag.subdiagnostic(__binding_6);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
198#[diag("{$source_kind ->
199[closure] type annotations needed for the closure `{$source_name}`
200[normal] type annotations needed for `{$source_name}`
201*[other] type annotations needed
202}", code = E0283)]
203pub(crate) struct AmbiguousImpl<'a> {
204    #[primary_span]
205    pub span: Span,
206    pub source_kind: &'static str,
207    pub source_name: &'a str,
208    #[label("type must be known at this point")]
209    pub failure_span: Option<Span>,
210    #[subdiagnostic]
211    pub bad_label: Option<InferenceBadError<'a>>,
212    #[subdiagnostic]
213    pub infer_subdiags: Vec<SourceKindSubdiag<'a>>,
214    #[subdiagnostic]
215    pub multi_suggestions: Vec<SourceKindMultiSuggestion<'a>>,
216}
217
218// Copy of `AnnotationRequired` for E0284
219#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            AmbiguousReturn<'a> where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    AmbiguousReturn {
                        span: __binding_0,
                        source_kind: __binding_1,
                        source_name: __binding_2,
                        failure_span: __binding_3,
                        bad_label: __binding_4,
                        infer_subdiags: __binding_5,
                        multi_suggestions: __binding_6 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$source_kind ->\n[closure] type annotations needed for the closure `{$source_name}`\n[normal] type annotations needed for `{$source_name}`\n*[other] type annotations needed\n}")));
                        diag.code(E0284);
                        ;
                        diag.arg("source_kind", __binding_1);
                        diag.arg("source_name", __binding_2);
                        diag.span(__binding_0);
                        if let Some(__binding_3) = __binding_3 {
                            diag.span_label(__binding_3,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type must be known at this point")));
                        }
                        if let Some(__binding_4) = __binding_4 {
                            diag.subdiagnostic(__binding_4);
                        }
                        for __binding_5 in __binding_5 {
                            diag.subdiagnostic(__binding_5);
                        }
                        for __binding_6 in __binding_6 {
                            diag.subdiagnostic(__binding_6);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
220#[diag("{$source_kind ->
221[closure] type annotations needed for the closure `{$source_name}`
222[normal] type annotations needed for `{$source_name}`
223*[other] type annotations needed
224}", code = E0284)]
225pub(crate) struct AmbiguousReturn<'a> {
226    #[primary_span]
227    pub span: Span,
228    pub source_kind: &'static str,
229    pub source_name: &'a str,
230    #[label("type must be known at this point")]
231    pub failure_span: Option<Span>,
232    #[subdiagnostic]
233    pub bad_label: Option<InferenceBadError<'a>>,
234    #[subdiagnostic]
235    pub infer_subdiags: Vec<SourceKindSubdiag<'a>>,
236    #[subdiagnostic]
237    pub multi_suggestions: Vec<SourceKindMultiSuggestion<'a>>,
238}
239
240// Used when a better one isn't available
241#[derive(const _: () =
    {
        impl<'a> rustc_errors::Subdiagnostic for InferenceBadError<'a> {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    InferenceBadError {
                        span: __binding_0,
                        bad_kind: __binding_1,
                        prefix_kind: __binding_2,
                        has_parent: __binding_3,
                        prefix: __binding_4,
                        parent_prefix: __binding_5,
                        parent_name: __binding_6,
                        name: __binding_7 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("bad_kind".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        sub_args.insert("prefix_kind".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        sub_args.insert("has_parent".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
                                &mut diag.long_ty_path));
                        sub_args.insert("prefix".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_4,
                                &mut diag.long_ty_path));
                        sub_args.insert("parent_prefix".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_5,
                                &mut diag.long_ty_path));
                        sub_args.insert("parent_name".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_6,
                                &mut diag.long_ty_path));
                        sub_args.insert("name".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_7,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$bad_kind ->\n*[other] cannot infer type\n[more_info] cannot infer {$prefix_kind ->\n*[type] type for {$prefix}\n[const_with_param] the value of const parameter\n[const] the value of the constant\n} `{$name}`{$has_parent ->\n[true] {\" \"}declared on the {$parent_prefix} `{$parent_name}`\n*[false] {\"\"}\n}\n}")),
                                &sub_args);
                        diag.span_label(__binding_0, __message);
                    }
                }
            }
        }
    };Subdiagnostic)]
242#[label(
243    "{$bad_kind ->
244*[other] cannot infer type
245[more_info] cannot infer {$prefix_kind ->
246*[type] type for {$prefix}
247[const_with_param] the value of const parameter
248[const] the value of the constant
249} `{$name}`{$has_parent ->
250[true] {\" \"}declared on the {$parent_prefix} `{$parent_name}`
251*[false] {\"\"}
252}
253}"
254)]
255pub(crate) struct InferenceBadError<'a> {
256    #[primary_span]
257    pub span: Span,
258    pub bad_kind: &'static str,
259    pub prefix_kind: UnderspecifiedArgKind,
260    pub has_parent: bool,
261    pub prefix: &'a str,
262    pub parent_prefix: &'a str,
263    pub parent_name: String,
264    pub name: String,
265}
266
267#[derive(const _: () =
    {
        impl<'a> rustc_errors::Subdiagnostic for SourceKindSubdiag<'a> {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    SourceKindSubdiag::LetLike {
                        span: __binding_0,
                        name: __binding_1,
                        type_name: __binding_2,
                        kind: __binding_3,
                        x_kind: __binding_4,
                        prefix_kind: __binding_5,
                        prefix: __binding_6,
                        arg_name: __binding_7 } => {
                        let __code_0 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!(": {0}", __binding_2))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("name".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        sub_args.insert("type_name".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        sub_args.insert("kind".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
                                &mut diag.long_ty_path));
                        sub_args.insert("x_kind".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_4,
                                &mut diag.long_ty_path));
                        sub_args.insert("prefix_kind".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_5,
                                &mut diag.long_ty_path));
                        sub_args.insert("prefix".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_6,
                                &mut diag.long_ty_path));
                        sub_args.insert("arg_name".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_7,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$kind ->\n            [with_pattern] consider giving `{$name}` an explicit type\n            [closure] consider giving this closure parameter an explicit type\n            *[other] consider giving this pattern a type\n        }{$x_kind ->\n            [has_name] , where the {$prefix_kind ->\n                *[type] type for {$prefix}\n                [const_with_param] value of const parameter\n                [const] value of the constant\n            } `{$arg_name}` is specified\n            [underscore_single] , where the placeholder `_` is specified\n            [underscore_multiple] , where the placeholders `_` are specified\n            *[empty] {\"\"}\n        }")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_0, rustc_errors::Applicability::HasPlaceholders,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                    SourceKindSubdiag::GenericLabel {
                        span: __binding_0,
                        is_type: __binding_1,
                        param_name: __binding_2,
                        parent_exists: __binding_3,
                        parent_prefix: __binding_4,
                        parent_name: __binding_5 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("is_type".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        sub_args.insert("param_name".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        sub_args.insert("parent_exists".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
                                &mut diag.long_ty_path));
                        sub_args.insert("parent_prefix".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_4,
                                &mut diag.long_ty_path));
                        sub_args.insert("parent_name".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_5,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot infer {$is_type ->\n            [true] type\n            *[false] the value\n        } of the {$is_type ->\n            [true] type\n            *[false] const\n        } {$parent_exists ->\n            [true] parameter `{$param_name}` declared on the {$parent_prefix} `{$parent_name}`\n            *[false] parameter {$param_name}\n        }")),
                                &sub_args);
                        diag.span_label(__binding_0, __message);
                    }
                    SourceKindSubdiag::GenericSuggestion {
                        span: __binding_0, arg_count: __binding_1, args: __binding_2
                        } => {
                        let __code_1 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("::<{0}>", __binding_2))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("arg_count".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        sub_args.insert("args".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider specifying the generic {$arg_count ->\n            [one] argument\n            *[other] arguments\n        }")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_1, rustc_errors::Applicability::HasPlaceholders,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                    SourceKindSubdiag::GenericTypeSuggestion {
                        span: __binding_0, param: __binding_1 } => {
                        let __code_2 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("::</* Type */>"))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("param".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider specifying a concrete type for the type parameter `{$param}`")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_2, rustc_errors::Applicability::HasPlaceholders,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                    SourceKindSubdiag::ConstGenericSuggestion {
                        span: __binding_0, param: __binding_1 } => {
                        let __code_3 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("::</* CONST */>"))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("param".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider specifying a const for the const parameter `{$param}`")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_3, rustc_errors::Applicability::HasPlaceholders,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                }
            }
        }
    };Subdiagnostic)]
268pub(crate) enum SourceKindSubdiag<'a> {
269    #[suggestion(
270        "{$kind ->
271            [with_pattern] consider giving `{$name}` an explicit type
272            [closure] consider giving this closure parameter an explicit type
273            *[other] consider giving this pattern a type
274        }{$x_kind ->
275            [has_name] , where the {$prefix_kind ->
276                *[type] type for {$prefix}
277                [const_with_param] value of const parameter
278                [const] value of the constant
279            } `{$arg_name}` is specified
280            [underscore_single] , where the placeholder `_` is specified
281            [underscore_multiple] , where the placeholders `_` are specified
282            *[empty] {\"\"}
283        }",
284        style = "verbose",
285        code = ": {type_name}",
286        applicability = "has-placeholders"
287    )]
288    LetLike {
289        #[primary_span]
290        span: Span,
291        name: String,
292        type_name: String,
293        kind: &'static str,
294        x_kind: &'static str,
295        prefix_kind: UnderspecifiedArgKind,
296        prefix: &'a str,
297        arg_name: String,
298    },
299    #[label(
300        "cannot infer {$is_type ->
301            [true] type
302            *[false] the value
303        } of the {$is_type ->
304            [true] type
305            *[false] const
306        } {$parent_exists ->
307            [true] parameter `{$param_name}` declared on the {$parent_prefix} `{$parent_name}`
308            *[false] parameter {$param_name}
309        }"
310    )]
311    GenericLabel {
312        #[primary_span]
313        span: Span,
314        is_type: bool,
315        param_name: String,
316        parent_exists: bool,
317        parent_prefix: String,
318        parent_name: String,
319    },
320    #[suggestion(
321        "consider specifying the generic {$arg_count ->
322            [one] argument
323            *[other] arguments
324        }",
325        style = "verbose",
326        code = "::<{args}>",
327        applicability = "has-placeholders"
328    )]
329    GenericSuggestion {
330        #[primary_span]
331        span: Span,
332        arg_count: usize,
333        args: String,
334    },
335    #[suggestion(
336        "consider specifying a concrete type for the type parameter `{$param}`",
337        style = "verbose",
338        code = "::</* Type */>",
339        applicability = "has-placeholders"
340    )]
341    GenericTypeSuggestion {
342        #[primary_span]
343        span: Span,
344        param: String,
345    },
346    #[suggestion(
347        "consider specifying a const for the const parameter `{$param}`",
348        style = "verbose",
349        code = "::</* CONST */>",
350        applicability = "has-placeholders"
351    )]
352    ConstGenericSuggestion {
353        #[primary_span]
354        span: Span,
355        param: String,
356    },
357}
358
359#[derive(const _: () =
    {
        impl<'a> rustc_errors::Subdiagnostic for SourceKindMultiSuggestion<'a>
            {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    SourceKindMultiSuggestion::FullyQualified {
                        span_lo: __binding_0,
                        span_hi: __binding_1,
                        def_path: __binding_2,
                        adjustment: __binding_3,
                        successor_pos: __binding_4 } => {
                        let mut suggestions = Vec::new();
                        let __code_4 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("{1}({0}", __binding_3,
                                            __binding_2))
                                });
                        let __code_5 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("{0}", __binding_4))
                                });
                        suggestions.push((__binding_0, __code_4));
                        suggestions.push((__binding_1, __code_5));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("def_path".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        sub_args.insert("adjustment".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
                                &mut diag.long_ty_path));
                        sub_args.insert("successor_pos".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_4,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try using a fully qualified path to specify the expected types")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::HasPlaceholders,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                    SourceKindMultiSuggestion::ClosureReturn {
                        start_span: __binding_0,
                        start_span_code: __binding_1,
                        end_span: __binding_2 } => {
                        let mut suggestions = Vec::new();
                        let __code_6 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("{0}", __binding_1))
                                });
                        let __code_7 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(" }}"))
                                });
                        suggestions.push((__binding_0, __code_6));
                        if let Some(__binding_2) = __binding_2 {
                            suggestions.push((__binding_2, __code_7));
                        }
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("start_span_code".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try giving this closure an explicit return type")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::HasPlaceholders,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                }
            }
        }
    };Subdiagnostic)]
360pub(crate) enum SourceKindMultiSuggestion<'a> {
361    #[multipart_suggestion(
362        "try using a fully qualified path to specify the expected types",
363        style = "verbose",
364        applicability = "has-placeholders"
365    )]
366    FullyQualified {
367        #[suggestion_part(code = "{def_path}({adjustment}")]
368        span_lo: Span,
369        #[suggestion_part(code = "{successor_pos}")]
370        span_hi: Span,
371        def_path: String,
372        adjustment: &'a str,
373        successor_pos: &'a str,
374    },
375    #[multipart_suggestion(
376        "try giving this closure an explicit return type",
377        style = "verbose",
378        applicability = "has-placeholders"
379    )]
380    ClosureReturn {
381        #[suggestion_part(code = "{start_span_code}")]
382        start_span: Span,
383        start_span_code: String,
384        #[suggestion_part(code = " }}")]
385        end_span: Option<Span>,
386    },
387}
388
389impl<'a> SourceKindMultiSuggestion<'a> {
390    pub(crate) fn new_fully_qualified(
391        span: Span,
392        def_path: String,
393        adjustment: &'a str,
394        successor: (&'a str, BytePos),
395    ) -> Self {
396        Self::FullyQualified {
397            span_lo: span.shrink_to_lo(),
398            span_hi: span.shrink_to_hi().with_hi(successor.1),
399            def_path,
400            adjustment,
401            successor_pos: successor.0,
402        }
403    }
404
405    pub(crate) fn new_closure_return(
406        ty_info: String,
407        data: &'a FnRetTy<'a>,
408        should_wrap_expr: Option<Span>,
409    ) -> Self {
410        let arrow = match data {
411            FnRetTy::DefaultReturn(_) => " -> ",
412            _ => "",
413        };
414        let (start_span, start_span_code, end_span) = match should_wrap_expr {
415            Some(end_span) => (data.span(), ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("{0}{1} {{", arrow, ty_info))
    })format!("{arrow}{ty_info} {{"), Some(end_span)),
416            None => (data.span(), ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("{0}{1}", arrow, ty_info))
    })format!("{arrow}{ty_info}"), None),
417        };
418        Self::ClosureReturn { start_span, start_span_code, end_span }
419    }
420}
421
422pub(crate) enum RegionOriginNote<'a> {
423    Plain {
424        span: Span,
425        msg: DiagMessage,
426    },
427    WithName {
428        span: Span,
429        msg: DiagMessage,
430        name: &'a str,
431        continues: bool,
432    },
433    WithRequirement {
434        span: Span,
435        requirement: ObligationCauseAsDiagArg<'a>,
436        expected_found: Option<(DiagStyledString, DiagStyledString)>,
437    },
438}
439
440impl Subdiagnostic for RegionOriginNote<'_> {
441    fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
442        let label_or_note = |diag: &mut Diag<'_, G>, span, msg: DiagMessage| {
443            let sub_count = diag.children.iter().filter(|d| d.span.is_dummy()).count();
444            let expanded_sub_count = diag.children.iter().filter(|d| !d.span.is_dummy()).count();
445            let span_is_primary = diag.span.primary_spans().iter().all(|&sp| sp == span);
446            if span_is_primary && sub_count == 0 && expanded_sub_count == 0 {
447                diag.span_label(span, msg);
448            } else if span_is_primary && expanded_sub_count == 0 {
449                diag.note(msg);
450            } else {
451                diag.span_note(span, msg);
452            }
453        };
454        match self {
455            RegionOriginNote::Plain { span, msg } => {
456                label_or_note(diag, span, msg);
457            }
458            RegionOriginNote::WithName { span, msg, name, continues } => {
459                label_or_note(
460                    diag,
461                    span,
462                    msg.arg("name", name).arg("continues", continues).format(),
463                );
464            }
465            RegionOriginNote::WithRequirement {
466                span,
467                requirement,
468                expected_found: Some((expected, found)),
469            } => {
470                let msg = rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("...so that the {$requirement ->\n                        [method_compat] method type is compatible with trait\n                        [type_compat] associated type is compatible with trait\n                        [const_compat] const is compatible with trait\n                        [expr_assignable] expression is assignable\n                        [if_else_different] `if` and `else` have incompatible types\n                        [no_else] `if` missing an `else` returns `()`\n                        [fn_main_correct_type] `main` function has the correct type\n                        [fn_lang_correct_type] lang item function has the correct type\n                        [intrinsic_correct_type] intrinsic has the correct type\n                        [method_correct_type] method receiver has the correct type\n                        *[other] types are compatible\n                    }"))msg!(
471                    "...so that the {$requirement ->
472                        [method_compat] method type is compatible with trait
473                        [type_compat] associated type is compatible with trait
474                        [const_compat] const is compatible with trait
475                        [expr_assignable] expression is assignable
476                        [if_else_different] `if` and `else` have incompatible types
477                        [no_else] `if` missing an `else` returns `()`
478                        [fn_main_correct_type] `main` function has the correct type
479                        [fn_lang_correct_type] lang item function has the correct type
480                        [intrinsic_correct_type] intrinsic has the correct type
481                        [method_correct_type] method receiver has the correct type
482                        *[other] types are compatible
483                    }"
484                )
485                .arg("requirement", requirement)
486                .format();
487                label_or_note(diag, span, msg);
488
489                diag.note_expected_found("", expected, "", found);
490            }
491            RegionOriginNote::WithRequirement { span, requirement, expected_found: None } => {
492                // FIXME: this really should be handled at some earlier stage. Our
493                // handling of region checking when type errors are present is
494                // *terrible*.
495                let msg = rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("...so that {$requirement ->\n                            [method_compat] method type is compatible with trait\n                            [type_compat] associated type is compatible with trait\n                            [const_compat] const is compatible with trait\n                            [expr_assignable] expression is assignable\n                            [if_else_different] `if` and `else` have incompatible types\n                            [no_else] `if` missing an `else` returns `()`\n                            [fn_main_correct_type] `main` function has the correct type\n                            [fn_lang_correct_type] lang item function has the correct type\n                            [intrinsic_correct_type] intrinsic has the correct type\n                            [method_correct_type] method receiver has the correct type\n                            *[other] types are compatible\n                        }"))msg!(
496                    "...so that {$requirement ->
497                            [method_compat] method type is compatible with trait
498                            [type_compat] associated type is compatible with trait
499                            [const_compat] const is compatible with trait
500                            [expr_assignable] expression is assignable
501                            [if_else_different] `if` and `else` have incompatible types
502                            [no_else] `if` missing an `else` returns `()`
503                            [fn_main_correct_type] `main` function has the correct type
504                            [fn_lang_correct_type] lang item function has the correct type
505                            [intrinsic_correct_type] intrinsic has the correct type
506                            [method_correct_type] method receiver has the correct type
507                            *[other] types are compatible
508                        }"
509                )
510                .arg("requirement", requirement)
511                .format();
512                label_or_note(diag, span, msg);
513            }
514        };
515    }
516}
517
518pub(crate) enum LifetimeMismatchLabels {
519    InRet {
520        param_span: Span,
521        ret_span: Span,
522        span: Span,
523        label_var1: Option<Ident>,
524    },
525    Normal {
526        hir_equal: bool,
527        ty_sup: Span,
528        ty_sub: Span,
529        span: Span,
530        sup: Option<Ident>,
531        sub: Option<Ident>,
532    },
533}
534
535impl Subdiagnostic for LifetimeMismatchLabels {
536    fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
537        match self {
538            LifetimeMismatchLabels::InRet { param_span, ret_span, span, label_var1 } => {
539                diag.span_label(param_span, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this parameter and the return type are declared with different lifetimes..."))msg!("this parameter and the return type are declared with different lifetimes..."));
540                diag.span_label(ret_span, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{\"\"}"))msg!("{\"\"}"));
541                diag.span_label(
542                    span,
543                    rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("...but data{$label_var1_exists ->\n                            [true] {\" \"}from `{$label_var1}`\n                            *[false] {\"\"}\n                        } is returned here"))msg!(
544                        "...but data{$label_var1_exists ->
545                            [true] {\" \"}from `{$label_var1}`
546                            *[false] {\"\"}
547                        } is returned here"
548                    ),
549                );
550                diag.arg("label_var1_exists", label_var1.is_some());
551                diag.arg("label_var1", label_var1.map(|x| x.to_string()).unwrap_or_default());
552            }
553            LifetimeMismatchLabels::Normal {
554                hir_equal,
555                ty_sup,
556                ty_sub,
557                span,
558                sup: label_var1,
559                sub: label_var2,
560            } => {
561                if hir_equal {
562                    diag.span_label(
563                        ty_sup,
564                        rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this type is declared with multiple lifetimes..."))msg!("this type is declared with multiple lifetimes..."),
565                    );
566                    diag.span_label(ty_sub, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{\"\"}"))msg!("{\"\"}"));
567                    diag.span_label(
568                        span,
569                        rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("...but data with one lifetime flows into the other here"))msg!("...but data with one lifetime flows into the other here"),
570                    );
571                } else {
572                    diag.span_label(
573                        ty_sup,
574                        rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("these two types are declared with different lifetimes..."))msg!("these two types are declared with different lifetimes..."),
575                    );
576                    diag.span_label(ty_sub, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{\"\"}"))msg!("{\"\"}"));
577                    diag.span_label(
578                        span,
579                        rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("...but data{$label_var1_exists ->\n                                [true] {\" \"}from `{$label_var1}`\n                                *[false] {\"\"}\n                            } flows{$label_var2_exists ->\n                                [true] {\" \"}into `{$label_var2}`\n                                *[false] {\"\"}\n                            } here"))msg!(
580                            "...but data{$label_var1_exists ->
581                                [true] {\" \"}from `{$label_var1}`
582                                *[false] {\"\"}
583                            } flows{$label_var2_exists ->
584                                [true] {\" \"}into `{$label_var2}`
585                                *[false] {\"\"}
586                            } here"
587                        ),
588                    );
589                    diag.arg("label_var1_exists", label_var1.is_some());
590                    diag.arg("label_var1", label_var1.map(|x| x.to_string()).unwrap_or_default());
591                    diag.arg("label_var2_exists", label_var2.is_some());
592                    diag.arg("label_var2", label_var2.map(|x| x.to_string()).unwrap_or_default());
593                }
594            }
595        }
596    }
597}
598
599pub(crate) struct AddLifetimeParamsSuggestion<'a> {
600    pub tcx: TyCtxt<'a>,
601    pub generic_param_scope: LocalDefId,
602    pub sub: Region<'a>,
603    pub ty_sup: &'a hir::Ty<'a>,
604    pub ty_sub: &'a hir::Ty<'a>,
605    pub add_note: bool,
606}
607
608impl Subdiagnostic for AddLifetimeParamsSuggestion<'_> {
609    fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
610        let mut mk_suggestion = || {
611            let Some(anon_reg) = self.tcx.is_suitable_region(self.generic_param_scope, self.sub)
612            else {
613                return false;
614            };
615
616            let node = self.tcx.hir_node_by_def_id(anon_reg.scope);
617            let is_impl = #[allow(non_exhaustive_omitted_patterns)] match &node {
    hir::Node::ImplItem(_) => true,
    _ => false,
}matches!(&node, hir::Node::ImplItem(_));
618            let (generics, parent_generics) = match node {
619                hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn { generics, .. }, .. })
620                | hir::Node::TraitItem(hir::TraitItem { generics, .. })
621                | hir::Node::ImplItem(hir::ImplItem { generics, .. }) => (
622                    generics,
623                    match self.tcx.parent_hir_node(self.tcx.local_def_id_to_hir_id(anon_reg.scope))
624                    {
625                        hir::Node::Item(hir::Item {
626                            kind: hir::ItemKind::Trait { generics, .. },
627                            ..
628                        })
629                        | hir::Node::Item(hir::Item {
630                            kind: hir::ItemKind::Impl(hir::Impl { generics, .. }),
631                            ..
632                        }) => Some(generics),
633                        _ => None,
634                    },
635                ),
636                _ => return false,
637            };
638
639            let suggestion_param_name = generics
640                .params
641                .iter()
642                .filter(|p| #[allow(non_exhaustive_omitted_patterns)] match p.kind {
    GenericParamKind::Lifetime { .. } => true,
    _ => false,
}matches!(p.kind, GenericParamKind::Lifetime { .. }))
643                .map(|p| p.name.ident().name)
644                .find(|i| *i != kw::UnderscoreLifetime);
645            let introduce_new = suggestion_param_name.is_none();
646
647            let mut default = "'a".to_string();
648            if let Some(parent_generics) = parent_generics {
649                let used: FxHashSet<_> = parent_generics
650                    .params
651                    .iter()
652                    .filter(|p| #[allow(non_exhaustive_omitted_patterns)] match p.kind {
    GenericParamKind::Lifetime { .. } => true,
    _ => false,
}matches!(p.kind, GenericParamKind::Lifetime { .. }))
653                    .map(|p| p.name.ident().name)
654                    .filter(|i| *i != kw::UnderscoreLifetime)
655                    .map(|l| l.to_string())
656                    .collect();
657                if let Some(lt) =
658                    ('a'..='z').map(|it| ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("\'{0}", it))
    })format!("'{it}")).find(|it| !used.contains(it))
659                {
660                    // We want a lifetime that *isn't* present in the `trait` or `impl` that assoc
661                    // `fn` belongs to. We could suggest reusing one of their lifetimes, but it is
662                    // likely to be an over-constraining lifetime requirement, so we always add a
663                    // lifetime to the `fn`.
664                    default = lt;
665                }
666            }
667            let suggestion_param_name =
668                suggestion_param_name.map(|n| n.to_string()).unwrap_or_else(|| default);
669
670            struct ImplicitLifetimeFinder {
671                suggestions: Vec<(Span, String)>,
672                suggestion_param_name: String,
673            }
674
675            impl<'v> Visitor<'v> for ImplicitLifetimeFinder {
676                fn visit_ty(&mut self, ty: &'v hir::Ty<'v, AmbigArg>) {
677                    match ty.kind {
678                        hir::TyKind::Path(hir::QPath::Resolved(_, path)) => {
679                            for segment in path.segments {
680                                if let Some(args) = segment.args {
681                                    if args.args.iter().all(|arg| {
682                                        #[allow(non_exhaustive_omitted_patterns)] match arg {
    hir::GenericArg::Lifetime(lifetime) if lifetime.is_implicit() => true,
    _ => false,
}matches!(
683                                            arg,
684                                            hir::GenericArg::Lifetime(lifetime)
685                                                if lifetime.is_implicit()
686                                        )
687                                    }) {
688                                        self.suggestions.push((
689                                            segment.ident.span.shrink_to_hi(),
690                                            ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("<{0}>",
                args.args.iter().map(|_|
                                self.suggestion_param_name.clone()).collect::<Vec<_>>().join(", ")))
    })format!(
691                                                "<{}>",
692                                                args.args
693                                                    .iter()
694                                                    .map(|_| self.suggestion_param_name.clone())
695                                                    .collect::<Vec<_>>()
696                                                    .join(", ")
697                                            ),
698                                        ));
699                                    } else {
700                                        for arg in args.args {
701                                            if let hir::GenericArg::Lifetime(lifetime) = arg
702                                                && lifetime.is_anonymous()
703                                            {
704                                                self.suggestions.push(
705                                                    lifetime
706                                                        .suggestion(&self.suggestion_param_name),
707                                                );
708                                            }
709                                        }
710                                    }
711                                }
712                            }
713                        }
714                        hir::TyKind::Ref(lifetime, ..) if lifetime.is_anonymous() => {
715                            self.suggestions.push(lifetime.suggestion(&self.suggestion_param_name));
716                        }
717                        _ => {}
718                    }
719                    walk_ty(self, ty);
720                }
721            }
722            let mut visitor = ImplicitLifetimeFinder {
723                suggestions: ::alloc::vec::Vec::new()vec![],
724                suggestion_param_name: suggestion_param_name.clone(),
725            };
726            if let Some(fn_decl) = node.fn_decl()
727                && let hir::FnRetTy::Return(ty) = fn_decl.output
728            {
729                visitor.visit_ty_unambig(ty);
730            }
731            if visitor.suggestions.is_empty() {
732                // Do not suggest constraining the `&self` param, but rather the return type.
733                // If that is wrong (because it is not sufficient), a follow up error will tell the
734                // user to fix it. This way we lower the chances of *over* constraining, but still
735                // get the cake of "correctly" constrained in two steps.
736                visitor.visit_ty_unambig(self.ty_sup);
737            }
738            visitor.visit_ty_unambig(self.ty_sub);
739            if visitor.suggestions.is_empty() {
740                return false;
741            }
742            if introduce_new {
743                let new_param_suggestion = if let Some(first) =
744                    generics.params.iter().find(|p| !p.name.ident().span.is_empty())
745                {
746                    (first.span.shrink_to_lo(), ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("{0}, ", suggestion_param_name))
    })format!("{suggestion_param_name}, "))
747                } else {
748                    (generics.span, ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("<{0}>", suggestion_param_name))
    })format!("<{suggestion_param_name}>"))
749                };
750
751                visitor.suggestions.push(new_param_suggestion);
752            }
753            diag.multipart_suggestion(
754                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider {$is_reuse ->\n                        [true] reusing\n                        *[false] introducing\n                    } a named lifetime parameter{$is_impl ->\n                        [true] {\" \"}and update trait if needed\n                        *[false] {\"\"}\n                    }"))msg!(
755                    "consider {$is_reuse ->
756                        [true] reusing
757                        *[false] introducing
758                    } a named lifetime parameter{$is_impl ->
759                        [true] {\" \"}and update trait if needed
760                        *[false] {\"\"}
761                    }"
762                ),
763                visitor.suggestions,
764                Applicability::MaybeIncorrect,
765            );
766            diag.arg("is_impl", is_impl);
767            diag.arg("is_reuse", !introduce_new);
768
769            true
770        };
771        if mk_suggestion() && self.add_note {
772            diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("each elided lifetime in input position becomes a distinct lifetime"))msg!("each elided lifetime in input position becomes a distinct lifetime"));
773        }
774    }
775}
776
777#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            LifetimeMismatch<'a> where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    LifetimeMismatch {
                        span: __binding_0,
                        labels: __binding_1,
                        suggestion: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetime mismatch")));
                        diag.code(E0623);
                        ;
                        diag.span(__binding_0);
                        diag.subdiagnostic(__binding_1);
                        diag.subdiagnostic(__binding_2);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
778#[diag("lifetime mismatch", code = E0623)]
779pub(crate) struct LifetimeMismatch<'a> {
780    #[primary_span]
781    pub span: Span,
782    #[subdiagnostic]
783    pub labels: LifetimeMismatchLabels,
784    #[subdiagnostic]
785    pub suggestion: AddLifetimeParamsSuggestion<'a>,
786}
787
788pub(crate) struct IntroducesStaticBecauseUnmetLifetimeReq {
789    pub unmet_requirements: MultiSpan,
790    pub binding_span: Span,
791}
792
793impl Subdiagnostic for IntroducesStaticBecauseUnmetLifetimeReq {
794    fn add_to_diag<G: EmissionGuarantee>(mut self, diag: &mut Diag<'_, G>) {
795        self.unmet_requirements.push_span_label(
796            self.binding_span,
797            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("introduces a `'static` lifetime requirement"))msg!("introduces a `'static` lifetime requirement"),
798        );
799        diag.span_note(
800            self.unmet_requirements,
801            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("because this has an unmet lifetime requirement"))msg!("because this has an unmet lifetime requirement"),
802        );
803    }
804}
805
806// FIXME(#100717): replace with a `Option<Span>` when subdiagnostic supports that
807#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for DoesNotOutliveStaticFromImpl {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    DoesNotOutliveStaticFromImpl::Spanned { span: __binding_0 }
                        => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("...does not necessarily outlive the static lifetime introduced by the compatible `impl`")),
                                &sub_args);
                        diag.span_note(__binding_0, __message);
                    }
                    DoesNotOutliveStaticFromImpl::Unspanned => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("...does not necessarily outlive the static lifetime introduced by the compatible `impl`")),
                                &sub_args);
                        diag.note(__message);
                    }
                }
            }
        }
    };Subdiagnostic)]
808pub(crate) enum DoesNotOutliveStaticFromImpl {
809    #[note(
810        "...does not necessarily outlive the static lifetime introduced by the compatible `impl`"
811    )]
812    Spanned {
813        #[primary_span]
814        span: Span,
815    },
816    #[note(
817        "...does not necessarily outlive the static lifetime introduced by the compatible `impl`"
818    )]
819    Unspanned,
820}
821
822#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for ImplicitStaticLifetimeSubdiag {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    ImplicitStaticLifetimeSubdiag::Note { span: __binding_0 } =>
                        {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this has an implicit `'static` lifetime requirement")),
                                &sub_args);
                        diag.span_note(__binding_0, __message);
                    }
                    ImplicitStaticLifetimeSubdiag::Sugg { span: __binding_0 } =>
                        {
                        let __code_8 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!(" + \'_"))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider relaxing the implicit `'static` requirement")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_8, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                }
            }
        }
    };Subdiagnostic)]
823pub(crate) enum ImplicitStaticLifetimeSubdiag {
824    #[note("this has an implicit `'static` lifetime requirement")]
825    Note {
826        #[primary_span]
827        span: Span,
828    },
829    #[suggestion(
830        "consider relaxing the implicit `'static` requirement",
831        style = "verbose",
832        code = " + '_",
833        applicability = "maybe-incorrect"
834    )]
835    Sugg {
836        #[primary_span]
837        span: Span,
838    },
839}
840
841#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            MismatchedStaticLifetime<'a> where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    MismatchedStaticLifetime {
                        cause_span: __binding_0,
                        unmet_lifetime_reqs: __binding_1,
                        expl: __binding_2,
                        does_not_outlive_static_from_impl: __binding_3,
                        implicit_static_lifetimes: __binding_4 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("incompatible lifetime on type")));
                        ;
                        diag.span(__binding_0);
                        diag.subdiagnostic(__binding_1);
                        if let Some(__binding_2) = __binding_2 {
                            diag.subdiagnostic(__binding_2);
                        }
                        diag.subdiagnostic(__binding_3);
                        for __binding_4 in __binding_4 {
                            diag.subdiagnostic(__binding_4);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
842#[diag("incompatible lifetime on type")]
843pub(crate) struct MismatchedStaticLifetime<'a> {
844    #[primary_span]
845    pub cause_span: Span,
846    #[subdiagnostic]
847    pub unmet_lifetime_reqs: IntroducesStaticBecauseUnmetLifetimeReq,
848    #[subdiagnostic]
849    pub expl: Option<note_and_explain::RegionExplanation<'a>>,
850    #[subdiagnostic]
851    pub does_not_outlive_static_from_impl: DoesNotOutliveStaticFromImpl,
852    #[subdiagnostic]
853    pub implicit_static_lifetimes: Vec<ImplicitStaticLifetimeSubdiag>,
854}
855
856#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            ExplicitLifetimeRequired<'a> where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    ExplicitLifetimeRequired::WithIdent {
                        span: __binding_0,
                        simple_ident: __binding_1,
                        named: __binding_2,
                        new_ty_span: __binding_3,
                        new_ty: __binding_4 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("explicit lifetime required in the type of `{$simple_ident}`")));
                        let __code_9 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("{0}", __binding_4))
                                            })].into_iter();
                        diag.code(E0621);
                        ;
                        diag.arg("simple_ident", __binding_1);
                        diag.arg("named", __binding_2);
                        diag.arg("new_ty", __binding_4);
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetime `{$named}` required")));
                        diag.span_suggestions_with_style(__binding_3,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add explicit lifetime `{$named}` to the type of `{$simple_ident}`")),
                            __code_9, rustc_errors::Applicability::Unspecified,
                            rustc_errors::SuggestionStyle::ShowAlways);
                        diag
                    }
                    ExplicitLifetimeRequired::WithParamType {
                        span: __binding_0,
                        named: __binding_1,
                        new_ty_span: __binding_2,
                        new_ty: __binding_3 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("explicit lifetime required in parameter type")));
                        let __code_10 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("{0}", __binding_3))
                                            })].into_iter();
                        diag.code(E0621);
                        ;
                        diag.arg("named", __binding_1);
                        diag.arg("new_ty", __binding_3);
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetime `{$named}` required")));
                        diag.span_suggestions_with_style(__binding_2,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add explicit lifetime `{$named}` to type")),
                            __code_10, rustc_errors::Applicability::Unspecified,
                            rustc_errors::SuggestionStyle::ShowAlways);
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
857pub(crate) enum ExplicitLifetimeRequired<'a> {
858    #[diag("explicit lifetime required in the type of `{$simple_ident}`", code = E0621)]
859    WithIdent {
860        #[primary_span]
861        #[label("lifetime `{$named}` required")]
862        span: Span,
863        simple_ident: Ident,
864        named: String,
865        #[suggestion(
866            "add explicit lifetime `{$named}` to the type of `{$simple_ident}`",
867            code = "{new_ty}",
868            applicability = "unspecified",
869            style = "verbose"
870        )]
871        new_ty_span: Span,
872        new_ty: Ty<'a>,
873    },
874    #[diag("explicit lifetime required in parameter type", code = E0621)]
875    WithParamType {
876        #[primary_span]
877        #[label("lifetime `{$named}` required")]
878        span: Span,
879        named: String,
880        #[suggestion(
881            "add explicit lifetime `{$named}` to type",
882            code = "{new_ty}",
883            applicability = "unspecified",
884            style = "verbose"
885        )]
886        new_ty_span: Span,
887        new_ty: Ty<'a>,
888    },
889}
890
891pub(crate) enum TyOrSig<'tcx> {
892    Ty(Highlighted<'tcx, Ty<'tcx>>),
893    ClosureSig(Highlighted<'tcx, Binder<'tcx, FnSig<'tcx>>>),
894}
895
896impl IntoDiagArg for TyOrSig<'_> {
897    fn into_diag_arg(self, path: &mut Option<std::path::PathBuf>) -> rustc_errors::DiagArgValue {
898        match self {
899            TyOrSig::Ty(ty) => ty.into_diag_arg(path),
900            TyOrSig::ClosureSig(sig) => sig.into_diag_arg(path),
901        }
902    }
903}
904
905#[derive(const _: () =
    {
        impl<'tcx> rustc_errors::Subdiagnostic for ActualImplExplNotes<'tcx> {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    ActualImplExplNotes::ExpectedSignatureTwo {
                        leading_ellipsis: __binding_0,
                        ty_or_sig: __binding_1,
                        trait_path: __binding_2,
                        lifetime_1: __binding_3,
                        lifetime_2: __binding_4 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("leading_ellipsis".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
                                &mut diag.long_ty_path));
                        sub_args.insert("ty_or_sig".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        sub_args.insert("trait_path".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        sub_args.insert("lifetime_1".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
                                &mut diag.long_ty_path));
                        sub_args.insert("lifetime_2".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_4,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$leading_ellipsis ->\n        [true] ...\n        *[false] {\"\"}\n    }closure with signature `{$ty_or_sig}` must implement `{$trait_path}`, for any two lifetimes `'{$lifetime_1}` and `'{$lifetime_2}`...")),
                                &sub_args);
                        diag.note(__message);
                    }
                    ActualImplExplNotes::ExpectedSignatureAny {
                        leading_ellipsis: __binding_0,
                        ty_or_sig: __binding_1,
                        trait_path: __binding_2,
                        lifetime_1: __binding_3 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("leading_ellipsis".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
                                &mut diag.long_ty_path));
                        sub_args.insert("ty_or_sig".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        sub_args.insert("trait_path".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        sub_args.insert("lifetime_1".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$leading_ellipsis ->\n        [true] ...\n        *[false] {\"\"}\n    }closure with signature `{$ty_or_sig}` must implement `{$trait_path}`, for any lifetime `'{$lifetime_1}`...")),
                                &sub_args);
                        diag.note(__message);
                    }
                    ActualImplExplNotes::ExpectedSignatureSome {
                        leading_ellipsis: __binding_0,
                        ty_or_sig: __binding_1,
                        trait_path: __binding_2,
                        lifetime_1: __binding_3 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("leading_ellipsis".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
                                &mut diag.long_ty_path));
                        sub_args.insert("ty_or_sig".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        sub_args.insert("trait_path".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        sub_args.insert("lifetime_1".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$leading_ellipsis ->\n        [true] ...\n        *[false] {\"\"}\n    }closure with signature `{$ty_or_sig}` must implement `{$trait_path}`, for some specific lifetime `'{$lifetime_1}`...")),
                                &sub_args);
                        diag.note(__message);
                    }
                    ActualImplExplNotes::ExpectedSignatureNothing {
                        leading_ellipsis: __binding_0,
                        ty_or_sig: __binding_1,
                        trait_path: __binding_2 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("leading_ellipsis".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
                                &mut diag.long_ty_path));
                        sub_args.insert("ty_or_sig".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        sub_args.insert("trait_path".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$leading_ellipsis ->\n            [true] ...\n            *[false] {\"\"}\n        }closure with signature `{$ty_or_sig}` must implement `{$trait_path}`")),
                                &sub_args);
                        diag.note(__message);
                    }
                    ActualImplExplNotes::ExpectedPassiveTwo {
                        leading_ellipsis: __binding_0,
                        ty_or_sig: __binding_1,
                        trait_path: __binding_2,
                        lifetime_1: __binding_3,
                        lifetime_2: __binding_4 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("leading_ellipsis".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
                                &mut diag.long_ty_path));
                        sub_args.insert("ty_or_sig".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        sub_args.insert("trait_path".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        sub_args.insert("lifetime_1".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
                                &mut diag.long_ty_path));
                        sub_args.insert("lifetime_2".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_4,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$leading_ellipsis ->\n        [true] ...\n        *[false] {\"\"}\n    }`{$trait_path}` would have to be implemented for the type `{$ty_or_sig}`, for any two lifetimes `'{$lifetime_1}` and `'{$lifetime_2}`...")),
                                &sub_args);
                        diag.note(__message);
                    }
                    ActualImplExplNotes::ExpectedPassiveAny {
                        leading_ellipsis: __binding_0,
                        ty_or_sig: __binding_1,
                        trait_path: __binding_2,
                        lifetime_1: __binding_3 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("leading_ellipsis".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
                                &mut diag.long_ty_path));
                        sub_args.insert("ty_or_sig".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        sub_args.insert("trait_path".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        sub_args.insert("lifetime_1".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$leading_ellipsis ->\n        [true] ...\n        *[false] {\"\"}\n    }`{$trait_path}` would have to be implemented for the type `{$ty_or_sig}`, for any lifetime `'{$lifetime_1}`...")),
                                &sub_args);
                        diag.note(__message);
                    }
                    ActualImplExplNotes::ExpectedPassiveSome {
                        leading_ellipsis: __binding_0,
                        ty_or_sig: __binding_1,
                        trait_path: __binding_2,
                        lifetime_1: __binding_3 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("leading_ellipsis".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
                                &mut diag.long_ty_path));
                        sub_args.insert("ty_or_sig".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        sub_args.insert("trait_path".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        sub_args.insert("lifetime_1".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$leading_ellipsis ->\n        [true] ...\n        *[false] {\"\"}\n    }`{$trait_path}` would have to be implemented for the type `{$ty_or_sig}`, for some specific lifetime `'{$lifetime_1}`...")),
                                &sub_args);
                        diag.note(__message);
                    }
                    ActualImplExplNotes::ExpectedPassiveNothing {
                        leading_ellipsis: __binding_0,
                        ty_or_sig: __binding_1,
                        trait_path: __binding_2 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("leading_ellipsis".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
                                &mut diag.long_ty_path));
                        sub_args.insert("ty_or_sig".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        sub_args.insert("trait_path".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$leading_ellipsis ->\n            [true] ...\n            *[false] {\"\"}\n        }`{$trait_path}` would have to be implemented for the type `{$ty_or_sig}`")),
                                &sub_args);
                        diag.note(__message);
                    }
                    ActualImplExplNotes::ExpectedOtherTwo {
                        leading_ellipsis: __binding_0,
                        ty_or_sig: __binding_1,
                        trait_path: __binding_2,
                        lifetime_1: __binding_3,
                        lifetime_2: __binding_4 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("leading_ellipsis".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
                                &mut diag.long_ty_path));
                        sub_args.insert("ty_or_sig".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        sub_args.insert("trait_path".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        sub_args.insert("lifetime_1".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
                                &mut diag.long_ty_path));
                        sub_args.insert("lifetime_2".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_4,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$leading_ellipsis ->\n        [true] ...\n        *[false] {\"\"}\n    }`{$ty_or_sig}` must implement `{$trait_path}`, for any two lifetimes `'{$lifetime_1}` and `'{$lifetime_2}`...")),
                                &sub_args);
                        diag.note(__message);
                    }
                    ActualImplExplNotes::ExpectedOtherAny {
                        leading_ellipsis: __binding_0,
                        ty_or_sig: __binding_1,
                        trait_path: __binding_2,
                        lifetime_1: __binding_3 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("leading_ellipsis".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
                                &mut diag.long_ty_path));
                        sub_args.insert("ty_or_sig".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        sub_args.insert("trait_path".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        sub_args.insert("lifetime_1".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$leading_ellipsis ->\n            [true] ...\n            *[false] {\"\"}\n        }`{$ty_or_sig}` must implement `{$trait_path}`, for any lifetime `'{$lifetime_1}`...")),
                                &sub_args);
                        diag.note(__message);
                    }
                    ActualImplExplNotes::ExpectedOtherSome {
                        leading_ellipsis: __binding_0,
                        ty_or_sig: __binding_1,
                        trait_path: __binding_2,
                        lifetime_1: __binding_3 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("leading_ellipsis".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
                                &mut diag.long_ty_path));
                        sub_args.insert("ty_or_sig".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        sub_args.insert("trait_path".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        sub_args.insert("lifetime_1".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$leading_ellipsis ->\n            [true] ...\n            *[false] {\"\"}\n        }`{$ty_or_sig}` must implement `{$trait_path}`, for some specific lifetime `'{$lifetime_1}`...")),
                                &sub_args);
                        diag.note(__message);
                    }
                    ActualImplExplNotes::ExpectedOtherNothing {
                        leading_ellipsis: __binding_0,
                        ty_or_sig: __binding_1,
                        trait_path: __binding_2 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("leading_ellipsis".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
                                &mut diag.long_ty_path));
                        sub_args.insert("ty_or_sig".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        sub_args.insert("trait_path".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$leading_ellipsis ->\n            [true] ...\n            *[false] {\"\"}\n        }`{$ty_or_sig}` must implement `{$trait_path}`")),
                                &sub_args);
                        diag.note(__message);
                    }
                    ActualImplExplNotes::ButActuallyImplementsTrait {
                        trait_path: __binding_0,
                        has_lifetime: __binding_1,
                        lifetime: __binding_2 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("trait_path".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
                                &mut diag.long_ty_path));
                        sub_args.insert("has_lifetime".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        sub_args.insert("lifetime".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("...but it actually implements `{$trait_path}`{$has_lifetime ->\n            [true] , for some specific lifetime `'{$lifetime}`\n            *[false] {\"\"}\n        }")),
                                &sub_args);
                        diag.note(__message);
                    }
                    ActualImplExplNotes::ButActuallyImplementedForTy {
                        trait_path: __binding_0,
                        has_lifetime: __binding_1,
                        lifetime: __binding_2,
                        ty: __binding_3 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("trait_path".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
                                &mut diag.long_ty_path));
                        sub_args.insert("has_lifetime".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        sub_args.insert("lifetime".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        sub_args.insert("ty".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("...but `{$trait_path}` is actually implemented for the type `{$ty}`{$has_lifetime ->\n            [true] , for some specific lifetime `'{$lifetime}`\n            *[false] {\"\"}\n        }")),
                                &sub_args);
                        diag.note(__message);
                    }
                    ActualImplExplNotes::ButActuallyTyImplements {
                        trait_path: __binding_0,
                        has_lifetime: __binding_1,
                        lifetime: __binding_2,
                        ty: __binding_3 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("trait_path".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
                                &mut diag.long_ty_path));
                        sub_args.insert("has_lifetime".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        sub_args.insert("lifetime".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        sub_args.insert("ty".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("...but `{$ty}` actually implements `{$trait_path}`{$has_lifetime ->\n            [true] , for some specific lifetime `'{$lifetime}`\n            *[false] {\"\"}\n        }")),
                                &sub_args);
                        diag.note(__message);
                    }
                }
            }
        }
    };Subdiagnostic)]
906pub(crate) enum ActualImplExplNotes<'tcx> {
907    #[note("{$leading_ellipsis ->
908        [true] ...
909        *[false] {\"\"}
910    }closure with signature `{$ty_or_sig}` must implement `{$trait_path}`, for any two lifetimes `'{$lifetime_1}` and `'{$lifetime_2}`...")]
911    ExpectedSignatureTwo {
912        leading_ellipsis: bool,
913        ty_or_sig: TyOrSig<'tcx>,
914        trait_path: Highlighted<'tcx, TraitRefPrintOnlyTraitPath<'tcx>>,
915        lifetime_1: usize,
916        lifetime_2: usize,
917    },
918    #[note("{$leading_ellipsis ->
919        [true] ...
920        *[false] {\"\"}
921    }closure with signature `{$ty_or_sig}` must implement `{$trait_path}`, for any lifetime `'{$lifetime_1}`...")]
922    ExpectedSignatureAny {
923        leading_ellipsis: bool,
924        ty_or_sig: TyOrSig<'tcx>,
925        trait_path: Highlighted<'tcx, TraitRefPrintOnlyTraitPath<'tcx>>,
926        lifetime_1: usize,
927    },
928    #[note("{$leading_ellipsis ->
929        [true] ...
930        *[false] {\"\"}
931    }closure with signature `{$ty_or_sig}` must implement `{$trait_path}`, for some specific lifetime `'{$lifetime_1}`...")]
932    ExpectedSignatureSome {
933        leading_ellipsis: bool,
934        ty_or_sig: TyOrSig<'tcx>,
935        trait_path: Highlighted<'tcx, TraitRefPrintOnlyTraitPath<'tcx>>,
936        lifetime_1: usize,
937    },
938    #[note(
939        "{$leading_ellipsis ->
940            [true] ...
941            *[false] {\"\"}
942        }closure with signature `{$ty_or_sig}` must implement `{$trait_path}`"
943    )]
944    ExpectedSignatureNothing {
945        leading_ellipsis: bool,
946        ty_or_sig: TyOrSig<'tcx>,
947        trait_path: Highlighted<'tcx, TraitRefPrintOnlyTraitPath<'tcx>>,
948    },
949    #[note("{$leading_ellipsis ->
950        [true] ...
951        *[false] {\"\"}
952    }`{$trait_path}` would have to be implemented for the type `{$ty_or_sig}`, for any two lifetimes `'{$lifetime_1}` and `'{$lifetime_2}`...")]
953    ExpectedPassiveTwo {
954        leading_ellipsis: bool,
955        ty_or_sig: TyOrSig<'tcx>,
956        trait_path: Highlighted<'tcx, TraitRefPrintOnlyTraitPath<'tcx>>,
957        lifetime_1: usize,
958        lifetime_2: usize,
959    },
960    #[note("{$leading_ellipsis ->
961        [true] ...
962        *[false] {\"\"}
963    }`{$trait_path}` would have to be implemented for the type `{$ty_or_sig}`, for any lifetime `'{$lifetime_1}`...")]
964    ExpectedPassiveAny {
965        leading_ellipsis: bool,
966        ty_or_sig: TyOrSig<'tcx>,
967        trait_path: Highlighted<'tcx, TraitRefPrintOnlyTraitPath<'tcx>>,
968        lifetime_1: usize,
969    },
970    #[note("{$leading_ellipsis ->
971        [true] ...
972        *[false] {\"\"}
973    }`{$trait_path}` would have to be implemented for the type `{$ty_or_sig}`, for some specific lifetime `'{$lifetime_1}`...")]
974    ExpectedPassiveSome {
975        leading_ellipsis: bool,
976        ty_or_sig: TyOrSig<'tcx>,
977        trait_path: Highlighted<'tcx, TraitRefPrintOnlyTraitPath<'tcx>>,
978        lifetime_1: usize,
979    },
980    #[note(
981        "{$leading_ellipsis ->
982            [true] ...
983            *[false] {\"\"}
984        }`{$trait_path}` would have to be implemented for the type `{$ty_or_sig}`"
985    )]
986    ExpectedPassiveNothing {
987        leading_ellipsis: bool,
988        ty_or_sig: TyOrSig<'tcx>,
989        trait_path: Highlighted<'tcx, TraitRefPrintOnlyTraitPath<'tcx>>,
990    },
991    #[note("{$leading_ellipsis ->
992        [true] ...
993        *[false] {\"\"}
994    }`{$ty_or_sig}` must implement `{$trait_path}`, for any two lifetimes `'{$lifetime_1}` and `'{$lifetime_2}`...")]
995    ExpectedOtherTwo {
996        leading_ellipsis: bool,
997        ty_or_sig: TyOrSig<'tcx>,
998        trait_path: Highlighted<'tcx, TraitRefPrintOnlyTraitPath<'tcx>>,
999        lifetime_1: usize,
1000        lifetime_2: usize,
1001    },
1002    #[note(
1003        "{$leading_ellipsis ->
1004            [true] ...
1005            *[false] {\"\"}
1006        }`{$ty_or_sig}` must implement `{$trait_path}`, for any lifetime `'{$lifetime_1}`..."
1007    )]
1008    ExpectedOtherAny {
1009        leading_ellipsis: bool,
1010        ty_or_sig: TyOrSig<'tcx>,
1011        trait_path: Highlighted<'tcx, TraitRefPrintOnlyTraitPath<'tcx>>,
1012        lifetime_1: usize,
1013    },
1014    #[note(
1015        "{$leading_ellipsis ->
1016            [true] ...
1017            *[false] {\"\"}
1018        }`{$ty_or_sig}` must implement `{$trait_path}`, for some specific lifetime `'{$lifetime_1}`..."
1019    )]
1020    ExpectedOtherSome {
1021        leading_ellipsis: bool,
1022        ty_or_sig: TyOrSig<'tcx>,
1023        trait_path: Highlighted<'tcx, TraitRefPrintOnlyTraitPath<'tcx>>,
1024        lifetime_1: usize,
1025    },
1026    #[note(
1027        "{$leading_ellipsis ->
1028            [true] ...
1029            *[false] {\"\"}
1030        }`{$ty_or_sig}` must implement `{$trait_path}`"
1031    )]
1032    ExpectedOtherNothing {
1033        leading_ellipsis: bool,
1034        ty_or_sig: TyOrSig<'tcx>,
1035        trait_path: Highlighted<'tcx, TraitRefPrintOnlyTraitPath<'tcx>>,
1036    },
1037    #[note(
1038        "...but it actually implements `{$trait_path}`{$has_lifetime ->
1039            [true] , for some specific lifetime `'{$lifetime}`
1040            *[false] {\"\"}
1041        }"
1042    )]
1043    ButActuallyImplementsTrait {
1044        trait_path: Highlighted<'tcx, TraitRefPrintOnlyTraitPath<'tcx>>,
1045        has_lifetime: bool,
1046        lifetime: usize,
1047    },
1048    #[note(
1049        "...but `{$trait_path}` is actually implemented for the type `{$ty}`{$has_lifetime ->
1050            [true] , for some specific lifetime `'{$lifetime}`
1051            *[false] {\"\"}
1052        }"
1053    )]
1054    ButActuallyImplementedForTy {
1055        trait_path: Highlighted<'tcx, TraitRefPrintOnlyTraitPath<'tcx>>,
1056        has_lifetime: bool,
1057        lifetime: usize,
1058        ty: String,
1059    },
1060    #[note(
1061        "...but `{$ty}` actually implements `{$trait_path}`{$has_lifetime ->
1062            [true] , for some specific lifetime `'{$lifetime}`
1063            *[false] {\"\"}
1064        }"
1065    )]
1066    ButActuallyTyImplements {
1067        trait_path: Highlighted<'tcx, TraitRefPrintOnlyTraitPath<'tcx>>,
1068        has_lifetime: bool,
1069        lifetime: usize,
1070        ty: String,
1071    },
1072}
1073
1074pub(crate) enum ActualImplExpectedKind {
1075    Signature,
1076    Passive,
1077    Other,
1078}
1079
1080pub(crate) enum ActualImplExpectedLifetimeKind {
1081    Two,
1082    Any,
1083    Some,
1084    Nothing,
1085}
1086
1087impl<'tcx> ActualImplExplNotes<'tcx> {
1088    pub(crate) fn new_expected(
1089        kind: ActualImplExpectedKind,
1090        lt_kind: ActualImplExpectedLifetimeKind,
1091        leading_ellipsis: bool,
1092        ty_or_sig: TyOrSig<'tcx>,
1093        trait_path: Highlighted<'tcx, TraitRefPrintOnlyTraitPath<'tcx>>,
1094        lifetime_1: usize,
1095        lifetime_2: usize,
1096    ) -> Self {
1097        match (kind, lt_kind) {
1098            (ActualImplExpectedKind::Signature, ActualImplExpectedLifetimeKind::Two) => {
1099                Self::ExpectedSignatureTwo {
1100                    leading_ellipsis,
1101                    ty_or_sig,
1102                    trait_path,
1103                    lifetime_1,
1104                    lifetime_2,
1105                }
1106            }
1107            (ActualImplExpectedKind::Signature, ActualImplExpectedLifetimeKind::Any) => {
1108                Self::ExpectedSignatureAny { leading_ellipsis, ty_or_sig, trait_path, lifetime_1 }
1109            }
1110            (ActualImplExpectedKind::Signature, ActualImplExpectedLifetimeKind::Some) => {
1111                Self::ExpectedSignatureSome { leading_ellipsis, ty_or_sig, trait_path, lifetime_1 }
1112            }
1113            (ActualImplExpectedKind::Signature, ActualImplExpectedLifetimeKind::Nothing) => {
1114                Self::ExpectedSignatureNothing { leading_ellipsis, ty_or_sig, trait_path }
1115            }
1116            (ActualImplExpectedKind::Passive, ActualImplExpectedLifetimeKind::Two) => {
1117                Self::ExpectedPassiveTwo {
1118                    leading_ellipsis,
1119                    ty_or_sig,
1120                    trait_path,
1121                    lifetime_1,
1122                    lifetime_2,
1123                }
1124            }
1125            (ActualImplExpectedKind::Passive, ActualImplExpectedLifetimeKind::Any) => {
1126                Self::ExpectedPassiveAny { leading_ellipsis, ty_or_sig, trait_path, lifetime_1 }
1127            }
1128            (ActualImplExpectedKind::Passive, ActualImplExpectedLifetimeKind::Some) => {
1129                Self::ExpectedPassiveSome { leading_ellipsis, ty_or_sig, trait_path, lifetime_1 }
1130            }
1131            (ActualImplExpectedKind::Passive, ActualImplExpectedLifetimeKind::Nothing) => {
1132                Self::ExpectedPassiveNothing { leading_ellipsis, ty_or_sig, trait_path }
1133            }
1134            (ActualImplExpectedKind::Other, ActualImplExpectedLifetimeKind::Two) => {
1135                Self::ExpectedOtherTwo {
1136                    leading_ellipsis,
1137                    ty_or_sig,
1138                    trait_path,
1139                    lifetime_1,
1140                    lifetime_2,
1141                }
1142            }
1143            (ActualImplExpectedKind::Other, ActualImplExpectedLifetimeKind::Any) => {
1144                Self::ExpectedOtherAny { leading_ellipsis, ty_or_sig, trait_path, lifetime_1 }
1145            }
1146            (ActualImplExpectedKind::Other, ActualImplExpectedLifetimeKind::Some) => {
1147                Self::ExpectedOtherSome { leading_ellipsis, ty_or_sig, trait_path, lifetime_1 }
1148            }
1149            (ActualImplExpectedKind::Other, ActualImplExpectedLifetimeKind::Nothing) => {
1150                Self::ExpectedOtherNothing { leading_ellipsis, ty_or_sig, trait_path }
1151            }
1152        }
1153    }
1154}
1155
1156#[derive(const _: () =
    {
        impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
            TraitPlaceholderMismatch<'tcx> where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    TraitPlaceholderMismatch {
                        span: __binding_0,
                        satisfy_span: __binding_1,
                        where_span: __binding_2,
                        dup_span: __binding_3,
                        def_id: __binding_4,
                        trait_def_id: __binding_5,
                        actual_impl_expl_notes: __binding_6 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("implementation of `{$trait_def_id}` is not general enough")));
                        ;
                        diag.arg("def_id", __binding_4);
                        diag.arg("trait_def_id", __binding_5);
                        diag.span(__binding_0);
                        if let Some(__binding_1) = __binding_1 {
                            diag.span_label(__binding_1,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("doesn't satisfy where-clause")));
                        }
                        if let Some(__binding_2) = __binding_2 {
                            diag.span_label(__binding_2,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("due to a where-clause on `{$def_id}`...")));
                        }
                        if let Some(__binding_3) = __binding_3 {
                            diag.span_label(__binding_3,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("implementation of `{$trait_def_id}` is not general enough")));
                        }
                        for __binding_6 in __binding_6 {
                            diag.subdiagnostic(__binding_6);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1157#[diag("implementation of `{$trait_def_id}` is not general enough")]
1158pub(crate) struct TraitPlaceholderMismatch<'tcx> {
1159    #[primary_span]
1160    pub span: Span,
1161    #[label("doesn't satisfy where-clause")]
1162    pub satisfy_span: Option<Span>,
1163    #[label("due to a where-clause on `{$def_id}`...")]
1164    pub where_span: Option<Span>,
1165    #[label("implementation of `{$trait_def_id}` is not general enough")]
1166    pub dup_span: Option<Span>,
1167    pub def_id: String,
1168    pub trait_def_id: String,
1169
1170    #[subdiagnostic]
1171    pub actual_impl_expl_notes: Vec<ActualImplExplNotes<'tcx>>,
1172}
1173
1174pub(crate) struct ConsiderBorrowingParamHelp {
1175    pub spans: Vec<Span>,
1176}
1177
1178impl Subdiagnostic for ConsiderBorrowingParamHelp {
1179    fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
1180        let mut type_param_span: MultiSpan = self.spans.clone().into();
1181        for &span in &self.spans {
1182            // Seems like we can't call f() here as Into<DiagMessage> is required
1183            type_param_span
1184                .push_span_label(span, rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider borrowing this type parameter in the trait"))msg!("consider borrowing this type parameter in the trait"));
1185        }
1186        let msg = rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`"))msg!(
1187            "the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`"
1188        );
1189        diag.span_help(type_param_span, msg);
1190    }
1191}
1192
1193#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for TraitImplDiff
            where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    TraitImplDiff {
                        sp: __binding_0,
                        trait_sp: __binding_1,
                        note: __binding_2,
                        param_help: __binding_3,
                        rel_help: __binding_4,
                        expected: __binding_5,
                        found: __binding_6 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`impl` item signature doesn't match `trait` item signature")));
                        ;
                        diag.arg("expected", __binding_5);
                        diag.arg("found", __binding_6);
                        diag.span(__binding_0);
                        diag.span_label(__binding_0,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("found `{$found}`")));
                        diag.span_label(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected `{$expected}`")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected signature `{$expected}`\n        {\"   \"}found signature `{$found}`")));
                        diag.subdiagnostic(__binding_3);
                        if __binding_4 {
                            diag.help(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output")));
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1194#[diag("`impl` item signature doesn't match `trait` item signature")]
1195pub(crate) struct TraitImplDiff {
1196    #[primary_span]
1197    #[label("found `{$found}`")]
1198    pub sp: Span,
1199    #[label("expected `{$expected}`")]
1200    pub trait_sp: Span,
1201    #[note(
1202        "expected signature `{$expected}`
1203        {\"   \"}found signature `{$found}`"
1204    )]
1205    pub note: (),
1206    #[subdiagnostic]
1207    pub param_help: ConsiderBorrowingParamHelp,
1208    #[help(
1209        "verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output"
1210    )]
1211    pub rel_help: bool,
1212    pub expected: String,
1213    pub found: String,
1214}
1215
1216#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            ButNeedsToSatisfy where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    ButNeedsToSatisfy {
                        sp: __binding_0,
                        influencer_point: __binding_1,
                        spans: __binding_2,
                        require_span_as_label: __binding_3,
                        require_span_as_note: __binding_4,
                        bound: __binding_5,
                        has_param_name: __binding_6,
                        param_name: __binding_7,
                        spans_empty: __binding_8,
                        has_lifetime: __binding_9,
                        lifetime: __binding_10 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$has_param_name ->\n    [true] `{$param_name}`\n    *[false] `fn` parameter\n} has {$has_lifetime ->\n    [true] lifetime `{$lifetime}`\n    *[false] an anonymous lifetime `'_`\n} but it needs to satisfy a `'static` lifetime requirement")));
                        diag.code(E0759);
                        ;
                        diag.arg("has_param_name", __binding_6);
                        diag.arg("param_name", __binding_7);
                        diag.arg("spans_empty", __binding_8);
                        diag.arg("has_lifetime", __binding_9);
                        diag.arg("lifetime", __binding_10);
                        diag.span(__binding_0);
                        diag.span_label(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this data with {$has_lifetime ->\n        [true] lifetime `{$lifetime}`\n        *[false] an anonymous lifetime `'_`\n    }...")));
                        for __binding_2 in __binding_2 {
                            diag.span_label(__binding_2,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("...is used here...")));
                        }
                        if let Some(__binding_3) = __binding_3 {
                            diag.span_label(__binding_3,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$spans_empty ->\n        *[true] ...is used and required to live as long as `'static` here\n        [false] ...and is required to live as long as `'static` here\n    }")));
                        }
                        if let Some(__binding_4) = __binding_4 {
                            diag.span_note(__binding_4,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$spans_empty ->\n        *[true] ...is used and required to live as long as `'static` here\n        [false] ...and is required to live as long as `'static` here\n    }")));
                        }
                        if let Some(__binding_5) = __binding_5 {
                            diag.span_note(__binding_5,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`'static` lifetime requirement introduced by this bound")));
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1217#[diag("{$has_param_name ->
1218    [true] `{$param_name}`
1219    *[false] `fn` parameter
1220} has {$has_lifetime ->
1221    [true] lifetime `{$lifetime}`
1222    *[false] an anonymous lifetime `'_`
1223} but it needs to satisfy a `'static` lifetime requirement", code = E0759)]
1224pub(crate) struct ButNeedsToSatisfy {
1225    #[primary_span]
1226    pub sp: Span,
1227    #[label(
1228        "this data with {$has_lifetime ->
1229        [true] lifetime `{$lifetime}`
1230        *[false] an anonymous lifetime `'_`
1231    }..."
1232    )]
1233    pub influencer_point: Span,
1234    #[label("...is used here...")]
1235    pub spans: Vec<Span>,
1236    #[label(
1237        "{$spans_empty ->
1238        *[true] ...is used and required to live as long as `'static` here
1239        [false] ...and is required to live as long as `'static` here
1240    }"
1241    )]
1242    pub require_span_as_label: Option<Span>,
1243    #[note(
1244        "{$spans_empty ->
1245        *[true] ...is used and required to live as long as `'static` here
1246        [false] ...and is required to live as long as `'static` here
1247    }"
1248    )]
1249    pub require_span_as_note: Option<Span>,
1250    #[note("`'static` lifetime requirement introduced by this bound")]
1251    pub bound: Option<Span>,
1252
1253    pub has_param_name: bool,
1254    pub param_name: String,
1255    pub spans_empty: bool,
1256    pub has_lifetime: bool,
1257    pub lifetime: String,
1258}
1259
1260#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            OutlivesContent<'a> where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    OutlivesContent { span: __binding_0, notes: __binding_1 } =>
                        {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetime of reference outlives lifetime of borrowed content...")));
                        diag.code(E0312);
                        ;
                        diag.span(__binding_0);
                        for __binding_1 in __binding_1 {
                            diag.subdiagnostic(__binding_1);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1261#[diag("lifetime of reference outlives lifetime of borrowed content...", code = E0312)]
1262pub(crate) struct OutlivesContent<'a> {
1263    #[primary_span]
1264    pub span: Span,
1265    #[subdiagnostic]
1266    pub notes: Vec<note_and_explain::RegionExplanation<'a>>,
1267}
1268
1269#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            OutlivesBound<'a> where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    OutlivesBound { span: __binding_0, notes: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetime of the source pointer does not outlive lifetime bound of the object type")));
                        diag.code(E0476);
                        ;
                        diag.span(__binding_0);
                        for __binding_1 in __binding_1 {
                            diag.subdiagnostic(__binding_1);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1270#[diag("lifetime of the source pointer does not outlive lifetime bound of the object type", code = E0476)]
1271pub(crate) struct OutlivesBound<'a> {
1272    #[primary_span]
1273    pub span: Span,
1274    #[subdiagnostic]
1275    pub notes: Vec<note_and_explain::RegionExplanation<'a>>,
1276}
1277
1278#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            FulfillReqLifetime<'a> where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    FulfillReqLifetime {
                        span: __binding_0, ty: __binding_1, note: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the type `{$ty}` does not fulfill the required lifetime")));
                        diag.code(E0477);
                        ;
                        diag.arg("ty", __binding_1);
                        diag.span(__binding_0);
                        if let Some(__binding_2) = __binding_2 {
                            diag.subdiagnostic(__binding_2);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1279#[diag("the type `{$ty}` does not fulfill the required lifetime", code = E0477)]
1280pub(crate) struct FulfillReqLifetime<'a> {
1281    #[primary_span]
1282    pub span: Span,
1283    pub ty: Ty<'a>,
1284    #[subdiagnostic]
1285    pub note: Option<note_and_explain::RegionExplanation<'a>>,
1286}
1287
1288#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            LfBoundNotSatisfied<'a> where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    LfBoundNotSatisfied { span: __binding_0, notes: __binding_1
                        } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetime bound not satisfied")));
                        diag.code(E0478);
                        ;
                        diag.span(__binding_0);
                        for __binding_1 in __binding_1 {
                            diag.subdiagnostic(__binding_1);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1289#[diag("lifetime bound not satisfied", code = E0478)]
1290pub(crate) struct LfBoundNotSatisfied<'a> {
1291    #[primary_span]
1292    pub span: Span,
1293    #[subdiagnostic]
1294    pub notes: Vec<note_and_explain::RegionExplanation<'a>>,
1295}
1296
1297#[derive(const _: () =
    {
        impl<'_sess, 'a, G> rustc_errors::Diagnostic<'_sess, G> for
            RefLongerThanData<'a> where G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    RefLongerThanData {
                        span: __binding_0, ty: __binding_1, notes: __binding_2 } =>
                        {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("in type `{$ty}`, reference has a longer lifetime than the data it references")));
                        diag.code(E0491);
                        ;
                        diag.arg("ty", __binding_1);
                        diag.span(__binding_0);
                        for __binding_2 in __binding_2 {
                            diag.subdiagnostic(__binding_2);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1298#[diag("in type `{$ty}`, reference has a longer lifetime than the data it references", code = E0491)]
1299pub(crate) struct RefLongerThanData<'a> {
1300    #[primary_span]
1301    pub span: Span,
1302    pub ty: Ty<'a>,
1303    #[subdiagnostic]
1304    pub notes: Vec<note_and_explain::RegionExplanation<'a>>,
1305}
1306
1307#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for WhereClauseSuggestions {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    WhereClauseSuggestions::Remove { span: __binding_0 } => {
                        let __code_11 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!(""))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("remove the `where` clause")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_11, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                    WhereClauseSuggestions::CopyPredicates {
                        span: __binding_0,
                        space: __binding_1,
                        trait_predicates: __binding_2 } => {
                        let __code_12 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("{0}where {1}",
                                                        __binding_1, __binding_2))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("space".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        sub_args.insert("trait_predicates".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("copy the `where` clause predicates from the trait")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_12, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                }
            }
        }
    };Subdiagnostic)]
1308pub(crate) enum WhereClauseSuggestions {
1309    #[suggestion(
1310        "remove the `where` clause",
1311        code = "",
1312        applicability = "machine-applicable",
1313        style = "verbose"
1314    )]
1315    Remove {
1316        #[primary_span]
1317        span: Span,
1318    },
1319    #[suggestion(
1320        "copy the `where` clause predicates from the trait",
1321        code = "{space}where {trait_predicates}",
1322        applicability = "machine-applicable",
1323        style = "verbose"
1324    )]
1325    CopyPredicates {
1326        #[primary_span]
1327        span: Span,
1328        space: &'static str,
1329        trait_predicates: String,
1330    },
1331}
1332
1333#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for SuggestRemoveSemiOrReturnBinding
            {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    SuggestRemoveSemiOrReturnBinding::RemoveAndBox {
                        first_lo: __binding_0,
                        first_hi: __binding_1,
                        second_lo: __binding_2,
                        second_hi: __binding_3,
                        sp: __binding_4 } => {
                        let mut suggestions = Vec::new();
                        let __code_13 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("Box::new("))
                                });
                        let __code_14 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(")"))
                                });
                        let __code_15 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("Box::new("))
                                });
                        let __code_16 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(")"))
                                });
                        let __code_17 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(""))
                                });
                        suggestions.push((__binding_0, __code_13));
                        suggestions.push((__binding_1, __code_14));
                        suggestions.push((__binding_2, __code_15));
                        suggestions.push((__binding_3, __code_16));
                        suggestions.push((__binding_4, __code_17));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider removing this semicolon and boxing the expressions")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                    SuggestRemoveSemiOrReturnBinding::Remove { sp: __binding_0 }
                        => {
                        let __code_18 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!(""))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider removing this semicolon")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_18, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::HideCodeInline);
                    }
                    SuggestRemoveSemiOrReturnBinding::Add {
                        sp: __binding_0, code: __binding_1, ident: __binding_2 } =>
                        {
                        let __code_19 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("{0}", __binding_1))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("code".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        sub_args.insert("ident".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider returning the local binding `{$ident}`")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_19, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                    SuggestRemoveSemiOrReturnBinding::AddOne {
                        spans: __binding_0 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider returning one of these bindings")),
                                &sub_args);
                        diag.span_note(__binding_0, __message);
                    }
                }
            }
        }
    };Subdiagnostic)]
1334pub(crate) enum SuggestRemoveSemiOrReturnBinding {
1335    #[multipart_suggestion(
1336        "consider removing this semicolon and boxing the expressions",
1337        applicability = "machine-applicable"
1338    )]
1339    RemoveAndBox {
1340        #[suggestion_part(code = "Box::new(")]
1341        first_lo: Span,
1342        #[suggestion_part(code = ")")]
1343        first_hi: Span,
1344        #[suggestion_part(code = "Box::new(")]
1345        second_lo: Span,
1346        #[suggestion_part(code = ")")]
1347        second_hi: Span,
1348        #[suggestion_part(code = "")]
1349        sp: Span,
1350    },
1351    #[suggestion(
1352        "consider removing this semicolon",
1353        style = "short",
1354        code = "",
1355        applicability = "machine-applicable"
1356    )]
1357    Remove {
1358        #[primary_span]
1359        sp: Span,
1360    },
1361    #[suggestion(
1362        "consider returning the local binding `{$ident}`",
1363        style = "verbose",
1364        code = "{code}",
1365        applicability = "maybe-incorrect"
1366    )]
1367    Add {
1368        #[primary_span]
1369        sp: Span,
1370        code: String,
1371        ident: Ident,
1372    },
1373    #[note("consider returning one of these bindings")]
1374    AddOne {
1375        #[primary_span]
1376        spans: MultiSpan,
1377    },
1378}
1379
1380#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for ConsiderAddingAwait {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    ConsiderAddingAwait::BothFuturesHelp => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider `await`ing on both `Future`s")),
                                &sub_args);
                        diag.help(__message);
                    }
                    ConsiderAddingAwait::BothFuturesSugg {
                        first: __binding_0, second: __binding_1 } => {
                        let mut suggestions = Vec::new();
                        let __code_20 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(".await"))
                                });
                        let __code_21 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(".await"))
                                });
                        suggestions.push((__binding_0, __code_20));
                        suggestions.push((__binding_1, __code_21));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider `await`ing on both `Future`s")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                    ConsiderAddingAwait::FutureSugg { span: __binding_0 } => {
                        let __code_22 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!(".await"))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider `await`ing on the `Future`")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_22, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                    ConsiderAddingAwait::FutureSuggNote { span: __binding_0 } =>
                        {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("calling an async function returns a future")),
                                &sub_args);
                        diag.span_note(__binding_0, __message);
                    }
                    ConsiderAddingAwait::FutureSuggMultiple { spans: __binding_0
                        } => {
                        let mut suggestions = Vec::new();
                        let __code_23 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(".await"))
                                });
                        for __binding_0 in __binding_0 {
                            suggestions.push((__binding_0, __code_23.clone()));
                        }
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider `await`ing on the `Future`")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                }
            }
        }
    };Subdiagnostic)]
1381pub(crate) enum ConsiderAddingAwait {
1382    #[help("consider `await`ing on both `Future`s")]
1383    BothFuturesHelp,
1384    #[multipart_suggestion(
1385        "consider `await`ing on both `Future`s",
1386        applicability = "maybe-incorrect"
1387    )]
1388    BothFuturesSugg {
1389        #[suggestion_part(code = ".await")]
1390        first: Span,
1391        #[suggestion_part(code = ".await")]
1392        second: Span,
1393    },
1394    #[suggestion(
1395        "consider `await`ing on the `Future`",
1396        code = ".await",
1397        style = "verbose",
1398        applicability = "maybe-incorrect"
1399    )]
1400    FutureSugg {
1401        #[primary_span]
1402        span: Span,
1403    },
1404    #[note("calling an async function returns a future")]
1405    FutureSuggNote {
1406        #[primary_span]
1407        span: Span,
1408    },
1409    #[multipart_suggestion(
1410        "consider `await`ing on the `Future`",
1411        style = "verbose",
1412        applicability = "maybe-incorrect"
1413    )]
1414    FutureSuggMultiple {
1415        #[suggestion_part(code = ".await")]
1416        spans: Vec<Span>,
1417    },
1418}
1419
1420#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            PlaceholderRelationLfNotSatisfied where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    PlaceholderRelationLfNotSatisfied::HasBoth {
                        span: __binding_0,
                        sub_span: __binding_1,
                        sup_span: __binding_2,
                        sub_symbol: __binding_3,
                        sup_symbol: __binding_4,
                        note: __binding_5 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetime bound not satisfied")));
                        ;
                        diag.arg("sub_symbol", __binding_3);
                        diag.arg("sup_symbol", __binding_4);
                        diag.span(__binding_0);
                        diag.span_note(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the lifetime `{$sub_symbol}` defined here...")));
                        diag.span_note(__binding_2,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("...must outlive the lifetime `{$sup_symbol}` defined here")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this is a known limitation that will be removed in the future (see issue #100013 <https://github.com/rust-lang/rust/issues/100013> for more information)")));
                        diag
                    }
                    PlaceholderRelationLfNotSatisfied::HasSub {
                        span: __binding_0,
                        sub_span: __binding_1,
                        sup_span: __binding_2,
                        sub_symbol: __binding_3,
                        note: __binding_4 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetime bound not satisfied")));
                        ;
                        diag.arg("sub_symbol", __binding_3);
                        diag.span(__binding_0);
                        diag.span_note(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the lifetime `{$sub_symbol}` defined here...")));
                        diag.span_note(__binding_2,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("...must outlive the lifetime defined here")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this is a known limitation that will be removed in the future (see issue #100013 <https://github.com/rust-lang/rust/issues/100013> for more information)")));
                        diag
                    }
                    PlaceholderRelationLfNotSatisfied::HasSup {
                        span: __binding_0,
                        sub_span: __binding_1,
                        sup_span: __binding_2,
                        sup_symbol: __binding_3,
                        note: __binding_4 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetime bound not satisfied")));
                        ;
                        diag.arg("sup_symbol", __binding_3);
                        diag.span(__binding_0);
                        diag.span_note(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the lifetime defined here...")));
                        diag.span_note(__binding_2,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("...must outlive the lifetime `{$sup_symbol}` defined here")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this is a known limitation that will be removed in the future (see issue #100013 <https://github.com/rust-lang/rust/issues/100013> for more information)")));
                        diag
                    }
                    PlaceholderRelationLfNotSatisfied::HasNone {
                        span: __binding_0,
                        sub_span: __binding_1,
                        sup_span: __binding_2,
                        note: __binding_3 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetime bound not satisfied")));
                        ;
                        diag.span(__binding_0);
                        diag.span_note(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("the lifetime defined here...")));
                        diag.span_note(__binding_2,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("...must outlive the lifetime defined here")));
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this is a known limitation that will be removed in the future (see issue #100013 <https://github.com/rust-lang/rust/issues/100013> for more information)")));
                        diag
                    }
                    PlaceholderRelationLfNotSatisfied::OnlyPrimarySpan {
                        span: __binding_0, note: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("lifetime bound not satisfied")));
                        ;
                        diag.span(__binding_0);
                        diag.note(rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("this is a known limitation that will be removed in the future (see issue #100013 <https://github.com/rust-lang/rust/issues/100013> for more information)")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1421pub(crate) enum PlaceholderRelationLfNotSatisfied {
1422    #[diag("lifetime bound not satisfied")]
1423    HasBoth {
1424        #[primary_span]
1425        span: Span,
1426        #[note("the lifetime `{$sub_symbol}` defined here...")]
1427        sub_span: Span,
1428        #[note("...must outlive the lifetime `{$sup_symbol}` defined here")]
1429        sup_span: Span,
1430        sub_symbol: Symbol,
1431        sup_symbol: Symbol,
1432        #[note(
1433            "this is a known limitation that will be removed in the future (see issue #100013 <https://github.com/rust-lang/rust/issues/100013> for more information)"
1434        )]
1435        note: (),
1436    },
1437    #[diag("lifetime bound not satisfied")]
1438    HasSub {
1439        #[primary_span]
1440        span: Span,
1441        #[note("the lifetime `{$sub_symbol}` defined here...")]
1442        sub_span: Span,
1443        #[note("...must outlive the lifetime defined here")]
1444        sup_span: Span,
1445        sub_symbol: Symbol,
1446        #[note(
1447            "this is a known limitation that will be removed in the future (see issue #100013 <https://github.com/rust-lang/rust/issues/100013> for more information)"
1448        )]
1449        note: (),
1450    },
1451    #[diag("lifetime bound not satisfied")]
1452    HasSup {
1453        #[primary_span]
1454        span: Span,
1455        #[note("the lifetime defined here...")]
1456        sub_span: Span,
1457        #[note("...must outlive the lifetime `{$sup_symbol}` defined here")]
1458        sup_span: Span,
1459        sup_symbol: Symbol,
1460        #[note(
1461            "this is a known limitation that will be removed in the future (see issue #100013 <https://github.com/rust-lang/rust/issues/100013> for more information)"
1462        )]
1463        note: (),
1464    },
1465    #[diag("lifetime bound not satisfied")]
1466    HasNone {
1467        #[primary_span]
1468        span: Span,
1469        #[note("the lifetime defined here...")]
1470        sub_span: Span,
1471        #[note("...must outlive the lifetime defined here")]
1472        sup_span: Span,
1473        #[note(
1474            "this is a known limitation that will be removed in the future (see issue #100013 <https://github.com/rust-lang/rust/issues/100013> for more information)"
1475        )]
1476        note: (),
1477    },
1478    #[diag("lifetime bound not satisfied")]
1479    OnlyPrimarySpan {
1480        #[primary_span]
1481        span: Span,
1482        #[note(
1483            "this is a known limitation that will be removed in the future (see issue #100013 <https://github.com/rust-lang/rust/issues/100013> for more information)"
1484        )]
1485        note: (),
1486    },
1487}
1488
1489#[derive(const _: () =
    {
        impl<'_sess, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
            OpaqueCapturesLifetime<'tcx> where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    OpaqueCapturesLifetime {
                        span: __binding_0,
                        opaque_ty_span: __binding_1,
                        opaque_ty: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("hidden type for `{$opaque_ty}` captures lifetime that does not appear in bounds")));
                        diag.code(E0700);
                        ;
                        diag.arg("opaque_ty", __binding_2);
                        diag.span(__binding_0);
                        diag.span_label(__binding_1,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("opaque type defined here")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1490#[diag("hidden type for `{$opaque_ty}` captures lifetime that does not appear in bounds", code = E0700)]
1491pub(crate) struct OpaqueCapturesLifetime<'tcx> {
1492    #[primary_span]
1493    pub span: Span,
1494    #[label("opaque type defined here")]
1495    pub opaque_ty_span: Span,
1496    pub opaque_ty: Ty<'tcx>,
1497}
1498
1499#[derive(const _: () =
    {
        impl<'a> rustc_errors::Subdiagnostic for FunctionPointerSuggestion<'a>
            {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    FunctionPointerSuggestion::UseRef { span: __binding_0 } => {
                        let __code_24 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("&"))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider using a reference")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_24, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                    FunctionPointerSuggestion::RemoveRef {
                        span: __binding_0, fn_name: __binding_1 } => {
                        let __code_25 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("{0}", __binding_1))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("fn_name".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider removing the reference")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_25, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                    FunctionPointerSuggestion::CastRef {
                        span: __binding_0, fn_name: __binding_1, sig: __binding_2 }
                        => {
                        let __code_26 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("&({0} as {1})",
                                                        __binding_1, __binding_2))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("fn_name".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        sub_args.insert("sig".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider casting to a fn pointer")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_26, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                    FunctionPointerSuggestion::Cast {
                        span: __binding_0, sig: __binding_1 } => {
                        let __code_27 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!(" as {0}", __binding_1))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("sig".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider casting to a fn pointer")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_27, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                    FunctionPointerSuggestion::CastBoth {
                        span: __binding_0,
                        found_sig: __binding_1,
                        expected_sig: __binding_2 } => {
                        let __code_28 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!(" as {0}", __binding_1))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("found_sig".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        sub_args.insert("expected_sig".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider casting both fn items to fn pointers using `as {$expected_sig}`")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_28, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::HideCodeAlways);
                    }
                    FunctionPointerSuggestion::CastBothRef {
                        span: __binding_0,
                        fn_name: __binding_1,
                        found_sig: __binding_2,
                        expected_sig: __binding_3 } => {
                        let __code_29 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("&({0} as {1})",
                                                        __binding_1, __binding_2))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("fn_name".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        sub_args.insert("found_sig".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        sub_args.insert("expected_sig".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider casting both fn items to fn pointers using `as {$expected_sig}`")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_29, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::HideCodeAlways);
                    }
                }
            }
        }
    };Subdiagnostic)]
1500pub(crate) enum FunctionPointerSuggestion<'a> {
1501    #[suggestion(
1502        "consider using a reference",
1503        code = "&",
1504        style = "verbose",
1505        applicability = "maybe-incorrect"
1506    )]
1507    UseRef {
1508        #[primary_span]
1509        span: Span,
1510    },
1511    #[suggestion(
1512        "consider removing the reference",
1513        code = "{fn_name}",
1514        style = "verbose",
1515        applicability = "maybe-incorrect"
1516    )]
1517    RemoveRef {
1518        #[primary_span]
1519        span: Span,
1520        fn_name: String,
1521    },
1522    #[suggestion(
1523        "consider casting to a fn pointer",
1524        code = "&({fn_name} as {sig})",
1525        style = "verbose",
1526        applicability = "maybe-incorrect"
1527    )]
1528    CastRef {
1529        #[primary_span]
1530        span: Span,
1531        fn_name: String,
1532        sig: Binder<'a, FnSig<'a>>,
1533    },
1534    #[suggestion(
1535        "consider casting to a fn pointer",
1536        code = " as {sig}",
1537        style = "verbose",
1538        applicability = "maybe-incorrect"
1539    )]
1540    Cast {
1541        #[primary_span]
1542        span: Span,
1543        sig: Binder<'a, FnSig<'a>>,
1544    },
1545    #[suggestion(
1546        "consider casting both fn items to fn pointers using `as {$expected_sig}`",
1547        code = " as {found_sig}",
1548        style = "hidden",
1549        applicability = "maybe-incorrect"
1550    )]
1551    CastBoth {
1552        #[primary_span]
1553        span: Span,
1554        found_sig: Binder<'a, FnSig<'a>>,
1555        expected_sig: Binder<'a, FnSig<'a>>,
1556    },
1557    #[suggestion(
1558        "consider casting both fn items to fn pointers using `as {$expected_sig}`",
1559        code = "&({fn_name} as {found_sig})",
1560        style = "hidden",
1561        applicability = "maybe-incorrect"
1562    )]
1563    CastBothRef {
1564        #[primary_span]
1565        span: Span,
1566        fn_name: String,
1567        found_sig: Binder<'a, FnSig<'a>>,
1568        expected_sig: Binder<'a, FnSig<'a>>,
1569    },
1570}
1571
1572#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for FnItemsAreDistinct {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    FnItemsAreDistinct => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("fn items are distinct from fn pointers")),
                                &sub_args);
                        diag.note(__message);
                    }
                }
            }
        }
    };Subdiagnostic)]
1573#[note("fn items are distinct from fn pointers")]
1574pub(crate) struct FnItemsAreDistinct;
1575
1576#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for FnUniqTypes {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    FnUniqTypes => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("different fn items have unique types, even if their signatures are the same")),
                                &sub_args);
                        diag.note(__message);
                    }
                }
            }
        }
    };Subdiagnostic)]
1577#[note("different fn items have unique types, even if their signatures are the same")]
1578pub(crate) struct FnUniqTypes;
1579
1580#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for FnConsiderCasting {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    FnConsiderCasting { casting: __binding_0 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("casting".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider casting the fn item to a fn pointer: `{$casting}`")),
                                &sub_args);
                        diag.help(__message);
                    }
                }
            }
        }
    };Subdiagnostic)]
1581#[help("consider casting the fn item to a fn pointer: `{$casting}`")]
1582pub(crate) struct FnConsiderCasting {
1583    pub casting: String,
1584}
1585
1586#[derive(const _: () =
    {
        impl<'a> rustc_errors::Subdiagnostic for FnConsiderCastingBoth<'a> {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    FnConsiderCastingBoth { sig: __binding_0 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("sig".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider casting both fn items to fn pointers using `as {$sig}`")),
                                &sub_args);
                        diag.help(__message);
                    }
                }
            }
        }
    };Subdiagnostic)]
1587#[help("consider casting both fn items to fn pointers using `as {$sig}`")]
1588pub(crate) struct FnConsiderCastingBoth<'a> {
1589    pub sig: Binder<'a, FnSig<'a>>,
1590}
1591
1592#[derive(const _: () =
    {
        impl<'a> rustc_errors::Subdiagnostic for SuggestAccessingField<'a> {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    SuggestAccessingField::Safe {
                        span: __binding_0,
                        snippet: __binding_1,
                        name: __binding_2,
                        ty: __binding_3 } => {
                        let __code_30 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("{1}.{0}", __binding_2,
                                                        __binding_1))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("snippet".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        sub_args.insert("name".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        sub_args.insert("ty".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you might have meant to use field `{$name}` whose type is `{$ty}`")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_30, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                    SuggestAccessingField::Unsafe {
                        span: __binding_0,
                        snippet: __binding_1,
                        name: __binding_2,
                        ty: __binding_3 } => {
                        let __code_31 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("unsafe {{ {1}.{0} }}",
                                                        __binding_2, __binding_1))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("snippet".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        sub_args.insert("name".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        sub_args.insert("ty".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you might have meant to use field `{$name}` whose type is `{$ty}`")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_31, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                }
            }
        }
    };Subdiagnostic)]
1593pub(crate) enum SuggestAccessingField<'a> {
1594    #[suggestion(
1595        "you might have meant to use field `{$name}` whose type is `{$ty}`",
1596        code = "{snippet}.{name}",
1597        applicability = "maybe-incorrect",
1598        style = "verbose"
1599    )]
1600    Safe {
1601        #[primary_span]
1602        span: Span,
1603        snippet: String,
1604        name: Symbol,
1605        ty: Ty<'a>,
1606    },
1607    #[suggestion(
1608        "you might have meant to use field `{$name}` whose type is `{$ty}`",
1609        code = "unsafe {{ {snippet}.{name} }}",
1610        applicability = "maybe-incorrect",
1611        style = "verbose"
1612    )]
1613    Unsafe {
1614        #[primary_span]
1615        span: Span,
1616        snippet: String,
1617        name: Symbol,
1618        ty: Ty<'a>,
1619    },
1620}
1621
1622#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for SuggestTuplePatternOne {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    SuggestTuplePatternOne {
                        variant: __binding_0,
                        span_low: __binding_1,
                        span_high: __binding_2 } => {
                        let mut suggestions = Vec::new();
                        let __code_32 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("{0}(", __binding_0))
                                });
                        let __code_33 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(")"))
                                });
                        suggestions.push((__binding_1, __code_32));
                        suggestions.push((__binding_2, __code_33));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("variant".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try wrapping the pattern in `{$variant}`")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                }
            }
        }
    };Subdiagnostic)]
1623#[multipart_suggestion(
1624    "try wrapping the pattern in `{$variant}`",
1625    applicability = "maybe-incorrect"
1626)]
1627pub(crate) struct SuggestTuplePatternOne {
1628    pub variant: String,
1629    #[suggestion_part(code = "{variant}(")]
1630    pub span_low: Span,
1631    #[suggestion_part(code = ")")]
1632    pub span_high: Span,
1633}
1634
1635pub(crate) struct SuggestTuplePatternMany {
1636    pub path: String,
1637    pub cause_span: Span,
1638    pub compatible_variants: Vec<String>,
1639}
1640
1641impl Subdiagnostic for SuggestTuplePatternMany {
1642    fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
1643        diag.arg("path", self.path);
1644        let message = rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("try wrapping the pattern in a variant of `{$path}`"))msg!("try wrapping the pattern in a variant of `{$path}`");
1645        diag.multipart_suggestions(
1646            message,
1647            self.compatible_variants.into_iter().map(|variant| {
1648                ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
        [(self.cause_span.shrink_to_lo(),
                    ::alloc::__export::must_use({
                            ::alloc::fmt::format(format_args!("{0}(", variant))
                        })), (self.cause_span.shrink_to_hi(), ")".to_string())]))vec![
1649                    (self.cause_span.shrink_to_lo(), format!("{variant}(")),
1650                    (self.cause_span.shrink_to_hi(), ")".to_string()),
1651                ]
1652            }),
1653            rustc_errors::Applicability::MaybeIncorrect,
1654        );
1655    }
1656}
1657
1658#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for TypeErrorAdditionalDiags {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    TypeErrorAdditionalDiags::MeantByteLiteral {
                        span: __binding_0, code: __binding_1 } => {
                        let __code_34 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("b\'{0}\'", __binding_1))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("code".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if you meant to write a byte literal, prefix with `b`")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_34, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                    TypeErrorAdditionalDiags::MeantCharLiteral {
                        span: __binding_0, code: __binding_1 } => {
                        let __code_35 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("\'{0}\'", __binding_1))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("code".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if you meant to write a `char` literal, use single quotes")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_35, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                    TypeErrorAdditionalDiags::MeantStrLiteral {
                        start: __binding_0, end: __binding_1 } => {
                        let mut suggestions = Vec::new();
                        let __code_36 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("\""))
                                });
                        let __code_37 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("\""))
                                });
                        suggestions.push((__binding_0, __code_36));
                        suggestions.push((__binding_1, __code_37));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("if you meant to write a string literal, use double quotes")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                    TypeErrorAdditionalDiags::ConsiderSpecifyingLength {
                        span: __binding_0, length: __binding_1 } => {
                        let __code_38 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("{0}", __binding_1))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("length".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider specifying the actual array length")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_38, rustc_errors::Applicability::MaybeIncorrect,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                    TypeErrorAdditionalDiags::TryCannotConvert {
                        found: __binding_0, expected: __binding_1 } => {
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("found".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_0,
                                &mut diag.long_ty_path));
                        sub_args.insert("expected".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`?` operator cannot convert from `{$found}` to `{$expected}`")),
                                &sub_args);
                        diag.note(__message);
                    }
                    TypeErrorAdditionalDiags::TupleOnlyComma { span: __binding_0
                        } => {
                        let __code_39 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!(","))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use a trailing comma to create a tuple with one element")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_39, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                    TypeErrorAdditionalDiags::TupleAlsoParentheses {
                        span_low: __binding_0, span_high: __binding_1 } => {
                        let mut suggestions = Vec::new();
                        let __code_40 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!("("))
                                });
                        let __code_41 =
                            ::alloc::__export::must_use({
                                    ::alloc::fmt::format(format_args!(",)"))
                                });
                        suggestions.push((__binding_0, __code_40));
                        suggestions.push((__binding_1, __code_41));
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use a trailing comma to create a tuple with one element")),
                                &sub_args);
                        diag.multipart_suggestion_with_style(__message, suggestions,
                            rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowCode);
                    }
                    TypeErrorAdditionalDiags::AddLetForLetChains {
                        span: __binding_0 } => {
                        let __code_42 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("let "))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("consider adding `let`")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_42, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                }
            }
        }
    };Subdiagnostic)]
1659pub enum TypeErrorAdditionalDiags {
1660    #[suggestion(
1661        "if you meant to write a byte literal, prefix with `b`",
1662        code = "b'{code}'",
1663        applicability = "machine-applicable",
1664        style = "verbose"
1665    )]
1666    MeantByteLiteral {
1667        #[primary_span]
1668        span: Span,
1669        code: String,
1670    },
1671    #[suggestion(
1672        "if you meant to write a `char` literal, use single quotes",
1673        code = "'{code}'",
1674        applicability = "machine-applicable",
1675        style = "verbose"
1676    )]
1677    MeantCharLiteral {
1678        #[primary_span]
1679        span: Span,
1680        code: String,
1681    },
1682    #[multipart_suggestion(
1683        "if you meant to write a string literal, use double quotes",
1684        applicability = "machine-applicable"
1685    )]
1686    MeantStrLiteral {
1687        #[suggestion_part(code = "\"")]
1688        start: Span,
1689        #[suggestion_part(code = "\"")]
1690        end: Span,
1691    },
1692    #[suggestion(
1693        "consider specifying the actual array length",
1694        code = "{length}",
1695        applicability = "maybe-incorrect",
1696        style = "verbose"
1697    )]
1698    ConsiderSpecifyingLength {
1699        #[primary_span]
1700        span: Span,
1701        length: u64,
1702    },
1703    #[note("`?` operator cannot convert from `{$found}` to `{$expected}`")]
1704    TryCannotConvert { found: String, expected: String },
1705    #[suggestion(
1706        "use a trailing comma to create a tuple with one element",
1707        code = ",",
1708        applicability = "machine-applicable"
1709    )]
1710    TupleOnlyComma {
1711        #[primary_span]
1712        span: Span,
1713    },
1714    #[multipart_suggestion(
1715        "use a trailing comma to create a tuple with one element",
1716        applicability = "machine-applicable"
1717    )]
1718    TupleAlsoParentheses {
1719        #[suggestion_part(code = "(")]
1720        span_low: Span,
1721        #[suggestion_part(code = ",)")]
1722        span_high: Span,
1723    },
1724    #[suggestion(
1725        "consider adding `let`",
1726        style = "verbose",
1727        applicability = "machine-applicable",
1728        code = "let "
1729    )]
1730    AddLetForLetChains {
1731        #[primary_span]
1732        span: Span,
1733    },
1734}
1735
1736#[derive(const _: () =
    {
        impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for
            ObligationCauseFailureCode where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    ObligationCauseFailureCode::MethodCompat {
                        span: __binding_0, subdiags: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("method not compatible with trait")));
                        diag.code(E0308);
                        ;
                        diag.span(__binding_0);
                        for __binding_1 in __binding_1 {
                            diag.subdiagnostic(__binding_1);
                        }
                        diag
                    }
                    ObligationCauseFailureCode::TypeCompat {
                        span: __binding_0, subdiags: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("type not compatible with trait")));
                        diag.code(E0308);
                        ;
                        diag.span(__binding_0);
                        for __binding_1 in __binding_1 {
                            diag.subdiagnostic(__binding_1);
                        }
                        diag
                    }
                    ObligationCauseFailureCode::ConstCompat {
                        span: __binding_0, subdiags: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("const not compatible with trait")));
                        diag.code(E0308);
                        ;
                        diag.span(__binding_0);
                        for __binding_1 in __binding_1 {
                            diag.subdiagnostic(__binding_1);
                        }
                        diag
                    }
                    ObligationCauseFailureCode::TryCompat {
                        span: __binding_0, subdiags: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`?` operator has incompatible types")));
                        diag.code(E0308);
                        ;
                        diag.span(__binding_0);
                        for __binding_1 in __binding_1 {
                            diag.subdiagnostic(__binding_1);
                        }
                        diag
                    }
                    ObligationCauseFailureCode::MatchCompat {
                        span: __binding_0, subdiags: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`match` arms have incompatible types")));
                        diag.code(E0308);
                        ;
                        diag.span(__binding_0);
                        for __binding_1 in __binding_1 {
                            diag.subdiagnostic(__binding_1);
                        }
                        diag
                    }
                    ObligationCauseFailureCode::IfElseDifferent {
                        span: __binding_0, subdiags: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`if` and `else` have incompatible types")));
                        diag.code(E0308);
                        ;
                        diag.span(__binding_0);
                        for __binding_1 in __binding_1 {
                            diag.subdiagnostic(__binding_1);
                        }
                        diag
                    }
                    ObligationCauseFailureCode::NoElse { span: __binding_0 } =>
                        {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`if` may be missing an `else` clause")));
                        diag.code(E0317);
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                    ObligationCauseFailureCode::NoDiverge {
                        span: __binding_0, subdiags: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`else` clause of `let...else` does not diverge")));
                        diag.code(E0308);
                        ;
                        diag.span(__binding_0);
                        for __binding_1 in __binding_1 {
                            diag.subdiagnostic(__binding_1);
                        }
                        diag
                    }
                    ObligationCauseFailureCode::FnMainCorrectType {
                        span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("`main` function has wrong type")));
                        diag.code(E0580);
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                    ObligationCauseFailureCode::FnLangCorrectType {
                        span: __binding_0,
                        subdiags: __binding_1,
                        lang_item_name: __binding_2 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{$lang_item_name ->\n            [panic_impl] `#[panic_handler]`\n            *[lang_item_name] lang item `{$lang_item_name}`\n        } function has wrong type")));
                        diag.code(E0308);
                        ;
                        diag.arg("lang_item_name", __binding_2);
                        diag.span(__binding_0);
                        for __binding_1 in __binding_1 {
                            diag.subdiagnostic(__binding_1);
                        }
                        diag
                    }
                    ObligationCauseFailureCode::IntrinsicCorrectType {
                        span: __binding_0, subdiags: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("intrinsic has wrong type")));
                        diag.code(E0308);
                        ;
                        diag.span(__binding_0);
                        for __binding_1 in __binding_1 {
                            diag.subdiagnostic(__binding_1);
                        }
                        diag
                    }
                    ObligationCauseFailureCode::MethodCorrectType {
                        span: __binding_0, subdiags: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("mismatched `self` parameter type")));
                        diag.code(E0308);
                        ;
                        diag.span(__binding_0);
                        for __binding_1 in __binding_1 {
                            diag.subdiagnostic(__binding_1);
                        }
                        diag
                    }
                    ObligationCauseFailureCode::ClosureSelfref {
                        span: __binding_0 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("closure/coroutine type that references itself")));
                        diag.code(E0644);
                        ;
                        diag.span(__binding_0);
                        diag
                    }
                    ObligationCauseFailureCode::CantCoerceForceInline {
                        span: __binding_0, subdiags: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot coerce functions which must be inlined to function pointers")));
                        diag.code(E0308);
                        ;
                        diag.span(__binding_0);
                        for __binding_1 in __binding_1 {
                            diag.subdiagnostic(__binding_1);
                        }
                        diag
                    }
                    ObligationCauseFailureCode::CantCoerceIntrinsic {
                        span: __binding_0, subdiags: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("cannot coerce intrinsics to function pointers")));
                        diag.code(E0308);
                        ;
                        diag.span(__binding_0);
                        for __binding_1 in __binding_1 {
                            diag.subdiagnostic(__binding_1);
                        }
                        diag
                    }
                    ObligationCauseFailureCode::Generic {
                        span: __binding_0, subdiags: __binding_1 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("mismatched types")));
                        diag.code(E0308);
                        ;
                        diag.span(__binding_0);
                        for __binding_1 in __binding_1 {
                            diag.subdiagnostic(__binding_1);
                        }
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
1737pub enum ObligationCauseFailureCode {
1738    #[diag("method not compatible with trait", code = E0308)]
1739    MethodCompat {
1740        #[primary_span]
1741        span: Span,
1742        #[subdiagnostic]
1743        subdiags: Vec<TypeErrorAdditionalDiags>,
1744    },
1745    #[diag("type not compatible with trait", code = E0308)]
1746    TypeCompat {
1747        #[primary_span]
1748        span: Span,
1749        #[subdiagnostic]
1750        subdiags: Vec<TypeErrorAdditionalDiags>,
1751    },
1752    #[diag("const not compatible with trait", code = E0308)]
1753    ConstCompat {
1754        #[primary_span]
1755        span: Span,
1756        #[subdiagnostic]
1757        subdiags: Vec<TypeErrorAdditionalDiags>,
1758    },
1759    #[diag("`?` operator has incompatible types", code = E0308)]
1760    TryCompat {
1761        #[primary_span]
1762        span: Span,
1763        #[subdiagnostic]
1764        subdiags: Vec<TypeErrorAdditionalDiags>,
1765    },
1766    #[diag("`match` arms have incompatible types", code = E0308)]
1767    MatchCompat {
1768        #[primary_span]
1769        span: Span,
1770        #[subdiagnostic]
1771        subdiags: Vec<TypeErrorAdditionalDiags>,
1772    },
1773    #[diag("`if` and `else` have incompatible types", code = E0308)]
1774    IfElseDifferent {
1775        #[primary_span]
1776        span: Span,
1777        #[subdiagnostic]
1778        subdiags: Vec<TypeErrorAdditionalDiags>,
1779    },
1780    #[diag("`if` may be missing an `else` clause", code = E0317)]
1781    NoElse {
1782        #[primary_span]
1783        span: Span,
1784    },
1785    #[diag("`else` clause of `let...else` does not diverge", code = E0308)]
1786    NoDiverge {
1787        #[primary_span]
1788        span: Span,
1789        #[subdiagnostic]
1790        subdiags: Vec<TypeErrorAdditionalDiags>,
1791    },
1792    #[diag("`main` function has wrong type", code = E0580)]
1793    FnMainCorrectType {
1794        #[primary_span]
1795        span: Span,
1796    },
1797    #[diag(
1798        "{$lang_item_name ->
1799            [panic_impl] `#[panic_handler]`
1800            *[lang_item_name] lang item `{$lang_item_name}`
1801        } function has wrong type"
1802    , code = E0308)]
1803    FnLangCorrectType {
1804        #[primary_span]
1805        span: Span,
1806        #[subdiagnostic]
1807        subdiags: Vec<TypeErrorAdditionalDiags>,
1808        lang_item_name: Symbol,
1809    },
1810    #[diag("intrinsic has wrong type", code = E0308)]
1811    IntrinsicCorrectType {
1812        #[primary_span]
1813        span: Span,
1814        #[subdiagnostic]
1815        subdiags: Vec<TypeErrorAdditionalDiags>,
1816    },
1817    #[diag("mismatched `self` parameter type", code = E0308)]
1818    MethodCorrectType {
1819        #[primary_span]
1820        span: Span,
1821        #[subdiagnostic]
1822        subdiags: Vec<TypeErrorAdditionalDiags>,
1823    },
1824    #[diag("closure/coroutine type that references itself", code = E0644)]
1825    ClosureSelfref {
1826        #[primary_span]
1827        span: Span,
1828    },
1829    #[diag("cannot coerce functions which must be inlined to function pointers", code = E0308)]
1830    CantCoerceForceInline {
1831        #[primary_span]
1832        span: Span,
1833        #[subdiagnostic]
1834        subdiags: Vec<TypeErrorAdditionalDiags>,
1835    },
1836    #[diag("cannot coerce intrinsics to function pointers", code = E0308)]
1837    CantCoerceIntrinsic {
1838        #[primary_span]
1839        span: Span,
1840        #[subdiagnostic]
1841        subdiags: Vec<TypeErrorAdditionalDiags>,
1842    },
1843    #[diag("mismatched types", code = E0308)]
1844    Generic {
1845        #[primary_span]
1846        span: Span,
1847        #[subdiagnostic]
1848        subdiags: Vec<TypeErrorAdditionalDiags>,
1849    },
1850}
1851
1852#[derive(const _: () =
    {
        impl rustc_errors::Subdiagnostic for AddPreciseCapturing {
            fn add_to_diag<__G>(self, diag: &mut rustc_errors::Diag<'_, __G>)
                where __G: rustc_errors::EmissionGuarantee {
                match self {
                    AddPreciseCapturing::New {
                        span: __binding_0,
                        new_lifetime: __binding_1,
                        concatenated_bounds: __binding_2 } => {
                        let __code_43 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!(" + use<{0}>",
                                                        __binding_2))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("new_lifetime".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        sub_args.insert("concatenated_bounds".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add a `use<...>` bound to explicitly capture `{$new_lifetime}`")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_43, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                    AddPreciseCapturing::Existing {
                        span: __binding_0,
                        new_lifetime: __binding_1,
                        pre: __binding_2,
                        post: __binding_3 } => {
                        let __code_44 =
                            [::alloc::__export::must_use({
                                                ::alloc::fmt::format(format_args!("{2}{0}{1}", __binding_1,
                                                        __binding_3, __binding_2))
                                            })].into_iter();
                        let mut sub_args = rustc_errors::DiagArgMap::default();
                        sub_args.insert("new_lifetime".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_1,
                                &mut diag.long_ty_path));
                        sub_args.insert("pre".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_2,
                                &mut diag.long_ty_path));
                        sub_args.insert("post".into(),
                            rustc_errors::IntoDiagArg::into_diag_arg(__binding_3,
                                &mut diag.long_ty_path));
                        let __message =
                            rustc_errors::format_diag_message(&rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add `{$new_lifetime}` to the `use<...>` bound to explicitly capture it")),
                                &sub_args);
                        diag.span_suggestions_with_style(__binding_0, __message,
                            __code_44, rustc_errors::Applicability::MachineApplicable,
                            rustc_errors::SuggestionStyle::ShowAlways);
                    }
                }
            }
        }
    };Subdiagnostic)]
1853pub(crate) enum AddPreciseCapturing {
1854    #[suggestion(
1855        "add a `use<...>` bound to explicitly capture `{$new_lifetime}`",
1856        style = "verbose",
1857        code = " + use<{concatenated_bounds}>",
1858        applicability = "machine-applicable"
1859    )]
1860    New {
1861        #[primary_span]
1862        span: Span,
1863        new_lifetime: Symbol,
1864        concatenated_bounds: String,
1865    },
1866    #[suggestion(
1867        "add `{$new_lifetime}` to the `use<...>` bound to explicitly capture it",
1868        style = "verbose",
1869        code = "{pre}{new_lifetime}{post}",
1870        applicability = "machine-applicable"
1871    )]
1872    Existing {
1873        #[primary_span]
1874        span: Span,
1875        new_lifetime: Symbol,
1876        pre: &'static str,
1877        post: &'static str,
1878    },
1879}
1880
1881pub(crate) struct AddPreciseCapturingAndParams {
1882    pub suggs: Vec<(Span, String)>,
1883    pub new_lifetime: Symbol,
1884    pub apit_spans: Vec<Span>,
1885}
1886
1887impl Subdiagnostic for AddPreciseCapturingAndParams {
1888    fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
1889        diag.arg("new_lifetime", self.new_lifetime);
1890        diag.multipart_suggestion(
1891            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("add a `use<...>` bound to explicitly capture `{$new_lifetime}` after turning all argument-position `impl Trait` into type parameters, noting that this possibly affects the API of this crate"))msg!("add a `use<...>` bound to explicitly capture `{$new_lifetime}` after turning all argument-position `impl Trait` into type parameters, noting that this possibly affects the API of this crate"),
1892            self.suggs,
1893            Applicability::MaybeIncorrect,
1894        );
1895        diag.span_note(
1896            self.apit_spans,
1897            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you could use a `use<...>` bound to explicitly capture `{$new_lifetime}`, but argument-position `impl Trait`s are not nameable"))msg!("you could use a `use<...>` bound to explicitly capture `{$new_lifetime}`, but argument-position `impl Trait`s are not nameable"),
1898        );
1899    }
1900}
1901
1902/// Given a set of captured `DefId` for an RPIT (opaque_def_id) and a given
1903/// function (fn_def_id), try to suggest adding `+ use<...>` to capture just
1904/// the specified parameters. If one of those parameters is an APIT, then try
1905/// to suggest turning it into a regular type parameter.
1906pub fn impl_trait_overcapture_suggestion<'tcx>(
1907    tcx: TyCtxt<'tcx>,
1908    opaque_def_id: LocalDefId,
1909    fn_def_id: LocalDefId,
1910    captured_args: FxIndexSet<DefId>,
1911) -> Option<AddPreciseCapturingForOvercapture> {
1912    let generics = tcx.generics_of(fn_def_id);
1913
1914    let mut captured_lifetimes = FxIndexSet::default();
1915    let mut captured_non_lifetimes = FxIndexSet::default();
1916    let mut synthetics = ::alloc::vec::Vec::new()vec![];
1917
1918    for arg in captured_args {
1919        if tcx.def_kind(arg) == DefKind::LifetimeParam {
1920            captured_lifetimes.insert(tcx.item_name(arg));
1921        } else {
1922            let idx = generics.param_def_id_to_index(tcx, arg).expect("expected arg in scope");
1923            let param = generics.param_at(idx as usize, tcx);
1924            if param.kind.is_synthetic() {
1925                synthetics.push((tcx.def_span(arg), param.name));
1926            } else {
1927                captured_non_lifetimes.insert(tcx.item_name(arg));
1928            }
1929        }
1930    }
1931
1932    let mut next_fresh_param = || {
1933        ['T', 'U', 'V', 'W', 'X', 'Y', 'A', 'B', 'C']
1934            .into_iter()
1935            .map(sym::character)
1936            .chain((0..).map(|i| Symbol::intern(&::alloc::__export::must_use({ ::alloc::fmt::format(format_args!("T{0}", i)) })format!("T{i}"))))
1937            .find(|s| captured_non_lifetimes.insert(*s))
1938            .unwrap()
1939    };
1940
1941    let mut suggs = ::alloc::vec::Vec::new()vec![];
1942    let mut apit_spans = ::alloc::vec::Vec::new()vec![];
1943
1944    if !synthetics.is_empty() {
1945        let mut new_params = String::new();
1946        for (i, (span, name)) in synthetics.into_iter().enumerate() {
1947            apit_spans.push(span);
1948
1949            let fresh_param = next_fresh_param();
1950
1951            // Suggest renaming.
1952            suggs.push((span, fresh_param.to_string()));
1953
1954            // Super jank. Turn `impl Trait` into `T: Trait`.
1955            //
1956            // This currently involves stripping the `impl` from the name of
1957            // the parameter, since APITs are always named after how they are
1958            // rendered in the AST. This sucks! But to recreate the bound list
1959            // from the APIT itself would be miserable, so we're stuck with
1960            // this for now!
1961            if i > 0 {
1962                new_params += ", ";
1963            }
1964            let name_as_bounds = name.as_str().trim_start_matches("impl").trim_start();
1965            new_params += fresh_param.as_str();
1966            new_params += ": ";
1967            new_params += name_as_bounds;
1968        }
1969
1970        let Some(generics) = tcx.hir_get_generics(fn_def_id) else {
1971            // This shouldn't happen, but don't ICE.
1972            return None;
1973        };
1974
1975        // Add generics or concatenate to the end of the list.
1976        suggs.push(if let Some(params_span) = generics.span_for_param_suggestion() {
1977            (params_span, ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!(", {0}", new_params))
    })format!(", {new_params}"))
1978        } else {
1979            (generics.span, ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("<{0}>", new_params))
    })format!("<{new_params}>"))
1980        });
1981    }
1982
1983    let concatenated_bounds = captured_lifetimes
1984        .into_iter()
1985        .chain(captured_non_lifetimes)
1986        .map(|sym| sym.to_string())
1987        .collect::<Vec<_>>()
1988        .join(", ");
1989
1990    let opaque_hir_id = tcx.local_def_id_to_hir_id(opaque_def_id);
1991    // FIXME: This is a bit too conservative, since it ignores parens already written in AST.
1992    let (lparen, rparen) = match tcx
1993        .hir_parent_iter(opaque_hir_id)
1994        .nth(1)
1995        .expect("expected ty to have a parent always")
1996        .1
1997    {
1998        Node::PathSegment(segment)
1999            if segment.args().paren_sugar_output().is_some_and(|ty| ty.hir_id == opaque_hir_id) =>
2000        {
2001            ("(", ")")
2002        }
2003        Node::Ty(ty) => match ty.kind {
2004            rustc_hir::TyKind::Ptr(_) | rustc_hir::TyKind::Ref(..) => ("(", ")"),
2005            // FIXME: RPITs are not allowed to be nested in `impl Fn() -> ...`,
2006            // but we eventually could support that, and that would necessitate
2007            // making this more sophisticated.
2008            _ => ("", ""),
2009        },
2010        _ => ("", ""),
2011    };
2012
2013    let rpit_span = tcx.def_span(opaque_def_id);
2014    if !lparen.is_empty() {
2015        suggs.push((rpit_span.shrink_to_lo(), lparen.to_string()));
2016    }
2017    suggs.push((rpit_span.shrink_to_hi(), ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!(" + use<{0}>{1}",
                concatenated_bounds, rparen))
    })format!(" + use<{concatenated_bounds}>{rparen}")));
2018
2019    Some(AddPreciseCapturingForOvercapture { suggs, apit_spans })
2020}
2021
2022pub struct AddPreciseCapturingForOvercapture {
2023    pub suggs: Vec<(Span, String)>,
2024    pub apit_spans: Vec<Span>,
2025}
2026
2027impl Subdiagnostic for AddPreciseCapturingForOvercapture {
2028    fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
2029        let applicability = if self.apit_spans.is_empty() {
2030            Applicability::MachineApplicable
2031        } else {
2032            // If there are APIT that are converted to regular parameters,
2033            // then this may make the API turbofishable in ways that were
2034            // not intended.
2035            Applicability::MaybeIncorrect
2036        };
2037        diag.multipart_suggestion(
2038            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("use the precise capturing `use<...>` syntax to make the captures explicit"))msg!("use the precise capturing `use<...>` syntax to make the captures explicit"),
2039            self.suggs,
2040            applicability,
2041        );
2042        if !self.apit_spans.is_empty() {
2043            diag.span_note(
2044                self.apit_spans,
2045                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("you could use a `use<...>` bound to explicitly specify captures, but argument-position `impl Trait`s are not nameable"))msg!("you could use a `use<...>` bound to explicitly specify captures, but argument-position `impl Trait`s are not nameable"),
2046            );
2047        }
2048    }
2049}
2050
2051#[derive(const _: () =
    {
        impl<'_sess, 'a, 'tcx, G> rustc_errors::Diagnostic<'_sess, G> for
            NonGenericOpaqueTypeParam<'a, 'tcx> where
            G: rustc_errors::EmissionGuarantee {
            #[track_caller]
            fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'_sess>,
                level: rustc_errors::Level) -> rustc_errors::Diag<'_sess, G> {
                match self {
                    NonGenericOpaqueTypeParam {
                        arg: __binding_0,
                        kind: __binding_1,
                        span: __binding_2,
                        param_span: __binding_3 } => {
                        let mut diag =
                            rustc_errors::Diag::new(dcx, level,
                                rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("expected generic {$kind} parameter, found `{$arg}`")));
                        diag.code(E0792);
                        ;
                        diag.arg("arg", __binding_0);
                        diag.arg("kind", __binding_1);
                        diag.span(__binding_2);
                        diag.span_label(__binding_3,
                            rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed("{STREQ($arg, \"'static\") ->\n        [true] cannot use static lifetime; use a bound lifetime instead or remove the lifetime parameter from the opaque type\n        *[other] this generic parameter must be used with a generic {$kind} parameter\n    }")));
                        diag
                    }
                }
            }
        }
    };Diagnostic)]
2052#[diag("expected generic {$kind} parameter, found `{$arg}`", code = E0792)]
2053pub(crate) struct NonGenericOpaqueTypeParam<'a, 'tcx> {
2054    pub arg: GenericArg<'tcx>,
2055    pub kind: &'a str,
2056    #[primary_span]
2057    pub span: Span,
2058    #[label("{STREQ($arg, \"'static\") ->
2059        [true] cannot use static lifetime; use a bound lifetime instead or remove the lifetime parameter from the opaque type
2060        *[other] this generic parameter must be used with a generic {$kind} parameter
2061    }")]
2062    pub param_span: Span,
2063}