Closed
Description
With the following rust snippet, I get the error message:
$ rustc msg.rs
msg.rs:13:9: 13:12 error: unable to infer enough type information to locate the impl of the trait `core::kinds::Sized` for the type `Foo<<generic integer #0>>`; type annotations required
msg.rs:13 let foo = Foo::new(1);
^~~
msg.rs:13:9: 13:12 note: all local variables must have a statically known size
msg.rs:13 let foo = Foo::new(1);
^~~
error: aborting due to previous error
The issue is caused by having an extra semicolon at the last line of the new fn, but the error message was very confusing and it took me a while to realize that this was the problem.
#[deriving(Show)]
pub struct Foo<T> {
foo: T
}
impl<T> Foo<T> {
fn new(foo: T) -> Foo<T> {
Foo { foo: foo };
}
}
pub fn main() {
let foo = Foo::new(1);
println!("foo = {}", foo);
}
Metadata
Metadata
Assignees
Labels
No labels