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

"use a fully qualified path" picks a random self type #112897

Closed
BoxyUwU opened this issue Jun 21, 2023 · 1 comment · Fixed by #112948
Closed

"use a fully qualified path" picks a random self type #112897

BoxyUwU opened this issue Jun 21, 2023 · 1 comment · Fixed by #112948
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@BoxyUwU
Copy link
Member

BoxyUwU commented Jun 21, 2023

Code

fn main() {
    Default::default() == 1i32;
}

Current output

error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
 --> src/main.rs:2:5
  |
2 |     Default::default() == 1i32;
  |     ^^^^^^^^^^^^^^^^ cannot call associated function of trait
  |
help: use a fully-qualified path to a specific available implementation (273 found)
  |
2 |     <&OsStr as Default>::default() == 1i32;
  |     ++++++++++        +

Desired output

error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
 --> src/main.rs:2:5
  |
2 |     Default::default() == 1i32;
  |     ^^^^^^^^^^^^^^^^ cannot call associated function of trait
  |
help: use a fully-qualified path to a specific available implementation (273 found)
  |
2 |     </* self type */ as Default>::default() == 1i32;
  |     ++++++++++++++++++++       +

Rationale and extra context

if there are 273 possible self types to specify diagnostics should probably not arbitrarily decide what self type i meant since it actually has no idea.

Other cases

No response

Anything else?

Ideally it'd probably actually suggest i32::default() but it might be unreasonable to expect diagnostics to figure that out

@BoxyUwU BoxyUwU added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 21, 2023
@bkrl
Copy link
Contributor

bkrl commented Jun 22, 2023

I'll try working on this as my first contribution.

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants