File tree 2 files changed +62
-0
lines changed
tests/ui/lint/use-redundant
2 files changed +62
-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
+
You can’t perform that action at this time.
0 commit comments