mirror of
https://gitee.com/openharmony/third_party_rust_cxx
synced 2024-11-23 23:29:50 +00:00
Fix span placement on type aliases
This commit is contained in:
parent
524ff68081
commit
291c9350d6
@ -1019,13 +1019,18 @@ fn expand_rust_function_shim_super(
|
||||
fn expand_type_alias(alias: &TypeAlias) -> TokenStream {
|
||||
let doc = &alias.doc;
|
||||
let attrs = &alias.attrs;
|
||||
let visibility = alias.visibility;
|
||||
let type_token = alias.type_token;
|
||||
let ident = &alias.name.rust;
|
||||
let generics = &alias.generics;
|
||||
let eq_token = alias.eq_token;
|
||||
let ty = &alias.ty;
|
||||
let semi_token = alias.semi_token;
|
||||
|
||||
quote! {
|
||||
#doc
|
||||
#attrs
|
||||
pub type #ident #generics = #ty;
|
||||
#visibility #type_token #ident #generics #eq_token #ty #semi_token
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,6 +123,7 @@ pub struct TypeAlias {
|
||||
pub doc: Doc,
|
||||
pub derives: Vec<Derive>,
|
||||
pub attrs: OtherAttrs,
|
||||
pub visibility: Token![pub],
|
||||
pub type_token: Token![type],
|
||||
pub name: Pair,
|
||||
pub generics: Lifetimes,
|
||||
|
@ -688,7 +688,7 @@ fn parse_extern_verbatim(
|
||||
if lookahead.peek(Token![=]) {
|
||||
// type Alias = crate::path::to::Type;
|
||||
parse_type_alias(
|
||||
cx, attrs, type_token, ident, lifetimes, input, lang, namespace,
|
||||
cx, attrs, visibility, type_token, ident, lifetimes, input, lang, namespace,
|
||||
)
|
||||
} else if lookahead.peek(Token![:]) || lookahead.peek(Token![;]) {
|
||||
// type Opaque: Bound2 + Bound2;
|
||||
@ -706,6 +706,7 @@ fn parse_extern_verbatim(
|
||||
fn parse_type_alias(
|
||||
cx: &mut Errors,
|
||||
attrs: Vec<Attribute>,
|
||||
visibility: Visibility,
|
||||
type_token: Token![type],
|
||||
ident: Ident,
|
||||
generics: Lifetimes,
|
||||
@ -741,12 +742,19 @@ fn parse_type_alias(
|
||||
return Err(Error::new_spanned(span, msg));
|
||||
}
|
||||
|
||||
let visibility = Token![pub](match visibility {
|
||||
Visibility::Public(vis) => vis.pub_token.span,
|
||||
Visibility::Crate(vis) => vis.crate_token.span,
|
||||
Visibility::Restricted(vis) => vis.pub_token.span,
|
||||
Visibility::Inherited => ident.span(),
|
||||
});
|
||||
let name = pair(namespace, &ident, cxx_name, rust_name);
|
||||
|
||||
Ok(Api::TypeAlias(TypeAlias {
|
||||
doc,
|
||||
derives,
|
||||
attrs,
|
||||
visibility,
|
||||
type_token,
|
||||
name,
|
||||
generics,
|
||||
|
@ -35,12 +35,10 @@ error: missing documentation for a struct
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: missing documentation for a type alias
|
||||
--> $DIR/deny_missing_docs.rs:9:1
|
||||
|
|
||||
9 | #[cxx::bridge]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
--> $DIR/deny_missing_docs.rs:49:9
|
||||
|
|
||||
49 | pub type UndocumentedTypeAlias = crate::bindgen::UndocumentedTypeAlias;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: missing documentation for a function
|
||||
--> $DIR/deny_missing_docs.rs:9:1
|
||||
|
Loading…
Reference in New Issue
Block a user