quote_decl

func quote_decl(input: MacroInput, splices: [SyntaxSplice<Decl>], context: &QuoteContext) -> SyntaxResult<Decl>

Quotes declaration tokens while preserving token provenance and hygiene.

Because func and init grammar depends on where the result is inserted, this performs structural splice checks only. Wrapper materialization validates the declaration once the target context is known.

View Source
pub func quote_decl(input: MacroInput, splices: [SyntaxSplice<Decl>], context: &QuoteContext) -> SyntaxResult<Decl> {
	let result = quote_raw(input: input, splices: raw_decl_splices(splices: splices), context: context, category: .decl)
	if let .some(failure) = result.failure { return SyntaxResult<Decl>(value: .none, failure: .some(failure)) }
	if let .some(raw) = result.raw {
		// Declaration grammar depends on the declaration context the result
		// lands in (a `func` member is a method, `init` is context-gated), so
		// the category parse runs once at the wrapper service boundary where
		// that context is known; only structural splice checks happen here.
		return SyntaxResult<Decl>(value: .some(Syntax<Decl>(raw: raw)), failure: .none)
	}
	SyntaxResult<Decl>(value: .none, failure: .some(SyntaxFailure(code: "syntax.quote.invalid", message: "Invalid declaration quotation", span: 0..<0)))
}