From 64137c485a99c12517e98f67d00204570fa879ee Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Wed, 22 Jun 2016 08:24:16 -0400 Subject: [PATCH 01/12] Parameters in doc comment should be formatted code-like. --- src/libstd/thread/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 1f78b32bcf38e..188b596c67991 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -423,10 +423,10 @@ pub fn park() { /// the specified duration has been reached (may wake spuriously). /// /// The semantics of this function are equivalent to `park()` except that the -/// thread will be blocked for roughly no longer than *ms*. This method +/// thread will be blocked for roughly no longer than `ms`. This method /// should not be used for precise timing due to anomalies such as /// preemption or platform differences that may not cause the maximum -/// amount of time waited to be precisely *ms* long. +/// amount of time waited to be precisely `ms` long. /// /// See the module doc for more detail. #[stable(feature = "rust1", since = "1.0.0")] @@ -439,10 +439,10 @@ pub fn park_timeout_ms(ms: u32) { /// the specified duration has been reached (may wake spuriously). /// /// The semantics of this function are equivalent to `park()` except that the -/// thread will be blocked for roughly no longer than *dur*. This method +/// thread will be blocked for roughly no longer than `dur`. This method /// should not be used for precise timing due to anomalies such as /// preemption or platform differences that may not cause the maximum -/// amount of time waited to be precisely *dur* long. +/// amount of time waited to be precisely `dur` long. /// /// See the module doc for more detail. /// From 03f9dd21d6c181195e1ee024c9b8a188d23d5183 Mon Sep 17 00:00:00 2001 From: Fabian Vogt Date: Wed, 22 Jun 2016 15:09:11 +0200 Subject: [PATCH 02/12] Fix typo in bootstrap README "boostrap" instead of "bootstrap" --- src/bootstrap/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/README.md b/src/bootstrap/README.md index 942f070c82fd8..57d644d635cf7 100644 --- a/src/bootstrap/README.md +++ b/src/bootstrap/README.md @@ -50,7 +50,7 @@ compiler. What actually happens when you invoke rustbuild is: 1. The entry point script, `src/bootstrap/bootstrap.py` is run. This script is responsible for downloading the stage0 compiler/Cargo binaries, and it then compiles the build system itself (this folder). Finally, it then invokes the - actual `boostrap` binary build system. + actual `bootstrap` binary build system. 2. In Rust, `bootstrap` will slurp up all configuration, perform a number of sanity checks (compilers exist for example), and then start building the stage0 artifacts. From eb17527039c466f6f79c595f9f99a1a324a85955 Mon Sep 17 00:00:00 2001 From: Alfie John Date: Thu, 23 Jun 2016 06:20:29 +1000 Subject: [PATCH 03/12] Switched tense to clarify what is happening in the example --- src/doc/book/patterns.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/book/patterns.md b/src/doc/book/patterns.md index 7ecfdcfcc1e02..a0245d4c7b163 100644 --- a/src/doc/book/patterns.md +++ b/src/doc/book/patterns.md @@ -174,7 +174,7 @@ Here, we bind the first and last element of the tuple to `x` and `z`, but ignore the middle element. It’s worth noting that using `_` never binds the value in the first place, -which means a value may not move: +which means that the value does not move: ```rust let tuple: (u32, String) = (5, String::from("five")); From bbc33ac5050cc4e351f03f139a360efb0f2439ce Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Tue, 21 Jun 2016 21:41:02 -0400 Subject: [PATCH 04/12] Add example for `std::thread::sleep`. --- src/libstd/thread/mod.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index c474aa60b3ee4..30c337ab7bc7b 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -379,6 +379,19 @@ pub fn sleep_ms(ms: u32) { /// signal being received or a spurious wakeup. Platforms which do not support /// nanosecond precision for sleeping will have `dur` rounded up to the nearest /// granularity of time they can sleep for. +/// +/// # Examples +/// +/// ``` +/// use std::{thread, time}; +/// +/// let ten_millis = time::Duration::from_millis(10); +/// let now = time::Instant::now(); +/// +/// thread::sleep(ten_millis); +/// +/// assert!(now.elapsed() >= ten_millis); +/// ``` #[stable(feature = "thread_sleep", since = "1.4.0")] pub fn sleep(dur: Duration) { imp::Thread::sleep(dur) From 2d7bac7d865a3c77f2fb05b9505d81d068df5551 Mon Sep 17 00:00:00 2001 From: Liigo Zhuang Date: Mon, 20 Jun 2016 16:19:19 +0800 Subject: [PATCH 05/12] Improve diagnostics E0425: `use` (public) items E0425: unresolved name --- src/librustc_resolve/diagnostics.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 208b5f11e20d1..4e4f6e276d1dd 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -843,6 +843,17 @@ Or: let unknown_variable = 12u32; let x = unknown_variable; // ok! ``` + +If the item is not defined in the current module, it must be imported using a +`use` statement, like so: + +```ignore +use foo::bar; +bar(); +``` + +If the item you are importing is not defined in some super-module of the +current module, then it must also be declared as public (e.g., `pub fn`). "##, E0426: r##" From 5215acc27b05da8799e9cd5538e51d872989fe68 Mon Sep 17 00:00:00 2001 From: Seo Sanghyeon Date: Fri, 24 Jun 2016 03:33:40 +0900 Subject: [PATCH 06/12] Fix typo in future incompatible lint --- src/librustc_lint/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index ed12d0d9f3c11..7baadb2b69a5f 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -163,7 +163,7 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { }, FutureIncompatibleInfo { id: LintId::of(INVALID_TYPE_PARAM_DEFAULT), - reference: "PR 30742 ", + reference: "PR 30724 ", }, FutureIncompatibleInfo { id: LintId::of(SUPER_OR_SELF_IN_GLOBAL_PATH), From 0187aec8e0f7cb148c5360ab5d3953ee86394061 Mon Sep 17 00:00:00 2001 From: Paul Jarrett Date: Thu, 23 Jun 2016 23:02:30 -0400 Subject: [PATCH 07/12] Renames "lets_do_this" macro more appropriately. The macro gets used to create a mapping of identifiers to names and their associated functions. Since it creates a table of language items, let's rename it in a similar manner to how vec! creates a vec. --- src/librustc/middle/lang_items.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index 853477ac97c16..960305e10488d 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -37,7 +37,7 @@ use hir; // The actual lang items defined come at the end of this file in one handy table. // So you probably just want to nip down to the end. -macro_rules! lets_do_this { +macro_rules! language_item_table { ( $( $variant:ident, $name:expr, $method:ident; )* ) => { @@ -269,7 +269,7 @@ pub fn collect_language_items(session: &Session, } } -lets_do_this! { +language_item_table! { // Variant name, Name, Method name; CharImplItem, "char", char_impl; StrImplItem, "str", str_impl; From 6e848be5f8071f1fe6110b3ec2bee0776126f79b Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Thu, 23 Jun 2016 18:16:37 -0400 Subject: [PATCH 08/12] Indicate how the `JoinHandle` struct is created. --- src/libstd/thread/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 1f78b32bcf38e..355e0f50cef35 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -610,6 +610,12 @@ impl JoinInner { /// Due to platform restrictions, it is not possible to `Clone` this /// handle: the ability to join a child thread is a uniquely-owned /// permission. +/// +/// This `struct` is created by the [`thread::spawn`] function and the +/// [`thread::Builder::spawn`] method. +/// +/// [`thread::spawn`]: fn.spawn.html +/// [`thread::Builder::spawn`]: struct.Builder.html#method.spawn #[stable(feature = "rust1", since = "1.0.0")] pub struct JoinHandle(JoinInner); From 5e9b75e2dd440a5df2c7d90f88b2660c7581d964 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Fri, 24 Jun 2016 08:12:58 -0400 Subject: [PATCH 09/12] Add examples in docs for `JoinHandle`. --- src/libstd/thread/mod.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 355e0f50cef35..26085c86813ad 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -614,6 +614,30 @@ impl JoinInner { /// This `struct` is created by the [`thread::spawn`] function and the /// [`thread::Builder::spawn`] method. /// +/// # Examples +/// +/// Creation from [`thread::spawn`]: +/// +/// ```rust +/// use std::thread; +/// +/// let join_handle: thread::JoinHandle<_> = thread::spawn(|| { +/// // some work here +/// }); +/// ``` +/// +/// Creation from [`thread::Builder::spawn`]: +/// +/// ```rust +/// use std::thread; +/// +/// let builder = thread::Builder::new(); +/// +/// let join_handle: thread::JoinHandle<_> = builder.spawn(|| { +/// // some work here +/// }).unwrap(); +/// ``` +/// /// [`thread::spawn`]: fn.spawn.html /// [`thread::Builder::spawn`]: struct.Builder.html#method.spawn #[stable(feature = "rust1", since = "1.0.0")] From fd388d40ed4b44a7650c7a489a280e5387d89f47 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sat, 25 Jun 2016 07:22:19 -0400 Subject: [PATCH 10/12] Add doc example for `std::thread::Builder::name`. --- src/libstd/thread/mod.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 1f78b32bcf38e..8be4f619c7dc4 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -220,6 +220,21 @@ impl Builder { /// Names the thread-to-be. Currently the name is used for identification /// only in panic messages. + /// + /// # Examples + /// + /// ```rust + /// use std::thread; + /// + /// let builder = thread::Builder::new() + /// .name("foo".into()); + /// + /// let handler = builder.spawn(|| { + /// assert_eq!(thread::current().name(), Some("foo")) + /// }).unwrap(); + /// + /// handler.join().unwrap(); + /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn name(mut self, name: String) -> Builder { self.name = Some(name); From c55f0922aa6df5be8c4ac00757ec691f9fd629d7 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sat, 25 Jun 2016 09:26:41 -0400 Subject: [PATCH 11/12] Add hyperlinks to `std::fs` functions from `std::path`. --- src/libstd/path.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/libstd/path.rs b/src/libstd/path.rs index f413bed86a853..a19d51fac3552 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1781,7 +1781,9 @@ impl Path { /// This function will traverse symbolic links to query information about the /// destination file. /// - /// This is an alias to `fs::metadata`. + /// This is an alias to [`fs::metadata`]. + /// + /// [`fs::metadata`]: ../fs/fn.metadata.html #[stable(feature = "path_ext", since = "1.5.0")] pub fn metadata(&self) -> io::Result { fs::metadata(self) @@ -1789,7 +1791,9 @@ impl Path { /// Query the metadata about a file without following symlinks. /// - /// This is an alias to `fs::symlink_metadata`. + /// This is an alias to [`fs::symlink_metadata`]. + /// + /// [`fs::symlink_metadata`]: ../fs/fn.symlink_metadata.html #[stable(feature = "path_ext", since = "1.5.0")] pub fn symlink_metadata(&self) -> io::Result { fs::symlink_metadata(self) @@ -1798,7 +1802,9 @@ impl Path { /// Returns the canonical form of the path with all intermediate components /// normalized and symbolic links resolved. /// - /// This is an alias to `fs::canonicalize`. + /// This is an alias to [`fs::canonicalize`]. + /// + /// [`fs::canonicalize`]: ../fs/fn.canonicalize.html #[stable(feature = "path_ext", since = "1.5.0")] pub fn canonicalize(&self) -> io::Result { fs::canonicalize(self) @@ -1806,7 +1812,9 @@ impl Path { /// Reads a symbolic link, returning the file that the link points to. /// - /// This is an alias to `fs::read_link`. + /// This is an alias to [`fs::read_link`]. + /// + /// [`fs::read_link`]: ../fs/fn.read_link.html #[stable(feature = "path_ext", since = "1.5.0")] pub fn read_link(&self) -> io::Result { fs::read_link(self) @@ -1817,7 +1825,9 @@ impl Path { /// The iterator will yield instances of `io::Result`. New errors may /// be encountered after an iterator is initially constructed. /// - /// This is an alias to `fs::read_dir`. + /// This is an alias to [`fs::read_dir`]. + /// + /// [`fs::read_dir`]: ../fs/fn.read_dir.html #[stable(feature = "path_ext", since = "1.5.0")] pub fn read_dir(&self) -> io::Result { fs::read_dir(self) From f300fafccd4c6e1c83753dc283975ccda086ba1f Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sat, 25 Jun 2016 10:05:01 -0400 Subject: [PATCH 12/12] Indicate how the `std::path::Components` struct is created. --- src/libstd/path.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libstd/path.rs b/src/libstd/path.rs index f413bed86a853..afcb75ed22ed9 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -579,6 +579,8 @@ impl<'a> AsRef for Component<'a> { /// See the module documentation for an in-depth explanation of components and /// their role in the API. /// +/// This `struct` is created by the [`path::Path::components`] method. +/// /// # Examples /// /// ``` @@ -590,6 +592,8 @@ impl<'a> AsRef for Component<'a> { /// println!("{:?}", component); /// } /// ``` +/// +/// [`path::Path::components`]: struct.Path.html#method.components #[derive(Clone)] #[stable(feature = "rust1", since = "1.0.0")] pub struct Components<'a> {