-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Implement RFC-2011 (Nicer assert!
messages)
#96496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+1,161
−91
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 7 additions & 7 deletions
14
...est/ui/macros/assert-trailing-junk.stderr → ...t-trailing-junk.with-generic-asset.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/test/ui/macros/assert-trailing-junk.without-generic-asset.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
error: expected one of `,`, `.`, `?`, or an operator, found `some` | ||
--> $DIR/assert-trailing-junk.rs:9:18 | ||
| | ||
LL | assert!(true some extra junk, "whatever"); | ||
| ^^^^ expected one of `,`, `.`, `?`, or an operator | ||
|
||
error: expected one of `,`, `.`, `?`, or an operator, found `some` | ||
--> $DIR/assert-trailing-junk.rs:12:18 | ||
| | ||
LL | assert!(true some extra junk); | ||
| ^^^^ expected one of `,`, `.`, `?`, or an operator | ||
|
||
error: no rules expected the token `blah` | ||
--> $DIR/assert-trailing-junk.rs:15:30 | ||
| | ||
LL | assert!(true, "whatever" blah); | ||
| -^^^^ no rules expected this token in macro call | ||
| | | ||
| help: missing comma here | ||
|
||
error: unexpected string literal | ||
--> $DIR/assert-trailing-junk.rs:18:18 | ||
| | ||
LL | assert!(true "whatever" blah); | ||
| -^^^^^^^^^^ | ||
| | | ||
| help: try adding a comma | ||
|
||
error: no rules expected the token `blah` | ||
--> $DIR/assert-trailing-junk.rs:18:29 | ||
| | ||
LL | assert!(true "whatever" blah); | ||
| -^^^^ no rules expected this token in macro call | ||
| | | ||
| help: missing comma here | ||
|
||
error: macro requires an expression as an argument | ||
--> $DIR/assert-trailing-junk.rs:22:5 | ||
| | ||
LL | assert!(true;); | ||
| ^^^^^^^^^^^^-^ | ||
| | | ||
| help: try removing semicolon | ||
|
||
error: unexpected string literal | ||
--> $DIR/assert-trailing-junk.rs:25:27 | ||
| | ||
LL | assert!(false || true "error message"); | ||
| -^^^^^^^^^^^^^^^ | ||
| | | ||
| help: try adding a comma | ||
|
||
error: aborting due to 7 previous errors | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
src/test/ui/macros/assert.stderr → ...i/macros/assert.with-generic-asset.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
error: macro requires a boolean expression as an argument | ||
--> $DIR/assert.rs:5:5 | ||
| | ||
LL | assert!(); | ||
| ^^^^^^^^^ boolean expression required | ||
|
||
error: expected expression, found keyword `struct` | ||
--> $DIR/assert.rs:6:13 | ||
| | ||
LL | assert!(struct); | ||
| ^^^^^^ expected expression | ||
|
||
error: macro requires a boolean expression as an argument | ||
--> $DIR/assert.rs:7:5 | ||
| | ||
LL | debug_assert!(); | ||
| ^^^^^^^^^^^^^^^ boolean expression required | ||
| | ||
= note: this error originates in the macro `debug_assert` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: expected expression, found keyword `struct` | ||
--> $DIR/assert.rs:8:19 | ||
| | ||
LL | debug_assert!(struct); | ||
| ^^^^^^ expected expression | ||
|
||
error: aborting due to 4 previous errors | ||
|
188 changes: 188 additions & 0 deletions
188
src/test/ui/rfc-2011-nicer-assert-messages/all-expr-kinds.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
// aux-build:common.rs | ||
// edition:2021 | ||
// ignore-tidy-linelength | ||
// run-pass | ||
|
||
#![allow(path_statements, unused_allocation)] | ||
#![feature(box_syntax, core_intrinsics, generic_assert, generic_assert_internals)] | ||
|
||
extern crate common; | ||
|
||
// Use common::test once https://github.com/rust-lang/rust/issues/96997 is fixed | ||
macro_rules! test { | ||
( | ||
let mut $elem_ident:ident = $elem_expr:expr; | ||
[ $($assert:tt)* ] => $msg:literal | ||
) => { | ||
{ | ||
#[allow(unused_assignments, unused_mut, unused_variables)] | ||
let rslt = std::panic::catch_unwind(|| { | ||
let mut $elem_ident = $elem_expr; | ||
assert!($($assert)*); | ||
}); | ||
let err = rslt.unwrap_err(); | ||
if let Some(elem) = err.downcast_ref::<String>() { | ||
assert_eq!(elem, &$msg); | ||
} | ||
else if let Some(elem) = err.downcast_ref::<&str>() { | ||
assert_eq!(elem, &$msg); | ||
} | ||
else { | ||
panic!("assert!( ... ) should return a string"); | ||
} | ||
} | ||
} | ||
} | ||
|
||
macro_rules! tests { | ||
( | ||
let mut $elem_ident:ident = $elem_expr:expr; | ||
|
||
$( | ||
[ $($elem_assert:tt)* ] => $elem_msg:literal | ||
)+ | ||
) => { | ||
$( | ||
test!( | ||
let mut $elem_ident = $elem_expr; | ||
[ $($elem_assert)* ] => $elem_msg | ||
); | ||
)+ | ||
} | ||
} | ||
|
||
const FOO: Foo = Foo { bar: 1 }; | ||
|
||
#[derive(Clone, Copy, Debug, PartialEq)] | ||
struct Foo { | ||
bar: i32 | ||
} | ||
|
||
impl Foo { | ||
fn add(&self, a: i32, b: i32) -> i32 { a + b } | ||
} | ||
|
||
fn add(a: i32, b: i32) -> i32 { a + b } | ||
|
||
fn main() { | ||
// ***** Allowed ***** | ||
|
||
tests!( | ||
let mut elem = 1i32; | ||
|
||
// addr of | ||
[ &elem == &3 ] => "Assertion failed: &elem == &3\nWith captures:\n elem = 1\n" | ||
|
||
// array | ||
[ [elem][0] == 3 ] => "Assertion failed: [elem][0] == 3\nWith captures:\n elem = 1\n" | ||
|
||
// binary | ||
[ elem + 1 == 3 ] => "Assertion failed: elem + 1 == 3\nWith captures:\n elem = 1\n" | ||
|
||
// call | ||
[ add(elem, elem) == 3 ] => "Assertion failed: add(elem, elem) == 3\nWith captures:\n elem = 1\n" | ||
|
||
// cast | ||
[ elem as i32 == 3 ] => "Assertion failed: elem as i32 == 3\nWith captures:\n elem = 1\n" | ||
|
||
// index | ||
[ [1i32, 1][elem as usize] == 3 ] => "Assertion failed: [1i32, 1][elem as usize] == 3\nWith captures:\n elem = 1\n" | ||
|
||
// method call | ||
[ FOO.add(elem, elem) == 3 ] => "Assertion failed: FOO.add(elem, elem) == 3\nWith captures:\n elem = 1\n" | ||
|
||
// paren | ||
[ (elem) == 3 ] => "Assertion failed: (elem) == 3\nWith captures:\n elem = 1\n" | ||
|
||
// range | ||
[ (0..elem) == (0..3) ] => "Assertion failed: (0..elem) == (0..3)\nWith captures:\n elem = 1\n" | ||
|
||
// repeat | ||
[ [elem; 1] == [3; 1] ] => "Assertion failed: [elem; 1] == [3; 1]\nWith captures:\n elem = 1\n" | ||
|
||
// struct | ||
[ Foo { bar: elem } == Foo { bar: 3 } ] => "Assertion failed: Foo { bar: elem } == Foo { bar: 3 }\nWith captures:\n elem = 1\n" | ||
|
||
// tuple | ||
[ (elem, 1) == (3, 3) ] => "Assertion failed: (elem, 1) == (3, 3)\nWith captures:\n elem = 1\n" | ||
|
||
// unary | ||
[ -elem == -3 ] => "Assertion failed: -elem == -3\nWith captures:\n elem = 1\n" | ||
); | ||
|
||
// ***** Disallowed ***** | ||
|
||
tests!( | ||
let mut elem = 1i32; | ||
|
||
// assign | ||
[ { let local = elem; local } == 3 ] => "Assertion failed: { let local = elem; local } == 3" | ||
|
||
// assign op | ||
[ { elem += 1; elem } == 3 ] => "Assertion failed: { elem += 1; elem } == 3" | ||
|
||
// async | ||
[ { let _ = async { elem }; elem } == 3 ] => "Assertion failed: { let _ = async { elem }; elem } == 3" | ||
|
||
// await | ||
|
||
// block | ||
[ { elem } == 3 ] => "Assertion failed: { elem } == 3" | ||
|
||
// box | ||
[ box elem == box 3 ] => "Assertion failed: box elem == box 3" | ||
|
||
// break | ||
[ loop { break elem; } == 3 ] => "Assertion failed: loop { break elem; } == 3" | ||
|
||
// closure | ||
[(|| elem)() == 3 ] => "Assertion failed: (|| elem)() == 3" | ||
|
||
// const block | ||
|
||
// continue | ||
|
||
// err | ||
|
||
// field | ||
[ FOO.bar == 3 ] => "Assertion failed: FOO.bar == 3" | ||
|
||
// for loop | ||
[ { for _ in 0..elem { elem; } elem } == 3 ] => "Assertion failed: { for _ in 0..elem { elem; } elem } == 3" | ||
|
||
// if | ||
[ if true { elem } else { elem } == 3 ] => "Assertion failed: if true { elem } else { elem } == 3" | ||
|
||
// inline asm | ||
|
||
// let | ||
[ if let true = true { elem } else { elem } == 3 ] => "Assertion failed: if let true = true { elem } else { elem } == 3" | ||
|
||
// lit | ||
|
||
// loop | ||
[ loop { elem; break elem; } == 3 ] => "Assertion failed: loop { elem; break elem; } == 3" | ||
|
||
// mac call | ||
|
||
// match | ||
[ match elem { _ => elem } == 3 ] => "Assertion failed: match elem { _ => elem, } == 3" | ||
|
||
// ret | ||
[ (|| { return elem; })() == 3 ] => "Assertion failed: (|| { return elem; })() == 3" | ||
|
||
// try | ||
[ (|| { Some(Some(elem)?) })() == Some(3) ] => "Assertion failed: (|| { Some(Some(elem)?) })() == Some(3)" | ||
|
||
// try block | ||
|
||
// underscore | ||
|
||
// while | ||
[ { while false { elem; break; } elem } == 3 ] => "Assertion failed: { while false { elem; break; } elem } == 3" | ||
|
||
// yeet | ||
|
||
// yield | ||
); | ||
} |
42 changes: 42 additions & 0 deletions
42
src/test/ui/rfc-2011-nicer-assert-messages/all-not-available-cases.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// aux-build:common.rs | ||
// ignore-tidy-linelength | ||
// run-pass | ||
|
||
#![feature(core_intrinsics, generic_assert, generic_assert_internals)] | ||
|
||
extern crate common; | ||
|
||
#[derive(Clone, Copy, PartialEq)] | ||
struct CopyNoDebug(i32); | ||
|
||
#[derive(Debug, PartialEq)] | ||
struct NoCopyDebug(i32); | ||
|
||
#[derive(PartialEq)] | ||
struct NoCopyNoDebug(i32); | ||
|
||
fn main() { | ||
// Has Copy but does not have Debug | ||
common::test!( | ||
let mut copy_no_debug = CopyNoDebug(1); | ||
[ copy_no_debug == CopyNoDebug(3) ] => "Assertion failed: copy_no_debug == CopyNoDebug(3)\nWith captures:\n copy_no_debug = N/A\n" | ||
); | ||
|
||
// Does not have Copy but has Debug | ||
common::test!( | ||
let mut no_copy_debug = NoCopyDebug(1); | ||
[ no_copy_debug == NoCopyDebug(3) ] => "Assertion failed: no_copy_debug == NoCopyDebug(3)\nWith captures:\n no_copy_debug = N/A\n" | ||
); | ||
|
||
// Does not have Copy and does not have Debug | ||
common::test!( | ||
let mut no_copy_no_debug = NoCopyNoDebug(1); | ||
[ no_copy_no_debug == NoCopyNoDebug(3) ] => "Assertion failed: no_copy_no_debug == NoCopyNoDebug(3)\nWith captures:\n no_copy_no_debug = N/A\n" | ||
); | ||
|
||
// Unevaluated (Expression short-circuited) | ||
common::test!( | ||
let mut elem = true; | ||
[ false && elem ] => "Assertion failed: false && elem\nWith captures:\n elem = N/A\n" | ||
); | ||
} |
13 changes: 13 additions & 0 deletions
13
...-2011-nicer-assert-messages/assert-with-custom-errors-does-not-create-unnecessary-code.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// compile-flags: --test | ||
// run-pass | ||
|
||
#![feature(core_intrinsics, generic_assert, generic_assert_internals)] | ||
|
||
#[should_panic(expected = "OMG!")] | ||
#[test] | ||
fn test() { | ||
assert!(1 == 3, "OMG!"); | ||
} | ||
|
||
fn main() { | ||
} |
13 changes: 13 additions & 0 deletions
13
...fc-2011-nicer-assert-messages/assert-without-captures-does-not-create-unnecessary-code.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// aux-build:common.rs | ||
// run-pass | ||
|
||
#![feature(core_intrinsics, generic_assert, generic_assert_internals)] | ||
|
||
extern crate common; | ||
|
||
fn main() { | ||
common::test!( | ||
let mut _nothing = (); | ||
[ 1 == 3 ] => "Assertion failed: 1 == 3" | ||
); | ||
} |
25 changes: 25 additions & 0 deletions
25
src/test/ui/rfc-2011-nicer-assert-messages/auxiliary/common.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#[macro_export] | ||
macro_rules! test { | ||
( | ||
let mut $elem_ident:ident = $elem_expr:expr; | ||
[ $($assert:tt)* ] => $msg:literal | ||
) => { | ||
{ | ||
#[allow(unused_assignments, unused_mut, unused_variables)] | ||
let rslt = std::panic::catch_unwind(|| { | ||
let mut $elem_ident = $elem_expr; | ||
assert!($($assert)*); | ||
}); | ||
let err = rslt.unwrap_err(); | ||
if let Some(elem) = err.downcast_ref::<String>() { | ||
assert_eq!(elem, &$msg); | ||
} | ||
else if let Some(elem) = err.downcast_ref::<&str>() { | ||
assert_eq!(elem, &$msg); | ||
} | ||
else { | ||
panic!("assert!( ... ) should return a string"); | ||
} | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/test/ui/rfc-2011-nicer-assert-messages/feature-gate-generic_assert.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// compile-flags: --test | ||
// ignore-tidy-linelength | ||
// run-pass | ||
oli-obk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#![feature(core_intrinsics, generic_assert, generic_assert_internals)] | ||
|
||
use std::fmt::{Debug, Formatter}; | ||
|
||
#[derive(Clone, Copy, PartialEq)] | ||
struct CopyDebug(i32); | ||
|
||
impl Debug for CopyDebug { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), std::fmt::Error> { | ||
f.write_str("With great power comes great electricity bills") | ||
} | ||
} | ||
|
||
#[should_panic(expected = "Assertion failed: copy_debug == CopyDebug(3)\nWith captures:\n copy_debug = With great power comes great electricity bills\n")] | ||
#[test] | ||
fn test() { | ||
let copy_debug = CopyDebug(1); | ||
assert!(copy_debug == CopyDebug(3)); | ||
} | ||
|
||
fn main() { | ||
} |
32 changes: 32 additions & 0 deletions
32
src/test/ui/rfc-2011-nicer-assert-messages/non-consuming-methods-have-optimized-codegen.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// check-pass | ||
// compile-flags: -Z unpretty=expanded | ||
|
||
#![feature(core_intrinsics, generic_assert, generic_assert_internals)] | ||
|
||
fn arbitrary_consuming_method_for_demonstration_purposes() { | ||
let elem = 1i32; | ||
assert!(elem as usize); | ||
} | ||
|
||
fn addr_of() { | ||
let elem = 1i32; | ||
assert!(&elem); | ||
} | ||
|
||
fn binary() { | ||
let elem = 1i32; | ||
assert!(elem == 1); | ||
assert!(elem >= 1); | ||
assert!(elem > 0); | ||
assert!(elem < 3); | ||
assert!(elem <= 3); | ||
assert!(elem != 3); | ||
} | ||
|
||
fn unary() { | ||
let elem = &1i32; | ||
assert!(*elem); | ||
} | ||
|
||
fn main() { | ||
} |
147 changes: 147 additions & 0 deletions
147
...est/ui/rfc-2011-nicer-assert-messages/non-consuming-methods-have-optimized-codegen.stdout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
#![feature(prelude_import)] | ||
#![no_std] | ||
// check-pass | ||
// compile-flags: -Z unpretty=expanded | ||
|
||
#![feature(core_intrinsics, generic_assert, generic_assert_internals)] | ||
#[prelude_import] | ||
use ::std::prelude::rust_2015::*; | ||
#[macro_use] | ||
extern crate std; | ||
|
||
fn arbitrary_consuming_method_for_demonstration_purposes() { | ||
let elem = 1i32; | ||
{ | ||
#[allow(unused_imports)] | ||
use ::core::asserting::{TryCaptureGeneric, TryCapturePrintable}; | ||
let mut __capture0 = ::core::asserting::Capture::new(); | ||
let __local_bind0 = &elem; | ||
if ::core::intrinsics::unlikely(!(*{ | ||
(&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); | ||
__local_bind0 | ||
} as usize)) { | ||
|
||
|
||
|
||
|
||
{ | ||
::std::rt::panic_fmt(::core::fmt::Arguments::new_v1(&["Assertion failed: elem as usize\nWith captures:\n elem = ", | ||
"\n"], &[::core::fmt::ArgumentV1::new_debug(&__capture0)])) | ||
} | ||
} | ||
}; | ||
} | ||
fn addr_of() { | ||
let elem = 1i32; | ||
{ | ||
#[allow(unused_imports)] | ||
use ::core::asserting::{TryCaptureGeneric, TryCapturePrintable}; | ||
let mut __capture0 = ::core::asserting::Capture::new(); | ||
let __local_bind0 = &elem; | ||
if ::core::intrinsics::unlikely(!&*__local_bind0) { | ||
(&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); | ||
{ | ||
::std::rt::panic_fmt(::core::fmt::Arguments::new_v1(&["Assertion failed: &elem\nWith captures:\n elem = ", | ||
"\n"], &[::core::fmt::ArgumentV1::new_debug(&__capture0)])) | ||
} | ||
} | ||
}; | ||
} | ||
fn binary() { | ||
let elem = 1i32; | ||
{ | ||
#[allow(unused_imports)] | ||
use ::core::asserting::{TryCaptureGeneric, TryCapturePrintable}; | ||
let mut __capture0 = ::core::asserting::Capture::new(); | ||
let __local_bind0 = &elem; | ||
if ::core::intrinsics::unlikely(!(*__local_bind0 == 1)) { | ||
(&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); | ||
{ | ||
::std::rt::panic_fmt(::core::fmt::Arguments::new_v1(&["Assertion failed: elem == 1\nWith captures:\n elem = ", | ||
"\n"], &[::core::fmt::ArgumentV1::new_debug(&__capture0)])) | ||
} | ||
} | ||
}; | ||
{ | ||
#[allow(unused_imports)] | ||
use ::core::asserting::{TryCaptureGeneric, TryCapturePrintable}; | ||
let mut __capture0 = ::core::asserting::Capture::new(); | ||
let __local_bind0 = &elem; | ||
if ::core::intrinsics::unlikely(!(*__local_bind0 >= 1)) { | ||
(&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); | ||
{ | ||
::std::rt::panic_fmt(::core::fmt::Arguments::new_v1(&["Assertion failed: elem >= 1\nWith captures:\n elem = ", | ||
"\n"], &[::core::fmt::ArgumentV1::new_debug(&__capture0)])) | ||
} | ||
} | ||
}; | ||
{ | ||
#[allow(unused_imports)] | ||
use ::core::asserting::{TryCaptureGeneric, TryCapturePrintable}; | ||
let mut __capture0 = ::core::asserting::Capture::new(); | ||
let __local_bind0 = &elem; | ||
if ::core::intrinsics::unlikely(!(*__local_bind0 > 0)) { | ||
(&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); | ||
{ | ||
::std::rt::panic_fmt(::core::fmt::Arguments::new_v1(&["Assertion failed: elem > 0\nWith captures:\n elem = ", | ||
"\n"], &[::core::fmt::ArgumentV1::new_debug(&__capture0)])) | ||
} | ||
} | ||
}; | ||
{ | ||
#[allow(unused_imports)] | ||
use ::core::asserting::{TryCaptureGeneric, TryCapturePrintable}; | ||
let mut __capture0 = ::core::asserting::Capture::new(); | ||
let __local_bind0 = &elem; | ||
if ::core::intrinsics::unlikely(!(*__local_bind0 < 3)) { | ||
(&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); | ||
{ | ||
::std::rt::panic_fmt(::core::fmt::Arguments::new_v1(&["Assertion failed: elem < 3\nWith captures:\n elem = ", | ||
"\n"], &[::core::fmt::ArgumentV1::new_debug(&__capture0)])) | ||
} | ||
} | ||
}; | ||
{ | ||
#[allow(unused_imports)] | ||
use ::core::asserting::{TryCaptureGeneric, TryCapturePrintable}; | ||
let mut __capture0 = ::core::asserting::Capture::new(); | ||
let __local_bind0 = &elem; | ||
if ::core::intrinsics::unlikely(!(*__local_bind0 <= 3)) { | ||
(&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); | ||
{ | ||
::std::rt::panic_fmt(::core::fmt::Arguments::new_v1(&["Assertion failed: elem <= 3\nWith captures:\n elem = ", | ||
"\n"], &[::core::fmt::ArgumentV1::new_debug(&__capture0)])) | ||
} | ||
} | ||
}; | ||
{ | ||
#[allow(unused_imports)] | ||
use ::core::asserting::{TryCaptureGeneric, TryCapturePrintable}; | ||
let mut __capture0 = ::core::asserting::Capture::new(); | ||
let __local_bind0 = &elem; | ||
if ::core::intrinsics::unlikely(!(*__local_bind0 != 3)) { | ||
(&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); | ||
{ | ||
::std::rt::panic_fmt(::core::fmt::Arguments::new_v1(&["Assertion failed: elem != 3\nWith captures:\n elem = ", | ||
"\n"], &[::core::fmt::ArgumentV1::new_debug(&__capture0)])) | ||
} | ||
} | ||
}; | ||
} | ||
fn unary() { | ||
let elem = &1i32; | ||
{ | ||
#[allow(unused_imports)] | ||
use ::core::asserting::{TryCaptureGeneric, TryCapturePrintable}; | ||
let mut __capture0 = ::core::asserting::Capture::new(); | ||
let __local_bind0 = &elem; | ||
if ::core::intrinsics::unlikely(!**__local_bind0) { | ||
(&::core::asserting::Wrapper(__local_bind0)).try_capture(&mut __capture0); | ||
{ | ||
::std::rt::panic_fmt(::core::fmt::Arguments::new_v1(&["Assertion failed: *elem\nWith captures:\n elem = ", | ||
"\n"], &[::core::fmt::ArgumentV1::new_debug(&__capture0)])) | ||
} | ||
} | ||
}; | ||
} | ||
fn main() {} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.