-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-trait-systemArea: Trait systemArea: Trait systemC-bugCategory: This is a bug.Category: This is a bug.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
These two code snippets should functionally be doing the same thing, but the type checker seems to think one has a destructor. The difference seems to be in the reliance on an associated type.
rustc
complains that myfoo
cannot be declared a mutable static because it has a desctructor:
pub trait Foo {
type FooAssoc;
}
pub struct Bar<F: Foo> {
id: F::FooAssoc
}
pub struct Baz;
impl Foo for Baz {
type FooAssoc = usize;
}
static mut myfoo : Bar<Baz> = Bar { id: 0 };
While this, unsurprisingly, works:
pub struct Bar<A> {
id: A
}
static mut myfoo : Bar<usize> = Bar { id: 0 };
Here are links to non-compiling/compiling examples on play.rust-lang:
- non-working: http://is.gd/BVUqfJ
- working: http://is.gd/lWbhzw
Metadata
Metadata
Assignees
Labels
A-trait-systemArea: Trait systemArea: Trait systemC-bugCategory: This is a bug.Category: This is a bug.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.