Skip to content

Commit b19469b

Browse files
committed
internal: remove proc-macro[2] and quote workarounds
The kernel only had the `proc-macro` library available, whereas the user-space version also used `proc-macro2` and `quote`. Now both are available to the kernel, making it possible to remove the workarounds. Signed-off-by: Benno Lossin <lossin@kernel.org>
1 parent c894a58 commit b19469b

File tree

5 files changed

+7
-32
lines changed

5 files changed

+7
-32
lines changed

internal/src/helpers.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
// SPDX-License-Identifier: Apache-2.0 OR MIT
22

3-
#[cfg(not(kernel))]
4-
use proc_macro2 as proc_macro;
5-
6-
use proc_macro::{TokenStream, TokenTree};
3+
use proc_macro2::{TokenStream, TokenTree};
74

85
/// Parsed generics.
96
///

internal/src/lib.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,11 @@
77
//! `pin-init` proc macros.
88
99
#![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))]
10-
// Allow `.into()` to convert
11-
// - `proc_macro2::TokenStream` into `proc_macro::TokenStream` in the user-space version.
12-
// - `proc_macro::TokenStream` into `proc_macro::TokenStream` in the kernel version.
13-
// Clippy warns on this conversion, but it's required by the user-space version.
14-
//
15-
// Remove once we have `proc_macro2` in the kernel.
16-
#![allow(clippy::useless_conversion)]
1710
// Documentation is done in the pin-init crate instead.
1811
#![allow(missing_docs)]
1912

2013
use proc_macro::TokenStream;
2114

22-
#[cfg(kernel)]
23-
#[path = "../../../macros/quote.rs"]
24-
#[macro_use]
25-
#[cfg_attr(not(kernel), rustfmt::skip)]
26-
mod quote;
27-
#[cfg(not(kernel))]
28-
#[macro_use]
29-
extern crate quote;
30-
3115
mod helpers;
3216
mod pin_data;
3317
mod pinned_drop;

internal/src/pin_data.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
// SPDX-License-Identifier: Apache-2.0 OR MIT
22

3-
#[cfg(not(kernel))]
4-
use proc_macro2 as proc_macro;
5-
63
use crate::helpers::{parse_generics, Generics};
7-
use proc_macro::{Group, Punct, Spacing, TokenStream, TokenTree};
4+
use proc_macro2::{Group, Punct, Spacing, TokenStream, TokenTree};
5+
use quote::quote;
86

97
pub(crate) fn pin_data(args: TokenStream, input: TokenStream) -> TokenStream {
108
// This proc-macro only does some pre-parsing and then delegates the actual parsing to

internal/src/pinned_drop.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
// SPDX-License-Identifier: Apache-2.0 OR MIT
22

3-
#[cfg(not(kernel))]
4-
use proc_macro2 as proc_macro;
5-
6-
use proc_macro::{TokenStream, TokenTree};
3+
use proc_macro2::{TokenStream, TokenTree};
4+
use quote::quote;
75

86
pub(crate) fn pinned_drop(_args: TokenStream, input: TokenStream) -> TokenStream {
97
let mut toks = input.into_iter().collect::<Vec<_>>();

internal/src/zeroable.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
// SPDX-License-Identifier: GPL-2.0
22

3-
#[cfg(not(kernel))]
4-
use proc_macro2 as proc_macro;
5-
63
use crate::helpers::{parse_generics, Generics};
7-
use proc_macro::{TokenStream, TokenTree};
4+
use proc_macro2::{TokenStream, TokenTree};
5+
use quote::quote;
86

97
pub(crate) fn parse_zeroable_derive_input(
108
input: TokenStream,

0 commit comments

Comments
 (0)