Skip to content

Commit 523ab25

Browse files
committed
add test for #71450
1 parent 6e9f59f commit 523ab25

4 files changed

+110
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//@ check-pass
2+
3+
#![warn(unused_imports)]
4+
5+
mod foo {
6+
use std::fmt;
7+
8+
pub struct String;
9+
10+
impl String {
11+
pub fn new() -> String {
12+
String{}
13+
}
14+
}
15+
16+
impl fmt::Display for String {
17+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
18+
write!(f, "String")
19+
}
20+
}
21+
}
22+
23+
fn main() {
24+
25+
{
26+
use std::string::String; //~ WARNING the item `String` is imported redundantly
27+
// 'String' from 'std::string::String'.
28+
let s = String::new();
29+
println!("{}", s);
30+
}
31+
32+
{
33+
// 'String' from 'std::string::String'.
34+
let s = String::new();
35+
println!("{}", s);
36+
}
37+
38+
{
39+
use foo::*;
40+
// 'String' from 'foo::String'.
41+
let s = String::new();
42+
println!("{}", s);
43+
}
44+
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
warning: the item `String` is imported redundantly
2+
--> $DIR/use-redundant-issue-71450.rs:26:13
3+
|
4+
LL | use std::string::String;
5+
| ^^^^^^^^^^^^^^^^^^^
6+
--> $SRC_DIR/std/src/prelude/mod.rs:LL:COL
7+
|
8+
= note: the item `String` is already defined here
9+
|
10+
note: the lint level is defined here
11+
--> $DIR/use-redundant-issue-71450.rs:3:9
12+
|
13+
LL | #![warn(unused_imports)]
14+
| ^^^^^^^^^^^^^^
15+
16+
warning: 1 warning emitted
17+

tests/ui/lint/use-redundant/use-redundant-issue-78894.rs

+34
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
//@ check-pass
22
//@ edition:2018
3+
34
#![warn(unused_imports)]
45

6+
mod foo {
7+
macro_rules! foo1 {
8+
() => ();
9+
}
10+
11+
pub(crate) use foo1;
12+
}
13+
514
fn main ()
615
{
716
bar!();
@@ -11,4 +20,29 @@ fn main ()
1120
}
1221

1322
use bar;
23+
24+
mod m {
25+
bar1!();
26+
27+
macro_rules! bar1 {
28+
() => ();
29+
}
30+
31+
use bar1;
32+
}
33+
34+
{
35+
foo::foo1!();
36+
}
37+
38+
{
39+
use foo::foo1;
40+
foo1!();
41+
}
42+
43+
{
44+
use foo::foo1; //~ WARNING unused import: `foo::foo1`
45+
foo::foo1!();
46+
}
47+
1448
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
warning: unused import: `foo::foo1`
2+
--> $DIR/use-redundant-issue-78894.rs:44:13
3+
|
4+
LL | use foo::foo1;
5+
| ^^^^^^^^^
6+
|
7+
note: the lint level is defined here
8+
--> $DIR/use-redundant-issue-78894.rs:4:9
9+
|
10+
LL | #![warn(unused_imports)]
11+
| ^^^^^^^^^^^^^^
12+
13+
warning: 1 warning emitted
14+

0 commit comments

Comments
 (0)