Skip to content

Commit

Permalink
Auto merge of #59937 - Centril:rollup-6pousju, r=Centril
Browse files Browse the repository at this point in the history
Rollup of 18 pull requests

Successful merges:

 - #59612 (Use normal newtype_index macro for MIR dataflows)
 - #59675 (Stabilize the `alloc` crate.)
 - #59708 (Mark variables captured by reference as mutable correctly)
 - #59735 (remove lookup_char_pos_adj)
 - #59747 (Copy book.toml unstable book generator)
 - #59796 (Retire `IsNotConst` naming)
 - #59804 (Clean up jobserver integration)
 - #59818 (Eliminate `FnBox` usages from libstd.)
 - #59830 (Fix links on keyword docs.)
 - #59835 (Re-export NonZero signed variant in std)
 - #59852 (std: Add `{read,write}_vectored` for more types)
 - #59855 (Fix attributes position in type declaration)
 - #59858 (Make duplicate matcher bindings a hard error)
 - #59879 (Use SecRandomCopyBytes instead of /dev/urandom on MacOS)
 - #59899 (In `-Zprint-type-size` output, sort enum variants by size.)
 - #59912 (MaybeUninit: remove deprecated functions)
 - #59925 (Fix paste error in split_ascii_whitespace docs.)
 - #59930 (Exclude some copies of old book editions from search engines)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Apr 13, 2019
2 parents 896c3a5 + b613fd2 commit f1b5f80
Show file tree
Hide file tree
Showing 102 changed files with 617 additions and 577 deletions.
8 changes: 8 additions & 0 deletions src/doc/robots.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,11 @@ Disallow: /1.0.0-beta.2/
Disallow: /1.0.0-beta.3/
Disallow: /1.0.0-beta.4/
Disallow: /1.0.0-beta.5/
Disallow: /book/first-edition/
Disallow: /book/second-edition/
Disallow: /stable/book/first-edition/
Disallow: /stable/book/second-edition/
Disallow: /beta/book/first-edition/
Disallow: /beta/book/second-edition/
Disallow: /nightly/book/first-edition/
Disallow: /nightly/book/second-edition/
1 change: 1 addition & 0 deletions src/doc/unstable-book/book.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[book]
title = "The Rust Unstable Book"
author = "The Rust Community"
5 changes: 1 addition & 4 deletions src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@
//! default global allocator. It is not compatible with the libc allocator API.

