Rollup merge of #106383 - Manishearth:ast-docs, r=compiler-errors

Document some of the AST nodes

Someone was confused about some of this on Zulip, added some docs

We probably should make sure every last field/variant in the AST/HIR is documented at some point

`@bors` rollup
This commit is contained in:
Michael Goulet 2023-01-02 15:39:19 -08:00 committed by GitHub
commit d4cf00f03d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2743,8 +2743,19 @@ impl Item {
/// `extern` qualifier on a function item or function type. /// `extern` qualifier on a function item or function type.
#[derive(Clone, Copy, Encodable, Decodable, Debug)] #[derive(Clone, Copy, Encodable, Decodable, Debug)]
pub enum Extern { pub enum Extern {
/// No explicit extern keyword was used
///
/// E.g. `fn foo() {}`
None, None,
/// An explicit extern keyword was used, but with implicit ABI
///
/// E.g. `extern fn foo() {}`
///
/// This is just `extern "C"` (see `rustc_target::spec::abi::Abi::FALLBACK`)
Implicit(Span), Implicit(Span),
/// An explicit extern keyword was used with an explicit ABI
///
/// E.g. `extern "C" fn foo() {}`
Explicit(StrLit, Span), Explicit(StrLit, Span),
} }
@ -2763,9 +2774,13 @@ impl Extern {
/// included in this struct (e.g., `async unsafe fn` or `const extern "C" fn`). /// included in this struct (e.g., `async unsafe fn` or `const extern "C" fn`).
#[derive(Clone, Copy, Encodable, Decodable, Debug)] #[derive(Clone, Copy, Encodable, Decodable, Debug)]
pub struct FnHeader { pub struct FnHeader {
/// The `unsafe` keyword, if any
pub unsafety: Unsafe, pub unsafety: Unsafe,
/// The `async` keyword, if any
pub asyncness: Async, pub asyncness: Async,
/// The `const` keyword, if any
pub constness: Const, pub constness: Const,
/// The `extern` keyword and corresponding ABI string, if any
pub ext: Extern, pub ext: Extern,
} }