diff --git a/Cargo.lock b/Cargo.lock index a7b83f87b191b..234485afa809f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1599,12 +1599,6 @@ dependencies = [ [[package]] name = "proc_macro" version = "0.0.0" -dependencies = [ - "rustc_data_structures 0.0.0", - "rustc_errors 0.0.0", - "syntax 0.0.0", - "syntax_pos 0.0.0", -] [[package]] name = "profiler_builtins" @@ -1933,7 +1927,6 @@ dependencies = [ "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "polonius-engine 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "proc_macro 0.0.0", "rustc-rayon 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-rayon-core 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_apfloat 0.0.0", @@ -2351,7 +2344,6 @@ dependencies = [ "flate2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "proc_macro 0.0.0", "rustc 0.0.0", "rustc_data_structures 0.0.0", "rustc_errors 0.0.0", @@ -2890,7 +2882,6 @@ version = "0.0.0" dependencies = [ "fmt_macros 0.0.0", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "proc_macro 0.0.0", "rustc_data_structures 0.0.0", "rustc_errors 0.0.0", "rustc_target 0.0.0", @@ -2980,6 +2971,7 @@ name = "test" version = "0.0.0" dependencies = [ "getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "proc_macro 0.0.0", "term 0.0.0", ] diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index afe1b4c42eaef..d18a48e5d2270 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -129,10 +129,12 @@ fn main() { // Help the libc crate compile by assisting it in finding the MUSL // native libraries. if let Some(s) = env::var_os("MUSL_ROOT") { - let mut root = OsString::from("native="); - root.push(&s); - root.push("/lib"); - cmd.arg("-L").arg(&root); + if target.contains("musl") { + let mut root = OsString::from("native="); + root.push(&s); + root.push("/lib"); + cmd.arg("-L").arg(&root); + } } // Override linker if necessary. diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 900f336ef8cdc..079fdee7e8626 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -390,7 +390,6 @@ impl<'a> Builder<'a> { test::RunPassFullDeps, test::RunFailFullDeps, test::CompileFailFullDeps, - test::IncrementalFullDeps, test::Rustdoc, test::Pretty, test::RunPassPretty, diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index e55773011df8e..e6c260a1426f9 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -839,12 +839,6 @@ host_test!(CompileFailFullDeps { suite: "compile-fail-fulldeps" }); -host_test!(IncrementalFullDeps { - path: "src/test/incremental-fulldeps", - mode: "incremental", - suite: "incremental-fulldeps" -}); - host_test!(Rustdoc { path: "src/test/rustdoc", mode: "rustdoc", @@ -982,6 +976,11 @@ impl Step for Compiletest { builder.ensure(compile::Std { compiler, target: compiler.host }); } + // HACK(eddyb) ensure that `libproc_macro` is available on the host. + builder.ensure(compile::Test { compiler, target: compiler.host }); + // Also provide `rust_test_helpers` for the host. + builder.ensure(native::TestHelpers { target: compiler.host }); + builder.ensure(native::TestHelpers { target }); builder.ensure(RemoteCopyLibs { compiler, target }); @@ -1049,7 +1048,11 @@ impl Step for Compiletest { cmd.arg("--linker").arg(linker); } - let hostflags = flags.clone(); + let mut hostflags = flags.clone(); + hostflags.push(format!( + "-Lnative={}", + builder.test_helpers_out(compiler.host).display() + )); cmd.arg("--host-rustcflags").arg(hostflags.join(" ")); let mut targetflags = flags; diff --git a/src/libproc_macro/Cargo.toml b/src/libproc_macro/Cargo.toml index c1b2622520b11..f903f79f9afc0 100644 --- a/src/libproc_macro/Cargo.toml +++ b/src/libproc_macro/Cargo.toml @@ -5,10 +5,3 @@ version = "0.0.0" [lib] path = "lib.rs" -crate-type = ["dylib"] - -[dependencies] -syntax = { path = "../libsyntax" } -syntax_pos = { path = "../libsyntax_pos" } -rustc_errors = { path = "../librustc_errors" } -rustc_data_structures = { path = "../librustc_data_structures" } diff --git a/src/libproc_macro/bridge/buffer.rs b/src/libproc_macro/bridge/buffer.rs new file mode 100644 index 0000000000000..f228841c1e80f --- /dev/null +++ b/src/libproc_macro/bridge/buffer.rs @@ -0,0 +1,170 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Buffer management for same-process client<->server communication. + +use std::io::{self, Write}; +use std::mem; +use std::ops::{Deref, DerefMut}; +use std::slice; + +#[repr(C)] +struct Slice<'a, T: 'a> { + data: &'a [T; 0], + len: usize, +} + +unsafe impl<'a, T: Sync> Sync for Slice<'a, T> {} +unsafe impl<'a, T: Sync> Send for Slice<'a, T> {} + +impl Copy for Slice<'a, T> {} +impl Clone for Slice<'a, T> { + fn clone(&self) -> Self { + *self + } +} + +impl From<&'a [T]> for Slice<'a, T> { + fn from(xs: &'a [T]) -> Self { + Slice { + data: unsafe { &*(xs.as_ptr() as *const [T; 0]) }, + len: xs.len(), + } + } +} + +impl Deref for Slice<'a, T> { + type Target = [T]; + fn deref(&self) -> &[T] { + unsafe { slice::from_raw_parts(self.data.as_ptr(), self.len) } + } +} + +#[repr(C)] +pub struct Buffer { + data: *mut T, + len: usize, + capacity: usize, + extend_from_slice: extern "C" fn(Buffer, Slice) -> Buffer, + drop: extern "C" fn(Buffer), +} + +unsafe impl Sync for Buffer {} +unsafe impl Send for Buffer {} + +impl Default for Buffer { + fn default() -> Self { + Self::from(vec![]) + } +} + +impl Deref for Buffer { + type Target = [T]; + fn deref(&self) -> &[T] { + unsafe { slice::from_raw_parts(self.data as *const T, self.len) } + } +} + +impl DerefMut for Buffer { + fn deref_mut(&mut self) -> &mut [T] { + unsafe { slice::from_raw_parts_mut(self.data, self.len) } + } +} + +impl Buffer { + pub(super) fn new() -> Self { + Self::default() + } + + pub(super) fn clear(&mut self) { + self.len = 0; + } + + pub(super) fn take(&mut self) -> Self { + mem::replace(self, Self::default()) + } + + pub(super) fn extend_from_slice(&mut self, xs: &[T]) { + // Fast path to avoid going through an FFI call. + if let Some(final_len) = self.len.checked_add(xs.len()) { + if final_len <= self.capacity { + let dst = unsafe { slice::from_raw_parts_mut(self.data, self.capacity) }; + dst[self.len..][..xs.len()].copy_from_slice(xs); + self.len = final_len; + return; + } + } + let b = self.take(); + *self = (b.extend_from_slice)(b, Slice::from(xs)); + } +} + +impl Write for Buffer { + fn write(&mut self, xs: &[u8]) -> io::Result { + self.extend_from_slice(xs); + Ok(xs.len()) + } + + fn write_all(&mut self, xs: &[u8]) -> io::Result<()> { + self.extend_from_slice(xs); + Ok(()) + } + + fn flush(&mut self) -> io::Result<()> { + Ok(()) + } +} + +impl Drop for Buffer { + fn drop(&mut self) { + let b = self.take(); + (b.drop)(b); + } +} + +impl From> for Buffer { + fn from(mut v: Vec) -> Self { + let (data, len, capacity) = (v.as_mut_ptr(), v.len(), v.capacity()); + mem::forget(v); + + // This utility function is nested in here because it can *only* + // be safely called on `Buffer`s created by *this* `proc_macro`. + fn to_vec(b: Buffer) -> Vec { + unsafe { + let Buffer { + data, + len, + capacity, + .. + } = b; + mem::forget(b); + Vec::from_raw_parts(data, len, capacity) + } + } + + extern "C" fn extend_from_slice(b: Buffer, xs: Slice) -> Buffer { + let mut v = to_vec(b); + v.extend_from_slice(&xs); + Buffer::from(v) + } + + extern "C" fn drop(b: Buffer) { + mem::drop(to_vec(b)); + } + + Buffer { + data, + len, + capacity, + extend_from_slice, + drop, + } + } +} diff --git a/src/libproc_macro/bridge/client.rs b/src/libproc_macro/bridge/client.rs new file mode 100644 index 0000000000000..ed27df4496256 --- /dev/null +++ b/src/libproc_macro/bridge/client.rs @@ -0,0 +1,504 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Client-side types. + +use super::*; + +macro_rules! define_handles { + ( + 'owned: $($oty:ident,)* + 'interned: $($ity:ident,)* + ) => { + #[repr(C)] + #[allow(non_snake_case)] + pub struct HandleCounters { + $($oty: AtomicUsize,)* + $($ity: AtomicUsize,)* + } + + impl HandleCounters { + // FIXME(#53451) public to work around `Cannot create local mono-item` ICE. + pub extern "C" fn get() -> &'static Self { + static COUNTERS: HandleCounters = HandleCounters { + $($oty: AtomicUsize::new(1),)* + $($ity: AtomicUsize::new(1),)* + }; + &COUNTERS + } + } + + // FIXME(eddyb) generate the definition of `HandleStore` in `server.rs`. + #[repr(C)] + #[allow(non_snake_case)] + pub(super) struct HandleStore { + $($oty: handle::OwnedStore,)* + $($ity: handle::InternedStore,)* + } + + impl HandleStore { + pub(super) fn new(handle_counters: &'static HandleCounters) -> Self { + HandleStore { + $($oty: handle::OwnedStore::new(&handle_counters.$oty),)* + $($ity: handle::InternedStore::new(&handle_counters.$ity),)* + } + } + } + + $( + #[repr(C)] + pub(crate) struct $oty(handle::Handle); + impl !Send for $oty {} + impl !Sync for $oty {} + + // Forward `Drop::drop` to the inherent `drop` method. + impl Drop for $oty { + fn drop(&mut self) { + $oty(self.0).drop(); + } + } + + impl Encode for $oty { + fn encode(self, w: &mut Writer, s: &mut S) { + let handle = self.0; + mem::forget(self); + handle.encode(w, s); + } + } + + impl DecodeMut<'_, '_, HandleStore>> + for Marked + { + fn decode(r: &mut Reader, s: &mut HandleStore>) -> Self { + s.$oty.take(handle::Handle::decode(r, &mut ())) + } + } + + impl Encode for &$oty { + fn encode(self, w: &mut Writer, s: &mut S) { + self.0.encode(w, s); + } + } + + impl Decode<'_, 's, HandleStore>> + for &'s Marked + { + fn decode(r: &mut Reader, s: &'s HandleStore>) -> Self { + &s.$oty[handle::Handle::decode(r, &mut ())] + } + } + + impl Encode for &mut $oty { + fn encode(self, w: &mut Writer, s: &mut S) { + self.0.encode(w, s); + } + } + + impl DecodeMut<'_, 's, HandleStore>> + for &'s mut Marked + { + fn decode(r: &mut Reader, s: &'s mut HandleStore>) -> Self { + &mut s.$oty[handle::Handle::decode(r, &mut ())] + } + } + + impl Encode>> + for Marked + { + fn encode(self, w: &mut Writer, s: &mut HandleStore>) { + s.$oty.alloc(self).encode(w, s); + } + } + + impl DecodeMut<'_, '_, S> for $oty { + fn decode(r: &mut Reader, s: &mut S) -> Self { + $oty(handle::Handle::decode(r, s)) + } + } + )* + + $( + #[repr(C)] + #[derive(Copy, Clone, PartialEq, Eq, Hash)] + pub(crate) struct $ity(handle::Handle); + impl !Send for $ity {} + impl !Sync for $ity {} + + impl Encode for $ity { + fn encode(self, w: &mut Writer, s: &mut S) { + self.0.encode(w, s); + } + } + + impl DecodeMut<'_, '_, HandleStore>> + for Marked + { + fn decode(r: &mut Reader, s: &mut HandleStore>) -> Self { + s.$ity.copy(handle::Handle::decode(r, &mut ())) + } + } + + impl Encode>> + for Marked + { + fn encode(self, w: &mut Writer, s: &mut HandleStore>) { + s.$ity.alloc(self).encode(w, s); + } + } + + impl DecodeMut<'_, '_, S> for $ity { + fn decode(r: &mut Reader, s: &mut S) -> Self { + $ity(handle::Handle::decode(r, s)) + } + } + )* + } +} +define_handles! { + 'owned: + TokenStream, + TokenStreamBuilder, + TokenStreamIter, + Group, + Literal, + SourceFile, + MultiSpan, + Diagnostic, + + 'interned: + Punct, + Ident, + Span, +} + +// FIXME(eddyb) generate these impls by pattern-matching on the +// names of methods - also could use the presence of `fn drop` +// to distinguish between 'owned and 'interned, above. +// Alternatively, special 'modes" could be listed of types in with_api +// instead of pattern matching on methods, here and in server decl. + +impl Clone for TokenStream { + fn clone(&self) -> Self { + self.clone() + } +} + +impl Clone for TokenStreamIter { + fn clone(&self) -> Self { + self.clone() + } +} + +impl Clone for Group { + fn clone(&self) -> Self { + self.clone() + } +} + +impl Clone for Literal { + fn clone(&self) -> Self { + self.clone() + } +} + +// FIXME(eddyb) `Literal` should not expose internal `Debug` impls. +impl fmt::Debug for Literal { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_str(&self.debug()) + } +} + +impl Clone for SourceFile { + fn clone(&self) -> Self { + self.clone() + } +} + +impl fmt::Debug for Span { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_str(&self.debug()) + } +} + +macro_rules! define_client_side { + ($($name:ident { + $(fn $method:ident($($arg:ident: $arg_ty:ty),* $(,)*) $(-> $ret_ty:ty)*;)* + }),* $(,)*) => { + $(impl $name { + $(pub(crate) fn $method($($arg: $arg_ty),*) $(-> $ret_ty)* { + Bridge::with(|bridge| { + let mut b = bridge.cached_buffer.take(); + + b.clear(); + api_tags::Method::$name(api_tags::$name::$method).encode(&mut b, &mut ()); + reverse_encode!(b; $($arg),*); + + b = bridge.dispatch.call(b); + + let r = Result::<_, PanicMessage>::decode(&mut &b[..], &mut ()); + + bridge.cached_buffer = b; + + r.unwrap_or_else(|e| panic::resume_unwind(e.into())) + }) + })* + })* + } +} +with_api!(self, self, define_client_side); + +enum BridgeState<'a> { + /// No server is currently connected to this client. + NotConnected, + + /// A server is connected and available for requests. + Connected(Bridge<'a>), + + /// Access to the bridge is being exclusively acquired + /// (e.g. during `BridgeState::with`). + InUse, +} + +enum BridgeStateL {} + +impl<'a> scoped_cell::ApplyL<'a> for BridgeStateL { + type Out = BridgeState<'a>; +} + +thread_local! { + static BRIDGE_STATE: scoped_cell::ScopedCell = + scoped_cell::ScopedCell::new(BridgeState::NotConnected); +} + +impl BridgeState<'_> { + /// Take exclusive control of the thread-local + /// `BridgeState`, and pass it to `f`, mutably. + /// The state will be restored after `f` exits, even + /// by panic, including modifications made to it by `f`. + /// + /// NB: while `f` is running, the thread-local state + /// is `BridgeState::InUse`. + fn with(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 + f(&mut *state) + }) + }) + } +} + +impl Bridge<'_> { + fn enter(self, f: impl FnOnce() -> R) -> R { + // Hide the default panic output within `proc_macro` expansions. + // NB. the server can't do this because it may use a different libstd. + static HIDE_PANICS_DURING_EXPANSION: Once = Once::new(); + HIDE_PANICS_DURING_EXPANSION.call_once(|| { + let prev = panic::take_hook(); + panic::set_hook(Box::new(move |info| { + let hide = BridgeState::with(|state| match state { + BridgeState::NotConnected => false, + BridgeState::Connected(_) | BridgeState::InUse => true, + }); + if !hide { + prev(info) + } + })); + }); + + BRIDGE_STATE.with(|state| state.set(BridgeState::Connected(self), f)) + } + + fn with(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"); + } + BridgeState::InUse => { + panic!("procedural macro API is used while it's already in use"); + } + BridgeState::Connected(bridge) => f(bridge), + }) + } +} + +/// A client-side "global object" (usually a function pointer), +/// which may be using a different `proc_macro` from the one +/// used by the server, but can be interacted with compatibly. +/// +/// NB: `F` must have FFI-friendly memory layout (e.g. a pointer). +/// The call ABI of function pointers used for `F` doesn't +/// need to match between server and client, since it's only +/// passed between them and (eventually) called by the client. +#[repr(C)] +#[derive(Copy, Clone)] +pub struct Client { + pub(super) get_handle_counters: extern "C" fn() -> &'static HandleCounters, + pub(super) run: extern "C" fn(Bridge, F) -> Buffer, + 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, +) -> Buffer { + // The initial `cached_buffer` contains the input. + let mut b = bridge.cached_buffer.take(); + + panic::catch_unwind(panic::AssertUnwindSafe(|| { + bridge.enter(|| { + let reader = &mut &b[..]; + let input = TokenStream::decode(reader, &mut ()); + + // Put the `cached_buffer` back in the `Bridge`, for requests. + Bridge::with(|bridge| bridge.cached_buffer = b.take()); + + let output = f(::TokenStream(input)).0; + + // Take the `cached_buffer` back out, for the output value. + b = Bridge::with(|bridge| bridge.cached_buffer.take()); + + // HACK(eddyb) Separate encoding a success value (`Ok(output)`) + // from encoding a panic (`Err(e: PanicMessage)`) to avoid + // having handles outside the `bridge.enter(|| ...)` scope, and + // to catch panics that could happen while encoding the success. + // + // Note that panics should be impossible beyond this point, but + // this is defensively trying to avoid any accidental panicking + // reaching the `extern "C"` (which should `abort` but may not + // at the moment, so this is also potentially preventing UB). + b.clear(); + Ok::<_, ()>(output).encode(&mut b, &mut ()); + }) + })) + .map_err(PanicMessage::from) + .unwrap_or_else(|e| { + b.clear(); + Err::<(), _>(e).encode(&mut b, &mut ()); + }); + b +} + +impl Client ::TokenStream> { + pub const fn expand1(f: fn(::TokenStream) -> ::TokenStream) -> Self { + Client { + get_handle_counters: HandleCounters::get, + run: __run_expand1, + 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_expand2( + mut bridge: Bridge, + f: fn(::TokenStream, ::TokenStream) -> ::TokenStream, +) -> Buffer { + // The initial `cached_buffer` contains the input. + let mut b = bridge.cached_buffer.take(); + + panic::catch_unwind(panic::AssertUnwindSafe(|| { + bridge.enter(|| { + let reader = &mut &b[..]; + let input = TokenStream::decode(reader, &mut ()); + let input2 = TokenStream::decode(reader, &mut ()); + + // 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; + + // Take the `cached_buffer` back out, for the output value. + b = Bridge::with(|bridge| bridge.cached_buffer.take()); + + // HACK(eddyb) Separate encoding a success value (`Ok(output)`) + // from encoding a panic (`Err(e: PanicMessage)`) to avoid + // having handles outside the `bridge.enter(|| ...)` scope, and + // to catch panics that could happen while encoding the success. + // + // Note that panics should be impossible beyond this point, but + // this is defensively trying to avoid any accidental panicking + // reaching the `extern "C"` (which should `abort` but may not + // at the moment, so this is also potentially preventing UB). + b.clear(); + Ok::<_, ()>(output).encode(&mut b, &mut ()); + }) + })) + .map_err(PanicMessage::from) + .unwrap_or_else(|e| { + b.clear(); + Err::<(), _>(e).encode(&mut b, &mut ()); + }); + b +} + +impl Client ::TokenStream> { + pub const fn expand2(f: fn(::TokenStream, ::TokenStream) -> ::TokenStream) -> Self { + Client { + get_handle_counters: HandleCounters::get, + run: __run_expand2, + f, + } + } +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub enum ProcMacro { + CustomDerive { + trait_name: &'static str, + attributes: &'static [&'static str], + client: Client ::TokenStream>, + }, + + Attr { + name: &'static str, + client: Client ::TokenStream>, + }, + + Bang { + name: &'static str, + client: Client ::TokenStream>, + }, +} + +impl ProcMacro { + pub const fn custom_derive( + trait_name: &'static str, + attributes: &'static [&'static str], + expand: fn(::TokenStream) -> ::TokenStream, + ) -> Self { + ProcMacro::CustomDerive { + trait_name, + attributes, + client: Client::expand1(expand), + } + } + + pub const fn attr( + name: &'static str, + expand: fn(::TokenStream, ::TokenStream) -> ::TokenStream, + ) -> Self { + ProcMacro::Attr { + name, + client: Client::expand2(expand), + } + } + + pub const fn bang(name: &'static str, expand: fn(::TokenStream) -> ::TokenStream) -> Self { + ProcMacro::Bang { + name, + client: Client::expand1(expand), + } + } +} diff --git a/src/libproc_macro/bridge/closure.rs b/src/libproc_macro/bridge/closure.rs new file mode 100644 index 0000000000000..92fe7baae097c --- /dev/null +++ b/src/libproc_macro/bridge/closure.rs @@ -0,0 +1,42 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Closure type (equivalent to `&mut dyn FnMut(A) -> R`) that's `repr(C)`. + +#[repr(C)] +pub struct Closure<'a, A, R> { + call: unsafe extern "C" fn(&mut Env, A) -> R, + env: &'a mut Env, +} + +extern "C" { + type Env; +} + +impl<'a, A, R> !Sync for Closure<'a, A, R> {} +impl<'a, A, R> !Send for Closure<'a, A, R> {} + +impl<'a, A, R, F: FnMut(A) -> R> From<&'a mut F> for Closure<'a, A, R> { + fn from(f: &'a mut F) -> Self { + unsafe extern "C" fn call R>(env: &mut Env, arg: A) -> R { + (*(env as *mut _ as *mut F))(arg) + } + Closure { + call: call::, + env: unsafe { &mut *(f as *mut _ as *mut Env) }, + } + } +} + +impl<'a, A, R> Closure<'a, A, R> { + pub fn call(&mut self, arg: A) -> R { + unsafe { (self.call)(self.env, arg) } + } +} diff --git a/src/libproc_macro/bridge/handle.rs b/src/libproc_macro/bridge/handle.rs new file mode 100644 index 0000000000000..5c91a1408a42f --- /dev/null +++ b/src/libproc_macro/bridge/handle.rs @@ -0,0 +1,92 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Server-side handles and storage for per-handle data. + +use std::collections::{BTreeMap, HashMap}; +use std::hash::Hash; +use std::num::NonZeroU32; +use std::ops::{Index, IndexMut}; +use std::sync::atomic::{AtomicUsize, Ordering}; + +pub(super) type Handle = NonZeroU32; + +pub(super) struct OwnedStore { + counter: &'static AtomicUsize, + data: BTreeMap, +} + +impl OwnedStore { + pub(super) fn new(counter: &'static AtomicUsize) -> Self { + // Ensure the handle counter isn't 0, which would panic later, + // when `NonZeroU32::new` (aka `Handle::new`) is called in `alloc`. + assert_ne!(counter.load(Ordering::SeqCst), 0); + + OwnedStore { + counter, + data: BTreeMap::new(), + } + } +} + +impl OwnedStore { + pub(super) fn alloc(&mut self, x: T) -> Handle { + let counter = self.counter.fetch_add(1, Ordering::SeqCst); + let handle = Handle::new(counter as u32).expect("`proc_macro` handle counter overflowed"); + assert!(self.data.insert(handle, x).is_none()); + handle + } + + pub(super) fn take(&mut self, h: Handle) -> T { + self.data + .remove(&h) + .expect("use-after-free in `proc_macro` handle") + } +} + +impl Index for OwnedStore { + type Output = T; + fn index(&self, h: Handle) -> &T { + self.data + .get(&h) + .expect("use-after-free in `proc_macro` handle") + } +} + +impl IndexMut for OwnedStore { + fn index_mut(&mut self, h: Handle) -> &mut T { + self.data + .get_mut(&h) + .expect("use-after-free in `proc_macro` handle") + } +} + +pub(super) struct InternedStore { + owned: OwnedStore, + interner: HashMap, +} + +impl InternedStore { + pub(super) fn new(counter: &'static AtomicUsize) -> Self { + InternedStore { + owned: OwnedStore::new(counter), + interner: HashMap::new(), + } + } + + pub(super) fn alloc(&mut self, x: T) -> Handle { + let owned = &mut self.owned; + *self.interner.entry(x).or_insert_with(|| owned.alloc(x)) + } + + pub(super) fn copy(&mut self, h: Handle) -> T { + self.owned[h] + } +} diff --git a/src/libproc_macro/bridge/mod.rs b/src/libproc_macro/bridge/mod.rs new file mode 100644 index 0000000000000..f03c63fc04c81 --- /dev/null +++ b/src/libproc_macro/bridge/mod.rs @@ -0,0 +1,413 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Internal interface for communicating between a `proc_macro` client +//! (a proc macro crate) and a `proc_macro` server (a compiler front-end). +//! +//! Serialization (with C ABI buffers) and unique integer handles are employed +//! to allow safely interfacing between two copies of `proc_macro` built +//! (from the same source) by different compilers with potentially mismatching +//! Rust ABIs (e.g. stage0/bin/rustc vs stage1/bin/rustc during bootstrap). + +#![deny(unsafe_code)] + +use std::fmt; +use std::hash::Hash; +use std::marker; +use std::mem; +use std::ops::Bound; +use std::panic; +use std::sync::atomic::AtomicUsize; +use std::sync::Once; +use std::thread; +use {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. +/// +/// `with_api!(MySelf, my_self, my_macro)` expands to: +/// ```rust,ignore (pseudo-code) +/// my_macro! { +/// // ... +/// Literal { +/// // ... +/// fn character(ch: char) -> MySelf::Literal; +/// // ... +/// fn span(my_self: &MySelf::Literal) -> MySelf::Span; +/// fn set_span(my_self: &mut MySelf::Literal, span: MySelf::Span); +/// }, +/// // ... +/// } +/// ``` +/// +/// The first two arguments serve to customize the arguments names +/// and argument/return types, to enable several different usecases: +/// +/// If `my_self` is just `self`, then each `fn` signature can be used +/// as-is for a method. If it's anything else (`self_` in practice), +/// then the signatures don't have a special `self` argument, and +/// can, therefore, have a different one introduced. +/// +/// If `MySelf` is just `Self`, then the types are only valid inside +/// a trait or a trait impl, where the trait has associated types +/// for each of the API types. If non-associated types are desired, +/// a module name (`self` in practice) can be used instead of `Self`. +macro_rules! with_api { + ($S:ident, $self:ident, $m:ident) => { + $m! { + TokenStream { + fn drop($self: $S::TokenStream); + fn clone($self: &$S::TokenStream) -> $S::TokenStream; + fn new() -> $S::TokenStream; + fn is_empty($self: &$S::TokenStream) -> bool; + fn from_str(src: &str) -> $S::TokenStream; + fn to_string($self: &$S::TokenStream) -> String; + fn from_token_tree( + tree: TokenTree<$S::Group, $S::Punct, $S::Ident, $S::Literal>, + ) -> $S::TokenStream; + fn into_iter($self: $S::TokenStream) -> $S::TokenStreamIter; + }, + TokenStreamBuilder { + fn drop($self: $S::TokenStreamBuilder); + fn new() -> $S::TokenStreamBuilder; + fn push($self: &mut $S::TokenStreamBuilder, stream: $S::TokenStream); + fn build($self: $S::TokenStreamBuilder) -> $S::TokenStream; + }, + TokenStreamIter { + fn drop($self: $S::TokenStreamIter); + fn clone($self: &$S::TokenStreamIter) -> $S::TokenStreamIter; + fn next( + $self: &mut $S::TokenStreamIter, + ) -> Option>; + }, + Group { + fn drop($self: $S::Group); + fn clone($self: &$S::Group) -> $S::Group; + fn new(delimiter: Delimiter, stream: $S::TokenStream) -> $S::Group; + fn delimiter($self: &$S::Group) -> Delimiter; + fn stream($self: &$S::Group) -> $S::TokenStream; + fn span($self: &$S::Group) -> $S::Span; + fn span_open($self: &$S::Group) -> $S::Span; + fn span_close($self: &$S::Group) -> $S::Span; + fn set_span($self: &mut $S::Group, span: $S::Span); + }, + Punct { + fn new(ch: char, spacing: Spacing) -> $S::Punct; + fn as_char($self: $S::Punct) -> char; + fn spacing($self: $S::Punct) -> Spacing; + fn span($self: $S::Punct) -> $S::Span; + fn with_span($self: $S::Punct, span: $S::Span) -> $S::Punct; + }, + Ident { + fn new(string: &str, span: $S::Span, is_raw: bool) -> $S::Ident; + fn span($self: $S::Ident) -> $S::Span; + fn with_span($self: $S::Ident, span: $S::Span) -> $S::Ident; + }, + Literal { + fn drop($self: $S::Literal); + fn clone($self: &$S::Literal) -> $S::Literal; + // FIXME(eddyb) `Literal` should not expose internal `Debug` impls. + fn debug($self: &$S::Literal) -> String; + fn integer(n: &str) -> $S::Literal; + fn typed_integer(n: &str, kind: &str) -> $S::Literal; + fn float(n: &str) -> $S::Literal; + fn f32(n: &str) -> $S::Literal; + fn f64(n: &str) -> $S::Literal; + fn string(string: &str) -> $S::Literal; + fn character(ch: char) -> $S::Literal; + fn byte_string(bytes: &[u8]) -> $S::Literal; + fn span($self: &$S::Literal) -> $S::Span; + fn set_span($self: &mut $S::Literal, span: $S::Span); + fn subspan( + $self: &$S::Literal, + start: Bound, + end: Bound, + ) -> Option<$S::Span>; + }, + SourceFile { + fn drop($self: $S::SourceFile); + fn clone($self: &$S::SourceFile) -> $S::SourceFile; + fn eq($self: &$S::SourceFile, other: &$S::SourceFile) -> bool; + fn path($self: &$S::SourceFile) -> String; + fn is_real($self: &$S::SourceFile) -> bool; + }, + MultiSpan { + fn drop($self: $S::MultiSpan); + fn new() -> $S::MultiSpan; + fn push($self: &mut $S::MultiSpan, span: $S::Span); + }, + Diagnostic { + fn drop($self: $S::Diagnostic); + fn new(level: Level, msg: &str, span: $S::MultiSpan) -> $S::Diagnostic; + fn sub( + $self: &mut $S::Diagnostic, + level: Level, + msg: &str, + span: $S::MultiSpan, + ); + fn emit($self: $S::Diagnostic); + }, + Span { + fn debug($self: $S::Span) -> String; + fn def_site() -> $S::Span; + fn call_site() -> $S::Span; + fn source_file($self: $S::Span) -> $S::SourceFile; + fn parent($self: $S::Span) -> Option<$S::Span>; + fn source($self: $S::Span) -> $S::Span; + fn start($self: $S::Span) -> LineColumn; + fn end($self: $S::Span) -> LineColumn; + fn join($self: $S::Span, other: $S::Span) -> Option<$S::Span>; + fn resolved_at($self: $S::Span, at: $S::Span) -> $S::Span; + }, + } + }; +} + +// FIXME(eddyb) this calls `encode` for each argument, but in reverse, +// to avoid borrow conflicts from borrows started by `&mut` arguments. +macro_rules! reverse_encode { + ($writer:ident;) => {}; + ($writer:ident; $first:ident $(, $rest:ident)*) => { + reverse_encode!($writer; $($rest),*); + $first.encode(&mut $writer, &mut ()); + } +} + +// FIXME(eddyb) this calls `decode` for each argument, but in reverse, +// to avoid borrow conflicts from borrows started by `&mut` arguments. +macro_rules! reverse_decode { + ($reader:ident, $s:ident;) => {}; + ($reader:ident, $s:ident; $first:ident: $first_ty:ty $(, $rest:ident: $rest_ty:ty)*) => { + reverse_decode!($reader, $s; $($rest: $rest_ty),*); + let $first = <$first_ty>::decode(&mut $reader, $s); + } +} + +#[allow(unsafe_code)] +mod buffer; +#[forbid(unsafe_code)] +pub mod client; +#[allow(unsafe_code)] +mod closure; +#[forbid(unsafe_code)] +mod handle; +#[macro_use] +#[forbid(unsafe_code)] +mod rpc; +#[allow(unsafe_code)] +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}; + +/// An active connection between a server and a client. +/// The server creates the bridge (`Bridge::run_server` in `server.rs`), +/// then passes it to the client through the function pointer in the `run` +/// field of `client::Client`. The client holds its copy of the `Bridge` +/// in TLS during its execution (`Bridge::{enter, with}` in `client.rs`). +#[repr(C)] +pub struct Bridge<'a> { + /// Reusable buffer (only `clear`-ed, never shrunk), primarily + /// used for making requests, but also for passing input to client. + cached_buffer: Buffer, + + /// Server-side function that the client uses to make requests. + dispatch: closure::Closure<'a, Buffer, Buffer>, +} + +impl<'a> !Sync for Bridge<'a> {} +impl<'a> !Send for Bridge<'a> {} + +#[forbid(unsafe_code)] +#[allow(non_camel_case_types)] +mod api_tags { + use super::rpc::{DecodeMut, Encode, Reader, Writer}; + + macro_rules! declare_tags { + ($($name:ident { + $(fn $method:ident($($arg:ident: $arg_ty:ty),* $(,)*) $(-> $ret_ty:ty)*;)* + }),* $(,)*) => { + $( + pub(super) enum $name { + $($method),* + } + rpc_encode_decode!(enum $name { $($method),* }); + )* + + + pub(super) enum Method { + $($name($name)),* + } + rpc_encode_decode!(enum Method { $($name(m)),* }); + } + } + with_api!(self, self, declare_tags); +} + +/// Helper to wrap associated types to allow trait impl dispatch. +/// That is, normally a pair of impls for `T::Foo` and `T::Bar` +/// can overlap, but if the impls are, instead, on types like +/// `Marked` and `Marked`, they can't. +trait Mark { + type Unmarked; + fn mark(unmarked: Self::Unmarked) -> Self; +} + +/// Unwrap types wrapped by `Mark::mark` (see `Mark` for details). +trait Unmark { + type Unmarked; + fn unmark(self) -> Self::Unmarked; +} + +#[derive(Copy, Clone, PartialEq, Eq, Hash)] +struct Marked { + value: T, + _marker: marker::PhantomData, +} + +impl Mark for Marked { + type Unmarked = T; + fn mark(unmarked: Self::Unmarked) -> Self { + Marked { + value: unmarked, + _marker: marker::PhantomData, + } + } +} +impl Unmark for Marked { + type Unmarked = T; + fn unmark(self) -> Self::Unmarked { + self.value + } +} +impl Unmark for &'a Marked { + type Unmarked = &'a T; + fn unmark(self) -> Self::Unmarked { + &self.value + } +} +impl Unmark for &'a mut Marked { + type Unmarked = &'a mut T; + fn unmark(self) -> Self::Unmarked { + &mut self.value + } +} + +impl Mark for Option { + type Unmarked = Option; + fn mark(unmarked: Self::Unmarked) -> Self { + unmarked.map(T::mark) + } +} +impl Unmark for Option { + type Unmarked = Option; + fn unmark(self) -> Self::Unmarked { + self.map(T::unmark) + } +} + +macro_rules! mark_noop { + ($($ty:ty),* $(,)*) => { + $( + impl Mark for $ty { + type Unmarked = Self; + fn mark(unmarked: Self::Unmarked) -> Self { + unmarked + } + } + impl Unmark for $ty { + type Unmarked = Self; + fn unmark(self) -> Self::Unmarked { + self + } + } + )* + } +} +mark_noop! { + (), + bool, + char, + &'a [u8], + &'a str, + String, + Delimiter, + Level, + LineColumn, + Spacing, + Bound, +} + +rpc_encode_decode!( + enum Delimiter { + Parenthesis, + Brace, + Bracket, + None, + } +); +rpc_encode_decode!( + enum Level { + Error, + Warning, + Note, + Help, + } +); +rpc_encode_decode!(struct LineColumn { line, column }); +rpc_encode_decode!( + enum Spacing { + Alone, + Joint, + } +); + +#[derive(Clone)] +pub enum TokenTree { + Group(G), + Punct(P), + Ident(I), + Literal(L), +} + +impl Mark for TokenTree { + type Unmarked = TokenTree; + fn mark(unmarked: Self::Unmarked) -> Self { + match unmarked { + TokenTree::Group(tt) => TokenTree::Group(G::mark(tt)), + TokenTree::Punct(tt) => TokenTree::Punct(P::mark(tt)), + TokenTree::Ident(tt) => TokenTree::Ident(I::mark(tt)), + TokenTree::Literal(tt) => TokenTree::Literal(L::mark(tt)), + } + } +} +impl Unmark for TokenTree { + type Unmarked = TokenTree; + fn unmark(self) -> Self::Unmarked { + match self { + TokenTree::Group(tt) => TokenTree::Group(tt.unmark()), + TokenTree::Punct(tt) => TokenTree::Punct(tt.unmark()), + TokenTree::Ident(tt) => TokenTree::Ident(tt.unmark()), + TokenTree::Literal(tt) => TokenTree::Literal(tt.unmark()), + } + } +} + +rpc_encode_decode!( + enum TokenTree { + Group(tt), + Punct(tt), + Ident(tt), + Literal(tt), + } +); diff --git a/src/libproc_macro/bridge/rpc.rs b/src/libproc_macro/bridge/rpc.rs new file mode 100644 index 0000000000000..fafc3d0074065 --- /dev/null +++ b/src/libproc_macro/bridge/rpc.rs @@ -0,0 +1,319 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Serialization for client<->server communication. + +use std::any::Any; +use std::char; +use std::io::Write; +use std::num::NonZeroU32; +use std::ops::Bound; +use std::str; + +pub(super) type Writer = super::buffer::Buffer; + +pub(super) trait Encode: Sized { + fn encode(self, w: &mut Writer, s: &mut S); +} + +pub(super) type Reader<'a> = &'a [u8]; + +pub(super) trait Decode<'a, 's, S>: Sized { + fn decode(r: &mut Reader<'a>, s: &'s S) -> Self; +} + +pub(super) trait DecodeMut<'a, 's, S>: Sized { + fn decode(r: &mut Reader<'a>, s: &'s mut S) -> Self; +} + +macro_rules! rpc_encode_decode { + (uleb128 $ty:ty) => { + impl Encode for $ty { + fn encode(mut self, w: &mut Writer, s: &mut S) { + let mut byte = 0x80; + while byte & 0x80 != 0 { + byte = (self & 0x7f) as u8; + self >>= 7; + if self != 0 { + byte |= 0x80; + } + byte.encode(w, s); + } + } + } + + impl DecodeMut<'_, '_, S> for $ty { + fn decode(r: &mut Reader, s: &mut S) -> Self { + let mut byte = 0x80; + let mut v = 0; + let mut shift = 0; + while byte & 0x80 != 0 { + byte = u8::decode(r, s); + v |= ((byte & 0x7f) as Self) << shift; + shift += 7; + } + v + } + } + }; + (struct $name:ident { $($field:ident),* $(,)* }) => { + impl Encode for $name { + fn encode(self, w: &mut Writer, s: &mut S) { + $(self.$field.encode(w, s);)* + } + } + + impl DecodeMut<'_, '_, S> for $name { + fn decode(r: &mut Reader, s: &mut S) -> Self { + $name { + $($field: DecodeMut::decode(r, s)),* + } + } + } + }; + (enum $name:ident $(<$($T:ident),+>)* { $($variant:ident $(($field:ident))*),* $(,)* }) => { + impl),+)*> Encode for $name $(<$($T),+>)* { + fn encode(self, w: &mut Writer, s: &mut S) { + // HACK(eddyb) `Tag` enum duplicated between the + // two impls as there's no other place to stash it. + #[repr(u8)] enum Tag { $($variant),* } + #[allow(non_upper_case_globals)] + impl Tag { $(const $variant: u8 = Tag::$variant as u8;)* } + + match self { + $($name::$variant $(($field))* => { + ::$variant.encode(w, s); + $($field.encode(w, s);)* + })* + } + } + } + + impl DecodeMut<'a, 's, S>),+)*> DecodeMut<'a, '_, S> + for $name $(<$($T),+>)* + { + fn decode(r: &mut Reader<'a>, s: &mut S) -> Self { + // HACK(eddyb) `Tag` enum duplicated between the + // two impls as there's no other place to stash it. + #[repr(u8)] enum Tag { $($variant),* } + #[allow(non_upper_case_globals)] + impl Tag { $(const $variant: u8 = Tag::$variant as u8;)* } + + match u8::decode(r, s) { + $(::$variant => { + $(let $field = DecodeMut::decode(r, s);)* + $name::$variant $(($field))* + })* + _ => unreachable!(), + } + } + } + } +} + +impl Encode for () { + fn encode(self, _: &mut Writer, _: &mut S) {} +} + +impl DecodeMut<'_, '_, S> for () { + fn decode(_: &mut Reader, _: &mut S) -> Self {} +} + +impl Encode for u8 { + fn encode(self, w: &mut Writer, _: &mut S) { + w.write_all(&[self]).unwrap(); + } +} + +impl DecodeMut<'_, '_, S> for u8 { + fn decode(r: &mut Reader, _: &mut S) -> Self { + let x = r[0]; + *r = &r[1..]; + x + } +} + +rpc_encode_decode!(uleb128 u32); +rpc_encode_decode!(uleb128 usize); + +impl Encode for bool { + fn encode(self, w: &mut Writer, s: &mut S) { + (self as u8).encode(w, s); + } +} + +impl DecodeMut<'_, '_, S> for bool { + fn decode(r: &mut Reader, s: &mut S) -> Self { + match u8::decode(r, s) { + 0 => false, + 1 => true, + _ => unreachable!(), + } + } +} + +impl Encode for char { + fn encode(self, w: &mut Writer, s: &mut S) { + (self as u32).encode(w, s); + } +} + +impl DecodeMut<'_, '_, S> for char { + fn decode(r: &mut Reader, s: &mut S) -> Self { + char::from_u32(u32::decode(r, s)).unwrap() + } +} + +impl Encode for NonZeroU32 { + fn encode(self, w: &mut Writer, s: &mut S) { + self.get().encode(w, s); + } +} + +impl DecodeMut<'_, '_, S> for NonZeroU32 { + fn decode(r: &mut Reader, s: &mut S) -> Self { + Self::new(u32::decode(r, s)).unwrap() + } +} + +impl, B: Encode> Encode for (A, B) { + fn encode(self, w: &mut Writer, s: &mut S) { + self.0.encode(w, s); + self.1.encode(w, s); + } +} + +impl DecodeMut<'a, 's, S>, B: for<'s> DecodeMut<'a, 's, S>> DecodeMut<'a, '_, S> + for (A, B) +{ + fn decode(r: &mut Reader<'a>, s: &mut S) -> Self { + (DecodeMut::decode(r, s), DecodeMut::decode(r, s)) + } +} + +rpc_encode_decode!( + enum Bound { + Included(x), + Excluded(x), + Unbounded, + } +); + +rpc_encode_decode!( + enum Option { + None, + Some(x), + } +); + +rpc_encode_decode!( + enum Result { + Ok(x), + Err(e), + } +); + +impl Encode for &[u8] { + fn encode(self, w: &mut Writer, s: &mut S) { + self.len().encode(w, s); + w.write_all(self).unwrap(); + } +} + +impl DecodeMut<'a, '_, S> for &'a [u8] { + fn decode(r: &mut Reader<'a>, s: &mut S) -> Self { + let len = usize::decode(r, s); + let xs = &r[..len]; + *r = &r[len..]; + xs + } +} + +impl Encode for &str { + fn encode(self, w: &mut Writer, s: &mut S) { + self.as_bytes().encode(w, s); + } +} + +impl DecodeMut<'a, '_, S> for &'a str { + fn decode(r: &mut Reader<'a>, s: &mut S) -> Self { + str::from_utf8(<&[u8]>::decode(r, s)).unwrap() + } +} + +impl Encode for String { + fn encode(self, w: &mut Writer, s: &mut S) { + self[..].encode(w, s); + } +} + +impl DecodeMut<'_, '_, S> for String { + fn decode(r: &mut Reader, s: &mut S) -> Self { + <&str>::decode(r, s).to_string() + } +} + +/// Simplied version of panic payloads, ignoring +/// types other than `&'static str` and `String`. +pub enum PanicMessage { + StaticStr(&'static str), + String(String), + Unknown, +} + +impl From> for PanicMessage { + fn from(payload: Box) -> Self { + if let Some(s) = payload.downcast_ref::<&'static str>() { + return PanicMessage::StaticStr(s); + } + if let Ok(s) = payload.downcast::() { + return PanicMessage::String(*s); + } + PanicMessage::Unknown + } +} + +impl Into> for PanicMessage { + fn into(self) -> Box { + match self { + PanicMessage::StaticStr(s) => Box::new(s), + PanicMessage::String(s) => Box::new(s), + PanicMessage::Unknown => { + struct UnknownPanicMessage; + Box::new(UnknownPanicMessage) + } + } + } +} + +impl PanicMessage { + pub fn as_str(&self) -> Option<&str> { + match self { + PanicMessage::StaticStr(s) => Some(s), + PanicMessage::String(s) => Some(s), + PanicMessage::Unknown => None, + } + } +} + +impl Encode for PanicMessage { + fn encode(self, w: &mut Writer, s: &mut S) { + self.as_str().encode(w, s); + } +} + +impl DecodeMut<'_, '_, S> for PanicMessage { + fn decode(r: &mut Reader, s: &mut S) -> Self { + match Option::::decode(r, s) { + Some(s) => PanicMessage::String(s), + None => PanicMessage::Unknown, + } + } +} diff --git a/src/libproc_macro/bridge/scoped_cell.rs b/src/libproc_macro/bridge/scoped_cell.rs new file mode 100644 index 0000000000000..51d1fece79b92 --- /dev/null +++ b/src/libproc_macro/bridge/scoped_cell.rs @@ -0,0 +1,90 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! `Cell` variant for (scoped) existential lifetimes. + +use std::cell::Cell; +use std::mem; +use std::ops::{Deref, DerefMut}; + +/// Type lambda application, with a lifetime. +pub trait ApplyL<'a> { + type Out; +} + +/// Type lambda taking a lifetime, i.e. `Lifetime -> Type`. +pub trait LambdaL: for<'a> ApplyL<'a> {} + +impl ApplyL<'a>> LambdaL for T {} + +// HACK(eddyb) work around projection limitations with a newtype +// FIXME(#52812) replace with `&'a mut >::Out` +pub struct RefMutL<'a, 'b, T: LambdaL>(&'a mut >::Out); + +impl<'a, 'b, T: LambdaL> Deref for RefMutL<'a, 'b, T> { + type Target = >::Out; + fn deref(&self) -> &Self::Target { + self.0 + } +} + +impl<'a, 'b, T: LambdaL> DerefMut for RefMutL<'a, 'b, T> { + fn deref_mut(&mut self) -> &mut Self::Target { + self.0 + } +} + +pub struct ScopedCell(Cell<>::Out>); + +impl ScopedCell { + pub const fn new(value: >::Out) -> Self { + ScopedCell(Cell::new(value)) + } + + /// Set the value in `self` to `replacement` while + /// running `f`, which gets the old value, mutably. + /// The old value will be restored after `f` exits, even + /// by panic, including modifications made to it by `f`. + pub fn replace<'a, R>( + &self, + replacement: >::Out, + f: impl for<'b, 'c> FnOnce(RefMutL<'b, 'c, T>) -> R, + ) -> R { + /// Wrapper that ensures that the cell always gets filled + /// (with the original state, optionally changed by `f`), + /// even if `f` had panicked. + struct PutBackOnDrop<'a, T: LambdaL> { + cell: &'a ScopedCell, + value: Option<>::Out>, + } + + impl<'a, T: LambdaL> Drop for PutBackOnDrop<'a, T> { + fn drop(&mut self) { + self.cell.0.set(self.value.take().unwrap()); + } + } + + let mut put_back_on_drop = PutBackOnDrop { + cell: self, + value: Some(self.0.replace(unsafe { + let erased = mem::transmute_copy(&replacement); + mem::forget(replacement); + erased + })), + }; + + f(RefMutL(put_back_on_drop.value.as_mut().unwrap())) + } + + /// Set the value in `self` to `value` while running `f`. + pub fn set<'a, R>(&self, value: >::Out, f: impl FnOnce() -> R) -> R { + self.replace(value, |_| f()) + } +} diff --git a/src/libproc_macro/bridge/server.rs b/src/libproc_macro/bridge/server.rs new file mode 100644 index 0000000000000..f500b17d1caf3 --- /dev/null +++ b/src/libproc_macro/bridge/server.rs @@ -0,0 +1,352 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Server-side traits. + +use super::*; + +// FIXME(eddyb) generate the definition of `HandleStore` in `server.rs`. +use super::client::HandleStore; + +/// Declare an associated item of one of the traits below, optionally +/// adjusting it (i.e. adding bounds to types and default bodies to methods). +macro_rules! associated_item { + (type TokenStream) => + (type TokenStream: 'static + Clone;); + (type TokenStreamBuilder) => + (type TokenStreamBuilder: 'static;); + (type TokenStreamIter) => + (type TokenStreamIter: 'static + Clone;); + (type Group) => + (type Group: 'static + Clone;); + (type Punct) => + (type Punct: 'static + Copy + Eq + Hash;); + (type Ident) => + (type Ident: 'static + Copy + Eq + Hash;); + (type Literal) => + (type Literal: 'static + Clone;); + (type SourceFile) => + (type SourceFile: 'static + Clone;); + (type MultiSpan) => + (type MultiSpan: 'static;); + (type Diagnostic) => + (type Diagnostic: 'static;); + (type Span) => + (type Span: 'static + Copy + Eq + Hash;); + (fn drop(&mut self, $arg:ident: $arg_ty:ty)) => + (fn drop(&mut self, $arg: $arg_ty) { mem::drop($arg) }); + (fn clone(&mut self, $arg:ident: $arg_ty:ty) -> $ret_ty:ty) => + (fn clone(&mut self, $arg: $arg_ty) -> $ret_ty { $arg.clone() }); + ($($item:tt)*) => ($($item)*;) +} + +macro_rules! declare_server_traits { + ($($name:ident { + $(fn $method:ident($($arg:ident: $arg_ty:ty),* $(,)*) $(-> $ret_ty:ty)*;)* + }),* $(,)*) => { + pub trait Types { + $(associated_item!(type $name);)* + } + + $(pub trait $name: Types { + $(associated_item!(fn $method(&mut self, $($arg: $arg_ty),*) $(-> $ret_ty)*);)* + })* + + pub trait Server: Types $(+ $name)* {} + impl Server for S {} + } +} +with_api!(Self, self_, declare_server_traits); + +pub(super) struct MarkedTypes(S); + +macro_rules! define_mark_types_impls { + ($($name:ident { + $(fn $method:ident($($arg:ident: $arg_ty:ty),* $(,)*) $(-> $ret_ty:ty)*;)* + }),* $(,)*) => { + impl Types for MarkedTypes { + $(type $name = Marked;)* + } + + $(impl $name for MarkedTypes { + $(fn $method(&mut self, $($arg: $arg_ty),*) $(-> $ret_ty)* { + <_>::mark($name::$method(&mut self.0, $($arg.unmark()),*)) + })* + })* + } +} +with_api!(Self, self_, define_mark_types_impls); + +struct Dispatcher { + handle_store: HandleStore, + server: S, +} + +macro_rules! define_dispatcher_impl { + ($($name:ident { + $(fn $method:ident($($arg:ident: $arg_ty:ty),* $(,)*) $(-> $ret_ty:ty)*;)* + }),* $(,)*) => { + // FIXME(eddyb) `pub` only for `ExecutionStrategy` below. + pub trait DispatcherTrait { + // HACK(eddyb) these are here to allow `Self::$name` to work below. + $(type $name;)* + fn dispatch(&mut self, b: Buffer) -> Buffer; + } + + impl DispatcherTrait for Dispatcher> { + $(type $name = as Types>::$name;)* + fn dispatch(&mut self, mut b: Buffer) -> Buffer { + let Dispatcher { handle_store, server } = self; + + let mut reader = &b[..]; + match api_tags::Method::decode(&mut reader, &mut ()) { + $(api_tags::Method::$name(m) => match m { + $(api_tags::$name::$method => { + let mut call_method = || { + reverse_decode!(reader, handle_store; $($arg: $arg_ty),*); + $name::$method(server, $($arg),*) + }; + // HACK(eddyb) don't use `panic::catch_unwind` in a panic. + // If client and server happen to use the same `libstd`, + // `catch_unwind` asserts that the panic counter was 0, + // even when the closure passed to it didn't panic. + let r = if thread::panicking() { + Ok(call_method()) + } else { + panic::catch_unwind(panic::AssertUnwindSafe(call_method)) + .map_err(PanicMessage::from) + }; + + b.clear(); + r.encode(&mut b, handle_store); + })* + }),* + } + b + } + } + } +} +with_api!(Self, self_, define_dispatcher_impl); + +pub trait ExecutionStrategy { + fn run_bridge_and_client( + &self, + dispatcher: &mut impl DispatcherTrait, + input: Buffer, + run_client: extern "C" fn(Bridge, D) -> Buffer, + client_data: D, + ) -> Buffer; +} + +pub struct SameThread; + +impl ExecutionStrategy for SameThread { + fn run_bridge_and_client( + &self, + dispatcher: &mut impl DispatcherTrait, + input: Buffer, + run_client: extern "C" fn(Bridge, D) -> Buffer, + client_data: D, + ) -> Buffer { + let mut dispatch = |b| dispatcher.dispatch(b); + + run_client( + Bridge { + cached_buffer: input, + dispatch: (&mut dispatch).into(), + }, + client_data, + ) + } +} + +// NOTE(eddyb) Two implementations are provided, the second one is a bit +// faster but neither is anywhere near as fast as same-thread execution. + +pub struct CrossThread1; + +impl ExecutionStrategy for CrossThread1 { + fn run_bridge_and_client( + &self, + dispatcher: &mut impl DispatcherTrait, + input: Buffer, + run_client: extern "C" fn(Bridge, D) -> Buffer, + client_data: D, + ) -> Buffer { + use std::sync::mpsc::channel; + + let (req_tx, req_rx) = channel(); + let (res_tx, res_rx) = channel(); + + let join_handle = thread::spawn(move || { + let mut dispatch = |b| { + req_tx.send(b).unwrap(); + res_rx.recv().unwrap() + }; + + run_client( + Bridge { + cached_buffer: input, + dispatch: (&mut dispatch).into(), + }, + client_data, + ) + }); + + for b in req_rx { + res_tx.send(dispatcher.dispatch(b)).unwrap(); + } + + join_handle.join().unwrap() + } +} + +pub struct CrossThread2; + +impl ExecutionStrategy for CrossThread2 { + fn run_bridge_and_client( + &self, + dispatcher: &mut impl DispatcherTrait, + input: Buffer, + run_client: extern "C" fn(Bridge, D) -> Buffer, + client_data: D, + ) -> Buffer { + use std::sync::{Arc, Mutex}; + + enum State { + Req(T), + Res(T), + } + + let mut state = Arc::new(Mutex::new(State::Res(Buffer::new()))); + + let server_thread = thread::current(); + let state2 = state.clone(); + let join_handle = thread::spawn(move || { + let mut dispatch = |b| { + *state2.lock().unwrap() = State::Req(b); + server_thread.unpark(); + loop { + thread::park(); + if let State::Res(b) = &mut *state2.lock().unwrap() { + break b.take(); + } + } + }; + + let r = run_client( + Bridge { + cached_buffer: input, + dispatch: (&mut dispatch).into(), + }, + client_data, + ); + + // Wake up the server so it can exit the dispatch loop. + drop(state2); + server_thread.unpark(); + + r + }); + + // Check whether `state2` was dropped, to know when to stop. + while Arc::get_mut(&mut state).is_none() { + thread::park(); + let mut b = match &mut *state.lock().unwrap() { + State::Req(b) => b.take(), + _ => continue, + }; + b = dispatcher.dispatch(b.take()); + *state.lock().unwrap() = State::Res(b); + join_handle.thread().unpark(); + } + + join_handle.join().unwrap() + } +} + +fn run_server< + S: Server, + I: Encode>>, + O: for<'a, 's> DecodeMut<'a, 's, HandleStore>>, + D: Copy + Send + 'static, +>( + strategy: &impl ExecutionStrategy, + handle_counters: &'static client::HandleCounters, + server: S, + input: I, + run_client: extern "C" fn(Bridge, D) -> Buffer, + client_data: D, +) -> Result { + let mut dispatcher = Dispatcher { + handle_store: HandleStore::new(handle_counters), + server: MarkedTypes(server), + }; + + let mut b = Buffer::new(); + input.encode(&mut b, &mut dispatcher.handle_store); + + b = strategy.run_bridge_and_client(&mut dispatcher, b, run_client, client_data); + + Result::decode(&mut &b[..], &mut dispatcher.handle_store) +} + +impl client::Client ::TokenStream> { + pub fn run( + &self, + strategy: &impl ExecutionStrategy, + server: S, + input: S::TokenStream, + ) -> Result { + let client::Client { + get_handle_counters, + run, + f, + } = *self; + run_server( + strategy, + get_handle_counters(), + server, + as Types>::TokenStream::mark(input), + run, + f, + ) + .map( as Types>::TokenStream::unmark) + } +} + +impl client::Client ::TokenStream> { + pub fn run( + &self, + strategy: &impl ExecutionStrategy, + server: S, + input: S::TokenStream, + input2: S::TokenStream, + ) -> Result { + let client::Client { + get_handle_counters, + run, + f, + } = *self; + run_server( + strategy, + get_handle_counters(), + server, + ( + as Types>::TokenStream::mark(input), + as Types>::TokenStream::mark(input2), + ), + run, + f, + ) + .map( as Types>::TokenStream::unmark) + } +} diff --git a/src/libproc_macro/diagnostic.rs b/src/libproc_macro/diagnostic.rs index bf23de3943702..4234f0bcd21c1 100644 --- a/src/libproc_macro/diagnostic.rs +++ b/src/libproc_macro/diagnostic.rs @@ -10,8 +10,6 @@ use Span; -use rustc_errors as errors; - /// An enum representing a diagnostic level. #[unstable(feature = "proc_macro_diagnostic", issue = "54140")] #[derive(Copy, Clone, Debug)] @@ -180,22 +178,22 @@ impl Diagnostic { /// Emit the diagnostic. #[unstable(feature = "proc_macro_diagnostic", issue = "54140")] pub fn emit(self) { - fn to_internal(spans: Vec) -> ::syntax_pos::MultiSpan { - let spans: Vec<_> = spans.into_iter().map(|s| s.0).collect(); - ::syntax_pos::MultiSpan::from_spans(spans) + fn to_internal(spans: Vec) -> ::bridge::client::MultiSpan { + let mut multi_span = ::bridge::client::MultiSpan::new(); + for span in spans { + multi_span.push(span.0); + } + multi_span } - let level = self.level.to_internal(); - let mut diag = errors::Diagnostic::new(level, &*self.message); - diag.set_span(to_internal(self.spans)); - - for child in self.children { - let level = child.level.to_internal(); - diag.sub(level, &*child.message, to_internal(child.spans), None); + let mut diag = ::bridge::client::Diagnostic::new( + self.level, + &self.message[..], + to_internal(self.spans), + ); + for c in self.children { + diag.sub(c.level, &c.message[..], to_internal(c.spans)); } - - ::__internal::with_sess(move |sess, _| { - errors::DiagnosticBuilder::new_diagnostic(&sess.span_diagnostic, diag).emit(); - }); + diag.emit(); } } diff --git a/src/libproc_macro/lib.rs b/src/libproc_macro/lib.rs index e9d2d97e3646b..32c81302931f3 100644 --- a/src/libproc_macro/lib.rs +++ b/src/libproc_macro/lib.rs @@ -28,40 +28,30 @@ test(attr(allow(dead_code, deprecated, unused_variables, unused_mut))))] #![feature(nll)] -#![feature(rustc_private)] #![feature(staged_api)] -#![feature(lang_items)] +#![feature(const_fn)] +#![feature(extern_types)] +#![feature(in_band_lifetimes)] #![feature(optin_builtin_traits)] #![feature(non_exhaustive)] +#![feature(specialization)] #![recursion_limit="256"] -extern crate syntax; -extern crate syntax_pos; -extern crate rustc_errors; -extern crate rustc_data_structures; - #[unstable(feature = "proc_macro_internals", issue = "27812")] #[doc(hidden)] -pub mod rustc; +pub mod bridge; mod diagnostic; #[unstable(feature = "proc_macro_diagnostic", issue = "54140")] pub use diagnostic::{Diagnostic, Level, MultiSpan}; +use std::{fmt, iter, mem}; use std::ops::{Bound, RangeBounds}; -use std::{ascii, fmt, iter}; use std::path::PathBuf; -use rustc_data_structures::sync::Lrc; use std::str::FromStr; -use syntax::errors::DiagnosticBuilder; -use syntax::parse::{self, token}; -use syntax::symbol::Symbol; -use syntax::tokenstream::{self, DelimSpan}; -use syntax_pos::{Pos, FileName, BytePos}; - /// The main type provided by this crate, representing an abstract stream of /// tokens, or, more specifically, a sequence of token trees. /// The type provide interfaces for iterating over those token trees and, conversely, @@ -71,7 +61,7 @@ use syntax_pos::{Pos, FileName, BytePos}; /// and `#[proc_macro_derive]` definitions. #[stable(feature = "proc_macro_lib", since = "1.15.0")] #[derive(Clone)] -pub struct TokenStream(tokenstream::TokenStream); +pub struct TokenStream(bridge::client::TokenStream); #[stable(feature = "proc_macro_lib", since = "1.15.0")] impl !Send for TokenStream {} @@ -94,7 +84,7 @@ impl TokenStream { /// Returns an empty `TokenStream` containing no token trees. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] pub fn new() -> TokenStream { - TokenStream(tokenstream::TokenStream::empty()) + TokenStream(bridge::client::TokenStream::new()) } /// Checks if this `TokenStream` is empty. @@ -116,11 +106,16 @@ impl FromStr for TokenStream { type Err = LexError; fn from_str(src: &str) -> Result { - __internal::with_sess(|sess, data| { - Ok(__internal::token_stream_wrap(parse::parse_stream_from_source_str( - FileName::ProcMacroSourceCode, src.to_string(), sess, Some(data.call_site.0) - ))) - }) + Ok(TokenStream(bridge::client::TokenStream::from_str(src))) + } +} + +// NB: the bridge only provides `to_string`, implement `fmt::Display` +// based on it (the reverse of the usual relationship between the two). +#[stable(feature = "proc_macro_lib", since = "1.15.0")] +impl ToString for TokenStream { + fn to_string(&self) -> String { + self.0.to_string() } } @@ -130,7 +125,7 @@ impl FromStr for TokenStream { #[stable(feature = "proc_macro_lib", since = "1.15.0")] impl fmt::Display for TokenStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - self.0.fmt(f) + f.write_str(&self.to_string()) } } @@ -150,7 +145,12 @@ pub use quote::{quote, quote_span}; #[stable(feature = "proc_macro_lib2", since = "1.29.0")] impl From for TokenStream { fn from(tree: TokenTree) -> TokenStream { - TokenStream(tree.to_internal()) + TokenStream(bridge::client::TokenStream::from_token_tree(match tree { + TokenTree::Group(tt) => bridge::TokenTree::Group(tt.0), + TokenTree::Punct(tt) => bridge::TokenTree::Punct(tt.0), + TokenTree::Ident(tt) => bridge::TokenTree::Ident(tt.0), + TokenTree::Literal(tt) => bridge::TokenTree::Literal(tt.0) + })) } } @@ -167,7 +167,7 @@ impl iter::FromIterator for TokenStream { #[stable(feature = "proc_macro_lib", since = "1.15.0")] impl iter::FromIterator for TokenStream { fn from_iter>(streams: I) -> Self { - let mut builder = tokenstream::TokenStreamBuilder::new(); + let mut builder = bridge::client::TokenStreamBuilder::new(); for stream in streams { builder.push(stream.0); } @@ -185,52 +185,34 @@ impl Extend for TokenStream { #[stable(feature = "token_stream_extend", since = "1.30.0")] impl Extend for TokenStream { fn extend>(&mut self, streams: I) { - self.0.extend(streams.into_iter().map(|stream| stream.0)); + // FIXME(eddyb) Use an optimized implementation if/when possible. + *self = iter::once(mem::replace(self, Self::new())).chain(streams).collect(); } } /// Public implementation details for the `TokenStream` type, such as iterators. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] pub mod token_stream { - use syntax::tokenstream; - use {TokenTree, TokenStream, Delimiter}; + use {bridge, Group, Ident, Literal, Punct, TokenTree, TokenStream}; /// An iterator over `TokenStream`'s `TokenTree`s. /// The iteration is "shallow", e.g. the iterator doesn't recurse into delimited groups, /// and returns whole groups as token trees. #[derive(Clone)] #[stable(feature = "proc_macro_lib2", since = "1.29.0")] - pub struct IntoIter { - cursor: tokenstream::Cursor, - stack: Vec, - } + pub struct IntoIter(bridge::client::TokenStreamIter); #[stable(feature = "proc_macro_lib2", since = "1.29.0")] impl Iterator for IntoIter { type Item = TokenTree; fn next(&mut self) -> Option { - loop { - let tree = self.stack.pop().or_else(|| { - let next = self.cursor.next_as_stream()?; - Some(TokenTree::from_internal(next, &mut self.stack)) - })?; - // HACK: The condition "dummy span + group with empty delimiter" represents an AST - // fragment approximately converted into a token stream. This may happen, for - // example, with inputs to proc macro attributes, including derives. Such "groups" - // need to flattened during iteration over stream's token trees. - // Eventually this needs to be removed in favor of keeping original token trees - // and not doing the roundtrip through AST. - if tree.span().0.is_dummy() { - if let TokenTree::Group(ref group) = tree { - if group.delimiter() == Delimiter::None { - self.cursor.insert(group.stream.clone().0); - continue - } - } - } - return Some(tree); - } + self.0.next().map(|tree| match tree { + bridge::TokenTree::Group(tt) => TokenTree::Group(Group(tt)), + bridge::TokenTree::Punct(tt) => TokenTree::Punct(Punct(tt)), + bridge::TokenTree::Ident(tt) => TokenTree::Ident(Ident(tt)), + bridge::TokenTree::Literal(tt) => TokenTree::Literal(Literal(tt)), + }) } } @@ -240,7 +222,7 @@ pub mod token_stream { type IntoIter = IntoIter; fn into_iter(self) -> IntoIter { - IntoIter { cursor: self.0.trees(), stack: Vec::new() } + IntoIter(self.0.into_iter()) } } } @@ -264,7 +246,7 @@ mod quote; /// A region of source code, along with macro expansion information. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] #[derive(Copy, Clone)] -pub struct Span(syntax_pos::Span); +pub struct Span(bridge::client::Span); #[stable(feature = "proc_macro_lib2", since = "1.29.0")] impl !Send for Span {} @@ -286,7 +268,7 @@ impl Span { /// A span that resolves at the macro definition site. #[unstable(feature = "proc_macro_def_site", issue = "54724")] pub fn def_site() -> Span { - ::__internal::with_sess(|_, data| data.def_site) + Span(bridge::client::Span::def_site()) } /// The span of the invocation of the current procedural macro. @@ -295,15 +277,13 @@ impl Span { /// at the macro call site will be able to refer to them as well. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] pub fn call_site() -> Span { - ::__internal::with_sess(|_, data| data.call_site) + Span(bridge::client::Span::call_site()) } /// The original source file into which this span points. #[unstable(feature = "proc_macro_span", issue = "54725")] pub fn source_file(&self) -> SourceFile { - SourceFile { - source_file: __internal::lookup_char_pos(self.0.lo()).file, - } + SourceFile(self.0.source_file()) } /// The `Span` for the tokens in the previous macro expansion from which @@ -318,27 +298,19 @@ impl Span { /// value is the same as `*self`. #[unstable(feature = "proc_macro_span", issue = "54725")] pub fn source(&self) -> Span { - Span(self.0.source_callsite()) + Span(self.0.source()) } /// Get the starting line/column in the source file for this span. #[unstable(feature = "proc_macro_span", issue = "54725")] pub fn start(&self) -> LineColumn { - let loc = __internal::lookup_char_pos(self.0.lo()); - LineColumn { - line: loc.line, - column: loc.col.to_usize() - } + self.0.start() } /// Get the ending line/column in the source file for this span. #[unstable(feature = "proc_macro_span", issue = "54725")] pub fn end(&self) -> LineColumn { - let loc = __internal::lookup_char_pos(self.0.hi()); - LineColumn { - line: loc.line, - column: loc.col.to_usize() - } + self.0.end() } /// Create a new span encompassing `self` and `other`. @@ -346,19 +318,14 @@ impl Span { /// Returns `None` if `self` and `other` are from different files. #[unstable(feature = "proc_macro_span", issue = "54725")] pub fn join(&self, other: Span) -> Option { - let self_loc = __internal::lookup_char_pos(self.0.lo()); - let other_loc = __internal::lookup_char_pos(other.0.lo()); - - if self_loc.file.name != other_loc.file.name { return None } - - Some(Span(self.0.to(other.0))) + self.0.join(other.0).map(Span) } /// Creates a new span with the same line/column information as `self` but /// that resolves symbols as though it were at `other`. #[unstable(feature = "proc_macro_span", issue = "54725")] pub fn resolved_at(&self, other: Span) -> Span { - Span(self.0.with_ctxt(other.0.ctxt())) + Span(self.0.resolved_at(other.0)) } /// Creates a new span with the same name resolution behavior as `self` but @@ -384,10 +351,7 @@ impl Span { #[stable(feature = "proc_macro_lib2", since = "1.29.0")] impl fmt::Debug for Span { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{:?} bytes({}..{})", - self.0.ctxt(), - self.0.lo().0, - self.0.hi().0) + self.0.fmt(f) } } @@ -412,14 +376,7 @@ impl !Sync for LineColumn {} /// The source file of a given `Span`. #[unstable(feature = "proc_macro_span", issue = "54725")] #[derive(Clone)] -pub struct SourceFile { - source_file: Lrc, -} - -#[unstable(feature = "proc_macro_span", issue = "54725")] -impl !Send for SourceFile {} -#[unstable(feature = "proc_macro_span", issue = "54725")] -impl !Sync for SourceFile {} +pub struct SourceFile(bridge::client::SourceFile); impl SourceFile { /// Get the path to this source file. @@ -434,10 +391,7 @@ impl SourceFile { /// [`is_real`]: #method.is_real #[unstable(feature = "proc_macro_span", issue = "54725")] pub fn path(&self) -> PathBuf { - match self.source_file.name { - FileName::Real(ref path) => path.clone(), - _ => PathBuf::from(self.source_file.name.to_string()) - } + PathBuf::from(self.0.path()) } /// Returns `true` if this source file is a real source file, and not generated by an external @@ -447,7 +401,7 @@ impl SourceFile { // This is a hack until intercrate spans are implemented and we can have real source files // for spans generated in external macros. // https://github.com/rust-lang/rust/pull/43604#issuecomment-333334368 - self.source_file.is_real_file() + self.0.is_real() } } @@ -465,7 +419,7 @@ impl fmt::Debug for SourceFile { #[unstable(feature = "proc_macro_span", issue = "54725")] impl PartialEq for SourceFile { fn eq(&self, other: &Self) -> bool { - Lrc::ptr_eq(&self.source_file, &other.source_file) + self.0.eq(&other.0) } } @@ -579,18 +533,27 @@ impl From for TokenTree { } } +// NB: the bridge only provides `to_string`, implement `fmt::Display` +// based on it (the reverse of the usual relationship between the two). +#[stable(feature = "proc_macro_lib", since = "1.15.0")] +impl ToString for TokenTree { + fn to_string(&self) -> String { + match *self { + TokenTree::Group(ref t) => t.to_string(), + TokenTree::Ident(ref t) => t.to_string(), + TokenTree::Punct(ref t) => t.to_string(), + TokenTree::Literal(ref t) => t.to_string(), + } + } +} + /// Prints the token tree as a string that is supposed to be losslessly convertible back /// into the same token tree (modulo spans), except for possibly `TokenTree::Group`s /// with `Delimiter::None` delimiters and negative numeric literals. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] impl fmt::Display for TokenTree { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match *self { - TokenTree::Group(ref t) => t.fmt(f), - TokenTree::Ident(ref t) => t.fmt(f), - TokenTree::Punct(ref t) => t.fmt(f), - TokenTree::Literal(ref t) => t.fmt(f), - } + f.write_str(&self.to_string()) } } @@ -599,11 +562,7 @@ impl fmt::Display for TokenTree { /// A `Group` internally contains a `TokenStream` which is surrounded by `Delimiter`s. #[derive(Clone)] #[stable(feature = "proc_macro_lib2", since = "1.29.0")] -pub struct Group { - delimiter: Delimiter, - stream: TokenStream, - span: DelimSpan, -} +pub struct Group(bridge::client::Group); #[stable(feature = "proc_macro_lib2", since = "1.29.0")] impl !Send for Group {} @@ -640,17 +599,13 @@ impl Group { /// method below. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] pub fn new(delimiter: Delimiter, stream: TokenStream) -> Group { - Group { - delimiter: delimiter, - stream: stream, - span: DelimSpan::from_single(Span::call_site().0), - } + Group(bridge::client::Group::new(delimiter, stream.0)) } /// Returns the delimiter of this `Group` #[stable(feature = "proc_macro_lib2", since = "1.29.0")] pub fn delimiter(&self) -> Delimiter { - self.delimiter + self.0.delimiter() } /// Returns the `TokenStream` of tokens that are delimited in this `Group`. @@ -659,7 +614,7 @@ impl Group { /// returned above. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] pub fn stream(&self) -> TokenStream { - self.stream.clone() + TokenStream(self.0.stream()) } /// Returns the span for the delimiters of this token stream, spanning the @@ -671,7 +626,7 @@ impl Group { /// ``` #[stable(feature = "proc_macro_lib2", since = "1.29.0")] pub fn span(&self) -> Span { - Span(self.span.entire()) + Span(self.0.span()) } /// Returns the span pointing to the opening delimiter of this group. @@ -682,7 +637,7 @@ impl Group { /// ``` #[unstable(feature = "proc_macro_span", issue = "54725")] pub fn span_open(&self) -> Span { - Span(self.span.open) + Span(self.0.span_open()) } /// Returns the span pointing to the closing delimiter of this group. @@ -693,7 +648,7 @@ impl Group { /// ``` #[unstable(feature = "proc_macro_span", issue = "54725")] pub fn span_close(&self) -> Span { - Span(self.span.close) + Span(self.0.span_close()) } /// Configures the span for this `Group`'s delimiters, but not its internal @@ -704,7 +659,16 @@ impl Group { /// tokens at the level of the `Group`. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] pub fn set_span(&mut self, span: Span) { - self.span = DelimSpan::from_single(span.0); + self.0.set_span(span.0); + } +} + +// NB: the bridge only provides `to_string`, implement `fmt::Display` +// based on it (the reverse of the usual relationship between the two). +#[stable(feature = "proc_macro_lib", since = "1.15.0")] +impl ToString for Group { + fn to_string(&self) -> String { + TokenStream::from(TokenTree::from(self.clone())).to_string() } } @@ -714,7 +678,7 @@ impl Group { #[stable(feature = "proc_macro_lib2", since = "1.29.0")] impl fmt::Display for Group { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - TokenStream::from(TokenTree::from(self.clone())).fmt(f) + f.write_str(&self.to_string()) } } @@ -735,11 +699,7 @@ impl fmt::Debug for Group { /// forms of `Spacing` returned. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] #[derive(Clone)] -pub struct Punct { - ch: char, - spacing: Spacing, - span: Span, -} +pub struct Punct(bridge::client::Punct); #[stable(feature = "proc_macro_lib2", since = "1.29.0")] impl !Send for Punct {} @@ -774,17 +734,13 @@ impl Punct { if !LEGAL_CHARS.contains(&ch) { panic!("unsupported character `{:?}`", ch) } - Punct { - ch: ch, - spacing: spacing, - span: Span::call_site(), - } + Punct(bridge::client::Punct::new(ch, spacing)) } /// Returns the value of this punctuation character as `char`. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] pub fn as_char(&self) -> char { - self.ch + self.0.as_char() } /// Returns the spacing of this punctuation character, indicating whether it's immediately @@ -793,19 +749,28 @@ impl Punct { /// (`Alone`) so the operator has certainly ended. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] pub fn spacing(&self) -> Spacing { - self.spacing + self.0.spacing() } /// Returns the span for this punctuation character. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] pub fn span(&self) -> Span { - self.span + Span(self.0.span()) } /// Configure the span for this punctuation character. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] pub fn set_span(&mut self, span: Span) { - self.span = span; + self.0 = self.0.with_span(span.0); + } +} + +// NB: the bridge only provides `to_string`, implement `fmt::Display` +// based on it (the reverse of the usual relationship between the two). +#[stable(feature = "proc_macro_lib", since = "1.15.0")] +impl ToString for Punct { + fn to_string(&self) -> String { + TokenStream::from(TokenTree::from(self.clone())).to_string() } } @@ -814,7 +779,7 @@ impl Punct { #[stable(feature = "proc_macro_lib2", since = "1.29.0")] impl fmt::Display for Punct { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - TokenStream::from(TokenTree::from(self.clone())).fmt(f) + f.write_str(&self.to_string()) } } @@ -832,16 +797,7 @@ impl fmt::Debug for Punct { /// An identifier (`ident`). #[derive(Clone)] #[stable(feature = "proc_macro_lib2", since = "1.29.0")] -pub struct Ident { - sym: Symbol, - span: Span, - is_raw: bool, -} - -#[stable(feature = "proc_macro_lib2", since = "1.29.0")] -impl !Send for Ident {} -#[stable(feature = "proc_macro_lib2", since = "1.29.0")] -impl !Sync for Ident {} +pub struct Ident(bridge::client::Ident); impl Ident { fn is_valid(string: &str) -> bool { @@ -878,7 +834,7 @@ impl Ident { if !Ident::is_valid(string) { panic!("`{:?}` is not a valid identifier", string) } - Ident::new_maybe_raw(string, span, false) + Ident(bridge::client::Ident::new(string, span.0, false)) } /// Same as `Ident::new`, but creates a raw identifier (`r#ident`). @@ -887,20 +843,29 @@ impl Ident { if !Ident::is_valid(string) { panic!("`{:?}` is not a valid identifier", string) } - Ident::new_maybe_raw(string, span, true) + Ident(bridge::client::Ident::new(string, span.0, true)) } /// Returns the span of this `Ident`, encompassing the entire string returned /// by `as_str`. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] pub fn span(&self) -> Span { - self.span + Span(self.0.span()) } /// Configures the span of this `Ident`, possibly changing its hygiene context. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] pub fn set_span(&mut self, span: Span) { - self.span = span; + self.0 = self.0.with_span(span.0); + } +} + +// NB: the bridge only provides `to_string`, implement `fmt::Display` +// based on it (the reverse of the usual relationship between the two). +#[stable(feature = "proc_macro_lib", since = "1.15.0")] +impl ToString for Ident { + fn to_string(&self) -> String { + TokenStream::from(TokenTree::from(self.clone())).to_string() } } @@ -909,7 +874,7 @@ impl Ident { #[stable(feature = "proc_macro_lib2", since = "1.29.0")] impl fmt::Display for Ident { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - TokenStream::from(TokenTree::from(self.clone())).fmt(f) + f.write_str(&self.to_string()) } } @@ -927,19 +892,9 @@ impl fmt::Debug for Ident { /// character (`'a'`), byte character (`b'a'`), an integer or floating point number /// with or without a suffix (`1`, `1u8`, `2.3`, `2.3f32`). /// Boolean literals like `true` and `false` do not belong here, they are `Ident`s. -// FIXME(eddyb) `Literal` should not expose internal `Debug` impls. -#[derive(Clone, Debug)] -#[stable(feature = "proc_macro_lib2", since = "1.29.0")] -pub struct Literal { - lit: token::Lit, - suffix: Option, - span: Span, -} - -#[stable(feature = "proc_macro_lib2", since = "1.29.0")] -impl !Send for Literal {} +#[derive(Clone)] #[stable(feature = "proc_macro_lib2", since = "1.29.0")] -impl !Sync for Literal {} +pub struct Literal(bridge::client::Literal); macro_rules! suffixed_int_literals { ($($name:ident => $kind:ident,)*) => ($( @@ -956,11 +911,7 @@ macro_rules! suffixed_int_literals { /// below. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] pub fn $name(n: $kind) -> Literal { - Literal { - lit: token::Lit::Integer(Symbol::intern(&n.to_string())), - suffix: Some(Symbol::intern(stringify!($kind))), - span: Span::call_site(), - } + Literal(bridge::client::Literal::typed_integer(&n.to_string(), stringify!($kind))) } )*) } @@ -982,11 +933,7 @@ macro_rules! unsuffixed_int_literals { /// below. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] pub fn $name(n: $kind) -> Literal { - Literal { - lit: token::Lit::Integer(Symbol::intern(&n.to_string())), - suffix: None, - span: Span::call_site(), - } + Literal(bridge::client::Literal::integer(&n.to_string())) } )*) } @@ -1039,11 +986,7 @@ impl Literal { if !n.is_finite() { panic!("Invalid float literal {}", n); } - Literal { - lit: token::Lit::Float(Symbol::intern(&n.to_string())), - suffix: None, - span: Span::call_site(), - } + Literal(bridge::client::Literal::float(&n.to_string())) } /// Creates a new suffixed floating-point literal. @@ -1064,11 +1007,7 @@ impl Literal { if !n.is_finite() { panic!("Invalid float literal {}", n); } - Literal { - lit: token::Lit::Float(Symbol::intern(&n.to_string())), - suffix: Some(Symbol::intern("f32")), - span: Span::call_site(), - } + Literal(bridge::client::Literal::f32(&n.to_string())) } /// Creates a new unsuffixed floating-point literal. @@ -1088,11 +1027,7 @@ impl Literal { if !n.is_finite() { panic!("Invalid float literal {}", n); } - Literal { - lit: token::Lit::Float(Symbol::intern(&n.to_string())), - suffix: None, - span: Span::call_site(), - } + Literal(bridge::client::Literal::float(&n.to_string())) } /// Creates a new suffixed floating-point literal. @@ -1113,61 +1048,37 @@ impl Literal { if !n.is_finite() { panic!("Invalid float literal {}", n); } - Literal { - lit: token::Lit::Float(Symbol::intern(&n.to_string())), - suffix: Some(Symbol::intern("f64")), - span: Span::call_site(), - } + Literal(bridge::client::Literal::f64(&n.to_string())) } /// String literal. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] pub fn string(string: &str) -> Literal { - let mut escaped = String::new(); - for ch in string.chars() { - escaped.extend(ch.escape_debug()); - } - Literal { - lit: token::Lit::Str_(Symbol::intern(&escaped)), - suffix: None, - span: Span::call_site(), - } + Literal(bridge::client::Literal::string(string)) } /// Character literal. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] pub fn character(ch: char) -> Literal { - let mut escaped = String::new(); - escaped.extend(ch.escape_unicode()); - Literal { - lit: token::Lit::Char(Symbol::intern(&escaped)), - suffix: None, - span: Span::call_site(), - } + Literal(bridge::client::Literal::character(ch)) } /// Byte string literal. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] pub fn byte_string(bytes: &[u8]) -> Literal { - let string = bytes.iter().cloned().flat_map(ascii::escape_default) - .map(Into::::into).collect::(); - Literal { - lit: token::Lit::ByteStr(Symbol::intern(&string)), - suffix: None, - span: Span::call_site(), - } + Literal(bridge::client::Literal::byte_string(bytes)) } /// Returns the span encompassing this literal. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] pub fn span(&self) -> Span { - self.span + Span(self.0.span()) } /// Configures the span associated for this literal. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] pub fn set_span(&mut self, span: Span) { - self.span = span; + self.0.set_span(span.0); } /// Returns a `Span` that is a subset of `self.span()` containing only the @@ -1183,35 +1094,28 @@ impl Literal { // was 'c' or whether it was '\u{63}'. #[unstable(feature = "proc_macro_span", issue = "54725")] pub fn subspan>(&self, range: R) -> Option { - let inner = self.span().0; - let length = inner.hi().to_usize() - inner.lo().to_usize(); - - let start = match range.start_bound() { - Bound::Included(&lo) => lo, - Bound::Excluded(&lo) => lo + 1, - Bound::Unbounded => 0, - }; - - let end = match range.end_bound() { - Bound::Included(&hi) => hi + 1, - Bound::Excluded(&hi) => hi, - Bound::Unbounded => length, - }; - - // Bounds check the values, preventing addition overflow and OOB spans. - if start > u32::max_value() as usize - || end > u32::max_value() as usize - || (u32::max_value() - start as u32) < inner.lo().to_u32() - || (u32::max_value() - end as u32) < inner.lo().to_u32() - || start >= end - || end > length - { - return None; + // HACK(eddyb) something akin to `Option::cloned`, but for `Bound<&T>`. + fn cloned_bound(bound: Bound<&T>) -> Bound { + match bound { + Bound::Included(x) => Bound::Included(x.clone()), + Bound::Excluded(x) => Bound::Excluded(x.clone()), + Bound::Unbounded => Bound::Unbounded, + } } - let new_lo = inner.lo() + BytePos::from_usize(start); - let new_hi = inner.lo() + BytePos::from_usize(end); - Some(Span(inner.with_lo(new_lo).with_hi(new_hi))) + self.0.subspan( + cloned_bound(range.start_bound()), + cloned_bound(range.end_bound()), + ).map(Span) + } +} + +// NB: the bridge only provides `to_string`, implement `fmt::Display` +// based on it (the reverse of the usual relationship between the two). +#[stable(feature = "proc_macro_lib", since = "1.15.0")] +impl ToString for Literal { + fn to_string(&self) -> String { + TokenStream::from(TokenTree::from(self.clone())).to_string() } } @@ -1220,149 +1124,14 @@ impl Literal { #[stable(feature = "proc_macro_lib2", since = "1.29.0")] impl fmt::Display for Literal { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - TokenStream::from(TokenTree::from(self.clone())).fmt(f) + f.write_str(&self.to_string()) } } -/// Permanently unstable internal implementation details of this crate. This -/// should not be used. -/// -/// These methods are used by the rest of the compiler to generate instances of -/// `TokenStream` to hand to macro definitions, as well as consume the output. -/// -/// Note that this module is also intentionally separate from the rest of the -/// crate. This allows the `#[unstable]` directive below to naturally apply to -/// all of the contents. -#[unstable(feature = "proc_macro_internals", issue = "27812")] -#[doc(hidden)] -pub mod __internal { - use std::cell::Cell; - use std::ptr; - - use syntax::ast; - use syntax::ext::base::ExtCtxt; - use syntax::ptr::P; - use syntax::parse::{self, ParseSess}; - use syntax::parse::token::{self, Token}; - use syntax::tokenstream; - use syntax_pos::{BytePos, Loc, DUMMY_SP}; - use syntax_pos::hygiene::{SyntaxContext, Transparency}; - - use super::{TokenStream, LexError, Span}; - - pub fn lookup_char_pos(pos: BytePos) -> Loc { - with_sess(|sess, _| sess.source_map().lookup_char_pos(pos)) - } - - pub fn new_token_stream(item: P) -> TokenStream { - let token = Token::interpolated(token::NtItem(item)); - TokenStream(tokenstream::TokenTree::Token(DUMMY_SP, token).into()) - } - - pub fn token_stream_wrap(inner: tokenstream::TokenStream) -> TokenStream { - TokenStream(inner) - } - - pub fn token_stream_parse_items(stream: TokenStream) -> Result>, LexError> { - with_sess(move |sess, _| { - let mut parser = parse::stream_to_parser(sess, stream.0); - let mut items = Vec::new(); - - while let Some(item) = try!(parser.parse_item().map_err(super::parse_to_lex_err)) { - items.push(item) - } - - Ok(items) - }) - } - - pub fn token_stream_inner(stream: TokenStream) -> tokenstream::TokenStream { - stream.0 - } - - pub trait Registry { - fn register_custom_derive(&mut self, - trait_name: &str, - expand: fn(TokenStream) -> TokenStream, - attributes: &[&'static str]); - - fn register_attr_proc_macro(&mut self, - name: &str, - expand: fn(TokenStream, TokenStream) -> TokenStream); - - fn register_bang_proc_macro(&mut self, - name: &str, - expand: fn(TokenStream) -> TokenStream); - } - - #[derive(Clone, Copy)] - pub struct ProcMacroData { - pub def_site: Span, - pub call_site: Span, - } - - #[derive(Clone, Copy)] - struct ProcMacroSess { - parse_sess: *const ParseSess, - data: ProcMacroData, - } - - // Emulate scoped_thread_local!() here essentially - thread_local! { - static CURRENT_SESS: Cell = Cell::new(ProcMacroSess { - parse_sess: ptr::null(), - data: ProcMacroData { def_site: Span(DUMMY_SP), call_site: Span(DUMMY_SP) }, - }); - } - - pub fn set_sess(cx: &ExtCtxt, f: F) -> R - where F: FnOnce() -> R - { - struct Reset { prev: ProcMacroSess } - - impl Drop for Reset { - fn drop(&mut self) { - CURRENT_SESS.with(|p| p.set(self.prev)); - } - } - - CURRENT_SESS.with(|p| { - let _reset = Reset { prev: p.get() }; - - // No way to determine def location for a proc macro right now, so use call location. - let location = cx.current_expansion.mark.expn_info().unwrap().call_site; - let to_span = |transparency| Span(location.with_ctxt( - SyntaxContext::empty().apply_mark_with_transparency(cx.current_expansion.mark, - transparency)) - ); - p.set(ProcMacroSess { - parse_sess: cx.parse_sess, - data: ProcMacroData { - def_site: to_span(Transparency::Opaque), - call_site: to_span(Transparency::Transparent), - }, - }); - f() - }) - } - - pub fn in_sess() -> bool - { - !CURRENT_SESS.with(|sess| sess.get()).parse_sess.is_null() - } - - pub fn with_sess(f: F) -> R - where F: FnOnce(&ParseSess, &ProcMacroData) -> R - { - let sess = CURRENT_SESS.with(|sess| sess.get()); - if sess.parse_sess.is_null() { - panic!("procedural macro API is used outside of a procedural macro"); - } - f(unsafe { &*sess.parse_sess }, &sess.data) +#[stable(feature = "proc_macro_lib2", since = "1.29.0")] +impl fmt::Debug for Literal { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + // FIXME(eddyb) `Literal` should not expose internal `Debug` impls. + self.0.fmt(f) } } - -fn parse_to_lex_err(mut err: DiagnosticBuilder) -> LexError { - err.cancel(); - LexError { _inner: () } -} diff --git a/src/libproc_macro/rustc.rs b/src/libproc_macro/rustc.rs deleted file mode 100644 index 3ce02d1afb10b..0000000000000 --- a/src/libproc_macro/rustc.rs +++ /dev/null @@ -1,283 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use {Delimiter, Level, Spacing, Span, __internal}; -use {Group, Ident, Literal, Punct, TokenTree}; - -use rustc_errors as errors; -use syntax::ast; -use syntax::parse::lexer::comments; -use syntax::parse::token; -use syntax::tokenstream; -use syntax_pos::symbol::{keywords, Symbol}; - -impl Ident { - pub(crate) fn new_maybe_raw(string: &str, span: Span, is_raw: bool) -> Ident { - let sym = Symbol::intern(string); - if is_raw - && (sym == keywords::Underscore.name() - || ast::Ident::with_empty_ctxt(sym).is_path_segment_keyword()) - { - panic!("`{:?}` is not a valid raw identifier", string) - } - Ident { sym, span, is_raw } - } -} - -impl Delimiter { - pub(crate) fn from_internal(delim: token::DelimToken) -> Delimiter { - match delim { - token::Paren => Delimiter::Parenthesis, - token::Brace => Delimiter::Brace, - token::Bracket => Delimiter::Bracket, - token::NoDelim => Delimiter::None, - } - } - - pub(crate) fn to_internal(self) -> token::DelimToken { - match self { - Delimiter::Parenthesis => token::Paren, - Delimiter::Brace => token::Brace, - Delimiter::Bracket => token::Bracket, - Delimiter::None => token::NoDelim, - } - } -} - -impl TokenTree { - pub(crate) fn from_internal( - stream: tokenstream::TokenStream, - stack: &mut Vec, - ) -> TokenTree { - use syntax::parse::token::*; - - let (tree, is_joint) = stream.as_tree(); - let (span, token) = match tree { - tokenstream::TokenTree::Token(span, token) => (span, token), - tokenstream::TokenTree::Delimited(span, delimed) => { - let delimiter = Delimiter::from_internal(delimed.delim); - let mut g = Group::new(delimiter, ::TokenStream(delimed.tts.into())); - g.span = span; - return g.into(); - } - }; - - let op_kind = if is_joint { - Spacing::Joint - } else { - Spacing::Alone - }; - macro_rules! tt { - ($e:expr) => {{ - let mut x = TokenTree::from($e); - x.set_span(Span(span)); - x - }}; - } - macro_rules! op { - ($a:expr) => { - tt!(Punct::new($a, op_kind)) - }; - ($a:expr, $b:expr) => {{ - stack.push(tt!(Punct::new($b, op_kind))); - tt!(Punct::new($a, Spacing::Joint)) - }}; - ($a:expr, $b:expr, $c:expr) => {{ - stack.push(tt!(Punct::new($c, op_kind))); - stack.push(tt!(Punct::new($b, Spacing::Joint))); - tt!(Punct::new($a, Spacing::Joint)) - }}; - } - - match token { - Eq => op!('='), - Lt => op!('<'), - Le => op!('<', '='), - EqEq => op!('=', '='), - Ne => op!('!', '='), - Ge => op!('>', '='), - Gt => op!('>'), - AndAnd => op!('&', '&'), - OrOr => op!('|', '|'), - Not => op!('!'), - Tilde => op!('~'), - BinOp(Plus) => op!('+'), - BinOp(Minus) => op!('-'), - BinOp(Star) => op!('*'), - BinOp(Slash) => op!('/'), - BinOp(Percent) => op!('%'), - BinOp(Caret) => op!('^'), - BinOp(And) => op!('&'), - BinOp(Or) => op!('|'), - BinOp(Shl) => op!('<', '<'), - BinOp(Shr) => op!('>', '>'), - BinOpEq(Plus) => op!('+', '='), - BinOpEq(Minus) => op!('-', '='), - BinOpEq(Star) => op!('*', '='), - BinOpEq(Slash) => op!('/', '='), - BinOpEq(Percent) => op!('%', '='), - BinOpEq(Caret) => op!('^', '='), - BinOpEq(And) => op!('&', '='), - BinOpEq(Or) => op!('|', '='), - BinOpEq(Shl) => op!('<', '<', '='), - BinOpEq(Shr) => op!('>', '>', '='), - At => op!('@'), - Dot => op!('.'), - DotDot => op!('.', '.'), - DotDotDot => op!('.', '.', '.'), - DotDotEq => op!('.', '.', '='), - Comma => op!(','), - Semi => op!(';'), - Colon => op!(':'), - ModSep => op!(':', ':'), - RArrow => op!('-', '>'), - LArrow => op!('<', '-'), - FatArrow => op!('=', '>'), - Pound => op!('#'), - Dollar => op!('$'), - Question => op!('?'), - SingleQuote => op!('\''), - - Ident(ident, false) => tt!(self::Ident::new(&ident.as_str(), Span(span))), - Ident(ident, true) => tt!(self::Ident::new_raw(&ident.as_str(), Span(span))), - Lifetime(ident) => { - let ident = ident.without_first_quote(); - stack.push(tt!(self::Ident::new(&ident.as_str(), Span(span)))); - tt!(Punct::new('\'', Spacing::Joint)) - } - Literal(lit, suffix) => tt!(self::Literal { - lit, - suffix, - span: Span(span) - }), - DocComment(c) => { - let style = comments::doc_comment_style(&c.as_str()); - let stripped = comments::strip_doc_comment_decoration(&c.as_str()); - let stream = vec![ - tt!(self::Ident::new("doc", Span(span))), - tt!(Punct::new('=', Spacing::Alone)), - tt!(self::Literal::string(&stripped)), - ].into_iter() - .collect(); - stack.push(tt!(Group::new(Delimiter::Bracket, stream))); - if style == ast::AttrStyle::Inner { - stack.push(tt!(Punct::new('!', Spacing::Alone))); - } - tt!(Punct::new('#', Spacing::Alone)) - } - - Interpolated(_) => __internal::with_sess(|sess, _| { - let tts = token.interpolated_to_tokenstream(sess, span); - tt!(Group::new(Delimiter::None, ::TokenStream(tts))) - }), - - DotEq => op!('.', '='), - OpenDelim(..) | CloseDelim(..) => unreachable!(), - Whitespace | Comment | Shebang(..) | Eof => unreachable!(), - } - } - - pub(crate) fn to_internal(self) -> tokenstream::TokenStream { - use syntax::parse::token::*; - use syntax::tokenstream::{Delimited, TokenTree}; - - let (ch, kind, span) = match self { - self::TokenTree::Punct(tt) => (tt.as_char(), tt.spacing(), tt.span()), - self::TokenTree::Group(tt) => { - return TokenTree::Delimited( - tt.span, - Delimited { - delim: tt.delimiter.to_internal(), - tts: tt.stream.0.into(), - }, - ).into(); - } - self::TokenTree::Ident(tt) => { - let token = Ident(ast::Ident::new(tt.sym, tt.span.0), tt.is_raw); - return TokenTree::Token(tt.span.0, token).into(); - } - self::TokenTree::Literal(self::Literal { - lit: Lit::Integer(ref a), - suffix, - span, - }) - if a.as_str().starts_with("-") => - { - let minus = BinOp(BinOpToken::Minus); - let integer = Symbol::intern(&a.as_str()[1..]); - let integer = Literal(Lit::Integer(integer), suffix); - let a = TokenTree::Token(span.0, minus); - let b = TokenTree::Token(span.0, integer); - return vec![a, b].into_iter().collect(); - } - self::TokenTree::Literal(self::Literal { - lit: Lit::Float(ref a), - suffix, - span, - }) - if a.as_str().starts_with("-") => - { - let minus = BinOp(BinOpToken::Minus); - let float = Symbol::intern(&a.as_str()[1..]); - let float = Literal(Lit::Float(float), suffix); - let a = TokenTree::Token(span.0, minus); - let b = TokenTree::Token(span.0, float); - return vec![a, b].into_iter().collect(); - } - self::TokenTree::Literal(tt) => { - let token = Literal(tt.lit, tt.suffix); - return TokenTree::Token(tt.span.0, token).into(); - } - }; - - let token = match ch { - '=' => Eq, - '<' => Lt, - '>' => Gt, - '!' => Not, - '~' => Tilde, - '+' => BinOp(Plus), - '-' => BinOp(Minus), - '*' => BinOp(Star), - '/' => BinOp(Slash), - '%' => BinOp(Percent), - '^' => BinOp(Caret), - '&' => BinOp(And), - '|' => BinOp(Or), - '@' => At, - '.' => Dot, - ',' => Comma, - ';' => Semi, - ':' => Colon, - '#' => Pound, - '$' => Dollar, - '?' => Question, - '\'' => SingleQuote, - _ => unreachable!(), - }; - - let tree = TokenTree::Token(span.0, token); - match kind { - Spacing::Alone => tree.into(), - Spacing::Joint => tree.joint(), - } - } -} - -impl Level { - pub(crate) fn to_internal(self) -> errors::Level { - match self { - Level::Error => errors::Level::Error, - Level::Warning => errors::Level::Warning, - Level::Note => errors::Level::Note, - Level::Help => errors::Level::Help, - } - } -} diff --git a/src/librustc/Cargo.toml b/src/librustc/Cargo.toml index d0ec8640ce9ef..3316735de663e 100644 --- a/src/librustc/Cargo.toml +++ b/src/librustc/Cargo.toml @@ -18,7 +18,6 @@ lazy_static = "1.0.0" scoped-tls = { version = "0.1.1", features = ["nightly"] } log = { version = "0.4", features = ["release_max_level_info", "std"] } polonius-engine = "0.5.0" -proc_macro = { path = "../libproc_macro" } rustc-rayon = "0.1.1" rustc-rayon-core = "0.1.1" rustc_apfloat = { path = "../librustc_apfloat" } diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index 3ff2545f78dfa..388bbc52c3b1a 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -596,7 +596,7 @@ define_dep_nodes!( <'tcx> [] ReachableNonGenerics(CrateNum), [] NativeLibraries(CrateNum), [] PluginRegistrarFn(CrateNum), - [] DeriveRegistrarFn(CrateNum), + [] ProcMacroDeclsStatic(CrateNum), [input] CrateDisambiguator(CrateNum), [input] CrateHash(CrateNum), [input] OriginalCrateName(CrateNum), diff --git a/src/librustc/middle/dependency_format.rs b/src/librustc/middle/dependency_format.rs index 671f513d5b933..549a848a39dc1 100644 --- a/src/librustc/middle/dependency_format.rs +++ b/src/librustc/middle/dependency_format.rs @@ -127,9 +127,8 @@ fn calculate_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sess.crt_static() => Linkage::Static, config::CrateType::Executable => Linkage::Dynamic, - // proc-macro crates are required to be dylibs, and they're currently - // required to link to libsyntax as well. - config::CrateType::ProcMacro => Linkage::Dynamic, + // proc-macro crates are mostly cdylibs, but we also need metadata. + config::CrateType::ProcMacro => Linkage::Static, // No linkage happens with rlibs, we just needed the metadata (which we // got long ago), so don't bother with anything. diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index 1187c53305d1c..d1c3acc57b723 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -68,7 +68,7 @@ pub struct Session { /// For a library crate, this is always none pub entry_fn: Once>, pub plugin_registrar_fn: Once>, - pub derive_registrar_fn: Once>, + pub proc_macro_decls_static: Once>, pub default_sysroot: Option, /// The name of the root source file of the crate, in the local file system. /// `None` means that there is no source file. @@ -687,9 +687,9 @@ impl Session { ) } - pub fn generate_derive_registrar_symbol(&self, disambiguator: CrateDisambiguator) -> String { + pub fn generate_proc_macro_decls_symbol(&self, disambiguator: CrateDisambiguator) -> String { format!( - "__rustc_derive_registrar_{}__", + "__rustc_proc_macro_decls_{}__", disambiguator.to_fingerprint().to_hex() ) } @@ -1146,7 +1146,7 @@ pub fn build_session_( // For a library crate, this is always none entry_fn: Once::new(), plugin_registrar_fn: Once::new(), - derive_registrar_fn: Once::new(), + proc_macro_decls_static: Once::new(), default_sysroot, local_crate_source_file, working_dir, diff --git a/src/librustc/ty/query/config.rs b/src/librustc/ty/query/config.rs index bb33def51cc3b..5d12aaeed5f79 100644 --- a/src/librustc/ty/query/config.rs +++ b/src/librustc/ty/query/config.rs @@ -591,7 +591,7 @@ impl<'tcx> QueryDescription<'tcx> for queries::plugin_registrar_fn<'tcx> { } } -impl<'tcx> QueryDescription<'tcx> for queries::derive_registrar_fn<'tcx> { +impl<'tcx> QueryDescription<'tcx> for queries::proc_macro_decls_static<'tcx> { fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { "looking up the derive registrar for a crate".into() } diff --git a/src/librustc/ty/query/mod.rs b/src/librustc/ty/query/mod.rs index 22bd1e26ba3ee..699c2d111c639 100644 --- a/src/librustc/ty/query/mod.rs +++ b/src/librustc/ty/query/mod.rs @@ -470,7 +470,7 @@ define_queries! { <'tcx> [] fn foreign_modules: ForeignModules(CrateNum) -> Lrc>, [] fn plugin_registrar_fn: PluginRegistrarFn(CrateNum) -> Option, - [] fn derive_registrar_fn: DeriveRegistrarFn(CrateNum) -> Option, + [] fn proc_macro_decls_static: ProcMacroDeclsStatic(CrateNum) -> Option, [] fn crate_disambiguator: CrateDisambiguator(CrateNum) -> CrateDisambiguator, [] fn crate_hash: CrateHash(CrateNum) -> Svh, [] fn original_crate_name: OriginalCrateName(CrateNum) -> Symbol, diff --git a/src/librustc/ty/query/plumbing.rs b/src/librustc/ty/query/plumbing.rs index efee39a1d63f9..5f33d466c4a19 100644 --- a/src/librustc/ty/query/plumbing.rs +++ b/src/librustc/ty/query/plumbing.rs @@ -1200,7 +1200,7 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>, DepKind::ReachableNonGenerics => { force!(reachable_non_generics, krate!()); } DepKind::NativeLibraries => { force!(native_libraries, krate!()); } DepKind::PluginRegistrarFn => { force!(plugin_registrar_fn, krate!()); } - DepKind::DeriveRegistrarFn => { force!(derive_registrar_fn, krate!()); } + DepKind::ProcMacroDeclsStatic => { force!(proc_macro_decls_static, krate!()); } DepKind::CrateDisambiguator => { force!(crate_disambiguator, krate!()); } DepKind::CrateHash => { force!(crate_hash, krate!()); } DepKind::OriginalCrateName => { force!(original_crate_name, krate!()); } diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index bcc0b8047ef74..7a246af82e5fe 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -24,7 +24,6 @@ use std::sync::mpsc::{Sender}; use syntax_pos::{SpanData}; use ty::TyCtxt; use dep_graph::{DepNode}; -use proc_macro; use lazy_static; use session::Session; @@ -47,14 +46,13 @@ lazy_static! { } fn panic_hook(info: &panic::PanicInfo<'_>) { - if !proc_macro::__internal::in_sess() { - (*DEFAULT_HOOK)(info); + (*DEFAULT_HOOK)(info); - let backtrace = env::var_os("RUST_BACKTRACE").map(|x| &x != "0").unwrap_or(false); + let backtrace = env::var_os("RUST_BACKTRACE").map(|x| &x != "0").unwrap_or(false); - if backtrace { - TyCtxt::try_print_query_stack(); - } + if backtrace { + TyCtxt::try_print_query_stack(); + } #[cfg(windows)] unsafe { @@ -66,7 +64,6 @@ fn panic_hook(info: &panic::PanicInfo<'_>) { DebugBreak(); } } - } } pub fn install_panic_hook() { diff --git a/src/librustc_codegen_ssa/back/symbol_export.rs b/src/librustc_codegen_ssa/back/symbol_export.rs index 0463da00c89d9..0fb2641a4f82e 100644 --- a/src/librustc_codegen_ssa/back/symbol_export.rs +++ b/src/librustc_codegen_ssa/back/symbol_export.rs @@ -157,7 +157,7 @@ fn reachable_non_generics_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, }) .collect(); - if let Some(id) = *tcx.sess.derive_registrar_fn.get() { + if let Some(id) = *tcx.sess.proc_macro_decls_static.get() { let def_id = tcx.hir.local_def_id(id); reachable_non_generics.insert(def_id, SymbolExportLevel::C); } diff --git a/src/librustc_codegen_utils/symbol_names.rs b/src/librustc_codegen_utils/symbol_names.rs index f8593363bb16a..344a252578472 100644 --- a/src/librustc_codegen_utils/symbol_names.rs +++ b/src/librustc_codegen_utils/symbol_names.rs @@ -257,9 +257,9 @@ fn compute_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance let disambiguator = tcx.sess.local_crate_disambiguator(); return tcx.sess.generate_plugin_registrar_symbol(disambiguator); } - if *tcx.sess.derive_registrar_fn.get() == Some(id) { + if *tcx.sess.proc_macro_decls_static.get() == Some(id) { let disambiguator = tcx.sess.local_crate_disambiguator(); - return tcx.sess.generate_derive_registrar_symbol(disambiguator); + return tcx.sess.generate_proc_macro_decls_symbol(disambiguator); } } diff --git a/src/librustc_cratesio_shim/src/lib.rs b/src/librustc_cratesio_shim/src/lib.rs index 1fe70fa23b7a2..56e480208e1c3 100644 --- a/src/librustc_cratesio_shim/src/lib.rs +++ b/src/librustc_cratesio_shim/src/lib.rs @@ -15,4 +15,5 @@ extern crate bitflags; extern crate log; +extern crate proc_macro; extern crate unicode_width; diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 7ad012409b53a..c1705ad2d58ff 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -62,7 +62,7 @@ use syntax::symbol::Symbol; use syntax_pos::{FileName, hygiene}; use syntax_ext; -use derive_registrar; +use proc_macro_decls; use pretty::ReplaceBodyWithLoop; use profile; @@ -1066,7 +1066,7 @@ where let num_crate_types = crate_types.len(); let is_proc_macro_crate = crate_types.contains(&config::CrateType::ProcMacro); let is_test_crate = sess.opts.test; - syntax_ext::proc_macro_registrar::modify( + syntax_ext::proc_macro_decls::modify( &sess.parse_sess, &mut resolver, krate, @@ -1243,8 +1243,8 @@ where .set(time(sess, "looking for plugin registrar", || { plugin::build::find_plugin_registrar(sess.diagnostic(), &hir_map) })); - sess.derive_registrar_fn - .set(derive_registrar::find(&hir_map)); + sess.proc_macro_decls_static + .set(proc_macro_decls::find(&hir_map)); time(sess, "loop checking", || loops::check_crate(sess, &hir_map)); diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index ec3cb95db88f8..b063176d3cafa 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -127,7 +127,7 @@ mod test; pub mod profile; pub mod driver; pub mod pretty; -mod derive_registrar; +mod proc_macro_decls; pub mod target_features { use syntax::ast; diff --git a/src/librustc_driver/derive_registrar.rs b/src/librustc_driver/proc_macro_decls.rs similarity index 81% rename from src/librustc_driver/derive_registrar.rs rename to src/librustc_driver/proc_macro_decls.rs index 9983efce6af0b..136a27b1ced47 100644 --- a/src/librustc_driver/derive_registrar.rs +++ b/src/librustc_driver/proc_macro_decls.rs @@ -17,19 +17,19 @@ use syntax::attr; pub fn find(hir_map: &Map) -> Option { let krate = hir_map.krate(); - let mut finder = Finder { registrar: None }; + let mut finder = Finder { decls: None }; krate.visit_all_item_likes(&mut finder); - finder.registrar + finder.decls } struct Finder { - registrar: Option, + decls: Option, } impl<'v> ItemLikeVisitor<'v> for Finder { fn visit_item(&mut self, item: &hir::Item) { - if attr::contains_name(&item.attrs, "rustc_derive_registrar") { - self.registrar = Some(item.id); + if attr::contains_name(&item.attrs, "rustc_proc_macro_decls") { + self.decls = Some(item.id); } } diff --git a/src/librustc_metadata/Cargo.toml b/src/librustc_metadata/Cargo.toml index 276e2a911e697..337c87c24ba2b 100644 --- a/src/librustc_metadata/Cargo.toml +++ b/src/librustc_metadata/Cargo.toml @@ -12,7 +12,6 @@ crate-type = ["dylib"] flate2 = "1.0" log = "0.4" memmap = "0.6" -proc_macro = { path = "../libproc_macro" } rustc = { path = "../librustc" } rustc_data_structures = { path = "../librustc_data_structures" } rustc_errors = { path = "../librustc_errors" } diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index a14dd99eeb3b3..4ff29f5c04d41 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -36,7 +36,6 @@ use std::{cmp, fs}; use syntax::ast; use syntax::attr; -use syntax::edition::Edition; use syntax::ext::base::SyntaxExtension; use syntax::symbol::Symbol; use syntax::visit; @@ -231,7 +230,7 @@ impl<'a> CrateLoader<'a> { let dependencies: Vec = cnum_map.iter().cloned().collect(); - let proc_macros = crate_root.macro_derive_registrar.map(|_| { + let proc_macros = crate_root.proc_macro_decls_static.map(|_| { self.load_derive_macros(&crate_root, dylib.clone().map(|p| p.0), span) }); @@ -339,7 +338,7 @@ impl<'a> CrateLoader<'a> { match result { LoadResult::Previous(cnum) => { let data = self.cstore.get_crate_data(cnum); - if data.root.macro_derive_registrar.is_some() { + if data.root.proc_macro_decls_static.is_some() { dep_kind = DepKind::UnexportedMacrosOnly; } data.dep_kind.with_lock(|data_dep_kind| { @@ -431,7 +430,7 @@ impl<'a> CrateLoader<'a> { dep_kind: DepKind) -> cstore::CrateNumMap { debug!("resolving deps of external crate"); - if crate_root.macro_derive_registrar.is_some() { + if crate_root.proc_macro_decls_static.is_some() { return cstore::CrateNumMap::new(); } @@ -533,9 +532,8 @@ impl<'a> CrateLoader<'a> { fn load_derive_macros(&mut self, root: &CrateRoot, dylib: Option, span: Span) -> Vec<(ast::Name, Lrc)> { use std::{env, mem}; - use proc_macro::TokenStream; - use proc_macro::__internal::Registry; use dynamic_lib::DynamicLibrary; + use proc_macro::bridge::client::ProcMacro; use syntax_ext::deriving::custom::ProcMacroDerive; use syntax_ext::proc_macro_impl::{AttrProcMacro, BangProcMacro}; @@ -550,61 +548,49 @@ impl<'a> CrateLoader<'a> { Err(err) => self.sess.span_fatal(span, &err), }; - let sym = self.sess.generate_derive_registrar_symbol(root.disambiguator); - let registrar = unsafe { + let sym = self.sess.generate_proc_macro_decls_symbol(root.disambiguator); + let decls = unsafe { let sym = match lib.symbol(&sym) { Ok(f) => f, Err(err) => self.sess.span_fatal(span, &err), }; - mem::transmute::<*mut u8, fn(&mut dyn Registry)>(sym) + *(sym as *const &[ProcMacro]) }; - struct MyRegistrar { - extensions: Vec<(ast::Name, Lrc)>, - edition: Edition, - } - - impl Registry for MyRegistrar { - fn register_custom_derive(&mut self, - trait_name: &str, - expand: fn(TokenStream) -> TokenStream, - attributes: &[&'static str]) { - let attrs = attributes.iter().cloned().map(Symbol::intern).collect::>(); - let derive = ProcMacroDerive::new(expand, attrs.clone()); - let derive = SyntaxExtension::ProcMacroDerive( - Box::new(derive), attrs, self.edition - ); - self.extensions.push((Symbol::intern(trait_name), Lrc::new(derive))); - } - - fn register_attr_proc_macro(&mut self, - name: &str, - expand: fn(TokenStream, TokenStream) -> TokenStream) { - let expand = SyntaxExtension::AttrProcMacro( - Box::new(AttrProcMacro { inner: expand }), self.edition - ); - self.extensions.push((Symbol::intern(name), Lrc::new(expand))); - } - - fn register_bang_proc_macro(&mut self, - name: &str, - expand: fn(TokenStream) -> TokenStream) { - let expand = SyntaxExtension::ProcMacro { - expander: Box::new(BangProcMacro { inner: expand }), - allow_internal_unstable: false, - edition: self.edition, - }; - self.extensions.push((Symbol::intern(name), Lrc::new(expand))); + let extensions = decls.iter().map(|&decl| { + match decl { + ProcMacro::CustomDerive { trait_name, attributes, client } => { + let attrs = attributes.iter().cloned().map(Symbol::intern).collect::>(); + (trait_name, SyntaxExtension::ProcMacroDerive( + Box::new(ProcMacroDerive { + client, + attrs: attrs.clone(), + }), + attrs, + root.edition, + )) + } + ProcMacro::Attr { name, client } => { + (name, SyntaxExtension::AttrProcMacro( + Box::new(AttrProcMacro { client }), + root.edition, + )) + } + ProcMacro::Bang { name, client } => { + (name, SyntaxExtension::ProcMacro { + expander: Box::new(BangProcMacro { client }), + allow_internal_unstable: false, + edition: root.edition, + }) + } } - } - - let mut my_registrar = MyRegistrar { extensions: Vec::new(), edition: root.edition }; - registrar(&mut my_registrar); + }).map(|(name, ext)| (Symbol::intern(name), Lrc::new(ext))).collect(); // Intentionally leak the dynamic library. We can't ever unload it // since the library can make things that will live arbitrarily long. mem::forget(lib); - my_registrar.extensions + + extensions } /// Look for a plugin registrar. Returns library path, crate diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index c7bd1744a3d6d..d0fa63a6163db 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -203,8 +203,8 @@ provide! { <'tcx> tcx, def_id, other, cdata, DefId { krate: def_id.krate, index } }) } - derive_registrar_fn => { - cdata.root.macro_derive_registrar.map(|index| { + proc_macro_decls_static => { + cdata.root.proc_macro_decls_static.map(|index| { DefId { krate: def_id.krate, index } }) } @@ -431,8 +431,9 @@ impl cstore::CStore { use syntax::ext::base::SyntaxExtension; use syntax_ext::proc_macro_impl::BangProcMacro; + let client = ::proc_macro::bridge::client::Client::expand1(::proc_macro::quote); let ext = SyntaxExtension::ProcMacro { - expander: Box::new(BangProcMacro { inner: ::proc_macro::quote }), + expander: Box::new(BangProcMacro { client }), allow_internal_unstable: true, edition: data.root.edition, }; diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index 5421972a4adcb..2736c60ffb6fa 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -496,8 +496,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { .plugin_registrar_fn .get() .map(|id| tcx.hir.local_def_id(id).index), - macro_derive_registrar: if is_proc_macro { - let id = tcx.sess.derive_registrar_fn.get().unwrap(); + proc_macro_decls_static: if is_proc_macro { + let id = tcx.sess.proc_macro_decls_static.get().unwrap(); Some(tcx.hir.local_def_id(id).index) } else { None diff --git a/src/librustc_metadata/locator.rs b/src/librustc_metadata/locator.rs index 528c96f240dba..d4e51693d7edf 100644 --- a/src/librustc_metadata/locator.rs +++ b/src/librustc_metadata/locator.rs @@ -713,7 +713,7 @@ impl<'a> Context<'a> { let root = metadata.get_root(); if let Some(is_proc_macro) = self.is_proc_macro { - if root.macro_derive_registrar.is_some() != is_proc_macro { + if root.proc_macro_decls_static.is_some() != is_proc_macro { return None; } } diff --git a/src/librustc_metadata/schema.rs b/src/librustc_metadata/schema.rs index da2a8ae714b5a..e91d15b78c075 100644 --- a/src/librustc_metadata/schema.rs +++ b/src/librustc_metadata/schema.rs @@ -196,7 +196,7 @@ pub struct CrateRoot { pub has_panic_handler: bool, pub has_default_lib_allocator: bool, pub plugin_registrar_fn: Option, - pub macro_derive_registrar: Option, + pub proc_macro_decls_static: Option, pub crate_deps: LazySeq, pub dylib_dependency_formats: LazySeq>, diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 3bc349170514c..c93abc39ff3b9 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -1122,8 +1122,8 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG ("proc_macro_attribute", Normal, Ungated), ("proc_macro", Normal, Ungated), - ("rustc_derive_registrar", Normal, Gated(Stability::Unstable, - "rustc_derive_registrar", + ("rustc_proc_macro_decls", Normal, Gated(Stability::Unstable, + "rustc_proc_macro_decls", "used internally by rustc", cfg_fn!(rustc_attrs))), diff --git a/src/libsyntax_ext/Cargo.toml b/src/libsyntax_ext/Cargo.toml index 5a691bde3ecb3..4979d0b3e92a4 100644 --- a/src/libsyntax_ext/Cargo.toml +++ b/src/libsyntax_ext/Cargo.toml @@ -10,7 +10,6 @@ crate-type = ["dylib"] [dependencies] fmt_macros = { path = "../libfmt_macros" } -proc_macro = { path = "../libproc_macro" } rustc_errors = { path = "../librustc_errors" } syntax = { path = "../libsyntax" } syntax_pos = { path = "../libsyntax_pos" } diff --git a/src/libsyntax_ext/deriving/custom.rs b/src/libsyntax_ext/deriving/custom.rs index 55b3928d68eee..5c82d1911383e 100644 --- a/src/libsyntax_ext/deriving/custom.rs +++ b/src/libsyntax_ext/deriving/custom.rs @@ -8,15 +8,18 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::panic; - use errors::FatalError; -use proc_macro::{TokenStream, __internal}; use syntax::ast::{self, ItemKind, Attribute, Mac}; use syntax::attr::{mark_used, mark_known}; use syntax::source_map::Span; use syntax::ext::base::*; +use syntax::parse; +use syntax::parse::token::{self, Token}; +use syntax::tokenstream; use syntax::visit::Visitor; +use syntax_pos::DUMMY_SP; + +use proc_macro_impl::EXEC_STRATEGY; struct MarkAttrs<'a>(&'a [ast::Name]); @@ -32,14 +35,10 @@ impl<'a> Visitor<'a> for MarkAttrs<'a> { } pub struct ProcMacroDerive { - inner: fn(TokenStream) -> TokenStream, - attrs: Vec, -} - -impl ProcMacroDerive { - pub fn new(inner: fn(TokenStream) -> TokenStream, attrs: Vec) -> ProcMacroDerive { - ProcMacroDerive { inner: inner, attrs: attrs } - } + pub client: ::proc_macro::bridge::client::Client< + fn(::proc_macro::TokenStream) -> ::proc_macro::TokenStream, + >, + pub attrs: Vec, } impl MultiItemModifier for ProcMacroDerive { @@ -75,21 +74,17 @@ impl MultiItemModifier for ProcMacroDerive { // Mark attributes as known, and used. MarkAttrs(&self.attrs).visit_item(&item); - let input = __internal::new_token_stream(ecx.resolver.eliminate_crate_var(item)); - let res = __internal::set_sess(ecx, || { - let inner = self.inner; - panic::catch_unwind(panic::AssertUnwindSafe(|| inner(input))) - }); + let item = ecx.resolver.eliminate_crate_var(item); + let token = Token::interpolated(token::NtItem(item)); + let input = tokenstream::TokenTree::Token(DUMMY_SP, token).into(); - let stream = match res { + let server = ::proc_macro_server::Rustc::new(ecx); + let stream = match self.client.run(&EXEC_STRATEGY, server, input) { Ok(stream) => stream, Err(e) => { let msg = "proc-macro derive panicked"; let mut err = ecx.struct_span_fatal(span, msg); - if let Some(s) = e.downcast_ref::() { - err.help(&format!("message: {}", s)); - } - if let Some(s) = e.downcast_ref::<&'static str>() { + if let Some(s) = e.as_str() { err.help(&format!("message: {}", s)); } @@ -99,21 +94,33 @@ impl MultiItemModifier for ProcMacroDerive { }; let error_count_before = ecx.parse_sess.span_diagnostic.err_count(); - __internal::set_sess(ecx, || { - let msg = "proc-macro derive produced unparseable tokens"; - match __internal::token_stream_parse_items(stream) { - // fail if there have been errors emitted - Ok(_) if ecx.parse_sess.span_diagnostic.err_count() > error_count_before => { - ecx.struct_span_fatal(span, msg).emit(); - FatalError.raise(); + let msg = "proc-macro derive produced unparseable tokens"; + + let mut parser = parse::stream_to_parser(ecx.parse_sess, stream); + let mut items = vec![]; + + loop { + match parser.parse_item() { + Ok(None) => break, + Ok(Some(item)) => { + items.push(Annotatable::Item(item)) } - Ok(new_items) => new_items.into_iter().map(Annotatable::Item).collect(), - Err(_) => { + Err(mut err) => { // FIXME: handle this better + err.cancel(); ecx.struct_span_fatal(span, msg).emit(); FatalError.raise(); } } - }) + } + + + // fail if there have been errors emitted + if ecx.parse_sess.span_diagnostic.err_count() > error_count_before { + ecx.struct_span_fatal(span, msg).emit(); + FatalError.raise(); + } + + items } } diff --git a/src/libsyntax_ext/lib.rs b/src/libsyntax_ext/lib.rs index 7c023fc5c9c22..1d814a67876b8 100644 --- a/src/libsyntax_ext/lib.rs +++ b/src/libsyntax_ext/lib.rs @@ -14,7 +14,10 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] +#![feature(in_band_lifetimes)] +#![feature(proc_macro_diagnostic)] #![feature(proc_macro_internals)] +#![feature(proc_macro_span)] #![feature(decl_macro)] #![feature(nll)] #![feature(str_escape)] @@ -55,10 +58,9 @@ mod trace_macros; mod test; mod test_case; -pub mod proc_macro_registrar; - - +pub mod proc_macro_decls; pub mod proc_macro_impl; +mod proc_macro_server; use rustc_data_structures::sync::Lrc; use syntax::ast; diff --git a/src/libsyntax_ext/proc_macro_registrar.rs b/src/libsyntax_ext/proc_macro_decls.rs similarity index 76% rename from src/libsyntax_ext/proc_macro_registrar.rs rename to src/libsyntax_ext/proc_macro_decls.rs index 65e175f95df81..c859275ed020c 100644 --- a/src/libsyntax_ext/proc_macro_registrar.rs +++ b/src/libsyntax_ext/proc_macro_decls.rs @@ -91,7 +91,7 @@ pub fn modify(sess: &ParseSess, return krate; } - krate.module.items.push(mk_registrar(&mut cx, &derives, &attr_macros, &bang_macros)); + krate.module.items.push(mk_decls(&mut cx, &derives, &attr_macros, &bang_macros)); krate } @@ -339,19 +339,21 @@ impl<'a> Visitor<'a> for CollectProcMacros<'a> { // mod $gensym { // extern crate proc_macro; // -// use proc_macro::__internal::Registry; +// use proc_macro::bridge::client::ProcMacro; // -// #[plugin_registrar] -// fn registrar(registrar: &mut Registry) { -// registrar.register_custom_derive($name_trait1, ::$name1, &[]); -// registrar.register_custom_derive($name_trait2, ::$name2, &["attribute_name"]); +// #[rustc_proc_macro_decls] +// static DECLS: &[ProcMacro] = &[ +// ProcMacro::custom_derive($name_trait1, &[], ::$name1); +// ProcMacro::custom_derive($name_trait2, &["attribute_name"], ::$name2); // // ... -// } +// ]; // } -fn mk_registrar(cx: &mut ExtCtxt, - custom_derives: &[ProcMacroDerive], - custom_attrs: &[ProcMacroDef], - custom_macros: &[ProcMacroDef]) -> P { +fn mk_decls( + cx: &mut ExtCtxt, + custom_derives: &[ProcMacroDerive], + custom_attrs: &[ProcMacroDef], + custom_macros: &[ProcMacroDef], +) -> P { let mark = Mark::fresh(Mark::root()); mark.set_expn_info(ExpnInfo { call_site: DUMMY_SP, @@ -370,75 +372,67 @@ fn mk_registrar(cx: &mut ExtCtxt, Vec::new(), ast::ItemKind::ExternCrate(None)); - let __internal = Ident::from_str("__internal"); - let registry = Ident::from_str("Registry"); - let registrar = Ident::from_str("_registrar"); - let register_custom_derive = Ident::from_str("register_custom_derive"); - let register_attr_proc_macro = Ident::from_str("register_attr_proc_macro"); - let register_bang_proc_macro = Ident::from_str("register_bang_proc_macro"); + let bridge = Ident::from_str("bridge"); + let client = Ident::from_str("client"); + let proc_macro_ty = Ident::from_str("ProcMacro"); + let custom_derive = Ident::from_str("custom_derive"); + let attr = Ident::from_str("attr"); + let bang = Ident::from_str("bang"); let crate_kw = Ident::with_empty_ctxt(keywords::Crate.name()); - let local_path = |cx: &mut ExtCtxt, sp: Span, name: Ident| { - cx.path(sp.with_ctxt(span.ctxt()), vec![crate_kw, name]) + + let decls = { + let local_path = |sp: Span, name| { + cx.expr_path(cx.path(sp.with_ctxt(span.ctxt()), vec![crate_kw, name])) + }; + let proc_macro_ty_method_path = |method| cx.expr_path(cx.path(span, vec![ + proc_macro, bridge, client, proc_macro_ty, method, + ])); + custom_derives.iter().map(|cd| { + cx.expr_call(span, proc_macro_ty_method_path(custom_derive), vec![ + cx.expr_str(cd.span, cd.trait_name), + cx.expr_vec_slice( + span, + cd.attrs.iter().map(|&s| cx.expr_str(cd.span, s)).collect::>() + ), + local_path(cd.span, cd.function_name), + ]) + }).chain(custom_attrs.iter().map(|ca| { + cx.expr_call(span, proc_macro_ty_method_path(attr), vec![ + cx.expr_str(ca.span, ca.function_name.name), + local_path(ca.span, ca.function_name), + ]) + })).chain(custom_macros.iter().map(|cm| { + cx.expr_call(span, proc_macro_ty_method_path(bang), vec![ + cx.expr_str(cm.span, cm.function_name.name), + local_path(cm.span, cm.function_name), + ]) + })).collect() }; - let mut stmts = custom_derives.iter().map(|cd| { - let path = local_path(cx, cd.span, cd.function_name); - let trait_name = cx.expr_str(cd.span, cd.trait_name); - let attrs = cx.expr_vec_slice( - span, - cd.attrs.iter().map(|&s| cx.expr_str(cd.span, s)).collect::>() - ); - let registrar = cx.expr_ident(span, registrar); - let ufcs_path = cx.path(span, vec![proc_macro, __internal, registry, - register_custom_derive]); - - cx.stmt_expr(cx.expr_call(span, cx.expr_path(ufcs_path), - vec![registrar, trait_name, cx.expr_path(path), attrs])) - - }).collect::>(); - - stmts.extend(custom_attrs.iter().map(|ca| { - let name = cx.expr_str(ca.span, ca.function_name.name); - let path = local_path(cx, ca.span, ca.function_name); - let registrar = cx.expr_ident(ca.span, registrar); - - let ufcs_path = cx.path(span, - vec![proc_macro, __internal, registry, register_attr_proc_macro]); - - cx.stmt_expr(cx.expr_call(span, cx.expr_path(ufcs_path), - vec![registrar, name, cx.expr_path(path)])) - })); - - stmts.extend(custom_macros.iter().map(|cm| { - let name = cx.expr_str(cm.span, cm.function_name.name); - let path = local_path(cx, cm.span, cm.function_name); - let registrar = cx.expr_ident(cm.span, registrar); - - let ufcs_path = cx.path(span, - vec![proc_macro, __internal, registry, register_bang_proc_macro]); - - cx.stmt_expr(cx.expr_call(span, cx.expr_path(ufcs_path), - vec![registrar, name, cx.expr_path(path)])) - })); - - let path = cx.path(span, vec![proc_macro, __internal, registry]); - let registrar_path = cx.ty_path(path); - let arg_ty = cx.ty_rptr(span, registrar_path, None, ast::Mutability::Mutable); - let func = cx.item_fn(span, - registrar, - vec![cx.arg(span, registrar, arg_ty)], - cx.ty(span, ast::TyKind::Tup(Vec::new())), - cx.block(span, stmts)); - - let derive_registrar = cx.meta_word(span, Symbol::intern("rustc_derive_registrar")); - let derive_registrar = cx.attribute(span, derive_registrar); - let func = func.map(|mut i| { - i.attrs.push(derive_registrar); + let decls_static = cx.item_static( + span, + Ident::from_str("_DECLS"), + cx.ty_rptr(span, + cx.ty(span, ast::TyKind::Slice( + cx.ty_path(cx.path(span, + vec![proc_macro, bridge, client, proc_macro_ty])))), + None, ast::Mutability::Immutable), + ast::Mutability::Immutable, + cx.expr_vec_slice(span, decls), + ).map(|mut i| { + let attr = cx.meta_word(span, Symbol::intern("rustc_proc_macro_decls")); + i.attrs.push(cx.attribute(span, attr)); i.vis = respan(span, ast::VisibilityKind::Public); i }); - let ident = ast::Ident::with_empty_ctxt(Symbol::gensym("registrar")); - let module = cx.item_mod(span, span, ident, Vec::new(), vec![krate, func]).map(|mut i| { + + let module = cx.item_mod( + span, + span, + ast::Ident::with_empty_ctxt(Symbol::gensym("decls")), + vec![], + vec![krate, decls_static], + ).map(|mut i| { i.vis = respan(span, ast::VisibilityKind::Public); i }); diff --git a/src/libsyntax_ext/proc_macro_impl.rs b/src/libsyntax_ext/proc_macro_impl.rs index ff60262055bf3..43ef31a00baa5 100644 --- a/src/libsyntax_ext/proc_macro_impl.rs +++ b/src/libsyntax_ext/proc_macro_impl.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::panic; use errors::FatalError; @@ -17,11 +16,13 @@ use syntax::ext::base::*; use syntax::tokenstream::TokenStream; use syntax::ext::base; -use proc_macro::TokenStream as TsShim; -use proc_macro::__internal; +pub const EXEC_STRATEGY: ::proc_macro::bridge::server::SameThread = + ::proc_macro::bridge::server::SameThread; pub struct AttrProcMacro { - pub inner: fn(TsShim, TsShim) -> TsShim, + pub client: ::proc_macro::bridge::client::Client< + fn(::proc_macro::TokenStream, ::proc_macro::TokenStream) -> ::proc_macro::TokenStream, + >, } impl base::AttrProcMacro for AttrProcMacro { @@ -31,22 +32,13 @@ impl base::AttrProcMacro for AttrProcMacro { annotation: TokenStream, annotated: TokenStream) -> TokenStream { - let annotation = __internal::token_stream_wrap(annotation); - let annotated = __internal::token_stream_wrap(annotated); - - let res = __internal::set_sess(ecx, || { - panic::catch_unwind(panic::AssertUnwindSafe(|| (self.inner)(annotation, annotated))) - }); - - match res { - Ok(stream) => __internal::token_stream_inner(stream), + let server = ::proc_macro_server::Rustc::new(ecx); + match self.client.run(&EXEC_STRATEGY, server, annotation, annotated) { + Ok(stream) => stream, Err(e) => { let msg = "custom attribute panicked"; let mut err = ecx.struct_span_fatal(span, msg); - if let Some(s) = e.downcast_ref::() { - err.help(&format!("message: {}", s)); - } - if let Some(s) = e.downcast_ref::<&'static str>() { + if let Some(s) = e.as_str() { err.help(&format!("message: {}", s)); } @@ -58,7 +50,9 @@ impl base::AttrProcMacro for AttrProcMacro { } pub struct BangProcMacro { - pub inner: fn(TsShim) -> TsShim, + pub client: ::proc_macro::bridge::client::Client< + fn(::proc_macro::TokenStream) -> ::proc_macro::TokenStream, + >, } impl base::ProcMacro for BangProcMacro { @@ -67,21 +61,13 @@ impl base::ProcMacro for BangProcMacro { span: Span, input: TokenStream) -> TokenStream { - let input = __internal::token_stream_wrap(input); - - let res = __internal::set_sess(ecx, || { - panic::catch_unwind(panic::AssertUnwindSafe(|| (self.inner)(input))) - }); - - match res { - Ok(stream) => __internal::token_stream_inner(stream), + let server = ::proc_macro_server::Rustc::new(ecx); + match self.client.run(&EXEC_STRATEGY, server, input) { + Ok(stream) => stream, Err(e) => { let msg = "proc macro panicked"; let mut err = ecx.struct_span_fatal(span, msg); - if let Some(s) = e.downcast_ref::() { - err.help(&format!("message: {}", s)); - } - if let Some(s) = e.downcast_ref::<&'static str>() { + if let Some(s) = e.as_str() { err.help(&format!("message: {}", s)); } diff --git a/src/libsyntax_ext/proc_macro_server.rs b/src/libsyntax_ext/proc_macro_server.rs new file mode 100644 index 0000000000000..56bd58b28a66e --- /dev/null +++ b/src/libsyntax_ext/proc_macro_server.rs @@ -0,0 +1,751 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use errors::{self, Diagnostic, DiagnosticBuilder}; +use std::panic; + +use proc_macro::bridge::{server, TokenTree}; +use proc_macro::{Delimiter, Level, LineColumn, Spacing}; + +use rustc_data_structures::sync::Lrc; +use std::ascii; +use std::ops::Bound; +use syntax::ast; +use syntax::ext::base::ExtCtxt; +use syntax::parse::lexer::comments; +use syntax::parse::{self, token, ParseSess}; +use syntax::tokenstream::{self, DelimSpan, TokenStream}; +use syntax_pos::hygiene::{SyntaxContext, Transparency}; +use syntax_pos::symbol::{keywords, Symbol}; +use syntax_pos::{BytePos, FileName, MultiSpan, Pos, SourceFile, Span}; + +trait FromInternal { + fn from_internal(x: T) -> Self; +} + +trait ToInternal { + fn to_internal(self) -> T; +} + +impl FromInternal for Delimiter { + fn from_internal(delim: token::DelimToken) -> Delimiter { + match delim { + token::Paren => Delimiter::Parenthesis, + token::Brace => Delimiter::Brace, + token::Bracket => Delimiter::Bracket, + token::NoDelim => Delimiter::None, + } + } +} + +impl ToInternal for Delimiter { + fn to_internal(self) -> token::DelimToken { + match self { + Delimiter::Parenthesis => token::Paren, + Delimiter::Brace => token::Brace, + Delimiter::Bracket => token::Bracket, + Delimiter::None => token::NoDelim, + } + } +} + +impl FromInternal<(TokenStream, &'_ ParseSess, &'_ mut Vec)> + for TokenTree +{ + fn from_internal((stream, sess, stack): (TokenStream, &ParseSess, &mut Vec)) -> Self { + use syntax::parse::token::*; + + let (tree, joint) = stream.as_tree(); + let (span, token) = match tree { + tokenstream::TokenTree::Delimited(span, delimed) => { + let delimiter = Delimiter::from_internal(delimed.delim); + return TokenTree::Group(Group { + delimiter, + stream: delimed.tts.into(), + span, + }); + } + tokenstream::TokenTree::Token(span, token) => (span, token), + }; + + macro_rules! tt { + ($ty:ident { $($field:ident $(: $value:expr)*),+ $(,)* }) => ( + TokenTree::$ty(self::$ty { + $($field $(: $value)*,)* + span, + }) + ) + } + macro_rules! op { + ($a:expr) => { + tt!(Punct { ch: $a, joint }) + }; + ($a:expr, $b:expr) => {{ + stack.push(tt!(Punct { ch: $b, joint })); + tt!(Punct { + ch: $a, + joint: true + }) + }}; + ($a:expr, $b:expr, $c:expr) => {{ + stack.push(tt!(Punct { ch: $c, joint })); + stack.push(tt!(Punct { + ch: $b, + joint: true + })); + tt!(Punct { + ch: $a, + joint: true + }) + }}; + } + + match token { + Eq => op!('='), + Lt => op!('<'), + Le => op!('<', '='), + EqEq => op!('=', '='), + Ne => op!('!', '='), + Ge => op!('>', '='), + Gt => op!('>'), + AndAnd => op!('&', '&'), + OrOr => op!('|', '|'), + Not => op!('!'), + Tilde => op!('~'), + BinOp(Plus) => op!('+'), + BinOp(Minus) => op!('-'), + BinOp(Star) => op!('*'), + BinOp(Slash) => op!('/'), + BinOp(Percent) => op!('%'), + BinOp(Caret) => op!('^'), + BinOp(And) => op!('&'), + BinOp(Or) => op!('|'), + BinOp(Shl) => op!('<', '<'), + BinOp(Shr) => op!('>', '>'), + BinOpEq(Plus) => op!('+', '='), + BinOpEq(Minus) => op!('-', '='), + BinOpEq(Star) => op!('*', '='), + BinOpEq(Slash) => op!('/', '='), + BinOpEq(Percent) => op!('%', '='), + BinOpEq(Caret) => op!('^', '='), + BinOpEq(And) => op!('&', '='), + BinOpEq(Or) => op!('|', '='), + BinOpEq(Shl) => op!('<', '<', '='), + BinOpEq(Shr) => op!('>', '>', '='), + At => op!('@'), + Dot => op!('.'), + DotDot => op!('.', '.'), + DotDotDot => op!('.', '.', '.'), + DotDotEq => op!('.', '.', '='), + Comma => op!(','), + Semi => op!(';'), + Colon => op!(':'), + ModSep => op!(':', ':'), + RArrow => op!('-', '>'), + LArrow => op!('<', '-'), + FatArrow => op!('=', '>'), + Pound => op!('#'), + Dollar => op!('$'), + Question => op!('?'), + SingleQuote => op!('\''), + + Ident(ident, is_raw) => tt!(Ident { + sym: ident.name, + is_raw + }), + Lifetime(ident) => { + let ident = ident.without_first_quote(); + stack.push(tt!(Ident { + sym: ident.name, + is_raw: false + })); + tt!(Punct { + ch: '\'', + joint: true + }) + } + Literal(lit, suffix) => tt!(Literal { lit, suffix }), + DocComment(c) => { + let style = comments::doc_comment_style(&c.as_str()); + let stripped = comments::strip_doc_comment_decoration(&c.as_str()); + let mut escaped = String::new(); + for ch in stripped.chars() { + escaped.extend(ch.escape_debug()); + } + let stream = vec![ + Ident(ast::Ident::new(Symbol::intern("doc"), span), false), + Eq, + Literal(Lit::Str_(Symbol::intern(&escaped)), None), + ] + .into_iter() + .map(|token| tokenstream::TokenTree::Token(span, token)) + .collect(); + stack.push(TokenTree::Group(Group { + delimiter: Delimiter::Bracket, + stream, + span: DelimSpan::from_single(span), + })); + if style == ast::AttrStyle::Inner { + stack.push(tt!(Punct { + ch: '!', + joint: false + })); + } + tt!(Punct { + ch: '#', + joint: false + }) + } + + Interpolated(_) => { + let stream = token.interpolated_to_tokenstream(sess, span); + TokenTree::Group(Group { + delimiter: Delimiter::None, + stream, + span: DelimSpan::from_single(span), + }) + } + + DotEq => op!('.', '='), + OpenDelim(..) | CloseDelim(..) => unreachable!(), + Whitespace | Comment | Shebang(..) | Eof => unreachable!(), + } + } +} + +impl ToInternal for TokenTree { + fn to_internal(self) -> TokenStream { + use syntax::parse::token::*; + + let (ch, joint, span) = match self { + TokenTree::Punct(Punct { ch, joint, span }) => (ch, joint, span), + TokenTree::Group(Group { + delimiter, + stream, + span, + }) => { + return tokenstream::TokenTree::Delimited( + span, + tokenstream::Delimited { + delim: delimiter.to_internal(), + tts: stream.into(), + }, + ) + .into(); + } + TokenTree::Ident(self::Ident { sym, span, is_raw }) => { + let token = Ident(ast::Ident::new(sym, span), is_raw); + return tokenstream::TokenTree::Token(span, token).into(); + } + TokenTree::Literal(self::Literal { + lit: Lit::Integer(ref a), + suffix, + span, + }) if a.as_str().starts_with("-") => { + let minus = BinOp(BinOpToken::Minus); + let integer = Symbol::intern(&a.as_str()[1..]); + let integer = Literal(Lit::Integer(integer), suffix); + let a = tokenstream::TokenTree::Token(span, minus); + let b = tokenstream::TokenTree::Token(span, integer); + return vec![a, b].into_iter().collect(); + } + TokenTree::Literal(self::Literal { + lit: Lit::Float(ref a), + suffix, + span, + }) if a.as_str().starts_with("-") => { + let minus = BinOp(BinOpToken::Minus); + let float = Symbol::intern(&a.as_str()[1..]); + let float = Literal(Lit::Float(float), suffix); + let a = tokenstream::TokenTree::Token(span, minus); + let b = tokenstream::TokenTree::Token(span, float); + return vec![a, b].into_iter().collect(); + } + TokenTree::Literal(self::Literal { lit, suffix, span }) => { + return tokenstream::TokenTree::Token(span, Literal(lit, suffix)).into() + } + }; + + let token = match ch { + '=' => Eq, + '<' => Lt, + '>' => Gt, + '!' => Not, + '~' => Tilde, + '+' => BinOp(Plus), + '-' => BinOp(Minus), + '*' => BinOp(Star), + '/' => BinOp(Slash), + '%' => BinOp(Percent), + '^' => BinOp(Caret), + '&' => BinOp(And), + '|' => BinOp(Or), + '@' => At, + '.' => Dot, + ',' => Comma, + ';' => Semi, + ':' => Colon, + '#' => Pound, + '$' => Dollar, + '?' => Question, + '\'' => SingleQuote, + _ => unreachable!(), + }; + + let tree = tokenstream::TokenTree::Token(span, token); + if joint { + tree.joint() + } else { + tree.into() + } + } +} + +impl ToInternal for Level { + fn to_internal(self) -> errors::Level { + match self { + Level::Error => errors::Level::Error, + Level::Warning => errors::Level::Warning, + Level::Note => errors::Level::Note, + Level::Help => errors::Level::Help, + _ => unreachable!("unknown proc_macro::Level variant: {:?}", self), + } + } +} + +#[derive(Clone)] +pub struct TokenStreamIter { + cursor: tokenstream::Cursor, + stack: Vec>, +} + +#[derive(Clone)] +pub struct Group { + delimiter: Delimiter, + stream: TokenStream, + span: DelimSpan, +} + +#[derive(Copy, Clone, PartialEq, Eq, Hash)] +pub struct Punct { + ch: char, + // NB. not using `Spacing` here because it doesn't implement `Hash`. + joint: bool, + span: Span, +} + +#[derive(Copy, Clone, PartialEq, Eq, Hash)] +pub struct Ident { + sym: Symbol, + span: Span, + is_raw: bool, +} + +// FIXME(eddyb) `Literal` should not expose internal `Debug` impls. +#[derive(Clone, Debug)] +pub struct Literal { + lit: token::Lit, + suffix: Option, + span: Span, +} + +pub(crate) struct Rustc<'a> { + sess: &'a ParseSess, + def_site: Span, + call_site: Span, +} + +impl<'a> Rustc<'a> { + pub fn new(cx: &'a ExtCtxt) -> Self { + // No way to determine def location for a proc macro right now, so use call location. + let location = cx.current_expansion.mark.expn_info().unwrap().call_site; + let to_span = |transparency| { + location.with_ctxt( + SyntaxContext::empty() + .apply_mark_with_transparency(cx.current_expansion.mark, transparency), + ) + }; + Rustc { + sess: cx.parse_sess, + def_site: to_span(Transparency::Opaque), + call_site: to_span(Transparency::Transparent), + } + } +} + +impl server::Types for Rustc<'_> { + type TokenStream = TokenStream; + type TokenStreamBuilder = tokenstream::TokenStreamBuilder; + type TokenStreamIter = TokenStreamIter; + type Group = Group; + type Punct = Punct; + type Ident = Ident; + type Literal = Literal; + type SourceFile = Lrc; + type MultiSpan = Vec; + type Diagnostic = Diagnostic; + type Span = Span; +} + +impl server::TokenStream for Rustc<'_> { + fn new(&mut self) -> Self::TokenStream { + TokenStream::empty() + } + fn is_empty(&mut self, stream: &Self::TokenStream) -> bool { + stream.is_empty() + } + fn from_str(&mut self, src: &str) -> Self::TokenStream { + parse::parse_stream_from_source_str( + FileName::ProcMacroSourceCode, + src.to_string(), + self.sess, + Some(self.call_site), + ) + } + fn to_string(&mut self, stream: &Self::TokenStream) -> String { + stream.to_string() + } + fn from_token_tree( + &mut self, + tree: TokenTree, + ) -> Self::TokenStream { + tree.to_internal() + } + fn into_iter(&mut self, stream: Self::TokenStream) -> Self::TokenStreamIter { + TokenStreamIter { + cursor: stream.trees(), + stack: vec![], + } + } +} + +impl server::TokenStreamBuilder for Rustc<'_> { + fn new(&mut self) -> Self::TokenStreamBuilder { + tokenstream::TokenStreamBuilder::new() + } + fn push(&mut self, builder: &mut Self::TokenStreamBuilder, stream: Self::TokenStream) { + builder.push(stream); + } + fn build(&mut self, builder: Self::TokenStreamBuilder) -> Self::TokenStream { + builder.build() + } +} + +impl server::TokenStreamIter for Rustc<'_> { + fn next( + &mut self, + iter: &mut Self::TokenStreamIter, + ) -> Option> { + loop { + let tree = iter.stack.pop().or_else(|| { + let next = iter.cursor.next_as_stream()?; + Some(TokenTree::from_internal((next, self.sess, &mut iter.stack))) + })?; + // HACK: The condition "dummy span + group with empty delimiter" represents an AST + // fragment approximately converted into a token stream. This may happen, for + // example, with inputs to proc macro attributes, including derives. Such "groups" + // need to flattened during iteration over stream's token trees. + // Eventually this needs to be removed in favor of keeping original token trees + // and not doing the roundtrip through AST. + if let TokenTree::Group(ref group) = tree { + if group.delimiter == Delimiter::None && group.span.entire().is_dummy() { + iter.cursor.insert(group.stream.clone()); + continue; + } + } + return Some(tree); + } + } +} + +impl server::Group for Rustc<'_> { + fn new(&mut self, delimiter: Delimiter, stream: Self::TokenStream) -> Self::Group { + Group { + delimiter, + stream, + span: DelimSpan::from_single(server::Span::call_site(self)), + } + } + fn delimiter(&mut self, group: &Self::Group) -> Delimiter { + group.delimiter + } + fn stream(&mut self, group: &Self::Group) -> Self::TokenStream { + group.stream.clone() + } + fn span(&mut self, group: &Self::Group) -> Self::Span { + group.span.entire() + } + fn span_open(&mut self, group: &Self::Group) -> Self::Span { + group.span.open + } + fn span_close(&mut self, group: &Self::Group) -> Self::Span { + group.span.close + } + fn set_span(&mut self, group: &mut Self::Group, span: Self::Span) { + group.span = DelimSpan::from_single(span); + } +} + +impl server::Punct for Rustc<'_> { + fn new(&mut self, ch: char, spacing: Spacing) -> Self::Punct { + Punct { + ch, + joint: spacing == Spacing::Joint, + span: server::Span::call_site(self), + } + } + fn as_char(&mut self, punct: Self::Punct) -> char { + punct.ch + } + fn spacing(&mut self, punct: Self::Punct) -> Spacing { + if punct.joint { + Spacing::Joint + } else { + Spacing::Alone + } + } + fn span(&mut self, punct: Self::Punct) -> Self::Span { + punct.span + } + fn with_span(&mut self, punct: Self::Punct, span: Self::Span) -> Self::Punct { + Punct { span, ..punct } + } +} + +impl server::Ident for Rustc<'_> { + fn new(&mut self, string: &str, span: Self::Span, is_raw: bool) -> Self::Ident { + let sym = Symbol::intern(string); + if is_raw + && (sym == keywords::Underscore.name() + || ast::Ident::with_empty_ctxt(sym).is_path_segment_keyword()) + { + panic!("`{:?}` is not a valid raw identifier", string) + } + Ident { sym, span, is_raw } + } + fn span(&mut self, ident: Self::Ident) -> Self::Span { + ident.span + } + fn with_span(&mut self, ident: Self::Ident, span: Self::Span) -> Self::Ident { + Ident { span, ..ident } + } +} + +impl server::Literal for Rustc<'_> { + // FIXME(eddyb) `Literal` should not expose internal `Debug` impls. + fn debug(&mut self, literal: &Self::Literal) -> String { + format!("{:?}", literal) + } + fn integer(&mut self, n: &str) -> Self::Literal { + Literal { + lit: token::Lit::Integer(Symbol::intern(n)), + suffix: None, + span: server::Span::call_site(self), + } + } + fn typed_integer(&mut self, n: &str, kind: &str) -> Self::Literal { + Literal { + lit: token::Lit::Integer(Symbol::intern(n)), + suffix: Some(Symbol::intern(kind)), + span: server::Span::call_site(self), + } + } + fn float(&mut self, n: &str) -> Self::Literal { + Literal { + lit: token::Lit::Float(Symbol::intern(n)), + suffix: None, + span: server::Span::call_site(self), + } + } + fn f32(&mut self, n: &str) -> Self::Literal { + Literal { + lit: token::Lit::Float(Symbol::intern(n)), + suffix: Some(Symbol::intern("f32")), + span: server::Span::call_site(self), + } + } + fn f64(&mut self, n: &str) -> Self::Literal { + Literal { + lit: token::Lit::Float(Symbol::intern(n)), + suffix: Some(Symbol::intern("f64")), + span: server::Span::call_site(self), + } + } + fn string(&mut self, string: &str) -> Self::Literal { + let mut escaped = String::new(); + for ch in string.chars() { + escaped.extend(ch.escape_debug()); + } + Literal { + lit: token::Lit::Str_(Symbol::intern(&escaped)), + suffix: None, + span: server::Span::call_site(self), + } + } + fn character(&mut self, ch: char) -> Self::Literal { + let mut escaped = String::new(); + escaped.extend(ch.escape_unicode()); + Literal { + lit: token::Lit::Char(Symbol::intern(&escaped)), + suffix: None, + span: server::Span::call_site(self), + } + } + fn byte_string(&mut self, bytes: &[u8]) -> Self::Literal { + let string = bytes + .iter() + .cloned() + .flat_map(ascii::escape_default) + .map(Into::::into) + .collect::(); + Literal { + lit: token::Lit::ByteStr(Symbol::intern(&string)), + suffix: None, + span: server::Span::call_site(self), + } + } + fn span(&mut self, literal: &Self::Literal) -> Self::Span { + literal.span + } + fn set_span(&mut self, literal: &mut Self::Literal, span: Self::Span) { + literal.span = span; + } + fn subspan( + &mut self, + literal: &Self::Literal, + start: Bound, + end: Bound, + ) -> Option { + let span = literal.span; + let length = span.hi().to_usize() - span.lo().to_usize(); + + let start = match start { + Bound::Included(lo) => lo, + Bound::Excluded(lo) => lo + 1, + Bound::Unbounded => 0, + }; + + let end = match end { + Bound::Included(hi) => hi + 1, + Bound::Excluded(hi) => hi, + Bound::Unbounded => length, + }; + + // Bounds check the values, preventing addition overflow and OOB spans. + if start > u32::max_value() as usize + || end > u32::max_value() as usize + || (u32::max_value() - start as u32) < span.lo().to_u32() + || (u32::max_value() - end as u32) < span.lo().to_u32() + || start >= end + || end > length + { + return None; + } + + let new_lo = span.lo() + BytePos::from_usize(start); + let new_hi = span.lo() + BytePos::from_usize(end); + Some(span.with_lo(new_lo).with_hi(new_hi)) + } +} + +impl<'a> server::SourceFile for Rustc<'a> { + fn eq(&mut self, file1: &Self::SourceFile, file2: &Self::SourceFile) -> bool { + Lrc::ptr_eq(file1, file2) + } + fn path(&mut self, file: &Self::SourceFile) -> String { + match file.name { + FileName::Real(ref path) => path + .to_str() + .expect("non-UTF8 file path in `proc_macro::SourceFile::path`") + .to_string(), + _ => file.name.to_string(), + } + } + fn is_real(&mut self, file: &Self::SourceFile) -> bool { + file.is_real_file() + } +} + +impl server::MultiSpan for Rustc<'_> { + fn new(&mut self) -> Self::MultiSpan { + vec![] + } + fn push(&mut self, spans: &mut Self::MultiSpan, span: Self::Span) { + spans.push(span) + } +} + +impl server::Diagnostic for Rustc<'_> { + fn new(&mut self, level: Level, msg: &str, spans: Self::MultiSpan) -> Self::Diagnostic { + let mut diag = Diagnostic::new(level.to_internal(), msg); + diag.set_span(MultiSpan::from_spans(spans)); + diag + } + fn sub( + &mut self, + diag: &mut Self::Diagnostic, + level: Level, + msg: &str, + spans: Self::MultiSpan, + ) { + diag.sub(level.to_internal(), msg, MultiSpan::from_spans(spans), None); + } + fn emit(&mut self, diag: Self::Diagnostic) { + DiagnosticBuilder::new_diagnostic(&self.sess.span_diagnostic, diag).emit() + } +} + +impl server::Span for Rustc<'_> { + fn debug(&mut self, span: Self::Span) -> String { + format!("{:?} bytes({}..{})", span.ctxt(), span.lo().0, span.hi().0) + } + fn def_site(&mut self) -> Self::Span { + self.def_site + } + fn call_site(&mut self) -> Self::Span { + self.call_site + } + fn source_file(&mut self, span: Self::Span) -> Self::SourceFile { + self.sess.source_map().lookup_char_pos(span.lo()).file + } + fn parent(&mut self, span: Self::Span) -> Option { + span.ctxt().outer().expn_info().map(|i| i.call_site) + } + fn source(&mut self, span: Self::Span) -> Self::Span { + span.source_callsite() + } + fn start(&mut self, span: Self::Span) -> LineColumn { + let loc = self.sess.source_map().lookup_char_pos(span.lo()); + LineColumn { + line: loc.line, + column: loc.col.to_usize(), + } + } + fn end(&mut self, span: Self::Span) -> LineColumn { + let loc = self.sess.source_map().lookup_char_pos(span.hi()); + LineColumn { + line: loc.line, + column: loc.col.to_usize(), + } + } + fn join(&mut self, first: Self::Span, second: Self::Span) -> Option { + let self_loc = self.sess.source_map().lookup_char_pos(first.lo()); + let other_loc = self.sess.source_map().lookup_char_pos(second.lo()); + + if self_loc.file.name != other_loc.file.name { + return None; + } + + Some(first.to(second)) + } + fn resolved_at(&mut self, span: Self::Span, at: Self::Span) -> Self::Span { + span.with_ctxt(at.ctxt()) + } +} diff --git a/src/libtest/Cargo.toml b/src/libtest/Cargo.toml index ec77f95338081..aade10ed6c324 100644 --- a/src/libtest/Cargo.toml +++ b/src/libtest/Cargo.toml @@ -11,3 +11,6 @@ crate-type = ["dylib", "rlib"] [dependencies] getopts = "0.2" term = { path = "../libterm" } + +# not actually used but needed to always have proc_macro in the sysroot +proc_macro = { path = "../libproc_macro" } diff --git a/src/test/compile-fail-fulldeps/proc-macro/attr-invalid-exprs.rs b/src/test/compile-fail/proc-macro/attr-invalid-exprs.rs similarity index 98% rename from src/test/compile-fail-fulldeps/proc-macro/attr-invalid-exprs.rs rename to src/test/compile-fail/proc-macro/attr-invalid-exprs.rs index f52c251c14d7b..798cd1406ac81 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/attr-invalid-exprs.rs +++ b/src/test/compile-fail/proc-macro/attr-invalid-exprs.rs @@ -9,7 +9,6 @@ // except according to those terms. // aux-build:attr-stmt-expr.rs -// ignore-stage1 //! Attributes producing expressions in invalid locations diff --git a/src/test/compile-fail-fulldeps/proc-macro/attr-stmt-expr.rs b/src/test/compile-fail/proc-macro/attr-stmt-expr.rs similarity index 98% rename from src/test/compile-fail-fulldeps/proc-macro/attr-stmt-expr.rs rename to src/test/compile-fail/proc-macro/attr-stmt-expr.rs index 1344156b3053c..6d1d5dfe8ccdb 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/attr-stmt-expr.rs +++ b/src/test/compile-fail/proc-macro/attr-stmt-expr.rs @@ -9,7 +9,6 @@ // except according to those terms. // aux-build:attr-stmt-expr.rs -// ignore-stage1 #![feature(proc_macro_hygiene)] diff --git a/src/test/compile-fail-fulldeps/proc-macro/attribute-with-error.rs b/src/test/compile-fail/proc-macro/attribute-with-error.rs similarity index 98% rename from src/test/compile-fail-fulldeps/proc-macro/attribute-with-error.rs rename to src/test/compile-fail/proc-macro/attribute-with-error.rs index cf2522be922e3..ed2e8ec00a9f2 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/attribute-with-error.rs +++ b/src/test/compile-fail/proc-macro/attribute-with-error.rs @@ -9,7 +9,6 @@ // except according to those terms. // aux-build:attribute-with-error.rs -// ignore-stage1 #![feature(custom_inner_attributes)] diff --git a/src/test/compile-fail-fulldeps/proc-macro/attribute.rs b/src/test/compile-fail/proc-macro/attribute.rs similarity index 98% rename from src/test/compile-fail-fulldeps/proc-macro/attribute.rs rename to src/test/compile-fail/proc-macro/attribute.rs index 5d5e61270b61d..f89d74de50f41 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/attribute.rs +++ b/src/test/compile-fail/proc-macro/attribute.rs @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host +// no-prefer-dynamic + #![crate_type = "proc-macro"] extern crate proc_macro; diff --git a/src/test/compile-fail-fulldeps/proc-macro/attributes-included.rs b/src/test/compile-fail/proc-macro/attributes-included.rs similarity index 97% rename from src/test/compile-fail-fulldeps/proc-macro/attributes-included.rs rename to src/test/compile-fail/proc-macro/attributes-included.rs index e941367b08de9..e129711129a20 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/attributes-included.rs +++ b/src/test/compile-fail/proc-macro/attributes-included.rs @@ -9,7 +9,6 @@ // except according to those terms. // aux-build:attributes-included.rs -// ignore-stage1 // compile-pass #![warn(unused)] diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/attr-stmt-expr.rs b/src/test/compile-fail/proc-macro/auxiliary/attr-stmt-expr.rs similarity index 99% rename from src/test/compile-fail-fulldeps/proc-macro/auxiliary/attr-stmt-expr.rs rename to src/test/compile-fail/proc-macro/auxiliary/attr-stmt-expr.rs index 22ddc91399553..4cfeec2f8a665 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/attr-stmt-expr.rs +++ b/src/test/compile-fail/proc-macro/auxiliary/attr-stmt-expr.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/attribute-with-error.rs b/src/test/compile-fail/proc-macro/auxiliary/attribute-with-error.rs similarity index 100% rename from src/test/compile-fail-fulldeps/proc-macro/auxiliary/attribute-with-error.rs rename to src/test/compile-fail/proc-macro/auxiliary/attribute-with-error.rs diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/attributes-included.rs b/src/test/compile-fail/proc-macro/auxiliary/attributes-included.rs similarity index 100% rename from src/test/compile-fail-fulldeps/proc-macro/auxiliary/attributes-included.rs rename to src/test/compile-fail/proc-macro/auxiliary/attributes-included.rs diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/bang_proc_macro2.rs b/src/test/compile-fail/proc-macro/auxiliary/bang_proc_macro2.rs similarity index 100% rename from src/test/compile-fail-fulldeps/proc-macro/auxiliary/bang_proc_macro2.rs rename to src/test/compile-fail/proc-macro/auxiliary/bang_proc_macro2.rs diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-a-b.rs b/src/test/compile-fail/proc-macro/auxiliary/derive-a-b.rs similarity index 100% rename from src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-a-b.rs rename to src/test/compile-fail/proc-macro/auxiliary/derive-a-b.rs diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-a.rs b/src/test/compile-fail/proc-macro/auxiliary/derive-a.rs similarity index 100% rename from src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-a.rs rename to src/test/compile-fail/proc-macro/auxiliary/derive-a.rs diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-b.rs b/src/test/compile-fail/proc-macro/auxiliary/derive-b.rs similarity index 100% rename from src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-b.rs rename to src/test/compile-fail/proc-macro/auxiliary/derive-b.rs diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-bad.rs b/src/test/compile-fail/proc-macro/auxiliary/derive-bad.rs similarity index 100% rename from src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-bad.rs rename to src/test/compile-fail/proc-macro/auxiliary/derive-bad.rs index 841b39eaed07b..b2ded05eb51fb 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-bad.rs +++ b/src/test/compile-fail/proc-macro/auxiliary/derive-bad.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// no-prefer-dynamic // force-host +// no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-clona.rs b/src/test/compile-fail/proc-macro/auxiliary/derive-clona.rs similarity index 100% rename from src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-clona.rs rename to src/test/compile-fail/proc-macro/auxiliary/derive-clona.rs diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-foo.rs b/src/test/compile-fail/proc-macro/auxiliary/derive-foo.rs similarity index 100% rename from src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-foo.rs rename to src/test/compile-fail/proc-macro/auxiliary/derive-foo.rs diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-unstable-2.rs b/src/test/compile-fail/proc-macro/auxiliary/derive-unstable-2.rs similarity index 100% rename from src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-unstable-2.rs rename to src/test/compile-fail/proc-macro/auxiliary/derive-unstable-2.rs diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-unstable.rs b/src/test/compile-fail/proc-macro/auxiliary/derive-unstable.rs similarity index 100% rename from src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-unstable.rs rename to src/test/compile-fail/proc-macro/auxiliary/derive-unstable.rs diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/issue-41211.rs b/src/test/compile-fail/proc-macro/auxiliary/issue-41211.rs similarity index 100% rename from src/test/compile-fail-fulldeps/proc-macro/auxiliary/issue-41211.rs rename to src/test/compile-fail/proc-macro/auxiliary/issue-41211.rs diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/issue_38586.rs b/src/test/compile-fail/proc-macro/auxiliary/issue_38586.rs similarity index 100% rename from src/test/compile-fail-fulldeps/proc-macro/auxiliary/issue_38586.rs rename to src/test/compile-fail/proc-macro/auxiliary/issue_38586.rs diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/issue_50493.rs b/src/test/compile-fail/proc-macro/auxiliary/issue_50493.rs similarity index 100% rename from src/test/compile-fail-fulldeps/proc-macro/auxiliary/issue_50493.rs rename to src/test/compile-fail/proc-macro/auxiliary/issue_50493.rs diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/more-gates.rs b/src/test/compile-fail/proc-macro/auxiliary/more-gates.rs similarity index 98% rename from src/test/compile-fail-fulldeps/proc-macro/auxiliary/more-gates.rs rename to src/test/compile-fail/proc-macro/auxiliary/more-gates.rs index 67fe93058aa89..cc9420e15372b 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/more-gates.rs +++ b/src/test/compile-fail/proc-macro/auxiliary/more-gates.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/proc-macro-gates.rs b/src/test/compile-fail/proc-macro/auxiliary/proc-macro-gates.rs similarity index 100% rename from src/test/compile-fail-fulldeps/proc-macro/auxiliary/proc-macro-gates.rs rename to src/test/compile-fail/proc-macro/auxiliary/proc-macro-gates.rs index 0f8fd5b5709c7..7e4b7fe263d8c 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/proc-macro-gates.rs +++ b/src/test/compile-fail/proc-macro/auxiliary/proc-macro-gates.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// no-prefer-dynamic // force-host +// no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/test-macros.rs b/src/test/compile-fail/proc-macro/auxiliary/test-macros.rs similarity index 98% rename from src/test/compile-fail-fulldeps/proc-macro/auxiliary/test-macros.rs rename to src/test/compile-fail/proc-macro/auxiliary/test-macros.rs index 581c7cb15a59c..0e4343a90d645 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/test-macros.rs +++ b/src/test/compile-fail/proc-macro/auxiliary/test-macros.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/compile-fail-fulldeps/proc-macro/define-two.rs b/src/test/compile-fail/proc-macro/define-two.rs similarity index 98% rename from src/test/compile-fail-fulldeps/proc-macro/define-two.rs rename to src/test/compile-fail/proc-macro/define-two.rs index 8321c471b2a8a..f8c287b6b72b2 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/define-two.rs +++ b/src/test/compile-fail/proc-macro/define-two.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/compile-fail-fulldeps/proc-macro/derive-bad.rs b/src/test/compile-fail/proc-macro/derive-bad.rs similarity index 97% rename from src/test/compile-fail-fulldeps/proc-macro/derive-bad.rs rename to src/test/compile-fail/proc-macro/derive-bad.rs index 93790f5937298..ac27e87ace105 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/derive-bad.rs +++ b/src/test/compile-fail/proc-macro/derive-bad.rs @@ -9,7 +9,6 @@ // except according to those terms. // aux-build:derive-bad.rs -// ignore-stage1 #[macro_use] extern crate derive_bad; diff --git a/src/test/compile-fail-fulldeps/proc-macro/derive-still-gated.rs b/src/test/compile-fail/proc-macro/derive-still-gated.rs similarity index 100% rename from src/test/compile-fail-fulldeps/proc-macro/derive-still-gated.rs rename to src/test/compile-fail/proc-macro/derive-still-gated.rs diff --git a/src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable-2.rs b/src/test/compile-fail/proc-macro/expand-to-unstable-2.rs similarity index 97% rename from src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable-2.rs rename to src/test/compile-fail/proc-macro/expand-to-unstable-2.rs index 6f254dcbdb11a..e4fcbb117a505 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable-2.rs +++ b/src/test/compile-fail/proc-macro/expand-to-unstable-2.rs @@ -9,7 +9,6 @@ // except according to those terms. // aux-build:derive-unstable-2.rs -// ignore-stage1 #![allow(warnings)] diff --git a/src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable.rs b/src/test/compile-fail/proc-macro/expand-to-unstable.rs similarity index 97% rename from src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable.rs rename to src/test/compile-fail/proc-macro/expand-to-unstable.rs index ca0f0e382ed0c..836e336fc22f0 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable.rs +++ b/src/test/compile-fail/proc-macro/expand-to-unstable.rs @@ -9,7 +9,6 @@ // except according to those terms. // aux-build:derive-unstable.rs -// ignore-stage1 #![allow(warnings)] diff --git a/src/test/compile-fail-fulldeps/proc-macro/export-macro.rs b/src/test/compile-fail/proc-macro/export-macro.rs similarity index 94% rename from src/test/compile-fail-fulldeps/proc-macro/export-macro.rs rename to src/test/compile-fail/proc-macro/export-macro.rs index 477039bd7a2fa..d8bb3571c080b 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/export-macro.rs +++ b/src/test/compile-fail/proc-macro/export-macro.rs @@ -10,6 +10,9 @@ // error-pattern: cannot export macro_rules! macros from a `proc-macro` crate +// force-host +// no-prefer-dynamic + #![crate_type = "proc-macro"] #[macro_export] diff --git a/src/test/compile-fail-fulldeps/proc-macro/exports.rs b/src/test/compile-fail/proc-macro/exports.rs similarity index 95% rename from src/test/compile-fail-fulldeps/proc-macro/exports.rs rename to src/test/compile-fail/proc-macro/exports.rs index 41b94d04e8c73..07e5723c1c18e 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/exports.rs +++ b/src/test/compile-fail/proc-macro/exports.rs @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host +// no-prefer-dynamic + #![crate_type = "proc-macro"] #![allow(warnings)] diff --git a/src/test/compile-fail-fulldeps/proc-macro/illegal-proc-macro-derive-use.rs b/src/test/compile-fail/proc-macro/illegal-proc-macro-derive-use.rs similarity index 100% rename from src/test/compile-fail-fulldeps/proc-macro/illegal-proc-macro-derive-use.rs rename to src/test/compile-fail/proc-macro/illegal-proc-macro-derive-use.rs diff --git a/src/test/compile-fail-fulldeps/proc-macro/import.rs b/src/test/compile-fail/proc-macro/import.rs similarity index 100% rename from src/test/compile-fail-fulldeps/proc-macro/import.rs rename to src/test/compile-fail/proc-macro/import.rs diff --git a/src/test/compile-fail-fulldeps/proc-macro/issue-37788.rs b/src/test/compile-fail/proc-macro/issue-37788.rs similarity index 100% rename from src/test/compile-fail-fulldeps/proc-macro/issue-37788.rs rename to src/test/compile-fail/proc-macro/issue-37788.rs diff --git a/src/test/compile-fail-fulldeps/proc-macro/issue-38586.rs b/src/test/compile-fail/proc-macro/issue-38586.rs similarity index 97% rename from src/test/compile-fail-fulldeps/proc-macro/issue-38586.rs rename to src/test/compile-fail/proc-macro/issue-38586.rs index 2d843d0e46652..649220ac401f0 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/issue-38586.rs +++ b/src/test/compile-fail/proc-macro/issue-38586.rs @@ -9,7 +9,6 @@ // except according to those terms. // aux-build:issue_38586.rs -// ignore-stage1 #[macro_use] extern crate issue_38586; diff --git a/src/test/compile-fail-fulldeps/proc-macro/issue-41211.rs b/src/test/compile-fail/proc-macro/issue-41211.rs similarity index 100% rename from src/test/compile-fail-fulldeps/proc-macro/issue-41211.rs rename to src/test/compile-fail/proc-macro/issue-41211.rs diff --git a/src/test/compile-fail-fulldeps/proc-macro/issue-50493.rs b/src/test/compile-fail/proc-macro/issue-50493.rs similarity index 97% rename from src/test/compile-fail-fulldeps/proc-macro/issue-50493.rs rename to src/test/compile-fail/proc-macro/issue-50493.rs index eaa64c6ba3692..635da57049714 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/issue-50493.rs +++ b/src/test/compile-fail/proc-macro/issue-50493.rs @@ -9,7 +9,6 @@ // except according to those terms. // aux-build:issue_50493.rs -// ignore-stage1 #[macro_use] extern crate issue_50493; diff --git a/src/test/compile-fail-fulldeps/proc-macro/item-error.rs b/src/test/compile-fail/proc-macro/item-error.rs similarity index 97% rename from src/test/compile-fail-fulldeps/proc-macro/item-error.rs rename to src/test/compile-fail/proc-macro/item-error.rs index c0d4d71a6ec8b..4133e75e3a62d 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/item-error.rs +++ b/src/test/compile-fail/proc-macro/item-error.rs @@ -9,7 +9,6 @@ // except according to those terms. // aux-build:derive-b.rs -// ignore-stage1 #![allow(warnings)] diff --git a/src/test/compile-fail-fulldeps/proc-macro/lints_in_proc_macros.rs b/src/test/compile-fail/proc-macro/lints_in_proc_macros.rs similarity index 97% rename from src/test/compile-fail-fulldeps/proc-macro/lints_in_proc_macros.rs rename to src/test/compile-fail/proc-macro/lints_in_proc_macros.rs index 60e533d3ea8d2..d49c61202713b 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/lints_in_proc_macros.rs +++ b/src/test/compile-fail/proc-macro/lints_in_proc_macros.rs @@ -9,7 +9,6 @@ // except according to those terms. // aux-build:bang_proc_macro2.rs -// ignore-stage1 #![feature(proc_macro_hygiene)] #![allow(unused_macros)] diff --git a/src/test/compile-fail-fulldeps/proc-macro/macros-in-extern.rs b/src/test/compile-fail/proc-macro/macros-in-extern.rs similarity index 98% rename from src/test/compile-fail-fulldeps/proc-macro/macros-in-extern.rs rename to src/test/compile-fail/proc-macro/macros-in-extern.rs index f280e74fc90bd..43d7077d02210 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/macros-in-extern.rs +++ b/src/test/compile-fail/proc-macro/macros-in-extern.rs @@ -9,7 +9,6 @@ // except according to those terms. // aux-build:test-macros.rs -// ignore-stage1 // ignore-wasm32 extern crate test_macros; diff --git a/src/test/compile-fail-fulldeps/proc-macro/more-gates.rs b/src/test/compile-fail/proc-macro/more-gates.rs similarity index 100% rename from src/test/compile-fail-fulldeps/proc-macro/more-gates.rs rename to src/test/compile-fail/proc-macro/more-gates.rs diff --git a/src/test/compile-fail-fulldeps/proc-macro/no-macro-use-attr.rs b/src/test/compile-fail/proc-macro/no-macro-use-attr.rs similarity index 100% rename from src/test/compile-fail-fulldeps/proc-macro/no-macro-use-attr.rs rename to src/test/compile-fail/proc-macro/no-macro-use-attr.rs diff --git a/src/test/compile-fail-fulldeps/proc-macro/proc-macro-attributes.rs b/src/test/compile-fail/proc-macro/proc-macro-attributes.rs similarity index 97% rename from src/test/compile-fail-fulldeps/proc-macro/proc-macro-attributes.rs rename to src/test/compile-fail/proc-macro/proc-macro-attributes.rs index d0aed8b162486..6e52411500e22 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/proc-macro-attributes.rs +++ b/src/test/compile-fail/proc-macro/proc-macro-attributes.rs @@ -9,7 +9,6 @@ // except according to those terms. // aux-build:derive-b.rs -// ignore-stage1 #[macro_use] extern crate derive_b; diff --git a/src/test/compile-fail-fulldeps/proc-macro/proc-macro-gates.rs b/src/test/compile-fail/proc-macro/proc-macro-gates.rs similarity index 100% rename from src/test/compile-fail-fulldeps/proc-macro/proc-macro-gates.rs rename to src/test/compile-fail/proc-macro/proc-macro-gates.rs diff --git a/src/test/compile-fail-fulldeps/proc-macro/proc-macro-gates2.rs b/src/test/compile-fail/proc-macro/proc-macro-gates2.rs similarity index 100% rename from src/test/compile-fail-fulldeps/proc-macro/proc-macro-gates2.rs rename to src/test/compile-fail/proc-macro/proc-macro-gates2.rs diff --git a/src/test/compile-fail-fulldeps/proc-macro/pub-at-crate-root.rs b/src/test/compile-fail/proc-macro/pub-at-crate-root.rs similarity index 96% rename from src/test/compile-fail-fulldeps/proc-macro/pub-at-crate-root.rs rename to src/test/compile-fail/proc-macro/pub-at-crate-root.rs index 238dde5160cd4..e995eb549fae9 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/pub-at-crate-root.rs +++ b/src/test/compile-fail/proc-macro/pub-at-crate-root.rs @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host +// no-prefer-dynamic + #![crate_type = "proc-macro"] extern crate proc_macro; diff --git a/src/test/compile-fail-fulldeps/proc-macro/shadow-builtin.rs b/src/test/compile-fail/proc-macro/shadow-builtin.rs similarity index 95% rename from src/test/compile-fail-fulldeps/proc-macro/shadow-builtin.rs rename to src/test/compile-fail/proc-macro/shadow-builtin.rs index 8c5affb7b5ab3..a5fcfde1dda1e 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/shadow-builtin.rs +++ b/src/test/compile-fail/proc-macro/shadow-builtin.rs @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host +// no-prefer-dynamic + #![crate_type = "proc-macro"] extern crate proc_macro; diff --git a/src/test/compile-fail-fulldeps/proc-macro/shadow.rs b/src/test/compile-fail/proc-macro/shadow.rs similarity index 100% rename from src/test/compile-fail-fulldeps/proc-macro/shadow.rs rename to src/test/compile-fail/proc-macro/shadow.rs diff --git a/src/test/compile-fail-fulldeps/proc-macro/two-crate-types-1.rs b/src/test/compile-fail/proc-macro/two-crate-types-1.rs similarity index 94% rename from src/test/compile-fail-fulldeps/proc-macro/two-crate-types-1.rs rename to src/test/compile-fail/proc-macro/two-crate-types-1.rs index db646fb781544..06bd3f9dd6a2d 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/two-crate-types-1.rs +++ b/src/test/compile-fail/proc-macro/two-crate-types-1.rs @@ -10,5 +10,8 @@ // error-pattern: cannot mix `proc-macro` crate type with others +// force-host +// no-prefer-dynamic + #![crate_type = "proc-macro"] #![crate_type = "rlib"] diff --git a/src/test/compile-fail-fulldeps/proc-macro/two-crate-types-2.rs b/src/test/compile-fail/proc-macro/two-crate-types-2.rs similarity index 97% rename from src/test/compile-fail-fulldeps/proc-macro/two-crate-types-2.rs rename to src/test/compile-fail/proc-macro/two-crate-types-2.rs index 97b0f8446043d..dd5e5acbec868 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/two-crate-types-2.rs +++ b/src/test/compile-fail/proc-macro/two-crate-types-2.rs @@ -10,3 +10,4 @@ // error-pattern: cannot mix `proc-macro` crate type with others // compile-flags: --crate-type rlib --crate-type proc-macro +// force-host diff --git a/src/test/incremental-fulldeps/auxiliary/incremental_proc_macro_aux.rs b/src/test/incremental/auxiliary/incremental_proc_macro_aux.rs similarity index 98% rename from src/test/incremental-fulldeps/auxiliary/incremental_proc_macro_aux.rs rename to src/test/incremental/auxiliary/incremental_proc_macro_aux.rs index e9f9ba86f23dc..34d200982053f 100644 --- a/src/test/incremental-fulldeps/auxiliary/incremental_proc_macro_aux.rs +++ b/src/test/incremental/auxiliary/incremental_proc_macro_aux.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/incremental-fulldeps/auxiliary/issue_49482_macro_def.rs b/src/test/incremental/auxiliary/issue_49482_macro_def.rs similarity index 99% rename from src/test/incremental-fulldeps/auxiliary/issue_49482_macro_def.rs rename to src/test/incremental/auxiliary/issue_49482_macro_def.rs index 763c9eb138e74..fa6bff4660a7f 100644 --- a/src/test/incremental-fulldeps/auxiliary/issue_49482_macro_def.rs +++ b/src/test/incremental/auxiliary/issue_49482_macro_def.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type="proc-macro"] diff --git a/src/test/incremental-fulldeps/auxiliary/issue_49482_reexport.rs b/src/test/incremental/auxiliary/issue_49482_reexport.rs similarity index 100% rename from src/test/incremental-fulldeps/auxiliary/issue_49482_reexport.rs rename to src/test/incremental/auxiliary/issue_49482_reexport.rs diff --git a/src/test/incremental-fulldeps/auxiliary/issue_54059.rs b/src/test/incremental/auxiliary/issue_54059.rs similarity index 99% rename from src/test/incremental-fulldeps/auxiliary/issue_54059.rs rename to src/test/incremental/auxiliary/issue_54059.rs index ec0d044d4bf8d..635501fd60cfc 100644 --- a/src/test/incremental-fulldeps/auxiliary/issue_54059.rs +++ b/src/test/incremental/auxiliary/issue_54059.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic // check that having extern "C" functions in a proc macro doesn't crash. diff --git a/src/test/incremental-fulldeps/incremental_proc_macro.rs b/src/test/incremental/incremental_proc_macro.rs similarity index 97% rename from src/test/incremental-fulldeps/incremental_proc_macro.rs rename to src/test/incremental/incremental_proc_macro.rs index 103ee30baba93..495f4ff0ed046 100644 --- a/src/test/incremental-fulldeps/incremental_proc_macro.rs +++ b/src/test/incremental/incremental_proc_macro.rs @@ -9,7 +9,6 @@ // except according to those terms. // aux-build:incremental_proc_macro_aux.rs -// ignore-stage1 // revisions: cfail1 cfail2 // compile-pass diff --git a/src/test/incremental-fulldeps/issue-49482.rs b/src/test/incremental/issue-49482.rs similarity index 98% rename from src/test/incremental-fulldeps/issue-49482.rs rename to src/test/incremental/issue-49482.rs index 3261b5ae09201..65e86e868bbf9 100644 --- a/src/test/incremental-fulldeps/issue-49482.rs +++ b/src/test/incremental/issue-49482.rs @@ -10,7 +10,6 @@ // aux-build:issue_49482_macro_def.rs // aux-build:issue_49482_reexport.rs -// ignore-stage1 // revisions: rpass1 extern crate issue_49482_reexport; diff --git a/src/test/incremental-fulldeps/issue-54059.rs b/src/test/incremental/issue-54059.rs similarity index 97% rename from src/test/incremental-fulldeps/issue-54059.rs rename to src/test/incremental/issue-54059.rs index dee1e0abf61f2..2f4ea72b06673 100644 --- a/src/test/incremental-fulldeps/issue-54059.rs +++ b/src/test/incremental/issue-54059.rs @@ -9,7 +9,6 @@ // except according to those terms. // aux-build:issue_54059.rs -// ignore-stage1 // ignore-wasm32-bare no libc for ffi testing // ignore-windows - dealing with weird symbols issues on dylibs isn't worth it // revisions: rpass1 diff --git a/src/test/pretty/attr-derive.rs b/src/test/pretty/attr-derive.rs index a1c581a18682c..f38bf6e92eb75 100644 --- a/src/test/pretty/attr-derive.rs +++ b/src/test/pretty/attr-derive.rs @@ -9,7 +9,6 @@ // except according to those terms. // aux-build:derive-foo.rs -// ignore-stage1 // pp-exact // Testing that both the inner item and next outer item are // preserved, and that the first outer item parsed in main is not diff --git a/src/test/pretty/auxiliary/derive-foo.rs b/src/test/pretty/auxiliary/derive-foo.rs index bd81d3e5a3b53..3552b20fd414b 100644 --- a/src/test/pretty/auxiliary/derive-foo.rs +++ b/src/test/pretty/auxiliary/derive-foo.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/run-make-fulldeps/issue-38237/Makefile b/src/test/run-make-fulldeps/issue-38237/Makefile index 855d958b344a9..0a681401b1afb 100644 --- a/src/test/run-make-fulldeps/issue-38237/Makefile +++ b/src/test/run-make-fulldeps/issue-38237/Makefile @@ -1,11 +1,5 @@ -include ../tools.mk -ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1) -# ignore stage1 -all: - -else all: $(RUSTC) foo.rs; $(RUSTC) bar.rs $(RUSTDOC) baz.rs -L $(TMPDIR) -o $(TMPDIR) -endif diff --git a/src/test/run-make-fulldeps/rustc-macro-dep-files/Makefile b/src/test/run-make-fulldeps/rustc-macro-dep-files/Makefile deleted file mode 100644 index d2c8e7fd0434c..0000000000000 --- a/src/test/run-make-fulldeps/rustc-macro-dep-files/Makefile +++ /dev/null @@ -1,12 +0,0 @@ --include ../tools.mk - -ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1) -# ignore stage1 -all: - -else -all: - $(RUSTC) foo.rs - $(RUSTC) bar.rs --emit dep-info - $(CGREP) -v "proc-macro source" < $(TMPDIR)/bar.d -endif diff --git a/src/test/run-make/rustc-macro-dep-files/Makefile b/src/test/run-make/rustc-macro-dep-files/Makefile new file mode 100644 index 0000000000000..0420a389168f1 --- /dev/null +++ b/src/test/run-make/rustc-macro-dep-files/Makefile @@ -0,0 +1,8 @@ +-include ../../run-make-fulldeps/tools.mk + +# FIXME(eddyb) provide `HOST_RUSTC` and `TARGET_RUSTC` +# instead of hardcoding them everywhere they're needed. +all: + $(BARE_RUSTC) foo.rs --out-dir $(TMPDIR) + $(RUSTC) bar.rs --target $(TARGET) --emit dep-info + $(CGREP) -v "proc-macro source" < $(TMPDIR)/bar.d diff --git a/src/test/run-make-fulldeps/rustc-macro-dep-files/bar.rs b/src/test/run-make/rustc-macro-dep-files/bar.rs similarity index 93% rename from src/test/run-make-fulldeps/rustc-macro-dep-files/bar.rs rename to src/test/run-make/rustc-macro-dep-files/bar.rs index 03330c3d1700d..b2d7f3f348ce8 100644 --- a/src/test/run-make-fulldeps/rustc-macro-dep-files/bar.rs +++ b/src/test/run-make/rustc-macro-dep-files/bar.rs @@ -8,12 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![no_std] +#![crate_type = "lib"] + #[macro_use] extern crate foo; #[derive(A)] struct A; - -fn main() { - let _b = B; -} diff --git a/src/test/run-make-fulldeps/rustc-macro-dep-files/foo.rs b/src/test/run-make/rustc-macro-dep-files/foo.rs similarity index 100% rename from src/test/run-make-fulldeps/rustc-macro-dep-files/foo.rs rename to src/test/run-make/rustc-macro-dep-files/foo.rs diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-40001-plugin.rs b/src/test/run-pass-fulldeps/auxiliary/issue-40001-plugin.rs similarity index 100% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-40001-plugin.rs rename to src/test/run-pass-fulldeps/auxiliary/issue-40001-plugin.rs diff --git a/src/test/run-pass-fulldeps/compiler-calls.rs b/src/test/run-pass-fulldeps/compiler-calls.rs index 6283d054373c1..e8cbf5a270e03 100644 --- a/src/test/run-pass-fulldeps/compiler-calls.rs +++ b/src/test/run-pass-fulldeps/compiler-calls.rs @@ -11,6 +11,7 @@ // Test that the CompilerCalls interface to the compiler works. // ignore-cross-compile +// ignore-stage1 #![feature(rustc_private)] diff --git a/src/test/run-pass-fulldeps/proc-macro/issue-40001.rs b/src/test/run-pass-fulldeps/issue-40001.rs similarity index 100% rename from src/test/run-pass-fulldeps/proc-macro/issue-40001.rs rename to src/test/run-pass-fulldeps/issue-40001.rs diff --git a/src/test/run-pass-fulldeps/auxiliary/cond_plugin.rs b/src/test/run-pass/auxiliary/cond_plugin.rs similarity index 99% rename from src/test/run-pass-fulldeps/auxiliary/cond_plugin.rs rename to src/test/run-pass/auxiliary/cond_plugin.rs index e7545f954daab..940b1ea5df41a 100644 --- a/src/test/run-pass-fulldeps/auxiliary/cond_plugin.rs +++ b/src/test/run-pass/auxiliary/cond_plugin.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/run-pass-fulldeps/auxiliary/hello_macro.rs b/src/test/run-pass/auxiliary/hello_macro.rs similarity index 98% rename from src/test/run-pass-fulldeps/auxiliary/hello_macro.rs rename to src/test/run-pass/auxiliary/hello_macro.rs index caf56dabf796a..f3a0f2cc6257c 100644 --- a/src/test/run-pass-fulldeps/auxiliary/hello_macro.rs +++ b/src/test/run-pass/auxiliary/hello_macro.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/run-pass-fulldeps/auxiliary/proc_macro_def.rs b/src/test/run-pass/auxiliary/proc_macro_def.rs similarity index 98% rename from src/test/run-pass-fulldeps/auxiliary/proc_macro_def.rs rename to src/test/run-pass/auxiliary/proc_macro_def.rs index 847db0098fffc..d111db841a5bb 100644 --- a/src/test/run-pass-fulldeps/auxiliary/proc_macro_def.rs +++ b/src/test/run-pass/auxiliary/proc_macro_def.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/run-pass-fulldeps/macro-quote-cond.rs b/src/test/run-pass/macro-quote-cond.rs similarity index 98% rename from src/test/run-pass-fulldeps/macro-quote-cond.rs rename to src/test/run-pass/macro-quote-cond.rs index d438adda151fa..d8e36336028be 100644 --- a/src/test/run-pass-fulldeps/macro-quote-cond.rs +++ b/src/test/run-pass/macro-quote-cond.rs @@ -10,7 +10,6 @@ #![allow(unused_parens)] // aux-build:cond_plugin.rs -// ignore-stage1 #![feature(proc_macro_hygiene)] diff --git a/src/test/run-pass-fulldeps/macro-quote-test.rs b/src/test/run-pass/macro-quote-test.rs similarity index 97% rename from src/test/run-pass-fulldeps/macro-quote-test.rs rename to src/test/run-pass/macro-quote-test.rs index f967ef56bb8f0..473f92f7b74e8 100644 --- a/src/test/run-pass-fulldeps/macro-quote-test.rs +++ b/src/test/run-pass/macro-quote-test.rs @@ -11,7 +11,6 @@ // Test that a macro can emit delimiters with nothing inside - `()`, `{}` // aux-build:hello_macro.rs -// ignore-stage1 #![feature(proc_macro_hygiene)] diff --git a/src/test/run-pass-fulldeps/proc-macro/add-impl.rs b/src/test/run-pass/proc-macro/add-impl.rs similarity index 97% rename from src/test/run-pass-fulldeps/proc-macro/add-impl.rs rename to src/test/run-pass/proc-macro/add-impl.rs index 5175fe174a9e7..7ea7ceafc2876 100644 --- a/src/test/run-pass-fulldeps/proc-macro/add-impl.rs +++ b/src/test/run-pass/proc-macro/add-impl.rs @@ -9,7 +9,6 @@ // except according to those terms. // aux-build:add-impl.rs -// ignore-stage1 #[macro_use] extern crate add_impl; diff --git a/src/test/run-pass-fulldeps/proc-macro/append-impl.rs b/src/test/run-pass/proc-macro/append-impl.rs similarity index 97% rename from src/test/run-pass-fulldeps/proc-macro/append-impl.rs rename to src/test/run-pass/proc-macro/append-impl.rs index 37aef7ef1318c..591f3331d28c0 100644 --- a/src/test/run-pass-fulldeps/proc-macro/append-impl.rs +++ b/src/test/run-pass/proc-macro/append-impl.rs @@ -9,7 +9,6 @@ // except according to those terms. // aux-build:append-impl.rs -// ignore-stage1 #![allow(warnings)] diff --git a/src/test/run-pass-fulldeps/proc-macro/attr-args.rs b/src/test/run-pass/proc-macro/attr-args.rs similarity index 97% rename from src/test/run-pass-fulldeps/proc-macro/attr-args.rs rename to src/test/run-pass/proc-macro/attr-args.rs index effb3ad5189e1..b2ee5c2a20a92 100644 --- a/src/test/run-pass-fulldeps/proc-macro/attr-args.rs +++ b/src/test/run-pass/proc-macro/attr-args.rs @@ -9,7 +9,6 @@ // except according to those terms. // aux-build:attr-args.rs -// ignore-stage1 #![allow(warnings)] diff --git a/src/test/run-pass-fulldeps/proc-macro/attr-cfg.rs b/src/test/run-pass/proc-macro/attr-cfg.rs similarity index 97% rename from src/test/run-pass-fulldeps/proc-macro/attr-cfg.rs rename to src/test/run-pass/proc-macro/attr-cfg.rs index 1a9d9b9ee621d..58ffd0ce8b060 100644 --- a/src/test/run-pass-fulldeps/proc-macro/attr-cfg.rs +++ b/src/test/run-pass/proc-macro/attr-cfg.rs @@ -9,7 +9,6 @@ // except according to those terms. // aux-build:attr-cfg.rs -// ignore-stage1 // revisions: foo bar extern crate attr_cfg; diff --git a/src/test/run-pass-fulldeps/proc-macro/attr-on-trait.rs b/src/test/run-pass/proc-macro/attr-on-trait.rs similarity index 97% rename from src/test/run-pass-fulldeps/proc-macro/attr-on-trait.rs rename to src/test/run-pass/proc-macro/attr-on-trait.rs index 698a0eca1734f..383c193ddb451 100644 --- a/src/test/run-pass-fulldeps/proc-macro/attr-on-trait.rs +++ b/src/test/run-pass/proc-macro/attr-on-trait.rs @@ -9,7 +9,6 @@ // except according to those terms. // aux-build:attr-on-trait.rs -// ignore-stage1 extern crate attr_on_trait; diff --git a/src/test/run-pass-fulldeps/proc-macro/attr-stmt-expr.rs b/src/test/run-pass/proc-macro/attr-stmt-expr.rs similarity index 98% rename from src/test/run-pass-fulldeps/proc-macro/attr-stmt-expr.rs rename to src/test/run-pass/proc-macro/attr-stmt-expr.rs index 8a3452f24d247..43a5695f1b760 100644 --- a/src/test/run-pass-fulldeps/proc-macro/attr-stmt-expr.rs +++ b/src/test/run-pass/proc-macro/attr-stmt-expr.rs @@ -9,7 +9,6 @@ // except according to those terms. // aux-build:attr-stmt-expr.rs -// ignore-stage1 #![feature(stmt_expr_attributes, proc_macro_hygiene)] diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/add-impl.rs b/src/test/run-pass/proc-macro/auxiliary/add-impl.rs similarity index 98% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/add-impl.rs rename to src/test/run-pass/proc-macro/auxiliary/add-impl.rs index 3959eccd81e35..806d70eebde5f 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/add-impl.rs +++ b/src/test/run-pass/proc-macro/auxiliary/add-impl.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/append-impl.rs b/src/test/run-pass/proc-macro/auxiliary/append-impl.rs similarity index 100% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/append-impl.rs rename to src/test/run-pass/proc-macro/auxiliary/append-impl.rs diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-args.rs b/src/test/run-pass/proc-macro/auxiliary/attr-args.rs similarity index 98% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-args.rs rename to src/test/run-pass/proc-macro/auxiliary/attr-args.rs index 655bfa3ff6312..1f45a799a17f2 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-args.rs +++ b/src/test/run-pass/proc-macro/auxiliary/attr-args.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-cfg.rs b/src/test/run-pass/proc-macro/auxiliary/attr-cfg.rs similarity index 98% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-cfg.rs rename to src/test/run-pass/proc-macro/auxiliary/attr-cfg.rs index f9037aa8bf94d..553d2ca42f85d 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-cfg.rs +++ b/src/test/run-pass/proc-macro/auxiliary/attr-cfg.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-on-trait.rs b/src/test/run-pass/proc-macro/auxiliary/attr-on-trait.rs similarity index 98% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-on-trait.rs rename to src/test/run-pass/proc-macro/auxiliary/attr-on-trait.rs index 5e5c775b1ffbd..f5431ddb2a36b 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-on-trait.rs +++ b/src/test/run-pass/proc-macro/auxiliary/attr-on-trait.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-stmt-expr.rs b/src/test/run-pass/proc-macro/auxiliary/attr-stmt-expr.rs similarity index 99% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-stmt-expr.rs rename to src/test/run-pass/proc-macro/auxiliary/attr-stmt-expr.rs index 4d5e22b4eb6c2..4704bd16cbc4f 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-stmt-expr.rs +++ b/src/test/run-pass/proc-macro/auxiliary/attr-stmt-expr.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/bang-macro.rs b/src/test/run-pass/proc-macro/auxiliary/bang-macro.rs similarity index 98% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/bang-macro.rs rename to src/test/run-pass/proc-macro/auxiliary/bang-macro.rs index 8b7c6cd10b860..45301879e99bd 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/bang-macro.rs +++ b/src/test/run-pass/proc-macro/auxiliary/bang-macro.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/call-site.rs b/src/test/run-pass/proc-macro/auxiliary/call-site.rs similarity index 99% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/call-site.rs rename to src/test/run-pass/proc-macro/auxiliary/call-site.rs index 65eb8f4bec2d0..ed878a25e9983 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/call-site.rs +++ b/src/test/run-pass/proc-macro/auxiliary/call-site.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/count_compound_ops.rs b/src/test/run-pass/proc-macro/auxiliary/count_compound_ops.rs similarity index 98% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/count_compound_ops.rs rename to src/test/run-pass/proc-macro/auxiliary/count_compound_ops.rs index 77d0d9339feff..b0d71f248d7d2 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/count_compound_ops.rs +++ b/src/test/run-pass/proc-macro/auxiliary/count_compound_ops.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![feature(proc_macro_hygiene, proc_macro_quote)] diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/custom-attr-only-one-derive.rs b/src/test/run-pass/proc-macro/auxiliary/custom-attr-only-one-derive.rs similarity index 98% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/custom-attr-only-one-derive.rs rename to src/test/run-pass/proc-macro/auxiliary/custom-attr-only-one-derive.rs index 4609f57bddfa4..250d9508c234a 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/custom-attr-only-one-derive.rs +++ b/src/test/run-pass/proc-macro/auxiliary/custom-attr-only-one-derive.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-a.rs b/src/test/run-pass/proc-macro/auxiliary/derive-a.rs similarity index 98% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-a.rs rename to src/test/run-pass/proc-macro/auxiliary/derive-a.rs index b7374a07e427a..55c2b3c575e59 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-a.rs +++ b/src/test/run-pass/proc-macro/auxiliary/derive-a.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-atob.rs b/src/test/run-pass/proc-macro/auxiliary/derive-atob.rs similarity index 98% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-atob.rs rename to src/test/run-pass/proc-macro/auxiliary/derive-atob.rs index 67d828d92a700..406f169c24d39 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-atob.rs +++ b/src/test/run-pass/proc-macro/auxiliary/derive-atob.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-attr-cfg.rs b/src/test/run-pass/proc-macro/auxiliary/derive-attr-cfg.rs similarity index 98% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-attr-cfg.rs rename to src/test/run-pass/proc-macro/auxiliary/derive-attr-cfg.rs index 2b413579a9a0f..20ba0de5e385d 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-attr-cfg.rs +++ b/src/test/run-pass/proc-macro/auxiliary/derive-attr-cfg.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-b.rs b/src/test/run-pass/proc-macro/auxiliary/derive-b.rs similarity index 98% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-b.rs rename to src/test/run-pass/proc-macro/auxiliary/derive-b.rs index e1aabad4142f9..d69e69de1c2f8 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-b.rs +++ b/src/test/run-pass/proc-macro/auxiliary/derive-b.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-ctod.rs b/src/test/run-pass/proc-macro/auxiliary/derive-ctod.rs similarity index 98% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-ctod.rs rename to src/test/run-pass/proc-macro/auxiliary/derive-ctod.rs index 550ffe9400db8..91a82ba52c80f 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-ctod.rs +++ b/src/test/run-pass/proc-macro/auxiliary/derive-ctod.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-nothing.rs b/src/test/run-pass/proc-macro/auxiliary/derive-nothing.rs similarity index 97% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-nothing.rs rename to src/test/run-pass/proc-macro/auxiliary/derive-nothing.rs index cfe428bf5f323..635d3364f0db5 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-nothing.rs +++ b/src/test/run-pass/proc-macro/auxiliary/derive-nothing.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-same-struct.rs b/src/test/run-pass/proc-macro/auxiliary/derive-same-struct.rs similarity index 95% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-same-struct.rs rename to src/test/run-pass/proc-macro/auxiliary/derive-same-struct.rs index cf96f52823f0f..f62e0cd12a123 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-same-struct.rs +++ b/src/test/run-pass/proc-macro/auxiliary/derive-same-struct.rs @@ -8,8 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic -// compile-flags:--crate-type proc-macro + +#![crate_type = "proc-macro"] extern crate proc_macro; diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-two-attrs.rs b/src/test/run-pass/proc-macro/auxiliary/derive-two-attrs.rs similarity index 97% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-two-attrs.rs rename to src/test/run-pass/proc-macro/auxiliary/derive-two-attrs.rs index d02edb50fb2b5..eafd457675fda 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-two-attrs.rs +++ b/src/test/run-pass/proc-macro/auxiliary/derive-two-attrs.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-union.rs b/src/test/run-pass/proc-macro/auxiliary/derive-union.rs similarity index 98% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-union.rs rename to src/test/run-pass/proc-macro/auxiliary/derive-union.rs index 41bb88a0a92c1..e6d3d9185035c 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-union.rs +++ b/src/test/run-pass/proc-macro/auxiliary/derive-union.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/double.rs b/src/test/run-pass/proc-macro/auxiliary/double.rs similarity index 98% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/double.rs rename to src/test/run-pass/proc-macro/auxiliary/double.rs index a6c9817f24714..f37679552ecaf 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/double.rs +++ b/src/test/run-pass/proc-macro/auxiliary/double.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/empty-crate.rs b/src/test/run-pass/proc-macro/auxiliary/empty-crate.rs similarity index 97% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/empty-crate.rs rename to src/test/run-pass/proc-macro/auxiliary/empty-crate.rs index b45d4bf41d635..943acd9cecf06 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/empty-crate.rs +++ b/src/test/run-pass/proc-macro/auxiliary/empty-crate.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/expand-with-a-macro.rs b/src/test/run-pass/proc-macro/auxiliary/expand-with-a-macro.rs similarity index 98% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/expand-with-a-macro.rs rename to src/test/run-pass/proc-macro/auxiliary/expand-with-a-macro.rs index e6831b6bfdf65..d7f8ec43e5265 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/expand-with-a-macro.rs +++ b/src/test/run-pass/proc-macro/auxiliary/expand-with-a-macro.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/external-crate-var.rs b/src/test/run-pass/proc-macro/auxiliary/external-crate-var.rs similarity index 100% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/external-crate-var.rs rename to src/test/run-pass/proc-macro/auxiliary/external-crate-var.rs diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/gen-lifetime-token.rs b/src/test/run-pass/proc-macro/auxiliary/gen-lifetime-token.rs similarity index 98% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/gen-lifetime-token.rs rename to src/test/run-pass/proc-macro/auxiliary/gen-lifetime-token.rs index 978de27b70aad..9f300837315b1 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/gen-lifetime-token.rs +++ b/src/test/run-pass/proc-macro/auxiliary/gen-lifetime-token.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/hygiene_example.rs b/src/test/run-pass/proc-macro/auxiliary/hygiene_example.rs similarity index 100% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/hygiene_example.rs rename to src/test/run-pass/proc-macro/auxiliary/hygiene_example.rs diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/hygiene_example_codegen.rs b/src/test/run-pass/proc-macro/auxiliary/hygiene_example_codegen.rs similarity index 98% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/hygiene_example_codegen.rs rename to src/test/run-pass/proc-macro/auxiliary/hygiene_example_codegen.rs index 551ac3863e1ab..af3b60173aca3 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/hygiene_example_codegen.rs +++ b/src/test/run-pass/proc-macro/auxiliary/hygiene_example_codegen.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![feature(proc_macro_quote, proc_macro_hygiene)] diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-39889.rs b/src/test/run-pass/proc-macro/auxiliary/issue-39889.rs similarity index 100% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-39889.rs rename to src/test/run-pass/proc-macro/auxiliary/issue-39889.rs diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-42708.rs b/src/test/run-pass/proc-macro/auxiliary/issue-42708.rs similarity index 98% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-42708.rs rename to src/test/run-pass/proc-macro/auxiliary/issue-42708.rs index 906caceb8696b..e74b9dc745486 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-42708.rs +++ b/src/test/run-pass/proc-macro/auxiliary/issue-42708.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-50061.rs b/src/test/run-pass/proc-macro/auxiliary/issue-50061.rs similarity index 98% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-50061.rs rename to src/test/run-pass/proc-macro/auxiliary/issue-50061.rs index 6de17522fc9a7..a8a03ca540c88 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-50061.rs +++ b/src/test/run-pass/proc-macro/auxiliary/issue-50061.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/lifetimes.rs b/src/test/run-pass/proc-macro/auxiliary/lifetimes.rs similarity index 98% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/lifetimes.rs rename to src/test/run-pass/proc-macro/auxiliary/lifetimes.rs index 0ee26b6a1b9ee..c52496d0b30d7 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/lifetimes.rs +++ b/src/test/run-pass/proc-macro/auxiliary/lifetimes.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/modify-ast.rs b/src/test/run-pass/proc-macro/auxiliary/modify-ast.rs similarity index 99% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/modify-ast.rs rename to src/test/run-pass/proc-macro/auxiliary/modify-ast.rs index 498c6811d9c20..ff28c1db4f0b1 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/modify-ast.rs +++ b/src/test/run-pass/proc-macro/auxiliary/modify-ast.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/negative-token.rs b/src/test/run-pass/proc-macro/auxiliary/negative-token.rs similarity index 98% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/negative-token.rs rename to src/test/run-pass/proc-macro/auxiliary/negative-token.rs index fd639696991f6..ef4fd8d84a224 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/negative-token.rs +++ b/src/test/run-pass/proc-macro/auxiliary/negative-token.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/not-joint.rs b/src/test/run-pass/proc-macro/auxiliary/not-joint.rs similarity index 98% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/not-joint.rs rename to src/test/run-pass/proc-macro/auxiliary/not-joint.rs index e00a4d89e8d62..90209e042b23f 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/not-joint.rs +++ b/src/test/run-pass/proc-macro/auxiliary/not-joint.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/span-api-tests.rs b/src/test/run-pass/proc-macro/auxiliary/span-api-tests.rs similarity index 100% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/span-api-tests.rs rename to src/test/run-pass/proc-macro/auxiliary/span-api-tests.rs diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/span-test-macros.rs b/src/test/run-pass/proc-macro/auxiliary/span-test-macros.rs similarity index 100% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/span-test-macros.rs rename to src/test/run-pass/proc-macro/auxiliary/span-test-macros.rs diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/test-macros.rs b/src/test/run-pass/proc-macro/auxiliary/test-macros.rs similarity index 98% rename from src/test/run-pass-fulldeps/proc-macro/auxiliary/test-macros.rs rename to src/test/run-pass/proc-macro/auxiliary/test-macros.rs index 581c7cb15a59c..0e4343a90d645 100644 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/test-macros.rs +++ b/src/test/run-pass/proc-macro/auxiliary/test-macros.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/run-pass-fulldeps/proc-macro/bang-macro.rs b/src/test/run-pass/proc-macro/bang-macro.rs similarity index 97% rename from src/test/run-pass-fulldeps/proc-macro/bang-macro.rs rename to src/test/run-pass/proc-macro/bang-macro.rs index 10fe015555557..f433bc64c6e23 100644 --- a/src/test/run-pass-fulldeps/proc-macro/bang-macro.rs +++ b/src/test/run-pass/proc-macro/bang-macro.rs @@ -9,7 +9,6 @@ // except according to those terms. // aux-build:bang-macro.rs -// ignore-stage1 #![feature(proc_macro_hygiene)] diff --git a/src/test/run-pass-fulldeps/proc-macro/call-site.rs b/src/test/run-pass/proc-macro/call-site.rs similarity index 97% rename from src/test/run-pass-fulldeps/proc-macro/call-site.rs rename to src/test/run-pass/proc-macro/call-site.rs index b27c806f04717..ccbf33cc73b53 100644 --- a/src/test/run-pass-fulldeps/proc-macro/call-site.rs +++ b/src/test/run-pass/proc-macro/call-site.rs @@ -11,7 +11,6 @@ #![allow(unused_variables)] #![allow(unused_imports)] // aux-build:call-site.rs -// ignore-stage1 #![feature(proc_macro_hygiene)] diff --git a/src/test/run-pass-fulldeps/proc-macro/count_compound_ops.rs b/src/test/run-pass/proc-macro/count_compound_ops.rs similarity index 97% rename from src/test/run-pass-fulldeps/proc-macro/count_compound_ops.rs rename to src/test/run-pass/proc-macro/count_compound_ops.rs index 07ad4f288d894..46a5906e46ad1 100644 --- a/src/test/run-pass-fulldeps/proc-macro/count_compound_ops.rs +++ b/src/test/run-pass/proc-macro/count_compound_ops.rs @@ -9,7 +9,6 @@ // except according to those terms. // aux-build:count_compound_ops.rs -// ignore-stage1 #![feature(proc_macro_hygiene)] diff --git a/src/test/run-pass-fulldeps/proc-macro/crate-var.rs b/src/test/run-pass/proc-macro/crate-var.rs similarity index 98% rename from src/test/run-pass-fulldeps/proc-macro/crate-var.rs rename to src/test/run-pass/proc-macro/crate-var.rs index 41c15195bc840..00b467ad1c9b7 100644 --- a/src/test/run-pass-fulldeps/proc-macro/crate-var.rs +++ b/src/test/run-pass/proc-macro/crate-var.rs @@ -10,7 +10,6 @@ // aux-build:double.rs // aux-build:external-crate-var.rs -// ignore-stage1 #![allow(unused)] diff --git a/src/test/run-pass-fulldeps/proc-macro/custom-attr-only-one-derive.rs b/src/test/run-pass/proc-macro/custom-attr-only-one-derive.rs similarity index 100% rename from src/test/run-pass-fulldeps/proc-macro/custom-attr-only-one-derive.rs rename to src/test/run-pass/proc-macro/custom-attr-only-one-derive.rs diff --git a/src/test/run-pass-fulldeps/proc-macro/derive-attr-cfg.rs b/src/test/run-pass/proc-macro/derive-attr-cfg.rs similarity index 97% rename from src/test/run-pass-fulldeps/proc-macro/derive-attr-cfg.rs rename to src/test/run-pass/proc-macro/derive-attr-cfg.rs index e7e8b3d665ea1..f804042374d72 100644 --- a/src/test/run-pass-fulldeps/proc-macro/derive-attr-cfg.rs +++ b/src/test/run-pass/proc-macro/derive-attr-cfg.rs @@ -10,7 +10,6 @@ #![allow(dead_code)] // aux-build:derive-attr-cfg.rs -// ignore-stage1 extern crate derive_attr_cfg; use derive_attr_cfg::Foo; diff --git a/src/test/run-pass-fulldeps/proc-macro/derive-b.rs b/src/test/run-pass/proc-macro/derive-b.rs similarity index 97% rename from src/test/run-pass-fulldeps/proc-macro/derive-b.rs rename to src/test/run-pass/proc-macro/derive-b.rs index ac9eca3822669..60a6cf7662d01 100644 --- a/src/test/run-pass-fulldeps/proc-macro/derive-b.rs +++ b/src/test/run-pass/proc-macro/derive-b.rs @@ -9,7 +9,6 @@ // except according to those terms. // aux-build:derive-b.rs -// ignore-stage1 #![feature(unrestricted_attribute_tokens)] diff --git a/src/test/run-pass-fulldeps/proc-macro/derive-same-struct.rs b/src/test/run-pass/proc-macro/derive-same-struct.rs similarity index 97% rename from src/test/run-pass-fulldeps/proc-macro/derive-same-struct.rs rename to src/test/run-pass/proc-macro/derive-same-struct.rs index 64ad57107c7b2..7aff32e16cebd 100644 --- a/src/test/run-pass-fulldeps/proc-macro/derive-same-struct.rs +++ b/src/test/run-pass/proc-macro/derive-same-struct.rs @@ -11,7 +11,6 @@ #![allow(path_statements)] #![allow(dead_code)] // aux-build:derive-same-struct.rs -// ignore-stage1 #[macro_use] extern crate derive_same_struct; diff --git a/src/test/run-pass-fulldeps/proc-macro/derive-same-struct.stdout b/src/test/run-pass/proc-macro/derive-same-struct.stdout similarity index 100% rename from src/test/run-pass-fulldeps/proc-macro/derive-same-struct.stdout rename to src/test/run-pass/proc-macro/derive-same-struct.stdout diff --git a/src/test/run-pass-fulldeps/proc-macro/derive-test.rs b/src/test/run-pass/proc-macro/derive-test.rs similarity index 100% rename from src/test/run-pass-fulldeps/proc-macro/derive-test.rs rename to src/test/run-pass/proc-macro/derive-test.rs diff --git a/src/test/run-pass-fulldeps/proc-macro/derive-two-attrs.rs b/src/test/run-pass/proc-macro/derive-two-attrs.rs similarity index 100% rename from src/test/run-pass-fulldeps/proc-macro/derive-two-attrs.rs rename to src/test/run-pass/proc-macro/derive-two-attrs.rs diff --git a/src/test/run-pass-fulldeps/proc-macro/derive-union.rs b/src/test/run-pass/proc-macro/derive-union.rs similarity index 97% rename from src/test/run-pass-fulldeps/proc-macro/derive-union.rs rename to src/test/run-pass/proc-macro/derive-union.rs index 298a652aacceb..2aae1d8635feb 100644 --- a/src/test/run-pass-fulldeps/proc-macro/derive-union.rs +++ b/src/test/run-pass/proc-macro/derive-union.rs @@ -10,7 +10,6 @@ #![allow(unused_variables)] // aux-build:derive-union.rs -// ignore-stage1 #[macro_use] extern crate derive_union; diff --git a/src/test/run-pass-fulldeps/proc-macro/empty-crate.rs b/src/test/run-pass/proc-macro/empty-crate.rs similarity index 97% rename from src/test/run-pass-fulldeps/proc-macro/empty-crate.rs rename to src/test/run-pass/proc-macro/empty-crate.rs index 2b0a57dafefc9..1a0c0506112cb 100644 --- a/src/test/run-pass-fulldeps/proc-macro/empty-crate.rs +++ b/src/test/run-pass/proc-macro/empty-crate.rs @@ -10,7 +10,6 @@ #![allow(unused_imports)] // aux-build:empty-crate.rs -// ignore-stage1 #[macro_use] extern crate empty_crate; diff --git a/src/test/run-pass-fulldeps/proc-macro/expand-with-a-macro.rs b/src/test/run-pass/proc-macro/expand-with-a-macro.rs similarity index 92% rename from src/test/run-pass-fulldeps/proc-macro/expand-with-a-macro.rs rename to src/test/run-pass/proc-macro/expand-with-a-macro.rs index 4ccd4615fb609..944973ee7063a 100644 --- a/src/test/run-pass-fulldeps/proc-macro/expand-with-a-macro.rs +++ b/src/test/run-pass/proc-macro/expand-with-a-macro.rs @@ -9,7 +9,8 @@ // except according to those terms. // aux-build:expand-with-a-macro.rs -// ignore-stage1 + +// ignore-wasm32-bare compiled with panic=abort by default #![deny(warnings)] diff --git a/src/test/run-pass-fulldeps/proc-macro/gen-lifetime-token.rs b/src/test/run-pass/proc-macro/gen-lifetime-token.rs similarity index 100% rename from src/test/run-pass-fulldeps/proc-macro/gen-lifetime-token.rs rename to src/test/run-pass/proc-macro/gen-lifetime-token.rs diff --git a/src/test/run-pass-fulldeps/proc-macro/hygiene_example.rs b/src/test/run-pass/proc-macro/hygiene_example.rs similarity index 98% rename from src/test/run-pass-fulldeps/proc-macro/hygiene_example.rs rename to src/test/run-pass/proc-macro/hygiene_example.rs index cf18bb247c769..41857fde26920 100644 --- a/src/test/run-pass-fulldeps/proc-macro/hygiene_example.rs +++ b/src/test/run-pass/proc-macro/hygiene_example.rs @@ -11,7 +11,6 @@ #![allow(unused_macros)] // aux-build:hygiene_example_codegen.rs // aux-build:hygiene_example.rs -// ignore-stage1 #![feature(proc_macro_hygiene)] diff --git a/src/test/run-pass-fulldeps/proc-macro/issue-39889.rs b/src/test/run-pass/proc-macro/issue-39889.rs similarity index 97% rename from src/test/run-pass-fulldeps/proc-macro/issue-39889.rs rename to src/test/run-pass/proc-macro/issue-39889.rs index f722109260103..99500a77f09ea 100644 --- a/src/test/run-pass-fulldeps/proc-macro/issue-39889.rs +++ b/src/test/run-pass/proc-macro/issue-39889.rs @@ -10,7 +10,6 @@ #![allow(dead_code)] // aux-build:issue-39889.rs -// ignore-stage1 extern crate issue_39889; use issue_39889::Issue39889; diff --git a/src/test/run-pass-fulldeps/proc-macro/issue-42708.rs b/src/test/run-pass/proc-macro/issue-42708.rs similarity index 97% rename from src/test/run-pass-fulldeps/proc-macro/issue-42708.rs rename to src/test/run-pass/proc-macro/issue-42708.rs index 7bbdbc6505db5..8f9c8723953f2 100644 --- a/src/test/run-pass-fulldeps/proc-macro/issue-42708.rs +++ b/src/test/run-pass/proc-macro/issue-42708.rs @@ -9,7 +9,6 @@ // except according to those terms. // aux-build:issue-42708.rs -// ignore-stage1 #![feature(decl_macro)] #![allow(unused)] diff --git a/src/test/run-pass-fulldeps/proc-macro/issue-50061.rs b/src/test/run-pass/proc-macro/issue-50061.rs similarity index 97% rename from src/test/run-pass-fulldeps/proc-macro/issue-50061.rs rename to src/test/run-pass/proc-macro/issue-50061.rs index 046591665750c..1a751161a4465 100644 --- a/src/test/run-pass-fulldeps/proc-macro/issue-50061.rs +++ b/src/test/run-pass/proc-macro/issue-50061.rs @@ -10,7 +10,6 @@ #![allow(path_statements)] // aux-build:issue-50061.rs -// ignore-stage1 #![feature(decl_macro)] diff --git a/src/test/run-pass-fulldeps/proc-macro/lifetimes.rs b/src/test/run-pass/proc-macro/lifetimes.rs similarity index 98% rename from src/test/run-pass-fulldeps/proc-macro/lifetimes.rs rename to src/test/run-pass/proc-macro/lifetimes.rs index 79d6d27dc598d..7cd234df650fb 100644 --- a/src/test/run-pass-fulldeps/proc-macro/lifetimes.rs +++ b/src/test/run-pass/proc-macro/lifetimes.rs @@ -10,7 +10,6 @@ #![allow(unused_variables)] // aux-build:lifetimes.rs -// ignore-stage1 extern crate lifetimes; use lifetimes::*; diff --git a/src/test/run-pass-fulldeps/proc-macro/load-two.rs b/src/test/run-pass/proc-macro/load-two.rs similarity index 97% rename from src/test/run-pass-fulldeps/proc-macro/load-two.rs rename to src/test/run-pass/proc-macro/load-two.rs index cf1e076f270b6..319e99d4e44d2 100644 --- a/src/test/run-pass-fulldeps/proc-macro/load-two.rs +++ b/src/test/run-pass/proc-macro/load-two.rs @@ -12,7 +12,6 @@ #![allow(dead_code)] // aux-build:derive-atob.rs // aux-build:derive-ctod.rs -// ignore-stage1 #[macro_use] extern crate derive_atob; diff --git a/src/test/run-pass-fulldeps/proc-macro/macros-in-extern.rs b/src/test/run-pass/proc-macro/macros-in-extern.rs similarity index 98% rename from src/test/run-pass-fulldeps/proc-macro/macros-in-extern.rs rename to src/test/run-pass/proc-macro/macros-in-extern.rs index bd76cc380544f..ce62cabf281db 100644 --- a/src/test/run-pass-fulldeps/proc-macro/macros-in-extern.rs +++ b/src/test/run-pass/proc-macro/macros-in-extern.rs @@ -9,7 +9,6 @@ // except according to those terms. // aux-build:test-macros.rs -// ignore-stage1 // ignore-wasm32 #![feature(macros_in_extern)] diff --git a/src/test/run-pass-fulldeps/proc-macro/modify-ast.rs b/src/test/run-pass/proc-macro/modify-ast.rs similarity index 100% rename from src/test/run-pass-fulldeps/proc-macro/modify-ast.rs rename to src/test/run-pass/proc-macro/modify-ast.rs diff --git a/src/test/run-pass-fulldeps/proc-macro/negative-token.rs b/src/test/run-pass/proc-macro/negative-token.rs similarity index 97% rename from src/test/run-pass-fulldeps/proc-macro/negative-token.rs rename to src/test/run-pass/proc-macro/negative-token.rs index ccd729badebb9..f953ba8df7e40 100644 --- a/src/test/run-pass-fulldeps/proc-macro/negative-token.rs +++ b/src/test/run-pass/proc-macro/negative-token.rs @@ -9,7 +9,6 @@ // except according to those terms. // aux-build:negative-token.rs -// ignore-stage1 #![feature(proc_macro_hygiene)] diff --git a/src/test/run-pass-fulldeps/proc-macro/not-joint.rs b/src/test/run-pass/proc-macro/not-joint.rs similarity index 100% rename from src/test/run-pass-fulldeps/proc-macro/not-joint.rs rename to src/test/run-pass/proc-macro/not-joint.rs diff --git a/src/test/run-pass-fulldeps/proc-macro/smoke.rs b/src/test/run-pass/proc-macro/smoke.rs similarity index 97% rename from src/test/run-pass-fulldeps/proc-macro/smoke.rs rename to src/test/run-pass/proc-macro/smoke.rs index 49011e19a513d..ba0cd3b398d55 100644 --- a/src/test/run-pass-fulldeps/proc-macro/smoke.rs +++ b/src/test/run-pass/proc-macro/smoke.rs @@ -11,7 +11,6 @@ #![allow(unused_must_use)] #![allow(path_statements)] // aux-build:derive-a.rs -// ignore-stage1 #[macro_use] extern crate derive_a; diff --git a/src/test/run-pass-fulldeps/proc-macro/span-api-tests.rs b/src/test/run-pass/proc-macro/span-api-tests.rs similarity index 100% rename from src/test/run-pass-fulldeps/proc-macro/span-api-tests.rs rename to src/test/run-pass/proc-macro/span-api-tests.rs diff --git a/src/test/run-pass-fulldeps/proc-macro/struct-field-macro.rs b/src/test/run-pass/proc-macro/struct-field-macro.rs similarity index 97% rename from src/test/run-pass-fulldeps/proc-macro/struct-field-macro.rs rename to src/test/run-pass/proc-macro/struct-field-macro.rs index db52aa5d3a62a..b1ac8038fa283 100644 --- a/src/test/run-pass-fulldeps/proc-macro/struct-field-macro.rs +++ b/src/test/run-pass/proc-macro/struct-field-macro.rs @@ -10,7 +10,6 @@ #![allow(dead_code)] // aux-build:derive-nothing.rs -// ignore-stage1 #[macro_use] extern crate derive_nothing; diff --git a/src/test/run-pass-fulldeps/proc_macro.rs b/src/test/run-pass/proc_macro.rs similarity index 98% rename from src/test/run-pass-fulldeps/proc_macro.rs rename to src/test/run-pass/proc_macro.rs index 27e0c23561f57..e14ceca8e4211 100644 --- a/src/test/run-pass-fulldeps/proc_macro.rs +++ b/src/test/run-pass/proc_macro.rs @@ -9,7 +9,6 @@ // except according to those terms. // aux-build:proc_macro_def.rs -// ignore-stage1 // ignore-cross-compile #![feature(proc_macro_hygiene)] diff --git a/src/test/rustdoc/doc-proc-macro.rs b/src/test/rustdoc/doc-proc-macro.rs index 01a4a410b03fb..b3b403a7b86aa 100644 --- a/src/test/rustdoc/doc-proc-macro.rs +++ b/src/test/rustdoc/doc-proc-macro.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-stage1 - // Issue #52129: ICE when trying to document the `quote` proc-macro from proc_macro // As of this writing, we don't currently attempt to document proc-macros. However, we shouldn't diff --git a/src/test/rustdoc/inline_cross/auxiliary/proc_macro.rs b/src/test/rustdoc/inline_cross/auxiliary/proc_macro.rs index 6aac070c45bd9..bde1fd8b1e437 100644 --- a/src/test/rustdoc/inline_cross/auxiliary/proc_macro.rs +++ b/src/test/rustdoc/inline_cross/auxiliary/proc_macro.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type="proc-macro"] diff --git a/src/test/rustdoc/inline_cross/proc_macro.rs b/src/test/rustdoc/inline_cross/proc_macro.rs index a879258f82aee..c259e9cdaacf1 100644 --- a/src/test/rustdoc/inline_cross/proc_macro.rs +++ b/src/test/rustdoc/inline_cross/proc_macro.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-stage1 // aux-build:proc_macro.rs // build-aux-docs diff --git a/src/test/rustdoc/proc-macro.rs b/src/test/rustdoc/proc-macro.rs index bfd194701c85d..23d0d00580731 100644 --- a/src/test/rustdoc/proc-macro.rs +++ b/src/test/rustdoc/proc-macro.rs @@ -8,7 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-stage1 +// force-host +// no-prefer-dynamic #![crate_type="proc-macro"] #![crate_name="some_macros"] diff --git a/src/test/rustdoc/rustc-macro-crate.rs b/src/test/rustdoc/rustc-macro-crate.rs index d46f968441172..6ad5556b8f5db 100644 --- a/src/test/rustdoc/rustc-macro-crate.rs +++ b/src/test/rustdoc/rustc-macro-crate.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic -// ignore-stage1 #![crate_type = "proc-macro"] diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/attr_proc_macro.rs b/src/test/ui-fulldeps/proc-macro/auxiliary/attr_proc_macro.rs deleted file mode 100644 index 679cb7728680d..0000000000000 --- a/src/test/ui-fulldeps/proc-macro/auxiliary/attr_proc_macro.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// force-host -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_attribute] -pub fn attr_proc_macro(_: TokenStream, input: TokenStream) -> TokenStream { - input -} diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/bang_proc_macro.rs b/src/test/ui-fulldeps/proc-macro/auxiliary/bang_proc_macro.rs deleted file mode 100644 index 6484725814a10..0000000000000 --- a/src/test/ui-fulldeps/proc-macro/auxiliary/bang_proc_macro.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// force-host -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro] -pub fn bang_proc_macro(input: TokenStream) -> TokenStream { - input -} diff --git a/src/test/ui-fulldeps/custom-derive/auxiliary/plugin.rs b/src/test/ui/custom-derive/auxiliary/plugin.rs similarity index 98% rename from src/test/ui-fulldeps/custom-derive/auxiliary/plugin.rs rename to src/test/ui/custom-derive/auxiliary/plugin.rs index 124bc05b7a348..921e2ce2fe004 100644 --- a/src/test/ui-fulldeps/custom-derive/auxiliary/plugin.rs +++ b/src/test/ui/custom-derive/auxiliary/plugin.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/ui-fulldeps/custom-derive/derive-in-mod.rs b/src/test/ui/custom-derive/derive-in-mod.rs similarity index 100% rename from src/test/ui-fulldeps/custom-derive/derive-in-mod.rs rename to src/test/ui/custom-derive/derive-in-mod.rs diff --git a/src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import-ambig.rs b/src/test/ui/custom-derive/helper-attr-blocked-by-import-ambig.rs similarity index 91% rename from src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import-ambig.rs rename to src/test/ui/custom-derive/helper-attr-blocked-by-import-ambig.rs index b750a8bb0d932..ba072ba3568b7 100644 --- a/src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import-ambig.rs +++ b/src/test/ui/custom-derive/helper-attr-blocked-by-import-ambig.rs @@ -1,5 +1,4 @@ // aux-build:plugin.rs -// ignore-stage1 #[macro_use(WithHelper)] extern crate plugin; diff --git a/src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import-ambig.stderr b/src/test/ui/custom-derive/helper-attr-blocked-by-import-ambig.stderr similarity index 78% rename from src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import-ambig.stderr rename to src/test/ui/custom-derive/helper-attr-blocked-by-import-ambig.stderr index d288d7295120c..2c9d226cc9ef7 100644 --- a/src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import-ambig.stderr +++ b/src/test/ui/custom-derive/helper-attr-blocked-by-import-ambig.stderr @@ -1,16 +1,16 @@ error[E0659]: `helper` is ambiguous (derive helper attribute vs any other name) - --> $DIR/helper-attr-blocked-by-import-ambig.rs:10:3 + --> $DIR/helper-attr-blocked-by-import-ambig.rs:9:3 | LL | #[helper] //~ ERROR `helper` is ambiguous | ^^^^^^ ambiguous name | note: `helper` could refer to the derive helper attribute defined here - --> $DIR/helper-attr-blocked-by-import-ambig.rs:9:10 + --> $DIR/helper-attr-blocked-by-import-ambig.rs:8:10 | LL | #[derive(WithHelper)] | ^^^^^^^^^^ note: `helper` could also refer to the attribute macro imported here - --> $DIR/helper-attr-blocked-by-import-ambig.rs:7:5 + --> $DIR/helper-attr-blocked-by-import-ambig.rs:6:5 | LL | use plugin::helper; | ^^^^^^^^^^^^^^ diff --git a/src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import.rs b/src/test/ui/custom-derive/helper-attr-blocked-by-import.rs similarity index 95% rename from src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import.rs rename to src/test/ui/custom-derive/helper-attr-blocked-by-import.rs index 03b774f6c6400..abbf014f55337 100644 --- a/src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import.rs +++ b/src/test/ui/custom-derive/helper-attr-blocked-by-import.rs @@ -1,6 +1,5 @@ // compile-pass // aux-build:plugin.rs -// ignore-stage1 #[macro_use(WithHelper)] extern crate plugin; diff --git a/src/test/ui-fulldeps/custom-derive/issue-36935.rs b/src/test/ui/custom-derive/issue-36935.rs similarity index 97% rename from src/test/ui-fulldeps/custom-derive/issue-36935.rs rename to src/test/ui/custom-derive/issue-36935.rs index 5ec79a5520009..92c47eba9adb4 100644 --- a/src/test/ui-fulldeps/custom-derive/issue-36935.rs +++ b/src/test/ui/custom-derive/issue-36935.rs @@ -9,7 +9,7 @@ // except according to those terms. // aux-build:plugin.rs -// ignore-stage1 + #[macro_use] extern crate plugin; diff --git a/src/test/ui-fulldeps/custom-derive/issue-36935.stderr b/src/test/ui/custom-derive/issue-36935.stderr similarity index 100% rename from src/test/ui-fulldeps/custom-derive/issue-36935.stderr rename to src/test/ui/custom-derive/issue-36935.stderr diff --git a/src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs-test.rs b/src/test/ui/proc-macro/ambiguous-builtin-attrs-test.rs similarity index 100% rename from src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs-test.rs rename to src/test/ui/proc-macro/ambiguous-builtin-attrs-test.rs diff --git a/src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs-test.stderr b/src/test/ui/proc-macro/ambiguous-builtin-attrs-test.stderr similarity index 100% rename from src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs-test.stderr rename to src/test/ui/proc-macro/ambiguous-builtin-attrs-test.stderr diff --git a/src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs.rs b/src/test/ui/proc-macro/ambiguous-builtin-attrs.rs similarity index 100% rename from src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs.rs rename to src/test/ui/proc-macro/ambiguous-builtin-attrs.rs diff --git a/src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs.stderr b/src/test/ui/proc-macro/ambiguous-builtin-attrs.stderr similarity index 100% rename from src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs.stderr rename to src/test/ui/proc-macro/ambiguous-builtin-attrs.stderr diff --git a/src/test/ui-fulldeps/attribute-order-restricted.rs b/src/test/ui/proc-macro/attribute-order-restricted.rs similarity index 100% rename from src/test/ui-fulldeps/attribute-order-restricted.rs rename to src/test/ui/proc-macro/attribute-order-restricted.rs diff --git a/src/test/ui-fulldeps/attribute-order-restricted.stderr b/src/test/ui/proc-macro/attribute-order-restricted.stderr similarity index 100% rename from src/test/ui-fulldeps/attribute-order-restricted.stderr rename to src/test/ui/proc-macro/attribute-order-restricted.stderr diff --git a/src/test/ui-fulldeps/proc-macro/attribute-spans-preserved.rs b/src/test/ui/proc-macro/attribute-spans-preserved.rs similarity index 100% rename from src/test/ui-fulldeps/proc-macro/attribute-spans-preserved.rs rename to src/test/ui/proc-macro/attribute-spans-preserved.rs diff --git a/src/test/ui-fulldeps/proc-macro/attribute-spans-preserved.stderr b/src/test/ui/proc-macro/attribute-spans-preserved.stderr similarity index 100% rename from src/test/ui-fulldeps/proc-macro/attribute-spans-preserved.stderr rename to src/test/ui/proc-macro/attribute-spans-preserved.stderr diff --git a/src/test/ui-fulldeps/proc-macro/attribute-spans-preserved.stdout b/src/test/ui/proc-macro/attribute-spans-preserved.stdout similarity index 100% rename from src/test/ui-fulldeps/proc-macro/attribute-spans-preserved.stdout rename to src/test/ui/proc-macro/attribute-spans-preserved.stdout diff --git a/src/test/ui-fulldeps/auxiliary/attr_proc_macro.rs b/src/test/ui/proc-macro/auxiliary/attr_proc_macro.rs similarity index 100% rename from src/test/ui-fulldeps/auxiliary/attr_proc_macro.rs rename to src/test/ui/proc-macro/auxiliary/attr_proc_macro.rs diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/attribute-spans-preserved.rs b/src/test/ui/proc-macro/auxiliary/attribute-spans-preserved.rs similarity index 98% rename from src/test/ui-fulldeps/proc-macro/auxiliary/attribute-spans-preserved.rs rename to src/test/ui/proc-macro/auxiliary/attribute-spans-preserved.rs index e725cc7afb82b..9f7a7e4f22284 100644 --- a/src/test/ui-fulldeps/proc-macro/auxiliary/attribute-spans-preserved.rs +++ b/src/test/ui/proc-macro/auxiliary/attribute-spans-preserved.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/ui-fulldeps/auxiliary/bang_proc_macro.rs b/src/test/ui/proc-macro/auxiliary/bang_proc_macro.rs similarity index 100% rename from src/test/ui-fulldeps/auxiliary/bang_proc_macro.rs rename to src/test/ui/proc-macro/auxiliary/bang_proc_macro.rs diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/builtin-attrs.rs b/src/test/ui/proc-macro/auxiliary/builtin-attrs.rs similarity index 98% rename from src/test/ui-fulldeps/proc-macro/auxiliary/builtin-attrs.rs rename to src/test/ui/proc-macro/auxiliary/builtin-attrs.rs index e18ca57aab1fc..571ea1bc5f395 100644 --- a/src/test/ui-fulldeps/proc-macro/auxiliary/builtin-attrs.rs +++ b/src/test/ui/proc-macro/auxiliary/builtin-attrs.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/ui-fulldeps/auxiliary/derive-clona.rs b/src/test/ui/proc-macro/auxiliary/derive-clona.rs similarity index 100% rename from src/test/ui-fulldeps/auxiliary/derive-clona.rs rename to src/test/ui/proc-macro/auxiliary/derive-clona.rs diff --git a/src/test/ui-fulldeps/auxiliary/derive-foo.rs b/src/test/ui/proc-macro/auxiliary/derive-foo.rs similarity index 100% rename from src/test/ui-fulldeps/auxiliary/derive-foo.rs rename to src/test/ui/proc-macro/auxiliary/derive-foo.rs diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/derive-helper-shadowed-2.rs b/src/test/ui/proc-macro/auxiliary/derive-helper-shadowed-2.rs similarity index 100% rename from src/test/ui-fulldeps/proc-macro/auxiliary/derive-helper-shadowed-2.rs rename to src/test/ui/proc-macro/auxiliary/derive-helper-shadowed-2.rs diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/derive-helper-shadowed.rs b/src/test/ui/proc-macro/auxiliary/derive-helper-shadowed.rs similarity index 93% rename from src/test/ui-fulldeps/proc-macro/auxiliary/derive-helper-shadowed.rs rename to src/test/ui/proc-macro/auxiliary/derive-helper-shadowed.rs index 4e701710f4212..5b5243dd60ee3 100644 --- a/src/test/ui-fulldeps/proc-macro/auxiliary/derive-helper-shadowed.rs +++ b/src/test/ui/proc-macro/auxiliary/derive-helper-shadowed.rs @@ -1,3 +1,4 @@ +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/derive-helper-shadowing.rs b/src/test/ui/proc-macro/auxiliary/derive-helper-shadowing.rs similarity index 95% rename from src/test/ui-fulldeps/proc-macro/auxiliary/derive-helper-shadowing.rs rename to src/test/ui/proc-macro/auxiliary/derive-helper-shadowing.rs index 0fd8aa5638a50..6e0bdcba9c50f 100644 --- a/src/test/ui-fulldeps/proc-macro/auxiliary/derive-helper-shadowing.rs +++ b/src/test/ui/proc-macro/auxiliary/derive-helper-shadowing.rs @@ -1,3 +1,4 @@ +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/derive-panic.rs b/src/test/ui/proc-macro/auxiliary/derive-panic.rs similarity index 100% rename from src/test/ui-fulldeps/proc-macro/auxiliary/derive-panic.rs rename to src/test/ui/proc-macro/auxiliary/derive-panic.rs index 3274f0324e1cb..d7fa5b6bed10d 100644 --- a/src/test/ui-fulldeps/proc-macro/auxiliary/derive-panic.rs +++ b/src/test/ui/proc-macro/auxiliary/derive-panic.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// no-prefer-dynamic // force-host +// no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/generate-mod.rs b/src/test/ui/proc-macro/auxiliary/generate-mod.rs similarity index 99% rename from src/test/ui-fulldeps/proc-macro/auxiliary/generate-mod.rs rename to src/test/ui/proc-macro/auxiliary/generate-mod.rs index 1ed8ef5202735..a1f025de3be73 100644 --- a/src/test/ui-fulldeps/proc-macro/auxiliary/generate-mod.rs +++ b/src/test/ui/proc-macro/auxiliary/generate-mod.rs @@ -9,6 +9,7 @@ // except according to those terms. // run-pass +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/ui-fulldeps/auxiliary/invalid-punct-ident.rs b/src/test/ui/proc-macro/auxiliary/invalid-punct-ident.rs similarity index 100% rename from src/test/ui-fulldeps/auxiliary/invalid-punct-ident.rs rename to src/test/ui/proc-macro/auxiliary/invalid-punct-ident.rs diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/issue-53481.rs b/src/test/ui/proc-macro/auxiliary/issue-53481.rs similarity index 93% rename from src/test/ui-fulldeps/proc-macro/auxiliary/issue-53481.rs rename to src/test/ui/proc-macro/auxiliary/issue-53481.rs index 9554cdde4907e..d9f290dec7ef9 100644 --- a/src/test/ui-fulldeps/proc-macro/auxiliary/issue-53481.rs +++ b/src/test/ui/proc-macro/auxiliary/issue-53481.rs @@ -1,3 +1,4 @@ +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/ui-fulldeps/auxiliary/lifetimes.rs b/src/test/ui/proc-macro/auxiliary/lifetimes.rs similarity index 98% rename from src/test/ui-fulldeps/auxiliary/lifetimes.rs rename to src/test/ui/proc-macro/auxiliary/lifetimes.rs index fc59a622bfab0..8348d0888e49f 100644 --- a/src/test/ui-fulldeps/auxiliary/lifetimes.rs +++ b/src/test/ui/proc-macro/auxiliary/lifetimes.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/macro-brackets.rs b/src/test/ui/proc-macro/auxiliary/macro-brackets.rs similarity index 98% rename from src/test/ui-fulldeps/proc-macro/auxiliary/macro-brackets.rs rename to src/test/ui/proc-macro/auxiliary/macro-brackets.rs index be1777f3ebd05..08ff604fead1f 100644 --- a/src/test/ui-fulldeps/proc-macro/auxiliary/macro-brackets.rs +++ b/src/test/ui/proc-macro/auxiliary/macro-brackets.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/multispan.rs b/src/test/ui/proc-macro/auxiliary/multispan.rs similarity index 98% rename from src/test/ui-fulldeps/proc-macro/auxiliary/multispan.rs rename to src/test/ui/proc-macro/auxiliary/multispan.rs index 383016f990eb6..e122b22e080d6 100644 --- a/src/test/ui-fulldeps/proc-macro/auxiliary/multispan.rs +++ b/src/test/ui/proc-macro/auxiliary/multispan.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/nested-item-spans.rs b/src/test/ui/proc-macro/auxiliary/nested-item-spans.rs similarity index 98% rename from src/test/ui-fulldeps/proc-macro/auxiliary/nested-item-spans.rs rename to src/test/ui/proc-macro/auxiliary/nested-item-spans.rs index 6b893150b45e4..e195f425ab34f 100644 --- a/src/test/ui-fulldeps/proc-macro/auxiliary/nested-item-spans.rs +++ b/src/test/ui/proc-macro/auxiliary/nested-item-spans.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/parent-source-spans.rs b/src/test/ui/proc-macro/auxiliary/parent-source-spans.rs similarity index 99% rename from src/test/ui-fulldeps/proc-macro/auxiliary/parent-source-spans.rs rename to src/test/ui/proc-macro/auxiliary/parent-source-spans.rs index f5590405e61e3..a007fad3675a9 100644 --- a/src/test/ui-fulldeps/proc-macro/auxiliary/parent-source-spans.rs +++ b/src/test/ui/proc-macro/auxiliary/parent-source-spans.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![feature(proc_macro_diagnostic, proc_macro_span)] diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/span-preservation.rs b/src/test/ui/proc-macro/auxiliary/span-preservation.rs similarity index 94% rename from src/test/ui-fulldeps/proc-macro/auxiliary/span-preservation.rs rename to src/test/ui/proc-macro/auxiliary/span-preservation.rs index 65ed9cf737254..33c7968104b72 100644 --- a/src/test/ui-fulldeps/proc-macro/auxiliary/span-preservation.rs +++ b/src/test/ui/proc-macro/auxiliary/span-preservation.rs @@ -1,3 +1,4 @@ +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/ui-fulldeps/auxiliary/subspan.rs b/src/test/ui/proc-macro/auxiliary/subspan.rs similarity index 99% rename from src/test/ui-fulldeps/auxiliary/subspan.rs rename to src/test/ui/proc-macro/auxiliary/subspan.rs index 134b04d7333bc..dbf355fea5054 100644 --- a/src/test/ui-fulldeps/auxiliary/subspan.rs +++ b/src/test/ui/proc-macro/auxiliary/subspan.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/three-equals.rs b/src/test/ui/proc-macro/auxiliary/three-equals.rs similarity index 99% rename from src/test/ui-fulldeps/proc-macro/auxiliary/three-equals.rs rename to src/test/ui/proc-macro/auxiliary/three-equals.rs index 569a458f55a44..b23841077e393 100644 --- a/src/test/ui-fulldeps/proc-macro/auxiliary/three-equals.rs +++ b/src/test/ui/proc-macro/auxiliary/three-equals.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/ui-fulldeps/proc-macro/derive-helper-shadowed.rs b/src/test/ui/proc-macro/derive-helper-shadowed.rs similarity index 100% rename from src/test/ui-fulldeps/proc-macro/derive-helper-shadowed.rs rename to src/test/ui/proc-macro/derive-helper-shadowed.rs diff --git a/src/test/ui-fulldeps/proc-macro/derive-helper-shadowing.rs b/src/test/ui/proc-macro/derive-helper-shadowing.rs similarity index 100% rename from src/test/ui-fulldeps/proc-macro/derive-helper-shadowing.rs rename to src/test/ui/proc-macro/derive-helper-shadowing.rs diff --git a/src/test/ui-fulldeps/proc-macro/derive-helper-shadowing.stderr b/src/test/ui/proc-macro/derive-helper-shadowing.stderr similarity index 100% rename from src/test/ui-fulldeps/proc-macro/derive-helper-shadowing.stderr rename to src/test/ui/proc-macro/derive-helper-shadowing.stderr diff --git a/src/test/ui-fulldeps/proc-macro/extern-prelude-extern-crate-proc-macro.rs b/src/test/ui/proc-macro/extern-prelude-extern-crate-proc-macro.rs similarity index 100% rename from src/test/ui-fulldeps/proc-macro/extern-prelude-extern-crate-proc-macro.rs rename to src/test/ui/proc-macro/extern-prelude-extern-crate-proc-macro.rs diff --git a/src/test/ui-fulldeps/proc-macro/generate-mod.rs b/src/test/ui/proc-macro/generate-mod.rs similarity index 100% rename from src/test/ui-fulldeps/proc-macro/generate-mod.rs rename to src/test/ui/proc-macro/generate-mod.rs diff --git a/src/test/ui-fulldeps/proc-macro/generate-mod.stderr b/src/test/ui/proc-macro/generate-mod.stderr similarity index 100% rename from src/test/ui-fulldeps/proc-macro/generate-mod.stderr rename to src/test/ui/proc-macro/generate-mod.stderr diff --git a/src/test/ui-fulldeps/proc-macro/invalid-attributes.rs b/src/test/ui/proc-macro/invalid-attributes.rs similarity index 98% rename from src/test/ui-fulldeps/proc-macro/invalid-attributes.rs rename to src/test/ui/proc-macro/invalid-attributes.rs index 8b940a0f40585..cca954fdc6b90 100644 --- a/src/test/ui-fulldeps/proc-macro/invalid-attributes.rs +++ b/src/test/ui/proc-macro/invalid-attributes.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/ui-fulldeps/proc-macro/invalid-attributes.stderr b/src/test/ui/proc-macro/invalid-attributes.stderr similarity index 82% rename from src/test/ui-fulldeps/proc-macro/invalid-attributes.stderr rename to src/test/ui/proc-macro/invalid-attributes.stderr index 5fd87362db23b..c480bcb5df982 100644 --- a/src/test/ui-fulldeps/proc-macro/invalid-attributes.stderr +++ b/src/test/ui/proc-macro/invalid-attributes.stderr @@ -1,35 +1,35 @@ error: `#[proc_macro]` attribute does not take any arguments - --> $DIR/invalid-attributes.rs:19:1 + --> $DIR/invalid-attributes.rs:20:1 | LL | #[proc_macro = "test"] //~ ERROR: does not take any arguments | ^^^^^^^^^^^^^^^^^^^^^^ error: `#[proc_macro]` attribute does not take any arguments - --> $DIR/invalid-attributes.rs:22:1 + --> $DIR/invalid-attributes.rs:23:1 | LL | #[proc_macro()] //~ ERROR: does not take any arguments | ^^^^^^^^^^^^^^^ error: `#[proc_macro]` attribute does not take any arguments - --> $DIR/invalid-attributes.rs:25:1 + --> $DIR/invalid-attributes.rs:26:1 | LL | #[proc_macro(x)] //~ ERROR: does not take any arguments | ^^^^^^^^^^^^^^^^ error: `#[proc_macro_attribute]` attribute does not take any arguments - --> $DIR/invalid-attributes.rs:28:1 + --> $DIR/invalid-attributes.rs:29:1 | LL | #[proc_macro_attribute = "test"] //~ ERROR: does not take any arguments | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `#[proc_macro_attribute]` attribute does not take any arguments - --> $DIR/invalid-attributes.rs:31:1 + --> $DIR/invalid-attributes.rs:32:1 | LL | #[proc_macro_attribute()] //~ ERROR: does not take any arguments | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: `#[proc_macro_attribute]` attribute does not take any arguments - --> $DIR/invalid-attributes.rs:34:1 + --> $DIR/invalid-attributes.rs:35:1 | LL | #[proc_macro_attribute(x)] //~ ERROR: does not take any arguments | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui-fulldeps/invalid-punct-ident-1.rs b/src/test/ui/proc-macro/invalid-punct-ident-1.rs similarity index 100% rename from src/test/ui-fulldeps/invalid-punct-ident-1.rs rename to src/test/ui/proc-macro/invalid-punct-ident-1.rs diff --git a/src/test/ui-fulldeps/invalid-punct-ident-1.stderr b/src/test/ui/proc-macro/invalid-punct-ident-1.stderr similarity index 100% rename from src/test/ui-fulldeps/invalid-punct-ident-1.stderr rename to src/test/ui/proc-macro/invalid-punct-ident-1.stderr diff --git a/src/test/ui-fulldeps/invalid-punct-ident-2.rs b/src/test/ui/proc-macro/invalid-punct-ident-2.rs similarity index 100% rename from src/test/ui-fulldeps/invalid-punct-ident-2.rs rename to src/test/ui/proc-macro/invalid-punct-ident-2.rs diff --git a/src/test/ui-fulldeps/invalid-punct-ident-2.stderr b/src/test/ui/proc-macro/invalid-punct-ident-2.stderr similarity index 100% rename from src/test/ui-fulldeps/invalid-punct-ident-2.stderr rename to src/test/ui/proc-macro/invalid-punct-ident-2.stderr diff --git a/src/test/ui-fulldeps/invalid-punct-ident-3.rs b/src/test/ui/proc-macro/invalid-punct-ident-3.rs similarity index 100% rename from src/test/ui-fulldeps/invalid-punct-ident-3.rs rename to src/test/ui/proc-macro/invalid-punct-ident-3.rs diff --git a/src/test/ui-fulldeps/invalid-punct-ident-3.stderr b/src/test/ui/proc-macro/invalid-punct-ident-3.stderr similarity index 100% rename from src/test/ui-fulldeps/invalid-punct-ident-3.stderr rename to src/test/ui/proc-macro/invalid-punct-ident-3.stderr diff --git a/src/test/ui-fulldeps/invalid-punct-ident-4.rs b/src/test/ui/proc-macro/invalid-punct-ident-4.rs similarity index 100% rename from src/test/ui-fulldeps/invalid-punct-ident-4.rs rename to src/test/ui/proc-macro/invalid-punct-ident-4.rs diff --git a/src/test/ui-fulldeps/invalid-punct-ident-4.stderr b/src/test/ui/proc-macro/invalid-punct-ident-4.stderr similarity index 100% rename from src/test/ui-fulldeps/invalid-punct-ident-4.stderr rename to src/test/ui/proc-macro/invalid-punct-ident-4.stderr diff --git a/src/test/ui-fulldeps/proc-macro/issue-53481.rs b/src/test/ui/proc-macro/issue-53481.rs similarity index 100% rename from src/test/ui-fulldeps/proc-macro/issue-53481.rs rename to src/test/ui/proc-macro/issue-53481.rs diff --git a/src/test/ui-fulldeps/lifetimes.rs b/src/test/ui/proc-macro/lifetimes.rs similarity index 100% rename from src/test/ui-fulldeps/lifetimes.rs rename to src/test/ui/proc-macro/lifetimes.rs diff --git a/src/test/ui-fulldeps/lifetimes.stderr b/src/test/ui/proc-macro/lifetimes.stderr similarity index 100% rename from src/test/ui-fulldeps/lifetimes.stderr rename to src/test/ui/proc-macro/lifetimes.stderr diff --git a/src/test/ui-fulldeps/proc-macro/load-panic.rs b/src/test/ui/proc-macro/load-panic.rs similarity index 100% rename from src/test/ui-fulldeps/proc-macro/load-panic.rs rename to src/test/ui/proc-macro/load-panic.rs diff --git a/src/test/ui-fulldeps/proc-macro/load-panic.stderr b/src/test/ui/proc-macro/load-panic.stderr similarity index 100% rename from src/test/ui-fulldeps/proc-macro/load-panic.stderr rename to src/test/ui/proc-macro/load-panic.stderr diff --git a/src/test/ui-fulldeps/proc-macro/macro-brackets.rs b/src/test/ui/proc-macro/macro-brackets.rs similarity index 100% rename from src/test/ui-fulldeps/proc-macro/macro-brackets.rs rename to src/test/ui/proc-macro/macro-brackets.rs diff --git a/src/test/ui-fulldeps/proc-macro/macro-brackets.stderr b/src/test/ui/proc-macro/macro-brackets.stderr similarity index 100% rename from src/test/ui-fulldeps/proc-macro/macro-brackets.stderr rename to src/test/ui/proc-macro/macro-brackets.stderr diff --git a/src/test/ui-fulldeps/proc-macro/macro-namespace-reserved-2.rs b/src/test/ui/proc-macro/macro-namespace-reserved-2.rs similarity index 99% rename from src/test/ui-fulldeps/proc-macro/macro-namespace-reserved-2.rs rename to src/test/ui/proc-macro/macro-namespace-reserved-2.rs index fa05ad2fc605b..02526b60db0ad 100644 --- a/src/test/ui-fulldeps/proc-macro/macro-namespace-reserved-2.rs +++ b/src/test/ui/proc-macro/macro-namespace-reserved-2.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/ui-fulldeps/proc-macro/macro-namespace-reserved-2.stderr b/src/test/ui/proc-macro/macro-namespace-reserved-2.stderr similarity index 81% rename from src/test/ui-fulldeps/proc-macro/macro-namespace-reserved-2.stderr rename to src/test/ui/proc-macro/macro-namespace-reserved-2.stderr index 9def03e94506a..9e989ebdd3148 100644 --- a/src/test/ui-fulldeps/proc-macro/macro-namespace-reserved-2.stderr +++ b/src/test/ui/proc-macro/macro-namespace-reserved-2.stderr @@ -1,53 +1,53 @@ error: can't use a procedural macro from the same crate that defines it - --> $DIR/macro-namespace-reserved-2.rs:34:5 + --> $DIR/macro-namespace-reserved-2.rs:35:5 | LL | my_macro!(); //~ ERROR can't use a procedural macro from the same crate that defines it | ^^^^^^^^ error: can't use a procedural macro from the same crate that defines it - --> $DIR/macro-namespace-reserved-2.rs:37:5 + --> $DIR/macro-namespace-reserved-2.rs:38:5 | LL | my_macro_attr!(); //~ ERROR can't use a procedural macro from the same crate that defines it | ^^^^^^^^^^^^^ error: can't use a procedural macro from the same crate that defines it - --> $DIR/macro-namespace-reserved-2.rs:40:5 + --> $DIR/macro-namespace-reserved-2.rs:41:5 | LL | MyTrait!(); //~ ERROR can't use a procedural macro from the same crate that defines it | ^^^^^^^ error: can't use a procedural macro from the same crate that defines it - --> $DIR/macro-namespace-reserved-2.rs:43:3 + --> $DIR/macro-namespace-reserved-2.rs:44:3 | LL | #[my_macro] //~ ERROR can't use a procedural macro from the same crate that defines it | ^^^^^^^^ error: can't use a procedural macro from the same crate that defines it - --> $DIR/macro-namespace-reserved-2.rs:45:3 + --> $DIR/macro-namespace-reserved-2.rs:46:3 | LL | #[my_macro_attr] //~ ERROR can't use a procedural macro from the same crate that defines it | ^^^^^^^^^^^^^ error: can't use a procedural macro from the same crate that defines it - --> $DIR/macro-namespace-reserved-2.rs:47:3 + --> $DIR/macro-namespace-reserved-2.rs:48:3 | LL | #[MyTrait] //~ ERROR can't use a procedural macro from the same crate that defines it | ^^^^^^^ error: can't use a procedural macro from the same crate that defines it - --> $DIR/macro-namespace-reserved-2.rs:50:10 + --> $DIR/macro-namespace-reserved-2.rs:51:10 | LL | #[derive(my_macro)] //~ ERROR can't use a procedural macro from the same crate that defines it | ^^^^^^^^ error: can't use a procedural macro from the same crate that defines it - --> $DIR/macro-namespace-reserved-2.rs:52:10 + --> $DIR/macro-namespace-reserved-2.rs:53:10 | LL | #[derive(my_macro_attr)] //~ ERROR can't use a procedural macro from the same crate that defines it | ^^^^^^^^^^^^^ error: can't use a procedural macro from the same crate that defines it - --> $DIR/macro-namespace-reserved-2.rs:54:10 + --> $DIR/macro-namespace-reserved-2.rs:55:10 | LL | #[derive(MyTrait)] //~ ERROR can't use a procedural macro from the same crate that defines it | ^^^^^^^ diff --git a/src/test/ui-fulldeps/proc-macro/macro-namespace-reserved.rs b/src/test/ui/proc-macro/macro-namespace-reserved.rs similarity index 98% rename from src/test/ui-fulldeps/proc-macro/macro-namespace-reserved.rs rename to src/test/ui/proc-macro/macro-namespace-reserved.rs index e7bb05de88c8a..b0a3dbf0c1fab 100644 --- a/src/test/ui-fulldeps/proc-macro/macro-namespace-reserved.rs +++ b/src/test/ui/proc-macro/macro-namespace-reserved.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![feature(decl_macro)] diff --git a/src/test/ui-fulldeps/proc-macro/macro-namespace-reserved.stderr b/src/test/ui/proc-macro/macro-namespace-reserved.stderr similarity index 95% rename from src/test/ui-fulldeps/proc-macro/macro-namespace-reserved.stderr rename to src/test/ui/proc-macro/macro-namespace-reserved.stderr index 44b51edcc0b59..c453bde6c1796 100644 --- a/src/test/ui-fulldeps/proc-macro/macro-namespace-reserved.stderr +++ b/src/test/ui/proc-macro/macro-namespace-reserved.stderr @@ -1,5 +1,5 @@ error[E0428]: the name `my_macro` is defined multiple times - --> $DIR/macro-namespace-reserved.rs:34:1 + --> $DIR/macro-namespace-reserved.rs:35:1 | LL | pub fn my_macro(input: TokenStream) -> TokenStream { | -------------------------------------------------- previous definition of the macro `my_macro` here @@ -10,7 +10,7 @@ LL | macro my_macro() {} //~ ERROR the name `my_macro` is defined multiple times = note: `my_macro` must be defined only once in the macro namespace of this module error[E0428]: the name `my_macro_attr` is defined multiple times - --> $DIR/macro-namespace-reserved.rs:35:1 + --> $DIR/macro-namespace-reserved.rs:36:1 | LL | pub fn my_macro_attr(input: TokenStream, _: TokenStream) -> TokenStream { | ----------------------------------------------------------------------- previous definition of the macro `my_macro_attr` here @@ -21,7 +21,7 @@ LL | macro my_macro_attr() {} //~ ERROR the name `my_macro_attr` is defined mult = note: `my_macro_attr` must be defined only once in the macro namespace of this module error[E0428]: the name `MyTrait` is defined multiple times - --> $DIR/macro-namespace-reserved.rs:36:1 + --> $DIR/macro-namespace-reserved.rs:37:1 | LL | #[proc_macro_derive(MyTrait)] | ------- previous definition of the macro `MyTrait` here @@ -32,7 +32,7 @@ LL | macro MyTrait() {} //~ ERROR the name `MyTrait` is defined multiple times = note: `MyTrait` must be defined only once in the macro namespace of this module error[E0428]: the name `SameName` is defined multiple times - --> $DIR/macro-namespace-reserved.rs:44:1 + --> $DIR/macro-namespace-reserved.rs:45:1 | LL | #[proc_macro_derive(SameName)] | -------- previous definition of the macro `SameName` here diff --git a/src/test/ui-fulldeps/proc-macro/macro-use-attr.rs b/src/test/ui/proc-macro/macro-use-attr.rs similarity index 100% rename from src/test/ui-fulldeps/proc-macro/macro-use-attr.rs rename to src/test/ui/proc-macro/macro-use-attr.rs diff --git a/src/test/ui-fulldeps/proc-macro/macro-use-bang.rs b/src/test/ui/proc-macro/macro-use-bang.rs similarity index 100% rename from src/test/ui-fulldeps/proc-macro/macro-use-bang.rs rename to src/test/ui/proc-macro/macro-use-bang.rs diff --git a/src/test/ui-fulldeps/proc-macro/multispan.rs b/src/test/ui/proc-macro/multispan.rs similarity index 98% rename from src/test/ui-fulldeps/proc-macro/multispan.rs rename to src/test/ui/proc-macro/multispan.rs index 63a95ce211d7a..03067868a81f9 100644 --- a/src/test/ui-fulldeps/proc-macro/multispan.rs +++ b/src/test/ui/proc-macro/multispan.rs @@ -9,7 +9,6 @@ // except according to those terms. // aux-build:multispan.rs -// ignore-stage1 #![feature(proc_macro_hygiene)] diff --git a/src/test/ui-fulldeps/proc-macro/multispan.stderr b/src/test/ui/proc-macro/multispan.stderr similarity index 87% rename from src/test/ui-fulldeps/proc-macro/multispan.stderr rename to src/test/ui/proc-macro/multispan.stderr index 267313ef5ae0e..39bdbb5e4501e 100644 --- a/src/test/ui-fulldeps/proc-macro/multispan.stderr +++ b/src/test/ui/proc-macro/multispan.stderr @@ -1,83 +1,83 @@ error: hello to you, too! - --> $DIR/multispan.rs:25:5 + --> $DIR/multispan.rs:24:5 | LL | hello!(hi); //~ ERROR hello to you, too! | ^^^^^^^^^^^ | note: found these 'hi's - --> $DIR/multispan.rs:25:12 + --> $DIR/multispan.rs:24:12 | LL | hello!(hi); //~ ERROR hello to you, too! | ^^ error: hello to you, too! - --> $DIR/multispan.rs:28:5 + --> $DIR/multispan.rs:27:5 | LL | hello!(hi hi); //~ ERROR hello to you, too! | ^^^^^^^^^^^^^^ | note: found these 'hi's - --> $DIR/multispan.rs:28:12 + --> $DIR/multispan.rs:27:12 | LL | hello!(hi hi); //~ ERROR hello to you, too! | ^^ ^^ error: hello to you, too! - --> $DIR/multispan.rs:31:5 + --> $DIR/multispan.rs:30:5 | LL | hello!(hi hi hi); //~ ERROR hello to you, too! | ^^^^^^^^^^^^^^^^^ | note: found these 'hi's - --> $DIR/multispan.rs:31:12 + --> $DIR/multispan.rs:30:12 | LL | hello!(hi hi hi); //~ ERROR hello to you, too! | ^^ ^^ ^^ error: hello to you, too! - --> $DIR/multispan.rs:34:5 + --> $DIR/multispan.rs:33:5 | LL | hello!(hi hey hi yo hi beep beep hi hi); //~ ERROR hello to you, too! | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: found these 'hi's - --> $DIR/multispan.rs:34:12 + --> $DIR/multispan.rs:33:12 | LL | hello!(hi hey hi yo hi beep beep hi hi); //~ ERROR hello to you, too! | ^^ ^^ ^^ ^^ ^^ error: hello to you, too! - --> $DIR/multispan.rs:35:5 + --> $DIR/multispan.rs:34:5 | LL | hello!(hi there, hi how are you? hi... hi.); //~ ERROR hello to you, too! | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: found these 'hi's - --> $DIR/multispan.rs:35:12 + --> $DIR/multispan.rs:34:12 | LL | hello!(hi there, hi how are you? hi... hi.); //~ ERROR hello to you, too! | ^^ ^^ ^^ ^^ error: hello to you, too! - --> $DIR/multispan.rs:36:5 + --> $DIR/multispan.rs:35:5 | LL | hello!(whoah. hi di hi di ho); //~ ERROR hello to you, too! | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: found these 'hi's - --> $DIR/multispan.rs:36:19 + --> $DIR/multispan.rs:35:19 | LL | hello!(whoah. hi di hi di ho); //~ ERROR hello to you, too! | ^^ ^^ error: hello to you, too! - --> $DIR/multispan.rs:37:5 + --> $DIR/multispan.rs:36:5 | LL | hello!(hi good hi and good bye); //~ ERROR hello to you, too! | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: found these 'hi's - --> $DIR/multispan.rs:37:12 + --> $DIR/multispan.rs:36:12 | LL | hello!(hi good hi and good bye); //~ ERROR hello to you, too! | ^^ ^^ diff --git a/src/test/ui-fulldeps/proc-macro/nested-item-spans.rs b/src/test/ui/proc-macro/nested-item-spans.rs similarity index 100% rename from src/test/ui-fulldeps/proc-macro/nested-item-spans.rs rename to src/test/ui/proc-macro/nested-item-spans.rs diff --git a/src/test/ui-fulldeps/proc-macro/nested-item-spans.stderr b/src/test/ui/proc-macro/nested-item-spans.stderr similarity index 100% rename from src/test/ui-fulldeps/proc-macro/nested-item-spans.stderr rename to src/test/ui/proc-macro/nested-item-spans.stderr diff --git a/src/test/ui-fulldeps/proc-macro/non-root.rs b/src/test/ui/proc-macro/non-root.rs similarity index 98% rename from src/test/ui-fulldeps/proc-macro/non-root.rs rename to src/test/ui/proc-macro/non-root.rs index 2440488578814..437973a426e41 100644 --- a/src/test/ui-fulldeps/proc-macro/non-root.rs +++ b/src/test/ui/proc-macro/non-root.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/ui-fulldeps/proc-macro/non-root.stderr b/src/test/ui/proc-macro/non-root.stderr similarity index 90% rename from src/test/ui-fulldeps/proc-macro/non-root.stderr rename to src/test/ui/proc-macro/non-root.stderr index 23222a2b85145..8c14f644d7a64 100644 --- a/src/test/ui-fulldeps/proc-macro/non-root.stderr +++ b/src/test/ui/proc-macro/non-root.stderr @@ -1,5 +1,5 @@ error: functions tagged with `#[proc_macro]` must currently reside in the root of the crate - --> $DIR/non-root.rs:20:5 + --> $DIR/non-root.rs:21:5 | LL | pub fn foo(arg: TokenStream) -> TokenStream { arg } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui-fulldeps/proc-macro/parent-source-spans.rs b/src/test/ui/proc-macro/parent-source-spans.rs similarity index 99% rename from src/test/ui-fulldeps/proc-macro/parent-source-spans.rs rename to src/test/ui/proc-macro/parent-source-spans.rs index 7c30a8e328aa5..8f8e22ba1c34d 100644 --- a/src/test/ui-fulldeps/proc-macro/parent-source-spans.rs +++ b/src/test/ui/proc-macro/parent-source-spans.rs @@ -9,7 +9,7 @@ // except according to those terms. // aux-build:parent-source-spans.rs -// ignore-stage1 + #![feature(decl_macro, proc_macro_hygiene)] diff --git a/src/test/ui-fulldeps/proc-macro/parent-source-spans.stderr b/src/test/ui/proc-macro/parent-source-spans.stderr similarity index 100% rename from src/test/ui-fulldeps/proc-macro/parent-source-spans.stderr rename to src/test/ui/proc-macro/parent-source-spans.stderr diff --git a/src/test/ui-fulldeps/proc-macro/reserved-macro-names.rs b/src/test/ui/proc-macro/reserved-macro-names.rs similarity index 94% rename from src/test/ui-fulldeps/proc-macro/reserved-macro-names.rs rename to src/test/ui/proc-macro/reserved-macro-names.rs index ff5984aa67c7a..7c66af172fd5e 100644 --- a/src/test/ui-fulldeps/proc-macro/reserved-macro-names.rs +++ b/src/test/ui/proc-macro/reserved-macro-names.rs @@ -1,3 +1,6 @@ +// force-host +// no-prefer-dynamic + #![crate_type = "proc-macro"] extern crate proc_macro; diff --git a/src/test/ui-fulldeps/proc-macro/reserved-macro-names.stderr b/src/test/ui/proc-macro/reserved-macro-names.stderr similarity index 80% rename from src/test/ui-fulldeps/proc-macro/reserved-macro-names.stderr rename to src/test/ui/proc-macro/reserved-macro-names.stderr index be6e80c3878e1..5ebe62a4969bb 100644 --- a/src/test/ui-fulldeps/proc-macro/reserved-macro-names.stderr +++ b/src/test/ui/proc-macro/reserved-macro-names.stderr @@ -1,17 +1,17 @@ error: name `cfg` is reserved in macro namespace - --> $DIR/reserved-macro-names.rs:7:8 + --> $DIR/reserved-macro-names.rs:10:8 | LL | pub fn cfg(_: TokenStream, input: TokenStream) -> TokenStream { | ^^^ error: name `cfg_attr` is reserved in macro namespace - --> $DIR/reserved-macro-names.rs:13:8 + --> $DIR/reserved-macro-names.rs:16:8 | LL | pub fn cfg_attr(_: TokenStream, input: TokenStream) -> TokenStream { | ^^^^^^^^ error: name `derive` is reserved in macro namespace - --> $DIR/reserved-macro-names.rs:19:8 + --> $DIR/reserved-macro-names.rs:22:8 | LL | pub fn derive(_: TokenStream, input: TokenStream) -> TokenStream { | ^^^^^^ diff --git a/src/test/ui-fulldeps/resolve-error.rs b/src/test/ui/proc-macro/resolve-error.rs similarity index 100% rename from src/test/ui-fulldeps/resolve-error.rs rename to src/test/ui/proc-macro/resolve-error.rs diff --git a/src/test/ui-fulldeps/resolve-error.stderr b/src/test/ui/proc-macro/resolve-error.stderr similarity index 100% rename from src/test/ui-fulldeps/resolve-error.stderr rename to src/test/ui/proc-macro/resolve-error.stderr diff --git a/src/test/ui-fulldeps/proc-macro/signature.rs b/src/test/ui/proc-macro/signature.rs similarity index 94% rename from src/test/ui-fulldeps/proc-macro/signature.rs rename to src/test/ui/proc-macro/signature.rs index f2ea6f778cd26..4d6903187e449 100644 --- a/src/test/ui-fulldeps/proc-macro/signature.rs +++ b/src/test/ui/proc-macro/signature.rs @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host +// no-prefer-dynamic + #![crate_type = "proc-macro"] #![allow(warnings)] diff --git a/src/test/ui-fulldeps/proc-macro/signature.stderr b/src/test/ui/proc-macro/signature.stderr similarity index 94% rename from src/test/ui-fulldeps/proc-macro/signature.stderr rename to src/test/ui/proc-macro/signature.stderr index fdd10c3c5b903..681e72c08c445 100644 --- a/src/test/ui-fulldeps/proc-macro/signature.stderr +++ b/src/test/ui/proc-macro/signature.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/signature.rs:17:1 + --> $DIR/signature.rs:20:1 | LL | / pub unsafe extern fn foo(a: i32, b: u32) -> u32 { LL | | //~^ ERROR: mismatched types diff --git a/src/test/ui-fulldeps/proc-macro/span-preservation.rs b/src/test/ui/proc-macro/span-preservation.rs similarity index 100% rename from src/test/ui-fulldeps/proc-macro/span-preservation.rs rename to src/test/ui/proc-macro/span-preservation.rs diff --git a/src/test/ui-fulldeps/proc-macro/span-preservation.stderr b/src/test/ui/proc-macro/span-preservation.stderr similarity index 100% rename from src/test/ui-fulldeps/proc-macro/span-preservation.stderr rename to src/test/ui/proc-macro/span-preservation.stderr diff --git a/src/test/ui-fulldeps/subspan.rs b/src/test/ui/proc-macro/subspan.rs similarity index 98% rename from src/test/ui-fulldeps/subspan.rs rename to src/test/ui/proc-macro/subspan.rs index 437123ca4795e..dccf6e20448a6 100644 --- a/src/test/ui-fulldeps/subspan.rs +++ b/src/test/ui/proc-macro/subspan.rs @@ -9,7 +9,6 @@ // except according to those terms. // aux-build:subspan.rs -// ignore-stage1 extern crate subspan; diff --git a/src/test/ui-fulldeps/subspan.stderr b/src/test/ui/proc-macro/subspan.stderr similarity index 85% rename from src/test/ui-fulldeps/subspan.stderr rename to src/test/ui/proc-macro/subspan.stderr index 4d3928cae723a..d9339bdaf7632 100644 --- a/src/test/ui-fulldeps/subspan.stderr +++ b/src/test/ui/proc-macro/subspan.stderr @@ -1,95 +1,95 @@ error: found 'hi's - --> $DIR/subspan.rs:22:1 + --> $DIR/subspan.rs:21:1 | LL | subspan!("hi"); //~ ERROR found 'hi's | ^^^^^^^^^^^^^^^ | note: here - --> $DIR/subspan.rs:22:11 + --> $DIR/subspan.rs:21:11 | LL | subspan!("hi"); //~ ERROR found 'hi's | ^^ error: found 'hi's - --> $DIR/subspan.rs:25:1 + --> $DIR/subspan.rs:24:1 | LL | subspan!("hihi"); //~ ERROR found 'hi's | ^^^^^^^^^^^^^^^^^ | note: here - --> $DIR/subspan.rs:25:11 + --> $DIR/subspan.rs:24:11 | LL | subspan!("hihi"); //~ ERROR found 'hi's | ^^^^ error: found 'hi's - --> $DIR/subspan.rs:28:1 + --> $DIR/subspan.rs:27:1 | LL | subspan!("hihihi"); //~ ERROR found 'hi's | ^^^^^^^^^^^^^^^^^^^ | note: here - --> $DIR/subspan.rs:28:11 + --> $DIR/subspan.rs:27:11 | LL | subspan!("hihihi"); //~ ERROR found 'hi's | ^^^^^^ error: found 'hi's - --> $DIR/subspan.rs:31:1 + --> $DIR/subspan.rs:30:1 | LL | subspan!("why I hide? hi!"); //~ ERROR found 'hi's | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: here - --> $DIR/subspan.rs:31:17 + --> $DIR/subspan.rs:30:17 | LL | subspan!("why I hide? hi!"); //~ ERROR found 'hi's | ^^ ^^ error: found 'hi's - --> $DIR/subspan.rs:32:1 + --> $DIR/subspan.rs:31:1 | LL | subspan!("hey, hi, hidy, hidy, hi hi"); //~ ERROR found 'hi's | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: here - --> $DIR/subspan.rs:32:16 + --> $DIR/subspan.rs:31:16 | LL | subspan!("hey, hi, hidy, hidy, hi hi"); //~ ERROR found 'hi's | ^^ ^^ ^^ ^^ ^^ error: found 'hi's - --> $DIR/subspan.rs:33:1 + --> $DIR/subspan.rs:32:1 | LL | subspan!("this is a hi, and this is another hi"); //~ ERROR found 'hi's | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: here - --> $DIR/subspan.rs:33:12 + --> $DIR/subspan.rs:32:12 | LL | subspan!("this is a hi, and this is another hi"); //~ ERROR found 'hi's | ^^ ^^ ^^ ^^ error: found 'hi's - --> $DIR/subspan.rs:34:1 + --> $DIR/subspan.rs:33:1 | LL | subspan!("how are you this evening"); //~ ERROR found 'hi's | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: here - --> $DIR/subspan.rs:34:24 + --> $DIR/subspan.rs:33:24 | LL | subspan!("how are you this evening"); //~ ERROR found 'hi's | ^^ error: found 'hi's - --> $DIR/subspan.rs:35:1 + --> $DIR/subspan.rs:34:1 | LL | subspan!("this is highly eradic"); //~ ERROR found 'hi's | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: here - --> $DIR/subspan.rs:35:12 + --> $DIR/subspan.rs:34:12 | LL | subspan!("this is highly eradic"); //~ ERROR found 'hi's | ^^ ^^ diff --git a/src/test/ui-fulldeps/proc-macro/three-equals.rs b/src/test/ui/proc-macro/three-equals.rs similarity index 98% rename from src/test/ui-fulldeps/proc-macro/three-equals.rs rename to src/test/ui/proc-macro/three-equals.rs index dd81b1017ebc3..e3285d3e821f0 100644 --- a/src/test/ui-fulldeps/proc-macro/three-equals.rs +++ b/src/test/ui/proc-macro/three-equals.rs @@ -9,7 +9,7 @@ // except according to those terms. // aux-build:three-equals.rs -// ignore-stage1 + #![feature(proc_macro_hygiene)] diff --git a/src/test/ui-fulldeps/proc-macro/three-equals.stderr b/src/test/ui/proc-macro/three-equals.stderr similarity index 100% rename from src/test/ui-fulldeps/proc-macro/three-equals.stderr rename to src/test/ui/proc-macro/three-equals.stderr diff --git a/src/test/ui-fulldeps/rust-2018/auxiliary/suggestions-not-always-applicable.rs b/src/test/ui/rust-2018/auxiliary/suggestions-not-always-applicable.rs similarity index 98% rename from src/test/ui-fulldeps/rust-2018/auxiliary/suggestions-not-always-applicable.rs rename to src/test/ui/rust-2018/auxiliary/suggestions-not-always-applicable.rs index 7ae4731fde196..b8a05e89a664a 100644 --- a/src/test/ui-fulldeps/rust-2018/auxiliary/suggestions-not-always-applicable.rs +++ b/src/test/ui/rust-2018/auxiliary/suggestions-not-always-applicable.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// force-host // no-prefer-dynamic #![crate_type = "proc-macro"] diff --git a/src/test/ui-fulldeps/rust-2018/proc-macro-crate-in-paths.rs b/src/test/ui/rust-2018/proc-macro-crate-in-paths.rs similarity index 95% rename from src/test/ui-fulldeps/rust-2018/proc-macro-crate-in-paths.rs rename to src/test/ui/rust-2018/proc-macro-crate-in-paths.rs index 1068c05874589..51314abaad222 100644 --- a/src/test/ui-fulldeps/rust-2018/proc-macro-crate-in-paths.rs +++ b/src/test/ui/rust-2018/proc-macro-crate-in-paths.rs @@ -9,6 +9,8 @@ // except according to those terms. // compile-pass +// force-host +// no-prefer-dynamic #![crate_type = "proc-macro"] #![deny(rust_2018_compatibility)] diff --git a/src/test/ui-fulldeps/rust-2018/suggestions-not-always-applicable.fixed b/src/test/ui/rust-2018/suggestions-not-always-applicable.fixed similarity index 100% rename from src/test/ui-fulldeps/rust-2018/suggestions-not-always-applicable.fixed rename to src/test/ui/rust-2018/suggestions-not-always-applicable.fixed diff --git a/src/test/ui-fulldeps/rust-2018/suggestions-not-always-applicable.rs b/src/test/ui/rust-2018/suggestions-not-always-applicable.rs similarity index 100% rename from src/test/ui-fulldeps/rust-2018/suggestions-not-always-applicable.rs rename to src/test/ui/rust-2018/suggestions-not-always-applicable.rs diff --git a/src/test/ui-fulldeps/rust-2018/suggestions-not-always-applicable.stderr b/src/test/ui/rust-2018/suggestions-not-always-applicable.stderr similarity index 100% rename from src/test/ui-fulldeps/rust-2018/suggestions-not-always-applicable.stderr rename to src/test/ui/rust-2018/suggestions-not-always-applicable.stderr diff --git a/src/test/ui-fulldeps/unnecessary-extern-crate.rs b/src/test/ui/unnecessary-extern-crate.rs similarity index 67% rename from src/test/ui-fulldeps/unnecessary-extern-crate.rs rename to src/test/ui/unnecessary-extern-crate.rs index 1cdc9229d078c..110cfefcd92e5 100644 --- a/src/test/ui-fulldeps/unnecessary-extern-crate.rs +++ b/src/test/ui/unnecessary-extern-crate.rs @@ -13,10 +13,10 @@ #![deny(unused_extern_crates)] #![feature(alloc, test, libc, crate_visibility_modifier)] -extern crate alloc; +extern crate libc; //~^ ERROR unused extern crate //~| HELP remove -extern crate alloc as x; +extern crate libc as x; //~^ ERROR unused extern crate //~| HELP remove @@ -27,22 +27,22 @@ extern crate test; pub extern crate test as y; -pub extern crate libc; +pub extern crate alloc; -pub(crate) extern crate libc as a; +pub(crate) extern crate alloc as a; -crate extern crate libc as b; +crate extern crate alloc as b; mod foo { - pub(in crate::foo) extern crate libc as c; + pub(in crate::foo) extern crate alloc as c; - pub(super) extern crate libc as d; + pub(super) extern crate alloc as d; - extern crate alloc; + extern crate libc; //~^ ERROR unused extern crate //~| HELP remove - extern crate alloc as x; + extern crate libc as x; //~^ ERROR unused extern crate //~| HELP remove @@ -51,35 +51,31 @@ mod foo { pub extern crate test as y; mod bar { - extern crate alloc; + extern crate libc; //~^ ERROR unused extern crate //~| HELP remove - extern crate alloc as x; + extern crate libc as x; //~^ ERROR unused extern crate //~| HELP remove - pub(in crate::foo::bar) extern crate libc as e; + pub(in crate::foo::bar) extern crate alloc as e; fn dummy() { - unsafe { - e::getpid(); - } + e::string::String::new(); } } fn dummy() { - unsafe { - c::getpid(); - d::getpid(); - } + c::string::String::new(); + d::string::String::new(); } } fn main() { - unsafe { a::getpid(); } - unsafe { b::getpid(); } + a::string::String::new(); + b::string::String::new(); proc_macro::TokenStream::new(); } diff --git a/src/test/ui-fulldeps/unnecessary-extern-crate.stderr b/src/test/ui/unnecessary-extern-crate.stderr similarity index 58% rename from src/test/ui-fulldeps/unnecessary-extern-crate.stderr rename to src/test/ui/unnecessary-extern-crate.stderr index 58ec5901585d4..1315bff791deb 100644 --- a/src/test/ui-fulldeps/unnecessary-extern-crate.stderr +++ b/src/test/ui/unnecessary-extern-crate.stderr @@ -1,8 +1,8 @@ error: unused extern crate --> $DIR/unnecessary-extern-crate.rs:16:1 | -LL | extern crate alloc; - | ^^^^^^^^^^^^^^^^^^^ help: remove it +LL | extern crate libc; + | ^^^^^^^^^^^^^^^^^^ help: remove it | note: lint level defined here --> $DIR/unnecessary-extern-crate.rs:13:9 @@ -13,32 +13,32 @@ LL | #![deny(unused_extern_crates)] error: unused extern crate --> $DIR/unnecessary-extern-crate.rs:19:1 | -LL | extern crate alloc as x; - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it +LL | extern crate libc as x; + | ^^^^^^^^^^^^^^^^^^^^^^^ help: remove it error: unused extern crate --> $DIR/unnecessary-extern-crate.rs:41:5 | -LL | extern crate alloc; - | ^^^^^^^^^^^^^^^^^^^ help: remove it +LL | extern crate libc; + | ^^^^^^^^^^^^^^^^^^ help: remove it error: unused extern crate --> $DIR/unnecessary-extern-crate.rs:45:5 | -LL | extern crate alloc as x; - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it +LL | extern crate libc as x; + | ^^^^^^^^^^^^^^^^^^^^^^^ help: remove it error: unused extern crate --> $DIR/unnecessary-extern-crate.rs:54:9 | -LL | extern crate alloc; - | ^^^^^^^^^^^^^^^^^^^ help: remove it +LL | extern crate libc; + | ^^^^^^^^^^^^^^^^^^ help: remove it error: unused extern crate --> $DIR/unnecessary-extern-crate.rs:58:9 | -LL | extern crate alloc as x; - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it +LL | extern crate libc as x; + | ^^^^^^^^^^^^^^^^^^^^^^^ help: remove it error: aborting due to 6 previous errors diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 399f9f577edf5..b650e056eb774 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1829,10 +1829,10 @@ impl<'test> TestCx<'test> { rustc.args(self.split_maybe_args(&self.config.host_rustcflags)); } else { rustc.args(self.split_maybe_args(&self.config.target_rustcflags)); - } - if !is_rustdoc { - if let Some(ref linker) = self.config.linker { - rustc.arg(format!("-Clinker={}", linker)); + if !is_rustdoc { + if let Some(ref linker) = self.config.linker { + rustc.arg(format!("-Clinker={}", linker)); + } } }