rust/syn/path.rs
Source file repositories/reference/linux-study-clean/rust/syn/path.rs
File Facts
- System
- Linux kernel
- Corpus path
rust/syn/path.rs- Extension
.rs- Size
- 33539 bytes
- Lines
- 969
- 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 Somefunction parsefunction Okfunction Okfunction Okfunction pubfunction pubfunction to_tokensfunction print_path_segmentfunction to_tokensfunction print_path_argumentsfunction to_tokensfunction to_tokensfunction pubfunction to_tokensfunction to_tokensfunction to_tokensfunction to_tokensfunction print_parenthesized_generic_argumentsfunction pubfunction conditionally_print_turbofishfunction to_tokens
Annotated Snippet
fn to_tokens(&self, tokens: &mut TokenStream) {
print_path(tokens, self, PathStyle::AsWritten);
}
}
pub(crate) fn print_path(tokens: &mut TokenStream, path: &Path, style: PathStyle) {
path.leading_colon.to_tokens(tokens);
for segment in path.segments.pairs() {
print_path_segment(tokens, segment.value(), style);
segment.punct().to_tokens(tokens);
}
}
#[cfg_attr(docsrs, doc(cfg(feature = "printing")))]
impl ToTokens for PathSegment {
fn to_tokens(&self, tokens: &mut TokenStream) {
print_path_segment(tokens, self, PathStyle::AsWritten);
}
}
fn print_path_segment(tokens: &mut TokenStream, segment: &PathSegment, style: PathStyle) {
segment.ident.to_tokens(tokens);
print_path_arguments(tokens, &segment.arguments, style);
}
#[cfg_attr(docsrs, doc(cfg(feature = "printing")))]
impl ToTokens for PathArguments {
fn to_tokens(&self, tokens: &mut TokenStream) {
print_path_arguments(tokens, self, PathStyle::AsWritten);
}
}
fn print_path_arguments(tokens: &mut TokenStream, arguments: &PathArguments, style: PathStyle) {
match arguments {
PathArguments::None => {}
PathArguments::AngleBracketed(arguments) => {
print_angle_bracketed_generic_arguments(tokens, arguments, style);
}
PathArguments::Parenthesized(arguments) => {
print_parenthesized_generic_arguments(tokens, arguments, style);
}
}
}
#[cfg_attr(docsrs, doc(cfg(feature = "printing")))]
impl ToTokens for GenericArgument {
#[allow(clippy::match_same_arms)]
fn to_tokens(&self, tokens: &mut TokenStream) {
match self {
GenericArgument::Lifetime(lt) => lt.to_tokens(tokens),
GenericArgument::Type(ty) => ty.to_tokens(tokens),
GenericArgument::Const(expr) => {
generics::printing::print_const_argument(expr, tokens);
}
GenericArgument::AssocType(assoc) => assoc.to_tokens(tokens),
GenericArgument::AssocConst(assoc) => assoc.to_tokens(tokens),
GenericArgument::Constraint(constraint) => constraint.to_tokens(tokens),
}
}
}
#[cfg_attr(docsrs, doc(cfg(feature = "printing")))]
impl ToTokens for AngleBracketedGenericArguments {
fn to_tokens(&self, tokens: &mut TokenStream) {
print_angle_bracketed_generic_arguments(tokens, self, PathStyle::AsWritten);
}
}
pub(crate) fn print_angle_bracketed_generic_arguments(
tokens: &mut TokenStream,
arguments: &AngleBracketedGenericArguments,
style: PathStyle,
) {
if let PathStyle::Mod = style {
return;
}
conditionally_print_turbofish(tokens, &arguments.colon2_token, style);
arguments.lt_token.to_tokens(tokens);
// Print lifetimes before types/consts/bindings, regardless of their
// order in args.
let mut trailing_or_empty = true;
for param in arguments.args.pairs() {
match param.value() {
GenericArgument::Lifetime(_) => {
param.to_tokens(tokens);
trailing_or_empty = param.punct().is_some();
}
GenericArgument::Type(_)
Annotation
- Detected declarations: `function Some`, `function parse`, `function Ok`, `function Ok`, `function Ok`, `function pub`, `function pub`, `function to_tokens`, `function print_path_segment`, `function to_tokens`.
- 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.