Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Apr 29, 2019
1 parent 4b1297b commit 4e84b61
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/test/ui/numeric/len.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fn main() {
let array = [1, 2, 3];
test(array.len()); //~ ERROR mismatched types
}

fn test(length: u32) {
println!("{}", length);
}
13 changes: 13 additions & 0 deletions src/test/ui/numeric/len.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
error[E0308]: mismatched types
--> $DIR/len.rs:3:10
|
LL | test(array.len());
| ^^^^^^^^^^^ expected u32, found usize
help: you can convert an `usize` to `u32` or panic if it the converted value wouldn't fit
|
LL | test(array.len().try_into().unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.

0 comments on commit 4e84b61

Please sign in to comment.