Skip to content

Type ascription typo yields unclear error message #60933

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
oli-obk opened this issue May 18, 2019 · 2 comments · Fixed by #62791
Closed

Type ascription typo yields unclear error message #60933

oli-obk opened this issue May 18, 2019 · 2 comments · Fixed by #62791
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

@oli-obk
Copy link
Contributor

oli-obk commented May 18, 2019

The following code does not guide the user towards the problem. Especially considering the fact that there's no type ascription feature gate active.

fn main() {
    let u: usize = std::mem:size_of::<u32>();
    //                     ^ note the single colon instead of double
}

(Playground)

Errors:

   Compiling playground v0.0.1 (/playground)
warning: unnecessary path disambiguator
 --> src/main.rs:2:36
  |
2 |     let u: usize = std::mem:size_of::<u32>();
  |                                    ^^ try removing `::`

error: expected one of `!`, `::`, or `;`, found `(`
 --> src/main.rs:2:43
  |
2 |     let u: usize = std::mem:size_of::<u32>();
  |                                           ^ expected one of `!`, `::`, or `;` here

error: aborting due to previous error

error: Could not compile `playground`.

To learn more, run the command again with --verbose.

@oli-obk oli-obk added the A-diagnostics Area: Messages for errors, warnings, and lints label May 18, 2019
@Centril Centril added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label May 18, 2019
@estebank
Copy link
Contributor

Cc #47666, #54516, #34255 and #59150

@estebank
Copy link
Contributor

estebank commented Jul 18, 2019

Duplicate of #54516

It isn't a duplicate. The use of the println macro actually makes a material difference on how this is parsed.

@estebank estebank marked this as a duplicate of #54516 Jul 18, 2019
@estebank estebank reopened this Jul 18, 2019
Centril added a commit to Centril/rust that referenced this issue Jul 21, 2019
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Jul 23, 2019
# for free to join this conversation on GitHub. Already have an account? # 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.

3 participants