Skip to content

edition compatibility lints: Warning about dyn in a macro incorrectly #56327

Closed

Description

This code:

#![warn(rust_2018_compatibility)]

macro_rules! foo {
    () => {
        fn _foo() {
            let _x: Box<dyn Drop>;
        }
    }
}

foo!();

when compiled under 2015 edition yields:

warning: `dyn` is a keyword in the 2018 edition
 --> src/lib.rs:6:25
  |
6 |             let _x: Box<dyn Drop>;
  |                         ^^^ help: you can use a raw identifier to stay compatible: `r#dyn`
  |
note: lint level defined here
 --> src/lib.rs:1:9
  |
1 | #![warn(rust_2018_compatibility)]
  |         ^^^^^^^^^^^^^^^^^^^^^^^
  = note: #[warn(keyword_idents)] implied by #[warn(rust_2018_compatibility)]
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
  = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>

but the warning and suggestion are incorrect!

First reported at rust-lang/cargo#6359

This also applies to macro invocations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

A-edition-2018-lintsArea: Lints supporting the 2018 editionA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`P-mediumMedium priorityT-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