Skip to content

#![crate_id="x"] attribute emits false (and useless) root module warning #43142

Closed
@pnkfelix

Description

@pnkfelix

(Spawned off of issue #43106)

Compiling this code (in stable/beta/nightly) results in the following compiler warnings:

#![crate_id = "x"]
fn main() { }

warnings:

warning: unused attribute
 --> <anon>:1:1
  |
1 | #![crate_id = "x"]
  | ^^^^^^^^^^^^^^^^^^
  |
  = note: #[warn(unused_attributes)] on by default

warning: crate-level attribute should be in the root module
 --> <anon>:1:1
  |
1 | #![crate_id = "x"]
  | ^^^^^^^^^^^^^^^^^^

The first warning is legitimate, since we killed off #![crate_id] back in RFC 109. The fact that it exists as an attribute in the code base is probably for backwards compatibility.

  • (The fact that it still has occurrences in the run-pass test suite is less explicable, since it should have no effect in the current rustc...)

The second warning is quite confusing, since the attribute is in the root module.

Can we easily kill off the second warning in this case?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions