for attr in &**attrs {
wln!(
self,
- "#{}[{}{}] // {:?}",
+ "#{}[{}{}]",
inner,
attr.path,
attr.input.as_ref().map(|it| it.to_string()).unwrap_or_default(),
- attr.id,
);
}
}
ast_id: _,
flags,
} = &self.tree[it];
- if flags.bits != 0 {
- wln!(self, "// flags = 0x{:X}", flags.bits);
- }
self.print_visibility(*visibility);
+ if flags.contains(FnFlags::HAS_DEFAULT_KW) {
+ w!(self, "default ");
+ }
+ if flags.contains(FnFlags::HAS_CONST_KW) {
+ w!(self, "const ");
+ }
+ if flags.contains(FnFlags::HAS_ASYNC_KW) {
+ w!(self, "async ");
+ }
+ if flags.contains(FnFlags::HAS_UNSAFE_KW) {
+ w!(self, "unsafe ");
+ }
if let Some(abi) = abi {
w!(self, "extern \"{}\" ", abi);
}
w!(self, "(");
if !params.is_empty() {
self.indented(|this| {
- for param in params.clone() {
+ for (i, param) in params.clone().enumerate() {
this.print_attrs_of(param);
match &this.tree[param] {
Param::Normal(name, ty) => {
None => w!(this, "_: "),
}
this.print_type_ref(ty);
- wln!(this, ",");
+ w!(this, ",");
+ if flags.contains(FnFlags::HAS_SELF_PARAM) && i == 0 {
+ wln!(this, " // self");
+ } else {
+ wln!(this);
+ }
}
Param::Varargs => {
wln!(this, "...");
w!(self, ") -> ");
self.print_type_ref(ret_type);
self.print_where_clause(explicit_generic_params);
- wln!(self, ";");
+ if flags.contains(FnFlags::HAS_BODY) {
+ wln!(self, " {{ ... }}");
+ } else {
+ wln!(self, ";");
+ }
}
ModItem::Struct(it) => {
let Struct { visibility, name, fields, generic_params, ast_id: _ } = &self.tree[it];
use a::{c, d::{e}};
"#,
expect![[r##"
- #![doc = " file comment"] // AttrId { ast_index: 0 }
- #![no_std] // AttrId { ast_index: 1 }
- #![doc = " another file comment"] // AttrId { ast_index: 2 }
+ #![doc = " file comment"]
+ #![no_std]
+ #![doc = " another file comment"]
pub(self) extern crate self as renamed;
pub(self) use globs::*;
- #[doc = " docs on import"] // AttrId { ast_index: 0 }
+ #[doc = " docs on import"]
pub(self) use crate::{A, B};
pub(self) use a::{c, d::{e}};
}
"#,
expect![[r##"
- #[on_extern_block] // AttrId { ast_index: 0 }
+ #[on_extern_block]
extern "C" {
- #[on_extern_type] // AttrId { ast_index: 0 }
+ #[on_extern_type]
pub(self) type ExType;
- #[on_extern_static] // AttrId { ast_index: 0 }
+ #[on_extern_static]
pub(self) static EX_STATIC: u8 = _;
- #[on_extern_fn] // AttrId { ast_index: 0 }
+ #[on_extern_fn]
pub(self) fn ex_fn() -> ();
}
"##]],
expect![[r##"
pub(self) struct Unit;
- #[derive(Debug)] // AttrId { ast_index: 0 }
+ #[derive(Debug)]
pub(self) struct Struct {
- #[doc = " fld docs"] // AttrId { ast_index: 0 }
+ #[doc = " fld docs"]
pub(self) fld: (),
}
pub(self) struct Tuple(
- #[attr] // AttrId { ast_index: 0 }
+ #[attr]
pub(self) 0: u8,
);
}
pub(self) enum E {
- #[doc = " comment on Unit"] // AttrId { ast_index: 0 }
+ #[doc = " comment on Unit"]
Unit,
- #[doc = " comment on Tuple"] // AttrId { ast_index: 0 }
+ #[doc = " comment on Tuple"]
Tuple(
pub(self) 0: u8,
),
Struct {
- #[doc = " comment on a: u8"] // AttrId { ast_index: 0 }
+ #[doc = " comment on a: u8"]
pub(self) a: u8,
},
}
pub(self) const _: Anon = _;
- #[attr] // AttrId { ast_index: 0 }
- #[inner_attr_in_fn] // AttrId { ast_index: 1 }
- // flags = 0x2
+ #[attr]
+ #[inner_attr_in_fn]
pub(self) fn f(
- #[attr] // AttrId { ast_index: 0 }
+ #[attr]
arg: u8,
_: (),
- ) -> ();
+ ) -> () { ... }
pub(self) trait Tr<Self>
where
{
pub(self) type Assoc: AssocBound = Default;
- // flags = 0x1
pub(self) fn method(
- _: &Self,
+ _: &Self, // self
) -> ();
}
"##]],
mod outline;
"#,
expect![[r##"
- #[doc = " outer"] // AttrId { ast_index: 0 }
- #[doc = " inner"] // AttrId { ast_index: 1 }
+ #[doc = " outer"]
+ #[doc = " inner"]
pub(self) mod inline {
pub(self) use super::*;
- // flags = 0x2
- pub(self) fn fn_in_module() -> ();
+ pub(self) fn fn_in_module() -> () { ... }
}
pub(self) mod outline;
T: 'a,
T: 'b
{
- // flags = 0x2
pub(self) fn f<G>(
arg: impl Copy,
) -> impl Copy
where
- G: 'a;
+ G: 'a { ... }
}
pub(self) enum Enum<'a, T, const U: u8> {
pub(crate) trait Tr<Self> {
pub(crate) fn f() -> ();
- // flags = 0x3
pub(crate) fn method(
- _: &Self,
- ) -> ();
+ _: &Self, // self
+ ) -> () { ... }
}
"#]],
)