about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2019-04-21 15:57:00 -0700
committerEsteban Küber <esteban@kuber.com.ar>2019-04-29 14:38:26 -0700
commit4e84b619f4618a11e9be62379a60aebc7455a547 (patch)
tree0d51c281f81ff6846fc6679f71a9b131e7ea1f35 /src
parent4b1297baf7b6e9cd4cac83748c483a2f100a59e1 (diff)
downloadrust-4e84b619f4618a11e9be62379a60aebc7455a547.tar.gz
rust-4e84b619f4618a11e9be62379a60aebc7455a547.zip
Add test
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/numeric/len.rs8
-rw-r--r--src/test/ui/numeric/len.stderr13
2 files changed, 21 insertions, 0 deletions
diff --git a/src/test/ui/numeric/len.rs b/src/test/ui/numeric/len.rs
new file mode 100644
index 00000000000..a7254098820
--- /dev/null
+++ b/src/test/ui/numeric/len.rs
@@ -0,0 +1,8 @@
+fn main() {
+    let array = [1, 2, 3];
+    test(array.len()); //~ ERROR mismatched types
+}
+
+fn test(length: u32) {
+    println!("{}", length);
+}
diff --git a/src/test/ui/numeric/len.stderr b/src/test/ui/numeric/len.stderr
new file mode 100644
index 00000000000..5a9349b4c0f
--- /dev/null
+++ b/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());
+   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.