]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/std_instead_of_core.rs
Auto merge of #99182 - RalfJung:mitigate-uninit, r=scottmcm
[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
13     // Multiple imports
14     use std::fmt::{Debug, Result};
15
16     // Function calls
17     let ptr = std::ptr::null::<u32>();
18     let ptr_mut = ::std::ptr::null_mut::<usize>();
19
20     // Types
21     let cell = std::cell::Cell::new(8u32);
22     let cell_absolute = ::std::cell::Cell::new(8u32);
23 }
24
25 #[warn(clippy::std_instead_of_alloc)]
26 fn std_instead_of_alloc() {
27     use std::vec::Vec;
28 }
29
30 #[warn(clippy::alloc_instead_of_core)]
31 fn alloc_instead_of_core() {
32     use alloc::slice::from_ref;
33 }
34
35 fn main() {
36     std_instead_of_core();
37     std_instead_of_alloc();
38     alloc_instead_of_core();
39 }