]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_typeck/error_codes.rs
Auto merge of #61492 - RalfJung:const-qualif-comments, r=eddyb
[rust.git] / src / librustc_typeck / error_codes.rs
index fdca3230904a8124e0f805de3a7e6f1deb5657d2..66e9a6e6b2a2e4ae9a943ca7495a7aec8ca1d83b 100644 (file)
@@ -1482,8 +1482,8 @@ fn drop(&mut self) {}
 "##,
 
 E0121: r##"
-In order to be consistent with Rust's lack of global type inference, type
-placeholders are disallowed by design in item signatures.
+In order to be consistent with Rust's lack of global type inference,
+type and const placeholders are disallowed by design in item signatures.
 
 Examples of this error include:
 
@@ -1942,9 +1942,11 @@ impl Copy for &'static mut Bar { } // error
 Any type parameter or lifetime parameter of an `impl` must meet at least one of
 the following criteria:
 
- - it appears in the self type of the impl
- - for a trait impl, it appears in the trait reference
- - it is bound as an associated type
+ - it appears in the _implementing type_ of the impl, e.g. `impl<T> Foo<T>`
+ - for a trait impl, it appears in the _implemented trait_, e.g.
+   `impl<T> SomeTrait<T> for Foo`
+ - it is bound as an associated type, e.g. `impl<T, U> SomeTrait for T
+   where T: AnotherTrait<AssocType=U>`
 
 ### Error example 1
 
@@ -1963,9 +1965,9 @@ fn get(&self) -> T {
 }
 ```
 
-The problem is that the parameter `T` does not appear in the self type (`Foo`)
-of the impl. In this case, we can fix the error by moving the type parameter
-from the `impl` to the method `get`:
+The problem is that the parameter `T` does not appear in the implementing type
+(`Foo`) of the impl. In this case, we can fix the error by moving the type
+parameter from the `impl` to the method `get`:
 
 
 ```
@@ -4646,6 +4648,38 @@ fn make_recursive_type() -> impl Sized {
 ```
 "##,
 
+E0730: r##"
+An array without a fixed length was pattern-matched.
+
+Example of erroneous code:
+
+```compile_fail,E0730
+#![feature(const_generics)]
+
+fn is_123<const N: usize>(x: [u32; N]) -> bool {
+    match x {
+        [1, 2, 3] => true, // error: cannot pattern-match on an
+                           //        array without a fixed length
+        _ => false
+    }
+}
+```
+
+Ensure that the pattern is consistent with the size of the matched
+array. Additional elements can be matched with `..`:
+
+```
+#![feature(slice_patterns)]
+
+let r = &[1, 2, 3, 4];
+match r {
+    &[a, b, ..] => { // ok!
+        println!("a={}, b={}", a, b);
+    }
+}
+```
+"##,
+
 }
 
 register_diagnostics! {