Skip to content

Commit 88d9b37

Browse files
committed
Auto merge of #115400 - gurry:issue-115264-ice, r=compiler-errors
Return ident for ExprField and PatField HIR nodes Fixes #115264
2 parents 2f5df8a + 19574d2 commit 88d9b37

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

compiler/rustc_hir/src/hir.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3729,6 +3729,8 @@ impl<'hir> Node<'hir> {
37293729
Node::Lifetime(lt) => Some(lt.ident),
37303730
Node::GenericParam(p) => Some(p.name.ident()),
37313731
Node::TypeBinding(b) => Some(b.ident),
3732+
Node::PatField(f) => Some(f.ident),
3733+
Node::ExprField(f) => Some(f.ident),
37323734
Node::Param(..)
37333735
| Node::AnonConst(..)
37343736
| Node::ConstBlock(..)
@@ -3737,8 +3739,6 @@ impl<'hir> Node<'hir> {
37373739
| Node::Block(..)
37383740
| Node::Ctor(..)
37393741
| Node::Pat(..)
3740-
| Node::PatField(..)
3741-
| Node::ExprField(..)
37423742
| Node::Arm(..)
37433743
| Node::Local(..)
37443744
| Node::Crate(..)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Regression test for issue 115264
2+
// Tests that retrieving the ident of the X::foo field
3+
// in main() does not cause an ICE
4+
5+
// check-pass
6+
7+
#[allow(dead_code)]
8+
struct X {
9+
foo: i32,
10+
}
11+
12+
fn main() {
13+
let _ = X {
14+
#[doc(alias = "StructItem")]
15+
foo: 123,
16+
};
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Regression test for issue 115264
2+
// Tests that retrieving the ident of 'foo' variable in
3+
// the pattern inside main() does not cause an ICE
4+
5+
// check-pass
6+
7+
struct X {
8+
foo: i32,
9+
}
10+
11+
#[allow(unused_variables)]
12+
fn main() {
13+
let X {
14+
#[doc(alias = "StructItem")]
15+
foo
16+
} = X {
17+
foo: 123
18+
};
19+
}

0 commit comments

Comments
 (0)