about summary refs log tree commit diff
path: root/tests/ui/reachable
diff options
context:
space:
mode:
authorWaffle Lapkin <waffle.lapkin@gmail.com>2025-06-01 12:51:17 +0200
committerWaffle Lapkin <waffle.lapkin@gmail.com>2025-08-02 02:03:20 +0200
commita067c6a3c6ac4db7652e1722acf2648ef65b0229 (patch)
treea6ccee10027572cfa663f277be2a10f01bf4991a /tests/ui/reachable
parent4b55fe199cfe9c710555a5af7f2a49491ad38254 (diff)
downloadrust-a067c6a3c6ac4db7652e1722acf2648ef65b0229.tar.gz
rust-a067c6a3c6ac4db7652e1722acf2648ef65b0229.zip
refactor `unreachable/expr_cast.rs` test
Diffstat (limited to 'tests/ui/reachable')
-rw-r--r--tests/ui/reachable/expr_cast.rs15
-rw-r--r--tests/ui/reachable/expr_cast.stderr26
2 files changed, 21 insertions, 20 deletions
diff --git a/tests/ui/reachable/expr_cast.rs b/tests/ui/reachable/expr_cast.rs
index e8e477ea4f6..58ebe2a7b9f 100644
--- a/tests/ui/reachable/expr_cast.rs
+++ b/tests/ui/reachable/expr_cast.rs
@@ -1,13 +1,12 @@
-#![allow(unused_variables)]
-#![allow(unused_assignments)]
-#![allow(dead_code)]
+//@ edition: 2024
 #![deny(unreachable_code)]
-#![feature(never_type, type_ascription)]
 
 fn a() {
-    // the cast is unreachable:
-    let x = {return} as !; //~ ERROR unreachable
-    //~| ERROR non-primitive cast
+    _ = {return} as u32; //~ error: unreachable
 }
 
-fn main() { }
+fn b() {
+    (return) as u32; //~ error: unreachable
+}
+
+fn main() {}
diff --git a/tests/ui/reachable/expr_cast.stderr b/tests/ui/reachable/expr_cast.stderr
index 6643f1784a1..cf711d4436e 100644
--- a/tests/ui/reachable/expr_cast.stderr
+++ b/tests/ui/reachable/expr_cast.stderr
@@ -1,24 +1,26 @@
 error: unreachable expression
-  --> $DIR/expr_cast.rs:9:13
+  --> $DIR/expr_cast.rs:5:9
    |
-LL |     let x = {return} as !;
-   |             ^------^^^^^^
-   |             ||
-   |             |any code following this expression is unreachable
-   |             unreachable expression
+LL |     _ = {return} as u32;
+   |         ^------^^^^^^^^
+   |         ||
+   |         |any code following this expression is unreachable
+   |         unreachable expression
    |
 note: the lint level is defined here
-  --> $DIR/expr_cast.rs:4:9
+  --> $DIR/expr_cast.rs:2:9
    |
 LL | #![deny(unreachable_code)]
    |         ^^^^^^^^^^^^^^^^
 
-error[E0605]: non-primitive cast: `()` as `!`
-  --> $DIR/expr_cast.rs:9:13
+error: unreachable expression
+  --> $DIR/expr_cast.rs:9:5
    |
-LL |     let x = {return} as !;
-   |             ^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object
+LL |     (return) as u32;
+   |     --------^^^^^^^
+   |     |
+   |     unreachable expression
+   |     any code following this expression is unreachable
 
 error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0605`.