feature(const_generics) -> feature(const_param_types)

This commit is contained in:
lcnr 2021-08-27 18:04:57 +02:00
parent c0e853f274
commit 0c28e028b6
574 changed files with 849 additions and 4305 deletions

View file

@ -4,8 +4,6 @@ Const parameters cannot depend on type parameters.
The following is therefore invalid:
```compile_fail,E0770
#![feature(const_generics)]
fn const_id<T, const N: T>() -> T { // error
N
}

View file

@ -3,7 +3,7 @@ A non-structural-match type was used as the type of a const generic parameter.
Erroneous code example:
```compile_fail,E0741
#![feature(const_generics)]
#![feature(const_param_types)]
struct A;
@ -16,7 +16,7 @@ may be used as the types of const generic parameters.
To fix the previous code example, we derive `PartialEq` and `Eq`:
```
#![feature(const_generics)]
#![feature(const_param_types)]
#[derive(PartialEq, Eq)] // We derive both traits here.
struct A;

View file

@ -3,7 +3,6 @@ The type of a const parameter references other generic parameters.
Erroneous code example:
```compile_fail,E0770
#![feature(const_generics)]
fn foo<T, const N: T>() {} // error!
```

View file

@ -4,7 +4,7 @@ allowed.
Erroneous code example:
```compile_fail,E0771
#![feature(const_generics)]
#![feature(const_param_types)]
fn function_with_str<'a, const STRING: &'a str>() {} // error!
```
@ -13,7 +13,7 @@ To fix this issue, the lifetime in the const generic need to be changed to
`'static`:
```
#![feature(const_generics)]
#![feature(const_param_types)]
fn function_with_str<const STRING: &'static str>() {} // ok!
```