Rust's current mangling scheme depends on compiler internals; loses information about generic parameters (and other things) which makes for a worse experience when using external tools that need to interact with Rust symbol names; is inconsistent; and can contain `.` characters which aren't universally supported. Therefore, Rust has defined its own symbol mangling scheme which is defined in terms of the Rust language, not the compiler implementation; encodes information about generic parameters in a reversible way; has a consistent definition; and generates symbols that only use the characters `A-Z`, `a-z`, `0-9`, and `_`. Support for the new Rust symbol mangling scheme has been added to upstream tools that will need to interact with Rust symbols (e.g. debuggers). This commit changes the default symbol mangling scheme from the legacy scheme to the new Rust mangling scheme. Signed-off-by: David Wood <david.wood@huawei.com>
25 lines
1,005 B
Rust
25 lines
1,005 B
Rust
//@ compile-flags: -Cno-prepopulate-passes -Copt-level=0 -Cdebug-assertions=no
|
|
|
|
// This test ensures that in a debug build which turns off debug assertions, we do not monomorphize
|
|
// any of the standard library's unsafe precondition checks.
|
|
// The naive codegen of those checks contains the actual check underneath an `if false`, which
|
|
// could be optimized out if optimizations are enabled. But if we rely on optimizations to remove
|
|
// panic branches, then we can't link compiler_builtins without optimizing it, which means that
|
|
// -Zbuild-std doesn't work with -Copt-level=0.
|
|
//
|
|
// In other words, this tests for a mandatory optimization.
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
use std::ptr::NonNull;
|
|
|
|
// CHECK-LABEL: ; <core::ptr::non_null::NonNull<u8>>::new_unchecked
|
|
// CHECK-NOT: call
|
|
// CHECK: }
|
|
|
|
// CHECK-LABEL: @nonnull_new
|
|
#[no_mangle]
|
|
pub unsafe fn nonnull_new(ptr: *mut u8) -> NonNull<u8> {
|
|
// CHECK: ; call <core::ptr::non_null::NonNull<u8>>::new_unchecked
|
|
unsafe { NonNull::new_unchecked(ptr) }
|
|
}
|