Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit fb0b123

Browse files
committed
Auto merge of rust-lang#74929 - Manishearth:rollup-z2vflrp, r=Manishearth
Rollup of 10 pull requests Successful merges: - rust-lang#74742 (Remove links to rejected errata 4406 for RFC 4291) - rust-lang#74819 (Point towards `format_spec`; it is in other direction) - rust-lang#74852 (Explain why inlining default ToString impl) - rust-lang#74869 (Make closures and generators a must use types) - rust-lang#74873 (symbol mangling: use ty::print::Print for consts) - rust-lang#74902 (Remove deprecated unstable `{Box,Rc,Arc}::into_raw_non_null` functions) - rust-lang#74904 (Fix some typos in src/librustdoc/clean/auto_trait.rs) - rust-lang#74910 (fence docs: fix example Mutex) - rust-lang#74912 (Fix broken link in unstable book `plugin`) - rust-lang#74927 (Change the target data layout to specify more values) Failed merges: r? @ghost
2 parents 6b269e4 + f4f77d7 commit fb0b123

Some content is hidden

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

47 files changed

+373
-137
lines changed

library/alloc/src/boxed.rs

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ use core::ops::{
143143
CoerceUnsized, Deref, DerefMut, DispatchFromDyn, Generator, GeneratorState, Receiver,
144144
};
145145
use core::pin::Pin;
146-
use core::ptr::{self, NonNull, Unique};
146+
use core::ptr::{self, Unique};
147147
use core::task::{Context, Poll};
148148

149149
use crate::alloc::{self, AllocInit, AllocRef, Global};
@@ -451,50 +451,6 @@ impl<T: ?Sized> Box<T> {
451451
Box::leak(b) as *mut T
452452
}
453453

454-
/// Consumes the `Box`, returning the wrapped pointer as `NonNull<T>`.
455-
///
456-
/// After calling this function, the caller is responsible for the
457-
/// memory previously managed by the `Box`. In particular, the
458-
/// caller should properly destroy `T` and release the memory. The
459-
/// easiest way to do so is to convert the `NonNull<T>` pointer
460-
/// into a raw pointer and back into a `Box` with the [`Box::from_raw`]
461-
/// function.
462-
///
463-
/// Note: this is an associated function, which means that you have
464-
/// to call it as `Box::into_raw_non_null(b)`
465-
/// instead of `b.into_raw_non_null()`. This
466-
/// is so that there is no conflict with a method on the inner type.
467-
///
468-
/// [`Box::from_raw`]: struct.Box.html#method.from_raw
469-
///
470-
/// # Examples
471-
///
472-
/// ```
473-
/// #![feature(box_into_raw_non_null)]
474-
/// #![allow(deprecated)]
475-
///
476-
/// let x = Box::new(5);
477-
/// let ptr = Box::into_raw_non_null(x);
478-
///
479-
/// // Clean up the memory by converting the NonNull pointer back
480-
/// // into a Box and letting the Box be dropped.
481-
/// let x = unsafe { Box::from_raw(ptr.as_ptr()) };
482-
/// ```
483-
#[unstable(feature = "box_into_raw_non_null", issue = "47336")]
484-
#[rustc_deprecated(
485-
since = "1.44.0",
486-
reason = "use `Box::leak(b).into()` or `NonNull::from(Box::leak(b))` instead"
487-
)]
488-
#[inline]
489-
pub fn into_raw_non_null(b: Box<T>) -> NonNull<T> {
490-
// Box is recognized as a "unique pointer" by Stacked Borrows, but internally it is a
491-
// raw pointer for the type system. Turning it directly into a raw pointer would not be
492-
// recognized as "releasing" the unique pointer to permit aliased raw accesses,
493-
// so all raw pointer methods go through `leak` which creates a (unique)
494-
// mutable reference. Turning *that* to a raw pointer behaves correctly.
495-
Box::leak(b).into()
496-
}
497-
498454
#[unstable(
499455
feature = "ptr_internals",
500456
issue = "none",

