rust/syn/ty.rs
Source file repositories/reference/linux-study-clean/rust/syn/ty.rs
File Facts
- System
- Linux kernel
- Corpus path
rust/syn/ty.rs- Extension
.rs- Size
- 44783 bytes
- Lines
- 1274
- 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 Okfunction Okfunction Okfunction Okfunction Okfunction letfunction pubfunction Okfunction Somefunction to_tokensfunction to_tokensfunction to_tokensfunction to_tokensfunction to_tokensfunction Somefunction to_tokensfunction to_tokensfunction to_tokensfunction to_tokensfunction to_tokensfunction to_tokensfunction to_tokensfunction to_tokensfunction to_tokensfunction to_tokensfunction to_tokensfunction to_tokensfunction to_tokens
Annotated Snippet
Ok(if star_token.is_some() {
Type::Verbatim(verbatim::between(&begin, input))
} else {
Type::TraitObject(TypeTraitObject {
dyn_token: Some(dyn_token),
bounds,
})
})
} else if lookahead.peek(token::Bracket) {
let content;
let bracket_token = bracketed!(content in input);
let elem: Type = content.parse()?;
if content.peek(Token![;]) {
Ok(Type::Array(TypeArray {
bracket_token,
elem: Box::new(elem),
semi_token: content.parse()?,
len: content.parse()?,
}))
} else {
Ok(Type::Slice(TypeSlice {
bracket_token,
elem: Box::new(elem),
}))
}
} else if lookahead.peek(Token![*]) {
input.parse().map(Type::Ptr)
} else if lookahead.peek(Token![&]) {
input.parse().map(Type::Reference)
} else if lookahead.peek(Token![!]) && !input.peek(Token![=]) {
input.parse().map(Type::Never)
} else if lookahead.peek(Token![impl]) {
TypeImplTrait::parse(input, allow_plus).map(Type::ImplTrait)
} else if lookahead.peek(Token![_]) {
input.parse().map(Type::Infer)
} else if lookahead.peek(Lifetime) {
input.parse().map(Type::TraitObject)
} else {
Err(lookahead.error())
}
}
#[cfg_attr(docsrs, doc(cfg(feature = "parsing")))]
impl Parse for TypeSlice {
fn parse(input: ParseStream) -> Result<Self> {
let content;
Ok(TypeSlice {
bracket_token: bracketed!(content in input),
elem: content.parse()?,
})
}
}
#[cfg_attr(docsrs, doc(cfg(feature = "parsing")))]
impl Parse for TypeArray {
fn parse(input: ParseStream) -> Result<Self> {
let content;
Ok(TypeArray {
bracket_token: bracketed!(content in input),
elem: content.parse()?,
semi_token: content.parse()?,
len: content.parse()?,
})
}
}
#[cfg_attr(docsrs, doc(cfg(feature = "parsing")))]
impl Parse for TypePtr {
fn parse(input: ParseStream) -> Result<Self> {
let star_token: Token![*] = input.parse()?;
let lookahead = input.lookahead1();
let (const_token, mutability) = if lookahead.peek(Token![const]) {
(Some(input.parse()?), None)
} else if lookahead.peek(Token![mut]) {
(None, Some(input.parse()?))
} else {
return Err(lookahead.error());
};
Ok(TypePtr {
star_token,
const_token,
mutability,
elem: Box::new(input.call(Type::without_plus)?),
})
}
}
#[cfg_attr(docsrs, doc(cfg(feature = "parsing")))]
Annotation
- Detected declarations: `function Ok`, `function Ok`, `function Ok`, `function Ok`, `function Ok`, `function let`, `function pub`, `function Ok`, `function Some`, `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.