1 //@aux-build:proc_macro_derive.rs
2 #![warn(clippy::std_instead_of_core)]
3 #![allow(unused_imports)]
8 extern crate proc_macro_derive;
10 #[warn(clippy::std_instead_of_core)]
11 fn std_instead_of_core() {
13 use core::hash::Hasher;
14 //~^ ERROR: used import from `std` instead of `core`
16 use ::core::hash::Hash;
17 //~^ ERROR: used import from `std` instead of `core`
18 // Don't lint on `env` macro
22 use core::fmt::{Debug, Result};
23 //~^ ERROR: used import from `std` instead of `core`
26 let ptr = core::ptr::null::<u32>();
27 //~^ ERROR: used import from `std` instead of `core`
28 let ptr_mut = ::core::ptr::null_mut::<usize>();
29 //~^ ERROR: used import from `std` instead of `core`
32 let cell = core::cell::Cell::new(8u32);
33 //~^ ERROR: used import from `std` instead of `core`
34 let cell_absolute = ::core::cell::Cell::new(8u32);
35 //~^ ERROR: used import from `std` instead of `core`
37 let _ = std::env!("PATH");
39 // do not lint until `error_in_core` is stable
40 use std::error::Error;
42 // lint items re-exported from private modules, `core::iter::traits::iterator::Iterator`
43 use core::iter::Iterator;
44 //~^ ERROR: used import from `std` instead of `core`
47 #[warn(clippy::std_instead_of_alloc)]
48 fn std_instead_of_alloc() {
51 //~^ ERROR: used import from `std` instead of `alloc`
53 //~^ ERROR: used import from `std` instead of `alloc`
56 #[warn(clippy::alloc_instead_of_core)]
57 fn alloc_instead_of_core() {
58 use core::slice::from_ref;
59 //~^ ERROR: used import from `alloc` instead of `core`
62 mod std_in_proc_macro_derive {
63 #[warn(clippy::alloc_instead_of_core)]
65 #[derive(ImplStructWithStdDisplay)]
70 std_instead_of_core();
71 std_instead_of_alloc();
72 alloc_instead_of_core();