Skip to content

Commit 0e98d1d

Browse files
committed
Rollup merge of rust-lang#33955 - zackmdavis:explain_E0429, r=GuillaumeGomez
add explanation for E0429 (`self` use declaration must use brace syntax) This is an item under rust-lang#32777. r? @GuillaumeGomez
2 parents a8ab762 + 06ebda8 commit 0e98d1d

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

src/librustc_resolve/diagnostics.rs

+24-1
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,30 @@ struct Bar2; // ok!
10291029
```
10301030
"##,
10311031

1032+
E0429: r##"
1033+
The `self` keyword cannot appear alone as the last segment in a `use`
1034+
declaration.
1035+
1036+
Example of erroneous code:
1037+
1038+
```compile_fail
1039+
use std::fmt::self; // error: `self` imports are only allowed within a { } list
1040+
```
1041+
1042+
To use a namespace itself in addition to some of its members, `self` may appear
1043+
as part of a brace-enclosed list of imports:
1044+
1045+
```
1046+
use std::fmt::{self, Debug};
1047+
```
1048+
1049+
If you only want to import the namespace, do so directly:
1050+
1051+
```
1052+
use std::fmt;
1053+
```
1054+
"##,
1055+
10321056
E0430: r##"
10331057
The `self` import appears more than once in the list. Erroneous code example:
10341058
@@ -1235,5 +1259,4 @@ register_diagnostics! {
12351259
E0420, // is not an associated const
12361260
E0421, // unresolved associated const
12371261
E0427, // cannot use `ref` binding mode with ...
1238-
E0429, // `self` imports are only allowed within a { } list
12391262
}

0 commit comments

Comments
 (0)