about summary refs log tree commit diff
path: root/tests/ui/codegen
diff options
context:
space:
mode:
authorLaurențiu Nicola <lnicola@users.noreply.github.com>2025-05-01 07:33:30 +0000
committerGitHub <noreply@github.com>2025-05-01 07:33:30 +0000
commit00d2f60efd516bc7ea658bd0a6de5e2f1f1df322 (patch)
tree9375885343e27ab26b20dfe5a3714e00d5d378d0 /tests/ui/codegen
parente7502210ce5ab2d92cb87c372dab51b637ba6df4 (diff)
parent1c5de64814d72effc6890ca823fa4d248041a0bd (diff)
Merge pull request #19726 from lnicola/sync-from-rust
Sync from downstream again
Diffstat (limited to 'tests/ui/codegen')
-rw-r--r--tests/ui/codegen/cfguard-run.rs6
-rw-r--r--tests/ui/codegen/no-mangle-on-internal-lang-items.rs14
-rw-r--r--tests/ui/codegen/no-mangle-on-internal-lang-items.stderr12
-rw-r--r--tests/ui/codegen/no-mangle-on-panic-handler.rs14
-rw-r--r--tests/ui/codegen/no-mangle-on-panic-handler.stderr16
5 files changed, 62 insertions, 0 deletions
diff --git a/tests/ui/codegen/cfguard-run.rs b/tests/ui/codegen/cfguard-run.rs
new file mode 100644
index 00000000000..52ad3e3cc04
--- /dev/null
+++ b/tests/ui/codegen/cfguard-run.rs
@@ -0,0 +1,6 @@
+//@ run-pass
+//@ compile-flags: -C control-flow-guard
+
+pub fn main() {
+    println!("hello, world");
+}
diff --git a/tests/ui/codegen/no-mangle-on-internal-lang-items.rs b/tests/ui/codegen/no-mangle-on-internal-lang-items.rs
new file mode 100644
index 00000000000..37766936410
--- /dev/null
+++ b/tests/ui/codegen/no-mangle-on-internal-lang-items.rs
@@ -0,0 +1,14 @@
+// Issue a error when the user uses #[no_mangle] on internal language items
+//@ edition:2024
+
+#![feature(rustc_attrs)]
+
+#[rustc_std_internal_symbol]
+#[unsafe(no_mangle)] //~ERROR `#[no_mangle]` cannot be used on internal language items
+fn internal_lang_function () {
+
+}
+
+fn main() {
+
+}
diff --git a/tests/ui/codegen/no-mangle-on-internal-lang-items.stderr b/tests/ui/codegen/no-mangle-on-internal-lang-items.stderr
new file mode 100644
index 00000000000..12461a6abb9
--- /dev/null
+++ b/tests/ui/codegen/no-mangle-on-internal-lang-items.stderr
@@ -0,0 +1,12 @@
+error: `#[no_mangle]` cannot be used on internal language items
+  --> $DIR/no-mangle-on-internal-lang-items.rs:7:1
+   |
+LL | #[unsafe(no_mangle)]
+   | ^^^^^^^^^^^^^^^^^^^^
+LL | fn internal_lang_function () {
+   | ---------------------------- should be the internal language item
+   |
+   = note: Rustc requires this item to have a specific mangled name.
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/codegen/no-mangle-on-panic-handler.rs b/tests/ui/codegen/no-mangle-on-panic-handler.rs
new file mode 100644
index 00000000000..1dc0cce0a2e
--- /dev/null
+++ b/tests/ui/codegen/no-mangle-on-panic-handler.rs
@@ -0,0 +1,14 @@
+// Issue an error when the user uses #[no_mangle] on the panic handler
+//@ edition:2024
+
+#![crate_type="lib"]
+#![no_std]
+#![no_main]
+
+use core::panic::PanicInfo;
+
+#[unsafe(no_mangle)] //~ ERROR `#[no_mangle]` cannot be used on internal language items
+#[panic_handler]
+pub unsafe fn panic_fmt(pi: &PanicInfo) -> ! {
+    loop {}
+}
diff --git a/tests/ui/codegen/no-mangle-on-panic-handler.stderr b/tests/ui/codegen/no-mangle-on-panic-handler.stderr
new file mode 100644
index 00000000000..dc88b66d1b5
--- /dev/null
+++ b/tests/ui/codegen/no-mangle-on-panic-handler.stderr
@@ -0,0 +1,16 @@
+error: `#[no_mangle]` cannot be used on internal language items
+  --> $DIR/no-mangle-on-panic-handler.rs:10:1
+   |
+LL | #[unsafe(no_mangle)]
+   | ^^^^^^^^^^^^^^^^^^^^
+LL | #[panic_handler]
+LL | pub unsafe fn panic_fmt(pi: &PanicInfo) -> ! {
+   | -------------------------------------------- should be the internal language item
+   |
+   = note: Rustc requires this item to have a specific mangled name.
+   = note: If you are trying to prevent mangling to ease debugging, many
+   = note: debuggers support a command such as `rbreak rust_begin_unwind` to
+   = note: match `.*rust_begin_unwind.*` instead of `break rust_begin_unwind` on a specific name
+
+error: aborting due to 1 previous error
+