about summary refs log tree commit diff
path: root/compiler/rustc_error_codes/src
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2024-07-13 18:32:10 +0200
committerRalf Jung <post@ralfj.de>2024-07-18 11:58:16 +0200
commit67c99d6338922d270108fc6390d3ad5224b3a7e1 (patch)
treeea8ed203cc783a23f8e49e2d403b20728b511e0d /compiler/rustc_error_codes/src
parent86ce911f90d9498b33738655c8cfed2f637c335a (diff)
avoid creating an Instance only to immediately disassemble it again
Diffstat (limited to 'compiler/rustc_error_codes/src')
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0158.md17
1 files changed, 8 insertions, 9 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0158.md b/compiler/rustc_error_codes/src/error_codes/E0158.md
index 03b93d925c1..c31f1e13bee 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0158.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0158.md
@@ -1,5 +1,4 @@
-An associated `const`, `const` parameter or `static` has been referenced
-in a pattern.
+A generic parameter or `static` has been referenced in a pattern.
 
 Erroneous code example:
 
@@ -15,25 +14,25 @@ trait Bar {
 
 fn test<A: Bar>(arg: Foo) {
     match arg {
-        A::X => println!("A::X"), // error: E0158: associated consts cannot be
-                                  //        referenced in patterns
+        A::X => println!("A::X"), // error: E0158: constant pattern depends
+                                  //        on a generic parameter
         Foo::Two => println!("Two")
     }
 }
 ```
 
-Associated `const`s cannot be referenced in patterns because it is impossible
+Generic parameters cannot be referenced in patterns because it is impossible
 for the compiler to prove exhaustiveness (that some pattern will always match).
 Take the above example, because Rust does type checking in the *generic*
 method, not the *monomorphized* specific instance. So because `Bar` could have
-theoretically infinite implementations, there's no way to always be sure that
+theoretically arbitrary implementations, there's no way to always be sure that
 `A::X` is `Foo::One`. So this code must be rejected. Even if code can be
 proven exhaustive by a programmer, the compiler cannot currently prove this.
 
-The same holds true of `const` parameters and `static`s.
+The same holds true of `static`s.
 
-If you want to match against an associated `const`, `const` parameter or
-`static` consider using a guard instead:
+If you want to match against a `const` that depends on a generic parameter or a
+`static`, consider using a guard instead:
 
 ```
 trait Trait {