mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Add test
This commit is contained in:
parent
4b1297baf7
commit
4e84b619f4
8
src/test/ui/numeric/len.rs
Normal file
8
src/test/ui/numeric/len.rs
Normal file
@ -0,0 +1,8 @@
|
||||
fn main() {
|
||||
let array = [1, 2, 3];
|
||||
test(array.len()); //~ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn test(length: u32) {
|
||||
println!("{}", length);
|
||||
}
|
13
src/test/ui/numeric/len.stderr
Normal file
13
src/test/ui/numeric/len.stderr
Normal file
@ -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`.
|
Loading…
Reference in New Issue
Block a user