Skip to content

Calling associated methods on traits with . should yield helpful suggestion #100365

Closed
@vringar

Description

@vringar

Given the following code: playground link

use std::net::IpAddr;
fn main() {
   let addr = Into::<IpAddr>.into([127,0,0,1]);
}

The current output is:

Compiling playground v0.0.1 (/playground)
error[[E0423]](https://doc.rust-lang.org/stable/error-index.html#E0423): expected value, found trait `Into`
 --> src/main.rs:3:15
  |
3 |    let addr = Into::<IpAddr>.into([127,0,0,1]);
  |               ^^^^^^^^^^^^^^ not a value

For more information about this error, try `rustc --explain E0423`.
error: could not compile `playground` due to previous error

Ideally the output should look like:

Calling associated methods on a trait is done by using ::
Try:
 --> src/main.rs:3:15
  |
3 |    let addr = Into::<IpAddr>::into([127,0,0,1]);
  |                         ^^^^++^^^^^

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