Skip to content

Type ascription typo yields unclear error message #60933

Closed
@oli-obk

Description

@oli-obk

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.

Metadata

Metadata

Assignees

No one assigned

    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