rust/compiler/rustc_lint/src
bors d170833431 Auto merge of #112431 - Urgau:cast_ref_to_mut_improvments, r=Nilstrieb
Improve `invalid_reference_casting` lint

This PR is a follow-up to https://github.com/rust-lang/rust/pull/111567 and https://github.com/rust-lang/rust/pull/113422.

This PR does multiple things:
 - First it adds support for deferred de-reference, the goal is to support code like this, where the casting and de-reference are not done on the same expression
    ```rust
    let myself = self as *const Self as *mut Self;
    *myself = Self::Ready(value);
    ```
 - Second it does not lint anymore on SB/TB UB code by only checking assignments (`=`, `+=`, ...) and creation of mutable references `&mut *`
 - Thirdly it greatly improves the diagnostics in particular for cast from `&mut` to `&mut` or assignments
 - ~~And lastly it renames the lint from `cast_ref_to_mut` to `invalid_reference_casting` which is more consistent with the ["rules"](https://github.com/rust-lang/rust-clippy/issues/2845) and also more consistent with what the lint checks~~ *https://github.com/rust-lang/rust/pull/113422*

This PR is best reviewed commit by commit.

r? compiler
2023-08-02 11:25:13 +00:00
..
nonstandard_style
array_into_iter.rs Re-format let-else per rustfmt update 2023-07-12 21:49:27 -04:00
builtin.rs Check lazy type aliases for well-formedness 2023-07-30 11:24:15 +02:00
context.rs fix(resolve): update the ambiguity glob binding as warning recursively 2023-07-29 00:19:50 +08:00
deref_into_dyn_supertrait.rs refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
drop_forget_useless.rs
early.rs
enum_intrinsics_non_enums.rs refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
errors.rs
expect.rs
fn_null_check.rs
for_loops_over_fallibles.rs refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
hidden_unicode_codepoints.rs
internal.rs refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
invalid_from_utf8.rs
late.rs
let_underscore.rs
levels.rs inline format!() args from rustc_codegen_llvm to the end (4) 2023-07-25 23:20:28 +02:00
lib.rs Add support for deferred casting for the invalid_reference_casting lint 2023-07-29 12:20:59 +02:00
lints.rs Improve diagnostics of the invalid_reference_casting lint 2023-07-29 12:20:59 +02:00
map_unit_fn.rs
methods.rs refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
multiple_supertrait_upcastable.rs Add missing feature gate in multiple_supertrait_upcastable doc 2023-07-31 12:28:53 +01:00
non_ascii_idents.rs
non_fmt_panic.rs
nonstandard_style.rs
noop_method_call.rs fix 2023-07-23 09:58:31 +00:00
opaque_hidden_inferred_bound.rs Rename arg_iter to iter_instantiated 2023-07-17 21:04:12 +00:00
pass_by_value.rs refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
passes.rs
redundant_semicolon.rs
reference_casting.rs Improve diagnostics of the invalid_reference_casting lint 2023-07-29 12:20:59 +02:00
tests.rs
traits.rs Re-format let-else per rustfmt update 2023-07-12 21:49:27 -04:00
types.rs Auto merge of #113457 - davidtwco:lint-ctypes-issue-113436, r=oli-obk 2023-07-26 15:27:36 +00:00
unused.rs inline format!() args from rustc_codegen_llvm to the end (4) 2023-07-25 23:20:28 +02:00