]> git.lizzy.rs Git - rust.git/commitdiff
add explanation for E0429 (`self` use declaration must use brace syntax)
authorZack M. Davis <code@zackmdavis.net>
Mon, 30 May 2016 00:50:08 +0000 (17:50 -0700)
committerZack M. Davis <code@zackmdavis.net>
Mon, 30 May 2016 00:52:18 +0000 (17:52 -0700)
This is an item under #32777.

src/librustc_resolve/diagnostics.rs

index 351486220528952eae1c86f36257182369671e96..177a85709e445ca6aa902a36a0e966d29c67a5d8 100644 (file)
@@ -1029,6 +1029,32 @@ mod something_that_does_exist {
 ```
 "##,
 
+E0429: r##"
+To import a namespace itself in addition to some of its members, the `self`
+keyword may appear in a brace-enclosed list as the last segment in a `use`
+declaration. However, `self` cannot be used alone, without the brace
+syntax.
+
+Example of erroneous code:
+
+```compile_fail
+use std::fmt::self; // error: `self` imports are only allowed within a { } list
+```
+
+If you only want to import the namespace, do so directly:
+
+```
+use std::fmt;
+```
+
+If you also want to import members in the same statement, you may use the brace
+syntax:
+
+```
+use std::fmt::{self, Debug};
+```
+"##,
+
 E0430: r##"
 The `self` import appears more than once in the list. Erroneous code example:
 
@@ -1235,5 +1261,4 @@ impl Foo for i32 {}
     E0420, // is not an associated const
     E0421, // unresolved associated const
     E0427, // cannot use `ref` binding mode with ...
-    E0429, // `self` imports are only allowed within a { } list
 }