Stability attributes for third-party libraries?


#1

A few weeks (months?) ago, it was possible to add #[stable], #[unstable], #[deprecated], etc. attributes to the functions of your own rust libraries. These markers would show up in the docs generated by rustdoc, and if a user was using a deprecated function they would get a warning.

When suddenly after some change in the system, they stopped being recognized. Rustdoc shows “no stability level” for all functions, and users don’t get warnings if they use deprecated functions coming from third-party libraries.

What are the plans about this? I didn’t find any issue about this and it looks like an intended change, which is sad. The #[deprecated] attribute especially would be very useful.


#2

The new design was outlined in RFC 507. The system was/is explicitly designed for use by the standard library only. However, everyone (core team and otherwise) wants external libraries to have this sort of functionality available too, and we aim to provide something.

The discussion on that RFC includes more details, @alexcrichton’s summary comment serves as a table-of-contents.


#3

Unfortunately it seems that #[staged_stable] and #[staged_deprecated] aren’t recognized by the compiler :-/


#4

Recent nightly added an error:

stability attributes may not be used outside of the standard library

That’s a shame, because I was developing a library and well, a lot of it was unstable :smile:

The tags were useful for marking finished/unfinished parts of the library in rustdoc.


#5

Yes, this change was accepted long ago, but we didn’t actually write the code until recently.

The current stability attributes are very tied to the channels release process. We absolutely agree that something like it would be good for external crates, but they should be designed for that use case, specifically.


#6

I just anything, something simple, to signal a warning on deprecated items. This is needed to have a good communication with users.

Even more so I think when the crate version is pre-1.0… We don’t promise anything, but we still want to give users some warning before stuff is removed or changed.


#7

You should write up an RFC!