Skip to content

Cannot use where clauses in a tuple struct #106439

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

Closed
gamma-delta opened this issue Jan 4, 2023 · 4 comments
Closed

Cannot use where clauses in a tuple struct #106439

gamma-delta opened this issue Jan 4, 2023 · 4 comments
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug.

Comments

@gamma-delta
Copy link

gamma-delta commented Jan 4, 2023

I tried this code:

trait MyTrait {}

struct Foo<T> where T: MyTrait, (T)

I expected to see this happen: It compiles and requires T to implement MyTrait

Instead, this happened: It doesn't compile

Meta

rustc --version --verbose:

rustc 1.67.0-nightly (83356b78c 2022-11-17)
binary: rustc
commit-hash: 83356b78c4ff3e7d84e977aa6143793545967301
commit-date: 2022-11-17
host: x86_64-unknown-linux-gnu
release: 1.67.0-nightly
LLVM version: 15.0.4

"Backtrace" (compiler error)

error: expected one of `:`, `==`, or `=`, found `;`
 --> src/lib.rs:3:36
  |
3 | struct Foo<T> where T: MyTrait, (T);
  |                                    ^ expected one of `:`, `==`, or `=`

Playground Link

@gamma-delta gamma-delta added the C-bug Category: This is a bug. label Jan 4, 2023
@clubby789
Copy link
Contributor

The correct syntax for this is struct Foo<T>(T) where T: MyTrait;

@Noratrieb Noratrieb added the A-diagnostics Area: Messages for errors, warnings, and lints label Jan 4, 2023
@fmease
Copy link
Member

fmease commented Jan 4, 2023

A-diagnostics

Duplicate of #100790.

@rustbot claim

@gamma-delta
Copy link
Author

Can I just say this is one of the reasons I love the Rust project? Instead of getting some blunt "you're doing it wrong" you take the time to understand why I'm doing it wrong, and how to fix it for everyone. :)

@gamma-delta
Copy link
Author

(Oh, I guess I should close this then if it's a duplicate)

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 C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

4 participants