1 use rustc_errors::{IntoDiagnosticArg, MultiSpan};
2 use rustc_macros::{LintDiagnostic, SessionDiagnostic, SessionSubdiagnostic};
3 use rustc_middle::ty::Ty;
6 use crate::diagnostics::RegionName;
8 #[derive(SessionDiagnostic)]
9 #[diag(borrowck::move_unsized, code = "E0161")]
10 pub(crate) struct MoveUnsized<'tcx> {
17 #[derive(SessionDiagnostic)]
18 #[diag(borrowck::higher_ranked_lifetime_error)]
19 pub(crate) struct HigherRankedLifetimeError {
21 pub cause: Option<HigherRankedErrorCause>,
26 #[derive(SessionSubdiagnostic)]
27 pub(crate) enum HigherRankedErrorCause {
28 #[note(borrowck::could_not_prove)]
29 CouldNotProve { predicate: String },
30 #[note(borrowck::could_not_normalize)]
31 CouldNotNormalize { value: String },
34 #[derive(SessionDiagnostic)]
35 #[diag(borrowck::higher_ranked_subtype_error)]
36 pub(crate) struct HigherRankedSubtypeError {
41 #[derive(SessionDiagnostic)]
42 #[diag(borrowck::generic_does_not_live_long_enough)]
43 pub(crate) struct GenericDoesNotLiveLongEnough {
49 #[derive(LintDiagnostic)]
50 #[diag(borrowck::var_does_not_need_mut)]
51 pub(crate) struct VarNeedNotMut {
52 #[suggestion_short(applicability = "machine-applicable", code = "")]
56 #[derive(SessionDiagnostic)]
57 #[diag(borrowck::const_not_used_in_type_alias)]
58 pub(crate) struct ConstNotUsedTraitAlias {
64 #[derive(SessionDiagnostic)]
65 #[diag(borrowck::var_cannot_escape_closure)]
67 #[note(borrowck::cannot_escape)]
68 pub(crate) struct FnMutError {
72 pub ty_err: FnMutReturnTypeErr,
75 #[derive(SessionSubdiagnostic)]
76 pub(crate) enum VarHereDenote {
77 #[label(borrowck::var_here_captured)]
82 #[label(borrowck::var_here_defined)]
87 #[label(borrowck::closure_inferred_mut)]
94 #[derive(SessionSubdiagnostic)]
95 pub(crate) enum FnMutReturnTypeErr {
96 #[label(borrowck::returned_closure_escaped)]
101 #[label(borrowck::returned_async_block_escaped)]
106 #[label(borrowck::returned_ref_escaped)]
113 #[derive(SessionDiagnostic)]
114 #[diag(borrowck::lifetime_constraints_error)]
115 pub(crate) struct LifetimeOutliveErr {
120 #[derive(SessionSubdiagnostic)]
121 pub(crate) enum LifetimeReturnCategoryErr<'a> {
122 #[label(borrowck::returned_lifetime_wrong)]
126 mir_def_name: &'a str,
127 outlived_fr_name: RegionName,
128 fr_name: &'a RegionName,
130 #[label(borrowck::returned_lifetime_short)]
134 category_desc: &'static str,
135 free_region_name: &'a RegionName,
136 outlived_fr_name: RegionName,
140 impl IntoDiagnosticArg for &RegionName {
141 fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
142 format!("{}", self).into_diagnostic_arg()
146 impl IntoDiagnosticArg for RegionName {
147 fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
148 format!("{}", self).into_diagnostic_arg()
152 #[derive(SessionSubdiagnostic)]
153 pub(crate) enum RequireStaticErr {
154 #[note(borrowck::used_impl_require_static)]
157 multi_span: MultiSpan,