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 23 pull requests #58254

Merged
merged 47 commits into from
Feb 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
ea72066
Avoid some bounds checks in binary_heap::{PeekMut,Hole}
lnicola Feb 3, 2019
6413480
libsyntax_pos => 2018
taiki-e Feb 3, 2019
18da195
libproc_macro => 2018
taiki-e Feb 3, 2019
4ae8aba
Transition libtest to 2018 edition
h-michael Feb 3, 2019
3c67873
Excute rustfmt for fixing tidy check
h-michael Feb 3, 2019
27c8dfd
Improve error message and docs for non-UTF-8 bytes in stdio on Windows
abonander Feb 4, 2019
94f121f
libsyntax_ext => 2018
taiki-e Feb 4, 2019
4ca3c7b
update rust-installer from 27dec6c to ccdc47b
h-michael Feb 4, 2019
e957ed9
move librustc to 2018
mark-i-m Feb 5, 2019
80c052b
Do not ICE in codegen given a extern_type static
dlrobertson Feb 5, 2019
f7ed6e1
Make an assert debug-only in `find_constraint_paths_between_regions`.
nnethercote Feb 6, 2019
20022f8
librustc_tsan => 2018
taiki-e Feb 6, 2019
fb0f0bf
librustc_msan => 2018
taiki-e Feb 6, 2019
30fab05
librustc_asan => 2018
taiki-e Feb 6, 2019
3893b2f
libprofiler_builtins => 2018
taiki-e Feb 6, 2019
ea46f5b
librustc_lsan => 2018
taiki-e Feb 6, 2019
d4a60e0
librustc_fs_util => 2018
taiki-e Feb 6, 2019
9f4a11c
librustc_plugin => 2018
taiki-e Feb 6, 2019
edbd8a3
librustc_resolve => 2018
taiki-e Feb 6, 2019
86d8e47
Fix broken grammar in iter::from_fn() docs
sdroege Feb 6, 2019
0d3e178
librustc_apfloat => 2018
taiki-e Feb 6, 2019
a07dc4e
librustc_llvm => 2018
taiki-e Feb 6, 2019
950fe66
librustc_errors => 2018
taiki-e Feb 6, 2019
5db3850
Document the one TyKind that isn't documented
notriddle Feb 6, 2019
9b79370
Rollup merge of #58118 - h-michael:libtest-theme-2018, r=Centril
kennytm Feb 7, 2019
ed500e6
Rollup merge of #58119 - taiki-e:libproc_macro-2018, r=petrochenkov
kennytm Feb 7, 2019
8bc05ba
Rollup merge of #58123 - lnicola:binary-heap-no-bounds-checks, r=sfac…
kennytm Feb 7, 2019
281a26b
Rollup merge of #58124 - taiki-e:libsyntax_pos-2018, r=Centril
kennytm Feb 7, 2019
262b241
Rollup merge of #58133 - taiki-e:libsyntax_ext-2018, r=Centril
kennytm Feb 7, 2019
2be3ca4
Rollup merge of #58136 - abonander:doc-win-stdio-unicode, r=dtolnay
kennytm Feb 7, 2019
4c9bef0
Rollup merge of #58156 - h-michael:update-rust-installer, r=Centril
kennytm Feb 7, 2019
7168ead
Rollup merge of #58192 - dlrobertson:fix_57876, r=oli-obk
kennytm Feb 7, 2019
26b157b
Rollup merge of #58193 - mark-i-m:rustc-2018, r=Centril
kennytm Feb 7, 2019
fab527f
Rollup merge of #58210 - nnethercote:find_outlives-debug_assert, r=ma…
kennytm Feb 7, 2019
2b99c4e
Rollup merge of #58217 - taiki-e:librustc_tsan-2018, r=Centril
kennytm Feb 7, 2019
f3908ad
Rollup merge of #58218 - taiki-e:librustc_msan-2018, r=Centril
kennytm Feb 7, 2019
c1123aa
Rollup merge of #58219 - taiki-e:librustc_asan-2018, r=Centril
kennytm Feb 7, 2019
247da16
Rollup merge of #58220 - taiki-e:libprofiler_builtins-2018, r=Centril
kennytm Feb 7, 2019
d05313d
Rollup merge of #58223 - taiki-e:librustc_lsan-2018, r=Centril
kennytm Feb 7, 2019
c0a135f
Rollup merge of #58225 - taiki-e:librustc_fs_util-2018, r=Centril
kennytm Feb 7, 2019
73458cd
Rollup merge of #58228 - taiki-e:librustc_plugin-2018, r=Centril
kennytm Feb 7, 2019
86c761f
Rollup merge of #58236 - taiki-e:librustc_resolve-2018, r=Centril
kennytm Feb 7, 2019
9b28322
Rollup merge of #58237 - sdroege:docs-its-its, r=SimonSapin
kennytm Feb 7, 2019
5007287
Rollup merge of #58239 - taiki-e:librustc_apfloat-2018, r=Centril
kennytm Feb 7, 2019
207290d
Rollup merge of #58240 - taiki-e:librustc_errors-2018, r=Centril
kennytm Feb 7, 2019
5489d0d
Rollup merge of #58241 - taiki-e:librustc_llvm-2018, r=Centril
kennytm Feb 7, 2019
000daf9
Rollup merge of #58242 - notriddle:patch-3, r=zackmdavis
kennytm Feb 7, 2019
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
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