dump bugged fix

This commit is contained in:
MarcusGrass 2024-03-03 17:17:58 +01:00
parent 74cba639e9
commit a2e4ef294c
No known key found for this signature in database
GPG Key ID: B3F995FE064E3AA9
4 changed files with 32 additions and 14 deletions

View File

@ -109,7 +109,6 @@ impl<'tcx> LateLintPass<'tcx> for StdReexports {
sym::core => (STD_INSTEAD_OF_CORE, "std", "core"), sym::core => (STD_INSTEAD_OF_CORE, "std", "core"),
sym::alloc => (STD_INSTEAD_OF_ALLOC, "std", "alloc"), sym::alloc => (STD_INSTEAD_OF_ALLOC, "std", "alloc"),
_ => { _ => {
self.prev_span = first_segment.ident.span;
return; return;
}, },
}, },
@ -117,7 +116,6 @@ impl<'tcx> LateLintPass<'tcx> for StdReexports {
if cx.tcx.crate_name(def_id.krate) == sym::core { if cx.tcx.crate_name(def_id.krate) == sym::core {
(ALLOC_INSTEAD_OF_CORE, "alloc", "core") (ALLOC_INSTEAD_OF_CORE, "alloc", "core")
} else { } else {
self.prev_span = first_segment.ident.span;
return; return;
} }
}, },

View File

