Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
use rustc_errors::MultiSpan;
|
|
|
|
use rustc_errors::codes::*;
|
2022-09-18 15:47:31 +00:00
|
|
|
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
2023-01-16 15:15:09 +00:00
|
|
|
use rustc_middle::ty::{GenericArg, Ty};
|
2022-06-23 04:43:01 +00:00
|
|
|
use rustc_span::Span;
|
|
|
|
|
2022-08-26 02:32:59 +00:00
|
|
|
use crate::diagnostics::RegionName;
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(borrowck_move_unsized, code = E0161)]
|
2022-06-23 04:43:01 +00:00
|
|
|
pub(crate) struct MoveUnsized<'tcx> {
|
|
|
|
pub ty: Ty<'tcx>,
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(borrowck_higher_ranked_lifetime_error)]
|
2022-06-23 04:43:01 +00:00
|
|
|
pub(crate) struct HigherRankedLifetimeError {
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub cause: Option<HigherRankedErrorCause>,
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-06-23 04:43:01 +00:00
|
|
|
pub(crate) enum HigherRankedErrorCause {
|
2022-10-22 09:07:54 +00:00
|
|
|
#[note(borrowck_could_not_prove)]
|
2022-06-23 04:43:01 +00:00
|
|
|
CouldNotProve { predicate: String },
|
2022-10-22 09:07:54 +00:00
|
|
|
#[note(borrowck_could_not_normalize)]
|
2022-06-23 04:43:01 +00:00
|
|
|
CouldNotNormalize { value: String },
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(borrowck_higher_ranked_subtype_error)]
|
2022-06-23 04:43:01 +00:00
|
|
|
pub(crate) struct HigherRankedSubtypeError {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(borrowck_generic_does_not_live_long_enough)]
|
2022-06-23 04:43:01 +00:00
|
|
|
pub(crate) struct GenericDoesNotLiveLongEnough {
|
|
|
|
pub kind: String,
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
2022-08-26 02:32:59 +00:00
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(borrowck_var_does_not_need_mut)]
|
2022-08-26 02:32:59 +00:00
|
|
|
pub(crate) struct VarNeedNotMut {
|
2022-10-22 13:48:55 +00:00
|
|
|
#[suggestion(style = "short", applicability = "machine-applicable", code = "")]
|
2022-08-26 02:32:59 +00:00
|
|
|
pub span: Span,
|
|
|
|
}
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(borrowck_var_cannot_escape_closure)]
|
2022-08-26 02:32:59 +00:00
|
|
|
#[note]
|
2022-10-13 09:13:02 +00:00
|
|
|
#[note(borrowck_cannot_escape)]
|
2022-08-26 02:32:59 +00:00
|
|
|
pub(crate) struct FnMutError {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub ty_err: FnMutReturnTypeErr,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-08-26 02:32:59 +00:00
|
|
|
pub(crate) enum VarHereDenote {
|
2022-10-22 09:07:54 +00:00
|
|
|
#[label(borrowck_var_here_captured)]
|
2022-08-26 02:32:59 +00:00
|
|
|
Captured {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
},
|
2022-10-22 09:07:54 +00:00
|
|
|
#[label(borrowck_var_here_defined)]
|
2022-08-26 02:32:59 +00:00
|
|
|
Defined {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
},
|
2022-10-22 09:07:54 +00:00
|
|
|
#[label(borrowck_closure_inferred_mut)]
|
2022-08-26 02:32:59 +00:00
|
|
|
FnMutInferred {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-08-26 02:32:59 +00:00
|
|
|
pub(crate) enum FnMutReturnTypeErr {
|
2022-10-22 09:07:54 +00:00
|
|
|
#[label(borrowck_returned_closure_escaped)]
|
2022-08-26 02:32:59 +00:00
|
|
|
ReturnClosure {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
},
|
2022-10-22 09:07:54 +00:00
|
|
|
#[label(borrowck_returned_async_block_escaped)]
|
2022-08-26 02:32:59 +00:00
|
|
|
ReturnAsyncBlock {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
},
|
2022-10-22 09:07:54 +00:00
|
|
|
#[label(borrowck_returned_ref_escaped)]
|
2022-08-26 02:32:59 +00:00
|
|
|
ReturnRef {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:46:56 +00:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 09:07:54 +00:00
|
|
|
#[diag(borrowck_lifetime_constraints_error)]
|
2022-08-26 02:32:59 +00:00
|
|
|
pub(crate) struct LifetimeOutliveErr {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-08-26 02:32:59 +00:00
|
|
|
pub(crate) enum LifetimeReturnCategoryErr<'a> {
|
2022-10-22 09:07:54 +00:00
|
|
|
#[label(borrowck_returned_lifetime_wrong)]
|
2022-08-26 02:32:59 +00:00
|
|
|
WrongReturn {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
mir_def_name: &'a str,
|
|
|
|
outlived_fr_name: RegionName,
|
|
|
|
fr_name: &'a RegionName,
|
|
|
|
},
|
2022-10-22 09:07:54 +00:00
|
|
|
#[label(borrowck_returned_lifetime_short)]
|
2022-08-26 02:32:59 +00:00
|
|
|
ShortReturn {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
category_desc: &'static str,
|
|
|
|
free_region_name: &'a RegionName,
|
|
|
|
outlived_fr_name: RegionName,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2022-09-18 15:47:31 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
2022-08-26 02:32:59 +00:00
|
|
|
pub(crate) enum RequireStaticErr {
|
2022-10-22 09:07:54 +00:00
|
|
|
#[note(borrowck_used_impl_require_static)]
|
2022-08-26 02:32:59 +00:00
|
|
|
UsedImpl {
|
|
|
|
#[primary_span]
|
|
|
|
multi_span: MultiSpan,
|
|
|
|
},
|
|
|
|
}
|
2022-10-26 02:42:05 +00:00
|
|
|
|
2022-11-04 09:09:14 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
pub(crate) enum CaptureVarPathUseCause {
|
2023-10-19 21:46:28 +00:00
|
|
|
#[label(borrowck_borrow_due_to_use_coroutine)]
|
2023-10-19 16:06:43 +00:00
|
|
|
BorrowInCoroutine {
|
2022-11-04 09:09:14 +00:00
|
|
|
#[primary_span]
|
|
|
|
path_span: Span,
|
|
|
|
},
|
2023-10-19 21:46:28 +00:00
|
|
|
#[label(borrowck_use_due_to_use_coroutine)]
|
2023-10-19 16:06:43 +00:00
|
|
|
UseInCoroutine {
|
2022-11-04 09:09:14 +00:00
|
|
|
#[primary_span]
|
|
|
|
path_span: Span,
|
|
|
|
},
|
2023-10-19 21:46:28 +00:00
|
|
|
#[label(borrowck_assign_due_to_use_coroutine)]
|
2023-10-19 16:06:43 +00:00
|
|
|
AssignInCoroutine {
|
2022-11-04 09:09:14 +00:00
|
|
|
#[primary_span]
|
|
|
|
path_span: Span,
|
|
|
|
},
|
2023-10-19 21:46:28 +00:00
|
|
|
#[label(borrowck_assign_part_due_to_use_coroutine)]
|
2023-10-19 16:06:43 +00:00
|
|
|
AssignPartInCoroutine {
|
2022-11-04 09:09:14 +00:00
|
|
|
#[primary_span]
|
|
|
|
path_span: Span,
|
|
|
|
},
|
|
|
|
#[label(borrowck_borrow_due_to_use_closure)]
|
|
|
|
BorrowInClosure {
|
|
|
|
#[primary_span]
|
|
|
|
path_span: Span,
|
|
|
|
},
|
|
|
|
#[label(borrowck_use_due_to_use_closure)]
|
|
|
|
UseInClosure {
|
|
|
|
#[primary_span]
|
|
|
|
path_span: Span,
|
|
|
|
},
|
|
|
|
#[label(borrowck_assign_due_to_use_closure)]
|
|
|
|
AssignInClosure {
|
|
|
|
#[primary_span]
|
|
|
|
path_span: Span,
|
|
|
|
},
|
|
|
|
#[label(borrowck_assign_part_due_to_use_closure)]
|
|
|
|
AssignPartInClosure {
|
|
|
|
#[primary_span]
|
|
|
|
path_span: Span,
|
|
|
|
},
|
|
|
|
}
|
2022-11-09 12:56:28 +00:00
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
pub(crate) enum CaptureVarKind {
|
|
|
|
#[label(borrowck_capture_immute)]
|
2023-02-10 08:58:32 +00:00
|
|
|
Immut {
|
2022-11-09 12:56:28 +00:00
|
|
|
#[primary_span]
|
|
|
|
kind_span: Span,
|
|
|
|
},
|
|
|
|
#[label(borrowck_capture_mut)]
|
|
|
|
Mut {
|
|
|
|
#[primary_span]
|
|
|
|
kind_span: Span,
|
|
|
|
},
|
|
|
|
#[label(borrowck_capture_move)]
|
|
|
|
Move {
|
|
|
|
#[primary_span]
|
|
|
|
kind_span: Span,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
pub(crate) enum CaptureVarCause {
|
2023-10-19 21:46:28 +00:00
|
|
|
#[label(borrowck_var_borrow_by_use_place_in_coroutine)]
|
2023-10-19 16:06:43 +00:00
|
|
|
BorrowUsePlaceCoroutine {
|
2023-02-10 08:58:32 +00:00
|
|
|
is_single_var: bool,
|
2022-11-09 12:56:28 +00:00
|
|
|
place: String,
|
|
|
|
#[primary_span]
|
|
|
|
var_span: Span,
|
|
|
|
},
|
|
|
|
#[label(borrowck_var_borrow_by_use_place_in_closure)]
|
|
|
|
BorrowUsePlaceClosure {
|
2023-02-10 08:58:32 +00:00
|
|
|
is_single_var: bool,
|
2022-11-09 12:56:28 +00:00
|
|
|
place: String,
|
|
|
|
#[primary_span]
|
|
|
|
var_span: Span,
|
|
|
|
},
|
2023-10-19 21:46:28 +00:00
|
|
|
#[label(borrowck_var_borrow_by_use_in_coroutine)]
|
2023-10-19 16:06:43 +00:00
|
|
|
BorrowUseInCoroutine {
|
2023-02-10 08:58:32 +00:00
|
|
|
#[primary_span]
|
|
|
|
var_span: Span,
|
|
|
|
},
|
|
|
|
#[label(borrowck_var_borrow_by_use_in_closure)]
|
|
|
|
BorrowUseInClosure {
|
|
|
|
#[primary_span]
|
|
|
|
var_span: Span,
|
|
|
|
},
|
2023-10-19 21:46:28 +00:00
|
|
|
#[label(borrowck_var_move_by_use_in_coroutine)]
|
2023-10-19 16:06:43 +00:00
|
|
|
MoveUseInCoroutine {
|
2023-02-10 08:58:32 +00:00
|
|
|
#[primary_span]
|
|
|
|
var_span: Span,
|
|
|
|
},
|
|
|
|
#[label(borrowck_var_move_by_use_in_closure)]
|
|
|
|
MoveUseInClosure {
|
|
|
|
#[primary_span]
|
|
|
|
var_span: Span,
|
|
|
|
},
|
2023-10-19 21:46:28 +00:00
|
|
|
#[label(borrowck_var_first_borrow_by_use_place_in_coroutine)]
|
2023-10-19 16:06:43 +00:00
|
|
|
FirstBorrowUsePlaceCoroutine {
|
2023-02-10 08:58:32 +00:00
|
|
|
place: String,
|
|
|
|
#[primary_span]
|
|
|
|
var_span: Span,
|
|
|
|
},
|
|
|
|
#[label(borrowck_var_first_borrow_by_use_place_in_closure)]
|
|
|
|
FirstBorrowUsePlaceClosure {
|
|
|
|
place: String,
|
|
|
|
#[primary_span]
|
|
|
|
var_span: Span,
|
|
|
|
},
|
2023-10-19 21:46:28 +00:00
|
|
|
#[label(borrowck_var_second_borrow_by_use_place_in_coroutine)]
|
2023-10-19 16:06:43 +00:00
|
|
|
SecondBorrowUsePlaceCoroutine {
|
2023-02-10 08:58:32 +00:00
|
|
|
place: String,
|
|
|
|
#[primary_span]
|
|
|
|
var_span: Span,
|
|
|
|
},
|
|
|
|
#[label(borrowck_var_second_borrow_by_use_place_in_closure)]
|
|
|
|
SecondBorrowUsePlaceClosure {
|
|
|
|
place: String,
|
|
|
|
#[primary_span]
|
|
|
|
var_span: Span,
|
|
|
|
},
|
|
|
|
#[label(borrowck_var_mutable_borrow_by_use_place_in_closure)]
|
|
|
|
MutableBorrowUsePlaceClosure {
|
|
|
|
place: String,
|
|
|
|
#[primary_span]
|
|
|
|
var_span: Span,
|
|
|
|
},
|
2023-10-19 21:46:28 +00:00
|
|
|
#[label(borrowck_partial_var_move_by_use_in_coroutine)]
|
2023-10-19 16:06:43 +00:00
|
|
|
PartialMoveUseInCoroutine {
|
2023-02-10 08:58:32 +00:00
|
|
|
#[primary_span]
|
|
|
|
var_span: Span,
|
|
|
|
is_partial: bool,
|
|
|
|
},
|
|
|
|
#[label(borrowck_partial_var_move_by_use_in_closure)]
|
|
|
|
PartialMoveUseInClosure {
|
|
|
|
#[primary_span]
|
|
|
|
var_span: Span,
|
|
|
|
is_partial: bool,
|
|
|
|
},
|
2022-11-09 12:56:28 +00:00
|
|
|
}
|
2022-11-09 12:57:44 +00:00
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(borrowck_cannot_move_when_borrowed, code = E0505)]
|
2022-11-09 12:57:44 +00:00
|
|
|
pub(crate) struct MoveBorrow<'a> {
|
|
|
|
pub place: &'a str,
|
|
|
|
pub borrow_place: &'a str,
|
|
|
|
pub value_place: &'a str,
|
|
|
|
#[primary_span]
|
2022-10-13 09:13:02 +00:00
|
|
|
#[label(borrowck_move_label)]
|
2022-11-09 12:57:44 +00:00
|
|
|
pub span: Span,
|
|
|
|
#[label]
|
|
|
|
pub borrow_span: Span,
|
|
|
|
}
|
2023-01-16 15:15:09 +00:00
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
Stop using `String` for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!
This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.
With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123) // macro call
struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call
\#[diag(name, code = "E0123")] // string
struct Diag;
```
With the new code, they all use the `E0123` constant.
```
E0123 // constant
struct_span_code_err!(dcx, span, E0123, "msg"); // constant
\#[diag(name, code = E0123)] // constant
struct Diag;
```
The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
code constants and the `DIAGNOSTIC_TABLES`. This is in its new
`codes.rs` file.
2024-01-13 23:57:07 +00:00
|
|
|
#[diag(borrowck_opaque_type_non_generic_param, code = E0792)]
|
2023-01-16 15:15:09 +00:00
|
|
|
pub(crate) struct NonGenericOpaqueTypeParam<'a, 'tcx> {
|
|
|
|
pub ty: GenericArg<'tcx>,
|
|
|
|
pub kind: &'a str,
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
#[label]
|
|
|
|
pub param_span: Span,
|
|
|
|
}
|
2023-02-10 08:58:32 +00:00
|
|
|
|
2023-10-19 08:26:32 +00:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(borrowck_opaque_type_lifetime_mismatch)]
|
|
|
|
pub(crate) struct LifetimeMismatchOpaqueParam<'tcx> {
|
|
|
|
pub arg: GenericArg<'tcx>,
|
|
|
|
pub prev: GenericArg<'tcx>,
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
#[note]
|
|
|
|
pub span: Span,
|
|
|
|
#[label(borrowck_prev_lifetime_label)]
|
|
|
|
pub prev_span: Span,
|
|
|
|
}
|
|
|
|
|
2023-02-10 08:58:32 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
pub(crate) enum CaptureReasonLabel<'a> {
|
|
|
|
#[label(borrowck_moved_due_to_call)]
|
|
|
|
Call {
|
|
|
|
#[primary_span]
|
|
|
|
fn_call_span: Span,
|
|
|
|
place_name: &'a str,
|
|
|
|
is_partial: bool,
|
|
|
|
is_loop_message: bool,
|
|
|
|
},
|
|
|
|
#[label(borrowck_moved_due_to_usage_in_operator)]
|
|
|
|
OperatorUse {
|
|
|
|
#[primary_span]
|
|
|
|
fn_call_span: Span,
|
|
|
|
place_name: &'a str,
|
|
|
|
is_partial: bool,
|
|
|
|
is_loop_message: bool,
|
|
|
|
},
|
|
|
|
#[label(borrowck_moved_due_to_implicit_into_iter_call)]
|
|
|
|
ImplicitCall {
|
|
|
|
#[primary_span]
|
|
|
|
fn_call_span: Span,
|
|
|
|
place_name: &'a str,
|
|
|
|
is_partial: bool,
|
|
|
|
is_loop_message: bool,
|
|
|
|
},
|
|
|
|
#[label(borrowck_moved_due_to_method_call)]
|
|
|
|
MethodCall {
|
|
|
|
#[primary_span]
|
|
|
|
fn_call_span: Span,
|
|
|
|
place_name: &'a str,
|
|
|
|
is_partial: bool,
|
|
|
|
is_loop_message: bool,
|
|
|
|
},
|
2023-04-25 19:48:59 +00:00
|
|
|
#[label(borrowck_moved_due_to_await)]
|
|
|
|
Await {
|
|
|
|
#[primary_span]
|
|
|
|
fn_call_span: Span,
|
|
|
|
place_name: &'a str,
|
|
|
|
is_partial: bool,
|
|
|
|
is_loop_message: bool,
|
|
|
|
},
|
2023-02-10 08:58:32 +00:00
|
|
|
#[label(borrowck_value_moved_here)]
|
|
|
|
MovedHere {
|
|
|
|
#[primary_span]
|
|
|
|
move_span: Span,
|
|
|
|
is_partial: bool,
|
|
|
|
is_move_msg: bool,
|
|
|
|
is_loop_message: bool,
|
|
|
|
},
|
|
|
|
#[label(borrowck_consider_borrow_type_contents)]
|
|
|
|
BorrowContent {
|
|
|
|
#[primary_span]
|
|
|
|
var_span: Span,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
pub(crate) enum CaptureReasonNote {
|
|
|
|
#[note(borrowck_moved_a_fn_once_in_call)]
|
|
|
|
FnOnceMoveInCall {
|
|
|
|
#[primary_span]
|
|
|
|
var_span: Span,
|
|
|
|
},
|
2024-03-12 17:21:15 +00:00
|
|
|
#[note(borrowck_calling_operator_moves)]
|
|
|
|
UnOpMoveByOperator {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
},
|
2023-02-10 08:58:32 +00:00
|
|
|
#[note(borrowck_calling_operator_moves_lhs)]
|
|
|
|
LhsMoveByOperator {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
},
|
|
|
|
#[note(borrowck_func_take_self_moved_place)]
|
|
|
|
FuncTakeSelf {
|
|
|
|
func: String,
|
|
|
|
place_name: String,
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
pub(crate) enum CaptureReasonSuggest<'tcx> {
|
|
|
|
#[suggestion(
|
|
|
|
borrowck_suggest_iterate_over_slice,
|
|
|
|
applicability = "maybe-incorrect",
|
|
|
|
code = "&",
|
|
|
|
style = "verbose"
|
|
|
|
)]
|
|
|
|
IterateSlice {
|
|
|
|
ty: Ty<'tcx>,
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
},
|
|
|
|
#[suggestion(
|
2024-09-04 23:03:47 +00:00
|
|
|
borrowck_suggest_create_fresh_reborrow,
|
2023-02-10 08:58:32 +00:00
|
|
|
applicability = "maybe-incorrect",
|
2023-06-22 21:32:39 +00:00
|
|
|
code = ".as_mut()",
|
2023-02-10 08:58:32 +00:00
|
|
|
style = "verbose"
|
|
|
|
)]
|
|
|
|
FreshReborrow {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
pub(crate) enum CaptureArgLabel {
|
|
|
|
#[label(borrowck_value_capture_here)]
|
|
|
|
Capture {
|
|
|
|
is_within: bool,
|
|
|
|
#[primary_span]
|
|
|
|
args_span: Span,
|
|
|
|
},
|
|
|
|
#[label(borrowck_move_out_place_here)]
|
|
|
|
MoveOutPlace {
|
|
|
|
place: String,
|
|
|
|
#[primary_span]
|
|
|
|
args_span: Span,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
pub(crate) enum OnClosureNote<'a> {
|
|
|
|
#[note(borrowck_closure_invoked_twice)]
|
|
|
|
InvokedTwice {
|
|
|
|
place_name: &'a str,
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
},
|
|
|
|
#[note(borrowck_closure_moved_twice)]
|
|
|
|
MovedTwice {
|
|
|
|
place_name: &'a str,
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
Use short ty string for move errors
```
error[E0382]: use of moved value: `x`
--> bay.rs:14:14
|
12 | fn foo(x: D) {
| - move occurs because `x` has type `(((..., ..., ..., ...), ..., ..., ...), ..., ..., ...)`, which does not implement the `Copy` trait
13 | let _a = x;
| - value moved here
14 | let _b = x; //~ ERROR use of moved value
| ^ value used here after move
|
= note: the full type name has been written to 'bay.long-type-14349227078439097973.txt'
= note: consider using `--verbose` to print the full type name to the console
help: consider cloning the value if the performance cost is acceptable
|
13 | let _a = x.clone();
| ++++++++
```
2025-01-24 17:49:25 +00:00
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
pub(crate) enum TypeNoCopy<'a> {
|
2023-02-10 08:58:32 +00:00
|
|
|
#[label(borrowck_ty_no_impl_copy)]
|
|
|
|
Label {
|
|
|
|
is_partial_move: bool,
|
Use short ty string for move errors
```
error[E0382]: use of moved value: `x`
--> bay.rs:14:14
|
12 | fn foo(x: D) {
| - move occurs because `x` has type `(((..., ..., ..., ...), ..., ..., ...), ..., ..., ...)`, which does not implement the `Copy` trait
13 | let _a = x;
| - value moved here
14 | let _b = x; //~ ERROR use of moved value
| ^ value used here after move
|
= note: the full type name has been written to 'bay.long-type-14349227078439097973.txt'
= note: consider using `--verbose` to print the full type name to the console
help: consider cloning the value if the performance cost is acceptable
|
13 | let _a = x.clone();
| ++++++++
```
2025-01-24 17:49:25 +00:00
|
|
|
ty: String,
|
2023-02-10 08:58:32 +00:00
|
|
|
place: &'a str,
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
},
|
|
|
|
#[note(borrowck_ty_no_impl_copy)]
|
Use short ty string for move errors
```
error[E0382]: use of moved value: `x`
--> bay.rs:14:14
|
12 | fn foo(x: D) {
| - move occurs because `x` has type `(((..., ..., ..., ...), ..., ..., ...), ..., ..., ...)`, which does not implement the `Copy` trait
13 | let _a = x;
| - value moved here
14 | let _b = x; //~ ERROR use of moved value
| ^ value used here after move
|
= note: the full type name has been written to 'bay.long-type-14349227078439097973.txt'
= note: consider using `--verbose` to print the full type name to the console
help: consider cloning the value if the performance cost is acceptable
|
13 | let _a = x.clone();
| ++++++++
```
2025-01-24 17:49:25 +00:00
|
|
|
Note { is_partial_move: bool, ty: String, place: &'a str },
|
2023-02-10 08:58:32 +00:00
|
|
|
}
|
2023-09-06 09:38:15 +00:00
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2024-02-17 08:57:24 +00:00
|
|
|
#[diag(borrowck_simd_intrinsic_arg_const)]
|
|
|
|
pub(crate) struct SimdIntrinsicArgConst {
|
2023-09-06 09:38:15 +00:00
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
2024-02-17 08:57:24 +00:00
|
|
|
pub arg: usize,
|
|
|
|
pub intrinsic: String,
|
2023-09-06 09:38:15 +00:00
|
|
|
}
|
2024-12-04 18:58:59 +00:00
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
|
|
|
#[diag(borrowck_tail_expr_drop_order)]
|
|
|
|
pub(crate) struct TailExprDropOrder {
|
|
|
|
#[label]
|
|
|
|
pub borrowed: Span,
|
|
|
|
}
|