rust-lang / rust-lang/rust-clippy
warning: used import from `std` instead of `core` in external macros
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Summary
When enabling std_instead_of_core, the warning is emitted for code derived using derive macros.
This is likely not the desired behavior since there is a check using in_external_macro in the implementation.
Lint Name
std_instead_of_core
Reproducer
I tried this code:
#![warn(clippy::std_instead_of_core)]
use arbitrary::Arbitrary;
#[derive(Arbitrary)]
pub struct SomeStruct;
I saw this happen:
warning: used import from `std` instead of `core`
--> crates/ironvnc-core/src/pixel_format.rs:10:42
|
10 | #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
| ^^^^^^^^^^^^^^^^^^^^
|
= help: consider importing the item from `core`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#std_instead_of_core
= note: this warning originates in the derive macro `arbitrary::Arbitrary` (in Nightly builds, run with -Z macro-backtrace for more info)
I expected to see this happen: no warning
Version
rustc 1.74.0 (79e9716c9 2023-11-13)
binary: rustc
commit-hash: 79e9716c980570bfd1f666e3b16ac583f0168962
commit-date: 2023-11-13
host: x86_64-unknown-linux-gnu
release: 1.74.0
LLVM version: 17.0.4
Additional Labels
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the std_instead_of_core lint implementation and its in_external_macro check. Reproduce the derive-macro example from the issue, then verify that code generated by the external macro no longer produces the warning while direct std imports remain checked.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100