Skip to content

Commit 4bf0061

Browse files
author
Lukas Markeffsky
committed
Fix ICE for nested test function with arguments.
1 parent 3572d74 commit 4bf0061

File tree

1 file changed

+6
-6
lines changed
  • compiler/rustc_builtin_macros/src

1 file changed

+6
-6
lines changed

compiler/rustc_builtin_macros/src/test.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,7 @@ pub fn expand_test_or_bench(
122122
let ast::ItemKind::Fn(fn_) = &item.kind else {
123123
not_testable_error(cx, attr_sp, Some(&item));
124124
return if is_stmt {
125-
vec![Annotatable::Stmt(P(ast::Stmt {
126-
id: ast::DUMMY_NODE_ID,
127-
span: item.span,
128-
kind: ast::StmtKind::Item(item),
129-
}))]
125+
vec![Annotatable::Stmt(P(cx.stmt_item(item.span, item)))]
130126
} else {
131127
vec![Annotatable::Item(item)]
132128
};
@@ -138,7 +134,11 @@ pub fn expand_test_or_bench(
138134
if (!is_bench && !has_test_signature(cx, &item))
139135
|| (is_bench && !has_bench_signature(cx, &item))
140136
{
141-
return vec![Annotatable::Item(item)];
137+
return if is_stmt {
138+
vec![Annotatable::Stmt(P(cx.stmt_item(item.span, item)))]
139+
} else {
140+
vec![Annotatable::Item(item)]
141+
};
142142
}
143143

144144
let sp = cx.with_def_site_ctxt(item.span);

0 commit comments

Comments
 (0)