rust/compiler/rustc_data_structures/src
bors 168a020900 Auto merge of #92686 - saethlin:unsafe-debug-asserts, r=Amanieu
Add debug assertions to some unsafe functions

As suggested by https://github.com/rust-lang/rust/issues/51713

~~Some similar code calls `abort()` instead of `panic!()` but aborting doesn't work in a `const fn`, and the intrinsic for doing dispatch based on whether execution is in a const is unstable.~~

This picked up some invalid uses of `get_unchecked` in the compiler, and fixes them.

I can confirm that they do in fact pick up invalid uses of `get_unchecked` in the wild, though the user experience is less-than-awesome:
```
     Running unittests (target/x86_64-unknown-linux-gnu/debug/deps/rle_decode_fast-04b7918da2001b50)

running 6 tests
error: test failed, to rerun pass '--lib'

Caused by:
  process didn't exit successfully: `/home/ben/rle-decode-helper/target/x86_64-unknown-linux-gnu/debug/deps/rle_decode_fast-04b7918da2001b50` (signal: 4, SIGILL: illegal instruction)
```

~~As best I can tell these changes produce a 6% regression in the runtime of `./x.py test` when `[rust] debug = true` is set.~~
Latest commit (6894d559bd) brings the additional overhead from this PR down to 0.5%, while also adding a few more assertions. I think this actually covers all the places in `core` that it is reasonable to check for safety requirements at runtime.

Thoughts?
2022-04-03 16:04:47 +00:00
..
base_n
binary_search_util Adopt let else in more places 2022-02-19 17:27:43 +01:00
fingerprint
graph Avoid exhausting stack space in dominator compression 2022-02-23 16:07:56 -05:00
intern Rename PtrKey as Interned and improve it. 2022-02-15 15:50:29 +11:00
obligation_forest obligation forest docs 2022-02-21 12:00:26 +01:00
owning_ref
sip128
small_c_str
small_str Add SmallStr 2022-03-04 16:57:34 +01:00
snapshot_map Call the method fork instead of clone and add proper comments 2022-02-14 12:57:20 -03:00
sorted_map Remove invalid #[cfg(tests)] in index_map 2022-03-04 11:34:50 +01:00
sso compiler: fix some typos 2022-03-01 20:02:47 +08:00
stable_hasher
tagged_ptr
thin_vec
tiny_list
transitive_relation Spellchecking some comments 2022-03-30 01:39:38 -04:00
vec_map
atomic_ref.rs
base_n.rs
captures.rs
fingerprint.rs Provide copy-free access to raw Decoder bytes 2022-02-22 18:11:59 -05:00
flock.rs
frozen.rs
functor.rs
fx.rs
intern.rs Clarify Layout interning. 2022-03-07 13:41:47 +11:00
jobserver.rs
lib.rs Add SmallStr 2022-03-04 16:57:34 +01:00
macros.rs Introduce ChunkedBitSet and use it for some dataflow analyses. 2022-02-23 10:18:49 +11:00
map_in_place.rs Add debug assertions to some unsafe functions 2022-03-29 11:05:24 -04:00
memmap.rs
profiling.rs
sharded.rs Move Sharded maps into each QueryCache impl 2022-02-20 12:10:46 -05:00
sip128.rs Use const generics in SipHasher128's short_write 2022-02-05 19:55:44 +01:00
small_c_str.rs Inline SmallCStr::deref 2022-03-04 16:57:34 +01:00
small_str.rs Add SmallStr 2022-03-04 16:57:34 +01:00
sorted_map.rs
stable_hasher.rs Spellchecking some comments 2022-03-30 01:39:38 -04:00
stable_map.rs
stable_set.rs
stack.rs Allow inlining of ensure_sufficient_stack() 2022-02-12 11:30:04 +01:00
steal.rs
svh.rs
sync.rs
tagged_ptr.rs
temp_dir.rs
thin_vec.rs
tiny_list.rs
transitive_relation.rs add #[rustc_pass_by_value] to more types 2022-03-08 15:39:52 +01:00
unhash.rs
vec_linked_list.rs
vec_map.rs Revert "Auto merge of #93893 - oli-obk:sad_revert, r=oli-obk" 2022-03-28 16:27:14 +00:00
work_queue.rs