Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autogenerated filename string symbol is incompatible with some assemblers #15799

Closed
expipiplus1 opened this issue Jul 19, 2014 · 0 comments
Closed

Comments

@expipiplus1
Copy link

The assembler for the Gameboy Advance specifically, part of devkitARM.

rustc outputs the LLVM IR constant : @"strName(956)" = internal constant [8 x i8] c"hello.rs"
This is faithfully translated to

"strName(956)":
        .ascii  "hello.rs"
        .size   "strName(956)", 8

This version of as can't deal with quotes and brackets in symbol names. For this assembler it'll be necessary to mangle any offending symbol names.

@huonw huonw changed the title Autogenerated file name string symbol is incompatible with some assemblers Autogenerated filename string symbol is incompatible with some assemblers Jul 19, 2014
@huonw huonw closed this as completed in e753dbb Aug 4, 2014
lnicola pushed a commit to lnicola/rust that referenced this issue Oct 17, 2024
fix: Do not consider mutable usage of deref to `*mut T` as deref_mut

Fixes rust-lang#15799

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

https://github.com/rust-lang/rust-analyzer/blob/5982d9c420d0dc90739171829f0d2e9c80d98979/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;

https://github.com/rust-lang/rust-analyzer/blob/5982d9c420d0dc90739171829f0d2e9c80d98979/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 rust-lang#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 🤔
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant