Skip to content

Rollup of 8 pull requests #32173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Mar 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
e36c7da
Clarify documentation of `hash::SipHasher`
dirk Mar 7, 2016
054196d
Amend `hash::SipHasher` docs to more strongly discourage cryptographi…
dirk Mar 7, 2016
d7e406e
Remove final note from testing chapter.
pyfisch Mar 8, 2016
99eee83
Add missing documentation examples for BTreeSet.
nathankleyn Mar 8, 2016
46dc35e
Link to actual CSPRNG in `hash::SipHasher` documentation
dirk Mar 9, 2016
df550de
Clarify that try_unwrap needs exactly one
steveklabnik Mar 9, 2016
0f426aa
Small grammar fix in Guessing Game
steveklabnik Mar 9, 2016
aaca317
Add other primitive types to the reference
steveklabnik Mar 9, 2016
7848469
Remove inaccurate claim about inline assembly
steveklabnik Mar 9, 2016
d9dba76
Prefer 'associated function' over 'static method' in msg.
frewsxcv Feb 23, 2016
09e08ba
Rollup merge of #31830 - frewsxcv:assoc-func, r=steveklabnik
steveklabnik Mar 10, 2016
3e764ef
Rollup merge of #32091 - dirk:dirk/siphasher-docs-clarification, r=al…
steveklabnik Mar 10, 2016
3820d38
Rollup merge of #32125 - pyfisch:patch-2, r=steveklabnik
steveklabnik Mar 10, 2016
d6c4b53
Rollup merge of #32136 - nathankleyn:improve-docs-for-btreeset, r=ste…
steveklabnik Mar 10, 2016
76bcf64
Rollup merge of #32147 - steveklabnik:gh31950, r=bluss
steveklabnik Mar 10, 2016
c5ec055
Rollup merge of #32148 - steveklabnik:gh31912, r=apasel422
steveklabnik Mar 10, 2016
fc9bc7a
Rollup merge of #32149 - steveklabnik:gh31628, r=bluss
steveklabnik Mar 10, 2016
4f8d029
Rollup merge of #32150 - steveklabnik:gh20213, r=bluss
steveklabnik Mar 10, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/doc/book/guessing-game.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ Rust warns us that we haven’t used the `Result` value. This warning comes from
a special annotation that `io::Result` has. Rust is trying to tell you that
you haven’t handled a possible error. The right way to suppress the error is
to actually write error handling. Luckily, if we want to crash if there’s
a problem, we can use these two little methods. If we can recover from the
a problem, we can use `expect()`. If we can recover from the
error somehow, we’d do something else, but we’ll save that for a future
project.

Expand Down
3 changes: 1 addition & 2 deletions src/doc/book/inline-assembly.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

For extremely low-level manipulations and performance reasons, one
might wish to control the CPU directly. Rust supports using inline
assembly to do this via the `asm!` macro. The syntax roughly matches
that of GCC & Clang:
assembly to do this via the `asm!` macro.

```ignore
asm!(assembly template
Expand Down
4 changes: 0 additions & 4 deletions src/doc/book/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,3 @@ you add more examples.

We haven’t covered all of the details with writing documentation tests. For more,
please see the [Documentation chapter](documentation.html).

One final note: documentation tests *cannot* be run on binary crates.
To see more on file arrangement see the [Crates and
Modules](crates-and-modules.html) section.
4 changes: 4 additions & 0 deletions src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -3328,6 +3328,10 @@ The primitive types are the following:
* The boolean type `bool` with values `true` and `false`.
* The machine types (integer and floating-point).
* The machine-dependent integer types.
* Arrays
* Tuples
* Slices
* Function pointers

#### Machine types

Expand Down
5 changes: 3 additions & 2 deletions src/liballoc/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,12 @@ impl<T> Arc<T> {
Arc { _ptr: unsafe { Shared::new(Box::into_raw(x)) } }
}

/// Unwraps the contained value if the `Arc<T>` has only one strong reference.
/// This will succeed even if there are outstanding weak references.
/// Unwraps the contained value if the `Arc<T>` has exactly one strong reference.
///
/// Otherwise, an `Err` is returned with the same `Arc<T>`.
///
/// This will succeed even if there are outstanding weak references.
///
/// # Examples
///
/// ```
Expand Down
5 changes: 3 additions & 2 deletions src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,12 @@ impl<T> Rc<T> {
}
}

