We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4b1297b commit 4e84b61Copy full SHA for 4e84b61
src/test/ui/numeric/len.rs
@@ -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
@@ -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());
9
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10
11
+error: aborting due to previous error
12
13
+For more information about this error, try `rustc --explain E0308`.
0 commit comments