Skip to main content

rustc_trait_selection/
errors.rs

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