1 A type or lifetime parameter has been declared but is not actually used.
3 Erroneous code example:
11 If the type parameter was included by mistake, this error can be fixed
12 by simply removing the type parameter, as shown below:
20 Alternatively, if the type parameter was intentionally inserted, it must be
21 used. A simple fix is shown below:
29 This error may also commonly be found when working with unsafe code. For
30 example, when using raw pointers one may wish to specify the lifetime for
31 which the pointed-at data is valid. An initial attempt (below) causes this
40 We want to express the constraint that Foo should not outlive `'a`, because
41 the data pointed to by `T` is only valid for that lifetime. The problem is
42 that there are no actual uses of `'a`. It's possible to work around this
43 by adding a PhantomData type to the struct, using it to tell the compiler
44 to act as if the struct contained a borrowed reference `&'a T`:
47 use std::marker::PhantomData;
49 struct Foo<'a, T: 'a> {
51 phantom: PhantomData<&'a T>
55 [PhantomData] can also be used to express information about unused type
58 [PhantomData]: https://doc.rust-lang.org/std/marker/struct.PhantomData.html