mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Merge pull request #1997 from topecongiro/issue-1995
Fix a budget bug in Arg::rewrite()
This commit is contained in:
commit
ce62f0a7ec
11
src/items.rs
11
src/items.rs
@ -1598,11 +1598,12 @@ impl Rewrite for ast::Arg {
|
||||
if context.config.space_after_type_annotation_colon() {
|
||||
result.push_str(" ");
|
||||
}
|
||||
let max_width = try_opt!(shape.width.checked_sub(result.len()));
|
||||
let ty_str = try_opt!(self.ty.rewrite(
|
||||
context,
|
||||
Shape::legacy(max_width, shape.indent + result.len()),
|
||||
));
|
||||
let overhead = last_line_width(&result);
|
||||
let max_width = try_opt!(shape.width.checked_sub(overhead));
|
||||
let ty_str = try_opt!(
|
||||
self.ty
|
||||
.rewrite(context, Shape::legacy(max_width, shape.indent))
|
||||
);
|
||||
result.push_str(&ty_str);
|
||||
}
|
||||
|
||||
|
@ -139,3 +139,16 @@ pub trait Number: Copy + Eq + Not<Output = Self> + Shl<u8, Output = Self> +
|
||||
pub trait SomeTrait : Clone + Eq + PartialEq + Ord + PartialOrd + Default + Hash + Debug + Display + Write + Read + FromStr {
|
||||
// comment
|
||||
}
|
||||
|
||||
// #1995
|
||||
impl Foo {
|
||||
fn f(
|
||||
S {
|
||||
aaaaaaaaaa: aaaaaaaaaa,
|
||||
bbbbbbbbbb: bbbbbbbbbb,
|
||||
cccccccccc: cccccccccc,
|
||||
}: S
|
||||
) -> u32{
|
||||
1
|
||||
}
|
||||
}
|
||||
|
@ -202,3 +202,16 @@ pub trait SomeTrait
|
||||
+ FromStr {
|
||||
// comment
|
||||
}
|
||||
|
||||
// #1995
|
||||
impl Foo {
|
||||
fn f(
|
||||
S {
|
||||
aaaaaaaaaa: aaaaaaaaaa,
|
||||
bbbbbbbbbb: bbbbbbbbbb,
|
||||
cccccccccc: cccccccccc,
|
||||
}: S,
|
||||
) -> u32 {
|
||||
1
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user