Skip to content

Support deprecated annotation#618

Merged
soutaro merged 1 commit intomainfrom
rbs-class-deprecation-annotation
Mar 3, 2026
Merged

Support deprecated annotation#618
soutaro merged 1 commit intomainfrom
rbs-class-deprecation-annotation

Conversation

@soutaro
Copy link
Contributor

@soutaro soutaro commented Mar 2, 2026

RBS has %a{deprecated} and %a{deprecated: message} annotation. This PR is to import the flags for class and module declarations.

#87

@soutaro soutaro requested a review from a team as a code owner March 2, 2026 06:50
@soutaro soutaro added the enhancement New feature or request label Mar 2, 2026
@soutaro soutaro self-assigned this Mar 2, 2026
Copy link
Member

@vinistock vinistock left a comment

Choose a reason for hiding this comment

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

Nice

let mut flags = DefinitionFlags::empty();

for node in list.iter() {
if let Node::Annotation(annotation) = node {
Copy link
Member

Choose a reason for hiding this comment

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

Does node.annotations() always return a NodeList of Node::Annotation? Or can it return some other AST node?

Maybe, as a future improvement to the RBS crate API, we can make NodeList generic and then we might be able to not need to narrow the type.

Something like:

fn annotations() -> NodeList<Node::Annotation> {
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added panic() since the annotations node should not have any node other than annotation.

assert_def_name_eq!(&context, def, "Baz");
assert!(!def.flags().contains(DefinitionFlags::DEPRECATED));
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's also add a test for classes with deprecation, similar to the module test — just to confirm both paths are covered.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed the second example from module to class so that it tests class declaration too.

@soutaro soutaro force-pushed the rbs-class-deprecation-annotation branch from 5b4d9f2 to 240d85a Compare March 3, 2026 07:03
}

#[test]
fn flags_test_deprecation() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Extracted tests for deprecation annotation detection.

@soutaro soutaro enabled auto-merge March 3, 2026 07:04
@soutaro soutaro merged commit 84b5ad6 into main Mar 3, 2026
33 checks passed
@soutaro soutaro deleted the rbs-class-deprecation-annotation branch March 3, 2026 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants