Skip to content

Commit 2c35179

Browse files
committed
Auto merge of #143627 - matthiaskrgr:rollup-3elo6xo, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #134628 (Make `Default` const and add some `const Default` impls) - #143555 (Don't mark `#[target_feature]` safe fns as unsafe in rustdoc JSON.) - #143600 (Update intro blurb in `wasm32-wasip1` docs) - #143603 (Clarify the meaning of `AttributeOrder::KeepFirst` and `AttributeOrder::KeepLast`) - #143620 (fix: Remove newline from multiple crate versions note) - #143622 (Add target maintainer information for mips64-unknown-linux-muslabi64) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 45b80ac + 612e0a3 commit 2c35179

36 files changed

+319
-189
lines changed

compiler/rustc_attr_parsing/src/attributes/mod.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,14 @@ impl<S: Stage> OnDuplicate<S> {
217217
// them will be merged in another PR
218218
#[allow(unused)]
219219
pub(crate) enum AttributeOrder {
220-
/// Duplicates after the first attribute will be an error.
220+
/// Duplicates after the first attribute will be an error. I.e. only keep the lowest attribute.
221+
///
222+
/// Attributes are processed from bottom to top, so this raises an error on all the attributes
223+
/// further above the lowest one:
224+
/// ```
225+
/// #[stable(since="1.0")] //~ WARNING duplicated attribute
226+
/// #[stable(since="2.0")]
227+
/// ```
221228
///
222229
/// This should be used where duplicates would be ignored, but carry extra
223230
/// meaning that could cause confusion. For example, `#[stable(since="1.0")]
@@ -227,6 +234,13 @@ pub(crate) enum AttributeOrder {
227234
/// Duplicates preceding the last instance of the attribute will be a
228235
/// warning, with a note that this will be an error in the future.
229236
///
237+
/// Attributes are processed from bottom to top, so this raises a warning on all the attributes
238+
/// below the higher one:
239+
/// ```
240+
/// #[path="foo.rs"]
241+
/// #[path="bar.rs"] //~ WARNING duplicated attribute
242+
/// ```
243+
///
230244
/// This is the same as `FutureWarnFollowing`, except the last attribute is
231245
/// the one that is "used". Ideally these can eventually migrate to
232246
/// `ErrorPreceding`.

compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1933,7 +1933,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
19331933
StringPart::highlighted("multiple different versions".to_string()),
19341934
StringPart::normal(" of crate `".to_string()),
19351935
StringPart::highlighted(format!("{crate_name}")),
1936-
StringPart::normal("` in the dependency graph\n".to_string()),
1936+
StringPart::normal("` in the dependency graph".to_string()),
19371937
],
19381938
);
19391939
if points_at_type {

library/alloc/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,10 @@
107107
#![feature(char_max_len)]
108108
#![feature(clone_to_uninit)]
109109
#![feature(coerce_unsized)]
110+
#![feature(const_default)]
110111
#![feature(const_eval_select)]
111112
#![feature(const_heap)]
113+
#![feature(const_trait_impl)]
112114
#![feature(core_intrinsics)]
113115
#![feature(deprecated_suggestion)]
114116
#![feature(deref_pure_trait)]

library/alloc/src/string.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2611,7 +2611,8 @@ impl_eq! { Cow<'a, str>, &'b str }
26112611
impl_eq! { Cow<'a, str>, String }
26122612

26132613
#[stable(feature = "rust1", since = "1.0.0")]
2614-
impl Default for String {
2614+
#[rustc_const_unstable(feature = "const_default", issue = "67792")]
2615+
impl const Default for String {
26152616
/// Creates an empty `String`.
26162617
#[inline]
26172618
fn default() -> String {

library/alloc/src/vec/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3895,7 +3895,8 @@ unsafe impl<#[may_dangle] T, A: Allocator> Drop for Vec<T, A> {
38953895
}
38963896

38973897
#[stable(feature = "rust1", since = "1.0.0")]
3898-
impl<T> Default for Vec<T> {
3898+
#[rustc_const_unstable(feature = "const_default", issue = "67792")]
3899+
impl<T> const Default for Vec<T> {
38993900
/// Creates an empty `Vec<T>`.
39003901
///
39013902
/// The vector will not allocate until elements are pushed onto it.

library/core/src/cell.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,8 @@ impl<T: Copy> Clone for Cell<T> {
333333
}
334334

335335
#[stable(feature = "rust1", since = "1.0.0")]
336-
impl<T: Default> Default for Cell<T> {
336+
#[rustc_const_unstable(feature = "const_default", issue = "67792")]
337+
impl<T: ~const Default> const Default for Cell<T> {
337338
/// Creates a `Cell<T>`, with the `Default` value for T.
338339
#[inline]
339340
fn default() -> Cell<T> {
@@ -1323,7 +1324,8 @@ impl<T: Clone> Clone for RefCell<T> {
13231324
}
13241325

13251326
#[stable(feature = "rust1", since = "1.0.0")]
1326-
impl<T: Default> Default for RefCell<T> {
1327+
#[rustc_const_unstable(feature = "const_default", issue = "67792")]
1328+
impl<T: ~const Default> const Default for RefCell<T> {
13271329
/// Creates a `RefCell<T>`, with the `Default` value for T.
13281330
#[inline]
13291331
fn default() -> RefCell<T> {
@@ -2330,7 +2332,8 @@ impl<T: ?Sized> UnsafeCell<T> {
23302332
}
23312333

23322334
#[stable(feature = "unsafe_cell_default", since = "1.10.0")]
2333-
impl<T: Default> Default for UnsafeCell<T> {
2335+
#[rustc_const_unstable(feature = "const_default", issue = "67792")]
2336+
impl<T: ~const Default> const Default for UnsafeCell<T> {
23342337
/// Creates an `UnsafeCell`, with the `Default` value for T.
23352338
fn default() -> UnsafeCell<T> {
23362339
UnsafeCell::new(Default::default())
@@ -2434,7 +2437,8 @@ impl<T: ?Sized> SyncUnsafeCell<T> {
24342437
}
24352438

24362439
#[unstable(feature = "sync_unsafe_cell", issue = "95439")]
2437-
impl<T: Default> Default for SyncUnsafeCell<T> {
2440+
#[rustc_const_unstable(feature = "const_default", issue = "67792")]
2441+
impl<T: ~const Default> const Default for SyncUnsafeCell<T> {
24382442
/// Creates an `SyncUnsafeCell`, with the `Default` value for T.
24392443
fn default() -> SyncUnsafeCell<T> {
24402444
SyncUnsafeCell::new(Default::default())

library/core/src/default.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ use crate::ascii::Char as AsciiChar;
103103
/// ```
104104
#[rustc_diagnostic_item = "Default"]
105105
#[stable(feature = "rust1", since = "1.0.0")]
106+
#[const_trait]
107+
#[rustc_const_unstable(feature = "const_default", issue = "67792")]
106108
pub trait Default: Sized {
107109
/// Returns the "default value" for a type.
108110
///
@@ -149,7 +151,8 @@ pub macro Default($item:item) {
149151
macro_rules! default_impl {
150152
($t:ty, $v:expr, $doc:tt) => {
151153
#[stable(feature = "rust1", since = "1.0.0")]
152-
impl Default for $t {
154+
#[rustc_const_unstable(feature = "const_default", issue = "67792")]
155+
impl const Default for $t {
153156
#[inline(always)]
154157
#[doc = $doc]
155158
fn default() -> $t {

library/core/src/iter/sources/empty.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ impl<T> Clone for Empty<T> {
8181
// not #[derive] because that adds a Default bound on T,
8282
// which isn't necessary.
8383
#[stable(feature = "iter_empty", since = "1.2.0")]
84-
impl<T> Default for Empty<T> {
84+
#[rustc_const_unstable(feature = "const_default", issue = "67792")]
85+
impl<T> const Default for Empty<T> {
8586
fn default() -> Empty<T> {
8687
Empty(marker::PhantomData)
8788
}

library/core/src/marker.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,8 @@ impl<T: PointeeSized> Clone for PhantomData<T> {
858858
}
859859

860860
#[stable(feature = "rust1", since = "1.0.0")]
861-
impl<T: PointeeSized> Default for PhantomData<T> {
861+
#[rustc_const_unstable(feature = "const_default", issue = "67792")]
862+
impl<T: PointeeSized> const Default for PhantomData<T> {
862863
fn default() -> Self {
863864
Self
864865
}

library/core/src/option.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2111,7 +2111,8 @@ where
21112111
impl<T> crate::clone::UseCloned for Option<T> where T: crate::clone::UseCloned {}
21122112

21132113
#[stable(feature = "rust1", since = "1.0.0")]
2114-
impl<T> Default for Option<T> {
2114+
#[rustc_const_unstable(feature = "const_default", issue = "67792")]
2115+
impl<T> const Default for Option<T> {
21152116
/// Returns [`None`][Option::None].
21162117
///
21172118
/// # Examples

0 commit comments

Comments
 (0)