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 8 pull requests #70325

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c57de34
Stabilize --crate-version option in rustdoc
GuillaumeGomez Feb 26, 2020
7d40019
rustc_mir: remove extra space when pretty-printing MIR.
anyska Mar 17, 2020
f1188f7
Add test for issue #53275
rylev Mar 20, 2020
da5d03d
Add missing -Z unstable-options flag
aleksator Mar 20, 2020
13af249
Make `needs_drop` less pessimistic on generators
jonas-schievink Mar 14, 2020
489d79d
Adjust mir-opt test and make it drop something
jonas-schievink Mar 15, 2020
4803f29
add err_machine_stop macro
RalfJung Mar 23, 2020
821eef5
Make sure issue 53275 test goes through codegen
rylev Mar 23, 2020
403ba61
Rename remaining occurences of Void to Opaque.
anyska Mar 23, 2020
06ede35
Add Wake trait for safe construction of Wakers.
withoutboats Jan 31, 2020
d8a835f
Add `wake_trait` feature directive to std
withoutboats Jan 31, 2020
c9acdb0
Improve safety implementation, fix typos
withoutboats Jan 31, 2020
ede03a4
typo
withoutboats Jan 31, 2020
3ae74ca
More explicit; CFG on atomic pointer
withoutboats Feb 2, 2020
a4875a7
Update src/libstd/lib.rs
withoutboats Mar 23, 2020
caff9f9
Update src/liballoc/task.rs
withoutboats Mar 23, 2020
32f5724
Apply suggestions from code review
withoutboats Mar 23, 2020
fcb4e77
Split long derive lists into two derive attributes.
anyska Mar 23, 2020
0e40d7e
Rollup merge of #68700 - withoutboats:wake-trait, r=withoutboats
Centril Mar 23, 2020
6d0c041
Rollup merge of #69494 - GuillaumeGomez:stabilize-crate-version, r=eh…
Centril Mar 23, 2020
4432cb3
Rollup merge of #70015 - jonas-schievink:gen-needs-drop, r=matthewjasper
Centril Mar 23, 2020
34e664f
Rollup merge of #70080 - anyska:mir-double-space, r=oli-obk
Centril Mar 23, 2020
4be1ec1
Rollup merge of #70195 - rylev:test-for-53275, r=Centril
Centril Mar 23, 2020
589b51f
Rollup merge of #70299 - RalfJung:err_machine_stop, r=oli-obk
Centril Mar 23, 2020
8d074cd
Rollup merge of #70315 - anyska:void-rename, r=Mark-Simulacrum
Centril Mar 23, 2020
40c0ef4
Rollup merge of #70318 - anyska:multiple-derives, r=Dylan-DPC
Centril Mar 23, 2020
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
5 changes: 0 additions & 5 deletions src/bootstrap/bin/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,7 @@ fn main() {
// Bootstrap's Cargo-command builder sets this variable to the current Rust version; let's pick
// it up so we can make rustdoc print this into the docs
if let Some(version) = env::var_os("RUSTDOC_CRATE_VERSION") {
// This "unstable-options" can be removed when `--crate-version` is stabilized
if !has_unstable {
cmd.arg("-Z").arg("unstable-options");
}
cmd.arg("--crate-version").arg(version);
has_unstable = true;
}

// Needed to be able to run all rustdoc tests.
Expand Down
7 changes: 6 additions & 1 deletion src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,9 @@ impl Step for Standalone {
}

let mut cmd = builder.rustdoc_cmd(compiler);
// Needed for --index-page flag
cmd.arg("-Z").arg("unstable-options");

cmd.arg("--html-after-content")
.arg(&footer)
.arg("--html-before-content")
Expand Down Expand Up @@ -395,7 +398,7 @@ impl Step for Std {

// Keep a whitelist so we do not build internal stdlib crates, these will be
// build by the rustc step later if enabled.
cargo.arg("-Z").arg("unstable-options").arg("-p").arg(package);
cargo.arg("-p").arg(package);
// Create all crate output directories first to make sure rustdoc uses
// relative links.
// FIXME: Cargo should probably do this itself.
Expand All @@ -406,6 +409,8 @@ impl Step for Std {
.arg("rust.css")
.arg("--markdown-no-toc")
.arg("--generate-redirect-pages")
.arg("-Z")
.arg("unstable-options")
.arg("--resource-suffix")
.arg(crate::channel::CFG_RELEASE_NUM)
.arg("--index-page")
Expand Down
12 changes: 12 additions & 0 deletions src/doc/rustdoc/src/command-line-arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,3 +390,15 @@ the same CSS rules as the official `light` theme.
`--check-theme` is a separate mode in `rustdoc`. When `rustdoc` sees the
`--check-theme` flag, it discards all other flags and only performs the CSS rule
comparison operation.

### `--crate-version`: control the crate version

Using this flag looks like this:

```bash
$ rustdoc src/lib.rs --crate-version 1.3.37
```

When `rustdoc` receives this flag, it will print an extra "Version (version)" into the sidebar of
the crate root's docs. You can use this flag to differentiate between different versions of your
library's documentation.
12 changes: 0 additions & 12 deletions src/doc/rustdoc/src/unstable-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,18 +248,6 @@ Markdown file, the URL given to `--markdown-playground-url` will take precedence
`--playground-url` and `#![doc(html_playground_url = "url")]` are present when rendering crate docs,
the attribute will take precedence.

### `--crate-version`: control the crate version

Using this flag looks like this:

```bash
$ rustdoc src/lib.rs -Z unstable-options --crate-version 1.3.37
```

When `rustdoc` receives this flag, it will print an extra "Version (version)" into the sidebar of
the crate root's docs. You can use this flag to differentiate between different versions of your
library's documentation.

### `--sort-modules-by-appearance`: control how items on module pages are sorted

Using this flag looks like this:
Expand Down
2 changes: 2 additions & 0 deletions src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ pub mod str;
pub mod string;
#[cfg(target_has_atomic = "ptr")]
pub mod sync;
#[cfg(target_has_atomic = "ptr")]
pub mod task;
#[cfg(test)]
mod tests;
pub mod vec;
Expand Down
87 changes: 87 additions & 0 deletions src/liballoc/task.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#![unstable(feature = "wake_trait", issue = "69912")]
//! Types and Traits for working with asynchronous tasks.
use core::mem::{self, ManuallyDrop};
use core::task::{RawWaker, RawWakerVTable, Waker};

use crate::sync::Arc;

/// The implementation of waking a task on an executor.
///
/// This trait can be used to create a [`Waker`]. An executor can define an
/// implementation of this trait, and use that to construct a Waker to pass
/// to the tasks that are executed on that executor.
///
/// This trait is a memory-safe and ergonomic alternative to constructing a
/// [`RawWaker`]. It supports the common executor design in which the data
/// used to wake up a task is stored in an [`Arc`]. Some executors (especially
/// those for embedded systems) cannot use this API, which is why [`RawWaker`]
/// exists as an alternative for those systems.
#[unstable(feature = "wake_trait", issue = "69912")]
pub trait Wake {
/// Wake this task.
#[unstable(feature = "wake_trait", issue = "69912")]
fn wake(self: Arc<Self>);

/// Wake this task without consuming the waker.
///
/// If an executor supports a cheaper way to wake without consuming the
/// waker, it should override this method. By default, it clones the
/// [`Arc`] and calls `wake` on the clone.
#[unstable(feature = "wake_trait", issue = "69912")]
fn wake_by_ref(self: &Arc<Self>) {
self.clone().wake();
}
}

#[unstable(feature = "wake_trait", issue = "69912")]
impl<W: Wake + Send + Sync + 'static> From<Arc<W>> for Waker {
fn from(waker: Arc<W>) -> Waker {
// SAFETY: This is safe because raw_waker safely constructs
// a RawWaker from Arc<W>.
unsafe { Waker::from_raw(raw_waker(waker)) }
}
}

#[unstable(feature = "wake_trait", issue = "69912")]
impl<W: Wake + Send + Sync + 'static> From<Arc<W>> for RawWaker {
fn from(waker: Arc<W>) -> RawWaker {
raw_waker(waker)
}
}

// NB: This private function for constructing a RawWaker is used, rather than
// inlining this into the `From<Arc<W>> for RawWaker` impl, to ensure that
// the safety of `From<Arc<W>> for Waker` does not depend on the correct
// trait dispatch - instead both impls call this function directly and
// explicitly.
#[inline(always)]
fn raw_waker<W: Wake + Send + Sync + 'static>(waker: Arc<W>) -> RawWaker {
// Increment the reference count of the arc to clone it.
unsafe fn clone_waker<W: Wake + Send + Sync + 'static>(waker: *const ()) -> RawWaker {
let waker: Arc<W> = Arc::from_raw(waker as *const W);
mem::forget(Arc::clone(&waker));
raw_waker(waker)
}

