Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wayland-scanner: Support deprecated-since #784

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bbb651
Copy link

@bbb651 bbb651 commented Feb 7, 2025

Parses deprecated-since attributes in requests/events/entries, and generates #[deprecated]s. Note that this only happens for the client side, since servers are expected to support protocols indefinitely (P.S. should this be added to the description, if so only on the server side?)

The deprecations themselves also generate warnings for the wayland-protocols* crates, I'm not totally sure where the #[allow(deprecated)] should be and it feels silly to add them to every interface so I currently only put it for the core protocol (which iirc is the only place they are used so far), from what I see this is also a problem for missing_docs.

This needs some more testing, I only really tested AxisDiscrete.

@ids1024
Copy link
Member

ids1024 commented Feb 7, 2025

Note that this only happens for the client side, since servers are expected to support protocols indefinitely (P.S. should this be added to the description, if so only on the server side?)

Client may also want want to support old protocol version... if not indefinitely, at least for a fairly long time (it can take a while for all compositors to support a new version, then be released, then be in distros; and applications may want to target old LTS distros that presumably won't update the compositor with new features).

So this is a bit different from what #[deprecated] usually means in a Rust library.

@bbb651
Copy link
Author

bbb651 commented Feb 7, 2025

I agree, the meaning is different because the version of the interface is not tied to the version of the crate, this is also why we can't use the actual since field.
I still think it's a good idea even if you'll often have to often #[allow(deprecation)] for these items - it makes it very visible that it is deprecated when writing the code in autocompletion, and placing the attribute is a subtle reminder that it should be removed at some point.
For the AxisDiscrete example, the AxisValue120 event that replaces it was added in the same version AxisDiscrete was deprecated, and the event is no longer sent to versions requesting that interface. But if you happen to request (I assume requesting means the minimum?) version 8 or above, it'll never be sent and it be more obvious why with the deprecation.

The closet example I can think of is web-sys, you also have the same problem of using newer apis because of backwards compatibility with browsers, though they are much more conservative with deprecations, it seems like they don't surface deprecation information at all currently, but in the javascript ecosystem it does even thought it's different in the same way. Another non-rust example I can think of is the android api, they also deprecate system apis but you might still use them for years for device support.

Worst case we can keep them both as documentation text in a more prominent and structured way than the existing descriptions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants