`where` in `type` is unavailable. Whether it decision or error?


#1
pub trait Target {}

pub type Action<T> = Box<FnOnce(&mut T)>
    where T: Target;

Output

src\lib.rs:4:5: 4:10 error: expected one of `!`, `+`, `::`, or `;`, found `where` 
src\lib.rs:4     where T: Target;
                 ^~~~~

I wonder is it correct or bug?


#2

Rust currently doesn’t enforce trait bounds in type declarations. If you wrote that pub type Action<T: Target>, you’d get this warning, which explains it: https://doc.rust-lang.org/error-index.html#E0122

As far as I know this feature could be added some day, but right now it doesn’t exist.

But since it doesn’t do anything, there’s no reason to allow where clauses on type declarations right now.


#3

I know that it emits a warning. It should allow where like in <>. I don’t see any reasons why it is forbidden.


#4

Its excluded because it doesn’t do anything and it was easy to exclude (<T: Trait> should probably have been excluded to, but it would have been a more complicated change to the grammar than excluding where clauses is). If/when this feature is added, it should be included, but I don’t see why rustc should maintain a grammatical form that is at best pointless and at worst very misleading.