about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorEthiraric <ethiraric@gmail.com>2024-02-27 16:22:06 +0100
committerEthiraric <ethiraric@gmail.com>2024-02-27 16:27:12 +0100
commitc6cb0e99f3d5ed6b793f04b67d51878844bf608a (patch)
tree1498639c1f621a6dbc938a49078320434c9f2b80 /compiler/rustc_codegen_llvm/src
parent10136170fe9ed01e46aeb4f4479175b79eb0e3c7 (diff)
downloadrust-c6cb0e99f3d5ed6b793f04b67d51878844bf608a.tar.gz
rust-c6cb0e99f3d5ed6b793f04b67d51878844bf608a.zip
[`unnecessary_cast`]: Avoid breaking precedence
If the whole cast expression is a unary expression (`(*x as T)`) or an
addressof expression (`(&x as T)`), then not surrounding the suggestion
into a block risks us changing the precedence of operators if the cast
expression is followed by an operation with higher precedence than the
unary operator (`(*x as T).foo()` would become `*x.foo()`, which changes
what the `*` applies on).
The same is true if the expression encompassing the cast expression is a
unary expression or an addressof expression.

The lint supports the latter case, but missed the former one. This PR
fixes that.

Fixes #11968
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions