Skip to main content

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