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 --- <!-- Thank you for filing a regression report! 🐛 A regression is something that changed between versions of Rust but was not supposed to. 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); } 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/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() } }; 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<K, V> LeafNode<K, V> { /// 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<K, V> NodeRef<marker::Dying, K, V, marker::LeafOrInternal> { } impl<'a, K, V, Type> NodeRef<marker::Mut<'a>, 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<BorrowType, K, V, NodeType, HandleType> PartialEq impl<BorrowType, K, V, NodeType, HandleType> Handle<NodeRef<BorrowType, K, V, NodeType>, 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<NodeRef<marker::Immut<'_>, 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<BorrowType, K, V, NodeType, HandleType> } impl<'a, K, V, NodeType, HandleType> Handle<NodeRef<marker::Mut<'a>, 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. /// 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")] 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<String, VarError> { /// `'='` 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 /// /// ``` diff --git a/library/std/src/primitive_docs.rs b/library/std/src/primitive_docs.rs index c37111f665c47..cd6b0b2d7ee7a 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")] @@ -601,6 +603,49 @@ 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+) +/// +#[cfg_attr(bootstrap, doc = "```rust,edition2018,ignore")] +#[cfg_attr(not(bootstrap), doc = "```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 diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index a024fa49b0e8b..a95c90e999f98 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; @@ -385,17 +388,9 @@ nav.sub { position: relative; } -#results { - position: absolute; - right: 0; - left: 0; - overflow: auto; -} - #results > table { width: 100%; table-layout: fixed; - margin-bottom: 40px; } .content pre.line-numbers { @@ -453,20 +448,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 +475,7 @@ h4 > code, h3 > code, .invisible > code { } .content .in-band { + flex-grow: 1; margin: 0px; padding: 0px; } @@ -1484,10 +1474,6 @@ h4 > .notable-traits { display: none !important; } - h1.fqn { - overflow: initial; - } - .theme-picker { left: 10px; top: 54px; 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<F>(slf: &F) +where + F: Fn(&()) -> Box<dyn for<'a> Future<Output = ()> + 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<T: ?Sized>() {} +pub trait Frob<T: ?Sized> {} +fn main() { + f::<dyn Frob<str>>(); + f::<dyn for<'a> Frob<str>>(); +}