Skip to content

Commit 84ef869

Browse files
committed
rustc: Add long diagnostics for E0170
1 parent 5c26228 commit 84ef869

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

src/librustc/diagnostics.rs

+26-1
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,32 @@ loop {
191191
}
192192
"##,
193193

194+
E0170: r##"
195+
Enum variants are qualified by default. For example, given this type:
196+
197+
enum Method {
198+
GET,
199+
POST
200+
}
201+
202+
you would match it using:
203+
204+
match m {
205+
Method::GET => ...
206+
Method::POST => ...
207+
}
208+
209+
If you don't qualify the names, the code will bind new variables named "GET" and
210+
"POST" instead. This behavior is likely not what you want, so rustc warns when
211+
that happens.
212+
213+
Qualified names are good practice, and most code works well with them. But if
214+
you prefer them unqualified, you can import the variants into scope:
215+
216+
use Method::*;
217+
enum Method { GET, POST }
218+
"##,
219+
194220
E0297: r##"
195221
Patterns used to bind names must be irrefutable. That is, they must guarantee
196222
that a name will be extracted in all cases. Instead of pattern matching the
@@ -296,7 +322,6 @@ register_diagnostics! {
296322
E0137,
297323
E0138,
298324
E0139,
299-
E0170,
300325
E0261, // use of undeclared lifetime name
301326
E0262, // illegal lifetime parameter name
302327
E0263, // lifetime name declared twice in same scope

0 commit comments

Comments
 (0)