// Wake by value, moving the Arc into the Wake::wake function
unsafe fn wake<W: Wake + Send + Sync + 'static>(waker: *const ()) {
let waker: Arc<W> = Arc::from_raw(waker as *const W);
<W as Wake>::wake(waker);
}

// Wake by reference, wrap the waker in ManuallyDrop to avoid dropping it
unsafe fn wake_by_ref<W: Wake + Send + Sync + 'static>(waker: *const ()) {
let waker: ManuallyDrop<Arc<W>> = ManuallyDrop::new(Arc::from_raw(waker as *const W));
<W as Wake>::wake_by_ref(&waker);
}

// Decrement the reference count of the Arc on drop
unsafe fn drop_waker<W: Wake + Send + Sync + 'static>(waker: *const ()) {
mem::drop(Arc::from_raw(waker as *const W));
}

RawWaker::new(
Arc::into_raw(waker) as *const (),
&RawWakerVTable::new(clone_waker::<W>, wake::<W>, wake_by_ref::<W>, drop_waker::<W>),
)
}
4 changes: 2 additions & 2 deletions src/libcore/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,10 @@ impl<'a> ArgumentV1<'a> {
// SAFETY: `mem::transmute(x)` is safe because
// 1. `&'b T` keeps the lifetime it originated with `'b`
// (so as to not have an unbounded lifetime)
// 2. `&'b T` and `&'b Void` have the same memory layout
// 2. `&'b T` and `&'b Opaque` have the same memory layout
// (when `T` is `Sized`, as it is here)
// `mem::transmute(f)` is safe since `fn(&T, &mut Formatter<'_>) -> Result`
// and `fn(&Void, &mut Formatter<'_>) -> Result` have the same ABI
// and `fn(&Opaque, &mut Formatter<'_>) -> Result` have the same ABI
// (as long as `T` is `Sized`)
unsafe { ArgumentV1 { formatter: mem::transmute(f), value: mem::transmute(x) } }
}
Expand Down
15 changes: 2 additions & 13 deletions src/librustc/dep_graph/dep_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,19 +489,8 @@ impl<'tcx> DepNodeParams<'tcx> for HirId {
/// some independent path or string that persists between runs without
/// the need to be mapped or unmapped. (This ensures we can serialize
/// them even in the absence of a tcx.)
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
RustcEncodable,
RustcDecodable,
HashStable
)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
#[derive(HashStable)]
pub struct WorkProductId {
hash: Fingerprint,
}
Expand Down
14 changes: 2 additions & 12 deletions src/librustc/middle/cstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,8 @@ impl CrateSource {
}
}

