-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove useless ident() functions in const tests and replace the usefu…
…l ones by black_box (with a comment)
- Loading branch information
Showing
7 changed files
with
57 additions
and
72 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 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 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 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 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 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 |
---|---|---|
@@ -1,15 +1,16 @@ | ||
// run-pass | ||
|
||
#![feature(ptr_internals, test)] | ||
|
||
extern crate test; | ||
use test::black_box as b; // prevent promotion of the argument and const-propagation of the result | ||
|
||
use std::ptr::NonNull; | ||
|
||
const DANGLING: NonNull<u32> = NonNull::dangling(); | ||
const CASTED: NonNull<u32> = NonNull::cast(NonNull::<i32>::dangling()); | ||
|
||
fn ident<T>(ident: T) -> T { | ||
ident | ||
} | ||
|
||
pub fn main() { | ||
assert_eq!(DANGLING, ident(NonNull::dangling())); | ||
assert_eq!(CASTED, ident(NonNull::dangling())); | ||
assert_eq!(DANGLING, b(NonNull::dangling())); | ||
assert_eq!(CASTED, b(NonNull::dangling())); | ||
} |
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 |
---|---|---|
@@ -1,15 +1,15 @@ | ||
// run-pass | ||
|
||
#![feature(ptr_internals)] | ||
#![feature(ptr_internals, test)] | ||
|
||
extern crate test; | ||
use test::black_box as b; // prevent promotion of the argument and const-propagation of the result | ||
|
||
use std::ptr::Unique; | ||
|
||
const PTR: *mut u32 = Unique::empty().as_ptr(); | ||
|
||
fn ident<T>(ident: T) -> T { | ||
ident | ||
} | ||
const PTR: *mut u32 = Unique::empty().as_ptr(); | ||
|
||
pub fn main() { | ||
assert_eq!(PTR, ident(Unique::<u32>::empty().as_ptr())); | ||
assert_eq!(PTR, b(Unique::<u32>::empty()).as_ptr()); | ||
} |