Skip to content
This repository has been archived by the owner on May 12, 2022. It is now read-only.

Commit

Permalink
refactor: stop using proc-macro-hack
Browse files Browse the repository at this point in the history
Fn-like procedural macros in expression positions were stabilized in
<rust-lang/rust#68717>.
  • Loading branch information
yvt committed May 30, 2020
1 parent 2b56952 commit 14f3588
Show file tree
Hide file tree
Showing 12 changed files with 8 additions and 28 deletions.
4 changes: 0 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion stvg/macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ edition = "2018"
license = "MIT"

[dependencies]
proc-macro-hack = "0.5.11"
stvg_macro_impl = { path = "./impl" }
stvg_io = { path = "../io" }
1 change: 0 additions & 1 deletion stvg/macro/impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ authors = ["yvt <i@yvt.jp>"]
edition = "2018"

[dependencies]
proc-macro-hack = "0.5.11"
stvg_io = { path = "../../io" }
usvg = { version = "0.9.0", default-features = false }
syn = "1"
Expand Down
2 changes: 1 addition & 1 deletion stvg/macro/impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::path::Path;
use stvg_io::CmdEncoder;
use syn::{parse_macro_input, spanned::Spanned, Lit, LitByteStr};

#[proc_macro_hack::proc_macro_hack]
#[proc_macro]
pub fn include_stvg(params: proc_macro::TokenStream) -> proc_macro::TokenStream {
let path_lit: Lit = parse_macro_input!(params);

Expand Down
5 changes: 0 additions & 5 deletions stvg/macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,10 @@
//! println!("size = {:?}", TIGER.1);
//! ```

// `#[proc_macro_hack]` makes it possible to use this procedural macro in
// expression position without relying on an unstable rustc feature, but with
// some restrictions. See `proc_macro_hack`'s documentation for more.

/// Include the specified SVG file as StellaVG data (`([u8; _], [f32; 2])`).
///
/// The path is relative to `$CARGO_MANIFEST_DIR`.
///
/// Be aware that the range of coordinates are limited by the internal
/// representation used by StellaVG. See [`stvg_io::FRAC_BITS`].
#[proc_macro_hack::proc_macro_hack]
pub use stvg_macro_impl::include_stvg;
1 change: 0 additions & 1 deletion tcw3/pal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ neo_linked_list = { path = "../../support/neo_linked_list" }
once_cell = "1.2.0"
owning_ref = "0.4.0"
packed_simd = "0.3.0"
proc-macro-hack = "0.5.11"
rgb = "0.8.13"
svgbobdoc = "0.2"
try_match = "0.2.1"
Expand Down
1 change: 0 additions & 1 deletion tcw3/pal/macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ gtk = []
bitflags = "1.1.0"
enum-utils = "0.1.2"
proc-macro-error = "1"
proc-macro-hack = "0.5.11"
proc-macro2 = "1"
quote = "1"
syn = { version = "1", features = ["full"] }
Expand Down
2 changes: 1 addition & 1 deletion tcw3/pal/macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ extern crate proc_macro;
mod accel;
mod keycode;

#[proc_macro_hack::proc_macro_hack]
#[proc_macro]
#[proc_macro_error::proc_macro_error]
pub fn accel_table_inner(params: proc_macro::TokenStream) -> proc_macro::TokenStream {
accel::accel_table_inner(params)
Expand Down
2 changes: 1 addition & 1 deletion tcw3/pal/src/gtk/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,7 @@ impl AccelTable {
}
}

static TEXT_INPUT_ACCEL: AccelTable = accel_table_inner!(
static TEXT_INPUT_ACCEL: AccelTable = tcw3_pal_macro::accel_table_inner!(
crate,
"gtk",
[
Expand Down
13 changes: 3 additions & 10 deletions tcw3/pal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,6 @@ pub mod prelude {
mod cells;
pub use self::cells::{MtLock, MtSticky};

// This procedural macro can be used by backend implementations, so must
// precede `mod macos`, etc.
//
// `#[proc_macro_hack]` makes it possible to use this procedural macro in
// expression position without relying on an unstable rustc feature, but with
// some restrictions. See `proc_macro_hack`'s documentation for more.
#[doc(hidden)]
#[proc_macro_hack::proc_macro_hack]
pub use tcw3_pal_macro::accel_table_inner;

// ============================================================================
//
// The main module for each target platform. The active one for the current
Expand Down Expand Up @@ -107,6 +97,9 @@ pub use self::native as current;
// Define `accel_table`. This is trickier than other items because macros
// only have crate-level namespaces.

#[doc(hidden)]
pub use tcw3_pal_macro::accel_table_inner;

// The implementation of `native_accel_table` is chosen based on the target
// backend.
#[doc(hidden)]
Expand Down
2 changes: 1 addition & 1 deletion tcw3/pal/src/macos/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ unsafe extern "C" fn tcw_wndlistener_perform_selector(
});
}

static TEXT_INPUT_ACCEL: AccelTable = accel_table_inner!(
static TEXT_INPUT_ACCEL: AccelTable = tcw3_pal_macro::accel_table_inner!(
crate,
"macos",
[
Expand Down
2 changes: 1 addition & 1 deletion tcw3/pal/src/windows/acceltable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl AccelTable {
}
}

pub(super) static TEXT_INPUT_ACCEL: AccelTable = accel_table_inner!(
pub(super) static TEXT_INPUT_ACCEL: AccelTable = tcw3_pal_macro::accel_table_inner!(
crate,
"windows",
[
Expand Down

0 comments on commit 14f3588

Please sign in to comment.