rust/library/core/src
bors beb5ae474d Auto merge of #77023 - HeroicKatora:len-missed-optimization, r=Mark-Simulacrum
Hint the maximum length permitted by invariant of slices

One of the safety invariants of references, and in particular of references to slices, is that they may not cover more than `isize::MAX` bytes. The unsafe `from_raw_parts` constructors of slices explicitly requires the caller to guarantee this fact. Violating it would also be UB with regards to the semantics of generated llvm code.

This effectively bounds the length of a (non-ZST) slice from above by a compile time constant. But when the length is loaded from a function argument it appears llvm is not aware of this requirement. The additional value range assertions allow some further elision of code branches, including overflow checks, especially in the presence of artithmetic on the indices.

This may have a performance impact, adding more code to a common method but allowing more optimization. I'm not quite sure, is the Rust side of const-prop strong enough to elide the irrelevant match branches?

Fixes: #67186
2020-10-04 21:08:06 +00:00
..
alloc Rollup merge of #77315 - exrook:rename-allocerror, r=joshtriplett 2020-10-01 02:13:39 +02:00
array add tracking issue 2020-09-23 13:48:21 +02:00
char Use intra-doc-links in core::{char, macros, fmt} 2020-08-24 00:13:23 +02:00
convert add i32::MAX link 2020-08-30 17:07:50 +05:30
fmt Auto merge of #76017 - JulianKnodt:fmt_fast, r=nagisa 2020-10-04 02:24:20 +00:00
future Update library functions with stability attributes 2020-09-22 10:05:58 -07:00
hash Switch to intra-doc links in core::hash 2020-08-27 12:09:50 -07:00
iter Rollup merge of #77409 - pickfire:patch-6, r=GuillaumeGomez 2020-10-02 20:27:06 +02:00
macros Rollup merge of #74880 - chrisduerr:fix_matches, r=dtolnay 2020-09-01 18:24:23 -07:00
mem Uplift drop-bounds lint from clippy 2020-10-01 12:06:33 -07:00
num Implement as_ne_bytes for floats and integers 2020-09-20 22:20:06 +08:00
ops Use Self more in core in doc when possible 2020-09-23 00:16:16 +02:00
prelude mv std libs to library/ 2020-07-27 19:51:13 -05:00
ptr Rename AllocErr to AllocError 2020-09-28 14:51:03 -04:00
slice Auto merge of #77023 - HeroicKatora:len-missed-optimization, r=Mark-Simulacrum 2020-10-04 21:08:06 +00:00
str Remove unneeded tidy comment 2020-09-26 05:20:53 +00:00
sync Move use align_of in atomic.rs into the places where it is used. 2020-09-21 20:44:45 +02:00
task Remove rustc_allow_const_fn_ptr 2020-09-27 10:46:41 -07:00
unicode mv std libs to library/ 2020-07-27 19:51:13 -05:00
any.rs update tracking issue for const_type_id 2020-09-24 09:00:04 +10:00
ascii.rs Fixed some intra-docs links in library/core 2020-09-18 07:49:29 +08:00
bool.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
borrow.rs Remove AsRef link as it is in the prelude 2020-08-10 20:29:20 +02:00
cell.rs Rollup merge of #77055 - est31:more_track_caller, r=Mark-Simulacrum 2020-09-23 14:54:15 +02:00
clone.rs Improve readability 2020-09-01 19:56:32 +02:00
cmp.rs Use Self more in core/src/cmp.rs 2020-09-22 23:36:08 +02:00
default.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
ffi.rs Use intra-doc-links in core::{raw, ffi, pin} 2020-08-22 22:25:27 +02:00
hint.rs Rollup merge of #76823 - RalfJung:black-box-warn, r=joshtriplett 2020-09-20 12:08:24 +02:00
internal_macros.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
intrinsics.rs Clean up on example doc fixes for ptr::copy 2020-10-02 14:44:01 +08:00
lazy.rs Capitalize safety comments 2020-09-08 22:26:44 -04:00
lib.rs Assume slice len is bounded by allocation size 2020-10-04 20:43:36 +02:00
marker.rs Use Self more in core in doc when possible 2020-09-23 00:16:16 +02:00
option.rs Rollup merge of #75454 - ltratt:option_optimisation_guarantees, r=dtolnay 2020-09-26 12:58:12 +02:00
panic.rs Auto merge of #76157 - ArekPiekarz:const_caller_location_tracking_issue, r=joshtriplett 2020-09-06 20:27:51 +00:00
panicking.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
pin.rs Make some methods of Pin<&mut T> unstable const 2020-09-18 19:23:50 +02:00
primitive.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
raw.rs Use intra-doc-links in core::{raw, ffi, pin} 2020-08-22 22:25:27 +02:00
result.rs Stabilize some Result methods as const 2020-08-31 02:43:17 +02:00
time.rs Make all methods of Duration const 2020-09-12 15:14:58 +02:00
tuple.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
unit.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00