Skip to content

Commit

Permalink
Improve E0161 error explanation
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed May 29, 2016
1 parent 4fa8483 commit 31b9060
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/librustc/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,12 +438,11 @@ This error indicates that the compiler found multiple functions with the
`#[start]` attribute. This is an error because there must be a unique entry
point into a Rust program. Example:
```
#![feature(start)]
#[start]
fn foo(argc: isize, argv: *const *const u8) -> isize {} // ok!
fn foo(argc: isize, argv: *const *const u8) -> isize { 0 } // ok!
```
"##,

Expand Down
27 changes: 26 additions & 1 deletion src/librustc_passes/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,36 @@ match 5u32 {
"##,

E0161: r##"
A value was moved. However, its size was not known at compile time, and only
values of a known size can be moved.
Erroneous code example:
```compile_fail
#![feature(box_syntax)]
fn main() {
let array: &[isize] = &[1, 2, 3];
let _x: Box<[isize]> = box *array;
// error: cannot move a value of type [isize]: the size of [isize] cannot
// be statically determined
}
```
In Rust, you can only move a value when its size is known at compile time.
To work around this restriction, consider "hiding" the value behind a reference:
either `&x` or `&mut x`. Since a reference has a fixed size, this lets you move
it around as usual.
it around as usual. Example:
```
#![feature(box_syntax)]
fn main() {
let array: &[isize] = &[1, 2, 3];
let _x: Box<&[isize]> = box array; // ok!
}
```
"##,

E0265: r##"
Expand Down

0 comments on commit 31b9060

Please sign in to comment.