#attributes #deprecated #macro #removal #version #force #deprecate

macro deprecate-until

Rust attribute to force deprecated item removal at a specified version

2 releases

0.1.1 Nov 29, 2023
0.1.0 Jul 15, 2023

#2576 in Development tools

Download history 7617/week @ 2024-07-10 8413/week @ 2024-07-17 6403/week @ 2024-07-24 8550/week @ 2024-07-31 6491/week @ 2024-08-07 5589/week @ 2024-08-14 5819/week @ 2024-08-21 7444/week @ 2024-08-28 7370/week @ 2024-09-04 7686/week @ 2024-09-11 7782/week @ 2024-09-18 7687/week @ 2024-09-25 8811/week @ 2024-10-02 11155/week @ 2024-10-09 11103/week @ 2024-10-16 9907/week @ 2024-10-23

42,380 downloads per month
Used in 32 crates (3 directly)

Apache-2.0/MIT

10KB
99 lines

deprecate-until

Current Version Documentation License: Apache-2.0/MIT

This crate introduces a new deprecate_until attribute which helps crate authors not to remove to delete obsolete items when some version is reached. When the specified semver condition is verified, the crate will not compile anymore and hopefully this will be caught by the CI or by cargo install before the release actually happens.

Usage

The deprecate_until attribute supports the same arguments as deprecate, i.e., note and since. It also requires a remove argument, which is a semver requirement expression in a string.

Example

The following code

use deprecate_until::deprecate_until;

#[deprecate_until(remove = ">= 4.x", note = "use `some_new_function` instead")]
fn old_function() {
    todo!()
}

will give a warning when version 3.8 of the crate is used in a project:

warning: use of deprecated function `old_function`: use `some_new_function` instead (removal scheduled for version >= 4.x)
  |
4 | fn old_function() {
  |    ^^^^^^^^^^^^

It will also cause a compilation error in version 4.0.0 of the crate if you forgot to remove it:

error: version `4.0.0` matches `>= 4.x`, item should be removed
  |
3 | #[deprecate_until(remove = ">= 4.x", note = "use `some_new_function` instead")]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Dependencies

~305–760KB
~18K SLoC