Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 11 pull requests #87567

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
3b2b5b2
Remove P: Unpin bound on impl Future for Pin
jonhoo Jan 25, 2021
ac658e1
Merge branch 'master' into no-unpin-in-pin-future-impl
jonhoo May 27, 2021
b5e5a18
Update library/core/src/pin.rs
jonhoo Jun 16, 2021
cf40292
Link tracking issue for pin_deref_mut
jonhoo Jul 6, 2021
88aecc6
BufWriter: actually export WriterPanicked error
ijackson Jun 1, 2021
3aaa275
BufWriter: rename `into_parts` from `into_raw_parts`
ijackson Jun 1, 2021
51d16ac
Rename feature gate bufwriter_into_parts from bufwriter_into_raw_parts
ijackson Jul 19, 2021
8c91805
Stabilize core::task::ready!
yoshuawuyts Jan 15, 2021
ec76b6e
Add support for tuple structs' fields documentation
GuillaumeGomez Jul 25, 2021
19f30b7
Add test for tuple struct documentation fields
GuillaumeGomez Jul 25, 2021
2b79094
Add support for tuple struct fields documentation in enums as well
GuillaumeGomez Jul 25, 2021
fbf78e1
Add test for enum item tuple fields documentation
GuillaumeGomez Jul 25, 2021
beb9bb3
Integrate context into the memorial to Anna
Jul 26, 2021
c4aa735
Add explanations for why we use Variant::Struct instead of Variant::T…
GuillaumeGomez Jul 27, 2021
7f563f7
Add long explanation for E0498
midgleyc Jul 27, 2021
bc70252
Mark code as ignored due to requiring external plugin
midgleyc Jul 27, 2021
40b57be
Don't run MIR unsafeck at all when using `-Zthir-unsafeck`
LeSeulArtichaut Jul 27, 2021
4b5ac09
add CI_ONLY_WHEN_CHANNEL and run x86_64-gnu-stable only on nightly
pietroalbini Jul 28, 2021
18cc06c
Update stable version of ready!() macro.
m-ou-se Jul 28, 2021
387cd6d
Add some doc aliases
D1mon Jul 3, 2021
2d8b6e3
Use backticks when referring to `core::future::Ready` in panic message
ibraheemdev Jul 28, 2021
00198dd
fix example code for E0617
ibraheemdev Jul 24, 2021
f3fc3f2
Rollup merge of #81050 - yoshuawuyts:stabilize-task-ready, r=m-ou-se
JohnTitor Jul 28, 2021
efa3a2f
Rollup merge of #81363 - jonhoo:no-unpin-in-pin-future-impl, r=m-ou-se
JohnTitor Jul 28, 2021
af62d11
Rollup merge of #85901 - ijackson:bufwriter-tweaks, r=joshtriplett
JohnTitor Jul 28, 2021
3e5e737
Rollup merge of #86839 - D1mon:patch-1, r=JohnTitor
JohnTitor Jul 28, 2021
dbe6d25
Rollup merge of #87435 - ibraheemdev:patch-4, r=JohnTitor
JohnTitor Jul 28, 2021
0a92db3
Rollup merge of #87451 - GuillaumeGomez:tuple-struct-field-doc, r=jyn514
JohnTitor Jul 28, 2021
b03f637
Rollup merge of #87491 - jamesmunns:integrate-memorial, r=Mark-Simula…
JohnTitor Jul 28, 2021
3c29c95
Rollup merge of #87521 - midgleyc:long-E0498, r=GuillaumeGomez
JohnTitor Jul 28, 2021
e252b9b
Rollup merge of #87527 - LeSeulArtichaut:no-mir-unsafeck, r=oli-obk
JohnTitor Jul 28, 2021
09246b9
Rollup merge of #87550 - pietroalbini:ci-only-when-channel, r=Mark-Si…
JohnTitor Jul 28, 2021
ecaf978
Rollup merge of #87565 - ibraheemdev:patch-7, r=scottmcm
JohnTitor Jul 28, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ jobs:
env:
IMAGE: x86_64-gnu
RUST_CI_OVERRIDE_RELEASE_CHANNEL: stable
CI_ONLY_WHEN_CHANNEL: nightly
os: ubuntu-latest-xl
- name: x86_64-gnu-aux
os: ubuntu-latest-xl
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_error_codes/src/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ E0493: include_str!("./error_codes/E0493.md"),
E0495: include_str!("./error_codes/E0495.md"),
E0496: include_str!("./error_codes/E0496.md"),
E0497: include_str!("./error_codes/E0497.md"),
E0498: include_str!("./error_codes/E0498.md"),
E0499: include_str!("./error_codes/E0499.md"),
E0500: include_str!("./error_codes/E0500.md"),
E0501: include_str!("./error_codes/E0501.md"),
Expand Down Expand Up @@ -604,7 +605,6 @@ E0783: include_str!("./error_codes/E0783.md"),
// E0488, // lifetime of variable does not enclose its declaration
// E0489, // type/lifetime parameter not in scope here
E0490, // a value of type `..` is borrowed for too long
E0498, // malformed plugin attribute
E0514, // metadata version mismatch
E0519, // local crate and dependency have same (crate-name, disambiguator)
// two dependencies have same (crate-name, disambiguator) but different SVH
Expand Down
22 changes: 22 additions & 0 deletions compiler/rustc_error_codes/src/error_codes/E0498.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The `plugin` attribute was malformed.

