Skip to content

Add LLVM AllocToken and Heap Partitioning Support to the Rust compiler. - #160298

Open
rcvalle wants to merge 8 commits into
rust-lang:mainfrom
rcvalle:rust-heap-partitioning
Open

Add LLVM AllocToken and Heap Partitioning Support to the Rust compiler.#160298
rcvalle wants to merge 8 commits into
rust-lang:mainfrom
rcvalle:rust-heap-partitioning

Conversation

@rcvalle

@rcvalle rcvalle commented Jul 31, 2026

Copy link
Copy Markdown
Member

Add LLVM AllocToken and heap partitioning support to the Rust compiler.

For more information about LLVM AllocToken and heap partitioning support for the Rust compiler, see the design document in the tracking issue #159111.

r? @bjorn3

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) A-compiletest Area: The compiletest test runner A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-testsuite Area: The testsuite used to check the correctness of rustc PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 31, 2026
@rcvalle rcvalle changed the title Add LVM AllocToken and Heap Partitioning Support to the Rust compiler. Add LLVM AllocToken and Heap Partitioning Support to the Rust compiler. Aug 1, 2026
@rcvalle
rcvalle force-pushed the rust-heap-partitioning branch 2 times, most recently from a9de07c to 170b511 Compare August 8, 2026 00:17
rcvalle added 3 commits August 7, 2026 17:53
Add the `-Zsanitizer=alloc-token` sanitizer option, including target
support specification (i.e., `supported_sanitizers` in target
specifications), and the accompanying `-Zsanitizer-alloc-token-scheme`,
`-Zsanitizer-alloc-token-max`, `-Zsanitizer-alloc-token-extended`, and
`-Zsanitizer-alloc-token-fast-abi` options.
Add the `#[alloc_token_hint(contains_pointers = ..., type_name = "...")]`
attribute to allow the user to define the allocation token hint (i.e.,
the contains-pointer classification and type name encoding) for
user-defined types, and the internal `#[rustc_alloc_token_hint]`
attribute to annotate typed allocation functions whose type parameter
identifies the allocated type.
…ning schemes

Add the `rustc_sanitizers::alloc_token` module, organized and
structured similarly to `rustc_sanitizers::cfi::typeid` (i.e., the
`hint` module provides the interface for computing allocation token
hints for a given `Ty` and dispatches to the selected heap
partitioning scheme implementation, such as `type_hash_pointer_split`).
@rcvalle
rcvalle force-pushed the rust-heap-partitioning branch from 170b511 to 912d399 Compare August 8, 2026 00:54
@rcvalle
rcvalle marked this pull request as ready for review August 8, 2026 01:00
@rustbot

rustbot commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_hir/src/attrs

cc @jdonszelmann, @JonathanBrouwer

Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter
gets adapted for the changes, if necessary.

cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr

rustc_codegen_gcc is developed in its own repository. If possible, consider making this change to rust-lang/rustc_codegen_gcc instead.

cc @antoyo, @GuillaumeGomez

rustc_codegen_cranelift is developed in its own repository. If possible, consider making this change to rust-lang/rustc_codegen_cranelift instead.

cc @bjorn3

Any special-casing of Miri in the standard library requires review.

cc @rust-lang/miri

Some changes occurred in src/doc/unstable-book/src/compiler-flags/sanitizer.md

cc @rust-lang/project-exploit-mitigations

compiletest directives have been modified. Please add or update docs for the
new or modified directive in src/doc/rustc-dev-guide/.

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann, @JonathanBrouwer

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann, @JonathanBrouwer

These commits modify compiler targets.
(See the Target Tier Policy.)

Some changes occurred in src/tools/compiletest

cc @jieyouxu

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 8, 2026
@rcvalle

rcvalle commented Aug 8, 2026

Copy link
Copy Markdown
Member Author

@bjorn3 For whenever you have time. Thank you!

@rust-log-analyzer

This comment has been minimized.

@rcvalle
rcvalle force-pushed the rust-heap-partitioning branch from 912d399 to 6ab006f Compare August 8, 2026 01:54
@rust-log-analyzer

This comment has been minimized.

@rcvalle
rcvalle force-pushed the rust-heap-partitioning branch from 6ab006f to d4a3185 Compare August 8, 2026 02:47
@rust-log-analyzer

This comment has been minimized.

@RalfJung

RalfJung commented Aug 8, 2026

Copy link
Copy Markdown
Member

Has this been RFC'd or at least MCP'd? It seems to propose deep changes to the core semantics of Rust which definitely needs some wider discussion.

Rust does not have typed memory, so "typed allocation" is an oxymoron.

@RalfJung

RalfJung commented Aug 8, 2026

Copy link
Copy Markdown
Member

Rust does not have typed memory, so "typed allocation" is an oxymoron.

Okay, looking at your writeup, this isn't "typed memory" / "typed allocations" at all. I can store whatever types I want into these allocations without causing UB. It's just a hint to the allocator which allocations to put near each other and which not. I would strongly recommend to avoid calling this "typed X" (which you didn't in this PR but you did in the tracking issue) since some of us in Rust have strong feelings about typed memory, and Rust is very unlikely to ever have "typed allocations" in the sense of "allocations that are required to only hold data of a certain type".

The concrete API proposed here with these "tokens" seems very strange to me, but this will need a least an MCP anyway for the compiler and intrinsic part and discussion with libs-api for how to expose it and how it changes the global allocator story (and maybe lang, depending on how magic these intrinsics are -- in particular, is the type partition this induces arbitrary and we can change it any time in principle, or are we making any promises about how types are grouped and which Rust types correspond to which C types). Given that the entire project as a whole spans non-trivial changes for multiple teams, this should probably be an RFC. So I'll wait for that to properly explain to us why we need "tokens" to partition heap allocations. :)

tl;dr this is a big enough change to Rust that we need to ensure the relevant teams have agreed to the general design before we start landing anything.

(Also the PR looks like it could likely be split up into smaller parts which would help a lot.)

rcvalle added 5 commits August 8, 2026 09:59
…nt it for LLVM backend

Add the `set_alloc_token_hint` and `get_alloc_token_id` methods to the
backend-agnostic `BuilderMethods` trait, and implement them for the
LLVM backend; and add the `SanitizeAllocToken` LLVM function attribute,
and the `alloc-token-mode`, `alloc-token-max`, `alloc-token-extended`,
and `alloc-token-fast-abi` module flags.
Add `alloc_typed` and `alloc_array_typed`, internal, unstable, generic
allocation functions annotated with `#[rustc_alloc_token_hint]`. Route
`Box::new` and `RawVec::<T, Global>::with_capacity` through them when
LLVM AllocToken and heap partitioning support is enabled, so the
allocation call within them is annotated with the allocation token hint
(i.e., the contents of the `!alloc_token` metadata) for its type
parameter `T`.
…brary

Extend the Rust compiler allocator shim generation to also generate the
token-enabled versions of the `__rust_alloc`, `__rust_alloc_zeroed`, and
`__rust_realloc` allocation functions (i.e., `__alloc_token___rust_alloc`,
`__alloc_token___rust_alloc_zeroed`, and `__alloc_token___rust_realloc`),
forwarding to new unstable, token-enabled methods of the `GlobalAlloc`
trait (i.e., `alloc_with_token`, `alloc_zeroed_with_token`, and
`realloc_with_token`), with default implementations that ignore the
token identifier and call the non-token-enabled methods, for backward
compatibility with existing allocators.

In the `System` allocator implementation, the token-enabled methods
forward to the token-enabled C allocator interface (i.e.,
`__alloc_token_malloc`, `__alloc_token_calloc`, and
`__alloc_token_realloc`), so that programs using the default allocator
can use a token-enabled C memory allocator for the whole program,
including foreign code, in mixed binaries.

The token-enabled versions of these allocation functions are also added
to the allocator shim exported symbols. For allocators registered with
the `#[global_allocator]` attribute, the token-enabled versions of these
allocation functions forward to the non-token-enabled allocation
functions of the registered allocator, ignoring the token identifier,
for backward compatibility with existing allocators.
Add the `alloc_token_infer` intrinsic (i.e., the Rust equivalent of
the Clang `__builtin_infer_alloc_token` builtin, lowered to the
`llvm.alloc.token.id` intrinsic) for allocator and arena implementers
to query the token identifier for a given type at compile time (e.g.,
`core::intrinsics::alloc_token_infer::<T>() -> usize`), so it can be
passed to a token-enabled allocator interface directly.
Add documentation for the LLVM AllocToken and heap partitioning support
in the Rust compiler.
@rcvalle
rcvalle force-pushed the rust-heap-partitioning branch from d4a3185 to dfc5a28 Compare August 8, 2026 17:16
@rcvalle

rcvalle commented Aug 8, 2026

Copy link
Copy Markdown
Member Author

The concrete API proposed here with these "tokens" seems very strange to me, but this will need a least an MCP anyway for the compiler and intrinsic part and discussion with libs-api for how to expose it and how it changes the global allocator story (and maybe lang, depending on how magic these intrinsics are -- in particular, is the type partition this induces arbitrary and we can change it any time in principle, or are we making any promises about how types are grouped and which Rust types correspond to which C types).

Hey @RalfJung! I have a design document in the tracking issue #159111 that has all this information (and the tl;dr is that this is the implementation of the https://clang.llvm.org/docs/AllocToken.html sanitizer for Rust with matching heap partitioning schemes, and it doesn't change the language semantics or the program correctness in any way. Happy to open an MCP if you think that would be helpful. Let me know.

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job aarch64-gnu-llvm-21-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)

