Skip to content

Commit 18b48bf

Browse files
committed
Lazify some mac_placeholder() calls.
This avoids some unnecessary creation of empty token streams.
1 parent 1ce0347 commit 18b48bf

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/libsyntax/ext/placeholders.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ pub fn placeholder(kind: AstFragmentKind, id: ast::NodeId) -> AstFragment {
3232
attrs: ThinVec::new(),
3333
kind: ast::ExprKind::Mac(mac_placeholder()),
3434
});
35-
let ty = P(ast::Ty {
35+
let ty = || P(ast::Ty {
3636
id,
3737
kind: ast::TyKind::Mac(mac_placeholder()),
3838
span,
3939
});
40-
let pat = P(ast::Pat {
40+
let pat = || P(ast::Pat {
4141
id,
4242
kind: ast::PatKind::Mac(mac_placeholder()),
4343
span,
@@ -83,7 +83,7 @@ pub fn placeholder(kind: AstFragmentKind, id: ast::NodeId) -> AstFragment {
8383
body: expr_placeholder(),
8484
guard: None,
8585
id,
86-
pat,
86+
pat: pat(),
8787
span,
8888
is_placeholder: true,
8989
}
@@ -105,7 +105,7 @@ pub fn placeholder(kind: AstFragmentKind, id: ast::NodeId) -> AstFragment {
105105
id,
106106
ident,
107107
is_shorthand: false,
108-
pat,
108+
pat: pat(),
109109
span,
110110
is_placeholder: true,
111111
}
@@ -124,9 +124,9 @@ pub fn placeholder(kind: AstFragmentKind, id: ast::NodeId) -> AstFragment {
124124
ast::Param {
125125
attrs: Default::default(),
126126
id,
127-
pat,
127+
pat: pat(),
128128
span,
129-
ty,
129+
ty: ty(),
130130
is_placeholder: true,
131131
}
132132
]),
@@ -136,7 +136,7 @@ pub fn placeholder(kind: AstFragmentKind, id: ast::NodeId) -> AstFragment {
136136
id,
137137
ident: None,
138138
span,
139-
ty,
139+
ty: ty(),
140140
vis,
141141
is_placeholder: true,
142142
}

0 commit comments

Comments
 (0)