-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RFC 2011] Optimize non-consuming operators
- Loading branch information
Showing
5 changed files
with
260 additions
and
53 deletions.
There are no files selected for viewing
This file contains 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 was deleted.
Oops, something went wrong.
29 changes: 0 additions & 29 deletions
29
src/test/ui/macros/rfc-2011-nicer-assert-messages/codegen.stdout
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
.../ui/macros/rfc-2011-nicer-assert-messages/non-consuming-methods-have-optimized-codegen.rs
This file contains 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
...macros/rfc-2011-nicer-assert-messages/non-consuming-methods-have-optimized-codegen.stdout
This file contains 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() {} |