rust/src
bors 3fc70e8d46 Auto merge of #54383 - mikeyhew:custom-receivers-object-safety, r=nikomatsakis
Take 2: Implement object-safety and dynamic dispatch for arbitrary_self_types

This replaces #50173. Over the months that that PR was open, we made a lot of changes to the way this was going to be implemented, and the long, meandering comment thread and commit history would have been confusing to people reading it in the future. So I decided to package everything up with new, straighforward commits and open a new PR.

Here are the main points. Please read the commit messages for details.

- To simplify codegen, we only support receivers that have the ABI of a pointer. That means they are builtin pointer types, or newtypes thereof.
- We introduce a new trait: `DispatchFromDyn<T>`, similar to `CoerceUnsized<T>`. `DispatchFromDyn` has extra requirements that `CoerceUnsized` does not: when you implement `DispatchFromDyn` for a struct, there cannot be any extra fields besides the field being coerced and `PhantomData` fields. This ensures that the struct's ABI is the same as a pointer.
- For a method's receiver (e.g. `self: Rc<Self>`) to be object-safe, it needs to have the following property:
    - let `DynReceiver` be the receiver when `Self = dyn Trait`
    - let `ConcreteReceiver` be the receiver when `Self = T`, where `T` is some unknown `Sized` type that implements `Trait`, and is the erased type of the trait object.
    - `ConcreteReceiver` must implement `DispatchFromDyn<DynReceiver>`

In the case of `Rc<Self>`, this requires `Rc<T>: DispatchFromDyn<Rc<dyn Trait>>`

These rules are explained more thoroughly in the doc comment on `receiver_is_dispatchable` in object_safety.rs.

r? @nikomatsakis and @eddyb

cc @arielb1 @cramertj @withoutboats

Special thanks to @nikomatsakis for getting me un-stuck when implementing the object-safety checks, and @eddyb for helping with the codegen parts.