120 LL |     sanitize = "_UNEXPECTED_VALUE",
121    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
122    |
-    = note: expected values for `sanitize` are: `address`, `cfi`, `dataflow`, `hwaddress`, `kcfi`, `kernel-address`, `kernel-hwaddress`, `leak`, `memory`, `memtag`, `realtime`, `safestack`, `shadow-call-stack`, and `thread`
+    = note: expected values for `sanitize` are: `address`, `alloc-token`, `cfi`, `dataflow`, `hwaddress`, `kcfi`, `kernel-address`, `kernel-hwaddress`, `leak`, `memory`, `memtag`, `realtime`, `safestack`, `shadow-call-stack`, and `thread`
124    = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
125 
126 warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args check-cfg/well-known-values.rs`

error: 1 errors occurred comparing output.
status: exit status: 0
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/check-cfg/well-known-values.rs" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/check-cfg/well-known-values" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "--check-cfg=cfg()" "-Zcheck-cfg-all-expected"
stdout: none
--- stderr -------------------------------
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:30:5
   |
LL |     clippy = "_UNEXPECTED_VALUE",
   |     ^^^^^^----------------------
   |           |
   |           help: remove the value
   |
   = note: no expected value for `clippy`
---

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:40:5
   |
LL |     miri = "_UNEXPECTED_VALUE",
   |     ^^^^----------------------
   |         |
   |         help: remove the value
   |
   = note: no expected value for `miri`
---

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:46:5
   |
LL |     proc_macro = "_UNEXPECTED_VALUE",
   |     ^^^^^^^^^^----------------------
   |               |
   |               help: remove the value
   |
   = note: no expected value for `proc_macro`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:48:5
   |
LL |     relocation_model = "_UNEXPECTED_VALUE",
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected values for `relocation_model` are: `dynamic-no-pic`, `pic`, `pie`, `ropi`, `ropi-rwpi`, `rwpi`, and `static`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:50:5
   |
LL |     rustfmt = "_UNEXPECTED_VALUE",
   |     ^^^^^^^----------------------
   |            |
   |            help: remove the value
   |
   = note: no expected value for `rustfmt`
---
   |
LL |     sanitize = "_UNEXPECTED_VALUE",
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected values for `sanitize` are: `address`, `alloc-token`, `cfi`, `dataflow`, `hwaddress`, `kcfi`, `kernel-address`, `kernel-hwaddress`, `leak`, `memory`, `memtag`, `realtime`, `safestack`, `shadow-call-stack`, and `thread`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:54:5
   |
LL |     target_abi = "_UNEXPECTED_VALUE",
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected values for `target_abi` are: ``, `abi64`, `abiv2`, `abiv2hf`, `eabi`, `eabihf`, `elfv1`, `elfv2`, `fortanix`, `ilp32`, `ilp32e`, `llvm`, `macabi`, `pauthtest`, `sim`, `softfloat`, `spe`, `uwp`, `vec-extabi`, and `x32`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:56:5
   |
LL |     target_arch = "_UNEXPECTED_VALUE",
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected values for `target_arch` are: `aarch64`, `amdgpu`, `arm`, `arm64ec`, `avr`, `bpf`, `csky`, `hexagon`, `loongarch32`, `loongarch64`, `m68k`, `mips`, `mips32r6`, `mips64`, `mips64r6`, `msp430`, `nvptx64`, `powerpc`, `powerpc64`, `riscv32`, `riscv64`, `s390x`, `sparc`, `sparc64`, `wasm32`, `wasm64`, `x86`, `x86_64`, and `xtensa`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:58:5
   |
---
   |
LL |     target_env = "_UNEXPECTED_VALUE",
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected values for `target_env` are: ``, `gnu`, `macabi`, `mlibc`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `nto71_iosock`, `ohos`, `p1`, `p2`, `p3`, `relibc`, `sgx`, `sim`, `uclibc`, and `v5`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:62:5
   |
---
   |
LL |     target_has_atomic = "_UNEXPECTED_VALUE",
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected values for `target_has_atomic` are: (none), `128`, `16`, `32`, `64`, `8`, and `ptr`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:68:5
   |
LL |     target_has_atomic_load_store = "_UNEXPECTED_VALUE",
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected values for `target_has_atomic_load_store` are: (none), `128`, `16`, `32`, `64`, `8`, and `ptr`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:70:5
   |
LL |     target_has_atomic_primitive_alignment = "_UNEXPECTED_VALUE",
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected values for `target_has_atomic_primitive_alignment` are: `128`, `16`, `32`, `64`, `8`, and `ptr`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:72:5
   |
LL |     target_has_threads = "_UNEXPECTED_VALUE",
   |     ^^^^^^^^^^^^^^^^^^----------------------
   |                       |
   |                       help: remove the value
   |
   = note: no expected value for `target_has_threads`
---
   |
LL |     target_object_format = "_UNEXPECTED_VALUE",
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected values for `target_object_format` are: `coff`, `elf`, `mach-o`, `wasm`, and `xcoff`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:76:5
   |
LL |     target_os = "_UNEXPECTED_VALUE",
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `helenos`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `managarm`, `motor`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `qnx`, `qurt`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `vexos`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:78:5
   |
LL |     target_pointer_width = "_UNEXPECTED_VALUE",
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected values for `target_pointer_width` are: `16`, `32`, and `64`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:80:5
   |
---
   |
LL |     target_vendor = "_UNEXPECTED_VALUE",
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected values for `target_vendor` are: `amd`, `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `mti`, `nintendo`, `nvidia`, `openwrt`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `vex`, `win7`, and `wrs`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:84:5
   |
LL |     ub_checks = "_UNEXPECTED_VALUE",
   |     ^^^^^^^^^----------------------
   |              |
   |              help: remove the value
   |
   = note: no expected value for `ub_checks`
---

warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/well-known-values.rs:88:5
   |
LL |     windows = "_UNEXPECTED_VALUE",
   |     ^^^^^^^----------------------
   |            |
   |            help: remove the value
   |
   = note: no expected value for `windows`
---
   |
LL | #[cfg(target_os = "linuz")] // testing that we suggest `linux`
   |       ^^^^^^^^^^^^-------
   |                   |
   |                   help: there is a expected value with a similar name: `"linux"`
   |
   = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `helenos`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `managarm`, `motor`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `qnx`, `qurt`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `vexos`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: 30 warnings emitted
------------------------------------------

---- [ui] tests/ui/check-cfg/well-known-values.rs stdout end ----
---- [ui] tests/ui/hygiene/unpretty-debug-lifetimes.rs stdout ----
Saved the actual stdout to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/hygiene/unpretty-debug-lifetimes/unpretty-debug-lifetimes.stdout`
diff of stdout:

15     /*
16     0#0
17     */ {
-     ($f /* 0#0 */:ident /* 0#0 */<$a /* 0#0 */:lifetime /* 0#0 */>)
-     =>
+     ($f /* 0#0 */:ident /* 0#0 */<$a /* 0#0 */:lifetime /* 0#0
+     */>) =>
20     { fn /* 0#0 */ $f /* 0#0 */<$a /* 0#0 */, 'a /* 0#0 */>() {} }
21 }
22 fn f /* 0#0 */<'a /* 0#0 */, 'a /* 0#1 */>() {}

Note: some mismatched output was normalized before being compared
-     ($f /* 2356#0 */:ident /* 1002#0 */<$a /* 2351#0 */:lifetime /* 1099#0
+     ($f /* 0#0 */:ident /* 0#0 */<$a /* 0#0 */:lifetime /* 0#0
+     */>) =>


The actual stdout differed from the expected stdout
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args hygiene/unpretty-debug-lifetimes.rs`

