rust-analyzer/crates
bors 9f1f5cd8f6 Auto merge of #18252 - ShoyuVanilla:issue-15799, r=Veykril
fix: Do not consider mutable usage of deref to `*mut T` as deref_mut

Fixes #15799

We are doing some heuristics for deciding whether the given deref is deref or deref_mut here;

5982d9c420/crates/hir-ty/src/infer/mutability.rs (L182-L200)

But this heuristic is erroneous if we are dereferencing to a mut ptr and normally those cases are filtered out here as builtin;

5982d9c420/crates/hir-ty/src/mir/lower/as_place.rs (L165-L177)

Howerver, this works not so well if the given dereferencing is double dereferencings like the case in the #15799.

```rust
struct WrapPtr(*mut u32);

impl core::ops::Deref for WrapPtr {
    type Target = *mut u32;
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

fn main() {
    let mut x = 0u32;
    let wrap = WrapPtr(&mut x);
    unsafe {
        **wrap = 6;
    }
}
```

Here are two - outer and inner - dereferences here, and the outer dereference is marked as deref_mut because there is an assignment operation.
And this deref_mut marking is propagated into the inner dereferencing.
In the later MIR lowering, the outer dereference is filtered out as it's expr type is `*mut u32`, but the expr type in the inner dereference is an ADT, so this false-mutablility is not filtered out.

This PR cuts propagation of this false mutablilty chain if the expr type is mut ptr.
Since this happens before the resolve_all, it may have some limitations when the expr type is determined as mut ptr at the very end of inferencing, but I couldn't find simple fix for it 🤔
2024-10-14 12:07:31 +00:00
..
base-db Remove ImportSource::ExternCrate as the fixed point loop can't affect it 2024-10-05 15:02:47 +02:00
cfg Gate #[test] expansion under cfg(test). 2024-09-30 00:12:45 +03:00
hir Auto merge of #18227 - davidbarsky:davidbarsky/push-lmntvwvznyyx, r=davidbarsky 2024-10-04 17:59:02 +00:00
hir-def Fix IDE layer not correctly resolving opt-in extern crates 2024-10-05 15:36:44 +02:00
hir-expand Fix prettify_macro_expansion() when the node isn't the whole file 2024-10-05 22:39:33 +03:00
hir-ty Auto merge of #18252 - ShoyuVanilla:issue-15799, r=Veykril 2024-10-14 12:07:31 +00:00
ide Auto merge of #18242 - Veykril:veykril/push-tnynzqsmtnqw, r=Veykril 2024-10-14 11:52:17 +00:00
ide-assists Merge from rust-lang/rust 2024-10-08 14:25:39 +03:00
ide-completion Fix: Handle block exprs as modules when finding their parents 2024-10-01 14:05:15 +09:00
ide-db Auto merge of #18234 - Veykril:veykril/push-vzynqtlxmrnl, r=Veykril 2024-10-04 10:26:04 +00:00
ide-diagnostics Auto merge of #18252 - ShoyuVanilla:issue-15799, r=Veykril 2024-10-14 12:07:31 +00:00
ide-ssr Properly account for editions in names 2024-08-16 16:46:24 +03:00
intern Merge from rust-lang/rust 2024-09-25 09:00:53 +03:00
limit Replace [package.repository] = "…" of published crates with [package.repository.workspace] = true 2024-08-06 00:26:42 +02:00
load-cargo Gate #[test] expansion under cfg(test). 2024-09-30 00:12:45 +03:00
mbe Add missing rustc_private 2024-09-25 10:56:37 +03:00
parser fix: correctly parse use in generic parameters 2024-10-01 22:10:47 +01:00
paths Replace [package.repository] = "…" of published crates with [package.repository.workspace] = true 2024-08-06 00:26:42 +02:00
proc-macro-api Properly set the working directory for proc-macro execution 2024-09-11 12:23:12 +02:00
proc-macro-srv fix: Fix TokenStream::to_string implementation dropping quotation marks 2024-08-29 08:45:35 +02:00
proc-macro-srv-cli Replace [package.repository] = "…" of published crates with [package.repository.workspace] = true 2024-08-06 00:26:42 +02:00
profile Replace [package.repository] = "…" of published crates with [package.repository.workspace] = true 2024-08-06 00:26:42 +02:00
project-model Fix panic when json project has relative buildfile paths 2024-10-12 02:25:40 -05:00
rust-analyzer Auto merge of #18229 - mrkajetanp:rustfmt-path, r=Veykril 2024-10-14 11:37:56 +00:00
salsa Drop Apache license appendices 2024-08-27 14:52:34 +03:00
span internal: Filter out opaque tokens in some of IDE feature macro descensions 2024-10-04 11:53:12 +02:00
stdx Use crossbeam-channel from the workspace 2024-08-09 23:48:03 +02:00
syntax Rename object_safety to dyn_compatibility 2024-09-29 07:26:45 -04:00
syntax-bridge When glueing together tokens from macros, merge their spans 2024-09-29 22:58:15 +03:00
test-fixture Always cache macro expansions' root node in Semantics 2024-09-17 00:19:39 +03:00
test-utils fix: Always explicitly set trait ref self types when lowering 2024-09-06 14:06:41 +02:00
text-edit Replace [package.repository] = "…" of published crates with [package.repository.workspace] = true 2024-08-06 00:26:42 +02:00
toolchain Replace [package.repository] = "…" of published crates with [package.repository.workspace] = true 2024-08-06 00:26:42 +02:00
tt Support the ${concat(...)} metavariable expression 2024-09-19 22:19:12 +03:00
vfs Rename object_safety to dyn_compatibility 2024-09-29 07:26:45 -04:00
vfs-notify Auto merge of #17843 - mo8it:flycheck, r=Veykril 2024-08-12 09:27:47 +00:00