rust/src
bors 39ee3aaa13 Auto merge of #49297 - scottmcm:offset-from, r=dtolnay
Introduce unsafe offset_from on pointers

Adds intrinsics::exact_div to take advantage of the unsafe, which reduces the implementation from
```asm
    sub rcx, rdx
    mov rax, rcx
    sar rax, 63
    shr rax, 62
    lea rax, [rax + rcx]
    sar rax, 2
    ret
```
down to
```asm
    sub rcx, rdx
    sar rcx, 2
    mov rax, rcx
    ret
```
(for `*const i32`)

See discussion on the `offset_to` tracking issue https://github.com/rust-lang/rust/issues/41079

Some open questions
- Would you rather I split the intrinsic PR from the library PR?
- Do we even want the safe version of the API?  https://github.com/rust-lang/rust/issues/41079#issuecomment-374426786  I've added some text to its documentation that even if it's not UB, it's useless to use it between pointers into different objects.

and todos
- [x] ~~I need to make a codegen test~~ Done
- [x] ~~Can the subtraction use nsw/nuw?~~ No, it can't https://github.com/rust-lang/rust/pull/49297#discussion_r176697574
- [x] ~~Should there be `usize` variants of this, like there are now `add` and `sub` that you almost always want over `offset`?  For example, I imagine `sub_ptr` that returns `usize` and where it's UB if the distance is negative.~~ Can wait for later; C gives a signed result https://github.com/rust-lang/rust/issues/41079#issuecomment-375842235, so we might as well, and this existing to go with `offset` makes sense.
2018-03-26 00:15:34 +00:00
..
bootstrap Rollup merge of #49290 - cuviper:unextended-dist-rustfmt, r=nikomatsakis 2018-03-25 01:26:44 +08:00
build_helper
ci Auto merge of #49284 - alexcrichton:use-our-own-cache, r=kennytm 2018-03-25 02:42:58 +00:00
dlmalloc@9b2dcac06c
doc Rollup merge of #49318 - steveklabnik:update-books, r=kennytm 2018-03-25 01:26:48 +08:00
etc
grammar
jemalloc@1f5a28755e
liballoc Rollup merge of #49194 - Zoxc:unsafe-generator, r=cramertj 2018-03-25 01:26:34 +08:00
liballoc_jemalloc
liballoc_system
libarena
libbacktrace
libcompiler_builtins@266ea0740a
libcore Auto merge of #49297 - scottmcm:offset-from, r=dtolnay 2018-03-26 00:15:34 +00:00
libfmt_macros
libgraphviz
liblibc@ed04152aac
libpanic_abort
libpanic_unwind
libproc_macro
libprofiler_builtins
librustc Auto merge of #49212 - kyrias:strip-debug-no-debuginfo, r=michaelwoerister 2018-03-25 21:46:15 +00:00
librustc_allocator
librustc_apfloat
librustc_asan
librustc_back
librustc_borrowck
librustc_const_eval
librustc_const_math
librustc_cratesio_shim
librustc_data_structures
librustc_driver Rollup merge of #49046 - Zoxc:error-summary, r=michaelwoerister 2018-03-25 01:26:24 +08:00
librustc_errors Rollup merge of #49046 - Zoxc:error-summary, r=michaelwoerister 2018-03-25 01:26:24 +08:00
librustc_incremental
librustc_lint Filed a proper tracking issue. 2018-03-24 07:02:35 +08:00
librustc_llvm
librustc_lsan
librustc_metadata Rollup merge of #49299 - SimonSapin:ubiquity, r=nikomatsakis 2018-03-25 01:30:12 +08:00
librustc_mir Rollup merge of #49274 - oli-obk:slow_miri, r=michaelwoerister,eddyb 2018-03-25 01:26:43 +08:00
librustc_msan
librustc_passes Auto merge of #48482 - davidtwco:issue-47184, r=nikomatsakis 2018-03-24 02:08:22 +00:00
librustc_platform_intrinsics
librustc_plugin
librustc_privacy
librustc_resolve
librustc_save_analysis
librustc_traits
librustc_trans Auto merge of #49297 - scottmcm:offset-from, r=dtolnay 2018-03-26 00:15:34 +00:00
librustc_trans_utils
librustc_tsan
librustc_typeck Auto merge of #49297 - scottmcm:offset-from, r=dtolnay 2018-03-26 00:15:34 +00:00
librustdoc Rollup merge of #49312 - GuillaumeGomez:fix-ie11-search, r=QuietMisdreavus 2018-03-25 01:26:45 +08:00
libserialize
libstd Auto merge of #49315 - TheDan64:smaller_unsafe_block, r=joshtriplett 2018-03-25 05:26:58 +00:00
libstd_unicode
libsyntax Rollup merge of #49299 - SimonSapin:ubiquity, r=nikomatsakis 2018-03-25 01:30:12 +08:00
libsyntax_ext
libsyntax_pos
libterm
libtest
libunwind
llvm@6ceaaa4b01
llvm-emscripten@2717444753
rtstartup
rustc
rustllvm Polyfill LLVMBuildExactUDiv 2018-03-24 19:15:12 -07:00
stdsimd@bcb720e558
test Auto merge of #49297 - scottmcm:offset-from, r=dtolnay 2018-03-26 00:15:34 +00:00
tools Test fixes 2018-03-23 11:37:42 -07:00
Cargo.lock Rollup merge of #49203 - Eijebong:lets-cleanup-dependencies, r=Mark-Simulacrum 2018-03-25 01:26:36 +08:00
Cargo.toml
README.md
stage0.txt

This directory contains the source code of the rust project, including:

  • rustc and its tests
  • libstd
  • Various submodules for tools, like rustdoc, rls, etc.

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

Their is also useful content in the following READMEs, which are gradually being moved over to the guide: