-

+
Rust VERSION
SHORT_HASH
diff --git a/src/libcollections/btree/map.rs b/src/libcollections/btree/map.rs
index 492263da2bc5b..0ced4e1952aa5 100644
--- a/src/libcollections/btree/map.rs
+++ b/src/libcollections/btree/map.rs
@@ -1194,7 +1194,7 @@ unsafe fn unwrap_unchecked
(val: Option) -> T {
}
impl BTreeMap {
- /// Gets an iterator over the entries of the map.
+ /// Gets an iterator over the entries of the map, sorted by key.
///
/// # Examples
///
@@ -1202,9 +1202,9 @@ impl BTreeMap {
/// use std::collections::BTreeMap;
///
/// let mut map = BTreeMap::new();
- /// map.insert(1, "a");
- /// map.insert(2, "b");
/// map.insert(3, "c");
+ /// map.insert(2, "b");
+ /// map.insert(1, "a");
///
/// for (key, value) in map.iter() {
/// println!("{}: {}", key, value);
@@ -1224,7 +1224,7 @@ impl BTreeMap {
}
}
- /// Gets a mutable iterator over the entries of the map.
+ /// Gets a mutable iterator over the entries of the map, sorted by key.
///
/// # Examples
///
@@ -1257,7 +1257,7 @@ impl BTreeMap {
}
}
- /// Gets an iterator over the keys of the map.
+ /// Gets an iterator over the keys of the map, in sorted order.
///
/// # Examples
///
@@ -1265,8 +1265,8 @@ impl BTreeMap {
/// use std::collections::BTreeMap;
///
/// let mut a = BTreeMap::new();
- /// a.insert(1, "a");
/// a.insert(2, "b");
+ /// a.insert(1, "a");
///
/// let keys: Vec<_> = a.keys().cloned().collect();
/// assert_eq!(keys, [1, 2]);
@@ -1276,7 +1276,7 @@ impl BTreeMap {
Keys { inner: self.iter() }
}
- /// Gets an iterator over the values of the map.
+ /// Gets an iterator over the values of the map, in order by key.
///
/// # Examples
///
@@ -1284,11 +1284,11 @@ impl BTreeMap {
/// use std::collections::BTreeMap;
///
/// let mut a = BTreeMap::new();
- /// a.insert(1, "a");
- /// a.insert(2, "b");
+ /// a.insert(1, "hello");
+ /// a.insert(2, "goodbye");
///
/// let values: Vec<&str> = a.values().cloned().collect();
- /// assert_eq!(values, ["a", "b"]);
+ /// assert_eq!(values, ["hello", "goodbye"]);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn values<'a>(&'a self) -> Values<'a, K, V> {
diff --git a/src/librustc_borrowck/diagnostics.rs b/src/librustc_borrowck/diagnostics.rs
index 1f5824f82e486..7ad4d3ca70898 100644
--- a/src/librustc_borrowck/diagnostics.rs
+++ b/src/librustc_borrowck/diagnostics.rs
@@ -124,7 +124,7 @@ fn main() {
let mut x = Rc::new(RefCell::new(MyStruct{ s: 5u32 }));
let y = x.clone();
x.borrow_mut().s = 6;
- println!("{}", x.borrow.s);
+ println!("{}", x.borrow().s);
}
```
diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs
index 04ab3fe70e9fa..dc6da1f0ef847 100644
--- a/src/librustc_resolve/diagnostics.rs
+++ b/src/librustc_resolve/diagnostics.rs
@@ -207,7 +207,41 @@ https://doc.rust-lang.org/reference.html#statements
E0317: r##"
User-defined types or type parameters cannot shadow the primitive types.
This error indicates you tried to define a type, struct or enum with the same
-name as an existing primitive type.
+name as an existing primitive type:
+
+```
+struct u8 {
+ // ...
+}
+```
+
+To fix this, simply name it something else.
+
+Such an error may also occur if you define a type parameter which shadows a
+primitive type. An example would be something like:
+
+```
+impl MyTrait for Option {
+ // ...
+}
+```
+
+In such a case, if you meant for `u8` to be a generic type parameter (i.e. any
+type can be used in its place), use something like `T` instead:
+
+```
+impl MyTrait for Option {
+ // ...
+}
+```
+
+On the other hand, if you wished to refer to the specific type `u8`, remove it
+from the type parameter list:
+
+```
+impl MyTrait for Option {
+ // ...
+}
See the Types section of the reference for more information about the primitive
types:
diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs
index 0e095ed674d0e..db4f8d3a70c40 100644
--- a/src/librustc_typeck/collect.rs
+++ b/src/librustc_typeck/collect.rs
@@ -1918,8 +1918,8 @@ fn get_or_create_type_parameter_def<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
lint::builtin::INVALID_TYPE_PARAM_DEFAULT,
param.id,
param.span,
- format!("defaults for type parameters are only allowed on type definitions, \
- like `struct` or `enum`"));
+ format!("defaults for type parameters are only allowed in `struct`, \
+ `enum`, `type`, or `trait` definitions."));
}
}
diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs
index fdc23f89de237..8f7692c794540 100644
--- a/src/librustc_typeck/diagnostics.rs
+++ b/src/librustc_typeck/diagnostics.rs
@@ -2269,6 +2269,8 @@ struct MyType(T);
impl ForeignTrait for MyType { ... } // Ok
```
+Please note that a type alias is not sufficient.
+
For another example of an error, suppose there's another trait defined in `foo`
named `ForeignTrait2` that takes two type parameters. Then this `impl` results
in the same rule violation:
diff --git a/src/librustdoc/html/layout.rs b/src/librustdoc/html/layout.rs
index 227981d68fbb4..ffcd22fa82096 100644
--- a/src/librustdoc/html/layout.rs
+++ b/src/librustdoc/html/layout.rs
@@ -148,7 +148,7 @@ r##"
"".to_string()
} else {
format!("\
-
",
+
",
page.root_path, layout.krate,
layout.logo)
},
diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css
index 0bde582c19f28..c751cdeb6f790 100644
--- a/src/librustdoc/html/static/rustdoc.css
+++ b/src/librustdoc/html/static/rustdoc.css
@@ -383,7 +383,7 @@ a {
}
.content span.enum, .content a.enum, .block a.current.enum { color: #5e9766; }
-.content span.struct, .content a.struct, .block a.current.struct { color: #e53700; }
+.content span.struct, .content a.struct, .block a.current.struct { color: #df3600; }
.content a.type { color: #e57300; }
.content a.macro { color: #068000; }
.block a.current.crate { font-weight: 500; }
diff --git a/src/librustdoc/html/static/styles/main.css b/src/librustdoc/html/static/styles/main.css
index e138d62f986c1..02bb5221886df 100644
--- a/src/librustdoc/html/static/styles/main.css
+++ b/src/librustdoc/html/static/styles/main.css
@@ -106,14 +106,14 @@ a {
}
.docblock a, .stability a {
- color: #4e8bca;
+ color: #3873AD;
}
a.test-arrow {
color: #f5f5f5;
}
-.content span.trait, .content a.trait, .block a.current.trait { color: #8866ff; }
+.content span.trait, .content a.trait, .block a.current.trait { color: #7c5af3; }
.search-input {
color: #555;
diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs
index e43101b7c9d0d..43bf86a00399c 100644
--- a/src/libstd/collections/hash/map.rs
+++ b/src/libstd/collections/hash/map.rs
@@ -272,6 +272,35 @@ fn test_resize_policy() {
/// }
/// ```
///
+/// `HashMap` also implements an [`Entry API`](#method.entry), which allows
+/// for more complex methods of getting, setting, updating and removing keys and
+/// their values:
+///
+/// ```
+/// use std::collections::HashMap;
+///
+/// // type inference lets us omit an explicit type signature (which
+/// // would be `HashMap<&str, u8>` in this example).
+/// let mut player_stats = HashMap::new();
+///
+/// fn random_stat_buff() -> u8 {
+/// // could actually return some random value here - let's just return
+/// // some fixed value for now
+/// 42
+/// }
+///
+/// // insert a key only if it doesn't already exist
+/// player_stats.entry("health").or_insert(100);
+///
+/// // insert a key using a function that provides a new value only if it
+/// // doesn't already exist
+/// player_stats.entry("defence").or_insert_with(random_stat_buff);
+///
+/// // update a key, guarding against the key possibly not being set
+/// let stat = player_stats.entry("attack").or_insert(100);
+/// *stat += random_stat_buff();
+/// ```
+///
/// The easiest way to use `HashMap` with a custom type as key is to derive `Eq` and `Hash`.
/// We must also derive `PartialEq`.
///
diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs
index d6aa746f4cb53..9d505607a60c4 100644
--- a/src/libstd/ffi/c_str.rs
+++ b/src/libstd/ffi/c_str.rs
@@ -407,7 +407,6 @@ impl CStr {
/// # fn main() {
/// use std::ffi::CStr;
/// use std::os::raw::c_char;
- /// use std::str;
///
/// extern {
/// fn my_string() -> *const c_char;
@@ -415,8 +414,7 @@ impl CStr {
///
/// unsafe {
/// let slice = CStr::from_ptr(my_string());
- /// println!("string returned: {}",
- /// str::from_utf8(slice.to_bytes()).unwrap());
+ /// println!("string returned: {}", slice.to_str().unwrap());
/// }
/// # }
/// ```
diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs
index 414a0ebd11fa2..187a1797dac04 100644
--- a/src/libstd/fs.rs
+++ b/src/libstd/fs.rs
@@ -414,7 +414,7 @@ impl OpenOptions {
/// This option, when true, will indicate that the file should be
/// `write`-able if opened.
///
- /// If a file already exist, any write calls on the file will overwrite its
+ /// If the file already exists, any write calls on it will overwrite its
/// contents, without truncating it.
///
/// # Examples
@@ -487,8 +487,8 @@ impl OpenOptions {
/// This option indicates whether a new file will be created if the file
/// does not yet already exist.
///
- /// The file must be opened with write or append access in order to create
- /// a new file.
+ /// In order for the file to be created, `write` or `append` access must
+ /// be used.
///
/// # Examples
///
diff --git a/src/libstd/sync/semaphore.rs b/src/libstd/sync/semaphore.rs
index 8f08c840c218b..ac5ce298c5c6f 100644
--- a/src/libstd/sync/semaphore.rs
+++ b/src/libstd/sync/semaphore.rs
@@ -13,7 +13,7 @@
of resources is currently unclear",
issue = "27798")]
#![rustc_deprecated(since = "1.7.0",
- reason = "easily confused with system sempahores and not \
+ reason = "easily confused with system semaphores and not \
used enough to pull its weight")]
#![allow(deprecated)]
diff --git a/src/test/auxiliary/issue_30123_aux.rs b/src/test/auxiliary/issue_30123_aux.rs
new file mode 100644
index 0000000000000..f60311a9400b3
--- /dev/null
+++ b/src/test/auxiliary/issue_30123_aux.rs
@@ -0,0 +1,33 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 or the MIT license
+// , at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use std::marker::PhantomData;
+
+pub struct Directed;
+pub struct Undirected;
+
+pub struct Graph {
+ nodes: Vec>,
+ edges: Vec>,
+ ty: PhantomData,
+}
+
+
+impl Graph {
+ pub fn new() -> Self {
+ Graph{nodes: Vec::new(), edges: Vec::new(), ty: PhantomData}
+ }
+}
+
+impl Graph {
+ pub fn new_undirected() -> Self {
+ Graph{nodes: Vec::new(), edges: Vec::new(), ty: PhantomData}
+ }
+}
diff --git a/src/test/compile-fail/issue-30123.rs b/src/test/compile-fail/issue-30123.rs
new file mode 100644
index 0000000000000..cfd3cd3af3ebc
--- /dev/null
+++ b/src/test/compile-fail/issue-30123.rs
@@ -0,0 +1,19 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 or the MIT license
+// , at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// aux-build:issue_30123_aux.rs
+
+extern crate issue_30123_aux;
+use issue_30123_aux::*;
+
+fn main() {
+ let ug = Graph::::new_undirected();
+ //~^ ERR no associated item named `new_undirected` found for type
+}