library/alloc/src/fmt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
//! # Formatting Parameters
8484
//!
8585
//! Each argument being formatted can be transformed by a number of formatting
86-
//! parameters (corresponding to `format_spec` in the syntax above). These
86+
//! parameters (corresponding to `format_spec` in [the syntax](#syntax)). These
8787
//! parameters affect the string representation of what's being formatted.
8888
//!
8989
//! ## Width

library/alloc/src/rc.rs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -645,29 +645,6 @@ impl<T: ?Sized> Rc<T> {
645645
unsafe { Self::from_ptr(rc_ptr) }
646646
}
647647

648-
/// Consumes the `Rc`, returning the wrapped pointer as `NonNull<T>`.
649-
///
650-
/// # Examples
651-
///
652-
/// ```
653-
/// #![feature(rc_into_raw_non_null)]
654-
/// #![allow(deprecated)]
655-
///
656-
/// use std::rc::Rc;
657-
///
658-
/// let x = Rc::new("hello".to_owned());
659-
/// let ptr = Rc::into_raw_non_null(x);
660-
/// let deref = unsafe { ptr.as_ref() };
661-
/// assert_eq!(deref, "hello");
662-
/// ```
663-
#[unstable(feature = "rc_into_raw_non_null", issue = "47336")]
664-
#[rustc_deprecated(since = "1.44.0", reason = "use `Rc::into_raw` instead")]
665-
#[inline]
666-
pub fn into_raw_non_null(this: Self) -> NonNull<T> {
667-
// safe because Rc guarantees its pointer is non-null
668-
unsafe { NonNull::new_unchecked(Rc::into_raw(this) as *mut _) }
669-
}
670-
671648
/// Creates a new [`Weak`][weak] pointer to this allocation.
672649
///
673650
/// [weak]: struct.Weak.html

library/alloc/src/string.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2196,6 +2196,9 @@ pub trait ToString {
21962196
/// since `fmt::Write for String` never returns an error itself.
21972197
#[stable(feature = "rust1", since = "1.0.0")]
21982198
impl<T: fmt::Display + ?Sized> ToString for T {
2199+
// A common guideline is to not inline generic functions. However,
2200+
// remove `#[inline]` from this method causes non-negligible regression.
2201+
// See <https://github.com/rust-lang/rust/pull/74852> as last attempt try to remove it.
21992202
#[inline]
22002203
default fn to_string(&self) -> String {
22012204
use fmt::Write;

library/alloc/src/sync.rs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -646,29 +646,6 @@ impl<T: ?Sized> Arc<T> {
646646
}
647647
}
648648

649-
/// Consumes the `Arc`, returning the wrapped pointer as `NonNull<T>`.
650-
///
651-
/// # Examples
652-
///
653-
/// ```
654-
/// #![feature(rc_into_raw_non_null)]
655-
/// #![allow(deprecated)]
656-
///
657-
/// use std::sync::Arc;
658-
///
659-
/// let x = Arc::new("hello".to_owned());
660-
/// let ptr = Arc::into_raw_non_null(x);
661-
/// let deref = unsafe { ptr.as_ref() };
662-
/// assert_eq!(deref, "hello");
663-
/// ```
664-
#[unstable(feature = "rc_into_raw_non_null", issue = "47336")]
665-
#[rustc_deprecated(since = "1.44.0", reason = "use `Arc::into_raw` instead")]
666-
#[inline]
667-
pub fn into_raw_non_null(this: Self) -> NonNull<T> {
668-
// safe because Arc guarantees its pointer is non-null
669-
unsafe { NonNull::new_unchecked(Arc::into_raw(this) as *mut _) }
670-
}
671-
672649
/// Creates a new [`Weak`][weak] pointer to this allocation.
673650
///
674651
/// [weak]: struct.Weak.html

library/core/src/sync/atomic.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2649,7 +2649,8 @@ unsafe fn atomic_umin<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
26492649
/// }
26502650
///
26512651
/// pub fn lock(&self) {
2652-
/// while !self.flag.compare_and_swap(false, true, Ordering::Relaxed) {}
2652+
/// // Wait until the old value is `false`.
2653+
/// while self.flag.compare_and_swap(false, true, Ordering::Relaxed) != false {}
26532654
/// // This fence synchronizes-with store in `unlock`.
26542655
/// fence(Ordering::Acquire);
26552656
/// }

library/std/src/net/ip.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,15 +1265,15 @@ impl Ipv6Addr {
12651265
/// # See also
12661266
///
12671267
/// - [IETF RFC 4291 section 2.5.6]
1268-
/// - [RFC 4291 errata 4406]
1268+
/// - [RFC 4291 errata 4406] (which has been rejected but provides useful
1269+
/// insight)
12691270
/// - [`is_unicast_link_local()`]
12701271
///
12711272
/// [IETF RFC 4291]: https://tools.ietf.org/html/rfc4291
12721273
/// [IETF RFC 4291 section 2.5.6]: https://tools.ietf.org/html/rfc4291#section-2.5.6
12731274
/// [`true`]: ../../std/primitive.bool.html
12741275
/// [RFC 4291 errata 4406]: https://www.rfc-editor.org/errata/eid4406
12751276
/// [`is_unicast_link_local()`]: ../../std/net/struct.Ipv6Addr.html#method.is_unicast_link_local
1276-
///
12771277
pub fn is_unicast_link_local_strict(&self) -> bool {
12781278
(self.segments()[0] & 0xffff) == 0xfe80
12791279
&& (self.segments()[1] & 0xffff) == 0
@@ -1324,13 +1324,13 @@ impl Ipv6Addr {
13241324
/// # See also
13251325
///
13261326
/// - [IETF RFC 4291 section 2.4]
1327-
/// - [RFC 4291 errata 4406]
1327+
/// - [RFC 4291 errata 4406] (which has been rejected but provides useful
1328+
/// insight)
13281329
///
13291330
/// [IETF RFC 4291 section 2.4]: https://tools.ietf.org/html/rfc4291#section-2.4
13301331
/// [`true`]: ../../std/primitive.bool.html
13311332
/// [RFC 4291 errata 4406]: https://www.rfc-editor.org/errata/eid4406
13321333
/// [`is_unicast_link_local_strict()`]: ../../std/net/struct.Ipv6Addr.html#method.is_unicast_link_local_strict
1333-
///
13341334
pub fn is_unicast_link_local(&self) -> bool {
13351335
(self.segments()[0] & 0xffc0) == 0xfe80
13361336
}

src/doc/unstable-book/src/language-features/plugin.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ of a library.
3535
Plugins can extend [Rust's lint
3636
infrastructure](../../reference/attributes/diagnostics.md#lint-check-attributes) with
3737
additional checks for code style, safety, etc. Now let's write a plugin
38-
[`lint_plugin_test.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui-fulldeps/auxiliary/lint_plugin_test.rs)
38+
[`lint-plugin-test.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui-fulldeps/auxiliary/lint-plugin-test.rs)
3939
that warns about any item named `lintme`.
4040

4141
```rust,ignore

src/librustc_lint/unused.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,28 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
203203
// Otherwise, we don't lint, to avoid false positives.
204204
_ => false,
205205
},
206+
ty::Closure(..) => {
207+
cx.struct_span_lint(UNUSED_MUST_USE, span, |lint| {
208+
let mut err = lint.build(&format!(
209+
"unused {}closure{}{} that must be used",
210+
descr_pre, plural_suffix, descr_post,
211+
));
212+
err.note("closures are lazy and do nothing unless called");
213+
err.emit();
214+
});
215+
true
216+
}
217+
ty::Generator(..) => {
218+
cx.struct_span_lint(UNUSED_MUST_USE, span, |lint| {
219+
let mut err = lint.build(&format!(
220+
"unused {}generator{}{} that must be used",
221+
descr_pre, plural_suffix, descr_post,
222+
));
223+
err.note("generators are lazy and do nothing unless resumed");
224+
err.emit();
225+
});
226+
true
227+
}
206228
_ => false,
207229
}
208230
}

src/librustc_symbol_mangling/v0.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -636,9 +636,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
636636
}
637637
GenericArgKind::Const(c) => {
638638
self.push("K");
639-
// FIXME(const_generics) implement `ty::print::Print` on `ty::Const`.
640-
// self = c.print(self)?;
641-
self = self.print_const(c)?;
639+
self = c.print(self)?;
642640
}
643641
}
644642
}

0 commit comments

Comments
 (0)