From 3090b0151c896dd47dedcbd26f1223a534f55f17 Mon Sep 17 00:00:00 2001 From: Tor Hovland Date: Thu, 22 Apr 2021 22:33:54 +0200 Subject: [PATCH 01/13] Use flex more consistently. --- src/librustdoc/html/static/rustdoc.css | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 213ca9ec9e3ea..cf934efbb15d3 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -117,9 +117,12 @@ h4:not(.method):not(.type):not(.tymethod):not(.associatedconstant) { } h1.fqn { display: flex; - width: 100%; border-bottom: 1px dashed; margin-top: 0; + + /* workaround to keep flex from breaking below 700 px width due to the float: right on the nav + above the h1 */ + padding-left: 1px; } h1.fqn > .in-band > a:hover { text-decoration: underline; @@ -453,20 +456,14 @@ nav.sub { } .content .out-of-band { - float: right; + flex-grow: 0; + text-align: right; font-size: 23px; margin: 0px; - padding: 0px; + padding: 0 0 0 12px; font-weight: normal; } -h1.fqn > .out-of-band { - float: unset; - flex: 1; - text-align: right; - margin-left: 8px; -} - h3.impl > .out-of-band { font-size: 21px; } @@ -486,6 +483,7 @@ h4 > code, h3 > code, .invisible > code { } .content .in-band { + flex-grow: 1; margin: 0px; padding: 0px; } @@ -1483,10 +1481,6 @@ h4 > .notable-traits { display: none !important; } - h1.fqn { - overflow: initial; - } - .theme-picker { left: 10px; top: 54px; From 5bd31879d7969ceb9d616bf715722ccf807c015d Mon Sep 17 00:00:00 2001 From: est31 Date: Mon, 26 Apr 2021 20:46:30 +0200 Subject: [PATCH 02/13] Point out that behavior might be switched on 2015 and 2018 editions too one day --- library/std/src/primitive_docs.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/library/std/src/primitive_docs.rs b/library/std/src/primitive_docs.rs index c37111f665c47..ef0ab05a58d90 100644 --- a/library/std/src/primitive_docs.rs +++ b/library/std/src/primitive_docs.rs @@ -553,8 +553,10 @@ mod prim_pointer {} /// # Editions /// /// Prior to Rust 1.53, arrays did not implement `IntoIterator` by value, so the method call -/// `array.into_iter()` auto-referenced into a slice iterator. That behavior is preserved in the -/// 2015 and 2018 editions of Rust for compatability, ignoring `IntoIterator` by value. +/// `array.into_iter()` auto-referenced into a slice iterator. Right now, the old behavior +/// is preserved in the 2015 and 2018 editions of Rust for compatibility, ignoring +/// `IntoIterator` by value. In the future, the behavior on the 2015 and 2018 edition +/// might be made consistent to the behavior of later editions. /// #[cfg_attr(bootstrap, doc = "```rust,edition2018,ignore")] #[cfg_attr(not(bootstrap), doc = "```rust,edition2018")] From 12642d99a6a7f5302efb9079ece54cf18c337571 Mon Sep 17 00:00:00 2001 From: est31 Date: Wed, 28 Apr 2021 01:33:16 +0200 Subject: [PATCH 03/13] Add a paragraph with possible alternatives on older editions --- library/std/src/primitive_docs.rs | 42 +++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/library/std/src/primitive_docs.rs b/library/std/src/primitive_docs.rs index ef0ab05a58d90..a5292c8b878eb 100644 --- a/library/std/src/primitive_docs.rs +++ b/library/std/src/primitive_docs.rs @@ -603,6 +603,48 @@ mod prim_pointer {} /// } /// ``` /// +/// Future language versions might start treating the `array.into_iter()` +/// syntax on editions 2015 and 2018 the same as on edition 2021. So code using +/// those older editions should still be written with this change in mind, to +/// prevent breakage in the future. The safest way to accomplish this is to +/// avoid the `into_iter` syntax on those editions. If an edition update is not +/// viable/desired, there are multiple alternatives: +/// * use `iter`, equivalent to the old behavior, creating references +/// * use [`array::IntoIter`], equivalent to the post-2021 behavior (Rust 1.51+) +/// * replace `for ... in array.into_iter() {` with `for ... in array {`, +/// equivalent to the post-2021 behavior (Rust 1.53+) +/// +/// ```rust,edition2018 +/// use std::array::IntoIter; +/// +/// let array: [i32; 3] = [0; 3]; +/// +/// // This iterates by reference: +/// for item in array.iter() { +/// let x: &i32 = item; +/// println!("{}", x); +/// } +/// +/// // This iterates by value: +/// for item in IntoIter::new(array) { +/// let x: i32 = item; +/// println!("{}", x); +/// } +/// +/// // This iterates by value: +/// for item in array { +/// let x: i32 = item; +/// println!("{}", x); +/// } +/// +/// // IntoIter can also start a chain. +/// // This iterates by value: +/// for item in IntoIter::new(array).enumerate() { +/// let (i, x): (usize, i32) = item; +/// println!("array[{}] = {}", i, x); +/// } +/// ``` +/// /// [slice]: prim@slice /// [`Debug`]: fmt::Debug /// [`Hash`]: hash::Hash From 31ae3b2bdb9376b749fc1d64b531e86806e03c73 Mon Sep 17 00:00:00 2001 From: Jack Huey Date: Wed, 28 Apr 2021 10:18:52 -0400 Subject: [PATCH 04/13] Add HAS_RE_LATE_BOUND if there are bound vars --- compiler/rustc_middle/src/ty/flags.rs | 4 ++++ .../ui/lifetimes/issue-83737-erasing-bound-vars.rs | 14 ++++++++++++++ src/test/ui/lifetimes/issue-84604.rs | 9 +++++++++ 3 files changed, 27 insertions(+) create mode 100644 src/test/ui/lifetimes/issue-83737-erasing-bound-vars.rs create mode 100644 src/test/ui/lifetimes/issue-84604.rs diff --git a/compiler/rustc_middle/src/ty/flags.rs b/compiler/rustc_middle/src/ty/flags.rs index 01bc5cc761ca6..92288c8982744 100644 --- a/compiler/rustc_middle/src/ty/flags.rs +++ b/compiler/rustc_middle/src/ty/flags.rs @@ -59,6 +59,10 @@ impl FlagComputation { { let mut computation = FlagComputation::new(); + if !value.bound_vars().is_empty() { + computation.flags = computation.flags | TypeFlags::HAS_RE_LATE_BOUND; + } + f(&mut computation, value.skip_binder()); self.add_flags(computation.flags); diff --git a/src/test/ui/lifetimes/issue-83737-erasing-bound-vars.rs b/src/test/ui/lifetimes/issue-83737-erasing-bound-vars.rs new file mode 100644 index 0000000000000..c496a3556c84e --- /dev/null +++ b/src/test/ui/lifetimes/issue-83737-erasing-bound-vars.rs @@ -0,0 +1,14 @@ +// build-pass +// compile-flags: --edition 2018 +// compile-flags: --crate-type rlib + +use std::future::Future; + +async fn handle(slf: &F) +where + F: Fn(&()) -> Box Future + Unpin>, +{ + (slf)(&()).await; +} + +fn main() {} diff --git a/src/test/ui/lifetimes/issue-84604.rs b/src/test/ui/lifetimes/issue-84604.rs new file mode 100644 index 0000000000000..df8368da0a09a --- /dev/null +++ b/src/test/ui/lifetimes/issue-84604.rs @@ -0,0 +1,9 @@ +// run-pass +// compile-flags: -Zsymbol-mangling-version=v0 + +pub fn f() {} +pub trait Frob {} +fn main() { + f::>(); + f:: Frob>(); +} From 5f82e22ba4c3a17b17fb81664e21d0baa68e3d87 Mon Sep 17 00:00:00 2001 From: Jack Huey Date: Wed, 28 Apr 2021 18:10:44 -0400 Subject: [PATCH 05/13] Don't rebind in transitive_bounds_that_define_assoc_type --- compiler/rustc_infer/src/traits/util.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/compiler/rustc_infer/src/traits/util.rs b/compiler/rustc_infer/src/traits/util.rs index 87684c2715f4e..1cde4802a40b0 100644 --- a/compiler/rustc_infer/src/traits/util.rs +++ b/compiler/rustc_infer/src/traits/util.rs @@ -305,9 +305,7 @@ pub fn transitive_bounds_that_define_assoc_type<'tcx>( Some(assoc_name), )); for (super_predicate, _) in super_predicates.predicates { - let bound_predicate = super_predicate.kind(); - let subst_predicate = super_predicate - .subst_supertrait(tcx, &bound_predicate.rebind(trait_ref.skip_binder())); + let subst_predicate = super_predicate.subst_supertrait(tcx, &trait_ref); if let Some(binder) = subst_predicate.to_opt_poly_trait_ref() { stack.push(binder.value); } From 3e016a7682699ac23e48b4c6571c3d78503abf4d Mon Sep 17 00:00:00 2001 From: Ben-Lichtman Date: Wed, 28 Apr 2021 19:43:33 -0700 Subject: [PATCH 06/13] Minor grammar tweaks for readability --- library/alloc/src/collections/btree/node.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/alloc/src/collections/btree/node.rs b/library/alloc/src/collections/btree/node.rs index f330a1bb3dcfe..af403496e38e9 100644 --- a/library/alloc/src/collections/btree/node.rs +++ b/library/alloc/src/collections/btree/node.rs @@ -89,7 +89,7 @@ impl LeafNode { /// The underlying representation of internal nodes. As with `LeafNode`s, these should be hidden /// behind `BoxedNode`s to prevent dropping uninitialized keys and values. Any pointer to an -/// `InternalNode` can be directly casted to a pointer to the underlying `LeafNode` portion of the +/// `InternalNode` can be directly cast to a pointer to the underlying `LeafNode` portion of the /// node, allowing code to act on leaf and internal nodes generically without having to even check /// which of the two a pointer is pointing at. This property is enabled by the use of `repr(C)`. #[repr(C)] @@ -408,7 +408,7 @@ impl NodeRef { } impl<'a, K, V, Type> NodeRef, K, V, Type> { - /// Temporarily takes out another, mutable reference to the same node. Beware, as + /// Temporarily takes out another mutable reference to the same node. Beware, as /// this method is very dangerous, doubly so since it may not immediately appear /// dangerous. /// @@ -759,7 +759,7 @@ impl PartialEq impl Handle, HandleType> { - /// Temporarily takes out another, immutable handle on the same location. + /// Temporarily takes out another immutable handle on the same location. pub fn reborrow(&self) -> Handle, K, V, NodeType>, HandleType> { // We can't use Handle::new_kv or Handle::new_edge because we don't know our type Handle { node: self.node.reborrow(), idx: self.idx, _marker: PhantomData } @@ -767,7 +767,7 @@ impl } impl<'a, K, V, NodeType, HandleType> Handle, K, V, NodeType>, HandleType> { - /// Temporarily takes out another, mutable handle on the same location. Beware, as + /// Temporarily takes out another mutable handle on the same location. Beware, as /// this method is very dangerous, doubly so since it may not immediately appear /// dangerous. /// From 8c0469552e879f6319f8f96db660bab9eae1de5c Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 29 Apr 2021 10:40:10 +0200 Subject: [PATCH 07/13] Remove unnecessary CSS rules for search results --- src/librustdoc/html/static/rustdoc.css | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index a024fa49b0e8b..3eda2bea7fe6a 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -385,13 +385,6 @@ nav.sub { position: relative; } -#results { - position: absolute; - right: 0; - left: 0; - overflow: auto; -} - #results > table { width: 100%; table-layout: fixed; From a20831e7a6617953e8e9d3f94140a558feb1e8ce Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 29 Apr 2021 11:26:35 +0200 Subject: [PATCH 08/13] Remove unneeded bottom margin on search results --- src/librustdoc/html/static/rustdoc.css | 1 - 1 file changed, 1 deletion(-) diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index a024fa49b0e8b..62ea0935360f1 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -395,7 +395,6 @@ nav.sub { #results > table { width: 100%; table-layout: fixed; - margin-bottom: 40px; } .content pre.line-numbers { From a3523363dbd6871266e7aa2fe59566cf337190f4 Mon Sep 17 00:00:00 2001 From: est31 Date: Thu, 29 Apr 2021 12:39:23 +0200 Subject: [PATCH 09/13] Ignore doctests in bootstrap On bootstrap the IntoIterator trait is not implemented yet for arrays. --- library/std/src/primitive_docs.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/std/src/primitive_docs.rs b/library/std/src/primitive_docs.rs index a5292c8b878eb..cd6b0b2d7ee7a 100644 --- a/library/std/src/primitive_docs.rs +++ b/library/std/src/primitive_docs.rs @@ -614,7 +614,8 @@ mod prim_pointer {} /// * replace `for ... in array.into_iter() {` with `for ... in array {`, /// equivalent to the post-2021 behavior (Rust 1.53+) /// -/// ```rust,edition2018 +#[cfg_attr(bootstrap, doc = "```rust,edition2018,ignore")] +#[cfg_attr(not(bootstrap), doc = "```rust,edition2018")] /// use std::array::IntoIter; /// /// let array: [i32; 3] = [0; 3]; From d0c0b8a4a37827da956aafff33fa9882a3bc0df9 Mon Sep 17 00:00:00 2001 From: r00ster91 Date: Thu, 29 Apr 2021 13:15:49 +0200 Subject: [PATCH 10/13] Link between std::env::{var, var_os} and std::env::{vars, vars_os} --- library/std/src/env.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/library/std/src/env.rs b/library/std/src/env.rs index d20bb58584101..821e7d4cfe7ad 100644 --- a/library/std/src/env.rs +++ b/library/std/src/env.rs @@ -124,6 +124,10 @@ pub fn vars() -> Vars { /// variables at the time of this invocation. Modifications to environment /// variables afterwards will not be reflected in the returned iterator. /// +/// Note that the returned iterator will not check if the environment variables +/// are valid Unicode. If you want to panic on invalid UTF-8, +/// use the [`vars`] function instead. +/// /// # Examples /// /// ``` @@ -180,8 +184,9 @@ impl fmt::Debug for VarsOs { /// /// # Errors /// -/// * Environment variable is not present -/// * Environment variable is not valid unicode +/// Errors if the environment variable is not present. +/// Errors if the environment variable is not valid Unicode. If this is not desired, consider using +/// [`var_os`]. /// /// # Panics /// @@ -221,6 +226,10 @@ fn _var(key: &OsStr) -> Result { /// `'='` or the NUL character `'\0'`, or when the value contains the NUL /// character. /// +/// Note that the method will not check if the environment variable +/// is valid Unicode. If you want to have an error on invalid UTF-8, +/// use the [`var`] function instead. +/// /// # Examples /// /// ``` From da6261e07fa892f995703e4ae26832a633fa5a23 Mon Sep 17 00:00:00 2001 From: lcnr Date: Thu, 29 Apr 2021 20:06:11 +0200 Subject: [PATCH 11/13] make feature recommendations optional --- compiler/rustc_resolve/src/diagnostics.rs | 8 ++++++- compiler/rustc_typeck/src/check/wfcheck.rs | 25 ++++++++++++---------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index c5f12c0c691b3..6ea46f5c5289e 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -487,7 +487,13 @@ impl<'a> Resolver<'a> { name )); } - err.help("use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions"); + + if self.session.is_nightly_build() { + err.help( + "use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` \ + to allow generic const expressions" + ); + } err } diff --git a/compiler/rustc_typeck/src/check/wfcheck.rs b/compiler/rustc_typeck/src/check/wfcheck.rs index 26871d6f0285c..d25dd9a6e8302 100644 --- a/compiler/rustc_typeck/src/check/wfcheck.rs +++ b/compiler/rustc_typeck/src/check/wfcheck.rs @@ -315,17 +315,20 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) { ), ) } else { - tcx.sess - .struct_span_err( - hir_ty.span, - &format!( - "{} is forbidden as the type of a const generic parameter", - unsupported_type - ), - ) - .note("the only supported types are integers, `bool` and `char`") - .help("more complex types are supported with `#![feature(const_generics)]`") - .emit() + let mut err = tcx.sess.struct_span_err( + hir_ty.span, + &format!( + "{} is forbidden as the type of a const generic parameter", + unsupported_type + ), + ); + err.note("the only supported types are integers, `bool` and `char`"); + if tcx.sess.is_nightly_build() { + err.help( + "more complex types are supported with `#![feature(const_generics)]`", + ); + } + err.emit() } }; From 20b569f579842d6e0dd70ae86b8206ad04b1ec24 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Thu, 29 Apr 2021 12:05:08 -0700 Subject: [PATCH 12/13] Drop alias `reduce` for `fold` - we have a `reduce` function Searching for "reduce" currently puts the `reduce` alias for `fold` above the actual `reduce` function. The `reduce` function already has a cross-reference for `fold`, and vice versa. --- library/core/src/iter/traits/iterator.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index 7977d599ae725..da9e5fde7ccec 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -2133,7 +2133,6 @@ pub trait Iterator { /// ``` /// /// [`reduce()`]: Iterator::reduce - #[doc(alias = "reduce")] #[doc(alias = "inject")] #[inline] #[stable(feature = "rust1", since = "1.0.0")] From 16ff6c80504f095da947eeea3e09468228db8748 Mon Sep 17 00:00:00 2001 From: Camelid Date: Thu, 29 Apr 2021 13:13:28 -0700 Subject: [PATCH 13/13] Fix labels for regression issue template Each label needs to be separated by a comma (see the ICE issue template for an example of correct usage). As a result of this problem, the `regression-untriaged` label has not been automatically added to issues opened with this template. See c127530be76bd8aebc7b61f3b4a54f1be577f74c for another example of this. --- .github/ISSUE_TEMPLATE/regression.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/regression.md b/.github/ISSUE_TEMPLATE/regression.md index ffab883987c0d..c0e90824a710d 100644 --- a/.github/ISSUE_TEMPLATE/regression.md +++ b/.github/ISSUE_TEMPLATE/regression.md @@ -1,7 +1,7 @@ --- name: Regression about: Report something that unexpectedly changed between Rust versions. -labels: C-bug regression-untriaged +labels: C-bug, regression-untriaged ---