Skip to content

Incorrect 'unused extern crate warning' with extern crate alloc #83888

Open
@jyn514

Description

@jyn514

I tried this code:

#![no_std]
#![feature(vec_spare_capacity)]
extern crate alloc;

I expected to see this happen: No warning, because removing the extern crate gives an error:

error[E0635]: unknown feature `vec_spare_capacity`
 --> tmp.rs:2:12
  |
2 | #![feature(vec_spare_capacity)]
  |            ^^^^^^^^^^^^^^^^^^

Instead, this happened:

error: unused extern crate
 --> tmp.rs:2:1
  |
2 | extern crate alloc;
  | ^^^^^^^^^^^^^^^^^^^ help: remove it
  |
  = note: requested on the command line with `-D unused-extern-crates`

I think either the lint shouldn't fire or the compiler should somehow know the available feature gates ahead of time.

Meta

rustc --version --verbose:

rustc 1.53.0-nightly (138fd56cf 2021-04-02)
binary: rustc
commit-hash: 138fd56cf9598b4bf016634c768dca128a83a5d7
commit-date: 2021-04-02
host: x86_64-unknown-linux-gnu
release: 1.53.0-nightly
LLVM version: 12.0.0

cc rust-lang/stdarch#1108

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-edition-2018Area: The 2018 editionA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.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