Skip to content

Commit

Permalink
Auto merge of #58254 - kennytm:rollup, r=kennytm
Browse files Browse the repository at this point in the history
Rollup of 23 pull requests

Successful merges:

 - #58118 (Transition libtest to 2018 edition)
 - #58119 (libproc_macro => 2018)
 - #58123 (Avoid some bounds checks in binary_heap::{PeekMut,Hole})
 - #58124 (libsyntax_pos => 2018)
 - #58133 (libsyntax_ext => 2018)
 - #58136 (Improve error message and docs for non-UTF-8 bytes in stdio on Windows)
 - #58156 (update submodule: rust-installer from 27dec6c to ccdc47b)
 - #58192 (Do not ICE in codegen when using a extern_type static)
 - #58193 (Move librustc to 2018)
 - #58210 (Make an assert debug-only in `find_constraint_paths_between_regions`.)
 - #58217 (librustc_tsan => 2018)
 - #58218 (librustc_msan => 2018)
 - #58219 (librustc_asan => 2018)
 - #58220 (libprofiler_builtins => 2018)
 - #58223 (librustc_lsan => 2018)
 - #58225 (librustc_fs_util => 2018)
 - #58228 (librustc_plugin => 2018)
 - #58236 (librustc_resolve => 2018)
 - #58237 (Fix broken grammar in iter::from_fn() docs)
 - #58239 (librustc_apfloat => 2018)
 - #58240 (librustc_errors => 2018)
 - #58241 (librustc_llvm => 2018)
 - #58242 (Document the one TyKind that isn't documented)

Failed merges:

 - #58185 (Remove images' url to make it work even without internet connection)

r? @ghost
  • Loading branch information
bors committed Feb 7, 2019
2 parents 825f355 + 000daf9 commit 626e74d
Show file tree
Hide file tree
Showing 289 changed files with 2,038 additions and 1,928 deletions.
11 changes: 8 additions & 3 deletions src/liballoc/collections/binary_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,18 @@ impl<T: Ord> Drop for PeekMut<'_, T> {
impl<T: Ord> Deref for PeekMut<'_, T> {
type Target = T;
fn deref(&self) -> &T {
&self.heap.data[0]
debug_assert!(!self.heap.is_empty());
// SAFE: PeekMut is only instantiated for non-empty heaps
unsafe { self.heap.data.get_unchecked(0) }
}
}

#[stable(feature = "binary_heap_peek_mut", since = "1.12.0")]
impl<T: Ord> DerefMut for PeekMut<'_, T> {
fn deref_mut(&mut self) -> &mut T {
&mut self.heap.data[0]
debug_assert!(!self.heap.is_empty());
// SAFE: PeekMut is only instantiated for non-empty heaps
unsafe { self.heap.data.get_unchecked_mut(0) }
}
}

Expand Down Expand Up @@ -865,7 +869,8 @@ impl<'a, T> Hole<'a, T> {
#[inline]
unsafe fn new(data: &'a mut [T], pos: usize) -> Self {
debug_assert!(pos < data.len());
let elt = ptr::read(&data[pos]);
// SAFE: pos should be inside the slice
let elt = ptr::read(data.get_unchecked(pos));
Hole {
data,
elt: ManuallyDrop::new(elt),
Expand Down
6 changes: 2 additions & 4 deletions src/libcore/iter/sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,10 +504,8 @@ pub fn once_with<A, F: FnOnce() -> A>(gen: F) -> OnceWith<F> {
/// [`FusedIterator`]: trait.FusedIterator.html
/// [`Iterator::size_hint`]: trait.Iterator.html#method.size_hint
///
/// The closure can use its its captures and environment
/// to track state across iterations.
/// Depending on how the iterator is used,
/// this may require specifying the `move` keyword on the closure.
/// The closure can use captures and its environment to track state across iterations. Depending on
/// how the iterator is used, this may require specifying the `move` keyword on the closure.
///
/// # Examples
///
Expand Down
1 change: 1 addition & 0 deletions src/libproc_macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
authors = ["The Rust Project Developers"]
name = "proc_macro"
version = "0.0.0"
edition = "2018"

[lib]
path = "lib.rs"
6 changes: 3 additions & 3 deletions src/libproc_macro/bridge/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::ops::{Deref, DerefMut};
use std::slice;

#[repr(C)]
struct Slice<'a, T: 'a> {
struct Slice<'a, T> {
data: &'a [T; 0],
len: usize,
}
Expand Down Expand Up @@ -42,7 +42,7 @@ pub struct Buffer<T: Copy> {
data: *mut T,
len: usize,
capacity: usize,
extend_from_slice: extern "C" fn(Buffer<T>, Slice<T>) -> Buffer<T>,
extend_from_slice: extern "C" fn(Buffer<T>, Slice<'_, T>) -> Buffer<T>,
drop: extern "C" fn(Buffer<T>),
}

Expand Down Expand Up @@ -139,7 +139,7 @@ impl<T: Copy> From<Vec<T>> for Buffer<T> {
}
}

extern "C" fn extend_from_slice<T: Copy>(b: Buffer<T>, xs: Slice<T>) -> Buffer<T> {
extern "C" fn extend_from_slice<T: Copy>(b: Buffer<T>, xs: Slice<'_, T>) -> Buffer<T> {
let mut v = to_vec(b);
v.extend_from_slice(&xs);
Buffer::from(v)
Expand Down
62 changes: 35 additions & 27 deletions src/libproc_macro/bridge/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ macro_rules! define_handles {
impl<S: server::Types> DecodeMut<'_, '_, HandleStore<server::MarkedTypes<S>>>
for Marked<S::$oty, $oty>
{
fn decode(r: &mut Reader, s: &mut HandleStore<server::MarkedTypes<S>>) -> Self {
fn decode(r: &mut Reader<'_>, s: &mut HandleStore<server::MarkedTypes<S>>) -> Self {
s.$oty.take(handle::Handle::decode(r, &mut ()))
}
}
Expand All @@ -80,7 +80,7 @@ macro_rules! define_handles {
impl<S: server::Types> Decode<'_, 's, HandleStore<server::MarkedTypes<S>>>
for &'s Marked<S::$oty, $oty>
{
fn decode(r: &mut Reader, s: &'s HandleStore<server::MarkedTypes<S>>) -> Self {
fn decode(r: &mut Reader<'_>, s: &'s HandleStore<server::MarkedTypes<S>>) -> Self {
&s.$oty[handle::Handle::decode(r, &mut ())]
}
}
Expand All @@ -94,7 +94,10 @@ macro_rules! define_handles {
impl<S: server::Types> DecodeMut<'_, 's, HandleStore<server::MarkedTypes<S>>>
for &'s mut Marked<S::$oty, $oty>
{
fn decode(r: &mut Reader, s: &'s mut HandleStore<server::MarkedTypes<S>>) -> Self {
fn decode(
r: &mut Reader<'_>,
s: &'s mut HandleStore<server::MarkedTypes<S>>
) -> Self {
&mut s.$oty[handle::Handle::decode(r, &mut ())]
}
}
Expand All @@ -108,7 +111,7 @@ macro_rules! define_handles {
}

impl<S> DecodeMut<'_, '_, S> for $oty {
fn decode(r: &mut Reader, s: &mut S) -> Self {
fn decode(r: &mut Reader<'_>, s: &mut S) -> Self {
$oty(handle::Handle::decode(r, s))
}
}
Expand All @@ -130,7 +133,7 @@ macro_rules! define_handles {
impl<S: server::Types> DecodeMut<'_, '_, HandleStore<server::MarkedTypes<S>>>
for Marked<S::$ity, $ity>
{
fn decode(r: &mut Reader, s: &mut HandleStore<server::MarkedTypes<S>>) -> Self {
fn decode(r: &mut Reader<'_>, s: &mut HandleStore<server::MarkedTypes<S>>) -> Self {
s.$ity.copy(handle::Handle::decode(r, &mut ()))
}
}
Expand All @@ -144,7 +147,7 @@ macro_rules! define_handles {
}

impl<S> DecodeMut<'_, '_, S> for $ity {
fn decode(r: &mut Reader, s: &mut S) -> Self {
fn decode(r: &mut Reader<'_>, s: &mut S) -> Self {
$ity(handle::Handle::decode(r, s))
}
}
Expand Down Expand Up @@ -200,7 +203,7 @@ impl Clone for Literal {

// FIXME(eddyb) `Literal` should not expose internal `Debug` impls.
impl fmt::Debug for Literal {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(&self.debug())
}
}
Expand All @@ -212,7 +215,7 @@ impl Clone for SourceFile {
}

impl fmt::Debug for Span {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(&self.debug())
}
}
Expand Down Expand Up @@ -275,7 +278,7 @@ impl BridgeState<'_> {
///
/// N.B., while `f` is running, the thread-local state
/// is `BridgeState::InUse`.
fn with<R>(f: impl FnOnce(&mut BridgeState) -> R) -> R {
fn with<R>(f: impl FnOnce(&mut BridgeState<'_>) -> R) -> R {
BRIDGE_STATE.with(|state| {
state.replace(BridgeState::InUse, |mut state| {
// FIXME(#52812) pass `f` directly to `replace` when `RefMutL` is gone
Expand Down Expand Up @@ -306,7 +309,7 @@ impl Bridge<'_> {
BRIDGE_STATE.with(|state| state.set(BridgeState::Connected(self), f))
}

fn with<R>(f: impl FnOnce(&mut Bridge) -> R) -> R {
fn with<R>(f: impl FnOnce(&mut Bridge<'_>) -> R) -> R {
BridgeState::with(|state| match state {
BridgeState::NotConnected => {
panic!("procedural macro API is used outside of a procedural macro");
Expand All @@ -331,15 +334,15 @@ impl Bridge<'_> {
#[derive(Copy, Clone)]
pub struct Client<F> {
pub(super) get_handle_counters: extern "C" fn() -> &'static HandleCounters,
pub(super) run: extern "C" fn(Bridge, F) -> Buffer<u8>,
pub(super) run: extern "C" fn(Bridge<'_>, F) -> Buffer<u8>,
pub(super) f: F,
}

// FIXME(#53451) public to work around `Cannot create local mono-item` ICE,
// affecting not only the function itself, but also the `BridgeState` `thread_local!`.
pub extern "C" fn __run_expand1(
mut bridge: Bridge,
f: fn(::TokenStream) -> ::TokenStream,
mut bridge: Bridge<'_>,
f: fn(crate::TokenStream) -> crate::TokenStream,
) -> Buffer<u8> {
// The initial `cached_buffer` contains the input.
let mut b = bridge.cached_buffer.take();
Expand All @@ -352,7 +355,7 @@ pub extern "C" fn __run_expand1(
// Put the `cached_buffer` back in the `Bridge`, for requests.
Bridge::with(|bridge| bridge.cached_buffer = b.take());

let output = f(::TokenStream(input)).0;
let output = f(crate::TokenStream(input)).0;

// Take the `cached_buffer` back out, for the output value.
b = Bridge::with(|bridge| bridge.cached_buffer.take());
Expand All @@ -378,8 +381,8 @@ pub extern "C" fn __run_expand1(
b
}

impl Client<fn(::TokenStream) -> ::TokenStream> {
pub const fn expand1(f: fn(::TokenStream) -> ::TokenStream) -> Self {
impl Client<fn(crate::TokenStream) -> crate::TokenStream> {
pub const fn expand1(f: fn(crate::TokenStream) -> crate::TokenStream) -> Self {
Client {
get_handle_counters: HandleCounters::get,
run: __run_expand1,
Expand All @@ -391,8 +394,8 @@ impl Client<fn(::TokenStream) -> ::TokenStream> {
// FIXME(#53451) public to work around `Cannot create local mono-item` ICE,
// affecting not only the function itself, but also the `BridgeState` `thread_local!`.
pub extern "C" fn __run_expand2(
mut bridge: Bridge,
f: fn(::TokenStream, ::TokenStream) -> ::TokenStream,
mut bridge: Bridge<'_>,
f: fn(crate::TokenStream, crate::TokenStream) -> crate::TokenStream,
) -> Buffer<u8> {
// The initial `cached_buffer` contains the input.
let mut b = bridge.cached_buffer.take();
Expand All @@ -406,7 +409,7 @@ pub extern "C" fn __run_expand2(
// Put the `cached_buffer` back in the `Bridge`, for requests.
Bridge::with(|bridge| bridge.cached_buffer = b.take());

let output = f(::TokenStream(input), ::TokenStream(input2)).0;
let output = f(crate::TokenStream(input), crate::TokenStream(input2)).0;

// Take the `cached_buffer` back out, for the output value.
b = Bridge::with(|bridge| bridge.cached_buffer.take());
Expand All @@ -432,8 +435,10 @@ pub extern "C" fn __run_expand2(
b
}

impl Client<fn(::TokenStream, ::TokenStream) -> ::TokenStream> {
pub const fn expand2(f: fn(::TokenStream, ::TokenStream) -> ::TokenStream) -> Self {
impl Client<fn(crate::TokenStream, crate::TokenStream) -> crate::TokenStream> {
pub const fn expand2(
f: fn(crate::TokenStream, crate::TokenStream) -> crate::TokenStream
) -> Self {
Client {
get_handle_counters: HandleCounters::get,
run: __run_expand2,
Expand All @@ -448,25 +453,25 @@ pub enum ProcMacro {
CustomDerive {
trait_name: &'static str,
attributes: &'static [&'static str],
client: Client<fn(::TokenStream) -> ::TokenStream>,
client: Client<fn(crate::TokenStream) -> crate::TokenStream>,
},

Attr {
name: &'static str,
client: Client<fn(::TokenStream, ::TokenStream) -> ::TokenStream>,
client: Client<fn(crate::TokenStream, crate::TokenStream) -> crate::TokenStream>,
},

Bang {
name: &'static str,
client: Client<fn(::TokenStream) -> ::TokenStream>,
client: Client<fn(crate::TokenStream) -> crate::TokenStream>,
},
}

impl ProcMacro {
pub const fn custom_derive(
trait_name: &'static str,
attributes: &'static [&'static str],
expand: fn(::TokenStream) -> ::TokenStream,
expand: fn(crate::TokenStream) -> crate::TokenStream,
) -> Self {
ProcMacro::CustomDerive {
trait_name,
Expand All @@ -477,15 +482,18 @@ impl ProcMacro {

pub const fn attr(
name: &'static str,
expand: fn(::TokenStream, ::TokenStream) -> ::TokenStream,
expand: fn(crate::TokenStream, crate::TokenStream) -> crate::TokenStream,
) -> Self {
ProcMacro::Attr {
name,
client: Client::expand2(expand),
}
}

pub const fn bang(name: &'static str, expand: fn(::TokenStream) -> ::TokenStream) -> Self {
pub const fn bang(
name: &'static str,
expand: fn(crate::TokenStream) -> crate::TokenStream
) -> Self {
ProcMacro::Bang {
name,
client: Client::expand1(expand),
Expand Down
8 changes: 4 additions & 4 deletions src/libproc_macro/bridge/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::panic;
use std::sync::atomic::AtomicUsize;
use std::sync::Once;
use std::thread;
use {Delimiter, Level, LineColumn, Spacing};
use crate::{Delimiter, Level, LineColumn, Spacing};

/// Higher-order macro describing the server RPC API, allowing automatic
/// generation of type-safe Rust APIs, both client-side and server-side.
Expand Down Expand Up @@ -196,9 +196,9 @@ mod scoped_cell;
#[forbid(unsafe_code)]
pub mod server;

use self::buffer::Buffer;
pub use self::rpc::PanicMessage;
use self::rpc::{Decode, DecodeMut, Encode, Reader, Writer};
use buffer::Buffer;
pub use rpc::PanicMessage;
use rpc::{Decode, DecodeMut, Encode, Reader, Writer};

/// An active connection between a server and a client.
/// The server creates the bridge (`Bridge::run_server` in `server.rs`),
Expand Down
18 changes: 9 additions & 9 deletions src/libproc_macro/bridge/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ macro_rules! rpc_encode_decode {
}

impl<S> DecodeMut<'_, '_, S> for $ty {
fn decode(r: &mut Reader, s: &mut S) -> Self {
fn decode(r: &mut Reader<'_>, s: &mut S) -> Self {
let mut byte = 0x80;
let mut v = 0;
let mut shift = 0;
Expand All @@ -61,7 +61,7 @@ macro_rules! rpc_encode_decode {
}

impl<S> DecodeMut<'_, '_, S> for $name {
fn decode(r: &mut Reader, s: &mut S) -> Self {
fn decode(r: &mut Reader<'_>, s: &mut S) -> Self {
$name {
$($field: DecodeMut::decode(r, s)),*
}
Expand Down Expand Up @@ -119,7 +119,7 @@ impl<S> Encode<S> for () {
}

impl<S> DecodeMut<'_, '_, S> for () {
fn decode(_: &mut Reader, _: &mut S) -> Self {}
fn decode(_: &mut Reader<'_>, _: &mut S) -> Self {}
}

impl<S> Encode<S> for u8 {
Expand All @@ -129,7 +129,7 @@ impl<S> Encode<S> for u8 {
}

impl<S> DecodeMut<'_, '_, S> for u8 {
fn decode(r: &mut Reader, _: &mut S) -> Self {
fn decode(r: &mut Reader<'_>, _: &mut S) -> Self {
let x = r[0];
*r = &r[1..];
x
Expand All @@ -146,7 +146,7 @@ impl<S> Encode<S> for bool {
}

impl<S> DecodeMut<'_, '_, S> for bool {
fn decode(r: &mut Reader, s: &mut S) -> Self {
fn decode(r: &mut Reader<'_>, s: &mut S) -> Self {
match u8::decode(r, s) {
0 => false,
1 => true,
Expand All @@ -162,7 +162,7 @@ impl<S> Encode<S> for char {
}

impl<S> DecodeMut<'_, '_, S> for char {
fn decode(r: &mut Reader, s: &mut S) -> Self {
fn decode(r: &mut Reader<'_>, s: &mut S) -> Self {
char::from_u32(u32::decode(r, s)).unwrap()
}
}
Expand All @@ -174,7 +174,7 @@ impl<S> Encode<S> for NonZeroU32 {
}

impl<S> DecodeMut<'_, '_, S> for NonZeroU32 {
fn decode(r: &mut Reader, s: &mut S) -> Self {
fn decode(r: &mut Reader<'_>, s: &mut S) -> Self {
Self::new(u32::decode(r, s)).unwrap()
}
}
Expand Down Expand Up @@ -251,7 +251,7 @@ impl<S> Encode<S> for String {
}

impl<S> DecodeMut<'_, '_, S> for String {
fn decode(r: &mut Reader, s: &mut S) -> Self {
fn decode(r: &mut Reader<'_>, s: &mut S) -> Self {
<&str>::decode(r, s).to_string()
}
}
Expand Down Expand Up @@ -306,7 +306,7 @@ impl<S> Encode<S> for PanicMessage {
}

impl<S> DecodeMut<'_, '_, S> for PanicMessage {
fn decode(r: &mut Reader, s: &mut S) -> Self {
fn decode(r: &mut Reader<'_>, s: &mut S) -> Self {
match Option::<String>::decode(r, s) {
Some(s) => PanicMessage::String(s),
None => PanicMessage::Unknown,
Expand Down
Loading

0 comments on commit 626e74d

Please sign in to comment.