Files
rust/compiler/rustc_const_eval
Jacob Pratt 3657ecd71a Rollup merge of #159092 - RalfJung:const-volatile, r=oli-obk
make volatile operations const

This came up in https://github.com/gfx-rs/wgpu/issues/8897#issuecomment-4894447055. The tl;dr is that it can be useful to have shared codepaths between things that need to work on special memory (and hence need to use volatile) and things that work on regular Rust memory, and for the regular Rust memory case those things totally could and should be `const fn`.

So, let's (unstably, for now) allow volatile reads and writes in `const`, and specify them to behave just like normal reads and writes. In const we *know* that there's nobody trying to observe those locations so there's nothing special we have to do with those accesses.

Cc @rust-lang/opsem @rust-lang/wg-const-eval

Tracking issue: https://github.com/rust-lang/rust/issues/159094
2026-07-10 21:54:02 -04:00
..