Return ident for ExprField and PatField HIR nodes
This commit is contained in:
parent
b1b244da65
commit
19574d216a
3 changed files with 38 additions and 2 deletions
|
@ -3729,6 +3729,8 @@ impl<'hir> Node<'hir> {
|
||||||
Node::Lifetime(lt) => Some(lt.ident),
|
Node::Lifetime(lt) => Some(lt.ident),
|
||||||
Node::GenericParam(p) => Some(p.name.ident()),
|
Node::GenericParam(p) => Some(p.name.ident()),
|
||||||
Node::TypeBinding(b) => Some(b.ident),
|
Node::TypeBinding(b) => Some(b.ident),
|
||||||
|
Node::PatField(f) => Some(f.ident),
|
||||||
|
Node::ExprField(f) => Some(f.ident),
|
||||||
Node::Param(..)
|
Node::Param(..)
|
||||||
| Node::AnonConst(..)
|
| Node::AnonConst(..)
|
||||||
| Node::ConstBlock(..)
|
| Node::ConstBlock(..)
|
||||||
|
@ -3737,8 +3739,6 @@ impl<'hir> Node<'hir> {
|
||||||
| Node::Block(..)
|
| Node::Block(..)
|
||||||
| Node::Ctor(..)
|
| Node::Ctor(..)
|
||||||
| Node::Pat(..)
|
| Node::Pat(..)
|
||||||
| Node::PatField(..)
|
|
||||||
| Node::ExprField(..)
|
|
||||||
| Node::Arm(..)
|
| Node::Arm(..)
|
||||||
| Node::Local(..)
|
| Node::Local(..)
|
||||||
| Node::Crate(..)
|
| Node::Crate(..)
|
||||||
|
|
17
tests/ui/attributes/issue-115264-expr-field.rs
Normal file
17
tests/ui/attributes/issue-115264-expr-field.rs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
// Regression test for issue 115264
|
||||||
|
// Tests that retrieving the ident of the X::foo field
|
||||||
|
// in main() does not cause an ICE
|
||||||
|
|
||||||
|
// check-pass
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
struct X {
|
||||||
|
foo: i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let _ = X {
|
||||||
|
#[doc(alias = "StructItem")]
|
||||||
|
foo: 123,
|
||||||
|
};
|
||||||
|
}
|
19
tests/ui/attributes/issue-115264-pat-field.rs
Normal file
19
tests/ui/attributes/issue-115264-pat-field.rs
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
// Regression test for issue 115264
|
||||||
|
// Tests that retrieving the ident of 'foo' variable in
|
||||||
|
// the pattern inside main() does not cause an ICE
|
||||||
|
|
||||||
|
// check-pass
|
||||||
|
|
||||||
|
struct X {
|
||||||
|
foo: i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(unused_variables)]
|
||||||
|
fn main() {
|
||||||
|
let X {
|
||||||
|
#[doc(alias = "StructItem")]
|
||||||
|
foo
|
||||||
|
} = X {
|
||||||
|
foo: 123
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue