From 3c7c694e734b6bcc41663eaf230a7f26c19de0f4 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 2 Jan 2023 14:25:24 -0800 Subject: [PATCH 1/2] Document rustc_ast::Extern variants --- compiler/rustc_ast/src/ast.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 4ad9981991d..9f38deacca4 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -2705,8 +2705,19 @@ impl Item { /// `extern` qualifier on a function item or function type. #[derive(Clone, Copy, Encodable, Decodable, Debug)] pub enum Extern { + /// No explicit extern keyword was used + /// + /// E.g. `fn foo() {}` 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), + /// An explicit extern keyword was used with an explicit ABI + /// + /// E.g. `extern "C" fn foo() {}` Explicit(StrLit, Span), } From 157211ff2f0a8f45c6000c46a545412a0fb9eed4 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 2 Jan 2023 14:26:43 -0800 Subject: [PATCH 2/2] Document rustc_ast::FnHeader fields --- compiler/rustc_ast/src/ast.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 9f38deacca4..37dfa46f696 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -2736,9 +2736,13 @@ impl Extern { /// included in this struct (e.g., `async unsafe fn` or `const extern "C" fn`). #[derive(Clone, Copy, Encodable, Decodable, Debug)] pub struct FnHeader { + /// The `unsafe` keyword, if any pub unsafety: Unsafe, + /// The `async` keyword, if any pub asyncness: Async, + /// The `const` keyword, if any pub constness: Const, + /// The `extern` keyword and corresponding ABI string, if any pub ext: Extern, }