mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
Gracefully handle const _
items in ConstData
This commit is contained in:
parent
2d79a1ad83
commit
beac779c96
2 changed files with 9 additions and 5 deletions
|
@ -773,13 +773,17 @@ impl Const {
|
|||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct ConstData {
|
||||
pub(crate) name: Name,
|
||||
pub(crate) name: Option<Name>,
|
||||
pub(crate) type_ref: TypeRef,
|
||||
}
|
||||
|
||||
impl ConstData {
|
||||
pub fn name(&self) -> &Name {
|
||||
&self.name
|
||||
pub fn name(&self) -> Option<&Name> {
|
||||
self.name.as_ref()
|
||||
}
|
||||
|
||||
pub fn is_unnamed(&self) -> bool {
|
||||
self.name.is_none()
|
||||
}
|
||||
|
||||
pub fn type_ref(&self) -> &TypeRef {
|
||||
|
@ -804,7 +808,7 @@ impl ConstData {
|
|||
}
|
||||
|
||||
fn const_data_for<N: NameOwner + TypeAscriptionOwner>(node: &N) -> Arc<ConstData> {
|
||||
let name = node.name().map(|n| n.as_name()).unwrap_or_else(Name::missing);
|
||||
let name = node.name().map(|n| n.as_name());
|
||||
let type_ref = TypeRef::from_ast_opt(node.ascribed_type());
|
||||
let sig = ConstData { name, type_ref };
|
||||
Arc::new(sig)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue