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