rust/syn/parse.rs
Source file repositories/reference/linux-study-clean/rust/syn/parse.rs
File Facts
- System
- Linux kernel
- Corpus path
rust/syn/parse.rs- Extension
.rs- Size
- 47725 bytes
- Lines
- 1422
- 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 dropfunction inner_unexpectedfunction cell_clonefunction Somefunction cursorfunction Errfunction Somefunction Somefunction parsefunction clone
Annotated Snippet
fn drop(&mut self) {
if let Some((unexpected_span, delimiter)) = span_of_unexpected_ignoring_nones(self.cursor())
{
let (inner, old_span) = inner_unexpected(self);
if old_span.is_none() {
inner.set(Unexpected::Some(unexpected_span, delimiter));
}
}
}
}
impl<'a> Display for ParseBuffer<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
Display::fmt(&self.cursor().token_stream(), f)
}
}
impl<'a> Debug for ParseBuffer<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
Debug::fmt(&self.cursor().token_stream(), f)
}
}
impl<'a> UnwindSafe for ParseBuffer<'a> {}
impl<'a> RefUnwindSafe for ParseBuffer<'a> {}
/// Cursor state associated with speculative parsing.
///
/// This type is the input of the closure provided to [`ParseStream::step`].
///
/// [`ParseStream::step`]: ParseBuffer::step
///
/// # Example
///
/// ```
/// use proc_macro2::TokenTree;
/// use syn::Result;
/// use syn::parse::ParseStream;
///
/// // This function advances the stream past the next occurrence of `@`. If
/// // no `@` is present in the stream, the stream position is unchanged and
/// // an error is returned.
/// fn skip_past_next_at(input: ParseStream) -> Result<()> {
/// input.step(|cursor| {
/// let mut rest = *cursor;
/// while let Some((tt, next)) = rest.token_tree() {
/// match &tt {
/// TokenTree::Punct(punct) if punct.as_char() == '@' => {
/// return Ok(((), next));
/// }
/// _ => rest = next,
/// }
/// }
/// Err(cursor.error("no `@` was found after this point"))
/// })
/// }
/// #
/// # fn remainder_after_skipping_past_next_at(
/// # input: ParseStream,
/// # ) -> Result<proc_macro2::TokenStream> {
/// # skip_past_next_at(input)?;
/// # input.parse()
/// # }
/// #
/// # use syn::parse::Parser;
/// # let remainder = remainder_after_skipping_past_next_at
/// # .parse_str("a @ b c")
/// # .unwrap();
/// # assert_eq!(remainder.to_string(), "b c");
/// ```
pub struct StepCursor<'c, 'a> {
scope: Span,
// This field is covariant in 'c.
cursor: Cursor<'c>,
// This field is contravariant in 'c. Together these make StepCursor
// invariant in 'c. Also covariant in 'a. The user cannot cast 'c to a
// different lifetime but can upcast into a StepCursor with a shorter
// lifetime 'a.
//
// As long as we only ever construct a StepCursor for which 'c outlives 'a,
// this means if ever a StepCursor<'c, 'a> exists we are guaranteed that 'c
// outlives 'a.
marker: PhantomData<fn(Cursor<'c>) -> Cursor<'a>>,
}
impl<'c, 'a> Deref for StepCursor<'c, 'a> {
type Target = Cursor<'c>;
fn deref(&self) -> &Self::Target {
&self.cursor
Annotation
- Detected declarations: `function drop`, `function inner_unexpected`, `function cell_clone`, `function Some`, `function cursor`, `function Err`, `function Some`, `function Some`, `function parse`, `function clone`.
- 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.