Skip to content

Commit a2b7dfa

Browse files
committed
add explanation for E0429 (self use declaration must use brace syntax)
This is an item under rust-lang#32777.
1 parent a2a8694 commit a2b7dfa

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

src/librustc_resolve/diagnostics.rs

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

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

0 commit comments

Comments
 (0)