Skip to content

Type ascription typo yields unclear error message #60933

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.

Activity

  1. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on May 18, 2019
  2. estebank commented on May 18, 2019

    @estebank
    Contributor
  3. estebank commented on Jul 18, 2019

    @estebank
    Contributor

    Duplicate of #54516

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

  4. added a commit that references this issue on Jul 21, 2019
    38532ae
  5. added a commit that references this issue on Jul 23, 2019
    ab7149b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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