Struct expressions
diff --git a/tests/cases/function.rs b/tests/cases/function.rs
index b0eeb50..ba4a7ea 100644
--- a/tests/cases/function.rs
+++ b/tests/cases/function.rs
@@ -1,4 +1,4 @@
-fn f() {
+fn closure() {
(
|| (),
|_| (),
@@ -35,3 +35,14 @@
let a: u8 = 1;
let mut a = 1;
}
+
+fn expr() {
+ fallible()?;
+
+ [repeat; 1 + 1];
+
+ A::B {};
+ A::B { a: () };
+ A::B { .. c };
+ A::B { a: (), b: (), .. c };
+}
diff --git a/tests/test_round_trip.rs b/tests/test_round_trip.rs
index eccd2cb..d98f74b 100644
--- a/tests/test_round_trip.rs
+++ b/tests/test_round_trip.rs
@@ -79,7 +79,7 @@
}
fn respan_crate(krate: ast::Crate) -> ast::Crate {
- use syntex_syntax::ast::{Attribute, Expr, ExprKind, FnDecl, FunctionRetTy, ItemKind, Mac, TyParam};
+ use syntex_syntax::ast::{Attribute, Expr, ExprKind, Field, FnDecl, FunctionRetTy, ItemKind, Mac, TyParam};
use syntex_syntax::codemap::{self, Spanned};
use syntex_syntax::fold::{self, Folder};
use syntex_syntax::ptr::P;
@@ -118,9 +118,11 @@
Expr {
node: match folded.node {
ExprKind::Lit(l) => {
+ // default fold_expr does not fold this span
ExprKind::Lit(l.map(|l| self.fold_spanned(l)))
}
ExprKind::Binary(op, lhs, rhs) => {
+ // default fold_expr does not fold the op span
ExprKind::Binary(self.fold_spanned(op), self.fold_expr(lhs), self.fold_expr(rhs))
}
other => other,
@@ -150,6 +152,18 @@
})
}
+ fn fold_field(&mut self, field: Field) -> Field {
+ Field {
+ ident: codemap::respan(
+ // default fold_field does not fold this span
+ self.new_span(field.ident.span),
+ self.fold_ident(field.ident.node),
+ ),
+ expr: self.fold_expr(field.expr),
+ span: self.new_span(field.span)
+ }
+ }
+
fn fold_attribute(&mut self, mut at: Attribute) -> Option<Attribute> {
at.node.id.0 = 0;
fold::noop_fold_attribute(at, self)