rust/proc-macro2/lib.rs
Source file repositories/reference/linux-study-clean/rust/proc-macro2/lib.rs
File Facts
- System
- Linux kernel
- Corpus path
rust/proc-macro2/lib.rs- Extension
.rs- Size
- 45422 bytes
- Lines
- 1356
- Domain
- Rust Kernel Layer
- Bucket
- Rust API Membrane
- Inferred role
- Rust Kernel Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
Rust-side wrappers and abstractions around kernel C APIs, ownership contracts, allocation, synchronization, and module integration.
- Rust-side wrappers and abstractions around kernel C APIs, ownership contracts, allocation, synchronization, and module integration.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
function from_strfunction local_filefunction _newfunction as_charfunction newfunction eqfunction stringfunction from_strfunction next
Annotated Snippet
pub fn set_span(&mut self, span: Span) {
match self {
TokenTree::Group(t) => t.set_span(span),
TokenTree::Ident(t) => t.set_span(span),
TokenTree::Punct(t) => t.set_span(span),
TokenTree::Literal(t) => t.set_span(span),
}
}
}
impl From<Group> for TokenTree {
fn from(g: Group) -> Self {
TokenTree::Group(g)
}
}
impl From<Ident> for TokenTree {
fn from(g: Ident) -> Self {
TokenTree::Ident(g)
}
}
impl From<Punct> for TokenTree {
fn from(g: Punct) -> Self {
TokenTree::Punct(g)
}
}
impl From<Literal> for TokenTree {
fn from(g: Literal) -> Self {
TokenTree::Literal(g)
}
}
/// 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.
impl Display for TokenTree {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
TokenTree::Group(t) => Display::fmt(t, f),
TokenTree::Ident(t) => Display::fmt(t, f),
TokenTree::Punct(t) => Display::fmt(t, f),
TokenTree::Literal(t) => Display::fmt(t, f),
}
}
}
/// Prints token tree in a form convenient for debugging.
impl Debug for TokenTree {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
// Each of these has the name in the struct type in the derived debug,
// so don't bother with an extra layer of indirection
match self {
TokenTree::Group(t) => Debug::fmt(t, f),
TokenTree::Ident(t) => {
let mut debug = f.debug_struct("Ident");
debug.field("sym", &format_args!("{}", t));
imp::debug_span_field_if_nontrivial(&mut debug, t.span().inner);
debug.finish()
}
TokenTree::Punct(t) => Debug::fmt(t, f),
TokenTree::Literal(t) => Debug::fmt(t, f),
}
}
}
/// A delimited token stream.
///
/// A `Group` internally contains a `TokenStream` which is surrounded by
/// `Delimiter`s.
#[derive(Clone)]
pub struct Group {
inner: imp::Group,
}
/// Describes how a sequence of token trees is delimited.
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum Delimiter {
/// `( ... )`
Parenthesis,
/// `{ ... }`
Brace,
/// `[ ... ]`
Bracket,
/// `∅ ... ∅`
///
/// An invisible delimiter, that may, for example, appear around tokens
/// coming from a "macro variable" `$var`. It is important to preserve
Annotation
- Detected declarations: `function from_str`, `function local_file`, `function _new`, `function as_char`, `function new`, `function eq`, `function string`, `function from_str`, `function next`.
- Atlas domain: Rust Kernel Layer / Rust API Membrane.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.