@@ -2109,6 +2109,66 @@ E0380: r##"
2109
2109
Default impls are only allowed for traits with no methods or associated items.
2110
2110
For more information see the [opt-in builtin traits RFC](https://github.com/rust
2111
2111
-lang/rfcs/blob/master/text/0019-opt-in-builtin-traits.md).
2112
+ "## ,
2113
+
2114
+ E0392 : r##"
2115
+ This error indicates that a type or lifetime parameter has been declared
2116
+ but not actually used. Here is an example that demonstrates the error:
2117
+
2118
+ ```
2119
+ enum Foo<T> {
2120
+ Bar
2121
+ }
2122
+ ```
2123
+
2124
+ If the type parameter was included by mistake, this error can be fixed
2125
+ by simply removing the type parameter, as shown below:
2126
+
2127
+ ```
2128
+ enum Foo {
2129
+ Bar
2130
+ }
2131
+ ```
2132
+
2133
+ Alternatively, if the type parameter was intentionally inserted, it must be
2134
+ used. A simple fix is shown below:
2135
+
2136
+ ```
2137
+ enum Foo<T> {
2138
+ Bar(T)
2139
+ }
2140
+ ```
2141
+
2142
+ This error may also commonly be found when working with unsafe code. For
2143
+ example, when using raw pointers one may wish to specify the lifetime for
2144
+ which the pointed-at data is valid. An initial attempt (below) causes this
2145
+ error:
2146
+
2147
+ ```
2148
+ struct Foo<'a, T> {
2149
+ x: *const T
2150
+ }
2151
+ ```
2152
+
2153
+ We want to express the constraint that Foo should not outlive `'a`, because
2154
+ the data pointed to by `T` is only valid for that lifetime. The problem is
2155
+ that there are no actual uses of `'a`. It's possible to work around this
2156
+ by adding a PhantomData type to the struct, using it to tell the compiler
2157
+ to act as if the struct contained a borrowed reference `&'a T`:
2158
+
2159
+ ```
2160
+ use std::marker::PhantomData;
2161
+
2162
+ struct Foo<'a, T: 'a> {
2163
+ x: *const T,
2164
+ phantom: PhantomData<&'a T>
2165
+ }
2166
+ ```
2167
+
2168
+ PhantomData can also be used to express information about unused type
2169
+ parameters. You can read more about it in the API documentation:
2170
+
2171
+ https://doc.rust-lang.org/std/marker/struct.PhantomData.html
2112
2172
"##
2113
2173
2114
2174
}
@@ -2211,7 +2271,6 @@ register_diagnostics! {
2211
2271
E0390 , // only a single inherent implementation marked with
2212
2272
// `#[lang = \"{}\"]` is allowed for the `{}` primitive
2213
2273
E0391 , // unsupported cyclic reference between types/traits detected
2214
- E0392 , // parameter `{}` is never used
2215
2274
E0393 , // the type parameter `{}` must be explicitly specified in an object
2216
2275
// type because its default value `{}` references the type `Self`"
2217
2276
E0399 , // trait items need to be implemented because the associated
0 commit comments