How to deprecate type names in a library?


#1

I’d like to change names of some of my types, but I’m afraid there is a cost of breaking people’s stuff attached to that endeavour. I could provide aliases such as:

#[deprecated]
pub use NewName as OldName;

or

#[deprecated]
pub type OldName = NewName;

However those do not trigger deprecation warnings in the compiler. Thus while I can rename my stuff without breaking stuff this way, informing people who use the library that OldName is deprecated and that they should switch to NewName becomes problematic.

I guess support for the #[deprecated] annotation on things other than functions isn’t coming soon? Any ideas what would be the best practice in this scenario?


#2

This topic title almost gave me a heart attack: for a moment I thought type aliases as a language feature are being deprecated.


#3

Oh dear! I’ve edited it, hope it’s clearer now.


#4

This is a known bug. The #[deprecated] attribute throws a warning on an attempt to import the type via the deprecated alias, but not if you use the fully-qualified alias in a method invocation: https://is.gd/je6hNq