Skip to content

std_instead_of_core error with thiserror::Error #10198

@BratSinot

Description

@BratSinot

Summary

This isn't actually a false positive, because macro is expanded. But, may be some additional rules for macros from outside?

Lint Name

clippy::std_instead_of_core

Reproducer

I tried this code:

#![warn(clippy::std_instead_of_core)]

#[derive(Debug, thiserror::Error)]
enum Error {
    #[error("empty")]
    Empty,
}

fn main() {
    let _ = Error::Empty;
}

I saw this happen:

warning: used import from `std` instead of `core`
 --> src/main.rs:3:17
  |
3 | #[derive(Debug, thiserror::Error)]
  |                 ^^^^^^^^^^^^^^^^
  |
  = 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: the lint level is defined here
 --> src/main.rs:1:9
  |
1 | #![warn(clippy::std_instead_of_core)]
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  = note: this warning originates in the derive macro `thiserror::Error` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: 1 warning emitted

    Finished dev [unoptimized + debuginfo] target(s) in 0.43s
Process finished with exit code 0

Version

rustc 1.66.1 (90743e729 2023-01-10)
binary: rustc
commit-hash: 90743e7298aca107ddaa0c202a4d3604e29bfeb6
commit-date: 2023-01-10
host: x86_64-apple-darwin
release: 1.66.1
LLVM version: 15.0.2

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions