Skip to content

Commit 4e84b61

Browse files
committed
Add test
1 parent 4b1297b commit 4e84b61

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/test/ui/numeric/len.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
fn main() {
2+
let array = [1, 2, 3];
3+
test(array.len()); //~ ERROR mismatched types
4+
}
5+
6+
fn test(length: u32) {
7+
println!("{}", length);
8+
}

src/test/ui/numeric/len.stderr

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/len.rs:3:10
3+
|
4+
LL | test(array.len());
5+
| ^^^^^^^^^^^ expected u32, found usize
6+
help: you can convert an `usize` to `u32` or panic if it the converted value wouldn't fit
7+
|
8+
LL | test(array.len().try_into().unwrap());
9+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10+
11+
error: aborting due to previous error
12+
13+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)