Skip to content

Commit

Permalink
Auto merge of #36126 - GuillaumeGomez:rollup, r=GuillaumeGomez
Browse files Browse the repository at this point in the history
Rollup of 16 pull requests

- Successful merges: #35418, #35759, #35862, #35863, #35895, #35962, #35977, #35993, #35997, #36054, #36056, #36060, #36086, #36100, #36103, #36125
- Failed merges: #35771, #35810
  • Loading branch information
bors committed Aug 30, 2016
2 parents addb753 + 2217fc5 commit badf406
Show file tree
Hide file tree
Showing 30 changed files with 385 additions and 136 deletions.
6 changes: 3 additions & 3 deletions src/doc/book/compiler-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ extern crate rustc;
extern crate rustc_plugin;
use syntax::parse::token;
use syntax::ast::TokenTree;
use syntax::tokenstream::TokenTree;
use syntax::ext::base::{ExtCtxt, MacResult, DummyResult, MacEager};
use syntax::ext::build::AstBuilder; // trait for expr_usize
use syntax_pos::Span;
use syntax::ext::quote::rt::Span;
use rustc_plugin::Registry;
fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree])
Expand All @@ -69,7 +69,7 @@ fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree])
}
let text = match args[0] {
TokenTree::Token(_, token::Ident(s, _)) => s.to_string(),
TokenTree::Token(_, token::Ident(s)) => s.to_string(),
_ => {
cx.span_err(sp, "argument should be a single identifier");
return DummyResult::any(sp);
Expand Down
6 changes: 6 additions & 0 deletions src/liballoc/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ const MAX_REFCOUNT: usize = (isize::MAX) as usize;
/// does not use atomics, making it both thread-unsafe as well as significantly
/// faster when updating the reference count.
///
/// Note: the inherent methods defined on `Arc<T>` are all associated functions,
/// which means that you have to call them as e.g. `Arc::get_mut(&value)`
/// instead of `value.get_mut()`. This is so that there are no conflicts with
/// methods on the inner type `T`, which are what you want to call in the
/// majority of cases.
///
/// # Examples
///
/// In this example, a large vector of data will be shared by several threads. First we
Expand Down
4 changes: 4 additions & 0 deletions src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ impl<T: ?Sized> Box<T> {
/// proper way to do so is to convert the raw pointer back into a
/// `Box` with the `Box::from_raw` function.
///
/// Note: this is an associated function, which means that you have
/// to call it as `Box::into_raw(b)` instead of `b.into_raw()`. This
/// is so that there is no conflict with a method on the inner type.
///
/// # Examples
///
/// ```
Expand Down
6 changes: 6 additions & 0 deletions src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ struct RcBox<T: ?Sized> {
/// A reference-counted pointer type over an immutable value.
///
/// See the [module level documentation](./index.html) for more details.
///
/// Note: the inherent methods defined on `Rc<T>` are all associated functions,
/// which means that you have to call them as e.g. `Rc::get_mut(&value)` instead
/// of `value.get_mut()`. This is so that there are no conflicts with methods
/// on the inner type `T`, which are what you want to call in the majority of
/// cases.
#[cfg_attr(stage0, unsafe_no_drop_flag)]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Rc<T: ?Sized> {
Expand Down
12 changes: 9 additions & 3 deletions src/libcollections/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,15 @@
//! provides some helper methods.
//!
//! Additionally, the return value of this function is `fmt::Result` which is a
//! typedef to `Result<(), std::io::Error>` (also known as `std::io::Result<()>`).
//! Formatting implementations should ensure that they return errors from `write!`
//! correctly (propagating errors upward).
//! type alias of `Result<(), std::fmt::Error>`. Formatting implementations
//! should ensure that they propagate errors from the `Formatter` (e.g., when
//! calling `write!`) however, they should never return errors spuriously. That
//! is, a formatting implementation must and may only return an error if the
//! passed-in `Formatter` returns an error. This is because, contrary to what
//! the function signature might suggest, string formatting is an infallible
//! operation. This function only returns a result because writing to the
//! underlying stream might fail and it must provide a way to propagate the fact
//! that an error has occurred back up the stack.
//!
//! An example of implementing the formatting traits would look
//! like:
Expand Down
49 changes: 39 additions & 10 deletions src/libcore/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,26 +119,55 @@
//! `Cell<T>`.
//!
//! ```
//! #![feature(core_intrinsics)]
//! #![feature(shared)]
//! use std::cell::Cell;
//! use std::ptr::Shared;
//! use std::intrinsics::abort;
//! use std::intrinsics::assume;
//!
//! struct Rc<T> {
//! ptr: *mut RcBox<T>
//! struct Rc<T: ?Sized> {
//! ptr: Shared<RcBox<T>>
//! }
//!
//! struct RcBox<T> {
//! # #[allow(dead_code)]
//! struct RcBox<T: ?Sized> {
//! strong: Cell<usize>,
//! refcount: Cell<usize>,
//! value: T,
//! refcount: Cell<usize>
//! }
//!
//! impl<T> Clone for Rc<T> {
//! impl<T: ?Sized> Clone for Rc<T> {
//! fn clone(&self) -> Rc<T> {
//! unsafe {
//! (*self.ptr).refcount.set((*self.ptr).refcount.get() + 1);
//! Rc { ptr: self.ptr }
//! }
//! self.inc_strong();
//! Rc { ptr: self.ptr }
//! }
//! }
//!
//! trait RcBoxPtr<T: ?Sized> {
//!
//! fn inner(&self) -> &RcBox<T>;
//!
//! fn strong(&self) -> usize {
//! self.inner().strong.get()
//! }
//!
//! fn inc_strong(&self) {
//! self.inner()
//! .strong
//! .set(self.strong()
//! .checked_add(1)
//! .unwrap_or_else(|| unsafe { abort() }));
//! }
//! }
//!
//! impl<T: ?Sized> RcBoxPtr<T> for Rc<T> {
//! fn inner(&self) -> &RcBox<T> {
//! unsafe {
//! assume(!(*(&self.ptr as *const _ as *const *const ())).is_null());
//! &(**self.ptr)
//! }
//! }
//! }
//! ```
//!

Expand Down
Loading

0 comments on commit badf406

Please sign in to comment.