error: 1 errors occurred comparing output.
status: exit status: 0
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/hygiene/unpretty-debug-lifetimes.rs" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/hygiene/unpretty-debug-lifetimes" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "-Zunpretty=expanded,hygiene"
--- stdout -------------------------------
//@ check-pass
//@ compile-flags: -Zunpretty=expanded,hygiene

// Regression test for lifetime hygiene annotations in -Zunpretty=expanded,hygiene
// Previously, lifetimes were missing the #N syntax context suffix.

// Don't break whenever Symbol numbering changes
//@ normalize-stdout: "\d+#" -> "0#"

#![feature /* 862#0 */(decl_macro /* 697#0 */)]
#![feature /* 862#0 */(no_core /* 1334#0 */)]
#![no_core /* 1334#0 */]

macro lifetime_hygiene
    /*
    2944#0
    */ {
    ($f /* 2356#0 */:ident /* 1002#0 */<$a /* 2351#0 */:lifetime /* 1099#0
    */>) =>
    { fn /* 12#0 */ $f /* 2356#0 */<$a /* 2351#0 */, 'a /* 2945#0 */>() {} }
}
fn f /* 2356#0 */<'a /* 2945#0 */, 'a /* 2945#1 */>() {}


/*
Expansions:
crate0::{{expn0}}: parent: crate0::{{expn0}}, call_site_ctxt: #0, def_site_ctxt: #0, kind: Root
crate0::{{expn1}}: parent: crate0::{{expn0}}, call_site_ctxt: #0, def_site_ctxt: #0, kind: Macro(Bang, "lifetime_hygiene")

SyntaxContexts:
#0: parent: #0, outer_mark: (crate0::{{expn0}}, Opaque)
#1: parent: #0, outer_mark: (crate0::{{expn1}}, Opaque)
*/
------------------------------------------
stderr: none

---- [ui] tests/ui/hygiene/unpretty-debug-lifetimes.rs stdout end ----
---- [ui] tests/ui/sanitize-attr/invalid-sanitize.rs stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/sanitize-attr/invalid-sanitize/invalid-sanitize.stderr`
diff of stderr:

4 LL | #[sanitize(brontosaurus = "off")]
5    |   ^^^^^^^^^------------^^^^^^^^^
6    |            |
-    |            valid arguments are "address", "kernel_address", "cfi", "kcfi", "memory", "memtag", "shadow_call_stack", "thread", "hwaddress", "kernel_hwaddress" or "realtime"
+    |            valid arguments are "address", "kernel_address", "alloc_token", "cfi", "kcfi", "memory", "memtag", "shadow_call_stack", "thread", "hwaddress", "kernel_hwaddress" or "realtime"
8 
9 error: multiple `sanitize` attributes
10   --> $DIR/invalid-sanitize.rs:8:1


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args sanitize-attr/invalid-sanitize.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/sanitize-attr/invalid-sanitize.rs" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/sanitize-attr/invalid-sanitize" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2018"
stdout: none
--- stderr -------------------------------
error[E0539]: malformed `sanitize` attribute input
##[error]  --> /checkout/tests/ui/sanitize-attr/invalid-sanitize.rs:4:3
   |
LL | #[sanitize(brontosaurus = "off")] //~ ERROR malformed `sanitize` attribute input
   |   ^^^^^^^^^------------^^^^^^^^^
   |            |
   |            valid arguments are "address", "kernel_address", "alloc_token", "cfi", "kcfi", "memory", "memtag", "shadow_call_stack", "thread", "hwaddress", "kernel_hwaddress" or "realtime"

error: multiple `sanitize` attributes
##[error]  --> /checkout/tests/ui/sanitize-attr/invalid-sanitize.rs:8:1
   |
LL | #[sanitize(address = "off")] //~ ERROR multiple `sanitize` attributes
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
   |
note: attribute also specified here
  --> /checkout/tests/ui/sanitize-attr/invalid-sanitize.rs:7:1
   |
LL | #[sanitize(address = "off")]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: multiple `sanitize` attributes
##[error]  --> /checkout/tests/ui/sanitize-attr/invalid-sanitize.rs:12:1
   |
LL | #[sanitize(address = "off")] //~ ERROR multiple `sanitize` attributes
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
   |
note: attribute also specified here
  --> /checkout/tests/ui/sanitize-attr/invalid-sanitize.rs:11:1
   |
LL | #[sanitize(address = "on")]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0539]: malformed `sanitize` attribute input
##[error]  --> /checkout/tests/ui/sanitize-attr/invalid-sanitize.rs:15:3
   |
LL | #[sanitize(address = "bogus")] //~ ERROR malformed `sanitize` attribute input
   |   ^^^^^^^^^^^^^^^^^^^-------^
   |                      |
   |                      valid arguments are "on" or "off"

error[E0539]: malformed `sanitize` attribute input
##[error]  --> /checkout/tests/ui/sanitize-attr/invalid-sanitize.rs:18:3
   |
LL | #[sanitize = "off"] //~ ERROR malformed `sanitize` attribute input
   |   ^^^^^^^^^-------
   |            |
   |            expected this to be a list

error[E0539]: malformed `sanitize` attribute input
##[error]  --> /checkout/tests/ui/sanitize-attr/invalid-sanitize.rs:21:3
   |
LL | #[sanitize] //~ ERROR malformed `sanitize` attribute input
   |   ^^^^^^^^ expected this to be a list

error[E0539]: malformed `sanitize` attribute input
##[error]  --> /checkout/tests/ui/sanitize-attr/invalid-sanitize.rs:24:3
   |
LL | #[sanitize(realtime = "on")] //~ ERROR malformed `sanitize` attribute input
   |   ^^^^^^^^^^^^^^^^^^^^----^
   |                       |
   |                       valid arguments are "nonblocking", "blocking" or "caller"

warning: the async executor can run blocking code, without realtime sanitizer catching it
##[warning]  --> /checkout/tests/ui/sanitize-attr/invalid-sanitize.rs:27:1
   |
LL | #[sanitize(realtime = "nonblocking")] //~ WARN: the async executor can run blocking code, without realtime sanitizer catching it [rt...
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(rtsan_nonblocking_async)]` on by default

warning: the async executor can run blocking code, without realtime sanitizer catching it
##[warning]  --> /checkout/tests/ui/sanitize-attr/invalid-sanitize.rs:32:9
   |
LL | ...   #[sanitize(realtime = "nonblocking")] //~ WARN: the async executor can run blocking code, without realtime sanitizer catching ...
   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: the async executor can run blocking code, without realtime sanitizer catching it
##[warning]  --> /checkout/tests/ui/sanitize-attr/invalid-sanitize.rs:37:9
   |
LL | ...   #[sanitize(realtime = "nonblocking")] //~ WARN: the async executor can run blocking code, without realtime sanitizer catching ...
   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 7 previous errors; 3 warnings emitted

For more information about this error, try `rustc --explain E0539`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) A-compiletest Area: The compiletest test runner A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-testsuite Area: The testsuite used to check the correctness of rustc PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants