-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-type-systemArea: Type systemArea: Type systemC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Testcase:
enum Foo<T> {
F(Option<Box<Foo<Box<T>>>>)
}
fn main() { }
Gives:
<anon>:16:10: 16:11 error: parameter `T` is never used [E0392]
<anon>:16 enum Foo<T> {
^
<anon>:16:10: 16:11 help: consider removing `T` or using a marker such as `core::marker::PhantomData`
Not sure if this is really something rustc should actually support (I imagine trying to prove recursive properties about it is extremely awkward), but the error message makes no sense.
More related testcases:
// Crashes rustc with a stack overflow
use std::marker::PhantomData;
enum Foo<T> {
F(Option<Box<Foo<Box<T>>>>, PhantomData<T>)
}
fn takesfoo<T>(f:&Foo<T>) {
match f {
&Foo::F(Some(ref b), PhantomData) => takesfoo(&**b),
&Foo::F(None, PhantomData) => ()
}
}
fn main() { }
// Gives "error: overflow while adding drop-check rules for Foo<i32>"
use std::marker::PhantomData;
enum Foo<T> {
F(Option<Box<Foo<Box<T>>>>, PhantomData<T>)
}
fn main() { let _f = Foo::F::<i32>(None, PhantomData); }
Metadata
Metadata
Assignees
Labels
A-type-systemArea: Type systemArea: Type systemC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.