1
Fork 0

Improve note for the invalid_reference_casting lint

Add link to the book interior mutability chapter,
https://doc.rust-lang.org/book/ch15-05-interior-mutability.html.
This commit is contained in:
Urgau 2023-08-22 17:17:44 +02:00
parent 810573919f
commit aa7730003e
4 changed files with 62 additions and 0 deletions

View file

@ -323,6 +323,8 @@ lint_invalid_reference_casting_assign_to_ref = assigning to `&T` is undefined be
lint_invalid_reference_casting_borrow_as_mut = casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
.label = casting happend here
lint_invalid_reference_casting_note_book = for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
lint_lintpass_by_hand = implementing `LintPass` by hand
.help = try using `declare_lint_pass!` or `impl_lint_pass!` instead

View file

@ -764,11 +764,13 @@ pub enum InvalidFromUtf8Diag {
#[derive(LintDiagnostic)]
pub enum InvalidReferenceCastingDiag {
#[diag(lint_invalid_reference_casting_borrow_as_mut)]
#[note(lint_invalid_reference_casting_note_book)]
BorrowAsMut {
#[label]
orig_cast: Option<Span>,
},
#[diag(lint_invalid_reference_casting_assign_to_ref)]
#[note(lint_invalid_reference_casting_note_book)]
AssignToRef {
#[label]
orig_cast: Option<Span>,