Skip to content

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

Closed
@BoxyUwU

Description

@BoxyUwU

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

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions