rust/src
bors 0e7f91b75e Auto merge of #118324 - RalfJung:ctfe-read-only-pointers, r=saethlin
compile-time evaluation: detect writes through immutable pointers

This has two motivations:
- it unblocks https://github.com/rust-lang/rust/pull/116745 (and therefore takes a big step towards `const_mut_refs` stabilization), because we can now detect if the memory that we find in `const` can be interned as "immutable"
- it would detect the UB that was uncovered in https://github.com/rust-lang/rust/pull/117905, which was caused by accidental stabilization of `copy` functions in `const` that can only be called with UB

When UB is detected, we emit a future-compat warn-by-default lint. This is not a breaking change, so completely in line with [the const-UB RFC](https://rust-lang.github.io/rfcs/3016-const-ub.html), meaning we don't need t-lang FCP here. I made the lint immediately show up for dependencies since it is nearly impossible to even trigger this lint without `const_mut_refs` -- the accidentally stabilized `copy` functions are the only way this can happen, so the crates that popped up in #117905 are the only causes of such UB (in the code that crater covers), and the three cases of UB that we know about have all been fixed in their respective crates already.

The way this is implemented is by making use of the fact that our interpreter is already generic over the notion of provenance. For CTFE we now use the new `CtfeProvenance` type which is conceptually an `AllocId` plus a boolean `immutable` flag (but packed for a more efficient representation). This means we can mark a pointer as immutable when it is created as a shared reference. The flag will be propagated to all pointers derived from this one. We can then check the immutable flag on each write to reject writes through immutable pointers.

I just hope perf works out.
2023-12-07 18:11:01 +00:00
..
bootstrap Rollup merge of #117981 - Urgau:check-cfg-remove-deprecated-syntax, r=b-naber 2023-12-06 21:52:30 +01:00
ci Auto merge of #118463 - cuviper:restore-cg_gcc-ci, r=cuviper,GuillaumeGomez 2023-12-07 09:57:44 +00:00
doc Auto merge of #116565 - Sword-Destiny:master, r=Amanieu 2023-12-07 05:22:21 +00:00
etc Auto merge of #115274 - bjorn3:tidy_improvements, r=davidtwco 2023-11-04 02:28:17 +00:00
librustdoc Auto merge of #118605 - fee1-dead-contrib:rm-rustc_host, r=compiler-errors 2023-12-06 16:00:24 +00:00
llvm-project@7738295178 Update to LLVM 17.0.5 2023-11-14 12:06:30 +01:00
rustdoc-json-types rustdoc-json: Rename typedef to type alias 2023-08-21 14:02:34 -07:00
tools Auto merge of #118324 - RalfJung:ctfe-read-only-pointers, r=saethlin 2023-12-07 18:11:01 +00:00
README.md
stage0.json Bump stage0 to latest 2023-11-15 19:40:51 -05:00
version Bump nightly version 2023-11-11 11:29:33 -05:00

This directory contains some source code for the Rust project, including:

  • The bootstrapping build system
  • Various submodules for tools, like cargo, tidy, etc.

For more information on how various parts of the compiler work, see the rustc dev guide.