Closed
Description
I tried this code:
#![feature(generic_associated_types)]
#![allow(incomplete_features)]
trait Factory {
type Output<'a>;
fn build<'b>(&self, v: &'b u8) -> Self::Output<'b>;
}
#[allow(unused)]
struct Foo<'a, F: Factory> {
f: F::Output<'a>,
}
I got this error:
error[E0392]: parameter `'a` is never used
--> src/lib.rs:10:12
|
10 | struct Foo<'a, F: Factory> {
| ^^ unused parameter
|
= help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData`
I think it doesn't make sense since 'a
is used in the field f
, if I add the PhantomData
like suggested, it works fine.
Meta
rustc --version --verbose
:
rustc 1.51.0-nightly (da305a2b0 2021-01-05)
binary: rustc
commit-hash: da305a2b00530aa34dea4e48389204c26fa35dbb
commit-date: 2021-01-05
host: x86_64-unknown-linux-gnu
release: 1.51.0-nightly