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

Code passes initial check, but fails on closure-dyn type check after any operation #19003

Open
lxl66566 opened this issue Jan 22, 2025 · 0 comments
Labels
A-ty type system / type inference / traits / method resolution C-bug Category: bug

Comments

@lxl66566
Copy link

rust-analyzer version: both stable and pre-release (0.3.2273-standalone (248bd51 2025-01-18) and 0.4.2276-standalone (0b68402 2025-01-21))

rustc version: rustc 1.84.0 (9fc6b4312 2025-01-07)

editor or extension: VSCode

relevant settings: rustc_wrapper = sccache

repository link (if public, optional): None

code snippet to reproduce:

use std::sync::{Arc, Mutex};
fn need(x: Arc<Mutex<dyn FnMut(i32) -> i32>>) {
    todo!()
}
fn main() {
    let callback = |x| x;
    let mut callback = need(Arc::new(Mutex::new(callback)));
}

reproduce:

  1. copy this snippet to a new cargo project
  2. Run cargo check — the code passes.
  3. Restart the RA LSP — the code passes the initial check.
  4. Make a minor change (e.g., add a space somewhere in the code) to trigger a recheck in RA. RA now reports an error: expected Arc<Mutex<dyn FnMut(i32) -> i32>, Global>, found Arc<Mutex<{closure#1}>, Global> rust-analyzer ([E0308](https://doc.rust-lang.org/stable/error_codes/E0308.html))
@lxl66566 lxl66566 added the C-bug Category: bug label Jan 22, 2025
@lnicola lnicola added the A-ty type system / type inference / traits / method resolution label Jan 26, 2025
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