use std::fmt::{self, Write};
+use itertools::Itertools;
+
use crate::{
attr::RawAttrs,
generics::{WherePredicate, WherePredicateTypeTarget},
path::GenericArg,
+ type_ref::TraitBoundModifier,
visibility::RawVisibility,
};
macro_rules! w {
($dst:expr, $($arg:tt)*) => {
- drop(write!($dst, $($arg)*))
+ { let _ = write!($dst, $($arg)*); }
};
}
macro_rules! wln {
($dst:expr) => {
- drop(writeln!($dst))
+ { let _ = writeln!($dst); }
};
($dst:expr, $($arg:tt)*) => {
- drop(writeln!($dst, $($arg)*))
+ { let _ = writeln!($dst, $($arg)*); }
};
}
fn blank(&mut self) {
let mut iter = self.buf.chars().rev().fuse();
match (iter.next(), iter.next()) {
- (Some('\n'), Some('\n')) | (Some('\n'), None) | (None, None) => {}
+ (Some('\n'), Some('\n') | None) | (None, None) => {}
(Some('\n'), Some(_)) => {
self.buf.push('\n');
}
fn whitespace(&mut self) {
match self.buf.chars().next_back() {
- None | Some('\n') | Some(' ') => {}
+ None | Some('\n' | ' ') => {}
_ => self.buf.push(' '),
}
}
w!(self, " {{");
self.indented(|this| {
for item in &**items {
- this.print_mod_item((*item).into());
+ this.print_mod_item(*item);
}
});
wln!(self, "}}");
}
}
ModItem::MacroCall(it) => {
- let MacroCall { path, ast_id: _, fragment: _ } = &self.tree[it];
+ let MacroCall { path, ast_id: _, expand_to: _ } = &self.tree[it];
wln!(self, "{}!(...);", path);
}
ModItem::MacroRules(it) => {
}
match bound.as_ref() {
- TypeBound::Path(path) => self.print_path(path),
+ TypeBound::Path(path, modifier) => {
+ match modifier {
+ TraitBoundModifier::None => (),
+ TraitBoundModifier::Maybe => w!(self, "?"),
+ }
+ self.print_path(path)
+ }
+ TypeBound::ForLifetime(lifetimes, path) => {
+ w!(self, "for<{}> ", lifetimes.iter().format(", "));
+ self.print_path(path);
+ }
TypeBound::Lifetime(lt) => w!(self, "{}", lt.name),
TypeBound::Error => w!(self, "{{unknown}}"),
}