rust/syn/fixup.rs
Source file repositories/reference/linux-study-clean/rust/syn/fixup.rs
File Facts
- System
- Linux kernel
- Corpus path
rust/syn/fixup.rs- Extension
.rs- Size
- 27723 bytes
- Lines
- 776
- 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 Scanfunction new_stmtfunction leftmost_subexpression_with_dotfunction leftmost_subexpression_precedencefunction rightmost_subexpressionfunction scan_leftfunction clonefunction matchfunction Somefunction scan_rightfunction scan_rightfunction scan_right
Annotated Snippet
pub fn leftmost_subexpression_with_dot(self, expr: &Expr) -> (Precedence, Self) {
let fixup = FixupContext {
#[cfg(feature = "full")]
next_operator: Precedence::Unambiguous,
#[cfg(feature = "full")]
stmt: self.stmt || self.leftmost_subexpression_in_stmt,
#[cfg(feature = "full")]
leftmost_subexpression_in_stmt: false,
#[cfg(feature = "full")]
match_arm: self.match_arm || self.leftmost_subexpression_in_match_arm,
#[cfg(feature = "full")]
leftmost_subexpression_in_match_arm: false,
#[cfg(feature = "full")]
rightmost_subexpression_in_condition: false,
#[cfg(feature = "full")]
next_operator_can_begin_expr: false,
#[cfg(feature = "full")]
next_operator_can_continue_expr: true,
next_operator_can_begin_generics: false,
..self
};
(fixup.leftmost_subexpression_precedence(expr), fixup)
}
fn leftmost_subexpression_precedence(self, expr: &Expr) -> Precedence {
#[cfg(feature = "full")]
if !self.next_operator_can_begin_expr || self.next_operator == Precedence::Range {
if let Scan::Bailout = scan_right(expr, self, Precedence::MIN, 0, 0) {
if scan_left(expr, self) {
return Precedence::Unambiguous;
}
}
}
self.precedence(expr)
}
/// Transform this fixup into the one that should apply when printing the
/// rightmost subexpression of the current expression.
///
/// The rightmost subexpression is any subexpression that has a different
/// first token than the current expression, but has the same last token.
///
/// For example in `$a + $b` and `-$b`, the subexpression `$b` is a
/// rightmost subexpression.
///
/// Not every expression has a rightmost subexpression. For example neither
/// `[$b]` nor `$a.f($b)` have one.
pub fn rightmost_subexpression(
self,
expr: &Expr,
#[cfg(feature = "full")] precedence: Precedence,
) -> (Precedence, Self) {
let fixup = self.rightmost_subexpression_fixup(
#[cfg(feature = "full")]
false,
#[cfg(feature = "full")]
false,
#[cfg(feature = "full")]
precedence,
);
(fixup.rightmost_subexpression_precedence(expr), fixup)
}
pub fn rightmost_subexpression_fixup(
self,
#[cfg(feature = "full")] reset_allow_struct: bool,
#[cfg(feature = "full")] optional_operand: bool,
#[cfg(feature = "full")] precedence: Precedence,
) -> Self {
FixupContext {
#[cfg(feature = "full")]
previous_operator: precedence,
#[cfg(feature = "full")]
stmt: false,
#[cfg(feature = "full")]
leftmost_subexpression_in_stmt: false,
#[cfg(feature = "full")]
match_arm: false,
#[cfg(feature = "full")]
leftmost_subexpression_in_match_arm: false,
#[cfg(feature = "full")]
condition: self.condition && !reset_allow_struct,
#[cfg(feature = "full")]
leftmost_subexpression_in_optional_operand: self.condition && optional_operand,
..self
}
}
Annotation
- Detected declarations: `enum Scan`, `function new_stmt`, `function leftmost_subexpression_with_dot`, `function leftmost_subexpression_precedence`, `function rightmost_subexpression`, `function scan_left`, `function clone`, `function match`, `function Some`, `function scan_right`.
- 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.