diff options
| -rw-r--r-- | compiler/rustc_data_structures/src/vec_map.rs | 27 | ||||
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs | 35 | ||||
| -rw-r--r-- | compiler/rustc_typeck/src/collect/type_of.rs | 13 | ||||
| -rw-r--r-- | config.toml.example | 2 | ||||
| -rw-r--r-- | library/alloc/src/collections/btree/map.rs | 1 | ||||
| -rw-r--r-- | library/alloc/src/collections/btree/set.rs | 1 | ||||
| -rw-r--r-- | library/alloc/src/lib.rs | 4 | ||||
| -rw-r--r-- | library/core/src/lib.rs | 4 | ||||
| -rw-r--r-- | library/std/src/collections/hash/map.rs | 1 | ||||
| -rw-r--r-- | library/std/src/collections/hash/set.rs | 1 | ||||
| -rw-r--r-- | library/std/src/io/buffered/bufwriter.rs | 24 | ||||
| -rw-r--r-- | library/std/src/io/buffered/mod.rs | 6 | ||||
| -rw-r--r-- | src/bootstrap/compile.rs | 2 | ||||
| -rw-r--r-- | src/bootstrap/config.rs | 23 | ||||
| -rwxr-xr-x | src/bootstrap/configure.py | 3 | ||||
| -rw-r--r-- | src/bootstrap/dist.rs | 10 | ||||
| -rw-r--r-- | src/bootstrap/job.rs | 20 | ||||
| -rw-r--r-- | src/bootstrap/lib.rs | 4 | ||||
| -rw-r--r-- | src/test/rustdoc-gui/module-items-font.goml | 4 | ||||
| -rw-r--r-- | src/test/ui/async-await/issue-86507.rs | 25 | ||||
| -rw-r--r-- | src/test/ui/async-await/issue-86507.stderr | 23 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/auxiliary/impl-const.rs (renamed from src/test/ui/const-generics/auxiliary/impl-const.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-61522-array-len-succ.full.stderr (renamed from src/test/ui/const-generics/issue-61522-array-len-succ.full.stderr) | 0 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-61522-array-len-succ.min.stderr (renamed from src/test/ui/const-generics/issue-61522-array-len-succ.min.stderr) | 0 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-61522-array-len-succ.rs (renamed from src/test/ui/const-generics/issue-61522-array-len-succ.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-66596-impl-trait-for-str-const-arg.min.stderr (renamed from src/test/ui/const-generics/issue-66596-impl-trait-for-str-const-arg.min.stderr) | 0 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-66596-impl-trait-for-str-const-arg.rs (renamed from src/test/ui/const-generics/issue-66596-impl-trait-for-str-const-arg.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-67375.full.stderr (renamed from src/test/ui/const-generics/issue-67375.full.stderr) | 0 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-67375.min.stderr (renamed from src/test/ui/const-generics/issue-67375.min.stderr) | 0 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-67375.rs (renamed from src/test/ui/const-generics/issue-67375.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-67945-1.full.stderr (renamed from src/test/ui/const-generics/issue-67945-1.full.stderr) | 0 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-67945-1.min.stderr (renamed from src/test/ui/const-generics/issue-67945-1.min.stderr) | 0 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-67945-1.rs (renamed from src/test/ui/const-generics/issue-67945-1.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-67945-2.full.stderr (renamed from src/test/ui/const-generics/issue-67945-2.full.stderr) | 0 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-67945-2.min.stderr (renamed from src/test/ui/const-generics/issue-67945-2.min.stderr) | 0 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-67945-2.rs (renamed from src/test/ui/const-generics/issue-67945-2.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-67945-3.full.stderr (renamed from src/test/ui/const-generics/issue-67945-3.full.stderr) | 0 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-67945-3.min.stderr (renamed from src/test/ui/const-generics/issue-67945-3.min.stderr) | 0 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-67945-3.rs (renamed from src/test/ui/const-generics/issue-67945-3.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-68104-print-stack-overflow.rs (renamed from src/test/ui/const-generics/issue-68104-print-stack-overflow.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-70180-1-stalled_on.rs (renamed from src/test/ui/const-generics/issue-70180-1-stalled_on.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-70180-2-stalled_on.rs (renamed from src/test/ui/const-generics/issue-70180-2-stalled_on.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-71202.rs (renamed from src/test/ui/const-generics/issue-71202.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-71986.rs (renamed from src/test/ui/const-generics/issue-71986.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-73899.rs (renamed from src/test/ui/const-generics/issue-73899.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-74906.rs (renamed from src/test/ui/const-generics/issue-74906.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-75763.rs (renamed from src/test/ui/const-generics/issue-75763.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-79518-default_trait_method_normalization.rs (renamed from src/test/ui/const-generics/issue-79518-default_trait_method_normalization.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-79518-default_trait_method_normalization.stderr (renamed from src/test/ui/const-generics/issue-79518-default_trait_method_normalization.stderr) | 0 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-80561-incorrect-param-env.rs (renamed from src/test/ui/const-generics/issue-80561-incorrect-param-env.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-86820.rs (renamed from src/test/ui/const-generics/issue-86820.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-86820.stderr (renamed from src/test/ui/const-generics/issue-86820.stderr) | 0 | ||||
| -rw-r--r-- | src/test/ui/const-generics/issues/issue-87076.rs | 20 | ||||
| -rw-r--r-- | src/tools/clippy/tests/ui/future_not_send.stderr | 4 |
54 files changed, 213 insertions, 44 deletions
diff --git a/compiler/rustc_data_structures/src/vec_map.rs b/compiler/rustc_data_structures/src/vec_map.rs index e3fa587985d..cc7ec9432fa 100644 --- a/compiler/rustc_data_structures/src/vec_map.rs +++ b/compiler/rustc_data_structures/src/vec_map.rs @@ -1,4 +1,5 @@ use std::borrow::Borrow; +use std::fmt::Debug; use std::iter::FromIterator; use std::slice::Iter; use std::vec::IntoIter; @@ -12,7 +13,8 @@ pub struct VecMap<K, V>(Vec<(K, V)>); impl<K, V> VecMap<K, V> where - K: PartialEq, + K: Debug + PartialEq, + V: Debug, { pub fn new() -> Self { VecMap(Default::default()) @@ -37,14 +39,31 @@ where self.0.iter().find(|(key, _)| k == key.borrow()).map(|elem| &elem.1) } - /// Returns the value corresponding to the supplied predicate filter. + /// Returns the any value corresponding to the supplied predicate filter. /// /// The supplied predicate will be applied to each (key, value) pair and it will return a /// reference to the values where the predicate returns `true`. - pub fn get_by(&self, mut predicate: impl FnMut(&(K, V)) -> bool) -> Option<&V> { + pub fn any_value_matching(&self, mut predicate: impl FnMut(&(K, V)) -> bool) -> Option<&V> { self.0.iter().find(|kv| predicate(kv)).map(|elem| &elem.1) } + /// Returns the value corresponding to the supplied predicate filter. It crashes if there's + /// more than one matching element. + /// + /// The supplied predicate will be applied to each (key, value) pair and it will return a + /// reference to the value where the predicate returns `true`. + pub fn get_value_matching(&self, mut predicate: impl FnMut(&(K, V)) -> bool) -> Option<&V> { + let mut filter = self.0.iter().filter(|kv| predicate(kv)); + let (_, value) = filter.next()?; + // This should return just one element, otherwise it's a bug + assert!( + filter.next().is_none(), + "Collection {:?} should have just one matching element", + self + ); + Some(value) + } + /// Returns `true` if the map contains a value for the specified key. /// /// The key may be any borrowed form of the map's key type, @@ -131,7 +150,7 @@ impl<K, V> IntoIterator for VecMap<K, V> { } } -impl<K: PartialEq, V> Extend<(K, V)> for VecMap<K, V> { +impl<K: PartialEq + Debug, V: Debug> Extend<(K, V)> for VecMap<K, V> { fn extend<I: IntoIterator<Item = (K, V)>>(&mut self, iter: I) { for (k, v) in iter { self.insert(k, v); diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 1c6a83b5783..9a33875d6e4 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -1857,12 +1857,37 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { } } GeneratorInteriorOrUpvar::Upvar(upvar_span) => { + // `Some(ref_ty)` if `target_ty` is `&T` and `T` fails to impl `Sync` + let refers_to_non_sync = match target_ty.kind() { + ty::Ref(_, ref_ty, _) => match self.evaluate_obligation(&obligation) { + Ok(eval) if !eval.may_apply() => Some(ref_ty), + _ => None, + }, + _ => None, + }; + + let (span_label, span_note) = match refers_to_non_sync { + // if `target_ty` is `&T` and `T` fails to impl `Sync`, + // include suggestions to make `T: Sync` so that `&T: Send` + Some(ref_ty) => ( + format!( + "has type `{}` which {}, because `{}` is not `Sync`", + target_ty, trait_explanation, ref_ty + ), + format!( + "captured value {} because `&` references cannot be sent unless their referent is `Sync`", + trait_explanation + ), + ), + None => ( + format!("has type `{}` which {}", target_ty, trait_explanation), + format!("captured value {}", trait_explanation), + ), + }; + let mut span = MultiSpan::from_span(upvar_span); - span.push_span_label( - upvar_span, - format!("has type `{}` which {}", target_ty, trait_explanation), - ); - err.span_note(span, &format!("captured value {}", trait_explanation)); + span.push_span_label(upvar_span, span_label); + err.span_note(span, &span_note); } } diff --git a/compiler/rustc_typeck/src/collect/type_of.rs b/compiler/rustc_typeck/src/collect/type_of.rs index 15469cb0066..50e4ba4fe6c 100644 --- a/compiler/rustc_typeck/src/collect/type_of.rs +++ b/compiler/rustc_typeck/src/collect/type_of.rs @@ -364,7 +364,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> { let concrete_ty = tcx .mir_borrowck(owner.expect_local()) .concrete_opaque_types - .get_by(|(key, _)| key.def_id == def_id.to_def_id()) + .get_value_matching(|(key, _)| key.def_id == def_id.to_def_id()) .map(|concrete_ty| *concrete_ty) .unwrap_or_else(|| { tcx.sess.delay_span_bug( @@ -512,8 +512,15 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> { struct ConstraintLocator<'tcx> { tcx: TyCtxt<'tcx>, + + /// def_id of the opaque type whose defining uses are being checked def_id: DefId, - // (first found type span, actual type) + + /// as we walk the defining uses, we are checking that all of them + /// define the same hidden type. This variable is set to `Some` + /// with the first type that we find, and then later types are + /// checked against it (we also carry the span of that first + /// type). found: Option<(Span, Ty<'tcx>)>, } @@ -531,7 +538,7 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> { .tcx .typeck(def_id) .concrete_opaque_types - .get_by(|(key, _)| key.def_id == self.def_id) + .any_value_matching(|(key, _)| key.def_id == self.def_id) .is_none() { debug!("no constraints in typeck results"); diff --git a/config.toml.example b/config.toml.example index 9a820f0803f..775133f2ab3 100644 --- a/config.toml.example +++ b/config.toml.example @@ -38,7 +38,7 @@ changelog-seen = 2 # This is false by default so that distributions don't unexpectedly download # LLVM from the internet. # -# All tier 1 targets are currently supported; set this to `"if-supported"` if +# All tier 1 targets are currently supported; set this to `"if-available"` if # you are not sure whether you're on a tier 1 target. # # We also currently only support this when building LLVM for the build triple. diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs index dfd693d13b3..79042ab739c 100644 --- a/library/alloc/src/collections/btree/map.rs +++ b/library/alloc/src/collections/btree/map.rs @@ -935,6 +935,7 @@ impl<K, V> BTreeMap<K, V> { /// Retains only the elements specified by the predicate. /// /// In other words, remove all pairs `(k, v)` such that `f(&k, &mut v)` returns `false`. + /// The elements are visited in ascending key order. /// /// # Examples /// diff --git a/library/alloc/src/collections/btree/set.rs b/library/alloc/src/collections/btree/set.rs index be740b05fb8..9711214aea6 100644 --- a/library/alloc/src/collections/btree/set.rs +++ b/library/alloc/src/collections/btree/set.rs @@ -846,6 +846,7 @@ impl<T> BTreeSet<T> { /// Retains only the elements specified by the predicate. /// /// In other words, remove all elements `e` such that `f(&e)` returns `false`. + /// The elements are visited in ascending order. /// /// # Examples /// diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index e8bd4bcb01f..fa1f361a5b6 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -56,6 +56,10 @@ //! [`Rc`]: rc //! [`RefCell`]: core::cell +// To run liballoc tests without x.py without ending up with two copies of liballoc, Miri needs to be +// able to "empty" this crate. See <https://github.com/rust-lang/miri-test-libstd/issues/4>. +// rustc itself never sets the feature, so this line has no affect there. +#![cfg(any(not(feature = "miri-test-libstd"), test, doctest))] #![allow(unused_attributes)] #![stable(feature = "alloc", since = "1.36.0")] #![doc( diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 540cdf124ee..6d87a7ab055 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -49,6 +49,10 @@ // // This cfg won't affect doc tests. #![cfg(not(test))] +// To run libcore tests without x.py without ending up with two copies of libcore, Miri needs to be +// able to "empty" this crate. See <https://github.com/rust-lang/miri-test-libstd/issues/4>. +// rustc itself never sets the feature, so this line has no affect there. +#![cfg(any(not(feature = "miri-test-libstd"), test, doctest))] #![stable(feature = "core", since = "1.6.0")] #![doc( html_playground_url = "https://play.rust-lang.org/", diff --git a/library/std/src/collections/hash/map.rs b/library/std/src/collections/hash/map.rs index fac285c96f0..4a5efab9055 100644 --- a/library/std/src/collections/hash/map.rs +++ b/library/std/src/collections/hash/map.rs @@ -934,6 +934,7 @@ where /// Retains only the elements specified by the predicate. /// /// In other words, remove all pairs `(k, v)` such that `f(&k, &mut v)` returns `false`. + /// The elements are visited in unsorted (and unspecified) order. /// /// # Examples /// diff --git a/library/std/src/collections/hash/set.rs b/library/std/src/collections/hash/set.rs index 272e1c2be2b..1a2a8afac8b 100644 --- a/library/std/src/collections/hash/set.rs +++ b/library/std/src/collections/hash/set.rs @@ -912,6 +912,7 @@ where /// Retains only the elements specified by the predicate. /// /// In other words, remove all elements `e` such that `f(&e)` returns `false`. + /// The elements are visited in unsorted (and unspecified) order. /// /// # Examples /// diff --git a/library/std/src/io/buffered/bufwriter.rs b/library/std/src/io/buffered/bufwriter.rs index ef2769d431f..c98244132be 100644 --- a/library/std/src/io/buffered/bufwriter.rs +++ b/library/std/src/io/buffered/bufwriter.rs @@ -68,7 +68,7 @@ use crate::ptr; /// [`flush`]: BufWriter::flush #[stable(feature = "rust1", since = "1.0.0")] pub struct BufWriter<W: Write> { - inner: Option<W>, + inner: W, // The buffer. Avoid using this like a normal `Vec` in common code paths. // That is, don't use `buf.push`, `buf.extend_from_slice`, or any other // methods that require bounds checking or the like. This makes an enormous @@ -112,7 +112,7 @@ impl<W: Write> BufWriter<W> { /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn with_capacity(capacity: usize, inner: W) -> BufWriter<W> { - BufWriter { inner: Some(inner), buf: Vec::with_capacity(capacity), panicked: false } + BufWriter { inner, buf: Vec::with_capacity(capacity), panicked: false } } /// Send data in our local buffer into the inner writer, looping as @@ -161,10 +161,9 @@ impl<W: Write> BufWriter<W> { } let mut guard = BufGuard::new(&mut self.buf); - let inner = self.inner.as_mut().unwrap(); while !guard.done() { self.panicked = true; - let r = inner.write(guard.remaining()); + let r = self.inner.write(guard.remaining()); self.panicked = false; match r { @@ -212,7 +211,7 @@ impl<W: Write> BufWriter<W> { /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn get_ref(&self) -> &W { - self.inner.as_ref().unwrap() + &self.inner } /// Gets a mutable reference to the underlying writer. @@ -232,7 +231,7 @@ impl<W: Write> BufWriter<W> { /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn get_mut(&mut self) -> &mut W { - self.inner.as_mut().unwrap() + &mut self.inner } /// Returns a reference to the internally buffered data. @@ -308,7 +307,7 @@ impl<W: Write> BufWriter<W> { pub fn into_inner(mut self) -> Result<W, IntoInnerError<BufWriter<W>>> { match self.flush_buf() { Err(e) => Err(IntoInnerError::new(self, e)), - Ok(()) => Ok(self.inner.take().unwrap()), + Ok(()) => Ok(self.into_raw_parts().0), } } @@ -339,7 +338,12 @@ impl<W: Write> BufWriter<W> { pub fn into_raw_parts(mut self) -> (W, Result<Vec<u8>, WriterPanicked>) { let buf = mem::take(&mut self.buf); let buf = if !self.panicked { Ok(buf) } else { Err(WriterPanicked { buf }) }; - (self.inner.take().unwrap(), buf) + + // SAFETY: forget(self) prevents double dropping inner + let inner = unsafe { ptr::read(&mut self.inner) }; + mem::forget(self); + + (inner, buf) } // Ensure this function does not get inlined into `write`, so that it @@ -643,7 +647,7 @@ where { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_struct("BufWriter") - .field("writer", &self.inner.as_ref().unwrap()) + .field("writer", &self.inner) .field("buffer", &format_args!("{}/{}", self.buf.len(), self.buf.capacity())) .finish() } @@ -663,7 +667,7 @@ impl<W: Write + Seek> Seek for BufWriter<W> { #[stable(feature = "rust1", since = "1.0.0")] impl<W: Write> Drop for BufWriter<W> { fn drop(&mut self) { - if self.inner.is_some() && !self.panicked { + if !self.panicked { // dtors should not panic, so we ignore a failed flush let _r = self.flush_buf(); } diff --git a/library/std/src/io/buffered/mod.rs b/library/std/src/io/buffered/mod.rs index 65497817f81..38076ab3a2b 100644 --- a/library/std/src/io/buffered/mod.rs +++ b/library/std/src/io/buffered/mod.rs @@ -133,7 +133,6 @@ impl<W> IntoInnerError<W> { /// /// # Example /// ``` - /// #![feature(io_into_inner_error_parts)] /// use std::io::{BufWriter, ErrorKind, Write}; /// /// let mut not_enough_space = [0u8; 10]; @@ -143,7 +142,7 @@ impl<W> IntoInnerError<W> { /// let err = into_inner_err.into_error(); /// assert_eq!(err.kind(), ErrorKind::WriteZero); /// ``` - #[unstable(feature = "io_into_inner_error_parts", issue = "79704")] + #[stable(feature = "io_into_inner_error_parts", since = "1.55.0")] pub fn into_error(self) -> Error { self.1 } @@ -156,7 +155,6 @@ impl<W> IntoInnerError<W> { /// /// # Example /// ``` - /// #![feature(io_into_inner_error_parts)] /// use std::io::{BufWriter, ErrorKind, Write}; /// /// let mut not_enough_space = [0u8; 10]; @@ -167,7 +165,7 @@ impl<W> IntoInnerError<W> { /// assert_eq!(err.kind(), ErrorKind::WriteZero); /// assert_eq!(recovered_writer.buffer(), b"t be actually written"); /// ``` - #[unstable(feature = "io_into_inner_error_parts", issue = "79704")] + #[stable(feature = "io_into_inner_error_parts", since = "1.55.0")] pub fn into_parts(self) -> (Error, W) { (self.1, self.0) } diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 77d2684b5d2..78c9a252622 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -3,7 +3,7 @@ //! //! This module contains some of the real meat in the rustbuild build system //! which is where Cargo is used to compile the standard library, libtest, and -//! compiler. This module is also responsible for assembling the sysroot as it +//! the compiler. This module is also responsible for assembling the sysroot as it //! goes along from the output of the previous stage. use std::borrow::Cow; diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 483816b98d6..4b3c25b02c2 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -13,6 +13,7 @@ use std::path::{Path, PathBuf}; use std::str::FromStr; use crate::cache::{Interned, INTERNER}; +use crate::channel::GitInfo; pub use crate::flags::Subcommand; use crate::flags::{Color, Flags}; use crate::util::exe; @@ -48,7 +49,7 @@ pub struct Config { /// Call Build::ninja() instead of this. pub ninja_in_file: bool, pub verbose: usize, - pub submodules: bool, + pub submodules: Option<bool>, pub fast_submodules: bool, pub compiler_docs: bool, pub docs_minification: bool, @@ -552,7 +553,7 @@ impl Config { config.backtrace = true; config.rust_optimize = true; config.rust_optimize_tests = true; - config.submodules = true; + config.submodules = None; config.fast_submodules = true; config.docs = true; config.docs_minification = true; @@ -658,11 +659,11 @@ impl Config { config.npm = build.npm.map(PathBuf::from); config.gdb = build.gdb.map(PathBuf::from); config.python = build.python.map(PathBuf::from); + config.submodules = build.submodules; set(&mut config.low_priority, build.low_priority); set(&mut config.compiler_docs, build.compiler_docs); set(&mut config.docs_minification, build.docs_minification); set(&mut config.docs, build.docs); - set(&mut config.submodules, build.submodules); set(&mut config.fast_submodules, build.fast_submodules); set(&mut config.locked_deps, build.locked_deps); set(&mut config.vendor, build.vendor); @@ -792,8 +793,16 @@ impl Config { // CI-built LLVM can be either dynamic or static. let ci_llvm = config.out.join(&*config.build.triple).join("ci-llvm"); - let link_type = t!(std::fs::read_to_string(ci_llvm.join("link-type.txt"))); - config.llvm_link_shared = link_type == "dynamic"; + config.llvm_link_shared = if config.dry_run { + // just assume dynamic for now + true + } else { + let link_type = t!( + std::fs::read_to_string(ci_llvm.join("link-type.txt")), + format!("CI llvm missing: {}", ci_llvm.display()) + ); + link_type == "dynamic" + }; } if config.llvm_thin_lto { @@ -1075,6 +1084,10 @@ impl Config { pub fn llvm_enabled(&self) -> bool { self.rust_codegen_backends.contains(&INTERNER.intern_str("llvm")) } + + pub fn submodules(&self, rust_info: &GitInfo) -> bool { + self.submodules.unwrap_or(rust_info.is_git()) + } } fn set<T>(field: &mut T, val: Option<T>) { diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index 999882a1c04..8d9f169e6c5 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -160,6 +160,7 @@ o("full-bootstrap", "build.full-bootstrap", "build three compilers instead of tw o("extended", "build.extended", "build an extended rust tool set") v("tools", None, "List of extended tools will be installed") +v("codegen-backends", None, "List of codegen backends to build") v("build", "build.build", "GNUs ./configure syntax LLVM build triple") v("host", None, "GNUs ./configure syntax LLVM host triples") v("target", None, "GNUs ./configure syntax LLVM target triples") @@ -339,6 +340,8 @@ for key in known_args: set('target.{}.llvm-filecheck'.format(build()), value) elif option.name == 'tools': set('build.tools', value.split(',')) + elif option.name == 'codegen-backends': + set('rust.codegen-backends', value.split(',')) elif option.name == 'host': set('build.host', value.split(',')) elif option.name == 'target': diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 92853378e58..c37763243c0 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -1955,8 +1955,16 @@ fn maybe_install_llvm(builder: &Builder<'_>, target: TargetSelection, dst_libdir cmd.arg("--libfiles"); builder.verbose(&format!("running {:?}", cmd)); let files = output(&mut cmd); + let build_llvm_out = &builder.llvm_out(builder.config.build); + let target_llvm_out = &builder.llvm_out(target); for file in files.trim_end().split(' ') { - builder.install(Path::new(file), dst_libdir, 0o644); + // If we're not using a custom LLVM, make sure we package for the target. + let file = if let Ok(relative_path) = Path::new(file).strip_prefix(build_llvm_out) { + target_llvm_out.join(relative_path) + } else { + PathBuf::from(file) + }; + builder.install(&file, dst_libdir, 0o644); } !builder.config.dry_run } else { diff --git a/src/bootstrap/job.rs b/src/bootstrap/job.rs index 2fe9b06e426..5c0322e18a4 100644 --- a/src/bootstrap/job.rs +++ b/src/bootstrap/job.rs @@ -103,12 +103,20 @@ pub unsafe fn setup(build: &mut Build) { }; let parent = OpenProcess(PROCESS_DUP_HANDLE, FALSE, pid.parse().unwrap()); - assert!( - !parent.is_null(), - "PID `{}` doesn't seem to exist: {}", - pid, - io::Error::last_os_error() - ); + + // If we get a null parent pointer here, it is possible that either + // we have got an invalid pid or the parent process has been closed. + // Since the first case rarely happens + // (only when wrongly setting the environmental variable), + // so it might be better to improve the experience of the second case + // when users have interrupted the parent process and we don't finish + // duplicating the handle yet. + // We just need close the job object if that occurs. + if parent.is_null() { + CloseHandle(job); + return; + } + let mut parent_handle = ptr::null_mut(); let r = DuplicateHandle( GetCurrentProcess(), diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 6bcdbe3e4bb..245f3eada2a 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -486,7 +486,7 @@ impl Build { t!(std::fs::read_dir(dir)).next().is_none() } - if !self.config.submodules { + if !self.config.submodules(&self.rust_info) { return; } @@ -562,7 +562,7 @@ impl Build { "library/stdarch", ]; // Avoid running git when there isn't a git checkout. - if !self.config.submodules { + if !self.config.submodules(&self.rust_info) { return; } let output = output( diff --git a/src/test/rustdoc-gui/module-items-font.goml b/src/test/rustdoc-gui/module-items-font.goml new file mode 100644 index 00000000000..817b148bee1 --- /dev/null +++ b/src/test/rustdoc-gui/module-items-font.goml @@ -0,0 +1,4 @@ +// This test checks that the correct font is used on module items (in index.html pages). +goto: file://|DOC_PATH|/test_docs/index.html +assert-css: (".item-table .module-item a", {"font-family": '"Fira Sans", Arial, sans-serif'}, ALL) +assert-css: (".item-table .docblock-short", {"font-family": '"Source Serif 4", "Noto Sans KR", serif'}, ALL) diff --git a/src/test/ui/async-await/issue-86507.rs b/src/test/ui/async-await/issue-86507.rs new file mode 100644 index 00000000000..317f0317664 --- /dev/null +++ b/src/test/ui/async-await/issue-86507.rs @@ -0,0 +1,25 @@ +// edition:2018 + +use ::core::pin::Pin; +use ::core::future::Future; +use ::core::marker::Send; + +trait Foo { + fn bar<'me, 'async_trait, T: Send>(x: &'me T) + -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> + where 'me: 'async_trait; +} + +impl Foo for () { + fn bar<'me, 'async_trait, T: Send>(x: &'me T) + -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> + where 'me:'async_trait { + Box::pin( //~ ERROR future cannot be sent between threads safely + async move { + let x = x; + } + ) + } +} + +fn main() { } diff --git a/src/test/ui/async-await/issue-86507.stderr b/src/test/ui/async-await/issue-86507.stderr new file mode 100644 index 00000000000..51e8f61085b --- /dev/null +++ b/src/test/ui/async-await/issue-86507.stderr @@ -0,0 +1,23 @@ +error: future cannot be sent between threads safely + --> $DIR/issue-86507.rs:17:13 + | +LL | / Box::pin( +LL | | async move { +LL | | let x = x; +LL | | } +LL | | ) + | |_____________^ future created by async block is not `Send` + | +note: captured value is not `Send` because `&` references cannot be sent unless their referent is `Sync` + --> $DIR/issue-86507.rs:19:29 + | +LL | let x = x; + | ^ has type `&T` which is not `Send`, because `T` is not `Sync` + = note: required for the cast to the object type `dyn Future<Output = ()> + Send` +help: consider further restricting type parameter `T` + | +LL | where 'me:'async_trait, T: std::marker::Sync { + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/auxiliary/impl-const.rs b/src/test/ui/const-generics/issues/auxiliary/impl-const.rs index 4a6b5784221..4a6b5784221 100644 --- a/src/test/ui/const-generics/auxiliary/impl-const.rs +++ b/src/test/ui/const-generics/issues/auxiliary/impl-const.rs diff --git a/src/test/ui/const-generics/issue-61522-array-len-succ.full.stderr b/src/test/ui/const-generics/issues/issue-61522-array-len-succ.full.stderr index 56deec16548..56deec16548 100644 --- a/src/test/ui/const-generics/issue-61522-array-len-succ.full.stderr +++ b/src/test/ui/const-generics/issues/issue-61522-array-len-succ.full.stderr diff --git a/src/test/ui/const-generics/issue-61522-array-len-succ.min.stderr b/src/test/ui/const-generics/issues/issue-61522-array-len-succ.min.stderr index 36a0a37ae9c..36a0a37ae9c 100644 --- a/src/test/ui/const-generics/issue-61522-array-len-succ.min.stderr +++ b/src/test/ui/const-generics/issues/issue-61522-array-len-succ.min.stderr diff --git a/src/test/ui/const-generics/issue-61522-array-len-succ.rs b/src/test/ui/const-generics/issues/issue-61522-array-len-succ.rs index d4a948b9259..d4a948b9259 100644 --- a/src/test/ui/const-generics/issue-61522-array-len-succ.rs +++ b/src/test/ui/const-generics/issues/issue-61522-array-len-succ.rs diff --git a/src/test/ui/const-generics/issue-66596-impl-trait-for-str-const-arg.min.stderr b/src/test/ui/const-generics/issues/issue-66596-impl-trait-for-str-const-arg.min.stderr index e96b9e70352..e96b9e70352 100644 --- a/src/test/ui/const-generics/issue-66596-impl-trait-for-str-const-arg.min.stderr +++ b/src/test/ui/const-generics/issues/issue-66596-impl-trait-for-str-const-arg.min.stderr diff --git a/src/test/ui/const-generics/issue-66596-impl-trait-for-str-const-arg.rs b/src/test/ui/const-generics/issues/issue-66596-impl-trait-for-str-const-arg.rs index 2a741ba87a9..2a741ba87a9 100644 --- a/src/test/ui/const-generics/issue-66596-impl-trait-for-str-const-arg.rs +++ b/src/test/ui/const-generics/issues/issue-66596-impl-trait-for-str-const-arg.rs diff --git a/src/test/ui/const-generics/issue-67375.full.stderr b/src/test/ui/const-generics/issues/issue-67375.full.stderr index 0fe65272f1b..0fe65272f1b 100644 --- a/src/test/ui/const-generics/issue-67375.full.stderr +++ b/src/test/ui/const-generics/issues/issue-67375.full.stderr diff --git a/src/test/ui/const-generics/issue-67375.min.stderr b/src/test/ui/const-generics/issues/issue-67375.min.stderr index be81fa92129..be81fa92129 100644 --- a/src/test/ui/const-generics/issue-67375.min.stderr +++ b/src/test/ui/const-generics/issues/issue-67375.min.stderr diff --git a/src/test/ui/const-generics/issue-67375.rs b/src/test/ui/const-generics/issues/issue-67375.rs index a8875b8b6bf..a8875b8b6bf 100644 --- a/src/test/ui/const-generics/issue-67375.rs +++ b/src/test/ui/const-generics/issues/issue-67375.rs diff --git a/src/test/ui/const-generics/issue-67945-1.full.stderr b/src/test/ui/const-generics/issues/issue-67945-1.full.stderr index 63c50b5ca54..63c50b5ca54 100644 --- a/src/test/ui/const-generics/issue-67945-1.full.stderr +++ b/src/test/ui/const-generics/issues/issue-67945-1.full.stderr diff --git a/src/test/ui/const-generics/issue-67945-1.min.stderr b/src/test/ui/const-generics/issues/issue-67945-1.min.stderr index 074d36c8ef3..074d36c8ef3 100644 --- a/src/test/ui/const-generics/issue-67945-1.min.stderr +++ b/src/test/ui/const-generics/issues/issue-67945-1.min.stderr diff --git a/src/test/ui/const-generics/issue-67945-1.rs b/src/test/ui/const-generics/issues/issue-67945-1.rs index 84737e4e985..84737e4e985 100644 --- a/src/test/ui/const-generics/issue-67945-1.rs +++ b/src/test/ui/const-generics/issues/issue-67945-1.rs diff --git a/src/test/ui/const-generics/issue-67945-2.full.stderr b/src/test/ui/const-generics/issues/issue-67945-2.full.stderr index b9004060231..b9004060231 100644 --- a/src/test/ui/const-generics/issue-67945-2.full.stderr +++ b/src/test/ui/const-generics/issues/issue-67945-2.full.stderr diff --git a/src/test/ui/const-generics/issue-67945-2.min.stderr b/src/test/ui/const-generics/issues/issue-67945-2.min.stderr index c06df79f842..c06df79f842 100644 --- a/src/test/ui/const-generics/issue-67945-2.min.stderr +++ b/src/test/ui/const-generics/issues/issue-67945-2.min.stderr diff --git a/src/test/ui/const-generics/issue-67945-2.rs b/src/test/ui/const-generics/issues/issue-67945-2.rs index 4a46786e9a9..4a46786e9a9 100644 --- a/src/test/ui/const-generics/issue-67945-2.rs +++ b/src/test/ui/const-generics/issues/issue-67945-2.rs diff --git a/src/test/ui/const-generics/issue-67945-3.full.stderr b/src/test/ui/const-generics/issues/issue-67945-3.full.stderr index fa66252bd69..fa66252bd69 100644 --- a/src/test/ui/const-generics/issue-67945-3.full.stderr +++ b/src/test/ui/const-generics/issues/issue-67945-3.full.stderr diff --git a/src/test/ui/const-generics/issue-67945-3.min.stderr b/src/test/ui/const-generics/issues/issue-67945-3.min.stderr index 5c30429c895..5c30429c895 100644 --- a/src/test/ui/const-generics/issue-67945-3.min.stderr +++ b/src/test/ui/const-generics/issues/issue-67945-3.min.stderr diff --git a/src/test/ui/const-generics/issue-67945-3.rs b/src/test/ui/const-generics/issues/issue-67945-3.rs index 5bad61cfc76..5bad61cfc76 100644 --- a/src/test/ui/const-generics/issue-67945-3.rs +++ b/src/test/ui/const-generics/issues/issue-67945-3.rs diff --git a/src/test/ui/const-generics/issue-68104-print-stack-overflow.rs b/src/test/ui/const-generics/issues/issue-68104-print-stack-overflow.rs index 43c3999133c..43c3999133c 100644 --- a/src/test/ui/const-generics/issue-68104-print-stack-overflow.rs +++ b/src/test/ui/const-generics/issues/issue-68104-print-stack-overflow.rs diff --git a/src/test/ui/const-generics/issue-70180-1-stalled_on.rs b/src/test/ui/const-generics/issues/issue-70180-1-stalled_on.rs index f0554823273..f0554823273 100644 --- a/src/test/ui/const-generics/issue-70180-1-stalled_on.rs +++ b/src/test/ui/const-generics/issues/issue-70180-1-stalled_on.rs diff --git a/src/test/ui/const-generics/issue-70180-2-stalled_on.rs b/src/test/ui/const-generics/issues/issue-70180-2-stalled_on.rs index 21cefc09c25..21cefc09c25 100644 --- a/src/test/ui/const-generics/issue-70180-2-stalled_on.rs +++ b/src/test/ui/const-generics/issues/issue-70180-2-stalled_on.rs diff --git a/src/test/ui/const-generics/issue-71202.rs b/src/test/ui/const-generics/issues/issue-71202.rs index 78dee1717f1..78dee1717f1 100644 --- a/src/test/ui/const-generics/issue-71202.rs +++ b/src/test/ui/const-generics/issues/issue-71202.rs diff --git a/src/test/ui/const-generics/issue-71986.rs b/src/test/ui/const-generics/issues/issue-71986.rs index 6bfdba5711e..6bfdba5711e 100644 --- a/src/test/ui/const-generics/issue-71986.rs +++ b/src/test/ui/const-generics/issues/issue-71986.rs diff --git a/src/test/ui/const-generics/issue-73899.rs b/src/test/ui/const-generics/issues/issue-73899.rs index 2a3a5ab2a3b..2a3a5ab2a3b 100644 --- a/src/test/ui/const-generics/issue-73899.rs +++ b/src/test/ui/const-generics/issues/issue-73899.rs diff --git a/src/test/ui/const-generics/issue-74906.rs b/src/test/ui/const-generics/issues/issue-74906.rs index dc3c33736da..dc3c33736da 100644 --- a/src/test/ui/const-generics/issue-74906.rs +++ b/src/test/ui/const-generics/issues/issue-74906.rs diff --git a/src/test/ui/const-generics/issue-75763.rs b/src/test/ui/const-generics/issues/issue-75763.rs index c311de05a1c..c311de05a1c 100644 --- a/src/test/ui/const-generics/issue-75763.rs +++ b/src/test/ui/const-generics/issues/issue-75763.rs diff --git a/src/test/ui/const-generics/issue-79518-default_trait_method_normalization.rs b/src/test/ui/const-generics/issues/issue-79518-default_trait_method_normalization.rs index 8f02bfb937a..8f02bfb937a 100644 --- a/src/test/ui/const-generics/issue-79518-default_trait_method_normalization.rs +++ b/src/test/ui/const-generics/issues/issue-79518-default_trait_method_normalization.rs diff --git a/src/test/ui/const-generics/issue-79518-default_trait_method_normalization.stderr b/src/test/ui/const-generics/issues/issue-79518-default_trait_method_normalization.stderr index c90774e944f..c90774e944f 100644 --- a/src/test/ui/const-generics/issue-79518-default_trait_method_normalization.stderr +++ b/src/test/ui/const-generics/issues/issue-79518-default_trait_method_normalization.stderr diff --git a/src/test/ui/const-generics/issue-80561-incorrect-param-env.rs b/src/test/ui/const-generics/issues/issue-80561-incorrect-param-env.rs index a34d74b29e9..a34d74b29e9 100644 --- a/src/test/ui/const-generics/issue-80561-incorrect-param-env.rs +++ b/src/test/ui/const-generics/issues/issue-80561-incorrect-param-env.rs diff --git a/src/test/ui/const-generics/issue-86820.rs b/src/test/ui/const-generics/issues/issue-86820.rs index 04650403c6b..04650403c6b 100644 --- a/src/test/ui/const-generics/issue-86820.rs +++ b/src/test/ui/const-generics/issues/issue-86820.rs diff --git a/src/test/ui/const-generics/issue-86820.stderr b/src/test/ui/const-generics/issues/issue-86820.stderr index f4396f2f2b0..f4396f2f2b0 100644 --- a/src/test/ui/const-generics/issue-86820.stderr +++ b/src/test/ui/const-generics/issues/issue-86820.stderr diff --git a/src/test/ui/const-generics/issues/issue-87076.rs b/src/test/ui/const-generics/issues/issue-87076.rs new file mode 100644 index 00000000000..5dfda943bf6 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-87076.rs @@ -0,0 +1,20 @@ +// build-pass + +#![feature(const_generics)] +#![allow(incomplete_features)] + +#[derive(PartialEq, Eq)] +pub struct UnitDims { + pub time: u8, + pub length: u8, +} + +pub struct UnitValue<const DIMS: UnitDims>; + +impl<const DIMS: UnitDims> UnitValue<DIMS> { + fn crash() {} +} + +fn main() { + UnitValue::<{ UnitDims { time: 1, length: 2 } }>::crash(); +} diff --git a/src/tools/clippy/tests/ui/future_not_send.stderr b/src/tools/clippy/tests/ui/future_not_send.stderr index b59dbb3e76c..c734051ccf3 100644 --- a/src/tools/clippy/tests/ui/future_not_send.stderr +++ b/src/tools/clippy/tests/ui/future_not_send.stderr @@ -55,11 +55,11 @@ note: captured value is not `Send` LL | async fn private_future2(rc: Rc<[u8]>, cell: &Cell<usize>) -> bool { | ^^ has type `std::rc::Rc<[u8]>` which is not `Send` = note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Send` -note: captured value is not `Send` +note: captured value is not `Send` because `&` references cannot be sent unless their referent is `Sync` --> $DIR/future_not_send.rs:20:40 | LL | async fn private_future2(rc: Rc<[u8]>, cell: &Cell<usize>) -> bool { - | ^^^^ has type `&std::cell::Cell<usize>` which is not `Send` + | ^^^^ has type `&std::cell::Cell<usize>` which is not `Send`, because `std::cell::Cell<usize>` is not `Sync` = note: `std::cell::Cell<usize>` doesn't implement `std::marker::Sync` error: future cannot be sent between threads safely |
