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

FP type mismatch on DSTs #16293

Open
matthiaskrgr opened this issue Jan 6, 2024 · 0 comments
Open

FP type mismatch on DSTs #16293

matthiaskrgr opened this issue Jan 6, 2024 · 0 comments
Labels
A-ty type system / type inference / traits / method resolution C-bug Category: bug

Comments

@matthiaskrgr
Copy link
Member

// from src/tools/miri/tests/pass/issues/issue-23261.rs
// Matching on a DST struct should not trigger an LLVM assertion.

struct Foo<T: ?Sized> {
    a: i32,
    inner: T,
}

trait Get {
    fn get(&self) -> i32;
}

impl Get for i32 {
    fn get(&self) -> i32 {
        *self
    }
}

fn main() {
    // boom
    let foo: &Foo<[u8]> = &Foo { a: 32, inner: [1, 2, 3] };
    // boom
    let foo: &Foo<dyn Get> = &Foo { a: 32, inner: 32 };
}

edition 2015

ra reports a type mismatch here which rustc doesnt:

 rust-analyzer diagnostics  .
processing crate: bar, module: /tmp/bar/src/main.rs
Diagnostic { code: RustcHardError("E0308"), message: "expected &Foo<[u8]>, found &Foo<[i32; 3]>", range: FileRange { file_id: FileId(11), range: 336..368 }, severity: Error, unused: false, experimental: true, fixes: None, main_node: None }
Diagnostic { code: RustcHardError("E0308"), message: "expected &Foo<dyn Get>, found &Foo<i32>", range: FileRange { file_id: FileId(11), range: 411..436 }, severity: Error, unused: false, experimental: true, fixes: None, main_node: None }

diagnostic scan complete

Error: diagnostic error detected
@matthiaskrgr matthiaskrgr added the C-bug Category: bug label Jan 6, 2024
@lnicola lnicola added the A-ty type system / type inference / traits / method resolution label Aug 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ty type system / type inference / traits / method resolution C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants