Possibly unintended breakage between 0.8 and 0.9 involving use of the #[deprecated] attribute #109

Closed
opened 2017-06-08 11:57:56 -05:00 by Cldfire · 0 comments
Cldfire commented 2017-06-08 11:57:56 -05:00 (Migrated from github.com)

Given the following snippet of code compiled with bitflags 0.8:

#![allow(deprecated)]

#[macro_use]
extern crate bitflags;

bitflags! {
    pub flags TestFlags: u32 {
        #[deprecated(note = "test note")]
        const FLAG_ONE = 1,
    }
}

Everything works fine:

Compiling bitflags_breakage_test v0.1.0 (file:///home/cldfire/programming_projects/bitflags_breakage_test)
    Finished dev [unoptimized + debuginfo] target(s) in 0.10 secs

And everything looks fine in the docs as well:

spectacle h29900

spectacle t29900

However, given the same snippet of code (ignoring syntax changes) compiled with bitflags 0.9:

#![allow(deprecated)]

#[macro_use]
extern crate bitflags;

bitflags! {
    pub struct TestFlags: u32 {
        #[deprecated(note = "test note")]
        const FLAG_ONE = 1;
    }
}

It does not compile:

   Updating registry `https://github.com/rust-lang/crates.io-index`
   Compiling bitflags_breakage_test v0.1.0 (file:///home/cldfire/programming_projects/bitflags_breakage_test)
error: This deprecation annotation is useless
  --> src/lib.rs:6:1
   |
6  | / bitflags! {
7  | |     pub struct TestFlags: u32 {
8  | |         #[deprecated(note = "test note")]
9  | |         const FLAG_ONE = 1;
10 | |     }
11 | | }
   | |_^
   |
   = note: this error originates in a macro outside of the current crate

error: This deprecation annotation is useless
  --> src/lib.rs:6:1
   |
6  | / bitflags! {
7  | |     pub struct TestFlags: u32 {
8  | |         #[deprecated(note = "test note")]
9  | |         const FLAG_ONE = 1;
10 | |     }
11 | | }
   | |_^
   |
   = note: this error originates in a macro outside of the current crate

error: aborting due to 2 previous errors

error: Could not compile `bitflags_breakage_test`.

To learn more, run the command again with --verbose.

I am not sure if this behavior is intended or not, or if use of attributes such as #[deprecated] was supported in the first place. If this is correct behavior it would be nice to mention it in the release notes (I encountered this issue while bumping bitflags from 0.8 -> 0.9 in my own crate).

Given the following snippet of code compiled with bitflags 0.8: ```rust #![allow(deprecated)] #[macro_use] extern crate bitflags; bitflags! { pub flags TestFlags: u32 { #[deprecated(note = "test note")] const FLAG_ONE = 1, } } ``` Everything works fine: ```bash Compiling bitflags_breakage_test v0.1.0 (file:///home/cldfire/programming_projects/bitflags_breakage_test) Finished dev [unoptimized + debuginfo] target(s) in 0.10 secs ``` And everything looks fine in the docs as well: ![spectacle h29900](https://user-images.githubusercontent.com/13814214/26940771-faeeefac-4c49-11e7-9cb0-76ad068732e0.png) ![spectacle t29900](https://user-images.githubusercontent.com/13814214/26940787-07d93376-4c4a-11e7-915a-214261986bbd.png) However, given the same snippet of code (ignoring syntax changes) compiled with bitflags 0.9: ```rust #![allow(deprecated)] #[macro_use] extern crate bitflags; bitflags! { pub struct TestFlags: u32 { #[deprecated(note = "test note")] const FLAG_ONE = 1; } } ``` It does not compile: ```bash Updating registry `https://github.com/rust-lang/crates.io-index` Compiling bitflags_breakage_test v0.1.0 (file:///home/cldfire/programming_projects/bitflags_breakage_test) error: This deprecation annotation is useless --> src/lib.rs:6:1 | 6 | / bitflags! { 7 | | pub struct TestFlags: u32 { 8 | | #[deprecated(note = "test note")] 9 | | const FLAG_ONE = 1; 10 | | } 11 | | } | |_^ | = note: this error originates in a macro outside of the current crate error: This deprecation annotation is useless --> src/lib.rs:6:1 | 6 | / bitflags! { 7 | | pub struct TestFlags: u32 { 8 | | #[deprecated(note = "test note")] 9 | | const FLAG_ONE = 1; 10 | | } 11 | | } | |_^ | = note: this error originates in a macro outside of the current crate error: aborting due to 2 previous errors error: Could not compile `bitflags_breakage_test`. To learn more, run the command again with --verbose. ``` I am not sure if this behavior is intended or not, or if use of attributes such as `#[deprecated]` was supported in the first place. If this is correct behavior it would be nice to mention it in the release notes (I encountered this issue while bumping bitflags from 0.8 -> 0.9 in my own crate).
Sign in to join this conversation.
No labels
bug
good first issue
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-bitflags/bitflags#109
No description provided.