forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#121958 - chenyukang:yukang-fix-121915-import, r=petrochenkov Fix redundant import errors for preload extern crate Fixes rust-lang#121915
- Loading branch information
Showing
10 changed files
with
230 additions
and
72 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
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; | ||
| ^^^^^^^^^^^^^^^^ | ||
| | ||
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,14 @@ | ||
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 | ||
| | ||
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,40 @@ | ||
//@ compile-flags: --edition 2021 | ||
#![deny(unused_imports)] | ||
#![allow(dead_code)] | ||
|
||
fn test0() { | ||
// Test remove FlatUnused | ||
use std::convert::TryFrom; | ||
//~^ ERROR the item `TryFrom` is imported redundantly | ||
let _ = u32::try_from(5i32); | ||
} | ||
|
||
fn test1() { | ||
// FIXME(yukang) Test remove NestedFullUnused | ||
use std::convert::{TryFrom, TryInto}; | ||
//~^ ERROR the item `TryFrom` is imported redundantly | ||
//~| ERROR the item `TryInto` is imported redundantly | ||
|
||
let _ = u32::try_from(5i32); | ||
let _a: i32 = u32::try_into(5u32).unwrap(); | ||
} | ||
|
||
fn test2() { | ||
// FIXME(yukang): Test remove both redundant and unused | ||
use std::convert::{AsMut, Into}; | ||
//~^ ERROR unused import: `AsMut` | ||
//~| ERROR the item `Into` is imported redundantly | ||
|
||
let _a: u32 = (5u8).into(); | ||
} | ||
|
||
fn test3() { | ||
// Test remove NestedPartialUnused | ||
use std::convert::{From, Infallible}; | ||
//~^ ERROR unused import: `From` | ||
|
||
trait MyTrait {} | ||
impl MyTrait for fn() -> Infallible {} | ||
} | ||
|
||
fn main() {} |
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,56 @@ | ||
error: the item `TryFrom` is imported redundantly | ||
--> $DIR/suggest-remove-issue-121315.rs:7:9 | ||
| | ||
LL | use std::convert::TryFrom; | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
--> $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:2:9 | ||
| | ||
LL | #![deny(unused_imports)] | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: the item `TryFrom` is imported redundantly | ||
--> $DIR/suggest-remove-issue-121315.rs:14:24 | ||
| | ||
LL | use std::convert::{TryFrom, TryInto}; | ||
| ^^^^^^^ | ||
--> $SRC_DIR/std/src/prelude/mod.rs:LL:COL | ||
| | ||
= note: the item `TryFrom` is already defined here | ||
|
||
error: the item `TryInto` is imported redundantly | ||
--> $DIR/suggest-remove-issue-121315.rs:14:33 | ||
| | ||
LL | use std::convert::{TryFrom, TryInto}; | ||
| ^^^^^^^ | ||
--> $SRC_DIR/std/src/prelude/mod.rs:LL:COL | ||
| | ||
= note: the item `TryInto` is already defined here | ||
|
||
error: unused import: `AsMut` | ||
--> $DIR/suggest-remove-issue-121315.rs:24:24 | ||
| | ||
LL | use std::convert::{AsMut, Into}; | ||
| ^^^^^ | ||
|
||
error: the item `Into` is imported redundantly | ||
--> $DIR/suggest-remove-issue-121315.rs:24:31 | ||
| | ||
LL | use std::convert::{AsMut, Into}; | ||
| ^^^^ | ||
--> $SRC_DIR/std/src/prelude/mod.rs:LL:COL | ||
| | ||
= note: the item `Into` is already defined here | ||
|
||
error: unused import: `From` | ||
--> $DIR/suggest-remove-issue-121315.rs:33:24 | ||
| | ||
LL | use std::convert::{From, Infallible}; | ||
| ^^^^ | ||
|
||
error: aborting due to 6 previous errors | ||
|