commit
fff0be2f82
3 changed files with 19 additions and 16 deletions
|
|
@ -11,6 +11,7 @@
|
|||
#![feature(rustc_private)]
|
||||
#![feature(custom_attribute)]
|
||||
#![feature(slice_splits)]
|
||||
#![feature(slice_patterns)]
|
||||
#![feature(catch_panic)]
|
||||
#![allow(unused_attributes)]
|
||||
|
||||
|
|
|
|||
26
src/types.rs
26
src/types.rs
|
|
@ -484,22 +484,16 @@ impl Rewrite for ast::Ty {
|
|||
ty.rewrite(context, budget, offset + 1).map(|ty_str| format!("({})", ty_str))
|
||||
}
|
||||
ast::TyTup(ref tup_ret) => {
|
||||
let inner = try_opt!(tup_ret.iter()
|
||||
.map(|item| item.rewrite(context, width, offset))
|
||||
.fold(Some("".to_owned()),
|
||||
|sum, x| {
|
||||
match (sum, x) {
|
||||
(Some(sum), Some(x)) => {
|
||||
if sum == "" {
|
||||
// First item.
|
||||
Some(x)
|
||||
} else {
|
||||
Some(sum + ", " + &x)
|
||||
}
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}));
|
||||
let inner = if let [ref item] = &**tup_ret {
|
||||
try_opt!(item.rewrite(context, width, offset)) + ","
|
||||
} else {
|
||||
let rewrites: Option<Vec<_>>;
|
||||
rewrites = tup_ret.iter()
|
||||
.map(|item| item.rewrite(context, width, offset))
|
||||
.collect();
|
||||
|
||||
try_opt!(rewrites).join(", ")
|
||||
};
|
||||
|
||||
let ret = format!("({})", inner);
|
||||
wrap_str(ret, context.config.max_width, width, offset)
|
||||
|
|
|
|||
8
tests/target/fn_once.rs
Normal file
8
tests/target/fn_once.rs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
struct Add(usize);
|
||||
|
||||
impl FnOnce<(usize,)> for Add {
|
||||
type Output = Add;
|
||||
extern "rust-call" fn call_once(self, to: (usize,)) -> Add {
|
||||
Add(self.0 + to.0)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue