Skip to content

Cannot use where clauses in a tuple struct  #106439

Closed
@gamma-delta

Description

@gamma-delta

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

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions