Skip to content

Commit 06abaee

Browse files
varkoryodaldevoid
andcommitted
Add error for const parameters depending on type parameters
Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
1 parent 11874a0 commit 06abaee

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/librustc_resolve/diagnostics.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,8 @@ https://doc.rust-lang.org/reference.html#use-declarations
414414
"##,
415415

416416
E0401: r##"
417-
Inner items do not inherit type parameters from the functions they are embedded
418-
in.
417+
Inner items do not inherit type or const parameters from the functions
418+
they are embedded in.
419419
420420
Erroneous code example:
421421
@@ -1642,6 +1642,17 @@ fn main() {
16421642
```
16431643
"##,
16441644

1645+
E0670: r##"
1646+
Const parameters cannot depend on type parameters.
1647+
The following is therefore invalid:
1648+
1649+
```
1650+
fn const_id<T, const N: T>() -> T {
1651+
N
1652+
}
1653+
```
1654+
"##,
1655+
16451656
}
16461657

16471658
register_diagnostics! {

0 commit comments

Comments
 (0)