/// Unwraps the contained value if the `Rc<T>` has only one strong reference.
/// This will succeed even if there are outstanding weak references.
/// Unwraps the contained value if the `Rc<T>` has exactly one strong reference.
///
/// Otherwise, an `Err` is returned with the same `Rc<T>`.
///
/// This will succeed even if there are outstanding weak references.
///
/// # Examples
///
/// ```
Expand Down
30 changes: 30 additions & 0 deletions src/libcollections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,36 @@ use Bound;
/// [`Ord`]: ../../core/cmp/trait.Ord.html
/// [`Cell`]: ../../std/cell/struct.Cell.html
/// [`RefCell`]: ../../std/cell/struct.RefCell.html
///
/// # Examples
///
/// ```
/// use std::collections::BTreeSet;
///
/// // Type inference lets us omit an explicit type signature (which
/// // would be `BTreeSet<&str>` in this example).
/// let mut books = BTreeSet::new();
///
/// // Add some books.
/// books.insert("A Dance With Dragons");
/// books.insert("To Kill a Mockingbird");
/// books.insert("The Odyssey");
/// books.insert("The Great Gatsby");
///
/// // Check for a specific one.
/// if !books.contains("The Winds of Winter") {
/// println!("We have {} books, but The Winds of Winter ain't one.",
/// books.len());
/// }
///
/// // Remove a book.
/// books.remove("The Odyssey");
///
/// // Iterate over everything.
/// for book in &books {
/// println!("{}", book);
/// }
/// ```
#[derive(Clone, Hash, PartialEq, Eq, Ord, PartialOrd)]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct BTreeSet<T> {
Expand Down
18 changes: 10 additions & 8 deletions src/libcore/hash/sip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@ use super::Hasher;
///
/// See: http://131002.net/siphash/
///
/// Consider this as a main "general-purpose" hash for all hashtables: it
/// runs at good speed (competitive with spooky and city) and permits
/// strong _keyed_ hashing. Key your hashtables from a strong RNG,
/// such as `rand::Rng`.
/// This is currently the default hashing function used by standard library
/// (eg. `collections::HashMap` uses it by default).
///
/// Although the SipHash algorithm is considered to be cryptographically
/// strong, this implementation has not been reviewed for such purposes.
/// As such, all cryptographic uses of this implementation are strongly
/// discouraged.
/// SipHash is a general-purpose hashing function: it runs at a good
/// speed (competitive with Spooky and City) and permits strong _keyed_
/// hashing. This lets you key your hashtables from a strong RNG, such as
/// [`rand::os::OsRng`](https://doc.rust-lang.org/rand/rand/os/struct.OsRng.html).
///
/// Although the SipHash algorithm is considered to be generally strong,
/// it is not intended for cryptographic purposes. As such, all
/// cryptographic uses of this implementation are _strongly discouraged_.
#[stable(feature = "rust1", since = "1.0.0")]
pub struct SipHasher {
k0: u64,
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_typeck/check/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
if !static_sources.is_empty() {
err.fileline_note(
span,
"found defined static methods, maybe a `self` is missing?");
"found the following associated functions; to be used as \
methods, functions must have a `self` parameter");

report_candidates(fcx, &mut err, span, item_name, static_sources);
}
Expand Down
7 changes: 4 additions & 3 deletions src/test/compile-fail/issue-7575.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// except according to those terms.

// Test the mechanism for warning about possible missing `self` declarations.
// ignore-tidy-linelength

trait CtxtFn {
fn f8(self, usize) -> usize;
Expand Down Expand Up @@ -72,15 +73,15 @@ impl ManyImplTrait for Myisize {}
fn no_param_bound(u: usize, m: Myisize) -> usize {
u.f8(42) + u.f9(342) + m.fff(42)
//~^ ERROR no method named `f9` found for type `usize` in the current scope
//~^^ NOTE found defined static methods, maybe a `self` is missing?
//~^^ NOTE found the following associated functions; to be used as methods, functions must have a `self` parameter
//~^^^ ERROR no method named `fff` found for type `Myisize` in the current scope
//~^^^^ NOTE found defined static methods, maybe a `self` is missing?
//~^^^^ NOTE found the following associated functions; to be used as methods, functions must have a `self` parameter
}

fn param_bound<T: ManyImplTrait>(t: T) -> bool {
t.is_str()
//~^ ERROR no method named `is_str` found for type `T` in the current scope
//~^^ NOTE found defined static methods, maybe a `self` is missing?
//~^^ NOTE found the following associated functions; to be used as methods, functions must have a `self` parameter
}

fn main() {
Expand Down