rust/syn/item.rs
Source file repositories/reference/linux-study-clean/rust/syn/item.rs
File Facts
- System
- Linux kernel
- Corpus path
rust/syn/item.rs- Extension
.rs- Size
- 121565 bytes
- Lines
- 3493
- 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
struct FlexibleItemTypeenum TypeDefaultnessenum WhereClauseLocationenum FnArgOrVariadicfunction Okfunction Errfunction parse_item_usefunction Okfunction Somefunction Somefunction Somefunction parse_macro2function Okfunction Okfunction Okfunction parse_use_treefunction Okfunction Okfunction Somefunction Somefunction Okfunction Okfunction Okfunction parse_rest_of_traitfunction Errfunction matchfunction letfunction Somefunction parse_impl_item_typefunction 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_tokensfunction to_tokensfunction to_tokensfunction to_tokensfunction to_tokensfunction to_tokensfunction to_tokens
Annotated Snippet
struct FlexibleItemType {
vis: Visibility,
defaultness: Option<Token![default]>,
type_token: Token![type],
ident: Ident,
generics: Generics,
colon_token: Option<Token![:]>,
bounds: Punctuated<TypeParamBound, Token![+]>,
ty: Option<(Token![=], Type)>,
semi_token: Token![;],
}
enum TypeDefaultness {
Optional,
Disallowed,
}
enum WhereClauseLocation {
// type Ty<T> where T: 'static = T;
BeforeEq,
// type Ty<T> = T where T: 'static;
AfterEq,
// TODO: goes away once the migration period on rust-lang/rust#89122 is over
Both,
}
impl FlexibleItemType {
fn parse(
input: ParseStream,
allow_defaultness: TypeDefaultness,
where_clause_location: WhereClauseLocation,
) -> Result<Self> {
let vis: Visibility = input.parse()?;
let defaultness: Option<Token![default]> = match allow_defaultness {
TypeDefaultness::Optional => input.parse()?,
TypeDefaultness::Disallowed => None,
};
let type_token: Token![type] = input.parse()?;
let ident: Ident = input.parse()?;
let mut generics: Generics = input.parse()?;
let (colon_token, bounds) = Self::parse_optional_bounds(input)?;
match where_clause_location {
WhereClauseLocation::BeforeEq | WhereClauseLocation::Both => {
generics.where_clause = input.parse()?;
}
WhereClauseLocation::AfterEq => {}
}
let ty = Self::parse_optional_definition(input)?;
match where_clause_location {
WhereClauseLocation::AfterEq | WhereClauseLocation::Both
if generics.where_clause.is_none() =>
{
generics.where_clause = input.parse()?;
}
_ => {}
}
let semi_token: Token![;] = input.parse()?;
Ok(FlexibleItemType {
vis,
defaultness,
type_token,
ident,
generics,
colon_token,
bounds,
ty,
semi_token,
})
}
fn parse_optional_bounds(
input: ParseStream,
) -> Result<(Option<Token![:]>, Punctuated<TypeParamBound, Token![+]>)> {
let colon_token: Option<Token![:]> = input.parse()?;
let mut bounds = Punctuated::new();
if colon_token.is_some() {
loop {
if input.peek(Token![where]) || input.peek(Token![=]) || input.peek(Token![;]) {
break;
}
bounds.push_value({
let allow_precise_capture = false;
let allow_const = true;
TypeParamBound::parse_single(input, allow_precise_capture, allow_const)?
Annotation
- Detected declarations: `struct FlexibleItemType`, `enum TypeDefaultness`, `enum WhereClauseLocation`, `enum FnArgOrVariadic`, `function Ok`, `function Err`, `function parse_item_use`, `function Ok`, `function Some`, `function Some`.
- 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.