Skip to content

Commit 908db6b

Browse files
author
The Miri Cronjob Bot
committed
Merge ref '3f1552a273e4' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: 3f1552a Filtered ref: fbfa7b30a3ad5abd6a5db7e3ef15adc8da1ecc37 Upstream diff: rust-lang/rust@9d82de1...3f1552a This merge was created using https://github.com/rust-lang/josh-sync.
2 parents a8198dc + ac6ee69 commit 908db6b

File tree

16 files changed

+152
-162
lines changed

16 files changed

+152
-162
lines changed

alloc/src/vec/peek_mut.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ impl<'a, T> PeekMut<'a, T> {
2929

3030
/// Removes the peeked value from the vector and returns it.
3131
#[unstable(feature = "vec_peek_mut", issue = "122742")]
32-
pub fn pop(self) -> T {
32+
pub fn pop(this: Self) -> T {
3333
// SAFETY: PeekMut is only constructed if the vec is non-empty
34-
unsafe { self.vec.pop().unwrap_unchecked() }
34+
unsafe { this.vec.pop().unwrap_unchecked() }
3535
}
3636
}
3737

alloctests/tests/vec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::ops::Bound::*;
1515
use std::panic::{AssertUnwindSafe, catch_unwind};
1616
use std::rc::Rc;
1717
use std::sync::atomic::{AtomicU32, Ordering};
18-
use std::vec::{Drain, IntoIter};
18+
use std::vec::{Drain, IntoIter, PeekMut};
1919

2020
use crate::testing::macros::struct_with_counted_drop;
2121

@@ -2647,7 +2647,7 @@ fn test_peek_mut() {
26472647
assert_eq!(*p, 2);
26482648
*p = 0;
26492649
assert_eq!(*p, 0);
2650-
p.pop();
2650+
PeekMut::pop(p);
26512651
assert_eq!(vec.len(), 1);
26522652
} else {
26532653
unreachable!()

core/src/array/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,11 @@ impl<T: Copy> SpecArrayClone for T {
472472
// The Default impls cannot be done with const generics because `[T; 0]` doesn't
473473
// require Default to be implemented, and having different impl blocks for
474474
// different numbers isn't supported yet.
475+
//
476+
// Trying to improve the `[T; 0]` situation has proven to be difficult.
477+
// Please see these issues for more context on past attempts and crater runs:
478+
// - https://github.com/rust-lang/rust/issues/61415
479+
// - https://github.com/rust-lang/rust/pull/145457
475480

476481
macro_rules! array_impl_default {
477482
{$n:expr, $t:ident $($ts:ident)*} => {

core/src/cmp.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,8 @@ pub macro PartialEq($item:item) {
334334
#[doc(alias = "!=")]
335335
#[stable(feature = "rust1", since = "1.0.0")]
336336
#[rustc_diagnostic_item = "Eq"]
337-
#[const_trait]
338337
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
339-
pub trait Eq: [const] PartialEq<Self> + PointeeSized {
338+
pub const trait Eq: [const] PartialEq<Self> + PointeeSized {
340339
// this method is used solely by `impl Eq or #[derive(Eq)]` to assert that every component of a
341340
// type implements `Eq` itself. The current deriving infrastructure means doing this assertion
342341
// without using a method on this trait is nearly impossible.
@@ -966,9 +965,8 @@ impl<T: Clone> Clone for Reverse<T> {
966965
#[doc(alias = ">=")]
967966
#[stable(feature = "rust1", since = "1.0.0")]
968967
#[rustc_diagnostic_item = "Ord"]
969-
#[const_trait]
970968
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
971-
pub trait Ord: [const] Eq + [const] PartialOrd<Self> + PointeeSized {
969+
pub const trait Ord: [const] Eq + [const] PartialOrd<Self> + PointeeSized {
972970
/// This method returns an [`Ordering`] between `self` and `other`.
973971
///
974972
/// By convention, `self.cmp(&other)` returns the ordering matching the expression
@@ -1352,9 +1350,8 @@ pub macro Ord($item:item) {
13521350
)]
13531351
#[rustc_diagnostic_item = "PartialOrd"]
13541352
#[allow(multiple_supertrait_upcastable)] // FIXME(sized_hierarchy): remove this
1355-
#[const_trait]
13561353
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
1357-
pub trait PartialOrd<Rhs: PointeeSized = Self>: PartialEq<Rhs> + PointeeSized {
1354+
pub const trait PartialOrd<Rhs: PointeeSized = Self>: PartialEq<Rhs> + PointeeSized {
13581355
/// This method returns an ordering between `self` and `other` values if one exists.
13591356
///
13601357
/// # Examples

core/src/marker.rs

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,7 @@ pub trait Tuple {}
10831083
// We name this differently than the derive macro so that the `adt_const_params` can
10841084
// be used independently of `unsized_const_params` without requiring a full path
10851085
// to the derive macro every time it is used. This should be renamed on stabilization.
1086-
pub trait ConstParamTy_: UnsizedConstParamTy + StructuralPartialEq + Eq {}
1086+
pub trait ConstParamTy_: StructuralPartialEq + Eq {}
10871087

10881088
/// Derive macro generating an impl of the trait `ConstParamTy`.
10891089
#[rustc_builtin_macro]
@@ -1093,23 +1093,6 @@ pub macro ConstParamTy($item:item) {
10931093
/* compiler built-in */
10941094
}
10951095

1096-
#[lang = "unsized_const_param_ty"]
1097-
#[unstable(feature = "unsized_const_params", issue = "95174")]
1098-
#[diagnostic::on_unimplemented(message = "`{Self}` can't be used as a const parameter type")]
1099-
/// A marker for types which can be used as types of `const` generic parameters.
1100-
///
1101-
/// Equivalent to [`ConstParamTy_`] except that this is used by
1102-
/// the `unsized_const_params` to allow for fake unstable impls.
1103-
pub trait UnsizedConstParamTy: StructuralPartialEq + Eq {}
1104-
1105-
/// Derive macro generating an impl of the trait `ConstParamTy`.
1106-
#[rustc_builtin_macro]
1107-
#[allow_internal_unstable(unsized_const_params)]
1108-
#[unstable(feature = "unsized_const_params", issue = "95174")]
1109-
pub macro UnsizedConstParamTy($item:item) {
1110-
/* compiler built-in */
1111-
}
1112-
11131096
// FIXME(adt_const_params): handle `ty::FnDef`/`ty::Closure`
11141097
marker_impls! {
11151098
#[unstable(feature = "adt_const_params", issue = "95174")]
@@ -1124,17 +1107,11 @@ marker_impls! {
11241107

11251108
marker_impls! {
11261109
#[unstable(feature = "unsized_const_params", issue = "95174")]
1127-
UnsizedConstParamTy for
1128-
usize, u8, u16, u32, u64, u128,
1129-
isize, i8, i16, i32, i64, i128,
1130-
bool,
1131-
char,
1132-
(),
1133-
{T: UnsizedConstParamTy, const N: usize} [T; N],
1134-
1110+
#[unstable_feature_bound(unsized_const_params)]
1111+
ConstParamTy_ for
11351112
str,
1136-
{T: UnsizedConstParamTy} [T],
1137-
{T: UnsizedConstParamTy + ?Sized} &T,
1113+
{T: ConstParamTy_} [T],
1114+
{T: ConstParamTy_ + ?Sized} &T,
11381115
}
11391116

11401117
/// A common trait implemented by all function pointers.

core/src/mem/transmutability.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::marker::{ConstParamTy_, UnsizedConstParamTy};
1+
use crate::marker::ConstParamTy_;
22

33
/// Marks that `Src` is transmutable into `Self`.
44
///
@@ -83,6 +83,7 @@ use crate::marker::{ConstParamTy_, UnsizedConstParamTy};
8383
/// Furthermore, stability does not imply portability. For example, the size of
8484
/// `usize` is stable, but not portable.
8585
#[unstable(feature = "transmutability", issue = "99571")]
86+
#[unstable_feature_bound(transmutability)]
8687
#[lang = "transmute_trait"]
8788
#[rustc_deny_explicit_impl]
8889
#[rustc_do_not_implement_via_object]
@@ -288,9 +289,8 @@ pub struct Assume {
288289
}
289290

290291
#[unstable(feature = "transmutability", issue = "99571")]
292+
#[unstable_feature_bound(transmutability)]
291293
impl ConstParamTy_ for Assume {}
292-
#[unstable(feature = "transmutability", issue = "99571")]
293-
impl UnsizedConstParamTy for Assume {}
294294

295295
impl Assume {
296296
/// With this, [`TransmuteFrom`] does not assume you have ensured any safety

core/src/num/bignum.rs

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -335,43 +335,6 @@ macro_rules! define_bignum {
335335
}
336336
(self, borrow)
337337
}
338-
339-
/// Divide self by another bignum, overwriting `q` with the quotient and `r` with the
340-
/// remainder.
341-
pub fn div_rem(&self, d: &$name, q: &mut $name, r: &mut $name) {
342-
// Stupid slow base-2 long division taken from
343-
// https://en.wikipedia.org/wiki/Division_algorithm
344-
// FIXME use a greater base ($ty) for the long division.
345-
assert!(!d.is_zero());
346-
let digitbits = <$ty>::BITS as usize;
347-
for digit in &mut q.base[..] {
348-
*digit = 0;
349-
}
350-
for digit in &mut r.base[..] {
351-
*digit = 0;
352-
}
353-
r.size = d.size;
354-
q.size = 1;
355-
let mut q_is_zero = true;
356-
let end = self.bit_length();
357-
for i in (0..end).rev() {
358-
r.mul_pow2(1);
359-
r.base[0] |= self.get_bit(i) as $ty;
360-
if &*r >= d {
361-
r.sub(d);
362-
// Set bit `i` of q to 1.
363-
let digit_idx = i / digitbits;
364-
let bit_idx = i % digitbits;
365-
if q_is_zero {
366-
q.size = digit_idx + 1;
367-
q_is_zero = false;
368-
}
369-
q.base[digit_idx] |= 1 << bit_idx;
370-
}
371-
}
372-
debug_assert!(q.base[q.size..].iter().all(|&d| d == 0));
373-
debug_assert!(r.base[r.size..].iter().all(|&d| d == 0));
374-
}
375338
}
376339

377340
impl crate::cmp::PartialEq for $name {

core/src/tuple.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// See core/src/primitive_docs.rs for documentation.
22

33
use crate::cmp::Ordering::{self, *};
4-
use crate::marker::{ConstParamTy_, StructuralPartialEq, UnsizedConstParamTy};
4+
use crate::marker::{ConstParamTy_, StructuralPartialEq};
55
use crate::ops::ControlFlow::{self, Break, Continue};
66

77
// Recursive macro for implementing n-ary tuple functions and operations
@@ -47,17 +47,11 @@ macro_rules! tuple_impls {
4747
maybe_tuple_doc! {
4848
$($T)+ @
4949
#[unstable(feature = "adt_const_params", issue = "95174")]
50+
#[unstable_feature_bound(unsized_const_params)]
5051
impl<$($T: ConstParamTy_),+> ConstParamTy_ for ($($T,)+)
5152
{}
5253
}
5354

54-
maybe_tuple_doc! {
55-
$($T)+ @
56-
#[unstable(feature = "unsized_const_params", issue = "95174")]
57-
impl<$($T: UnsizedConstParamTy),+> UnsizedConstParamTy for ($($T,)+)
58-
{}
59-
}
60-
6155
maybe_tuple_doc! {
6256
$($T)+ @
6357
#[unstable(feature = "structural_match", issue = "31434")]

coretests/tests/ascii.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,3 +505,10 @@ fn test_escape_ascii_iter() {
505505
let _ = it.advance_back_by(4);
506506
assert_eq!(it.to_string(), r#"fastpath\xffremainder"#);
507507
}
508+
509+
#[test]
510+
fn test_invalid_u8() {
511+
for c in 128..=255 {
512+
assert_eq!(core::ascii::Char::from_u8(c), None);
513+
}
514+
}

coretests/tests/fmt/builders.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,21 @@ mod debug_struct {
173173
format!("{Bar:#?}")
174174
);
175175
}
176+
177+
#[test]
178+
fn test_field_with() {
179+
struct Foo;
180+
impl fmt::Debug for Foo {
181+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
182+
fmt.debug_struct("Foo")
183+
.field_with("bar", |f| f.write_str("true"))
184+
.field_with("baz", |f| f.write_str("false"))
185+
.finish()
186+
}
187+
}
188+
189+
assert_eq!("Foo {\n bar: true,\n baz: false,\n}", format!("{Foo:#?}"))
190+
}
176191
}
177192

178193
mod debug_tuple {

0 commit comments

Comments
 (0)