Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions crates/weaver_semconv/src/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,34 @@ impl AttributeSpec {
AttributeSpec::Id { tag, .. } => tag.clone(),
}
}

/// Apply stability inheritance to enum members when parent attribute is deprecated.
/// This mutates the attribute in-place to propagate deprecation status.
pub fn apply_enum_stability_inheritance(&mut self) {
if let AttributeSpec::Id {
r#type: Enum { members },
deprecated,
stability,
..
} = self
{
// Only apply inheritance if parent attribute is deprecated
if deprecated.is_some() {
for member in members {
// Only inherit stability if member doesn't have explicit stability
if member.stability.is_none() {
// Inherit the parent's stability (if any), or default to experimental
member.stability = stability.clone().or(Some(Stability::Development));
}
// Only inherit deprecation if member doesn't have explicit deprecation
if member.deprecated.is_none() {
// Inherit the parent's deprecation status
member.deprecated = deprecated.clone();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rpotluri-f5 i think we need to extend this logic to be such that if the attribute deprecation reason is obsoleted, then it is cloned otherwise the enum member deprecation reason should be uncategorised, note/brief should be copied across and nothing else. This is to handle the fact that an attribute rename is different to a member rename as the renamed to have different targets.

}
}
}
}
}
}

/// The different types of attributes (specification).
Expand Down
Loading
Loading