#[derive(
RustcEncodable,
RustcDecodable,
Copy,
Clone,
Ord,
PartialOrd,
Eq,
PartialEq,
Debug,
HashStable
)]
#[derive(RustcEncodable, RustcDecodable, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Debug)]
#[derive(HashStable)]
pub enum DepKind {
/// A dependency that is only used for its macros.
MacrosOnly,
Expand Down
29 changes: 4 additions & 25 deletions src/librustc/middle/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,8 @@ use std::fmt;
// placate the same deriving in `ty::FreeRegion`, but we may want to
// actually attach a more meaningful ordering to scopes than the one
// generated via deriving here.
#[derive(
Clone,
PartialEq,
PartialOrd,
Eq,
Ord,
Hash,
Copy,
RustcEncodable,
RustcDecodable,
HashStable
)]
#[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Copy, RustcEncodable, RustcDecodable)]
#[derive(HashStable)]
pub struct Scope {
pub id: hir::ItemLocalId,
pub data: ScopeData,
Expand All @@ -114,19 +104,8 @@ impl fmt::Debug for Scope {
}
}

#[derive(
Clone,
PartialEq,
PartialOrd,
Eq,
Ord,
Hash,
Debug,
Copy,
RustcEncodable,
RustcDecodable,
HashStable
)]
#[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Debug, Copy, RustcEncodable, RustcDecodable)]
#[derive(HashStable)]
pub enum ScopeData {
Node,

Expand Down
28 changes: 4 additions & 24 deletions src/librustc/mir/interpret/allocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,8 @@ use std::ops::{Deref, DerefMut, Range};

// NOTE: When adding new fields, make sure to adjust the `Snapshot` impl in
// `src/librustc_mir/interpret/snapshot.rs`.
#[derive(
Clone,
Debug,
Eq,
PartialEq,
PartialOrd,
Ord,
Hash,
RustcEncodable,
RustcDecodable,
HashStable
)]
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
#[derive(HashStable)]
pub struct Allocation<Tag = (), Extra = ()> {
/// The actual bytes of the allocation.
/// Note that the bytes of a pointer represent the offset of the pointer.
Expand Down Expand Up @@ -759,18 +749,8 @@ type Block = u64;

/// A bitmask where each bit refers to the byte with the same index. If the bit is `true`, the byte
/// is defined. If it is `false` the byte is undefined.
#[derive(
Clone,
Debug,
Eq,
PartialEq,
PartialOrd,
Ord,
Hash,
RustcEncodable,
RustcDecodable,
HashStable
)]
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
#[derive(HashStable)]
pub struct UndefMask {
blocks: Vec<Block>,
len: Size,
Expand Down
11 changes: 8 additions & 3 deletions src/librustc/mir/interpret/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ macro_rules! err_exhaust {
};
}