Erroneous code example:

```compile_fail,E0498
#![feature(plugin)]
#![plugin(foo(args))] // error: invalid argument
#![plugin(bar="test")] // error: invalid argument
```

The `#[plugin]` attribute should take a single argument: the name of the plugin.

For example, for the plugin `foo`:

```ignore (requires external plugin crate)
#![feature(plugin)]
#![plugin(foo)] // ok!
```

See the [`plugin` feature] section of the Unstable book for more details.

[`plugin` feature]: https://doc.rust-lang.org/nightly/unstable-book/language-features/plugin.html
11 changes: 7 additions & 4 deletions compiler/rustc_error_codes/src/error_codes/E0617.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ Attempted to pass an invalid type of variable into a variadic function.
Erroneous code example:

```compile_fail,E0617
# use std::os::raw::{c_char, c_int};
extern "C" {
fn printf(c: *const i8, ...);
fn printf(format: *const c_char, ...) -> c_int;
}

unsafe {
printf(::std::ptr::null(), 0f32);
printf("%f\n\0".as_ptr() as _, 0f32);
// error: cannot pass an `f32` to variadic function, cast to `c_double`
}
```
Expand All @@ -21,10 +22,12 @@ to import from `std::os::raw`).
In this case, `c_double` has the same size as `f64` so we can use it directly:

```no_run
# use std::os::raw::{c_char, c_int};
# extern "C" {
# fn printf(c: *const i8, ...);
# fn printf(format: *const c_char, ...) -> c_int;
# }

unsafe {
printf(::std::ptr::null(), 0f64); // ok!
printf("%f\n\0".as_ptr() as _, 0f64); // ok!
}
```
10 changes: 6 additions & 4 deletions compiler/rustc_mir/src/transform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,12 @@ fn mir_const<'tcx>(
}

// Unsafety check uses the raw mir, so make sure it is run.
if let Some(param_did) = def.const_param_did {
tcx.ensure().unsafety_check_result_for_const_arg((def.did, param_did));
} else {
tcx.ensure().unsafety_check_result(def.did);
if !tcx.sess.opts.debugging_opts.thir_unsafeck {
if let Some(param_did) = def.const_param_did {
tcx.ensure().unsafety_check_result_for_const_arg((def.did, param_did));
} else {
tcx.ensure().unsafety_check_result(def.did);
}
}

let mut body = tcx.mir_built(def).steal();
Expand Down
4 changes: 2 additions & 2 deletions library/core/src/future/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ impl<F: ?Sized + Future + Unpin> Future for &mut F {
#[stable(feature = "futures_api", since = "1.36.0")]
impl<P> Future for Pin<P>
where
P: Unpin + ops::DerefMut<Target: Future>,
P: ops::DerefMut<Target: Future>,
{
type Output = <<P as ops::Deref>::Target as Future>::Output;

fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
Pin::get_mut(self).as_mut().poll(cx)
<P::Target as Future>::poll(self.as_deref_mut(), cx)
}
}
2 changes: 1 addition & 1 deletion library/core/src/future/ready.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl<T> Future for Ready<T> {

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

Expand Down
1 change: 1 addition & 0 deletions library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
#![feature(exhaustive_patterns)]
#![feature(no_core)]
#![feature(auto_traits)]
#![feature(pin_deref_mut)]
#![feature(prelude_import)]
#![feature(ptr_metadata)]
#![feature(repr_simd, platform_intrinsics)]
Expand Down
38 changes: 38 additions & 0 deletions library/core/src/pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,44 @@ impl<T: ?Sized> Pin<&'static T> {
}
}

