]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0193.md
Rollup merge of #93556 - dtolnay:trailingcomma, r=cjgillot
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0193.md
1 #### Note: this error code is no longer emitted by the compiler.
2
3 `where` clauses must use generic type parameters: it does not make sense to use
4 them otherwise. An example causing this error:
5
6 ```
7 trait Foo {
8     fn bar(&self);
9 }
10
11 #[derive(Copy,Clone)]
12 struct Wrapper<T> {
13     Wrapped: T
14 }
15
16 impl Foo for Wrapper<u32> where Wrapper<u32>: Clone {
17     fn bar(&self) { }
18 }
19 ```
20
21 This use of a `where` clause is strange - a more common usage would look
22 something like the following:
23
24 ```
25 trait Foo {
26     fn bar(&self);
27 }
28
29 #[derive(Copy,Clone)]
30 struct Wrapper<T> {
31     Wrapped: T
32 }
33 impl <T> Foo for Wrapper<T> where Wrapper<T>: Clone {
34     fn bar(&self) { }
35 }
36 ```
37
38 Here, we're saying that the implementation exists on Wrapper only when the
39 wrapped type `T` implements `Clone`. The `where` clause is important because
40 some types will not implement `Clone`, and thus will not get this method.
41
42 In our erroneous example, however, we're referencing a single concrete type.
43 Since we know for certain that `Wrapper<u32>` implements `Clone`, there's no
44 reason to also specify it in a `where` clause.