From f45fe9493ba06cd57fc2f7317a39305f79a1a6e6 Mon Sep 17 00:00:00 2001 From: "Charles E. Lehner" Date: Sat, 20 Feb 2021 13:18:01 -0500 Subject: [PATCH 1/8] Add license metadata for std dependencies --- library/alloc/Cargo.toml | 3 +++ library/core/Cargo.toml | 3 +++ library/panic_abort/Cargo.toml | 3 +++ library/panic_unwind/Cargo.toml | 3 +++ library/unwind/Cargo.toml | 2 ++ 5 files changed, 14 insertions(+) diff --git a/library/alloc/Cargo.toml b/library/alloc/Cargo.toml index d95b5b7f17f42..4f97c95bcb9ea 100644 --- a/library/alloc/Cargo.toml +++ b/library/alloc/Cargo.toml @@ -2,6 +2,9 @@ authors = ["The Rust Project Developers"] name = "alloc" version = "0.0.0" +license = "MIT OR Apache-2.0" +repository = "https://github.com/rust-lang/rust.git" +description = "The Rust core allocation and collections library" autotests = false autobenches = false edition = "2018" diff --git a/library/core/Cargo.toml b/library/core/Cargo.toml index c1596012eac24..4a7dbb91822e2 100644 --- a/library/core/Cargo.toml +++ b/library/core/Cargo.toml @@ -2,6 +2,9 @@ authors = ["The Rust Project Developers"] name = "core" version = "0.0.0" +license = "MIT OR Apache-2.0" +repository = "https://github.com/rust-lang/rust.git" +description = "The Rust Core Library" autotests = false autobenches = false edition = "2018" diff --git a/library/panic_abort/Cargo.toml b/library/panic_abort/Cargo.toml index b15919fad75e7..caa89aa30d0bb 100644 --- a/library/panic_abort/Cargo.toml +++ b/library/panic_abort/Cargo.toml @@ -2,6 +2,9 @@ authors = ["The Rust Project Developers"] name = "panic_abort" version = "0.0.0" +license = "MIT OR Apache-2.0" +repository = "https://github.com/rust-lang/rust.git" +description = "Implementation of Rust panics via process aborts" edition = "2018" [lib] diff --git a/library/panic_unwind/Cargo.toml b/library/panic_unwind/Cargo.toml index d27ba9876416d..533f059a85e45 100644 --- a/library/panic_unwind/Cargo.toml +++ b/library/panic_unwind/Cargo.toml @@ -2,6 +2,9 @@ authors = ["The Rust Project Developers"] name = "panic_unwind" version = "0.0.0" +license = "MIT OR Apache-2.0" +repository = "https://github.com/rust-lang/rust.git" +description = "Implementation of Rust panics via stack unwinding" edition = "2018" [lib] diff --git a/library/unwind/Cargo.toml b/library/unwind/Cargo.toml index 4f7a304a59f68..69128591e0672 100644 --- a/library/unwind/Cargo.toml +++ b/library/unwind/Cargo.toml @@ -2,6 +2,8 @@ authors = ["The Rust Project Developers"] name = "unwind" version = "0.0.0" +license = "MIT OR Apache-2.0" +repository = "https://github.com/rust-lang/rust.git" edition = "2018" include = [ '/libunwind/*', From 9278b4c67284db95990673f26934b9d1d5af2e77 Mon Sep 17 00:00:00 2001 From: Jim Turner Date: Mon, 1 Mar 2021 16:09:41 -0500 Subject: [PATCH 2/8] Document panicking cases for integer division The panic on division by zero is expected, but the panic on overflow is somewhat surprising (since most arithmetic operations panic on overflow only when `debug_assertions` is enabled). As a result, it's helpful to document this behavior. --- library/core/src/ops/arith.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/library/core/src/ops/arith.rs b/library/core/src/ops/arith.rs index 92090d8e6fca7..da0f038e44e7b 100644 --- a/library/core/src/ops/arith.rs +++ b/library/core/src/ops/arith.rs @@ -456,9 +456,13 @@ pub trait Div { } macro_rules! div_impl_integer { - ($($t:ty)*) => ($( + ($(($($t:ty)*) => $panic:expr),*) => ($($( /// This operation rounds towards zero, truncating any /// fractional part of the exact result. + /// + /// # Panics + /// + #[doc = $panic] #[stable(feature = "rust1", since = "1.0.0")] impl Div for $t { type Output = $t; @@ -468,10 +472,13 @@ macro_rules! div_impl_integer { } forward_ref_binop! { impl Div, div for $t, $t } - )*) + )*)*) } -div_impl_integer! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +div_impl_integer! { + (usize u8 u16 u32 u64 u128) => "This operation will panic if `other == 0`.", + (isize i8 i16 i32 i64 i128) => "This operation will panic if `other == 0` or the division results in overflow." +} macro_rules! div_impl_float { ($($t:ty)*) => ($( From b45855032b3aad0ea0a48894f56cb9bb8fa361f2 Mon Sep 17 00:00:00 2001 From: Jim Turner Date: Mon, 1 Mar 2021 16:19:59 -0500 Subject: [PATCH 3/8] Document panicking cases for integer remainder The panic when the right operand is `0` is expected, but the overflow-related panic (which occurs only for `MIN % -1`) is somewhat surprising for two reasons: a return value of `0` would be reasonable in this case, and, for most arithmetic operations, overflow results in panic only when `debug_assertions` is enabled. As a result, it's helpful to document this behavior. --- library/core/src/ops/arith.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/library/core/src/ops/arith.rs b/library/core/src/ops/arith.rs index da0f038e44e7b..a0577b287ce24 100644 --- a/library/core/src/ops/arith.rs +++ b/library/core/src/ops/arith.rs @@ -556,9 +556,13 @@ pub trait Rem { } macro_rules! rem_impl_integer { - ($($t:ty)*) => ($( + ($(($($t:ty)*) => $panic:expr),*) => ($($( /// This operation satisfies `n % d == n - (n / d) * d`. The /// result has the same sign as the left operand. + /// + /// # Panics + /// + #[doc = $panic] #[stable(feature = "rust1", since = "1.0.0")] impl Rem for $t { type Output = $t; @@ -568,10 +572,13 @@ macro_rules! rem_impl_integer { } forward_ref_binop! { impl Rem, rem for $t, $t } - )*) + )*)*) } -rem_impl_integer! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +rem_impl_integer! { + (usize u8 u16 u32 u64 u128) => "This operation will panic if `other == 0`.", + (isize i8 i16 i32 i64 i128) => "This operation will panic if `other == 0` or if `self / other` results in overflow." +} macro_rules! rem_impl_float { ($($t:ty)*) => ($( From 6cfdc385a1e3e9dd624ce87c75f25f1bb16118a1 Mon Sep 17 00:00:00 2001 From: Kornel Date: Thu, 18 Mar 2021 18:43:08 +0000 Subject: [PATCH 4/8] Expand documentation of Iterator::take and skip --- library/core/src/iter/traits/iterator.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index f8504e842ee33..4c6039946474d 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -1228,7 +1228,11 @@ pub trait Iterator { /// Creates an iterator that skips the first `n` elements. /// - /// After they have been consumed, the rest of the elements are yielded. + /// `skip(n)` skips elements until `n` elements are skipped or the end of the + /// iterator is reached (whichever happens first). After that, all the remaining + /// elements are yielded. In particular, if the original iterator is too short, + /// then the returned iterator is empty. + /// /// Rather than overriding this method directly, instead override the `nth` method. /// /// # Examples @@ -1252,7 +1256,14 @@ pub trait Iterator { Skip::new(self, n) } - /// Creates an iterator that yields its first `n` elements. + /// Creates an iterator that yields the first `n` elements, or fewer + /// if the underlying iterator ends sooner. + /// + /// `take(n)` yields elements until `n` elements are yielded or the end of + /// the iterator is reached (whichever happens first). + /// The returned iterator is a prefix of length `n` if the original iterator + /// contains at least `n` elements, otherwise it contains all of the + /// (fewer than `n`) elements of the original iterator. /// /// # Examples /// From 9a9942cb230d3dac7fdbbefe4c94928608ea1d35 Mon Sep 17 00:00:00 2001 From: asquared31415 <34665709+asquared31415@users.noreply.github.com> Date: Sat, 20 Mar 2021 23:54:13 -0400 Subject: [PATCH 5/8] add arm llvm requirement --- src/test/ui/asm/inline-syntax.arm.stderr | 4 ++-- src/test/ui/asm/inline-syntax.rs | 1 + src/test/ui/asm/inline-syntax.x86_64.stderr | 12 ++++++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/test/ui/asm/inline-syntax.arm.stderr b/src/test/ui/asm/inline-syntax.arm.stderr index b1b61f0211a37..78b85dfde33e9 100644 --- a/src/test/ui/asm/inline-syntax.arm.stderr +++ b/src/test/ui/asm/inline-syntax.arm.stderr @@ -1,11 +1,11 @@ error: att syntax is the default syntax on this target, and trying to use this directive may cause issues - --> $DIR/inline-syntax.rs:22:15 + --> $DIR/inline-syntax.rs:23:15 | LL | asm!(".att_syntax noprefix", "nop"); | ^^^^^^^^^^^^^^^^^^^^ help: remove this assembler directive error: att syntax is the default syntax on this target, and trying to use this directive may cause issues - --> $DIR/inline-syntax.rs:25:15 + --> $DIR/inline-syntax.rs:26:15 | LL | asm!(".att_syntax bbb noprefix", "nop"); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this assembler directive diff --git a/src/test/ui/asm/inline-syntax.rs b/src/test/ui/asm/inline-syntax.rs index 9e9c7badfcace..9048282456eb2 100644 --- a/src/test/ui/asm/inline-syntax.rs +++ b/src/test/ui/asm/inline-syntax.rs @@ -1,3 +1,4 @@ +// needs-llvm-components: arm // revisions: x86_64 arm //[x86_64] compile-flags: --target x86_64-unknown-linux-gnu //[arm] compile-flags: --target armv7-unknown-linux-gnueabihf diff --git a/src/test/ui/asm/inline-syntax.x86_64.stderr b/src/test/ui/asm/inline-syntax.x86_64.stderr index c54c2742a5791..826657c98e154 100644 --- a/src/test/ui/asm/inline-syntax.x86_64.stderr +++ b/src/test/ui/asm/inline-syntax.x86_64.stderr @@ -1,17 +1,17 @@ error: intel syntax is the default syntax on this target, and trying to use this directive may cause issues - --> $DIR/inline-syntax.rs:18:15 + --> $DIR/inline-syntax.rs:19:15 | LL | asm!(".intel_syntax noprefix", "nop"); | ^^^^^^^^^^^^^^^^^^^^^^ help: remove this assembler directive error: intel syntax is the default syntax on this target, and trying to use this directive may cause issues - --> $DIR/inline-syntax.rs:20:15 + --> $DIR/inline-syntax.rs:21:15 | LL | asm!(".intel_syntax aaa noprefix", "nop"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this assembler directive error: using the .att_syntax directive may cause issues, use the att_syntax option instead - --> $DIR/inline-syntax.rs:22:15 + --> $DIR/inline-syntax.rs:23:15 | LL | asm!(".att_syntax noprefix", "nop"); | ^^^^^^^^^^^^^^^^^^^^ @@ -22,7 +22,7 @@ LL | asm!("", "nop", options(att_syntax)); | -- ^^^^^^^^^^^^^^^^^^^^^ error: using the .att_syntax directive may cause issues, use the att_syntax option instead - --> $DIR/inline-syntax.rs:25:15 + --> $DIR/inline-syntax.rs:26:15 | LL | asm!(".att_syntax bbb noprefix", "nop"); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,13 +33,13 @@ LL | asm!("", "nop", options(att_syntax)); | -- ^^^^^^^^^^^^^^^^^^^^^ error: intel syntax is the default syntax on this target, and trying to use this directive may cause issues - --> $DIR/inline-syntax.rs:28:15 + --> $DIR/inline-syntax.rs:29:15 | LL | asm!(".intel_syntax noprefix; nop"); | ^^^^^^^^^^^^^^^^^^^^^^ help: remove this assembler directive error: intel syntax is the default syntax on this target, and trying to use this directive may cause issues - --> $DIR/inline-syntax.rs:33:14 + --> $DIR/inline-syntax.rs:34:14 | LL | .intel_syntax noprefix | ______________^ From 4e7f1fa14fe54c20eb583dbf40efe3284d48a3b0 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 21 Mar 2021 18:09:53 +0100 Subject: [PATCH 6/8] post-drop-elab check-const: explain why we still check qualifs --- .../src/transform/check_consts/post_drop_elaboration.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_mir/src/transform/check_consts/post_drop_elaboration.rs b/compiler/rustc_mir/src/transform/check_consts/post_drop_elaboration.rs index 1a2d932ba1905..057092b8ef574 100644 --- a/compiler/rustc_mir/src/transform/check_consts/post_drop_elaboration.rs +++ b/compiler/rustc_mir/src/transform/check_consts/post_drop_elaboration.rs @@ -79,7 +79,9 @@ impl Visitor<'tcx> for CheckLiveDrops<'mir, 'tcx> { mir::TerminatorKind::Drop { place: dropped_place, .. } => { let dropped_ty = dropped_place.ty(self.body, self.tcx).ty; if !NeedsDrop::in_any_value_of_ty(self.ccx, dropped_ty) { - return; + bug!( + "Drop elaboration left behind a Drop for a type that does not need dropping" + ); } if dropped_place.is_indirect() { @@ -87,6 +89,10 @@ impl Visitor<'tcx> for CheckLiveDrops<'mir, 'tcx> { return; } + // Drop elaboration is not precise enough to accept code like + // `src/test/ui/consts/control-flow/drop-pass.rs`; e.g., when an `Option>` is + // initialized with `None` and never changed, it still emits drop glue. + // Hence we additionally check the qualifs here to allow more code to pass. if self.qualifs.needs_drop(self.ccx, dropped_place.local, location) { // Use the span where the dropped local was declared for the error. let span = self.body.local_decls[dropped_place.local].source_info.span; From 688c857c560e60a98576afa52f0829d54164e180 Mon Sep 17 00:00:00 2001 From: Rich Kadel Date: Sun, 21 Mar 2021 23:04:07 -0700 Subject: [PATCH 7/8] Improve error message for unassigned query provider Fixes: 83122 --- compiler/rustc_middle/src/ty/query/mod.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_middle/src/ty/query/mod.rs b/compiler/rustc_middle/src/ty/query/mod.rs index 48e777f7158fd..c170858ba85a1 100644 --- a/compiler/rustc_middle/src/ty/query/mod.rs +++ b/compiler/rustc_middle/src/ty/query/mod.rs @@ -217,8 +217,11 @@ macro_rules! define_callbacks { fn default() -> Self { Providers { $($name: |_, key| bug!( - "`tcx.{}({:?})` unsupported by its crate", - stringify!($name), key + "`tcx.{}({:?})` unsupported by its crate; \ + perhaps the `{}` query was never assigned a provider function", + stringify!($name), + key, + stringify!($name), ),)* } } From fe957350c700ba3a98c640054ad4978909594603 Mon Sep 17 00:00:00 2001 From: Alan Egerton Date: Mon, 22 Mar 2021 09:07:52 +0000 Subject: [PATCH 8/8] SplitInclusive is public API --- library/core/src/str/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs index b5c945594637b..03ed301eacf8c 100644 --- a/library/core/src/str/mod.rs +++ b/library/core/src/str/mod.rs @@ -66,7 +66,7 @@ pub use iter::{EscapeDebug, EscapeDefault, EscapeUnicode}; pub use iter::SplitAsciiWhitespace; #[stable(feature = "split_inclusive", since = "1.51.0")] -use iter::SplitInclusive; +pub use iter::SplitInclusive; #[unstable(feature = "str_internals", issue = "none")] pub use validations::next_code_point;