about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-10-27 19:29:35 +0000
committerbors <bors@rust-lang.org>2018-10-27 19:29:35 +0000
commitcae6efc37d70ab7d353e6ab9ce229d59a65ed643 (patch)
tree755deb56e86b2436a04ccbab70b3506608e36075 /src/rustllvm/RustWrapper.cpp
parentb3b87609713887a27ebd07557af14e4aa57771f3 (diff)
parent2f7ea4a8725d433db4f34fca87eb7f61afb7ef9a (diff)
downloadrust-cae6efc37d70ab7d353e6ab9ce229d59a65ed643.tar.gz
rust-cae6efc37d70ab7d353e6ab9ce229d59a65ed643.zip
Auto merge of #54183 - qnighy:by-value-object-safety, r=oli-obk
Implement by-value object safety

This PR implements **by-value object safety**, which is part of unsized rvalues #48055. That means, with `#![feature(unsized_locals)]`, you can call a method `fn foo(self, ...)` on trait objects. One aim of this is to enable `Box<FnOnce>`  in the near future.

The difficulty here is this: when constructing a vtable for a trait `Foo`, we can't just put the function `<T as Foo>::foo` into the table. If `T` is no larger than `usize`, `self` is usually passed directly. However, as the caller of the vtable doesn't know the concrete `Self` type, we want a variant of `<T as Foo>::foo` where `self` is always passed by reference.

Therefore, when the compiler encounters such a method to be generated as a vtable entry, it produces a newly introduced instance called `InstanceDef::VtableShim(def_id)` (that wraps the original instance). the shim just derefs the receiver and calls the original method. We give different symbol names for the shims by appending `::{{vtable-shim}}` to the symbol path (and also adding vtable-shimness as an ingredient to the symbol hash).

r? @eddyb
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions