Skip to content

Commit fb0b123

Browse files
committed
Auto merge of #74929 - Manishearth:rollup-z2vflrp, r=Manishearth
Rollup of 10 pull requests Successful merges: - #74742 (Remove links to rejected errata 4406 for RFC 4291) - #74819 (Point towards `format_spec`; it is in other direction) - #74852 (Explain why inlining default ToString impl) - #74869 (Make closures and generators a must use types) - #74873 (symbol mangling: use ty::print::Print for consts) - #74902 (Remove deprecated unstable `{Box,Rc,Arc}::into_raw_non_null` functions) - #74904 (Fix some typos in src/librustdoc/clean/auto_trait.rs) - #74910 (fence docs: fix example Mutex) - #74912 (Fix broken link in unstable book `plugin`) - #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

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

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

-23
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

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

-23
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

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

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

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

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

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

src/librustc_target/spec/thumbv4t_none_eabi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub fn target() -> TargetResult {
2929
* native integers are 32-bit
3030
* All other elements are default
3131
*/
32-
data_layout: "e-S64-p:32:32-i64:64-m:e-n32".to_string(),
32+
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
3333
linker_flavor: LinkerFlavor::Ld,
3434
options: TargetOptions {
3535
linker: Some("arm-none-eabi-ld".to_string()),

src/librustdoc/clean/auto_trait.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -430,14 +430,14 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
430430
}
431431

432432
// Converts the calculated ParamEnv and lifetime information to a clean::Generics, suitable for
433-
// display on the docs page. Cleaning the Predicates produces sub-optimal WherePredicate's,
433+
// display on the docs page. Cleaning the Predicates produces sub-optimal `WherePredicate`s,
434434
// so we fix them up:
435435
//
436436
// * Multiple bounds for the same type are coalesced into one: e.g., 'T: Copy', 'T: Debug'
437437
// becomes 'T: Copy + Debug'
438438
// * Fn bounds are handled specially - instead of leaving it as 'T: Fn(), <T as Fn::Output> =
439439
// K', we use the dedicated syntax 'T: Fn() -> K'
440-
// * We explcitly add a '?Sized' bound if we didn't find any 'Sized' predicates for a type
440+
// * We explicitly add a '?Sized' bound if we didn't find any 'Sized' predicates for a type
441441
fn param_env_to_generics(
442442
&self,
443443
tcx: TyCtxt<'tcx>,
@@ -588,7 +588,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
588588
.args;
589589

590590
match args {
591-
// Convert somethiung like '<T as Iterator::Item> = u8'
591+
// Convert something like '<T as Iterator::Item> = u8'
592592
// to 'T: Iterator<Item=u8>'
593593
GenericArgs::AngleBracketed {
594594
ref mut bindings, ..
@@ -712,7 +712,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
712712
// since FxHasher has different behavior for 32-bit and 64-bit platforms.
713713
//
714714
// Obviously, it's extremely undesirable for documentation rendering
715-
// to be depndent on the platform it's run on. Apart from being confusing
715+
// to be dependent on the platform it's run on. Apart from being confusing
716716
// to end users, it makes writing tests much more difficult, as predicates
717717
// can appear in any order in the final result.
718718
//

src/test/ui/generator/issue-52398.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ impl A {
1414
fn main() {
1515
// Test that the MIR local with type &A created for the auto-borrow adjustment
1616
// is caught by typeck
17-
move || {
17+
move || { //~ WARN unused generator that must be used
1818
A.test(yield);
1919
};
2020

2121
// Test that the std::cell::Ref temporary returned from the `borrow` call
2222
// is caught by typeck
2323
let y = RefCell::new(true);
24-
static move || {
24+
static move || { //~ WARN unused generator that must be used
2525
yield *y.borrow();
2626
return "Done";
2727
};
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
warning: unused generator that must be used
2+
--> $DIR/issue-52398.rs:17:5
3+
|
4+
LL | / move || {
5+
LL | | A.test(yield);
6+
LL | | };
7+
| |______^
8+
|
9+
= note: `#[warn(unused_must_use)]` on by default
10+
= note: generators are lazy and do nothing unless resumed
11+
12+
warning: unused generator that must be used
13+
--> $DIR/issue-52398.rs:24:5
14+
|
15+
LL | / static move || {
16+
LL | | yield *y.borrow();
17+
LL | | return "Done";
18+
LL | | };
19+
| |______^
20+
|
21+
= note: generators are lazy and do nothing unless resumed
22+
23+
warning: 2 warnings emitted
24+

src/test/ui/generator/issue-57084.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ where F: Fn() -> ()
1919

2020
fn main() {
2121
let data = &vec![1];
22-
|| {
22+
|| { //~ WARN unused generator that must be used
2323
let _to_pin = with(move || println!("{:p}", data));
2424
loop {
2525
yield
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
warning: unused generator that must be used
2+
--> $DIR/issue-57084.rs:22:5
3+
|
4+
LL | / || {
5+
LL | | let _to_pin = with(move || println!("{:p}", data));
6+
LL | | loop {
7+
LL | | yield
8+
LL | | }
9+
LL | | };
10+
| |______^
11+
|
12+
= note: `#[warn(unused_must_use)]` on by default
13+
= note: generators are lazy and do nothing unless resumed
14+
15+
warning: 1 warning emitted
16+

src/test/ui/generator/match-bindings.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ enum Enum {
99
}
1010

1111
fn main() {
12-
|| {
12+
|| { //~ WARN unused generator that must be used
1313
loop {
1414
if let true = true {
1515
match Enum::A(String::new()) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
warning: unused generator that must be used
2+
--> $DIR/match-bindings.rs:12:5
3+
|
4+
LL | / || {
5+
LL | | loop {
6+
LL | | if let true = true {
7+
LL | | match Enum::A(String::new()) {
8+
... |
9+
LL | | }
10+
LL | | };
11+
| |______^
12+
|
13+
= note: `#[warn(unused_must_use)]` on by default
14+
= note: generators are lazy and do nothing unless resumed
15+
16+
warning: 1 warning emitted
17+

src/test/ui/generator/reborrow-mut-upvar.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#![feature(generators)]
44

55
fn _run(bar: &mut i32) {
6-
|| {
6+
|| { //~ WARN unused generator that must be used
77
{
88
let _baz = &*bar;
99
yield;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
warning: unused generator that must be used
2+
--> $DIR/reborrow-mut-upvar.rs:6:5
3+
|
4+
LL | / || {
5+
LL | | {
6+
LL | | let _baz = &*bar;
7+
LL | | yield;
8+
... |
9+
LL | | *bar = 2;
10+
LL | | };
11+
| |______^
12+
|
13+
= note: `#[warn(unused_must_use)]` on by default
14+
= note: generators are lazy and do nothing unless resumed
15+
16+
warning: 1 warning emitted
17+

0 commit comments

Comments
 (0)