diff --git a/test_crates/safe_vs_unsafe_extern_fn/new/Cargo.toml b/test_crates/safe_vs_unsafe_extern_fn/new/Cargo.toml new file mode 100644 index 00000000..3e72da78 --- /dev/null +++ b/test_crates/safe_vs_unsafe_extern_fn/new/Cargo.toml @@ -0,0 +1,7 @@ +[package] +publish = false +name = "safe_vs_unsafe_extern_fn" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/safe_vs_unsafe_extern_fn/new/src/lib.rs b/test_crates/safe_vs_unsafe_extern_fn/new/src/lib.rs new file mode 100644 index 00000000..2988f647 --- /dev/null +++ b/test_crates/safe_vs_unsafe_extern_fn/new/src/lib.rs @@ -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(); +} diff --git a/test_crates/safe_vs_unsafe_extern_fn/old/Cargo.toml b/test_crates/safe_vs_unsafe_extern_fn/old/Cargo.toml new file mode 100644 index 00000000..3e72da78 --- /dev/null +++ b/test_crates/safe_vs_unsafe_extern_fn/old/Cargo.toml @@ -0,0 +1,7 @@ +[package] +publish = false +name = "safe_vs_unsafe_extern_fn" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/safe_vs_unsafe_extern_fn/old/src/lib.rs b/test_crates/safe_vs_unsafe_extern_fn/old/src/lib.rs new file mode 100644 index 00000000..ad1bb56d --- /dev/null +++ b/test_crates/safe_vs_unsafe_extern_fn/old/src/lib.rs @@ -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(); +} diff --git a/test_outputs/query_execution/function_unsafe_added.snap b/test_outputs/query_execution/function_unsafe_added.snap index 6d69e5e3..2d40ddae 100644 --- a/test_outputs/query_execution/function_unsafe_added.snap +++ b/test_outputs/query_execution/function_unsafe_added.snap @@ -15,4 +15,36 @@ expression: "&query_execution_results" "visibility_limit": String("public"), }, ], + "./test_crates/safe_vs_unsafe_extern_fn/": [ + { + "name": String("originally_safe_now_implicit_unsafe"), + "path": List([ + String("safe_vs_unsafe_extern_fn"), + String("originally_safe_now_implicit_unsafe"), + ]), + "span_begin_line": Uint64(16), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + { + "name": String("originally_safe_now_explicit_unsafe"), + "path": List([ + String("safe_vs_unsafe_extern_fn"), + String("originally_safe_now_explicit_unsafe"), + ]), + "span_begin_line": Uint64(18), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + { + "name": String("originally_safe_now_legacy"), + "path": List([ + String("safe_vs_unsafe_extern_fn"), + String("originally_safe_now_legacy"), + ]), + "span_begin_line": Uint64(28), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + ], }