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

Commit 4533be9

Browse files
committed
Auto merge of rust-lang#87569 - JohnTitor:rollup-7ydfetw, r=JohnTitor
Rollup of 10 pull requests Successful merges: - rust-lang#81050 (Stabilize core::task::ready!) - rust-lang#81363 (Remove P: Unpin bound on impl Future for Pin) - rust-lang#86839 (Add doc aliases to fs.rs) - rust-lang#87435 (fix example code for E0617) - rust-lang#87451 (Add support for tuple struct field documentation) - rust-lang#87491 (Integrate context into the memorial to Anna) - rust-lang#87521 (Add long explanation for E0498) - rust-lang#87527 (Don't run MIR unsafeck at all when using `-Zthir-unsafeck`) - rust-lang#87550 (Add `CI_ONLY_WHEN_CHANNEL` and run `x86_64-gnu-stable` only on nightly) - rust-lang#87565 (Use backticks when referring to `core::future::Ready` in panic message) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents b708886 + 6c4888a commit 4533be9

File tree

24 files changed

+202
-69
lines changed

24 files changed

+202
-69
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ jobs:
263263
env:
264264
IMAGE: x86_64-gnu
265265
RUST_CI_OVERRIDE_RELEASE_CHANNEL: stable
266+
CI_ONLY_WHEN_CHANNEL: nightly
266267
os: ubuntu-latest-xl
267268
- name: x86_64-gnu-aux
268269
os: ubuntu-latest-xl

compiler/rustc_error_codes/src/error_codes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ E0493: include_str!("./error_codes/E0493.md"),
248248
E0495: include_str!("./error_codes/E0495.md"),
249249
E0496: include_str!("./error_codes/E0496.md"),
250250
E0497: include_str!("./error_codes/E0497.md"),
251+
E0498: include_str!("./error_codes/E0498.md"),
251252
E0499: include_str!("./error_codes/E0499.md"),
252253
E0500: include_str!("./error_codes/E0500.md"),
253254
E0501: include_str!("./error_codes/E0501.md"),
@@ -604,7 +605,6 @@ E0783: include_str!("./error_codes/E0783.md"),
604605
// E0488, // lifetime of variable does not enclose its declaration
605606
// E0489, // type/lifetime parameter not in scope here
606607
E0490, // a value of type `..` is borrowed for too long
607-
E0498, // malformed plugin attribute
608608
E0514, // metadata version mismatch
609609
E0519, // local crate and dependency have same (crate-name, disambiguator)
610610
// two dependencies have same (crate-name, disambiguator) but different SVH
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The `plugin` attribute was malformed.
2+
3+
Erroneous code example:
4+
5+
```compile_fail,E0498
6+
#![feature(plugin)]
7+
#![plugin(foo(args))] // error: invalid argument
8+
#![plugin(bar="test")] // error: invalid argument
9+
```
10+
11+
The `#[plugin]` attribute should take a single argument: the name of the plugin.
12+
13+
For example, for the plugin `foo`:
14+
15+
```ignore (requires external plugin crate)
16+
#![feature(plugin)]
17+
#![plugin(foo)] // ok!
18+
```
19+
20+
See the [`plugin` feature] section of the Unstable book for more details.
21+
22+
[`plugin` feature]: https://doc.rust-lang.org/nightly/unstable-book/language-features/plugin.html

compiler/rustc_error_codes/src/error_codes/E0617.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ Attempted to pass an invalid type of variable into a variadic function.
33
Erroneous code example:
44

55
```compile_fail,E0617
6+
# use std::os::raw::{c_char, c_int};
67
extern "C" {
7-
fn printf(c: *const i8, ...);
8+
fn printf(format: *const c_char, ...) -> c_int;
89
}
910
1011
unsafe {
11-
printf(::std::ptr::null(), 0f32);
12+
printf("%f\n\0".as_ptr() as _, 0f32);
1213
// error: cannot pass an `f32` to variadic function, cast to `c_double`
1314
}
1415
```
@@ -21,10 +22,12 @@ to import from `std::os::raw`).
2122
In this case, `c_double` has the same size as `f64` so we can use it directly:
2223

2324
```no_run
25+
# use std::os::raw::{c_char, c_int};
2426
# extern "C" {
25-
# fn printf(c: *const i8, ...);
27+
# fn printf(format: *const c_char, ...) -> c_int;
2628
# }
29+
2730
unsafe {
28-
printf(::std::ptr::null(), 0f64); // ok!
31+
printf("%f\n\0".as_ptr() as _, 0f64); // ok!
2932
}
3033
```

