From 3b051d0171b4e15aff4d2ecacf7659f7278e8e09 Mon Sep 17 00:00:00 2001 From: Stein Somers Date: Sun, 27 Sep 2020 01:10:30 +0200 Subject: [PATCH 1/9] BTreeMap: comment why drain_filter's size_hint is somewhat pessimistictid --- library/alloc/src/collections/btree/map.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs index ee0f525fb15ee..4ca93a4eb8366 100644 --- a/library/alloc/src/collections/btree/map.rs +++ b/library/alloc/src/collections/btree/map.rs @@ -1748,6 +1748,10 @@ impl<'a, K: 'a, V: 'a> DrainFilterInner<'a, K, V> { /// Implementation of a typical `DrainFilter::size_hint` method. pub(super) fn size_hint(&self) -> (usize, Option) { + // In most of the btree iterators, `self.length` is the number of elements + // yet to be visited. Here, it includes elements that were visited and that + // the predicate decided not to drain. Making this upper bound more accurate + // requires maintaining an extra field and is not worth while. (0, Some(*self.length)) } } From 56b51a9751600dd65ad4bbda5c0f3d7b8c6db970 Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Wed, 7 Oct 2020 11:48:26 -0600 Subject: [PATCH 2/9] (docs): make mutex error comment consistent with codebase --- library/std/src/sync/mutex.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/sync/mutex.rs b/library/std/src/sync/mutex.rs index e8f5a6f429486..a01ebb316e886 100644 --- a/library/std/src/sync/mutex.rs +++ b/library/std/src/sync/mutex.rs @@ -276,7 +276,7 @@ impl Mutex { /// # Errors /// /// If another user of this mutex panicked while holding the mutex, then - /// this call will return failure if the mutex would otherwise be + /// this call will return an error if the mutex would otherwise be /// acquired. /// /// # Examples From 141544a903d4eb049d0611cbe6c7d248d3f5d425 Mon Sep 17 00:00:00 2001 From: Kazantcev Andrey <45011689+heckad@users.noreply.github.com> Date: Thu, 8 Oct 2020 00:29:20 +0300 Subject: [PATCH 3/9] Remove unnecessary lamda on emitter map. --- compiler/rustc_driver/src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/compiler/rustc_driver/src/lib.rs b/compiler/rustc_driver/src/lib.rs index 3f50c68e3ebf5..e89fcc920a093 100644 --- a/compiler/rustc_driver/src/lib.rs +++ b/compiler/rustc_driver/src/lib.rs @@ -155,8 +155,7 @@ pub fn run_compiler( ), } } - let diagnostic_output = - emitter.map(|emitter| DiagnosticOutput::Raw(emitter)).unwrap_or(DiagnosticOutput::Default); + let diagnostic_output = emitter.map(DiagnosticOutput::Raw).unwrap_or(DiagnosticOutput::Default); let matches = match handle_options(&args) { Some(matches) => matches, None => return Ok(()), From ea206f2c5af8597771347ecc95e76c258b710181 Mon Sep 17 00:00:00 2001 From: Andreas Molzer Date: Wed, 7 Oct 2020 19:49:52 +0200 Subject: [PATCH 4/9] Add compile fail test for issue 27675 --- .../issue-27675-unchecked-bounds.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/test/compile-fail/issue-27675-unchecked-bounds.rs diff --git a/src/test/compile-fail/issue-27675-unchecked-bounds.rs b/src/test/compile-fail/issue-27675-unchecked-bounds.rs new file mode 100644 index 0000000000000..1cfc230453120 --- /dev/null +++ b/src/test/compile-fail/issue-27675-unchecked-bounds.rs @@ -0,0 +1,19 @@ +/// The compiler previously did not properly check the bound of `From` when it was used from type +/// of the dyn trait object (use in `copy_any` below). Since the associated type is under user +/// control in this usage, the compiler could be tricked to believe any type implemented any trait. +/// This would ICE, except for pure marker traits like `Copy`. It did not require providing an +/// instance of the dyn trait type, only name said type. +trait Setup { + type From: Copy; +} + +fn copy(from: &U::From) -> U::From { + *from +} + +pub fn copy_any(t: &T) -> T { + copy::>(t) + //~^ ERROR the trait bound `T: Copy` is not satisfied +} + +fn main() {} From dd60ab3e2d5f2c650423f7d85b7cf5b4d8ce0a5c Mon Sep 17 00:00:00 2001 From: Kazantcev Andrey <45011689+heckad@users.noreply.github.com> Date: Thu, 8 Oct 2020 13:58:51 +0300 Subject: [PATCH 5/9] Commit suggestion Co-authored-by: Jonas Schievink --- compiler/rustc_driver/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_driver/src/lib.rs b/compiler/rustc_driver/src/lib.rs index e89fcc920a093..066a61a7a7b53 100644 --- a/compiler/rustc_driver/src/lib.rs +++ b/compiler/rustc_driver/src/lib.rs @@ -155,7 +155,7 @@ pub fn run_compiler( ), } } - let diagnostic_output = emitter.map(DiagnosticOutput::Raw).unwrap_or(DiagnosticOutput::Default); + let diagnostic_output = emitter.map_or(DiagnosticOutput::Default, DiagnosticOutput::Raw); let matches = match handle_options(&args) { Some(matches) => matches, None => return Ok(()), From a28f425ad7615761eaae9c9263fb8f657c21f839 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Thu, 8 Oct 2020 09:16:27 -0400 Subject: [PATCH 6/9] Make `max_log_info` easily greppable --- config.toml.example | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config.toml.example b/config.toml.example index c5efb8ed5e51c..6dc9eccbdfceb 100644 --- a/config.toml.example +++ b/config.toml.example @@ -382,6 +382,10 @@ changelog-seen = 1 # Overrides the `debug-assertions` option, if defined. # # Defaults to rust.debug-assertions value +# +# If you see a message from `tracing` saying +# `max_level_info` is enabled and means logging won't be shown, +# set this value to `true`. #debug-logging = debug-assertions # Debuginfo level for most of Rust code, corresponds to the `-C debuginfo=N` option of `rustc`. From 3450cf61e0e0e574dc25241e6a71b70e3b35fb93 Mon Sep 17 00:00:00 2001 From: Kazantcev Andrey <45011689+heckad@users.noreply.github.com> Date: Thu, 8 Oct 2020 16:22:31 +0300 Subject: [PATCH 7/9] Remove not needed lambda. --- compiler/rustc_interface/src/util.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index 7ace707cc88e9..c1b359c7d0de5 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -187,7 +187,7 @@ pub fn setup_callbacks_and_run_in_thread_pool_with_globals R + Se config = config.stack_size(size); } - let with_pool = move |pool: &rayon::ThreadPool| pool.install(move || f()); + let with_pool = move |pool: &rayon::ThreadPool| pool.install(f); rustc_span::with_session_globals(edition, || { rustc_span::SESSION_GLOBALS.with(|session_globals| { From 8ab2ba1fe9f1f26693db4a0131223e8f35ed02fb Mon Sep 17 00:00:00 2001 From: Raoul Strackx Date: Thu, 8 Oct 2020 17:43:26 +0200 Subject: [PATCH 8/9] Update submodule llvm to get LVI bugfix --- src/llvm-project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llvm-project b/src/llvm-project index e8b556b6a8836..3adf16e0cb1a0 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit e8b556b6a8836147429abe391d6ed18806867b45 +Subproject commit 3adf16e0cb1a0d9d7216883ac47857a6d1ee6581 From c17d0670185e67ed6edb0aca5d305b4b25072d35 Mon Sep 17 00:00:00 2001 From: Camelid Date: Tue, 15 Sep 2020 10:22:48 -0700 Subject: [PATCH 9/9] Don't discourage implementing `core::fmt::Write` Explain when you should use it and when you should not. --- library/core/src/fmt/mod.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/library/core/src/fmt/mod.rs b/library/core/src/fmt/mod.rs index 54772ebb523a3..0963c6d6cd7ea 100644 --- a/library/core/src/fmt/mod.rs +++ b/library/core/src/fmt/mod.rs @@ -92,18 +92,14 @@ pub type Result = result::Result<(), Error>; #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] pub struct Error; -/// A collection of methods that are required to format a message into a stream. +/// A trait for writing or formatting into Unicode-accepting buffers or streams. /// -/// This trait is the type which this modules requires when formatting -/// information. This is similar to the standard library's [`io::Write`] trait, -/// but it is only intended for use in libcore. +/// This trait only accepts UTF-8–encoded data and is not [flushable]. If you only +/// want to accept Unicode and you don't need flushing, you should implement this trait; +/// otherwise you should implement [`std::io::Write`]. /// -/// This trait should generally not be implemented by consumers of the standard -/// library. The [`write!`] macro accepts an instance of [`io::Write`], and the -/// [`io::Write`] trait is favored over implementing this trait. -/// -/// [`write!`]: crate::write! -/// [`io::Write`]: ../../std/io/trait.Write.html +/// [`std::io::Write`]: ../../std/io/trait.Write.html +/// [flushable]: ../../std/io/trait.Write.html#tymethod.flush #[stable(feature = "rust1", since = "1.0.0")] pub trait Write { /// Writes a string slice into this writer, returning whether the write