File tree 4 files changed +124
-0
lines changed
tests/ui/lint/use-redundant
4 files changed +124
-0
lines changed Original file line number Diff line number Diff line change
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 number Diff line number Diff line change
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
+
Original file line number Diff line number Diff line change
1
+ //@ check-pass
2
+ //@ edition:2018
3
+
4
+ #![ warn( unused_imports) ]
5
+
6
+ mod foo {
7
+ macro_rules! foo1 {
8
+ ( ) => ( ) ;
9
+ }
10
+
11
+ pub ( crate ) use foo1;
12
+ }
13
+
14
+ fn main ( )
15
+ {
16
+ bar ! ( ) ;
17
+
18
+ macro_rules! bar {
19
+ ( ) => ( ) ;
20
+ }
21
+
22
+ 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
+
48
+ }
Original file line number Diff line number Diff line change
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
+
You can’t perform that action at this time.
0 commit comments