Merge pull request #332 from dtolnay/doc

Preserve docs on aliases
This commit is contained in:
David Tolnay 2020-10-03 16:38:22 -07:00 committed by GitHub
commit 4954ca171f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 1 deletions

View File

@ -657,9 +657,11 @@ fn expand_rust_function_shim_impl(
}
fn expand_type_alias(alias: &TypeAlias) -> TokenStream {
let doc = &alias.doc;
let ident = &alias.ident;
let ty = &alias.ty;
quote! {
#doc
pub type #ident = #ty;
}
}

View File

@ -79,6 +79,7 @@ pub struct ExternFn {
}
pub struct TypeAlias {
pub doc: Doc,
pub type_token: Token![type],
pub ident: Ident,
pub eq_token: Token![=],

View File

@ -396,9 +396,10 @@ fn parse_extern_verbatim(cx: &mut Errors, tokens: &TokenStream, lang: Lang) -> R
let eq_token: Token![=] = input.parse()?;
let ty: RustType = input.parse()?;
let semi_token: Token![;] = input.parse()?;
attrs::parse_doc(cx, &attrs);
let doc = attrs::parse_doc(cx, &attrs);
Ok(TypeAlias {
doc,
type_token,
ident,
eq_token,