EDIT 2018-11-01: updated because CoerceSized has been replaced with DispatchFromDyn
2018-11-03 02:37:29 +00:00
..
bootstrap Auto merge of #54543 - GuillaumeGomez:top-level-index, r=QuietMisdreavus 2018-11-02 15:39:25 +00:00
build_helper Prefer unwrap_or_else to unwrap_or in case of function calls/allocations 2018-10-19 09:45:45 +02:00
ci Update enum debuginfo tests 2018-10-30 12:09:04 -06:00
dlmalloc@c99638dc2e
doc Auto merge of #54543 - GuillaumeGomez:top-level-index, r=QuietMisdreavus 2018-11-02 15:39:25 +00:00
etc Rollup merge of #55447 - frewsxcv:frewsxcv-rename, r=Mark-Simulacrum 2018-10-29 09:47:52 +01:00
grammar
jemalloc@1f5a28755e
liballoc Replace CoerceSized trait with DispatchFromDyn 2018-11-01 18:16:59 -04:00
liballoc_jemalloc Bump to 1.31.0 and bootstrap from 1.30 beta 2018-09-27 20:52:53 -07:00
liballoc_system std: Synchronize global allocator on wasm32 2018-10-09 23:35:45 -07:00
libarena Update TypedArena tests 2018-10-19 14:34:44 +02:00
libbacktrace@f4d02bbdbf
libcompiler_builtins@939cbca6e9 Update compiler-builtins submodule 2018-10-30 10:51:55 -07:00
libcore update DispatchFromDyn doctest 2018-11-01 18:16:59 -04:00
libfmt_macros remove padding from multiline format string label 2018-10-03 14:29:39 -04:00
libgraphviz Remove graphviz::IntoCow 2018-10-05 14:16:10 +02:00
liblibc@1844a772b6
libpanic_abort wasm: Explicitly export all symbols with LLD 2018-10-02 13:49:51 -07:00
libpanic_unwind Bump to 1.31.0 and bootstrap from 1.30 beta 2018-09-27 20:52:53 -07:00
libproc_macro All proc_macro_span APIs tracked at #54725 now 2018-10-01 12:15:35 -07:00
libprofiler_builtins Bump to 1.31.0 and bootstrap from 1.30 beta 2018-09-27 20:52:53 -07:00
librustc Auto merge of #54383 - mikeyhew:custom-receivers-object-safety, r=nikomatsakis 2018-11-03 02:37:29 +00:00
librustc_allocator Bump to 1.31.0 and bootstrap from 1.30 beta 2018-09-27 20:52:53 -07:00
librustc_apfloat Bump to 1.31.0 and bootstrap from 1.30 beta 2018-09-27 20:52:53 -07:00
librustc_asan Rollup merge of #54681 - alexcrichton:san-names, r=kennytm 2018-10-01 16:13:04 +08:00
librustc_borrowck Auto merge of #55150 - pnkfelix:issues-47215-54797-fix-ice-from-moving-out-of-thread-local-under-ast-borrowck, r=nikomatsakis 2018-10-27 09:56:37 +00:00
librustc_codegen_llvm Auto merge of #54383 - mikeyhew:custom-receivers-object-safety, r=nikomatsakis 2018-11-03 02:37:29 +00:00
librustc_codegen_utils Auto merge of #54183 - qnighy:by-value-object-safety, r=oli-obk 2018-10-27 19:29:35 +00:00
librustc_cratesio_shim Bump to 1.31.0 and bootstrap from 1.30 beta 2018-09-27 20:52:53 -07:00
librustc_data_structures Bump nightly to 1.32.0 2018-10-31 11:53:50 -07:00
librustc_driver Add extern crate items to extern prelude 2018-10-24 00:14:50 +03:00
librustc_errors Pass suggestions as impl Iterator instead of Vec 2018-10-31 13:56:20 +01:00
librustc_fs_util
librustc_incremental Prefer Default::default over FxHash*::default in struct constructors 2018-10-19 14:34:44 +02:00
librustc_lint don't lint unused_parens on if (break _) 2018-10-29 12:41:56 +01:00
librustc_llvm Revert "rustc: Fix (again) simd vectors by-val in ABI" 2018-10-23 00:59:14 -07:00
librustc_lsan Bump to 1.31.0 and bootstrap from 1.30 beta 2018-09-27 20:52:53 -07:00
librustc_metadata Auto merge of #54626 - alexcrichton:dwarf-generics, r=michaelwoerister 2018-10-26 14:30:26 +00:00
librustc_metadata_utils
librustc_mir Auto merge of #55087 - levex:e0669-improve-span, r=nagisa 2018-11-02 18:28:51 +00:00
librustc_msan Bump to 1.31.0 and bootstrap from 1.30 beta 2018-09-27 20:52:53 -07:00
librustc_passes Emit Retag statements, kill Validate statements 2018-10-29 09:05:18 +01:00
librustc_platform_intrinsics Bump to 1.31.0 and bootstrap from 1.30 beta 2018-09-27 20:52:53 -07:00
librustc_plugin Bump to 1.31.0 and bootstrap from 1.30 beta 2018-09-27 20:52:53 -07:00
librustc_privacy Deprecate the FxHashMap() and FxHashSet() constructor function hack 2018-10-19 14:34:44 +02:00
librustc_resolve Rollup merge of #55536 - ljedrz:don't_collect_suggestions, r=davidtwco 2018-11-01 22:52:13 +08:00
librustc_save_analysis save analysis: don't dump macro refs 2018-10-31 13:29:02 +13:00
librustc_target Bump nightly to 1.32.0 2018-10-31 11:53:50 -07:00
librustc_traits Change a flat_map with 0/1-element vecs to a filter_map 2018-10-29 16:28:33 +01:00
librustc_tsan Rollup merge of #54681 - alexcrichton:san-names, r=kennytm 2018-10-01 16:13:04 +08:00
librustc_typeck Auto merge of #54383 - mikeyhew:custom-receivers-object-safety, r=nikomatsakis 2018-11-03 02:37:29 +00:00
librustdoc Auto merge of #54543 - GuillaumeGomez:top-level-index, r=QuietMisdreavus 2018-11-02 15:39:25 +00:00
libserialize Bump to 1.31.0 and bootstrap from 1.30 beta 2018-09-27 20:52:53 -07:00
libstd Auto merge of #54043 - fintelia:raw_entry, r=alexcrichton 2018-11-02 07:04:07 +00:00
libsyntax Rollup merge of #55558 - nnethercote:tweak-MatcherPos-matches, r=petrochenkov 2018-11-01 22:52:17 +08:00
libsyntax_ext syntax: improve a few allocations 2018-10-31 16:58:51 +01:00
libsyntax_pos Rename other occs of (Code/File)Map to Source(Map/File) #51574 2018-10-29 21:26:13 +01:00
libterm Bump to 1.31.0 and bootstrap from 1.30 beta 2018-09-27 20:52:53 -07:00
libtest add option to libtest to run all tests 2018-10-14 00:58:17 +02:00
libunwind Bump to 1.31.0 and bootstrap from 1.30 beta 2018-09-27 20:52:53 -07:00
llvm@7051ead40a Fix DWARF generation for enums 2018-10-30 12:06:07 -06:00
llvm-emscripten@2717444753
rtstartup
rustc
rustllvm Fix DWARF generation for enums 2018-10-30 12:06:07 -06:00
stdsimd@431766a3fb Update stdsimd submodule 2018-10-23 09:51:02 -07:00
test Auto merge of #54383 - mikeyhew:custom-receivers-object-safety, r=nikomatsakis 2018-11-03 02:37:29 +00:00
tools Update clippy 2018-11-01 13:58:07 -07:00
.gitignore
Cargo.lock Bump nightly to 1.32.0 2018-10-31 11:53:50 -07:00
Cargo.toml Use rls-data 0.18.1 2018-09-28 01:54:01 +02:00
README.md
stage0.txt Bump nightly to 1.32.0 2018-10-31 11:53:50 -07:00

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: