How to deprecate type names in a library?

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:

pub use NewName as OldName;


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?

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

1 Like

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

1 Like

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: Rust Playground