Skip to content

Commit 26cbf91

Browse files
authored
Rollup merge of #94554 - Urgau:stmt-node-id-ice, r=petrochenkov
Fix invalid lint_node_id being put on a removed stmt This pull-request remove a invalid `assign_id!` being put on an stmt node. The problem is that this node is being removed away by a cfg making it unreachable when triggering a buffered lint. The comment in the other match arm already tell to not assign a id because it could have a `#[cfg()]` so this is just respecting the comment. Fixes #94523 r? ```````@petrochenkov```````
2 parents 40c146c + 5164884 commit 26cbf91

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

compiler/rustc_expand/src/expand.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1841,7 +1841,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
18411841
self.flat_map_node(node)
18421842
}
18431843

1844-
fn flat_map_stmt(&mut self, mut node: ast::Stmt) -> SmallVec<[ast::Stmt; 1]> {
1844+
fn flat_map_stmt(&mut self, node: ast::Stmt) -> SmallVec<[ast::Stmt; 1]> {
18451845
// FIXME: invocations in semicolon-less expressions positions are expanded as expressions,
18461846
// changing that requires some compatibility measures.
18471847
if node.is_expr() {
@@ -1863,7 +1863,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
18631863
self.cx.current_expansion.is_trailing_mac = false;
18641864
res
18651865
}
1866-
_ => assign_id!(self, &mut node.id, || noop_flat_map_stmt(node, self)),
1866+
_ => noop_flat_map_stmt(node, self),
18671867
};
18681868
}
18691869

src/test/ui/check-cfg/stmt-no-ice.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// This test checks that there is no ICE with this code
2+
//
3+
// check-pass
4+
// compile-flags:--check-cfg=names() -Z unstable-options
5+
6+
fn main() {
7+
#[cfg(crossbeam_loom)]
8+
//~^ WARNING unexpected `cfg` condition name
9+
{}
10+
}
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
warning: unexpected `cfg` condition name
2+
--> $DIR/stmt-no-ice.rs:7:11
3+
|
4+
LL | #[cfg(crossbeam_loom)]
5+
| ^^^^^^^^^^^^^^
6+
|
7+
= note: `#[warn(unexpected_cfgs)]` on by default
8+
9+
warning: 1 warning emitted
10+

0 commit comments

Comments
 (0)