Closed
Description
This piece of code gives the following error
use std::path::Path;
pub struct Foo {
id: i32,
path: Path
}
impl Foo {
pub fn new() -> Foo {
Foo{id: 42, path: Path::new()}
}
}
fn main() {
let b = Foo::new();
}
$ rustc test.rs
error[E0277]: the trait bound `[u8]: std::marker::Sized` is not satisfied in `Foo`
--> test.rs:9:21
|
9 | pub fn new() -> Foo {
| ^^^ `[u8]` does not have a constant size known at compile-time
|
= help: within `Foo`, the trait `std::marker::Sized` is not implemented for `[u8]`
= note: required because it appears within the type `Foo`
= note: the return type of a function must have a statically known size
error[E0061]: this function takes 1 parameter but 0 parameters were supplied
--> test.rs:10:27
|
10 | Foo{id: 42, path: Path::new()}
| ^^^^^^^^^^^ expected 1 parameter
error[E0308]: mismatched types
--> test.rs:10:27
|
10 | Foo{id: 42, path: Path::new()}
| ^^^^^^^^^^^ expected struct `std::path::Path`, found reference
|
= note: expected type `std::path::Path`
found type `&std::path::Path`
error[E0277]: the trait bound `[u8]: std::marker::Sized` is not satisfied in `Foo`
--> test.rs:10:9
|
10 | Foo{id: 42, path: Path::new()}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `[u8]` does not have a constant size known at compile-time
|
= help: within `Foo`, the trait `std::marker::Sized` is not implemented for `[u8]`
= note: required because it appears within the type `Foo`
= note: structs must have a statically known size to be initialized
error[E0277]: the trait bound `[u8]: std::marker::Sized` is not satisfied in `Foo`
--> test.rs:15:9
|
15 | let b = Foo::new();
| ^ `[u8]` does not have a constant size known at compile-time
|
= help: within `Foo`, the trait `std::marker::Sized` is not implemented for `[u8]`
= note: required because it appears within the type `Foo`
= note: all local variables must have a statically known size
error: aborting due to previous error(s)
This is a bit confusing since the span points to Foo
but the message says [u8]
. The ergonomics will be nicer if the message said Foo
. It will be easier to debug that way.
Meta:
$ rustc --version
rustc 1.19.0-nightly (76242aebb 2017-06-06)