rust/syn/pat.rs
Source file repositories/reference/linux-study-clean/rust/syn/pat.rs
File Facts
- System
- Linux kernel
- Corpus path
rust/syn/pat.rs- Extension
.rs- Size
- 32051 bytes
- Lines
- 958
- 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
enum PatRangeBoundfunction pat_path_or_macro_or_struct_or_rangefunction pat_structfunction Okfunction letfunction letfunction 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
if let (RangeLimits::Closed(_), None) = (&limits, &end) {
return Err(input.error("expected range upper bound"));
}
Ok(Pat::Range(ExprRange {
attrs: Vec::new(),
start: Some(Box::new(Expr::Path(ExprPath {
attrs: Vec::new(),
qself,
path,
}))),
limits,
end: end.map(PatRangeBound::into_expr),
}))
}
fn pat_range_half_open(input: ParseStream) -> Result<Pat> {
let limits: RangeLimits = input.parse()?;
let end = input.call(pat_range_bound)?;
if end.is_some() {
Ok(Pat::Range(ExprRange {
attrs: Vec::new(),
start: None,
limits,
end: end.map(PatRangeBound::into_expr),
}))
} else {
match limits {
RangeLimits::HalfOpen(dot2_token) => Ok(Pat::Rest(PatRest {
attrs: Vec::new(),
dot2_token,
})),
RangeLimits::Closed(_) => Err(input.error("expected range upper bound")),
}
}
}
fn pat_paren_or_tuple(input: ParseStream) -> Result<Pat> {
let content;
let paren_token = parenthesized!(content in input);
let mut elems = Punctuated::new();
while !content.is_empty() {
let value = Pat::parse_multi_with_leading_vert(&content)?;
if content.is_empty() {
if elems.is_empty() && !matches!(value, Pat::Rest(_)) {
return Ok(Pat::Paren(PatParen {
attrs: Vec::new(),
paren_token,
pat: Box::new(value),
}));
}
elems.push_value(value);
break;
}
elems.push_value(value);
let punct = content.parse()?;
elems.push_punct(punct);
}
Ok(Pat::Tuple(PatTuple {
attrs: Vec::new(),
paren_token,
elems,
}))
}
fn pat_reference(input: ParseStream) -> Result<PatReference> {
Ok(PatReference {
attrs: Vec::new(),
and_token: input.parse()?,
mutability: input.parse()?,
pat: Box::new(Pat::parse_single(input)?),
})
}
fn pat_lit_or_range(input: ParseStream) -> Result<Pat> {
let start = input.call(pat_range_bound)?.unwrap();
if input.peek(Token![..]) {
let limits = RangeLimits::parse_obsolete(input)?;
let end = input.call(pat_range_bound)?;
if let (RangeLimits::Closed(_), None) = (&limits, &end) {
return Err(input.error("expected range upper bound"));
}
Ok(Pat::Range(ExprRange {
attrs: Vec::new(),
start: Some(start.into_expr()),
limits,
end: end.map(PatRangeBound::into_expr),
}))
} else {
Annotation
- Detected declarations: `enum PatRangeBound`, `function pat_path_or_macro_or_struct_or_range`, `function pat_struct`, `function Ok`, `function let`, `function let`, `function to_tokens`, `function to_tokens`, `function to_tokens`, `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.