Skip to content

Compiler expected where but there is a where #93567

Closed
@aaronddavies

Description

@aaronddavies

I tried this code:

pub trait MyTrait {}
pub trait AnotherTrait<U> {}
pub struct MyStruct<T> where T: AnotherTrait<U> where U: MyTrait {
    t: T,
    u: U,
}

I expected to see this happen: The compiler would give a sensible error.

Instead, this happened: The compiler complains that it expected where where I actually do have where:

error: expected `where`, or `{` after struct name, found keyword `where`
  --> src/main.rs:29:49
   |
29 | pub struct MyStruct<T> where T: AnotherTrait<U> where U: MyTrait {
   |                                                 ^^^^^ expected `where`, or `{` after struct name

Meta

rustc --version --verbose:

rustc 1.59.0-nightly (cfa4ac66c 2022-01-06)
binary: rustc
commit-hash: cfa4ac66c194046f631ce076c75516ecfdeb77ee
commit-date: 2022-01-06
host: x86_64-unknown-linux-gnu
release: 1.59.0-nightly
LLVM version: 13.0.0
Backtrace

Adding RUST_BACKTRACE=1 did not produce any additional output.

Metadata

Metadata

Labels

C-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