]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/std_instead_of_core.rs
Auto merge of #98246 - joshtriplett:times, r=m-ou-se
[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
29 #[warn(clippy::std_instead_of_alloc)]
30 fn std_instead_of_alloc() {
31     // Only lint once.
32     use std::vec;
33     use std::vec::Vec;
34 }
35
36 #[warn(clippy::alloc_instead_of_core)]
37 fn alloc_instead_of_core() {
38     use alloc::slice::from_ref;
39 }
40
41 fn main() {
42     std_instead_of_core();
43     std_instead_of_alloc();
44     alloc_instead_of_core();
45 }