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

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

Closed
vringar opened this issue Aug 10, 2022 · 1 comment · Fixed by #100367
Closed

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

vringar opened this issue Aug 10, 2022 · 1 comment · Fixed by #100367
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

@vringar
Copy link

vringar commented Aug 10, 2022

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]);
  |                         ^^^^++^^^^^
@vringar vringar 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 Aug 10, 2022
@fmease
Copy link
Member

fmease commented Aug 10, 2022

@rustbot claim

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Aug 13, 2022
Suggest the path separator when a dot is used on a trait

Fixes rust-lang#100365.

`@rustbot` label A-diagnostics
r? diagnostics
@bors bors closed this as completed in e248c7f Aug 14, 2022
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