diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2020-07-16 11:18:46 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-16 11:18:46 -0700 |
| commit | 6ef0dfa42f8fa559f98c51dcd7c926fbf410a367 (patch) | |
| tree | 52c9039411769928c23db2265739eeb20c9b2d1f /src/librustc_error_codes/error_codes | |
| parent | 61a3f6701b5e1d8cd87be83c2b6a8322f812c8d8 (diff) | |
| parent | 09ba0bda2caa448d381b952d2b52df1782c44966 (diff) | |
| download | rust-6ef0dfa42f8fa559f98c51dcd7c926fbf410a367.tar.gz rust-6ef0dfa42f8fa559f98c51dcd7c926fbf410a367.zip | |
Rollup merge of #74159 - lcnr:const-generic-ty-decl, r=varkor
forbid generic params in the type of const params implements and closes #74152 fixes #74101, closes #71169, fixes #73491, closes #62878 @eddyb and I talked [on zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/type.20of.20const.20parameters/near/203405696) about this and we probably want to also forbid generic consts in the default type of a parameter, e.g. `struct Foo<T, U = [u8; std::mem::size_of::<T>()]>`, this is currently still allowed and I will probably fix that in a followup PR. r? @varkor @eddyb
Diffstat (limited to 'src/librustc_error_codes/error_codes')
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0671.md | 2 | ||||
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0770.md | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/src/librustc_error_codes/error_codes/E0671.md b/src/librustc_error_codes/error_codes/E0671.md index 449fb8ffc89..a993ce826a7 100644 --- a/src/librustc_error_codes/error_codes/E0671.md +++ b/src/librustc_error_codes/error_codes/E0671.md @@ -3,7 +3,7 @@ Const parameters cannot depend on type parameters. The following is therefore invalid: -```compile_fail,E0741 +```compile_fail,E0770 #![feature(const_generics)] fn const_id<T, const N: T>() -> T { // error diff --git a/src/librustc_error_codes/error_codes/E0770.md b/src/librustc_error_codes/error_codes/E0770.md new file mode 100644 index 00000000000..278bf9b907b --- /dev/null +++ b/src/librustc_error_codes/error_codes/E0770.md @@ -0,0 +1,15 @@ +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! +``` + +To fix this error, use a concrete type for the const parameter: + +``` +#![feature(const_generics)] +fn foo<T, const N: usize>() {} +``` |
