about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorAriel Ben-Yehuda <ariel.byd@gmail.com>2017-12-24 11:40:54 +0200
committerAriel Ben-Yehuda <ariel.byd@gmail.com>2017-12-24 11:40:54 +0200
commit6aca3301491bc11bf403b9abeedcfbd63c2a43fd (patch)
treee0c11781f2539617cceeed6a5d2523ae0a2f5718 /src/test
parentce58d965efda96c97ac92fd61c0da0f3a8e2cb60 (diff)
Handle casts to integer/float variables
These can happen if prior errors disable defaulting.

Fixes #43825.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/cast-errors-issue-43825.rs17
-rw-r--r--src/test/ui/cast-errors-issue-43825.stderr8
2 files changed, 25 insertions, 0 deletions
diff --git a/src/test/ui/cast-errors-issue-43825.rs b/src/test/ui/cast-errors-issue-43825.rs
new file mode 100644
index 00000000000..65b391205e3
--- /dev/null
+++ b/src/test/ui/cast-errors-issue-43825.rs
@@ -0,0 +1,17 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {
+    let error = error; //~ ERROR cannot find value `error`
+
+    // These used to cause errors.
+    0 as f32;
+    0.0 as u32;
+}
diff --git a/src/test/ui/cast-errors-issue-43825.stderr b/src/test/ui/cast-errors-issue-43825.stderr
new file mode 100644
index 00000000000..db0a33e927f
--- /dev/null
+++ b/src/test/ui/cast-errors-issue-43825.stderr
@@ -0,0 +1,8 @@
+error[E0425]: cannot find value `error` in this scope
+  --> $DIR/cast-errors-issue-43825.rs:12:17
+   |
+12 |     let error = error; //~ ERROR cannot find value `error`
+   |                 ^^^^^ not found in this scope
+
+error: aborting due to previous error
+