-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix redundant import errors for preload extern crate
- Loading branch information
1 parent
62415e2
commit ac035e7
Showing
19 changed files
with
246 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub fn item() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
//@ compile-flags: --extern aux_issue_121915 --edition 2015 | ||
//@ aux-build: aux-issue-121915.rs | ||
|
||
extern crate aux_issue_121915; | ||
|
||
#[deny(unused_imports)] | ||
fn main() { | ||
use aux_issue_121915; | ||
//~^ ERROR the item `aux_issue_121915` is imported redundantly | ||
aux_issue_121915::item(); | ||
} |
17 changes: 17 additions & 0 deletions
17
tests/ui/imports/redundant-import-issue-121915-2015.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
error: the item `aux_issue_121915` is imported redundantly | ||
--> $DIR/redundant-import-issue-121915-2015.rs:8:9 | ||
| | ||
LL | extern crate aux_issue_121915; | ||
| ------------------------------ the item `aux_issue_121915` is already imported here | ||
... | ||
LL | use aux_issue_121915; | ||
| ----^^^^^^^^^^^^^^^^- help: remove this import | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/redundant-import-issue-121915-2015.rs:6:8 | ||
| | ||
LL | #[deny(unused_imports)] | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
//@ compile-flags: --extern aux_issue_121915 --edition 2018 | ||
//@ aux-build: aux-issue-121915.rs | ||
|
||
#[deny(unused_imports)] | ||
fn main() { | ||
use aux_issue_121915; | ||
//~^ ERROR the item `aux_issue_121915` is imported redundantly | ||
aux_issue_121915::item(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
error: the item `aux_issue_121915` is imported redundantly | ||
--> $DIR/redundant-import-issue-121915.rs:6:9 | ||
| | ||
LL | use aux_issue_121915; | ||
| ----^^^^^^^^^^^^^^^^- | ||
| | | | ||
| | the item `aux_issue_121915` is already defined by prelude | ||
| help: remove this import | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/redundant-import-issue-121915.rs:4:8 | ||
| | ||
LL | #[deny(unused_imports)] | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//@ run-rustfix | ||
//@ compile-flags: --edition 2021 | ||
#![deny(unused_imports)] | ||
#![allow(dead_code)] | ||
|
||
// Test remove FlatUnused | ||
//~^ ERROR the item `TryFrom` is imported redundantly | ||
|
||
// Test remove NestedFullUnused | ||
//~^ ERROR the item `TryInto` is imported redundantly | ||
|
||
// Test remove NestedPartialUnused | ||
use std::convert::{Infallible}; | ||
//~^ ERROR the item `From` is imported redundantly | ||
|
||
// Test remove both redundant and unused? | ||
// use std::convert::{AsMut, Into}; | ||
|
||
trait MyTrait {} | ||
impl MyTrait for fn() -> Infallible {} | ||
|
||
fn main() { | ||
let _ = u32::try_from(5i32); | ||
let _a: i32 = u32::try_into(5u32).unwrap(); | ||
let _a: String = String::from("hello anan"); | ||
//let _a: u32 = (5i32).into(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//@ run-rustfix | ||
//@ compile-flags: --edition 2021 | ||
#![deny(unused_imports)] | ||
#![allow(dead_code)] | ||
|
||
// Test remove FlatUnused | ||
use std::convert::TryFrom; | ||
//~^ ERROR the item `TryFrom` is imported redundantly | ||
|
||
// Test remove NestedFullUnused | ||
use std::convert::{TryInto}; | ||
//~^ ERROR the item `TryInto` is imported redundantly | ||
|
||
// Test remove NestedPartialUnused | ||
use std::convert::{From, Infallible}; | ||
//~^ ERROR the item `From` is imported redundantly | ||
|
||
// Test remove both redundant and unused? | ||
// use std::convert::{AsMut, Into}; | ||
|
||
trait MyTrait {} | ||
impl MyTrait for fn() -> Infallible {} | ||
|
||
fn main() { | ||
let _ = u32::try_from(5i32); | ||
let _a: i32 = u32::try_into(5u32).unwrap(); | ||
let _a: String = String::from("hello anan"); | ||
//let _a: u32 = (5i32).into(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
error: the item `TryFrom` is imported redundantly | ||
--> $DIR/suggest-remove-issue-121315.rs:7:5 | ||
| | ||
LL | use std::convert::TryFrom; | ||
| ----^^^^^^^^^^^^^^^^^^^^^- help: remove this import | ||
--> $SRC_DIR/std/src/prelude/mod.rs:LL:COL | ||
| | ||
= note: the item `TryFrom` is already defined here | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/suggest-remove-issue-121315.rs:3:9 | ||
| | ||
LL | #![deny(unused_imports)] | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: the item `TryInto` is imported redundantly | ||
--> $DIR/suggest-remove-issue-121315.rs:11:20 | ||
| | ||
LL | use std::convert::{TryInto}; | ||
| -------------------^^^^^^^-- help: remove this import | ||
--> $SRC_DIR/std/src/prelude/mod.rs:LL:COL | ||
| | ||
= note: the item `TryInto` is already defined here | ||
|
||
error: the item `From` is imported redundantly | ||
--> $DIR/suggest-remove-issue-121315.rs:15:20 | ||
| | ||
LL | use std::convert::{From, Infallible}; | ||
| ^^^^-- | ||
| | | ||
| help: remove this import | ||
--> $SRC_DIR/std/src/prelude/mod.rs:LL:COL | ||
| | ||
= note: the item `From` is already defined here | ||
|
||
error: aborting due to 3 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.