-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rust will occasionally rely on fn((), X) -> Y being compatible with fn(X) -> Y, since () is a non-passed argument. Relax CFI by choosing not to encode non-passed arguments.
- Loading branch information
Showing
4 changed files
with
38 additions
and
115 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Tests that converting a closure to a function pointer works | ||
// The notable thing being tested here is that when the closure does not capture anything, | ||
// the call method from its Fn trait takes a ZST representing its environment. The compiler then | ||
// uses the assumption that the ZST is non-passed to reify this into a function pointer. | ||
// | ||
// This checks that the reified function pointer will have the expected alias set at its call-site. | ||
|
||
//@ needs-sanitizer-cfi | ||
//@ compile-flags: --crate-type=bin -Cprefer-dynamic=off -Clto -Zsanitizer=cfi | ||
//@ compile-flags:-C codegen-units=1 -C opt-level=0 | ||
//@ run-pass | ||
|
||
pub fn main() { | ||
let f: &fn() = &((|| ()) as _); | ||
f(); | ||
} |