mirror of
https://gitee.com/openharmony/third_party_rust_cxx
synced 2024-11-27 01:11:38 +00:00
7fae55596e
warning: associated function is never used: `checked_succ` --> gen/build/src/syntax/discriminant.rs:183:18 | 183 | pub const fn checked_succ(self) -> Option<Self> { | ^^^^^^^^^^^^ | = note: `#[warn(dead_code)]` on by default warning: associated function is never used: `ty` --> gen/build/src/syntax/tokens.rs:305:12 | 305 | pub fn ty(&self) -> ReceiverType { | ^^ warning: associated function is never used: `ty_self` --> gen/build/src/syntax/tokens.rs:310:12 | 310 | pub fn ty_self(&self) -> ReceiverTypeSelf { | ^^^^^^^ warning: variant is never constructed: `Foreign` --> gen/build/src/syntax/mod.rs:122:5 | 122 | Foreign { rust_type: Path }, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: associated function is never used: `checked_succ` --> macro/src/syntax/discriminant.rs:183:18 | 183 | pub const fn checked_succ(self) -> Option<Self> { | ^^^^^^^^^^^^ | = note: `#[warn(dead_code)]` on by default warning: associated function is never used: `is_empty` --> macro/src/syntax/doc.rs:22:12 | 22 | pub fn is_empty(&self) -> bool { | ^^^^^^^^ warning: associated function is never used: `to_string` --> macro/src/syntax/doc.rs:26:12 | 26 | pub fn to_string(&self) -> String { | ^^^^^^^^^ warning: associated function is never used: `remove` --> macro/src/syntax/map.rs:127:16 | 127 | pub fn remove<Q>(&mut self, key: &Q) -> Option<V> | ^^^^^^ warning: associated function is never used: `to_fully_qualified` --> macro/src/syntax/names.rs:24:12 | 24 | pub fn to_fully_qualified(&self) -> String { | ^^^^^^^^^^^^^^^^^^ warning: associated function is never used: `prefix_with` --> macro/src/syntax/symbol.rs:44:12 | 44 | pub fn prefix_with(&self, prefix: &str) -> Symbol { | ^^^^^^^^^^^ warning: variant is never constructed: `Foreign` --> macro/src/syntax/mod.rs:122:5 | 122 | Foreign { rust_type: Path }, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
47 lines
1.0 KiB
Rust
47 lines
1.0 KiB
Rust
use proc_macro2::TokenStream;
|
|
use quote::{quote, ToTokens};
|
|
use syn::LitStr;
|
|
|
|
pub struct Doc {
|
|
pub(crate) hidden: bool,
|
|
fragments: Vec<LitStr>,
|
|
}
|
|
|
|
impl Doc {
|
|
pub fn new() -> Self {
|
|
Doc {
|
|
hidden: false,
|
|
fragments: Vec::new(),
|
|
}
|
|
}
|
|
|
|
pub fn push(&mut self, lit: LitStr) {
|
|
self.fragments.push(lit);
|
|
}
|
|
|
|
#[allow(dead_code)] // only used by cxx-build, not cxxbridge-macro
|
|
pub fn is_empty(&self) -> bool {
|
|
self.fragments.is_empty()
|
|
}
|
|
|
|
#[allow(dead_code)] // only used by cxx-build, not cxxbridge-macro
|
|
pub fn to_string(&self) -> String {
|
|
let mut doc = String::new();
|
|
for lit in &self.fragments {
|
|
doc += &lit.value();
|
|
doc.push('\n');
|
|
}
|
|
doc
|
|
}
|
|
}
|
|
|
|
impl ToTokens for Doc {
|
|
fn to_tokens(&self, tokens: &mut TokenStream) {
|
|
let fragments = &self.fragments;
|
|
tokens.extend(quote! { #(#[doc = #fragments])* });
|
|
if self.hidden {
|
|
tokens.extend(quote! { #[doc(hidden)] });
|
|
}
|
|
}
|
|
}
|