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

Diff for: src/liballoc/borrow.rs

+6-6
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 {

Diff for: src/liballoc/lib.rs

+1
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

Diff for: src/liballoc/tests/lib.rs

+1
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;

Diff for: src/liballoc/tests/str.rs

+6-4
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 {

Diff for: src/libcore/clone.rs

+8
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
//

Diff for: src/libcore/cmp.rs

+32
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.

Diff for: src/libcore/convert.rs

+2-2
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
// }

Diff for: src/libcore/default.rs

+8
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")]

Diff for: src/libcore/fmt/mod.rs

+15
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

Diff for: src/libcore/future/future.rs

+1-2
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

Diff for: src/libcore/hash/mod.rs

+15
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,21 @@ pub trait Hash {
198198
}
199199
}
200200

201+
// Separate module to reexport the macro `Hash` from prelude without the trait `Hash`.
202+
#[cfg(not(bootstrap))]
203+
pub(crate) mod macros {
204+
/// Derive macro generating an impl of the trait `Hash`.
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 Hash($item:item) { /* compiler built-in */ }
210+
}
211+
#[cfg(not(bootstrap))]
212+
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
213+
#[doc(inline)]
214+
pub use macros::Hash;
215+
201216
/// A trait for hashing an arbitrary stream of bytes.
202217
///
203218
/// Instances of `Hasher` usually represent state that is changed while hashing

Diff for: src/libcore/iter/adapters/flatten.rs

+37-24
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,17 @@ impl<I: Iterator, U: IntoIterator, F: FnMut(I::Item) -> U> FlatMap<I, U, F> {
2424
}
2525

2626
#[stable(feature = "rust1", since = "1.0.0")]
27-
impl<I: Clone, U: Clone + IntoIterator, F: Clone> Clone for FlatMap<I, U, F>
28-
where <U as IntoIterator>::IntoIter: Clone
27+
impl<I: Clone, U, F: Clone> Clone for FlatMap<I, U, F>
28+
where
29+
U: Clone + IntoIterator<IntoIter: Clone>,
2930
{
3031
fn clone(&self) -> Self { FlatMap { inner: self.inner.clone() } }
3132
}
3233

3334
#[stable(feature = "core_impl_debug", since = "1.9.0")]
34-
impl<I: fmt::Debug, U: IntoIterator, F> fmt::Debug for FlatMap<I, U, F>
35-
where U::IntoIter: fmt::Debug
35+
impl<I: fmt::Debug, U, F> fmt::Debug for FlatMap<I, U, F>
36+
where
37+
U: IntoIterator<IntoIter: fmt::Debug>,
3638
{
3739
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3840
f.debug_struct("FlatMap").field("inner", &self.inner).finish()
@@ -68,9 +70,10 @@ impl<I: Iterator, U: IntoIterator, F> Iterator for FlatMap<I, U, F>
6870

6971
#[stable(feature = "rust1", since = "1.0.0")]
7072
impl<I: DoubleEndedIterator, U, F> DoubleEndedIterator for FlatMap<I, U, F>
71-
where F: FnMut(I::Item) -> U,
72-
U: IntoIterator,
73-
U::IntoIter: DoubleEndedIterator
73+
where
74+
F: FnMut(I::Item) -> U,
75+
U: IntoIterator,
76+
U::IntoIter: DoubleEndedIterator,
7477
{
7578
#[inline]
7679
fn next_back(&mut self) -> Option<U::Item> { self.inner.next_back() }
@@ -105,20 +108,23 @@ impl<I, U, F> FusedIterator for FlatMap<I, U, F>
105108
#[must_use = "iterators are lazy and do nothing unless consumed"]
106109
#[stable(feature = "iterator_flatten", since = "1.29.0")]
107110
pub struct Flatten<I: Iterator>
108-
where I::Item: IntoIterator {
111+
where
112+
I::Item: IntoIterator,
113+
{
109114
inner: FlattenCompat<I, <I::Item as IntoIterator>::IntoIter>,
110115
}
111-
impl<I: Iterator> Flatten<I>
112-
where I::Item: IntoIterator {
116+
117+
impl<I: Iterator<Item: IntoIterator>> Flatten<I> {
113118
pub(in super::super) fn new(iter: I) -> Flatten<I> {
114119
Flatten { inner: FlattenCompat::new(iter) }
115120
}
116121
}
117122

118123
#[stable(feature = "iterator_flatten", since = "1.29.0")]
119124
impl<I, U> fmt::Debug for Flatten<I>
120-
where I: Iterator + fmt::Debug, U: Iterator + fmt::Debug,
121-
I::Item: IntoIterator<IntoIter = U, Item = U::Item>,
125+
where
126+
I: fmt::Debug + Iterator<Item: IntoIterator<IntoIter = U, Item = U::Item>>,
127+
U: fmt::Debug + Iterator,
122128
{
123129
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
124130
f.debug_struct("Flatten").field("inner", &self.inner).finish()
@@ -127,16 +133,18 @@ impl<I, U> fmt::Debug for Flatten<I>
127133

128134
#[stable(feature = "iterator_flatten", since = "1.29.0")]
129135
impl<I, U> Clone for Flatten<I>
130-
where I: Iterator + Clone, U: Iterator + Clone,
131-
I::Item: IntoIterator<IntoIter = U, Item = U::Item>,
136+
where
137+
I: Clone + Iterator<Item: IntoIterator<IntoIter = U, Item = U::Item>>,
138+
U: Clone + Iterator,
132139
{
133140
fn clone(&self) -> Self { Flatten { inner: self.inner.clone() } }
134141
}
135142

136143
#[stable(feature = "iterator_flatten", since = "1.29.0")]
137144
impl<I, U> Iterator for Flatten<I>
138-
where I: Iterator, U: Iterator,
139-
I::Item: IntoIterator<IntoIter = U, Item = U::Item>
145+
where
146+
I: Iterator<Item: IntoIterator<IntoIter = U, Item = U::Item>>,
147+
U: Iterator,
140148
{
141149
type Item = U::Item;
142150

@@ -163,8 +171,9 @@ impl<I, U> Iterator for Flatten<I>
163171

164172
#[stable(feature = "iterator_flatten", since = "1.29.0")]
165173
impl<I, U> DoubleEndedIterator for Flatten<I>
166-
where I: DoubleEndedIterator, U: DoubleEndedIterator,
167-
I::Item: IntoIterator<IntoIter = U, Item = U::Item>
174+
where
175+
I: DoubleEndedIterator<Item: IntoIterator<IntoIter = U, Item = U::Item>>,
176+
U: DoubleEndedIterator,
168177
{
169178
#[inline]
170179
fn next_back(&mut self) -> Option<U::Item> { self.inner.next_back() }
@@ -186,8 +195,10 @@ impl<I, U> DoubleEndedIterator for Flatten<I>
186195

187196
#[stable(feature = "iterator_flatten", since = "1.29.0")]
188197
impl<I, U> FusedIterator for Flatten<I>
189-
where I: FusedIterator, U: Iterator,
190-
I::Item: IntoIterator<IntoIter = U, Item = U::Item> {}
198+
where
199+
I: FusedIterator<Item: IntoIterator<IntoIter = U, Item = U::Item>>,
200+
U: Iterator,
201+
{}
191202

192203
/// Real logic of both `Flatten` and `FlatMap` which simply delegate to
193204
/// this type.
@@ -205,8 +216,9 @@ impl<I, U> FlattenCompat<I, U> {
205216
}
206217

207218
impl<I, U> Iterator for FlattenCompat<I, U>
208-
where I: Iterator, U: Iterator,
209-
I::Item: IntoIterator<IntoIter = U, Item = U::Item>
219+
where
220+
I: Iterator<Item: IntoIterator<IntoIter = U, Item = U::Item>>,
221+
U: Iterator,
210222
{
211223
type Item = U::Item;
212224

@@ -274,8 +286,9 @@ impl<I, U> Iterator for FlattenCompat<I, U>
274286
}
275287

276288
impl<I, U> DoubleEndedIterator for FlattenCompat<I, U>
277-
where I: DoubleEndedIterator, U: DoubleEndedIterator,
278-
I::Item: IntoIterator<IntoIter = U, Item = U::Item>
289+
where
290+
I: DoubleEndedIterator<Item: IntoIterator<IntoIter = U, Item = U::Item>>,
291+
U: DoubleEndedIterator,
279292
{
280293
#[inline]
281294
fn next_back(&mut self) -> Option<U::Item> {

Diff for: src/libcore/iter/traits/collect.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,9 @@ pub trait FromIterator<A>: Sized {
195195
///
196196
/// ```rust
197197
/// fn collect_as_strings<T>(collection: T) -> Vec<String>
198-
/// where T: IntoIterator,
199-
/// T::Item: std::fmt::Debug,
198+
/// where
199+
/// T: IntoIterator,
200+
/// T::Item: std::fmt::Debug,
200201
/// {
201202
/// collection
202203
/// .into_iter()

Diff for: src/libcore/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@
132132
#![feature(maybe_uninit_slice, maybe_uninit_array)]
133133
#![feature(external_doc)]
134134
#![feature(mem_take)]
135+
#![feature(associated_type_bounds)]
135136

136137
#[prelude_import]
137138
#[allow(unused)]

0 commit comments

Comments
 (0)