about summary refs log tree commit diff
path: root/compiler/rustc_codegen_gcc/example/std_example.rs
diff options
context:
space:
mode:
authorBen Kimock <kimockb@gmail.com>2022-04-03 13:23:27 -0400
committerBen Kimock <kimockb@gmail.com>2022-04-03 16:16:33 -0400
commitf4a7ed433834e8ea2775097a9bf433880d6e34a3 (patch)
tree8e439b642f4d65fd311b972b4c3516634c8232fe /compiler/rustc_codegen_gcc/example/std_example.rs
parent15a242a432c9c40a60def102209a5d40900b7b9d (diff)
downloadrust-f4a7ed433834e8ea2775097a9bf433880d6e34a3.tar.gz
rust-f4a7ed433834e8ea2775097a9bf433880d6e34a3.zip
Fix &mut invalidation in ptr::swap doctest
Under Stacked Borrows with raw pointer tagging, the previous code was UB
because the code which creates the the second pointer borrows the array
through a tag in the borrow stacks below the Unique tag that our first
pointer is based on, thus invalidating the first pointer.

This is not definitely a bug and may never be real UB, but I desperately
want people to write code that conforms to SB with raw pointer tagging
so that I can write good diagnostics. The alternative aliasing models
aren't possible to diagnose well due to state space explosion.
Therefore, it would be super cool if the standard library nudged people
towards writing code that is valid with respect to SB with raw pointer
tagging.
Diffstat (limited to 'compiler/rustc_codegen_gcc/example/std_example.rs')
0 files changed, 0 insertions, 0 deletions