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

Vec<foo::bar:A> (with single :) in a struct field causes misleading errors #94812

Closed
TaKO8Ki opened this issue Mar 10, 2022 · 0 comments · Fixed by #94865
Closed

Vec<foo::bar:A> (with single :) in a struct field causes misleading errors #94812

TaKO8Ki opened this issue Mar 10, 2022 · 0 comments · Fixed by #94865
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

@TaKO8Ki
Copy link
Member

TaKO8Ki commented Mar 10, 2022

Given the following code:

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=43eaa091f27b11807fadff36c41b3945

mod foo {
    mod bar {
        struct A;
    }
}

struct Foo {
  a: Vec<foo::bar:A>,
}

The current output is:

error: expected one of `,` or `>`, found `:`
 [--> src/lib.rs:8:18
](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=c816dd29ce8ce457fbdaa7f0eb66d2d3#)  |
8 |   a: Vec<foo::bar:A>,
  |                  ^ expected one of `,` or `>`
  |
help: expressions must be enclosed in braces to be used as const generic arguments
  |
8 |   a: Vec<{ foo::bar:A }>,
  |          +            +

error[[E0747]](https://doc.rust-lang.org/nightly/error-index.html#E0747): constant provided when a type was expected
 [--> src/lib.rs:8:10
](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=c816dd29ce8ce457fbdaa7f0eb66d2d3#)  |
8 |   a: Vec<foo::bar:A>,
  |          ^^^^^^^^^^

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

Ideally the output should look like:

error[[E0405]](https://doc.rust-lang.org/nightly/error-index.html#E0405): cannot find trait `A` in this scope
 [--> src/lib.rs:6:14
](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=c816dd29ce8ce457fbdaa7f0eb66d2d3#)  |
6 |   a: Vec<foo::bar:A>,
  |                   ^ not found in this scope
  |
help: you might have meant to write a path instead of an associated type bound
  |
6 |   a: Vec<foo::var::A>,
  |                  ~~
@TaKO8Ki TaKO8Ki 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 Mar 10, 2022
@TaKO8Ki TaKO8Ki changed the title Vec<foo::bar:A> (with single ':') in a struct field causes misleading errors Vec<foo::bar:A> (with single ':') in a struct field causes misleading errors Mar 10, 2022
@TaKO8Ki TaKO8Ki changed the title Vec<foo::bar:A> (with single ':') in a struct field causes misleading errors Vec<foo::bar:A> (with single :) in a struct field causes misleading errors Mar 10, 2022
@notriddle notriddle self-assigned this Mar 11, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 12, 2022
…th-not-const-generics, r=cjgillot

diagnostics: single colon within `<>` probably, not type ascription

Fixes rust-lang#94812
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 12, 2022
…-not-const-generics, r=cjgillot

diagnostics: single colon within `<>` probably, not type ascription

Fixes rust-lang#94812
@bors bors closed this as completed in 7e32337 Mar 12, 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