impl<'a, P: DerefMut> Pin<&'a mut Pin<P>> {
/// Gets a pinned mutable reference from this nested pinned pointer.
///
/// This is a generic method to go from `Pin<&mut Pin<Pointer<T>>>` to `Pin<&mut T>`. It is
/// safe because the existence of a `Pin<Pointer<T>>` ensures that the pointee, `T`, cannot
/// move in the future, and this method does not enable the pointee to move. "Malicious"
/// implementations of `P::DerefMut` are likewise ruled out by the contract of
/// `Pin::new_unchecked`.
#[unstable(feature = "pin_deref_mut", issue = "86918")]
#[inline(always)]
pub fn as_deref_mut(self) -> Pin<&'a mut P::Target> {
// SAFETY: What we're asserting here is that going from
//
// Pin<&mut Pin<P>>
//
// to
//
// Pin<&mut P::Target>
//
// is safe.
//
// We need to ensure that two things hold for that to be the case:
//
// 1) Once we give out a `Pin<&mut P::Target>`, an `&mut P::Target` will not be given out.
// 2) By giving out a `Pin<&mut P::Target>`, we do not risk of violating `Pin<&mut Pin<P>>`
//
// The existence of `Pin<P>` is sufficient to guarantee #1: since we already have a
// `Pin<P>`, it must already uphold the pinning guarantees, which must mean that
// `Pin<&mut P::Target>` does as well, since `Pin::as_mut` is safe. We do not have to rely
// on the fact that P is _also_ pinned.
//
// For #2, we need to ensure that code given a `Pin<&mut P::Target>` cannot cause the
// `Pin<P>` to move? That is not possible, since `Pin<&mut P::Target>` no longer retains
// any access to the `P` itself, much less the `Pin<P>`.
unsafe { self.get_unchecked_mut() }.as_mut()
}
}

impl<T: ?Sized> Pin<&'static mut T> {
/// Get a pinned mutable reference from a static mutable reference.
///
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/task/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ mod wake;
pub use self::wake::{Context, RawWaker, RawWakerVTable, Waker};