#![allow(unused_attributes)]
#![unstable(feature = "alloc",
reason = "this library is unlikely to be stabilized in its current \
form or name",
issue = "27783")]
#![stable(feature = "alloc", since = "1.36.0")]
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/",
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))]
Expand Down
1 change: 0 additions & 1 deletion src/liballoc/prelude/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
//!
//! ```
//! # #![allow(unused_imports)]
//! # #![feature(alloc)]
//! #![feature(alloc_prelude)]
//! extern crate alloc;
//! use alloc::prelude::v1::*;
Expand Down
4 changes: 2 additions & 2 deletions src/liballoc/raw_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ impl<T, A: Alloc> RawVec<T, A> {
/// # Examples
///
/// ```
/// # #![feature(alloc, raw_vec_internals)]
/// # #![feature(raw_vec_internals)]
/// # extern crate alloc;
/// # use std::ptr;
/// # use alloc::raw_vec::RawVec;
Expand Down Expand Up @@ -460,7 +460,7 @@ impl<T, A: Alloc> RawVec<T, A> {
/// # Examples
///
/// ```
/// # #![feature(alloc, raw_vec_internals)]
/// # #![feature(raw_vec_internals)]
/// # extern crate alloc;
/// # use std::ptr;
/// # use alloc::raw_vec::RawVec;
Expand Down
1 change: 0 additions & 1 deletion src/libarena/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#![deny(rust_2018_idioms)]
#![cfg_attr(not(stage0), deny(internal))]

#![feature(alloc)]
#![feature(core_intrinsics)]
#![feature(dropck_eyepatch)]
#![feature(raw_vec_internals)]
Expand Down
34 changes: 0 additions & 34 deletions src/libcore/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1152,15 +1152,6 @@ impl<T> MaybeUninit<T> {
MaybeUninit { uninit: () }
}

/// Deprecated before stabilization.
#[unstable(feature = "maybe_uninit", issue = "53491")]
#[inline(always)]
// FIXME: still used by stdsimd
// #[rustc_deprecated(since = "1.35.0", reason = "use `uninit` instead")]
pub const fn uninitialized() -> MaybeUninit<T> {
Self::uninit()
}

/// Creates a new `MaybeUninit<T>` in an uninitialized state, with the memory being
/// filled with `0` bytes. It depends on `T` whether that already makes for
/// proper initialization. For example, `MaybeUninit<usize>::zeroed()` is initialized,
Expand Down Expand Up @@ -1221,14 +1212,6 @@ impl<T> MaybeUninit<T> {
}
}

/// Deprecated before stabilization.
#[unstable(feature = "maybe_uninit", issue = "53491")]
#[inline(always)]
#[rustc_deprecated(since = "1.35.0", reason = "use `write` instead")]
pub fn set(&mut self, val: T) -> &mut T {
self.write(val)
}

/// Gets a pointer to the contained value. Reading from this pointer or turning it
/// into a reference is undefined behavior unless the `MaybeUninit<T>` is initialized.
///
Expand Down Expand Up @@ -1346,15 +1329,6 @@ impl<T> MaybeUninit<T> {
ManuallyDrop::into_inner(self.value)
}

/// Deprecated before stabilization.
#[unstable(feature = "maybe_uninit", issue = "53491")]
#[inline(always)]
// FIXME: still used by stdsimd
// #[rustc_deprecated(since = "1.35.0", reason = "use `assume_init` instead")]
pub unsafe fn into_initialized(self) -> T {
self.assume_init()
}

/// Reads the value from the `MaybeUninit<T>` container. The resulting `T` is subject
/// to the usual drop handling.
///
Expand Down Expand Up @@ -1417,14 +1391,6 @@ impl<T> MaybeUninit<T> {
self.as_ptr().read()
}

/// Deprecated before stabilization.
#[unstable(feature = "maybe_uninit", issue = "53491")]
#[inline(always)]
#[rustc_deprecated(since = "1.35.0", reason = "use `read` instead")]
pub unsafe fn read_initialized(&self) -> T {
self.read()
}

/// Gets a reference to the contained value.
///
/// # Safety
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2712,7 +2712,7 @@ impl str {
/// All kinds of ASCII whitespace are considered:
///
/// ```
/// let mut iter = " Mary had\ta little \n\t lamb".split_whitespace();
/// let mut iter = " Mary had\ta little \n\t lamb".split_ascii_whitespace();
/// assert_eq!(Some("Mary"), iter.next());
/// assert_eq!(Some("had"), iter.next());
/// assert_eq!(Some("a"), iter.next());
Expand Down
2 changes: 0 additions & 2 deletions src/libpanic_unwind/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

#![deny(rust_2018_idioms)]

#![feature(allocator_api)]
#![feature(alloc)]
#![feature(core_intrinsics)]
#![feature(lang_items)]
#![feature(libc)]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
}

fn explain_span(self, heading: &str, span: Span) -> (String, Option<Span>) {
let lo = self.sess.source_map().lookup_char_pos_adj(span.lo());
let lo = self.sess.source_map().lookup_char_pos(span.lo());
(
format!("the {} at {}:{}", heading, lo.line, lo.col.to_usize() + 1),
Some(span),
Expand Down
7 changes: 0 additions & 7 deletions src/librustc/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,12 +352,6 @@ declare_lint! {
"outlives requirements can be inferred"
}

declare_lint! {
pub DUPLICATE_MATCHER_BINDING_NAME,
Deny,
"duplicate macro matcher binding name"
}

/// Some lints that are buffered from `libsyntax`. See `syntax::early_buffered_lints`.
pub mod parser {
declare_lint! {
Expand Down Expand Up @@ -462,7 +456,6 @@ declare_lint_pass! {
DEPRECATED_IN_FUTURE,
AMBIGUOUS_ASSOCIATED_ITEMS,
NESTED_IMPL_TRAIT,
DUPLICATE_MATCHER_BINDING_NAME,
MUTABLE_BORROW_RESERVATION_CONFLICT,
]
}
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/lint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use rustc_data_structures::sync::{self, Lrc};
use crate::hir::def_id::{CrateNum, LOCAL_CRATE};
use crate::hir::intravisit;
use crate::hir;
use crate::lint::builtin::{BuiltinLintDiagnostics, DUPLICATE_MATCHER_BINDING_NAME};
use crate::lint::builtin::BuiltinLintDiagnostics;
use crate::lint::builtin::parser::{QUESTION_MARK_MACRO_SEP, ILL_FORMED_ATTRIBUTE_INPUT};
use crate::session::{Session, DiagnosticMessageId};
use crate::ty::TyCtxt;
Expand Down Expand Up @@ -82,7 +82,6 @@ impl Lint {
match lint_id {
BufferedEarlyLintId::QuestionMarkMacroSep => QUESTION_MARK_MACRO_SEP,
BufferedEarlyLintId::IllFormedAttributeInput => ILL_FORMED_ATTRIBUTE_INPUT,
BufferedEarlyLintId::DuplicateMacroMatcherBindingName => DUPLICATE_MATCHER_BINDING_NAME,
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/mir/interpret/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ impl<'tcx> fmt::Display for FrameInfo<'tcx> {
write!(f, "inside call to `{}`", self.instance)?;
}
if !self.call_site.is_dummy() {
let lo = tcx.sess.source_map().lookup_char_pos_adj(self.call_site.lo());
write!(f, " at {}:{}:{}", lo.filename, lo.line, lo.col.to_usize() + 1)?;
let lo = tcx.sess.source_map().lookup_char_pos(self.call_site.lo());
write!(f, " at {}:{}:{}", lo.file.name, lo.line, lo.col.to_usize() + 1)?;
}
Ok(())
})
Expand Down
8 changes: 7 additions & 1 deletion src/librustc/session/code_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ impl CodeStats {
overall_size: Size,
packed: bool,
opt_discr_size: Option<Size>,
variants: Vec<VariantInfo>) {
mut variants: Vec<VariantInfo>) {
// Sort variants so the largest ones are shown first. A stable sort is
// used here so that source code order is preserved for all variants
// that have the same size.
variants.sort_by(|info1, info2| {
info2.size.cmp(&info1.size)
});
let info = TypeSizeInfo {
kind,
type_description: type_desc.to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_data_structures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ crate-type = ["dylib"]
[dependencies]
ena = "0.13"
log = "0.4"
jobserver_crate = { version = "0.1", package = "jobserver" }
jobserver_crate = { version = "0.1.13", package = "jobserver" }
lazy_static = "1"
rustc_cratesio_shim = { path = "../librustc_cratesio_shim" }
serialize = { path = "../libserialize" }
Expand Down
128 changes: 7 additions & 121 deletions src/librustc_data_structures/jobserver.rs
Original file line number Diff line number Diff line change
@@ -1,89 +1,5 @@
use jobserver_crate::{Client, HelperThread, Acquired};
use jobserver_crate::Client;
use lazy_static::lazy_static;
use std::sync::{Condvar, Arc, Mutex};
use std::mem;

#[derive(Default)]
struct LockedProxyData {
/// The number of free thread tokens, this may include the implicit token given to the process
free: usize,

/// The number of threads waiting for a token
waiters: usize,

/// The number of tokens we requested from the server
requested: usize,

/// Stored tokens which will be dropped when we no longer need them
tokens: Vec<Acquired>,
}

impl LockedProxyData {
fn request_token(&mut self, thread: &Mutex<HelperThread>) {
self.requested += 1;
thread.lock().unwrap().request_token();
}

fn release_token(&mut self, cond_var: &Condvar) {
if self.waiters > 0 {
self.free += 1;
cond_var.notify_one();
} else {
if self.tokens.is_empty() {
// We are returning the implicit token
self.free += 1;
} else {
// Return a real token to the server
self.tokens.pop().unwrap();
}
}
}

fn take_token(&mut self, thread: &Mutex<HelperThread>) -> bool {
if self.free > 0 {
self.free -= 1;
self.waiters -= 1;

// We stole some token reqested by someone else
// Request another one
if self.requested + self.free < self.waiters {
self.request_token(thread);
}

true
} else {
false
}
}

fn new_requested_token(&mut self, token: Acquired, cond_var: &Condvar) {
self.requested -= 1;

// Does anything need this token?
if self.waiters > 0 {
self.free += 1;
self.tokens.push(token);
cond_var.notify_one();
} else {
// Otherwise we'll just drop it
mem::drop(token);
}
}
}

#[derive(Default)]
struct ProxyData {
lock: Mutex<LockedProxyData>,
cond_var: Condvar,
}

/// A helper type which makes managing jobserver tokens easier.
/// It also allows you to treat the implicit token given to the process
/// in the same manner as requested tokens.
struct Proxy {
thread: Mutex<HelperThread>,
data: Arc<ProxyData>,
}

lazy_static! {
// We can only call `from_env` once per process
Expand All @@ -105,52 +21,22 @@ lazy_static! {
// per-process.
static ref GLOBAL_CLIENT: Client = unsafe {
Client::from_env().unwrap_or_else(|| {
Client::new(32).expect("failed to create jobserver")
let client = Client::new(32).expect("failed to create jobserver");
// Acquire a token for the main thread which we can release later
client.acquire_raw().ok();
client
})
};

static ref GLOBAL_PROXY: Proxy = {
let data = Arc::new(ProxyData::default());

Proxy {
data: data.clone(),
thread: Mutex::new(client().into_helper_thread(move |token| {
data.lock.lock().unwrap().new_requested_token(token.unwrap(), &data.cond_var);
}).unwrap()),
}
};
}

pub fn client() -> Client {
GLOBAL_CLIENT.clone()
}

pub fn acquire_thread() {
GLOBAL_PROXY.acquire_token();
GLOBAL_CLIENT.acquire_raw().ok();
}

pub fn release_thread() {
GLOBAL_PROXY.release_token();
}

impl Proxy {
fn release_token(&self) {
self.data.lock.lock().unwrap().release_token(&self.data.cond_var);
}

fn acquire_token(&self) {
let mut data = self.data.lock.lock().unwrap();
data.waiters += 1;
if data.take_token(&self.thread) {
return;
}
// Request a token for us
data.request_token(&self.thread);
loop {
data = self.data.cond_var.wait(data).unwrap();
if data.take_token(&self.thread) {
return;
}
}
}
GLOBAL_CLIENT.release_raw().ok();
}
7 changes: 2 additions & 5 deletions src/librustc_lint/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,11 +428,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
reference: "issue #57644 <https://github.com/rust-lang/rust/issues/57644>",
edition: None,
},
FutureIncompatibleInfo {
id: LintId::of(DUPLICATE_MATCHER_BINDING_NAME),
reference: "issue #57593 <https://github.com/rust-lang/rust/issues/57593>",
edition: None,
},
FutureIncompatibleInfo {
id: LintId::of(NESTED_IMPL_TRAIT),
reference: "issue #59014 <https://github.com/rust-lang/rust/issues/59014>",
Expand Down Expand Up @@ -494,6 +489,8 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
"no longer a warning, #[no_mangle] statics always exported");
store.register_removed("bad_repr",
"replaced with a generic attribute input check");
store.register_removed("duplicate_matcher_binding_name",
"converted into hard error, see https://github.com/rust-lang/rust/issues/57742");
}

pub fn register_internals(store: &mut lint::LintStore, sess: Option<&Session>) {
Expand Down
Loading

0 comments on commit f1b5f80

Please sign in to comment.