text.push('>');
}
- if f.unsafety == ast::Unsafety::Unsafe {
+ if let ast::Unsafe::Yes(_) = f.unsafety {
text.push_str("unsafe ");
}
push_extern(&mut text, f.ext);
let ty = ty.make(offset + text.len(), id, scx)?;
text.push_str(&ty.text);
- text.push_str(" = ");
- let expr = pprust::expr_to_string(expr).replace('\n', " ");
- text.push_str(&expr);
+ if let Some(expr) = expr {
+ text.push_str(" = ");
+ let expr = pprust::expr_to_string(expr).replace('\n', " ");
+ text.push_str(&expr);
+ }
+
text.push(';');
Ok(extend_sig(ty, text, defs, vec![]))
let ty = ty.make(offset + text.len(), id, scx)?;
text.push_str(&ty.text);
- text.push_str(" = ");
- let expr = pprust::expr_to_string(expr).replace('\n', " ");
- text.push_str(&expr);
+ if let Some(expr) = expr {
+ text.push_str(" = ");
+ let expr = pprust::expr_to_string(expr).replace('\n', " ");
+ text.push_str(&expr);
+ }
+
text.push(';');
Ok(extend_sig(ty, text, defs, vec![]))
}
ast::ItemKind::Fn(ast::FnSig { ref decl, header }, ref generics, _) => {
let mut text = String::new();
- if header.constness.node == ast::Constness::Const {
+ if let ast::Const::Yes(_) = header.constness {
text.push_str("const ");
}
- if header.asyncness.node.is_async() {
+ if header.asyncness.is_async() {
text.push_str("async ");
}
- if header.unsafety == ast::Unsafety::Unsafe {
+ if let ast::Unsafe::Yes(_) = header.unsafety {
text.push_str("unsafe ");
}
push_extern(&mut text, header.ext);
text.push_str("auto ");
}
- if unsafety == ast::Unsafety::Unsafe {
+ if let ast::Unsafe::Yes(_) = unsafety {
text.push_str("unsafe ");
}
text.push_str("trait ");
if let ast::Defaultness::Default = defaultness {
text.push_str("default ");
}
- if unsafety == ast::Unsafety::Unsafe {
+ if let ast::Unsafe::Yes(_) = unsafety {
text.push_str("unsafe ");
}
text.push_str("impl");
- if constness == ast::Constness::Const {
+ if let ast::Const::Yes(_) = constness {
text.push_str(" const");
}
fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext<'_, '_>) -> Result {
let id = Some(self.id);
match self.kind {
- ast::ForeignItemKind::Fn(ref decl, ref generics) => {
+ ast::ForeignItemKind::Fn(ref sig, ref generics, _) => {
+ let decl = &sig.decl;
let mut text = String::new();
text.push_str("fn ");
Ok(sig)
}
- ast::ForeignItemKind::Static(ref ty, m) => {
+ ast::ForeignItemKind::Static(ref ty, m, _) => {
let mut text = "static ".to_owned();
if m == ast::Mutability::Mut {
text.push_str("mut ");
Ok(extend_sig(ty_sig, text, defs, vec![]))
}
- ast::ForeignItemKind::Ty => {
+ ast::ForeignItemKind::TyAlias(..) => {
let mut text = "type ".to_owned();
let name = self.ident.to_string();
let defs = vec![SigElement {
) -> Result {
// FIXME code dup with function signature
let mut text = String::new();
- if m.header.constness.node == ast::Constness::Const {
+ if let ast::Const::Yes(_) = m.header.constness {
text.push_str("const ");
}
- if m.header.asyncness.node.is_async() {
+ if m.header.asyncness.is_async() {
text.push_str("async ");
}
- if m.header.unsafety == ast::Unsafety::Unsafe {
+ if let ast::Unsafe::Yes(_) = m.header.unsafety {
text.push_str("unsafe ");
}
push_extern(&mut text, m.header.ext);