From 249e07b237bd3049eb7fd94afe450b7c09b6a3d9 Mon Sep 17 00:00:00 2001 From: Alexis Bourget Date: Wed, 24 Jun 2020 14:53:52 +0200 Subject: [PATCH 01/15] Short documentation for the false keyword --- src/libstd/keyword_docs.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libstd/keyword_docs.rs b/src/libstd/keyword_docs.rs index a4996d9eee810..cd722458a90b8 100644 --- a/src/libstd/keyword_docs.rs +++ b/src/libstd/keyword_docs.rs @@ -387,10 +387,12 @@ mod extern_keyword {} // /// A value of type [`bool`] representing logical **false**. /// -/// The documentation for this keyword is [not yet complete]. Pull requests welcome! +/// Logically `false` is not equal to [`true`]. +/// +/// See the documentation for [`true`] for more information. /// +/// [`true`]: keyword.true.html /// [`bool`]: primitive.bool.html -/// [not yet complete]: https://github.com/rust-lang/rust/issues/34601 mod false_keyword {} #[doc(keyword = "fn")] From d88cce24238cc76b45e647448d99a87e98cd86b7 Mon Sep 17 00:00:00 2001 From: Alexis Bourget Date: Sat, 18 Jul 2020 23:20:58 +0200 Subject: [PATCH 02/15] Add a link to read in the read_exact doc about the guarantees --- src/libstd/io/mod.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index d5af4f25102d1..aba67df0063e0 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -741,7 +741,9 @@ pub trait Read { /// No guarantees are provided about the contents of `buf` when this /// function is called, implementations cannot rely on any property of the /// contents of `buf` being true. It is recommended that implementations - /// only write data to `buf` instead of reading its contents. + /// only write data to `buf` instead of reading its contents. The + /// documentation on [`read`] has a more detailed explanation on this + /// subject. /// /// # Errors /// @@ -764,6 +766,7 @@ pub trait Read { /// /// [`File`]s implement `Read`: /// + /// [`read`]: trait.Read.html#tymethod.read /// [`File`]: ../fs/struct.File.html /// [`ErrorKind::Interrupted`]: ../../std/io/enum.ErrorKind.html#variant.Interrupted /// [`ErrorKind::UnexpectedEof`]: ../../std/io/enum.ErrorKind.html#variant.UnexpectedEof From e88220f86749d88e53c5dbaa421dcaba1889f86c Mon Sep 17 00:00:00 2001 From: Alexis Bourget Date: Sun, 19 Jul 2020 15:30:32 +0200 Subject: [PATCH 03/15] Fix small nit in the link to read --- src/libstd/io/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index aba67df0063e0..73a6f08df65fd 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -766,7 +766,7 @@ pub trait Read { /// /// [`File`]s implement `Read`: /// - /// [`read`]: trait.Read.html#tymethod.read + /// [`read`]: Read::read /// [`File`]: ../fs/struct.File.html /// [`ErrorKind::Interrupted`]: ../../std/io/enum.ErrorKind.html#variant.Interrupted /// [`ErrorKind::UnexpectedEof`]: ../../std/io/enum.ErrorKind.html#variant.UnexpectedEof From 455e6140d81f48d99d43573382c67f804434a949 Mon Sep 17 00:00:00 2001 From: Bastian Kauschke Date: Sun, 19 Jul 2020 15:45:44 +0200 Subject: [PATCH 04/15] do not try fetching the ancestors of errored trait impls --- src/librustc_middle/traits/specialization_graph.rs | 4 +++- .../min_specialization/impl-on-nonexisting.rs | 7 +++++++ .../min_specialization/impl-on-nonexisting.stderr | 9 +++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/specialization/min_specialization/impl-on-nonexisting.rs create mode 100644 src/test/ui/specialization/min_specialization/impl-on-nonexisting.stderr diff --git a/src/librustc_middle/traits/specialization_graph.rs b/src/librustc_middle/traits/specialization_graph.rs index f4961617b81c6..c9aae8980076f 100644 --- a/src/librustc_middle/traits/specialization_graph.rs +++ b/src/librustc_middle/traits/specialization_graph.rs @@ -1,5 +1,6 @@ use crate::ich::{self, StableHashingContext}; use crate::ty::fast_reject::SimplifiedType; +use crate::ty::fold::TypeFoldable; use crate::ty::{self, TyCtxt}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; @@ -226,7 +227,8 @@ pub fn ancestors( start_from_impl: DefId, ) -> Result, ErrorReported> { let specialization_graph = tcx.specialization_graph_of(trait_def_id); - if specialization_graph.has_errored { + + if specialization_graph.has_errored || tcx.type_of(start_from_impl).references_error() { Err(ErrorReported) } else { Ok(Ancestors { diff --git a/src/test/ui/specialization/min_specialization/impl-on-nonexisting.rs b/src/test/ui/specialization/min_specialization/impl-on-nonexisting.rs new file mode 100644 index 0000000000000..77a64320d6f37 --- /dev/null +++ b/src/test/ui/specialization/min_specialization/impl-on-nonexisting.rs @@ -0,0 +1,7 @@ +#![feature(min_specialization)] + +trait Trait {} +impl Trait for NonExistent {} +//~^ ERROR cannot find type `NonExistent` in this scope + +fn main() {} diff --git a/src/test/ui/specialization/min_specialization/impl-on-nonexisting.stderr b/src/test/ui/specialization/min_specialization/impl-on-nonexisting.stderr new file mode 100644 index 0000000000000..b032ccbe53ffc --- /dev/null +++ b/src/test/ui/specialization/min_specialization/impl-on-nonexisting.stderr @@ -0,0 +1,9 @@ +error[E0412]: cannot find type `NonExistent` in this scope + --> $DIR/impl-on-nonexisting.rs:4:16 + | +LL | impl Trait for NonExistent {} + | ^^^^^^^^^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0412`. From b7bf3c83c408c18465bc3a1ea9c98a0023b90d93 Mon Sep 17 00:00:00 2001 From: Alexis Bourget Date: Sun, 19 Jul 2020 15:58:41 +0200 Subject: [PATCH 05/15] Remove useless link to bool primitive --- src/libstd/keyword_docs.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libstd/keyword_docs.rs b/src/libstd/keyword_docs.rs index cd722458a90b8..139b402c3357b 100644 --- a/src/libstd/keyword_docs.rs +++ b/src/libstd/keyword_docs.rs @@ -392,7 +392,6 @@ mod extern_keyword {} /// See the documentation for [`true`] for more information. /// /// [`true`]: keyword.true.html -/// [`bool`]: primitive.bool.html mod false_keyword {} #[doc(keyword = "fn")] From a459fc4e3140cd89457f973045d9c82ef2928698 Mon Sep 17 00:00:00 2001 From: Poliorcetics Date: Sun, 19 Jul 2020 16:28:18 +0200 Subject: [PATCH 06/15] Apply suggestions from review Co-authored-by: Joshua Nelson --- src/libstd/keyword_docs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/keyword_docs.rs b/src/libstd/keyword_docs.rs index 139b402c3357b..a3f5a820d6769 100644 --- a/src/libstd/keyword_docs.rs +++ b/src/libstd/keyword_docs.rs @@ -387,7 +387,7 @@ mod extern_keyword {} // /// A value of type [`bool`] representing logical **false**. /// -/// Logically `false` is not equal to [`true`]. +/// `false` is the logical opposite of [`true`]. /// /// See the documentation for [`true`] for more information. /// From be43319b174589f61ce5d8a7b00c0567eb8cff35 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sun, 19 Jul 2020 09:18:32 -0400 Subject: [PATCH 07/15] Do not clobber RUSTDOCFLAGS We were setting these in both Builder::cargo and here, which ended up only setting the first of the two. --- src/bootstrap/builder.rs | 7 +++++++ src/bootstrap/doc.rs | 10 ++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 70e5f6ac26fc1..737176c48f878 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -1444,6 +1444,10 @@ pub struct Cargo { } impl Cargo { + pub fn rustdocflag(&mut self, arg: &str) -> &mut Cargo { + self.rustdocflags.arg(arg); + self + } pub fn rustflag(&mut self, arg: &str) -> &mut Cargo { self.rustflags.arg(arg); self @@ -1466,6 +1470,9 @@ impl Cargo { } pub fn env(&mut self, key: impl AsRef, value: impl AsRef) -> &mut Cargo { + // These are managed through rustflag/rustdocflag interfaces. + assert_ne!(key.as_ref(), "RUSTFLAGS"); + assert_ne!(key.as_ref(), "RUSTDOCFLAGS"); self.command.env(key.as_ref(), value.as_ref()); self } diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index b051390fc2671..f8a549afc88fb 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -527,11 +527,9 @@ impl Step for Rustc { // Build cargo command. let mut cargo = builder.cargo(compiler, Mode::Rustc, SourceType::InTree, target, "doc"); - cargo.env( - "RUSTDOCFLAGS", - "--document-private-items \ - --enable-index-page -Zunstable-options", - ); + cargo.rustdocflag("--document-private-items"); + cargo.rustdocflag("--enable-index-page"); + cargo.rustdocflag("-Zunstable-options"); compile::rustc_cargo(builder, &mut cargo, target); // Only include compiler crates, no dependencies of those, such as `libc`. @@ -624,7 +622,7 @@ impl Step for Rustdoc { cargo.arg("--no-deps"); cargo.arg("-p").arg("rustdoc"); - cargo.env("RUSTDOCFLAGS", "--document-private-items"); + cargo.rustdocflag("--document-private-items"); builder.run(&mut cargo.into()); } } From d7a36d8964c927863faef5d3b42da08f37e5896c Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 19 Jul 2020 16:53:53 +0200 Subject: [PATCH 08/15] include backtrace folder in rust-src component --- src/bootstrap/dist.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index af30747a9592e..ffdde85d7656b 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -1005,6 +1005,7 @@ impl Step for Src { // (essentially libstd and all of its path dependencies) let std_src_dirs = [ "src/build_helper", + "src/backtrace", "src/liballoc", "src/libcore", "src/libpanic_abort", From a462e7c1d08ba0babd18a4a71d1833839c3cd52d Mon Sep 17 00:00:00 2001 From: Solomon Ucko Date: Sun, 19 Jul 2020 11:10:03 -0400 Subject: [PATCH 09/15] Document `core::fmt::rt::v1::Count` --- src/libcore/fmt/rt/v1.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libcore/fmt/rt/v1.rs b/src/libcore/fmt/rt/v1.rs index f6460470bfe18..37202b2774dc6 100644 --- a/src/libcore/fmt/rt/v1.rs +++ b/src/libcore/fmt/rt/v1.rs @@ -33,9 +33,13 @@ pub enum Alignment { Unknown, } +/// Used by [width](https://doc.rust-lang.org/std/fmt/#width) and [precision](https://doc.rust-lang.org/std/fmt/#precision) specifiers. #[derive(Copy, Clone)] pub enum Count { + /// Specified with a literal number, stores the value Is(usize), + /// Specified using `$` and `*` syntaxes, stores the index into `args` Param(usize), + /// Not specified Implied, } From 7dba34fd6b9a837300157608a90ce8d65d1490e5 Mon Sep 17 00:00:00 2001 From: Caleb Cartwright Date: Sun, 19 Jul 2020 13:10:38 -0500 Subject: [PATCH 10/15] tools: update rustfmt toolstate maintainers --- src/tools/publish_toolstate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/publish_toolstate.py b/src/tools/publish_toolstate.py index 72437e070044c..c0631fcedd349 100755 --- a/src/tools/publish_toolstate.py +++ b/src/tools/publish_toolstate.py @@ -26,7 +26,7 @@ MAINTAINERS = { 'miri': {'oli-obk', 'RalfJung', 'eddyb'}, 'rls': {'Xanewok'}, - 'rustfmt': {'topecongiro'}, + 'rustfmt': {'topecongiro', 'calebcartwright'}, 'book': {'carols10cents', 'steveklabnik'}, 'nomicon': {'frewsxcv', 'Gankra'}, 'reference': {'steveklabnik', 'Havvy', 'matthewjasper', 'ehuss'}, From e24a0172b0df21b0bc17f3c9a16773d8889dd2b1 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sun, 19 Jul 2020 16:39:20 -0400 Subject: [PATCH 11/15] Only skip impls of foreign unstable traits Previously unstable impls were skipped, which meant that any impl with an unstable method would get skipped. --- src/librustdoc/clean/inline.rs | 8 +++--- src/test/rustdoc/auxiliary/unstable-trait.rs | 26 ++++++++++++++++++++ src/test/rustdoc/hide-unstable-trait.rs | 11 +++++++++ 3 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 src/test/rustdoc/auxiliary/unstable-trait.rs create mode 100644 src/test/rustdoc/hide-unstable-trait.rs diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 491daa80e5c85..1f576a17dd9d6 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -346,9 +346,11 @@ pub fn build_impl( // such. This helps prevent dependencies of the standard library, for // example, from getting documented as "traits `u32` implements" which // isn't really too helpful. - if let Some(stab) = cx.tcx.lookup_stability(did) { - if stab.level.is_unstable() { - return; + if let Some(trait_did) = associated_trait { + if let Some(stab) = cx.tcx.lookup_stability(trait_did.def_id) { + if stab.level.is_unstable() { + return; + } } } } diff --git a/src/test/rustdoc/auxiliary/unstable-trait.rs b/src/test/rustdoc/auxiliary/unstable-trait.rs new file mode 100644 index 0000000000000..6f06a6e2656d7 --- /dev/null +++ b/src/test/rustdoc/auxiliary/unstable-trait.rs @@ -0,0 +1,26 @@ +#![feature(staged_api)] +#![stable(feature = "private_general", since = "1.0.0")] + +#[unstable(feature = "private_trait", issue = "none")] +pub trait Bar {} + +#[stable(feature = "private_general", since = "1.0.0")] +pub struct Foo { + // nothing +} + +impl Foo { + #[stable(feature = "private_general", since = "1.0.0")] + pub fn stable_impl() {} +} + +impl Foo { + #[unstable(feature = "private_trait", issue = "none")] + pub fn bar() {} + + #[stable(feature = "private_general", since = "1.0.0")] + pub fn bar2() {} +} + +#[stable(feature = "private_general", since = "1.0.0")] +impl Bar for Foo {} diff --git a/src/test/rustdoc/hide-unstable-trait.rs b/src/test/rustdoc/hide-unstable-trait.rs new file mode 100644 index 0000000000000..c30d6ed7b5220 --- /dev/null +++ b/src/test/rustdoc/hide-unstable-trait.rs @@ -0,0 +1,11 @@ +// aux-build:unstable-trait.rs + +#![crate_name = "foo"] +#![feature(private_trait)] + +extern crate unstable_trait; + +// @has foo/struct.Foo.html 'bar' +// @has foo/struct.Foo.html 'bar2' +#[doc(inline)] +pub use unstable_trait::Foo; From 940ceb1a4368110df2d24e58896d3753d5596a33 Mon Sep 17 00:00:00 2001 From: Nicholas-Baron Date: Sun, 19 Jul 2020 14:03:52 -0700 Subject: [PATCH 12/15] Mentioned IntoIterator earlier in keyword 'for' docs --- src/libstd/keyword_docs.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/keyword_docs.rs b/src/libstd/keyword_docs.rs index d985f10ccb486..66236b45761b5 100644 --- a/src/libstd/keyword_docs.rs +++ b/src/libstd/keyword_docs.rs @@ -473,8 +473,8 @@ mod fn_keyword {} /// * `for` is also used for [higher-ranked trait bounds] as in `for<'a> &'a T: PartialEq`. /// /// for-in-loops, or to be more precise, iterator loops, are a simple syntactic sugar over a common -/// practice within Rust, which is to loop over an iterator until that iterator returns `None` (or -/// `break` is called). +/// practice within Rust, which is to loop over anything that implements `IntoIterator` until the +/// temporary iterator returns `None` (or `break` is called). /// /// ```rust /// for i in 0..5 { From 6c493df0f83c6114cddc1ad72929d1f9d4aded1e Mon Sep 17 00:00:00 2001 From: Nicholas-Baron Date: Sun, 19 Jul 2020 14:05:45 -0700 Subject: [PATCH 13/15] Mentioned IntoIterator in keyword 'in' docs --- src/libstd/keyword_docs.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/keyword_docs.rs b/src/libstd/keyword_docs.rs index 66236b45761b5..d99399c08690f 100644 --- a/src/libstd/keyword_docs.rs +++ b/src/libstd/keyword_docs.rs @@ -680,7 +680,7 @@ mod impl_keyword {} // /// Iterate over a series of values with [`for`]. /// -/// The expression immediately following `in` must implement the [`Iterator`] trait. +/// The expression immediately following `in` must implement the [`IntoIterator`] trait. /// /// ## Literal Examples: /// @@ -689,7 +689,7 @@ mod impl_keyword {} /// /// (Read more about [range patterns]) /// -/// [`Iterator`]: ../book/ch13-04-performance.html +/// [`IntoIterator`]: ../book/ch13-04-performance.html /// [range patterns]: ../reference/patterns.html?highlight=range#range-patterns /// [`for`]: keyword.for.html mod in_keyword {} From f268525d966a99ca6881d6f7dc18aafe85c6d28c Mon Sep 17 00:00:00 2001 From: Nicholas-Baron Date: Sun, 19 Jul 2020 14:06:55 -0700 Subject: [PATCH 14/15] Linked the earlier mention of IntoIterator in the keyword 'for' docs --- src/libstd/keyword_docs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/keyword_docs.rs b/src/libstd/keyword_docs.rs index d99399c08690f..0ab4a45b7795e 100644 --- a/src/libstd/keyword_docs.rs +++ b/src/libstd/keyword_docs.rs @@ -473,7 +473,7 @@ mod fn_keyword {} /// * `for` is also used for [higher-ranked trait bounds] as in `for<'a> &'a T: PartialEq`. /// /// for-in-loops, or to be more precise, iterator loops, are a simple syntactic sugar over a common -/// practice within Rust, which is to loop over anything that implements `IntoIterator` until the +/// practice within Rust, which is to loop over anything that implements [`IntoIterator`] until the /// temporary iterator returns `None` (or `break` is called). /// /// ```rust From 09d55292ed1eca97b997f22656eb7e696e9c1bf1 Mon Sep 17 00:00:00 2001 From: Nicholas Baron Date: Sun, 19 Jul 2020 17:01:36 -0700 Subject: [PATCH 15/15] Update src/libstd/keyword_docs.rs Clear up wording regarding the iterator and usage of `break`. Co-authored-by: Josh Triplett --- src/libstd/keyword_docs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/keyword_docs.rs b/src/libstd/keyword_docs.rs index 0ab4a45b7795e..d8d7039777cec 100644 --- a/src/libstd/keyword_docs.rs +++ b/src/libstd/keyword_docs.rs @@ -474,7 +474,7 @@ mod fn_keyword {} /// /// for-in-loops, or to be more precise, iterator loops, are a simple syntactic sugar over a common /// practice within Rust, which is to loop over anything that implements [`IntoIterator`] until the -/// temporary iterator returns `None` (or `break` is called). +/// iterator returned by `.into_iter()` returns `None` (or the loop body uses `break`). /// /// ```rust /// for i in 0..5 {