mod ready;
#[unstable(feature = "ready_macro", issue = "70922")]
#[stable(feature = "ready_macro", since = "1.56.0")]
pub use ready::ready;
6 changes: 1 addition & 5 deletions library/core/src/task/ready.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
/// # Examples
///
/// ```
/// #![feature(ready_macro)]
///
/// use std::task::{ready, Context, Poll};
/// use std::future::{self, Future};
/// use std::pin::Pin;
Expand All @@ -29,8 +27,6 @@
/// The `ready!` call expands to:
///
/// ```
/// # #![feature(ready_macro)]
/// #
/// # use std::task::{Context, Poll};
/// # use std::future::{self, Future};
/// # use std::pin::Pin;
Expand All @@ -49,7 +45,7 @@
/// # Poll::Ready(())
/// # }
/// ```
#[unstable(feature = "ready_macro", issue = "70922")]
#[stable(feature = "ready_macro", since = "1.56.0")]
#[rustc_macro_transparency = "semitransparent"]
pub macro ready($e:expr) {
match $e {
Expand Down
2 changes: 2 additions & 0 deletions library/std/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1912,6 +1912,7 @@ pub fn canonicalize<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> {
/// Ok(())
/// }
/// ```
#[doc(alias = "mkdir")]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn create_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
DirBuilder::new().create(path.as_ref())
Expand Down Expand Up @@ -1991,6 +1992,7 @@ pub fn create_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> {
/// Ok(())
/// }
/// ```
#[doc(alias = "rmdir")]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn remove_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
fs_imp::rmdir(path.as_ref())
Expand Down
26 changes: 13 additions & 13 deletions library/std/src/io/buffered/bufwriter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,24 +318,24 @@ impl<W: Write> BufWriter<W> {
/// In this case, we return `WriterPanicked` for the buffered data (from which the buffer
/// contents can still be recovered).
///
/// `into_raw_parts` makes no attempt to flush data and cannot fail.
/// `into_parts` makes no attempt to flush data and cannot fail.
///
/// # Examples
///
/// ```
/// #![feature(bufwriter_into_raw_parts)]
/// #![feature(bufwriter_into_parts)]
/// use std::io::{BufWriter, Write};
///
/// let mut buffer = [0u8; 10];
/// let mut stream = BufWriter::new(buffer.as_mut());
/// write!(stream, "too much data").unwrap();
/// stream.flush().expect_err("it doesn't fit");
/// let (recovered_writer, buffered_data) = stream.into_raw_parts();
/// let (recovered_writer, buffered_data) = stream.into_parts();
/// assert_eq!(recovered_writer.len(), 0);
/// assert_eq!(&buffered_data.unwrap(), b"ata");
/// ```
#[unstable(feature = "bufwriter_into_raw_parts", issue = "80690")]
pub fn into_raw_parts(mut self) -> (W, Result<Vec<u8>, WriterPanicked>) {
#[unstable(feature = "bufwriter_into_parts", issue = "80690")]
pub fn into_parts(mut self) -> (W, Result<Vec<u8>, WriterPanicked>) {
let buf = mem::take(&mut self.buf);
let buf = if !self.panicked { Ok(buf) } else { Err(WriterPanicked { buf }) };

Expand Down Expand Up @@ -444,14 +444,14 @@ impl<W: Write> BufWriter<W> {
}
}

#[unstable(feature = "bufwriter_into_raw_parts", issue = "80690")]
/// Error returned for the buffered data from `BufWriter::into_raw_parts`, when the underlying
#[unstable(feature = "bufwriter_into_parts", issue = "80690")]
/// Error returned for the buffered data from `BufWriter::into_parts`, when the underlying
/// writer has previously panicked. Contains the (possibly partly written) buffered data.
///
/// # Example
///
/// ```
/// #![feature(bufwriter_into_raw_parts)]
/// #![feature(bufwriter_into_parts)]
/// use std::io::{self, BufWriter, Write};
/// use std::panic::{catch_unwind, AssertUnwindSafe};
///
Expand All @@ -467,7 +467,7 @@ impl<W: Write> BufWriter<W> {
/// stream.flush().unwrap()
/// }));
/// assert!(result.is_err());
/// let (recovered_writer, buffered_data) = stream.into_raw_parts();
/// let (recovered_writer, buffered_data) = stream.into_parts();
/// assert!(matches!(recovered_writer, PanickingWriter));
/// assert_eq!(buffered_data.unwrap_err().into_inner(), b"some data");
/// ```
Expand All @@ -478,7 +478,7 @@ pub struct WriterPanicked {
impl WriterPanicked {
/// Returns the perhaps-unwritten data. Some of this data may have been written by the
/// panicking call(s) to the underlying writer, so simply writing it again is not a good idea.
#[unstable(feature = "bufwriter_into_raw_parts", issue = "80690")]
#[unstable(feature = "bufwriter_into_parts", issue = "80690")]
pub fn into_inner(self) -> Vec<u8> {
self.buf
}
Expand All @@ -487,22 +487,22 @@ impl WriterPanicked {
"BufWriter inner writer panicked, what data remains unwritten is not known";
}

#[unstable(feature = "bufwriter_into_raw_parts", issue = "80690")]
#[unstable(feature = "bufwriter_into_parts", issue = "80690")]
impl error::Error for WriterPanicked {
#[allow(deprecated, deprecated_in_future)]
fn description(&self) -> &str {
Self::DESCRIPTION
}
}

#[unstable(feature = "bufwriter_into_raw_parts", issue = "80690")]
#[unstable(feature = "bufwriter_into_parts", issue = "80690")]
impl fmt::Display for WriterPanicked {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", Self::DESCRIPTION)
}
}

#[unstable(feature = "bufwriter_into_raw_parts", issue = "80690")]
#[unstable(feature = "bufwriter_into_parts", issue = "80690")]
impl fmt::Debug for WriterPanicked {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("WriterPanicked")
Expand Down
2 changes: 2 additions & 0 deletions library/std/src/io/buffered/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ use crate::io::Error;

pub use bufreader::BufReader;
pub use bufwriter::BufWriter;
#[unstable(feature = "bufwriter_into_parts", issue = "80690")]
pub use bufwriter::WriterPanicked;
pub use linewriter::LineWriter;
use linewritershim::LineWriterShim;

Expand Down
2 changes: 2 additions & 0 deletions library/std/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ use crate::sys_common::memchr;

#[stable(feature = "rust1", since = "1.0.0")]
pub use self::buffered::IntoInnerError;
#[unstable(feature = "bufwriter_into_parts", issue = "80690")]
pub use self::buffered::WriterPanicked;
#[stable(feature = "rust1", since = "1.0.0")]
pub use self::buffered::{BufReader, BufWriter, LineWriter};
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
1 change: 0 additions & 1 deletion library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,6 @@
#![feature(pin_static_ref)]
#![feature(prelude_import)]
#![feature(ptr_internals)]
#![feature(ready_macro)]
#![feature(rustc_attrs)]
#![feature(rustc_private)]
#![feature(shrink_to)]
Expand Down
4 changes: 4 additions & 0 deletions src/ci/github-actions/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,10 @@ jobs:
env:
IMAGE: x86_64-gnu
RUST_CI_OVERRIDE_RELEASE_CHANNEL: stable
# Only run this job on the nightly channel. Running this on beta
# could cause failures when `dev: 1` in `stage0.txt`, and running
# this on stable is useless.
CI_ONLY_WHEN_CHANNEL: nightly
<<: *job-linux-xl

- name: x86_64-gnu-aux
Expand Down
Loading