Skip to content

Commit 2287a88

Browse files
committed
Auto merge of #83376 - Dylan-DPC:rollup-s2fsjwj, r=Dylan-DPC
Rollup of 7 pull requests Successful merges: - #82374 (Add license metadata for std dependencies) - #82683 (Document panicking cases for integer division and remainder) - #83272 (Clarify non-exact length in the Iterator::take documentation) - #83338 (Fix test for #82270) - #83351 (post-drop-elab check-const: explain why we still check qualifs) - #83367 (Improve error message for unassigned query provider) - #83372 (SplitInclusive is public API) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents d04c3aa + ce06787 commit 2287a88

File tree

13 files changed

+69
-20
lines changed

13 files changed

+69
-20
lines changed

compiler/rustc_middle/src/ty/query/mod.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,11 @@ macro_rules! define_callbacks {
217217
fn default() -> Self {
218218
Providers {
219219
$($name: |_, key| bug!(
220-
"`tcx.{}({:?})` unsupported by its crate",
221-
stringify!($name), key
220+
"`tcx.{}({:?})` unsupported by its crate; \
221+
perhaps the `{}` query was never assigned a provider function",
222+
stringify!($name),
223+
key,
224+
stringify!($name),
222225
),)*
223226
}
224227
}

compiler/rustc_mir/src/transform/check_consts/post_drop_elaboration.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,20 @@ impl Visitor<'tcx> for CheckLiveDrops<'mir, 'tcx> {
7979
mir::TerminatorKind::Drop { place: dropped_place, .. } => {
8080
let dropped_ty = dropped_place.ty(self.body, self.tcx).ty;
8181
if !NeedsDrop::in_any_value_of_ty(self.ccx, dropped_ty) {
82-
return;
82+
bug!(
83+
"Drop elaboration left behind a Drop for a type that does not need dropping"
84+
);
8385
}
8486

8587
if dropped_place.is_indirect() {
8688
self.check_live_drop(terminator.source_info.span);
8789
return;
8890
}
8991

92+
// Drop elaboration is not precise enough to accept code like
93+
// `src/test/ui/consts/control-flow/drop-pass.rs`; e.g., when an `Option<Vec<T>>` is
94+
// initialized with `None` and never changed, it still emits drop glue.
95+
// Hence we additionally check the qualifs here to allow more code to pass.
9096
if self.qualifs.needs_drop(self.ccx, dropped_place.local, location) {
9197
// Use the span where the dropped local was declared for the error.
9298
let span = self.body.local_decls[dropped_place.local].source_info.span;

library/alloc/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
authors = ["The Rust Project Developers"]
33
name = "alloc"
44
version = "0.0.0"
5+
license = "MIT OR Apache-2.0"
6+
repository = "https://github.com/rust-lang/rust.git"
7+
description = "The Rust core allocation and collections library"
58
autotests = false
69
autobenches = false
710
edition = "2018"

library/core/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
authors = ["The Rust Project Developers"]
33
name = "core"
44
version = "0.0.0"
5+
license = "MIT OR Apache-2.0"
6+
repository = "https://github.com/rust-lang/rust.git"
7+
description = "The Rust Core Library"
58
autotests = false
69
autobenches = false
710
edition = "2018"

library/core/src/iter/traits/iterator.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,11 @@ pub trait Iterator {
12281228

12291229
/// Creates an iterator that skips the first `n` elements.
12301230
///
1231-
/// After they have been consumed, the rest of the elements are yielded.
1231+
/// `skip(n)` skips elements until `n` elements are skipped or the end of the
1232+
/// iterator is reached (whichever happens first). After that, all the remaining
1233+
/// elements are yielded. In particular, if the original iterator is too short,
1234+
/// then the returned iterator is empty.
1235+
///
12321236
/// Rather than overriding this method directly, instead override the `nth` method.
12331237
///
12341238
/// # Examples
@@ -1252,7 +1256,14 @@ pub trait Iterator {
12521256
Skip::new(self, n)
12531257
}
12541258

1255-
/// Creates an iterator that yields its first `n` elements.
1259+
/// Creates an iterator that yields the first `n` elements, or fewer
1260+
/// if the underlying iterator ends sooner.
1261+
///
1262+
/// `take(n)` yields elements until `n` elements are yielded or the end of
1263+
/// the iterator is reached (whichever happens first).
1264+
/// The returned iterator is a prefix of length `n` if the original iterator
1265+
/// contains at least `n` elements, otherwise it contains all of the
1266+
/// (fewer than `n`) elements of the original iterator.
12561267
///
12571268
/// # Examples
12581269
///

library/core/src/ops/arith.rs

+20-6
Original file line numberDiff line numberDiff line change
@@ -456,9 +456,13 @@ pub trait Div<Rhs = Self> {
456456
}
457457

458458
macro_rules! div_impl_integer {
459-
($($t:ty)*) => ($(
459+
($(($($t:ty)*) => $panic:expr),*) => ($($(
460460
/// This operation rounds towards zero, truncating any
461461
/// fractional part of the exact result.
462+
///
463+
/// # Panics
464+
///
465+
#[doc = $panic]
462466
#[stable(feature = "rust1", since = "1.0.0")]
463467
impl Div for $t {
464468
type Output = $t;
@@ -468,10 +472,13 @@ macro_rules! div_impl_integer {
468472
}
469473

470474
forward_ref_binop! { impl Div, div for $t, $t }
471-
)*)
475+
)*)*)
472476
}
473477

474-
div_impl_integer! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
478+
div_impl_integer! {
479+
(usize u8 u16 u32 u64 u128) => "This operation will panic if `other == 0`.",
480+
(isize i8 i16 i32 i64 i128) => "This operation will panic if `other == 0` or the division results in overflow."
481+
}
475482

476483
macro_rules! div_impl_float {
477484
($($t:ty)*) => ($(
@@ -549,9 +556,13 @@ pub trait Rem<Rhs = Self> {
549556
}
550557

551558
macro_rules! rem_impl_integer {
552-
($($t:ty)*) => ($(
559+
($(($($t:ty)*) => $panic:expr),*) => ($($(
553560
/// This operation satisfies `n % d == n - (n / d) * d`. The
554561
/// result has the same sign as the left operand.
562+
///
563+
/// # Panics
564+
///
565+
#[doc = $panic]
555566
#[stable(feature = "rust1", since = "1.0.0")]
556567
impl Rem for $t {
557568
type Output = $t;
@@ -561,10 +572,13 @@ macro_rules! rem_impl_integer {
561572
}
562573

563574
forward_ref_binop! { impl Rem, rem for $t, $t }
564-
)*)
575+
)*)*)
565576
}
566577

567-
rem_impl_integer! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
578+
rem_impl_integer! {
579+
(usize u8 u16 u32 u64 u128) => "This operation will panic if `other == 0`.",
580+
(isize i8 i16 i32 i64 i128) => "This operation will panic if `other == 0` or if `self / other` results in overflow."
581+
}
568582

569583
macro_rules! rem_impl_float {
570584
($($t:ty)*) => ($(

library/core/src/str/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ pub use iter::{EscapeDebug, EscapeDefault, EscapeUnicode};
6666
pub use iter::SplitAsciiWhitespace;
6767

6868
#[stable(feature = "split_inclusive", since = "1.51.0")]
69-
use iter::SplitInclusive;
69+
pub use iter::SplitInclusive;
7070

7171
#[unstable(feature = "str_internals", issue = "none")]
7272
pub use validations::next_code_point;

library/panic_abort/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
authors = ["The Rust Project Developers"]
33
name = "panic_abort"
44
version = "0.0.0"
5+
license = "MIT OR Apache-2.0"
6+
repository = "https://github.com/rust-lang/rust.git"
7+
description = "Implementation of Rust panics via process aborts"
58
edition = "2018"
69

710
[lib]

library/panic_unwind/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
authors = ["The Rust Project Developers"]
33
name = "panic_unwind"
44
version = "0.0.0"
5+
license = "MIT OR Apache-2.0"
6+
repository = "https://github.com/rust-lang/rust.git"
7+
description = "Implementation of Rust panics via stack unwinding"
58
edition = "2018"
69

710
[lib]

library/unwind/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
authors = ["The Rust Project Developers"]
33
name = "unwind"
44
version = "0.0.0"
5+
license = "MIT OR Apache-2.0"
6+
repository = "https://github.com/rust-lang/rust.git"
57
edition = "2018"
68
include = [
79
'/libunwind/*',

src/test/ui/asm/inline-syntax.arm.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error: att syntax is the default syntax on this target, and trying to use this directive may cause issues
2-
--> $DIR/inline-syntax.rs:22:15
2+
--> $DIR/inline-syntax.rs:23:15
33
|
44
LL | asm!(".att_syntax noprefix", "nop");
55
| ^^^^^^^^^^^^^^^^^^^^ help: remove this assembler directive
66

77
error: att syntax is the default syntax on this target, and trying to use this directive may cause issues
8-
--> $DIR/inline-syntax.rs:25:15
8+
--> $DIR/inline-syntax.rs:26:15
99
|
1010
LL | asm!(".att_syntax bbb noprefix", "nop");
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this assembler directive

src/test/ui/asm/inline-syntax.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// needs-llvm-components: arm
12
// revisions: x86_64 arm
23
//[x86_64] compile-flags: --target x86_64-unknown-linux-gnu
34
//[arm] compile-flags: --target armv7-unknown-linux-gnueabihf

src/test/ui/asm/inline-syntax.x86_64.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
error: intel syntax is the default syntax on this target, and trying to use this directive may cause issues
2-
--> $DIR/inline-syntax.rs:18:15
2+
--> $DIR/inline-syntax.rs:19:15
33
|
44
LL | asm!(".intel_syntax noprefix", "nop");
55
| ^^^^^^^^^^^^^^^^^^^^^^ help: remove this assembler directive
66

77
error: intel syntax is the default syntax on this target, and trying to use this directive may cause issues
8-
--> $DIR/inline-syntax.rs:20:15
8+
--> $DIR/inline-syntax.rs:21:15
99
|
1010
LL | asm!(".intel_syntax aaa noprefix", "nop");
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this assembler directive
1212

1313
error: using the .att_syntax directive may cause issues, use the att_syntax option instead
14-
--> $DIR/inline-syntax.rs:22:15
14+
--> $DIR/inline-syntax.rs:23:15
1515
|
1616
LL | asm!(".att_syntax noprefix", "nop");
1717
| ^^^^^^^^^^^^^^^^^^^^
@@ -22,7 +22,7 @@ LL | asm!("", "nop", options(att_syntax));
2222
| -- ^^^^^^^^^^^^^^^^^^^^^
2323

2424
error: using the .att_syntax directive may cause issues, use the att_syntax option instead
25-
--> $DIR/inline-syntax.rs:25:15
25+
--> $DIR/inline-syntax.rs:26:15
2626
|
2727
LL | asm!(".att_syntax bbb noprefix", "nop");
2828
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -33,13 +33,13 @@ LL | asm!("", "nop", options(att_syntax));
3333
| -- ^^^^^^^^^^^^^^^^^^^^^
3434

3535
error: intel syntax is the default syntax on this target, and trying to use this directive may cause issues
36-
--> $DIR/inline-syntax.rs:28:15
36+
--> $DIR/inline-syntax.rs:29:15
3737
|
3838
LL | asm!(".intel_syntax noprefix; nop");
3939
| ^^^^^^^^^^^^^^^^^^^^^^ help: remove this assembler directive
4040

4141
error: intel syntax is the default syntax on this target, and trying to use this directive may cause issues
42-
--> $DIR/inline-syntax.rs:33:14
42+
--> $DIR/inline-syntax.rs:34:14
4343
|
4444
LL | .intel_syntax noprefix
4545
| ______________^

0 commit comments

Comments
 (0)