File tree Expand file tree Collapse file tree 1 file changed +35
-1
lines changed Expand file tree Collapse file tree 1 file changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -207,7 +207,41 @@ https://doc.rust-lang.org/reference.html#statements
207207E0317 : r##"
208208User-defined types or type parameters cannot shadow the primitive types.
209209This error indicates you tried to define a type, struct or enum with the same
210- name as an existing primitive type.
210+ name as an existing primitive type:
211+
212+ ```
213+ struct u8 {
214+ // ...
215+ }
216+ ```
217+
218+ To fix this, simply name it something else.
219+
220+ Such an error may also occur if you define a type parameter which shadows a
221+ primitive type. An example would be something like:
222+
223+ ```
224+ impl<u8> MyTrait for Option<u8> {
225+ // ...
226+ }
227+ ```
228+
229+ In such a case, if you meant for `u8` to be a generic type parameter (i.e. any
230+ type can be used in its place), use something like `T` instead:
231+
232+ ```
233+ impl<T> MyTrait for Option<T> {
234+ // ...
235+ }
236+ ```
237+
238+ On the other hand, if you wished to refer to the specific type `u8`, remove it
239+ from the type parameter list:
240+
241+ ```
242+ impl MyTrait for Option<u8> {
243+ // ...
244+ }
211245
212246See the Types section of the reference for more information about the primitive
213247types:
You can’t perform that action at this time.
0 commit comments