Skip to content

Commit

Permalink
rust: macros: remove helpers
Browse files Browse the repository at this point in the history
Only one helper function (`expect_punct`) is used by our proc-macros. So
remove all others and move `expect_punct` into concat_idents.rs.

Signed-off-by: Benno Lossin <[email protected]>
  • Loading branch information
y86-dev committed Apr 9, 2024
1 parent 3f5282d commit 4777db0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 221 deletions.
9 changes: 7 additions & 2 deletions rust/macros/concat_idents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@

use proc_macro2::{token_stream, Ident, TokenStream, TokenTree};

use crate::helpers::expect_punct;

fn expect_ident(it: &mut token_stream::IntoIter) -> Ident {
if let Some(TokenTree::Ident(ident)) = it.next() {
ident
} else {
panic!("Expected Ident")
}
}
fn expect_punct(it: &mut token_stream::IntoIter) -> char {
if let TokenTree::Punct(punct) = it.next().expect("Reached end of token stream for Punct") {
punct.as_char()
} else {
panic!("Expected Punct");
}
}

pub(crate) fn concat_idents(ts: TokenStream) -> TokenStream {
let mut it = ts.into_iter();
Expand Down
218 changes: 0 additions & 218 deletions rust/macros/helpers.rs

This file was deleted.

1 change: 0 additions & 1 deletion rust/macros/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
//! Crate for all kernel procedural macros.
mod concat_idents;
mod helpers;
mod module;
mod paste;
mod pin_data;
Expand Down

0 comments on commit 4777db0

Please sign in to comment.