compiler/rustc_mir/src/transform/mod.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,12 @@ fn mir_const<'tcx>(
259259
}
260260

261261
// Unsafety check uses the raw mir, so make sure it is run.
262-
if let Some(param_did) = def.const_param_did {
263-
tcx.ensure().unsafety_check_result_for_const_arg((def.did, param_did));
264-
} else {
265-
tcx.ensure().unsafety_check_result(def.did);
262+
if !tcx.sess.opts.debugging_opts.thir_unsafeck {
263+
if let Some(param_did) = def.const_param_did {
264+
tcx.ensure().unsafety_check_result_for_const_arg((def.did, param_did));
265+
} else {
266+
tcx.ensure().unsafety_check_result(def.did);
267+
}
266268
}
267269

268270
let mut body = tcx.mir_built(def).steal();

library/core/src/future/future.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ 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<Target: Future>,
114+
P: ops::DerefMut<Target: Future>,
115115
{
116116
type Output = <<P as ops::Deref>::Target as Future>::Output;
117117

118118
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
119-
Pin::get_mut(self).as_mut().poll(cx)
119+
<P::Target as Future>::poll(self.as_deref_mut(), cx)
120120
}
121121
}

library/core/src/future/ready.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl<T> Future for Ready<T> {
2020

2121
#[inline]
2222
fn poll(mut self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<T> {
23-
Poll::Ready(self.0.take().expect("Ready polled after completion"))
23+
Poll::Ready(self.0.take().expect("`Ready` polled after completion"))
2424
}
2525
}
2626

library/core/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
#![feature(exhaustive_patterns)]
129129
#![feature(no_core)]
130130
#![feature(auto_traits)]
131+
#![feature(pin_deref_mut)]
131132
#![feature(prelude_import)]
132133
#![feature(ptr_metadata)]
133134
#![feature(repr_simd, platform_intrinsics)]

library/core/src/pin.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,44 @@ impl<T: ?Sized> Pin<&'static T> {
802802
}
803803
}
804804

805+
impl<'a, P: DerefMut> Pin<&'a mut Pin<P>> {
806+
/// Gets a pinned mutable reference from this nested pinned pointer.
807+
///
808+
/// This is a generic method to go from `Pin<&mut Pin<Pointer<T>>>` to `Pin<&mut T>`. It is
809+
/// safe because the existence of a `Pin<Pointer<T>>` ensures that the pointee, `T`, cannot
810+
/// move in the future, and this method does not enable the pointee to move. "Malicious"
811+
/// implementations of `P::DerefMut` are likewise ruled out by the contract of
812+
/// `Pin::new_unchecked`.
813+
#[unstable(feature = "pin_deref_mut", issue = "86918")]
814+
#[inline(always)]
815+
pub fn as_deref_mut(self) -> Pin<&'a mut P::Target> {
816+
// SAFETY: What we're asserting here is that going from
817+
//
818+
// Pin<&mut Pin<P>>
819+
//
820+
// to
821+
//
822+
// Pin<&mut P::Target>
823+
//
824+
// is safe.
825+
//
826+
// We need to ensure that two things hold for that to be the case:
827+
//
828+
// 1) Once we give out a `Pin<&mut P::Target>`, an `&mut P::Target` will not be given out.
829+
// 2) By giving out a `Pin<&mut P::Target>`, we do not risk of violating `Pin<&mut Pin<P>>`
830+
//
831+
// The existence of `Pin<P>` is sufficient to guarantee #1: since we already have a
832+
// `Pin<P>`, it must already uphold the pinning guarantees, which must mean that
833+
// `Pin<&mut P::Target>` does as well, since `Pin::as_mut` is safe. We do not have to rely
834+
// on the fact that P is _also_ pinned.
835+
//
836+
// For #2, we need to ensure that code given a `Pin<&mut P::Target>` cannot cause the
837+
// `Pin<P>` to move? That is not possible, since `Pin<&mut P::Target>` no longer retains
838+
// any access to the `P` itself, much less the `Pin<P>`.
839+
unsafe { self.get_unchecked_mut() }.as_mut()
840+
}
841+
}
842+
805843
impl<T: ?Sized> Pin<&'static mut T> {
806844
/// Get a pinned mutable reference from a static mutable reference.
807845
///

library/core/src/task/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ mod wake;
1111
pub use self::wake::{Context, RawWaker, RawWakerVTable, Waker};
1212

1313
mod ready;
14-
#[unstable(feature = "ready_macro", issue = "70922")]
14+
#[stable(feature = "ready_macro", since = "1.56.0")]
1515
pub use ready::ready;

0 commit comments

Comments
 (0)