Skip to content

Commit

Permalink
Rollup merge of rust-lang#35281 - apasel422:repr, r=steveklabnik
Browse files Browse the repository at this point in the history
Clean up `std::raw` docs

There is no longer a `Repr` trait, so mentioning a missing impl of it was potentially confusing.

r? @steveklabnik
  • Loading branch information
Jonathan Turner authored Aug 4, 2016
2 parents 3b948b3 + 33a4806 commit 69b78db
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/libcore/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@
/// only designed to be used by unsafe code that needs to manipulate
/// the low-level details.
///
/// There is no `Repr` implementation for `TraitObject` because there
/// is no way to refer to all trait objects generically, so the only
/// There is no way to refer to all trait objects generically, so the only
/// way to create values of this type is with functions like
/// `std::mem::transmute`. Similarly, the only way to create a true
/// [`std::mem::transmute`][transmute]. Similarly, the only way to create a true
/// trait object from a `TraitObject` value is with `transmute`.
///
/// [transmute]: ../mem/fn.transmute.html
///
/// Synthesizing a trait object with mismatched types—one where the
/// vtable does not correspond to the type of the value to which the
/// data pointer points—is highly likely to lead to undefined
Expand All @@ -50,13 +51,13 @@
/// ```
/// #![feature(raw)]
///
/// use std::mem;
/// use std::raw;
/// use std::{mem, raw};
///
/// // an example trait
/// trait Foo {
/// fn bar(&self) -> i32;
/// }
///
/// impl Foo for i32 {
/// fn bar(&self) -> i32 {
/// *self + 1
Expand All @@ -74,19 +75,18 @@
/// // the data pointer is the address of `value`
/// assert_eq!(raw_object.data as *const i32, &value as *const _);
///
///
/// let other_value: i32 = 456;
///
/// // construct a new object, pointing to a different `i32`, being
/// // careful to use the `i32` vtable from `object`
/// let synthesized: &Foo = unsafe {
/// mem::transmute(raw::TraitObject {
/// data: &other_value as *const _ as *mut (),
/// vtable: raw_object.vtable
/// vtable: raw_object.vtable,
/// })
/// };
///
/// // it should work just like we constructed a trait object out of
/// // it should work just as if we had constructed a trait object out of
/// // `other_value` directly
/// assert_eq!(synthesized.bar(), 457);
/// ```
Expand Down

0 comments on commit 69b78db

Please sign in to comment.