mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-03 20:23:59 +00:00
Fix #775
rewrite_tuple referring config.max_width where given width should be used
This commit is contained in:
parent
3ff7e83457
commit
2dfa96bc9a
13
src/expr.rs
13
src/expr.rs
@ -303,16 +303,16 @@ pub fn rewrite_array<'a, I>(expr_iter: I,
|
||||
-> Option<String>
|
||||
where I: Iterator<Item = &'a ast::Expr>
|
||||
{
|
||||
// 2 for brackets;
|
||||
// 1 = [
|
||||
let offset = offset + 1;
|
||||
let inner_context = &RewriteContext { block_indent: offset, ..*context };
|
||||
// 2 for brackets
|
||||
let max_item_width = try_opt!(width.checked_sub(2));
|
||||
let items = itemize_list(context.codemap,
|
||||
expr_iter,
|
||||
"]",
|
||||
|item| item.span.lo,
|
||||
|item| item.span.hi,
|
||||
// 1 = [
|
||||
|item| item.rewrite(inner_context, max_item_width, offset),
|
||||
span.lo,
|
||||
span.hi)
|
||||
@ -1753,20 +1753,15 @@ pub fn rewrite_tuple<'a, I>(context: &RewriteContext,
|
||||
}
|
||||
|
||||
let list_lo = context.codemap.span_after(span, "(");
|
||||
let budget = try_opt!(width.checked_sub(2));
|
||||
let items = itemize_list(context.codemap,
|
||||
items,
|
||||
")",
|
||||
|item| item.span().lo,
|
||||
|item| item.span().hi,
|
||||
|item| {
|
||||
let inner_width = try_opt!(context.config
|
||||
.max_width
|
||||
.checked_sub(indent.width() + 1));
|
||||
item.rewrite(&aligned, inner_width, indent)
|
||||
},
|
||||
|item| item.rewrite(&aligned, budget, indent),
|
||||
list_lo,
|
||||
span.hi - BytePos(1));
|
||||
let budget = try_opt!(width.checked_sub(2));
|
||||
let list_str = try_opt!(format_item_list(items, budget, indent, context.config));
|
||||
|
||||
Some(format!("({})", list_str))
|
||||
|
@ -32,3 +32,13 @@ fn issue550() {
|
||||
self.visitor.visit_volume(self.level.sector_id(sector), (floor_y,
|
||||
if is_sky_flat(ceil_tex) {from_wad_height(self.height_range.1)} else {ceil_y}));
|
||||
}
|
||||
|
||||
fn issue775() {
|
||||
if indent {
|
||||
let a = mk_object(&[("a".to_string(), Boolean(true)),
|
||||
("b".to_string(),
|
||||
Array(vec![mk_object(&[("c".to_string(),
|
||||
String("\x0c\r".to_string()))]),
|
||||
mk_object(&[("d".to_string(), String("".to_string()))])]))]);
|
||||
}
|
||||
}
|
||||
|
@ -37,3 +37,14 @@ fn issue550() {
|
||||
ceil_y
|
||||
}));
|
||||
}
|
||||
|
||||
fn issue775() {
|
||||
if indent {
|
||||
let a = mk_object(&[("a".to_string(), Boolean(true)),
|
||||
("b".to_string(),
|
||||
Array(vec![mk_object(&[("c".to_string(),
|
||||
String("\x0c\r".to_string()))]),
|
||||
mk_object(&[("d".to_string(),
|
||||
String("".to_string()))])]))]);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user