Skip to content
This repository was archived by the owner on Nov 24, 2023. It is now read-only.
This repository was archived by the owner on Nov 24, 2023. It is now read-only.

Guided renames by deprecations #151

Closed as not planned
Closed as not planned
@bluss

Description

@bluss

(Excuse me if this is not the right place to bring this up.)

What if a library could use #[deprecated] + a convention about what to put in the note to enable cargo fix to automatically fix the deprecation, if it's due to a rename.

#[deprecated(note="Renamed to `new_name`")]
pub fn old_name(x: i32) -> i32 {
    new_name(x)
}

pub fn new_name(x: i32) -> i32 {
    unimplemented!()
}

Here's the rustc warning:

Warning: use of deprecated item 'old_name': Renamed to `new_name`
  --> src/visit/reversed.rs:56:40
   |
56 |         old_name(3)
   |         ^^^^^^^^
   |
   = note: #[warn(deprecated)] on by default

In that sense it is guided by rustc. I don't know at all if this is doable, but I imagine it would require some kind of agreed "protocol" for the format of the deprecation message. A more formal way to go about it would be to design this in rustc and for example use a new attribute or a new option on the attribute like #[deprecated(renamed_to="new_name")]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions