Skip to content

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

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

Open
jyn514 opened this issue Apr 5, 2021 · 0 comments
Open

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

jyn514 opened this issue Apr 5, 2021 · 0 comments
Labels
A-edition-2018 Area: The 2018 edition A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jyn514
Copy link
Member

jyn514 commented Apr 5, 2021

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

@jyn514 jyn514 added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. A-edition-2018-lints labels Apr 5, 2021
@fmease fmease added A-edition-2018 Area: The 2018 edition and removed A-edition-2018-lints labels Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-edition-2018 Area: The 2018 edition A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants