Add error for const parameters depending on type parameters
Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
This commit is contained in:
parent
11874a0c14
commit
06abaee21b
1 changed files with 13 additions and 2 deletions
|
@ -414,8 +414,8 @@ https://doc.rust-lang.org/reference.html#use-declarations
|
||||||
"##,
|
"##,
|
||||||
|
|
||||||
E0401: r##"
|
E0401: r##"
|
||||||
Inner items do not inherit type parameters from the functions they are embedded
|
Inner items do not inherit type or const parameters from the functions
|
||||||
in.
|
they are embedded in.
|
||||||
|
|
||||||
Erroneous code example:
|
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! {
|
register_diagnostics! {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue