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

Rust analyzer fails to recognize impl<T:Any + Debug> with error "expected &dyn AnyDebug, found &T" #17334

Closed
codecnotsupported opened this issue Jun 2, 2024 · 2 comments
Labels
C-bug Category: bug

Comments

@codecnotsupported
Copy link

codecnotsupported commented Jun 2, 2024

rust-analyzer version:
rust-analyzer version: 0.4.1981-standalone
rustc version:
rustc 1.80.0-nightly (bdbbb6c6a 2024-05-26)
editor or extension:
VSCodium
relevant settings:
N/A
repository link (if public, optional):
N/A
code snippet to reproduce:
This compiles without warning. But Gives a error in rust-analyzer.

use std::any::Any;
use std::fmt::Debug;


pub trait AnyDebug: Any + Debug {}
impl<T:Any + Debug> AnyDebug for T {}

fn main(){
    
    let variable: &dyn AnyDebug = &1; // expected &dyn AnyDebug, found &i32 rust-analyzer[E0308]
    dbg!(variable);

}
@codecnotsupported codecnotsupported added the C-bug Category: bug label Jun 2, 2024
@codecnotsupported
Copy link
Author

codecnotsupported commented Jun 2, 2024

As a temporary workaround, the error goes away if you write it as:

let variable = &1 as &dyn AnyDebug;

@lnicola
Copy link
Member

lnicola commented Jun 2, 2024

Probably a duplicate of #11847.

@lnicola lnicola closed this as completed Jun 2, 2024
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

2 participants