Skip to content

Commit d19a359

Browse files
committed
Auto merge of #63428 - Centril:rollup-c2ru1z1, r=Centril
Rollup of 7 pull requests Successful merges: - #63056 (Give built-in macros stable addresses in the standard library) - #63337 (Tweak mismatched types error) - #63350 (Use associated_type_bounds where applicable - closes #61738) - #63394 (Add test for issue 36804) - #63399 (More explicit diagnostic when using a `vec![]` in a pattern) - #63419 (check against more collisions for TypeId of fn pointer) - #63423 (Mention that tuple structs are private if any of their fields are) Failed merges: r? @ghost
2 parents be8bbb0 + 019f6fe commit d19a359

File tree

92 files changed

+1507
-412
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+1507
-412
lines changed

src/liballoc/borrow.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,8 @@ impl<'a, B: ?Sized> PartialOrd for Cow<'a, B>
329329

330330
#[stable(feature = "rust1", since = "1.0.0")]
331331
impl<B: ?Sized> fmt::Debug for Cow<'_, B>
332-
where B: fmt::Debug + ToOwned,
333-
<B as ToOwned>::Owned: fmt::Debug
332+
where
333+
B: fmt::Debug + ToOwned<Owned: fmt::Debug>,
334334
{
335335
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
336336
match *self {
@@ -342,8 +342,8 @@ impl<B: ?Sized> fmt::Debug for Cow<'_, B>
342342

343343
#[stable(feature = "rust1", since = "1.0.0")]
344344
impl<B: ?Sized> fmt::Display for Cow<'_, B>
345-
where B: fmt::Display + ToOwned,
346-
<B as ToOwned>::Owned: fmt::Display
345+
where
346+
B: fmt::Display + ToOwned<Owned: fmt::Display>,
347347
{
348348
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
349349
match *self {
@@ -355,8 +355,8 @@ impl<B: ?Sized> fmt::Display for Cow<'_, B>
355355

356356
#[stable(feature = "default", since = "1.11.0")]
357357
impl<B: ?Sized> Default for Cow<'_, B>
358-
where B: ToOwned,
359-
<B as ToOwned>::Owned: Default
358+
where
359+
B: ToOwned<Owned: Default>,
360360
{
361361
/// Creates an owned Cow<'a, B> with the default value for the contained owned value.
362362
fn default() -> Self {

src/liballoc/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
#![feature(alloc_layout_extra)]
123123
#![feature(try_trait)]
124124
#![feature(mem_take)]
125+
#![feature(associated_type_bounds)]
125126

126127
// Allow testing this library
127128

src/liballoc/tests/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#![feature(trusted_len)]
99
#![feature(try_reserve)]
1010
#![feature(unboxed_closures)]
11+
#![feature(associated_type_bounds)]
1112

1213
use std::hash::{Hash, Hasher};
1314
use std::collections::hash_map::DefaultHasher;

src/liballoc/tests/str.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,10 +1638,12 @@ mod pattern {
16381638
}
16391639
}
16401640

1641-
fn cmp_search_to_vec<'a, P: Pattern<'a>>(rev: bool, pat: P, haystack: &'a str,
1642-
right: Vec<SearchStep>)
1643-
where P::Searcher: ReverseSearcher<'a>
1644-
{
1641+
fn cmp_search_to_vec<'a>(
1642+
rev: bool,
1643+
pat: impl Pattern<'a, Searcher: ReverseSearcher<'a>>,
1644+
haystack: &'a str,
1645+
right: Vec<SearchStep>
1646+
) {
16451647
let mut searcher = pat.into_searcher(haystack);
16461648
let mut v = vec![];
16471649
loop {

src/libcore/clone.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ pub trait Clone : Sized {
133133
}
134134
}
135135

136+
/// Derive macro generating an impl of the trait `Clone`.
137+
#[cfg(not(bootstrap))]
138+
#[rustc_builtin_macro]
139+
#[rustc_macro_transparency = "semitransparent"]
140+
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
141+
#[allow_internal_unstable(core_intrinsics, derive_clone_copy)]
142+
pub macro Clone($item:item) { /* compiler built-in */ }
143+
136144
// FIXME(aburka): these structs are used solely by #[derive] to
137145
// assert that every component of a type implements Clone or Copy.
138146
//

src/libcore/cmp.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,14 @@ pub trait PartialEq<Rhs: ?Sized = Self> {
200200
fn ne(&self, other: &Rhs) -> bool { !self.eq(other) }
201201
}
202202

203+
/// Derive macro generating an impl of the trait `PartialEq`.
204+
#[cfg(not(bootstrap))]
205+
#[rustc_builtin_macro]
206+
#[rustc_macro_transparency = "semitransparent"]
207+
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
208+
#[allow_internal_unstable(core_intrinsics)]
209+
pub macro PartialEq($item:item) { /* compiler built-in */ }
210+
203211
/// Trait for equality comparisons which are [equivalence relations](
204212
/// https://en.wikipedia.org/wiki/Equivalence_relation).
205213
///
@@ -256,6 +264,14 @@ pub trait Eq: PartialEq<Self> {
256264
fn assert_receiver_is_total_eq(&self) {}
257265
}
258266

267+
/// Derive macro generating an impl of the trait `Eq`.
268+
#[cfg(not(bootstrap))]
269+
#[rustc_builtin_macro]
270+
#[rustc_macro_transparency = "semitransparent"]
271+
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
272+
#[allow_internal_unstable(core_intrinsics, derive_eq)]
273+
pub macro Eq($item:item) { /* compiler built-in */ }
274+
259275
// FIXME: this struct is used solely by #[derive] to
260276
// assert that every component of a type implements Eq.
261277
//
@@ -600,6 +616,14 @@ pub trait Ord: Eq + PartialOrd<Self> {
600616
}
601617
}
602618

619+
/// Derive macro generating an impl of the trait `Ord`.
620+
#[cfg(not(bootstrap))]
621+
#[rustc_builtin_macro]
622+
#[rustc_macro_transparency = "semitransparent"]
623+
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
624+
#[allow_internal_unstable(core_intrinsics)]
625+
pub macro Ord($item:item) { /* compiler built-in */ }
626+
603627
#[stable(feature = "rust1", since = "1.0.0")]
604628
impl Eq for Ordering {}
605629

@@ -842,6 +866,14 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
842866
}
843867
}
844868

869+
/// Derive macro generating an impl of the trait `PartialOrd`.
870+
#[cfg(not(bootstrap))]
871+
#[rustc_builtin_macro]
872+
#[rustc_macro_transparency = "semitransparent"]
873+
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
874+
#[allow_internal_unstable(core_intrinsics)]
875+
pub macro PartialOrd($item:item) { /* compiler built-in */ }
876+
845877
/// Compares and returns the minimum of two values.
846878
///
847879
/// Returns the first argument if the comparison determines them to be equal.

src/libcore/convert.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ impl<T: ?Sized, U: ?Sized> AsRef<U> for &mut T where T: AsRef<U>
513513

514514
// FIXME (#45742): replace the above impls for &/&mut with the following more general one:
515515
// // As lifts over Deref
516-
// impl<D: ?Sized + Deref, U: ?Sized> AsRef<U> for D where D::Target: AsRef<U> {
516+
// impl<D: ?Sized + Deref<Target: AsRef<U>>, U: ?Sized> AsRef<U> for D {
517517
// fn as_ref(&self) -> &U {
518518
// self.deref().as_ref()
519519
// }
@@ -530,7 +530,7 @@ impl<T: ?Sized, U: ?Sized> AsMut<U> for &mut T where T: AsMut<U>
530530

531531
// FIXME (#45742): replace the above impl for &mut with the following more general one:
532532
// // AsMut lifts over DerefMut
533-
// impl<D: ?Sized + Deref, U: ?Sized> AsMut<U> for D where D::Target: AsMut<U> {
533+
// impl<D: ?Sized + Deref<Target: AsMut<U>>, U: ?Sized> AsMut<U> for D {
534534
// fn as_mut(&mut self) -> &mut U {
535535
// self.deref_mut().as_mut()
536536
// }

src/libcore/default.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ pub trait Default: Sized {
115115
fn default() -> Self;
116116
}
117117

118+
/// Derive macro generating an impl of the trait `Default`.
119+
#[cfg(not(bootstrap))]
120+
#[rustc_builtin_macro]
121+
#[rustc_macro_transparency = "semitransparent"]
122+
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
123+
#[allow_internal_unstable(core_intrinsics)]
124+
pub macro Default($item:item) { /* compiler built-in */ }
125+
118126
macro_rules! default_impl {
119127
($t:ty, $v:expr, $doc:tt) => {
120128
#[stable(feature = "rust1", since = "1.0.0")]

src/libcore/fmt/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,21 @@ pub trait Debug {
545545
fn fmt(&self, f: &mut Formatter<'_>) -> Result;
546546
}
547547

548+
// Separate module to reexport the macro `Debug` from prelude without the trait `Debug`.
549+
#[cfg(not(bootstrap))]
550+
pub(crate) mod macros {
551+
/// Derive macro generating an impl of the trait `Debug`.
552+
#[rustc_builtin_macro]
553+
#[rustc_macro_transparency = "semitransparent"]
554+
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
555+
#[allow_internal_unstable(core_intrinsics)]
556+
pub macro Debug($item:item) { /* compiler built-in */ }
557+
}
558+
#[cfg(not(bootstrap))]
559+
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
560+
#[doc(inline)]
561+
pub use macros::Debug;
562+
548563
/// Format trait for an empty format, `{}`.
549564
///
550565
/// `Display` is similar to [`Debug`][debug], but `Display` is for user-facing

src/libcore/future/future.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ impl<F: ?Sized + Future + Unpin> Future for &mut F {
111111
#[stable(feature = "futures_api", since = "1.36.0")]
112112
impl<P> Future for Pin<P>
113113
where
114-
P: Unpin + ops::DerefMut,
115-
P::Target: Future,
114+
P: Unpin + ops::DerefMut<Target: Future>,
116115
{
117116
type Output = <<P as ops::Deref>::Target as Future>::Output;
118117

0 commit comments

Comments
 (0)