@@ -329,6 +329,48 @@ loop. Without a loop to break out of or continue in, no sensible action can be
329
329
taken.
330
330
"## ,
331
331
332
+ E0271 : r##"
333
+ This is because of a type mismatch, that happens to involve a constraint that
334
+ forces the associated type of some particular trait to be equivalent to some
335
+ other type. Examples:
336
+ ```
337
+ // example 1:
338
+ let vs = vec![1, 2, 3, 4];
339
+ for v in &vs {
340
+ match v {
341
+ 1 => {}
342
+ _ => {}
343
+ }
344
+ }
345
+ //example 2:
346
+ trait Trait { type AssociatedType; }
347
+ impl Trait for i8 { type AssociatedType = &'static str; }
348
+ fn foo<T>(t: T) where T: Trait<AssociatedType=u32> {
349
+ println!("in foo");
350
+ }
351
+ foo(3i8);
352
+ ```
353
+ To avoid those issues, you have to make the types match correctly. So we can
354
+ fix the previous examples like this:
355
+ ```
356
+ // example 1:
357
+ let vs = vec![1, 2, 3, 4];
358
+ for v in &vs {
359
+ match v {
360
+ &1 => {}
361
+ _ => {}
362
+ }
363
+ }
364
+ //example 2:
365
+ trait Trait { type AssociatedType; }
366
+ impl Trait for i8 { type AssociatedType = &'static str; }
367
+ fn foo<T>(t: T) where T: Trait<AssociatedType = &'static str> {
368
+ println!("in foo");
369
+ }
370
+ foo(3i8);
371
+ ```
372
+ "## ,
373
+
332
374
E0296 : r##"
333
375
This error indicates that the given recursion limit could not be parsed. Ensure
334
376
that the value provided is a positive integer between quotes, like so:
@@ -456,7 +498,6 @@ register_diagnostics! {
456
498
E0266 , // expected item
457
499
E0269 , // not all control paths return a value
458
500
E0270 , // computation may converge in a function marked as diverging
459
- E0271 , // type mismatch resolving
460
501
E0272 , // rustc_on_unimplemented attribute refers to non-existent type parameter
461
502
E0273 , // rustc_on_unimplemented must have named format arguments
462
503
E0274 , // rustc_on_unimplemented must have a value
0 commit comments