File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -126,6 +126,24 @@ attributes:
126
126
See also https://doc.rust-lang.org/book/no-stdlib.html
127
127
"## ,
128
128
129
+ E0158 : r##"
130
+ `const` and `static` mean different things. A `const` is a compile-time
131
+ constant, an alias for a literal value. This property means you can match it
132
+ directly within a pattern.
133
+
134
+ The `static` keyword, on the other hand, guarantees a fixed location in memory.
135
+ This does not always mean that the value is constant. For example, a global
136
+ mutex can be declared `static` as well.
137
+
138
+ If you want to match against a `static`, consider using a guard instead:
139
+
140
+ static FORTY_TWO: i32 = 42;
141
+ match Some(42) {
142
+ Some(x) if x == FORTY_TWO => ...
143
+ ...
144
+ }
145
+ "## ,
146
+
129
147
E0162 : r##"
130
148
An if-let pattern attempts to match the pattern, and enters the body if the
131
149
match was succesful. If the match is irrefutable (when it cannot fail to match),
@@ -270,7 +288,6 @@ register_diagnostics! {
270
288
E0137 ,
271
289
E0138 ,
272
290
E0139 ,
273
- E0158 ,
274
291
E0161 ,
275
292
E0170 ,
276
293
E0261 , // use of undeclared lifetime name
You can’t perform that action at this time.
0 commit comments