@ -17,7 +17,7 @@ fn std_instead_of_core() {
use ::core::hash::Hash; use ::core::hash::Hash;
//~^ ERROR: used import from `std` instead of `core` //~^ ERROR: used import from `std` instead of `core`
// Don't lint on `env` macro // Don't lint on `env` macro
use std::env; use core::env;
// Multiple imports // Multiple imports
use core::fmt::{Debug, Result}; use core::fmt::{Debug, Result};
@ -27,10 +27,14 @@ fn std_instead_of_core() {
#[rustfmt::skip] #[rustfmt::skip]
use core::{ use core::{
//~^ ERROR: used import from `std` instead of `core` //~^ ERROR: used import from `std` instead of `core`
fmt::Write, fmt::Write as _,
ptr::read_unaligned, ptr::read_unaligned,
}; };
// Multiline mixed imports
use core::{io::Write, fmt::Display};
//~^ ERROR: used import from `std` instead of `core`
// Function calls // Function calls
let ptr = core::ptr::null::<u32>(); let ptr = core::ptr::null::<u32>();
//~^ ERROR: used import from `std` instead of `core` //~^ ERROR: used import from `std` instead of `core`

View File

@ -27,10 +27,14 @@ fn std_instead_of_core() {
#[rustfmt::skip] #[rustfmt::skip]
use std::{ use std::{
//~^ ERROR: used import from `std` instead of `core` //~^ ERROR: used import from `std` instead of `core`
fmt::Write, fmt::Write as _,
ptr::read_unaligned, ptr::read_unaligned,
}; };
// Multiline mixed imports
use std::{io::Write, fmt::Display};
//~^ ERROR: used import from `std` instead of `core`
// Function calls // Function calls
let ptr = std::ptr::null::<u32>(); let ptr = std::ptr::null::<u32>();
//~^ ERROR: used import from `std` instead of `core` //~^ ERROR: used import from `std` instead of `core`

View File

@ -13,6 +13,12 @@ error: used import from `std` instead of `core`
LL | use ::std::hash::Hash; LL | use ::std::hash::Hash;
| ^^^ help: consider importing the item from `core`: `core` | ^^^ help: consider importing the item from `core`: `core`
error: used import from `std` instead of `core`
--> tests/ui/std_instead_of_core.rs:20:9
|
LL | use std::env;
| ^^^ help: consider importing the item from `core`: `core`
error: used import from `std` instead of `core` error: used import from `std` instead of `core`
--> tests/ui/std_instead_of_core.rs:23:9 --> tests/ui/std_instead_of_core.rs:23:9
| |
@ -26,37 +32,43 @@ LL | use std::{
| ^^^ help: consider importing the item from `core`: `core` | ^^^ help: consider importing the item from `core`: `core`
error: used import from `std` instead of `core` error: used import from `std` instead of `core`
--> tests/ui/std_instead_of_core.rs:35:15 --> tests/ui/std_instead_of_core.rs:35:9
|
LL | use std::{io::Write, fmt::Display};
| ^^^ help: consider importing the item from `core`: `core`
error: used import from `std` instead of `core`
--> tests/ui/std_instead_of_core.rs:39:15
| |
LL | let ptr = std::ptr::null::<u32>(); LL | let ptr = std::ptr::null::<u32>();
| ^^^ help: consider importing the item from `core`: `core` | ^^^ help: consider importing the item from `core`: `core`
error: used import from `std` instead of `core` error: used import from `std` instead of `core`
--> tests/ui/std_instead_of_core.rs:37:21 --> tests/ui/std_instead_of_core.rs:41:21
| |
LL | let ptr_mut = ::std::ptr::null_mut::<usize>(); LL | let ptr_mut = ::std::ptr::null_mut::<usize>();
| ^^^ help: consider importing the item from `core`: `core` | ^^^ help: consider importing the item from `core`: `core`
error: used import from `std` instead of `core` error: used import from `std` instead of `core`
--> tests/ui/std_instead_of_core.rs:41:16 --> tests/ui/std_instead_of_core.rs:45:16
| |
LL | let cell = std::cell::Cell::new(8u32); LL | let cell = std::cell::Cell::new(8u32);
| ^^^ help: consider importing the item from `core`: `core` | ^^^ help: consider importing the item from `core`: `core`
error: used import from `std` instead of `core` error: used import from `std` instead of `core`
--> tests/ui/std_instead_of_core.rs:43:27 --> tests/ui/std_instead_of_core.rs:47:27
| |
LL | let cell_absolute = ::std::cell::Cell::new(8u32); LL | let cell_absolute = ::std::cell::Cell::new(8u32);
| ^^^ help: consider importing the item from `core`: `core` | ^^^ help: consider importing the item from `core`: `core`
error: used import from `std` instead of `core` error: used import from `std` instead of `core`
--> tests/ui/std_instead_of_core.rs:52:9 --> tests/ui/std_instead_of_core.rs:56:9
| |
LL | use std::iter::Iterator; LL | use std::iter::Iterator;
| ^^^ help: consider importing the item from `core`: `core` | ^^^ help: consider importing the item from `core`: `core`
error: used import from `std` instead of `alloc` error: used import from `std` instead of `alloc`
--> tests/ui/std_instead_of_core.rs:59:9 --> tests/ui/std_instead_of_core.rs:63:9
| |
LL | use std::vec; LL | use std::vec;
| ^^^ help: consider importing the item from `alloc`: `alloc` | ^^^ help: consider importing the item from `alloc`: `alloc`
@ -65,13 +77,13 @@ LL | use std::vec;
= help: to override `-D warnings` add `#[allow(clippy::std_instead_of_alloc)]` = help: to override `-D warnings` add `#[allow(clippy::std_instead_of_alloc)]`
error: used import from `std` instead of `alloc` error: used import from `std` instead of `alloc`
--> tests/ui/std_instead_of_core.rs:61:9 --> tests/ui/std_instead_of_core.rs:65:9
| |
LL | use std::vec::Vec; LL | use std::vec::Vec;
| ^^^ help: consider importing the item from `alloc`: `alloc` | ^^^ help: consider importing the item from `alloc`: `alloc`
error: used import from `alloc` instead of `core` error: used import from `alloc` instead of `core`
--> tests/ui/std_instead_of_core.rs:67:9 --> tests/ui/std_instead_of_core.rs:71:9
| |
LL | use alloc::slice::from_ref; LL | use alloc::slice::from_ref;
| ^^^^^ help: consider importing the item from `core`: `core` | ^^^^^ help: consider importing the item from `core`: `core`
@ -79,5 +91,5 @@ LL | use alloc::slice::from_ref;
= note: `-D clippy::alloc-instead-of-core` implied by `-D warnings` = note: `-D clippy::alloc-instead-of-core` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::alloc_instead_of_core)]` = help: to override `-D warnings` add `#[allow(clippy::alloc_instead_of_core)]`
error: aborting due to 12 previous errors error: aborting due to 14 previous errors