]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/std_instead_of_core.rs
make const_err a hard error
[rust.git] / src / tools / clippy / tests / ui / std_instead_of_core.rs
1 #![warn(clippy::std_instead_of_core)]
2 #![allow(unused_imports)]
3
4 extern crate alloc;
5
6 #[warn(clippy::std_instead_of_core)]
7 fn std_instead_of_core() {
8     // Regular import
9     use std::hash::Hasher;
10     // Absolute path
11     use ::std::hash::Hash;
12     // Don't lint on `env` macro
13     use std::env;
14
15     // Multiple imports
16     use std::fmt::{Debug, Result};
17
18     // Function calls
19     let ptr = std::ptr::null::<u32>();
20     let ptr_mut = ::std::ptr::null_mut::<usize>();
21
22     // Types
23     let cell = std::cell::Cell::new(8u32);
24     let cell_absolute = ::std::cell::Cell::new(8u32);
25
26     let _ = std::env!("PATH");
27
28     // do not lint until `error_in_core` is stable
29     use std::error::Error;
30
31     // lint items re-exported from private modules, `core::iter::traits::iterator::Iterator`
32     use std::iter::Iterator;
33 }
34
35 #[warn(clippy::std_instead_of_alloc)]
36 fn std_instead_of_alloc() {
37     // Only lint once.
38     use std::vec;
39     use std::vec::Vec;
40 }
41
42 #[warn(clippy::alloc_instead_of_core)]
43 fn alloc_instead_of_core() {
44     use alloc::slice::from_ref;
45 }
46
47 fn main() {
48     std_instead_of_core();
49     std_instead_of_alloc();
50     alloc_instead_of_core();
51 }