about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2019-02-05 16:52:31 +0100
committervarkor <github@varkor.com>2019-02-07 15:02:17 +0100
commit06abaee21ba25b4d5ebaf014928269734ad9ee15 (patch)
tree86b46376647d03fded14732bb10e5bdf5c6a5dda
parent11874a0c14a1637a310f0088a2c91ceb2810f6dd (diff)
downloadrust-06abaee21ba25b4d5ebaf014928269734ad9ee15.tar.gz
rust-06abaee21ba25b4d5ebaf014928269734ad9ee15.zip
Add error for const parameters depending on type parameters
Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
-rw-r--r--src/librustc_resolve/diagnostics.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs
index 0db8689c0c1..a5f9124674a 100644
--- a/src/librustc_resolve/diagnostics.rs
+++ b/src/librustc_resolve/diagnostics.rs
@@ -414,8 +414,8 @@ https://doc.rust-lang.org/reference.html#use-declarations
 "##,
 
 E0401: r##"
-Inner items do not inherit type parameters from the functions they are embedded
-in.
+Inner items do not inherit type or const parameters from the functions
+they are embedded in.
 
 Erroneous code example:
 
@@ -1642,6 +1642,17 @@ fn main() {
 ```
 "##,
 
+E0670: r##"
+Const parameters cannot depend on type parameters.
+The following is therefore invalid:
+
+```
+fn const_id<T, const N: T>() -> T {
+    N
+}
+```
+"##,
+
 }
 
 register_diagnostics! {