Merge pull request #211 from sinhpham/master

Fix #201
This commit is contained in:
cassiersg 2015-08-28 13:50:10 +02:00
commit 0ef88be7cf
3 changed files with 24 additions and 2 deletions

View File

@ -959,8 +959,14 @@ fn rewrite_struct_lit<'a>(context: &RewriteContext,
|item| {
match *item {
StructLitField::Regular(ref field) => field.span.lo,
// 2 = ..
StructLitField::Base(ref expr) => expr.span.lo - BytePos(2),
StructLitField::Base(ref expr) => {
let last_field_hi =
fields.last().map_or(span.lo, |field| field.span.hi);
let snippet =
context.snippet(mk_sp(last_field_hi, expr.span.lo));
let pos = snippet.find_uncommented("..").unwrap();
last_field_hi + BytePos(pos as u32)
}
}
},
|item| {

View File

@ -53,3 +53,11 @@ fn issue177() {
struct Foo<T> { memb: T }
let foo = Foo::<i64> { memb: 10 };
}
fn issue201() {
let s = S{a:0, .. b};
}
fn issue201_2() {
let s = S{a: S2{ .. c}, .. b};
}

View File

@ -71,3 +71,11 @@ fn issue177() {
}
let foo = Foo::<i64> { memb: 10 };
}
fn issue201() {
let s = S { a: 0, ..b };
}
fn issue201_2() {
let s = S { a: S2 { ..c }, ..b };
}