Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inner macro attributes no longer compile on rust 1.52 #85015

Closed
tylerhawkes opened this issue May 6, 2021 · 2 comments
Closed

inner macro attributes no longer compile on rust 1.52 #85015

tylerhawkes opened this issue May 6, 2021 · 2 comments
Labels
C-bug Category: This is a bug. regression-from-stable-to-stable Performance or correctness regression from one stable version to another.
Milestone

Comments

@tylerhawkes
Copy link

Code

I have some proprietary code similar to this that has worked up through rust 1.51. Looking at the linked issues it looks like it should have never compiled in the first place. Whether this is fixed or not, I'll be moving the attributes out to their module definitions so that I can move on.

Cargo.toml:

[package]
name = "broken"
version = "0.1.0"
authors = ["Tyler Hawkes"]
edition = "2018"
[dependencies]
is_not = "*"

src/lib.rs

mod compile;
mod do_not_compile;
#[is_not::is]
pub use compile::compile_fn;
#[is_not::not]
pub use do_not_compile::compile_fn;

src/compile.rs (generated by build.rs)

#![is_not::is]
pub fn compile_fn() {
    println!("compiled")
}

src/do_not_compile.rs (generated by build.rs)

#![is_not::not]
pub fn compile_fn() {
    println!("compiled")
}

I expected to have the code compile with these 3 warnings (though I don't get them with my other code):

warning: function is never used: `compile_fn`
 --> src/do_not_compile.rs:3:8
  |
3 | pub fn compile_fn() {
  |        ^^^^^^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: unused attribute
 --> src/compile.rs:1:1
  |
1 | #![is_not::is]
  | ^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_attributes)]` on by default

warning: unused attribute
 --> src/do_not_compile.rs:1:1
  |
1 | #![is_not::not]
  | ^^^^^^^^^^^^^^^

warning: 3 warnings emitted

Instead, the code doesn't compile referencing error E0658

error[E0658]: inner macro attributes are unstable
 --> src/compile.rs:1:4
  |
1 | #![is_not::is]
  |    ^^^^^^^^^^
  |
  = note: see issue #54726 <https://github.com/rust-lang/rust/issues/54726> for more information

error[E0658]: non-inline modules in proc macro input are unstable
 --> src/lib.rs:1:1
  |
1 | mod compile;
  | ^^^^^^^^^^^^
  |
  = note: see issue #54727 <https://github.com/rust-lang/rust/issues/54727> for more information

error[E0658]: inner macro attributes are unstable
 --> src/do_not_compile.rs:1:4
  |
1 | #![is_not::not]
  |    ^^^^^^^^^^^
  |
  = note: see issue #54726 <https://github.com/rust-lang/rust/issues/54726> for more information

error[E0658]: non-inline modules in proc macro input are unstable
 --> src/lib.rs:2:1
  |
2 | mod do_not_compile;
  | ^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #54727 <https://github.com/rust-lang/rust/issues/54727> for more information

Version it worked on

It most recently worked on: Rust 1.51

Version with regression

rustc --version --verbose:

rustc 1.52.0 (88f19c6da 2021-05-03)
binary: rustc
commit-hash: 88f19c6dab716c6281af7602e30f413e809c5974
commit-date: 2021-05-03
host: x86_64-unknown-linux-gnu
release: 1.52.0
LLVM version: 12.0.0

@tylerhawkes tylerhawkes added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels May 6, 2021
@rustbot rustbot added I-prioritize Issue: Indicates that prioritization has been requested for this issue. regression-from-stable-to-stable Performance or correctness regression from one stable version to another. and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. regression-untriaged Untriaged performance or correctness regression. labels May 6, 2021
@Mark-Simulacrum Mark-Simulacrum added this to the 1.52.0 milestone May 7, 2021
@ehuss
Copy link
Contributor

ehuss commented May 7, 2021

I believe this was intended as part of #82399. It was unintentionally ignored in 1.44, and should have required feature(custom_inner_attributes).

@tylerhawkes
Copy link
Author

tylerhawkes commented May 7, 2021 via email

@apiraino apiraino removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jan 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. regression-from-stable-to-stable Performance or correctness regression from one stable version to another.
Projects
None yet
Development

No branches or pull requests

6 participants