-
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test that externally-defined functions going safe -> unsafe are caugh…
…t. (#1003)
- Loading branch information
1 parent
c0c1cc0
commit a4937e1
Showing
5 changed files
with
102 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
publish = false | ||
name = "safe_vs_unsafe_extern_fn" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
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,29 @@ | ||
#![feature(unsafe_extern_blocks)] // Remove after our lowest tested Rust version is 1.82+. | ||
|
||
unsafe extern "C" { | ||
pub fn originally_legacy_now_unsafe_extern_and_implicit_unsafe(); | ||
|
||
pub unsafe fn originally_legacy_now_unsafe_extern_and_explicit_unsafe(); | ||
|
||
pub safe fn originally_legacy_now_unsafe_extern_and_safe(); | ||
} | ||
|
||
unsafe extern "C" { | ||
pub fn originally_explicit_now_implicit_unsafe(); | ||
|
||
pub unsafe fn originally_implicit_now_explicit_unsafe(); | ||
|
||
pub fn originally_safe_now_implicit_unsafe(); | ||
|
||
pub unsafe fn originally_safe_now_explicit_unsafe(); | ||
} | ||
|
||
// This is the "legacy" way of specifying `extern`. | ||
extern "C" { | ||
pub fn originally_implicit_unsafe_now_legacy(); | ||
|
||
pub fn originally_explicit_unsafe_now_legacy(); | ||
|
||
// This is a breaking change! | ||
pub fn originally_safe_now_legacy(); | ||
} |
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,7 @@ | ||
[package] | ||
publish = false | ||
name = "safe_vs_unsafe_extern_fn" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
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,27 @@ | ||
#![feature(unsafe_extern_blocks)] // Remove after our lowest tested Rust version is 1.82+. | ||
|
||
extern "C" { | ||
pub fn originally_legacy_now_unsafe_extern_and_implicit_unsafe(); | ||
|
||
pub fn originally_legacy_now_unsafe_extern_and_explicit_unsafe(); | ||
|
||
pub fn originally_legacy_now_unsafe_extern_and_safe(); | ||
} | ||
|
||
unsafe extern "C" { | ||
pub unsafe fn originally_explicit_now_implicit_unsafe(); | ||
|
||
pub fn originally_implicit_now_explicit_unsafe(); | ||
|
||
pub safe fn originally_safe_now_implicit_unsafe(); | ||
|
||
pub safe fn originally_safe_now_explicit_unsafe(); | ||
} | ||
|
||
unsafe extern "C" { | ||
pub fn originally_implicit_unsafe_now_legacy(); | ||
|
||
pub unsafe fn originally_explicit_unsafe_now_legacy(); | ||
|
||
pub safe fn originally_safe_now_legacy(); | ||
} |
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