From c5a4e074f052d0528451035df58c0f612ee45118 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Mon, 22 Jan 2024 16:14:17 +0100 Subject: [PATCH] Use `-> !` to test divergence --- tests/ui/rfcs/rfc-0000-never_patterns/diverges.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/ui/rfcs/rfc-0000-never_patterns/diverges.rs b/tests/ui/rfcs/rfc-0000-never_patterns/diverges.rs index 6f4b81b9b25b0..57151e246ff56 100644 --- a/tests/ui/rfcs/rfc-0000-never_patterns/diverges.rs +++ b/tests/ui/rfcs/rfc-0000-never_patterns/diverges.rs @@ -9,21 +9,24 @@ enum Void {} // A never pattern alone diverges. -fn never_arg(!: Void) -> u32 {} +fn never_arg(!: Void) -> ! {} -fn ref_never_arg(&!: &Void) -> u32 {} +fn never_arg_returns_anything(!: Void) -> T {} -fn never_let() -> u32 { +fn ref_never_arg(&!: &Void) -> ! {} + +fn never_let() -> ! { let ptr: *const Void = std::ptr::null(); unsafe { let ! = *ptr; } } -fn never_match() -> u32 { +fn never_match() -> ! { let ptr: *const Void = std::ptr::null(); unsafe { match *ptr { ! }; } - println!(); // Ensures this typechecks because of divergence. + // Ensures this typechecks because of divergence and not the type of the match expression. + println!(); }