#[macro_export]
macro_rules! err_machine_stop {
($($tt:tt)*) => {
$crate::mir::interpret::InterpError::MachineStop(Box::new($($tt)*))
};
}

// In the `throw_*` macros, avoid `return` to make them work with `try {}`.
#[macro_export]
macro_rules! throw_unsup {
Expand Down Expand Up @@ -79,9 +86,7 @@ macro_rules! throw_exhaust {

#[macro_export]
macro_rules! throw_machine_stop {
($($tt:tt)*) => {
Err::<!, _>($crate::mir::interpret::InterpError::MachineStop(Box::new($($tt)*)))?
};
($($tt:tt)*) => { Err::<!, _>(err_machine_stop!($($tt)*))? };
}

mod allocation;
Expand Down
14 changes: 2 additions & 12 deletions src/librustc/mir/interpret/pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,8 @@ impl<T: layout::HasDataLayout> PointerArithmetic for T {}
///
/// `Pointer` is also generic over the `Tag` associated with each pointer,
/// which is used to do provenance tracking during execution.
#[derive(
Copy,
Clone,
Eq,
PartialEq,
Ord,
PartialOrd,
RustcEncodable,
RustcDecodable,
Hash,
HashStable
)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, RustcEncodable, RustcDecodable, Hash)]
#[derive(HashStable)]
pub struct Pointer<Tag = (), Id = AllocId> {
pub alloc_id: Id,
pub offset: Size,
Expand Down
Loading