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

False positive error involving double reference #18061

Closed
Coder-256 opened this issue Sep 6, 2024 · 2 comments
Closed

False positive error involving double reference #18061

Coder-256 opened this issue Sep 6, 2024 · 2 comments
Labels
A-ty type system / type inference / traits / method resolution C-bug Category: bug

Comments

@Coder-256
Copy link
Contributor

I'm getting what appears to be a false-positive error in my IDE, but cargo build succeeds.

rust-analyzer version: 0.3.2096-standalone

rustc version: rustc 1.81.0 (eeb90cda1 2024-09-04)

editor or extension: VS Code 1.93.0, rust-analyzer VS Code extension v0.3.2096

relevant settings: none

repository link (if public, optional): N/A

code snippet to reproduce:

use std::borrow::Borrow;

fn buggy<T: Borrow<Q>, Q: Ord>(a: T, b: &Q) -> std::cmp::Ordering {
    a.borrow().cmp(b)
}

Error:

expected &&{unknown}, found &Q

Screenshot:
Screenshot 2024-09-05 at 9 06 51 PM

Ironically if I do add a reference, it triggers a clippy warning ("this expression creates a reference which is immediately dereferenced by the compiler").

@Coder-256 Coder-256 added the C-bug Category: bug label Sep 6, 2024
@ShoyuVanilla ShoyuVanilla added A-diagnostics diagnostics / error reporting A-ty type system / type inference / traits / method resolution and removed A-diagnostics diagnostics / error reporting labels Sep 6, 2024
@ChayimFriedman2
Copy link
Contributor

Probably #5514.

@Veykril
Copy link
Member

Veykril commented Sep 6, 2024

Dupe of #5514

@Veykril Veykril closed this as not planned Won't fix, can't repro, duplicate, stale Sep 6, 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

4 participants