Skip to content

deprecated proc_macro trigger warning on build library  #65189

Closed
@la10736

Description

@la10736

Use deprecated attribute on a procedural macro function doesn't work like expected: it triggers a warning message also when library is building and not just in call place.

I know that the deprecate attribute support is not landed in stable but this warning is present in all channels (stable, beta and nightly).

  stable-x86_64-unknown-linux-gnu unchanged - rustc 1.38.0 (625451e37 2019-09-23)
    beta-x86_64-unknown-linux-gnu unchanged - rustc 1.39.0-beta.5 (fa5c2f3e5 2019-10-02)
   nightly-x86_64-unknown-linux-gnu updated - rustc 1.40.0-nightly (421bd77f4 2019-10-06)

Compiling lib simple by cargo +beta build raise follow warning:

   Compiling deprecete_proc_macro v0.1.0 (/home/michele/temp/ppp/deprecete_proc_macro)
warning: use of deprecated item 'deprecable_fn'
 --> src/lib.rs:6:1
  |
6 | pub fn deprecable_fn(input: proc_macro::TokenStream) -> proc_macro::TokenStream { input }
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(deprecated)]` on by default

warning: use of deprecated item 'deprecable_derive'
  --> src/lib.rs:10:1
   |
10 | pub fn deprecable_derive(input: proc_macro::TokenStream) -> proc_macro::TokenStream { input }
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: use of deprecated item 'deprecable_attr'
  --> src/lib.rs:14:1
   |
14 | pub fn deprecable_attr(_args: proc_macro::TokenStream, input: proc_macro::TokenStream) -> proc_macro::TokenStream { input }
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    Finished dev [unoptimized + debuginfo] target(s) in 0.70s

Sadly this issue make deprecated attribute not usable at all for procedural macro.

Follow the code to reproduce this issue:

Cargo.toml

[package]
name = "deprecete_proc_macro"
version = "0.1.0"
authors = ["me <myself@gmail.com>"]
edition = "2018"

[lib]
proc_macro=true

src/lib.rs

extern crate proc_macro;

#[deprecated]
#[proc_macro]
pub fn deprecable_fn(input: proc_macro::TokenStream) -> proc_macro::TokenStream { input }

#[deprecated]
#[proc_macro_derive(Deprecable)]
pub fn deprecable_derive(input: proc_macro::TokenStream) -> proc_macro::TokenStream { input }

#[deprecated]
#[proc_macro_attribute]
pub fn deprecable_attr(_args: proc_macro::TokenStream, input: proc_macro::TokenStream) -> proc_macro::TokenStream { input }

This issue has been assigned to @XiangQingW via this comment.

Metadata

Metadata

Assignees

Labels

A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions