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

Incorrect import suggestion when using rhai #16436

Open
Cerber-Ursi opened this issue Jan 27, 2024 · 5 comments
Open

Incorrect import suggestion when using rhai #16436

Cerber-Ursi opened this issue Jan 27, 2024 · 5 comments
Labels
C-bug Category: bug

Comments

@Cerber-Ursi
Copy link

Got somewhat strange behavior when working with rhai. Here's the minimal example.

Cargo.toml:

[package]
name = "quick_tests"
version = "0.1.0"
edition = "2021"

[dependencies]
rhai = "=1.16.3"

main.rs:

fn main() {
    let _: Rc<RefCell<()>> = todo!();
}

This code errors as expected, but when I try to use code actions to apply auto fixes, VSCode with RA offers to auto import rhai::Shared and rhai::Locked, instead of std::rc::Rc and std::cell::RefCell. cargo check shows suggestions correctly, so it's purely rust-analyzer problem.

rust-analyzer version: 0.3.1815-standalone

rustc version: 1.75.0 (82e1608df 2023-12-21)

@Cerber-Ursi Cerber-Ursi added the C-bug Category: bug label Jan 27, 2024
@Cerber-Ursi
Copy link
Author

Actually, this might be something on rustc side too - rust-lang/rust#120416.

@Veykril
Copy link
Member

Veykril commented Jan 27, 2024

is this specifically about the quickfix for the dignostic or is this about rust-analyzer's import assist? If the former then that's a rustc issue as you pointed out. If the latter has the same problem it's also rust-analyzer related

@Cerber-Ursi
Copy link
Author

Do you mean that quickfix here comes from rustc and not from the rust-analyzer itself? It was importing types from rhai even with rustc correctly suggesting std types.

@lnicola
Copy link
Member

lnicola commented Jan 27, 2024

If you're unsure, try it with "rust-analyzer.checkOnSave": false.

@Cerber-Ursi
Copy link
Author

Cerber-Ursi commented Jan 27, 2024

Just tried without checkOnSave - no red squiggle (as expected, I guess?), but RA quickfix still suggests rhai type aliases and not the actual types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

3 participants