diff options
| author | bors <bors@rust-lang.org> | 2021-07-10 06:01:04 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-07-10 06:01:04 +0000 |
| commit | a84d1b21aea9863f0fc5f436b4982d145dade646 (patch) | |
| tree | a85f0777ccf4782a6054403bcb6304f8513963a4 /src | |
| parent | 8eae2eb1d31da4b0bbdb80dcf2625535c3f147ae (diff) | |
| parent | 4a53b115181a16d681dc05b312bbc913b7f836ac (diff) | |
| download | rust-a84d1b21aea9863f0fc5f436b4982d145dade646.tar.gz rust-a84d1b21aea9863f0fc5f436b4982d145dade646.zip | |
Auto merge of #86987 - lcnr:const-default-eval-bound, r=oli-obk
only check cg defaults wf once instantiated the previous fixmes here didn't make too much sense as I didn't yet fully understand the code further below. That code only runs if the predicates using our generic param default are fully concrete after substituting our default, which never happens if our default is generic. r? `@oli-obk` `@BoxyUwU`
Diffstat (limited to 'src')
4 files changed, 10 insertions, 23 deletions
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/unused-complex-default-expr.rs b/src/test/ui/const-generics/const_evaluatable_checked/unused-complex-default-expr.rs new file mode 100644 index 00000000000..21f14f58ab5 --- /dev/null +++ b/src/test/ui/const-generics/const_evaluatable_checked/unused-complex-default-expr.rs @@ -0,0 +1,6 @@ +// check-pass +#![feature(const_generics, const_evaluatable_checked, const_generics_defaults)] +#![allow(incomplete_features)] +struct Foo<const N: usize, const M: usize = { N + 1 }>; +struct Bar<const N: usize>(Foo<N, 3>); +fn main() {} diff --git a/src/test/ui/const-generics/defaults/complex-generic-default-expr.full.stderr b/src/test/ui/const-generics/defaults/complex-generic-default-expr.full.stderr deleted file mode 100644 index e0e2b6c69f2..00000000000 --- a/src/test/ui/const-generics/defaults/complex-generic-default-expr.full.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error: constant expression depends on a generic parameter - --> $DIR/complex-generic-default-expr.rs:6:34 - | -LL | struct Foo<const N: usize, const M: usize = { N + 1 }>; - | ^ - | - = note: this may fail depending on what value the parameter takes - -error: constant expression depends on a generic parameter - --> $DIR/complex-generic-default-expr.rs:10:21 - | -LL | struct Bar<T, const TYPE_SIZE: usize = { std::mem::size_of::<T>() }>(T); - | ^^^^^^^^^ - | - = note: this may fail depending on what value the parameter takes - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/const-generics/defaults/complex-generic-default-expr.min.stderr b/src/test/ui/const-generics/defaults/complex-generic-default-expr.min.stderr index 58abd8db9f0..44df2ac9f40 100644 --- a/src/test/ui/const-generics/defaults/complex-generic-default-expr.min.stderr +++ b/src/test/ui/const-generics/defaults/complex-generic-default-expr.min.stderr @@ -1,5 +1,5 @@ error: generic parameters may not be used in const operations - --> $DIR/complex-generic-default-expr.rs:6:47 + --> $DIR/complex-generic-default-expr.rs:7:47 | LL | struct Foo<const N: usize, const M: usize = { N + 1 }>; | ^ cannot perform const operation using `N` diff --git a/src/test/ui/const-generics/defaults/complex-generic-default-expr.rs b/src/test/ui/const-generics/defaults/complex-generic-default-expr.rs index a7b712f7b4b..d3558007977 100644 --- a/src/test/ui/const-generics/defaults/complex-generic-default-expr.rs +++ b/src/test/ui/const-generics/defaults/complex-generic-default-expr.rs @@ -1,14 +1,13 @@ // revisions: full min +//[full] check-pass #![cfg_attr(full, feature(const_generics))] #![feature(const_generics_defaults)] #![allow(incomplete_features)] struct Foo<const N: usize, const M: usize = { N + 1 }>; -//[full]~^ ERROR constant expression depends on a generic parameter -//[min]~^^ ERROR generic parameters may not be used in const operations +//[min]~^ ERROR generic parameters may not be used in const operations struct Bar<T, const TYPE_SIZE: usize = { std::mem::size_of::<T>() }>(T); -//[full]~^ ERROR constant expression depends on a generic parameter -//[min]~^^ ERROR generic parameters may not be used in const operations +//[min]~^ ERROR generic parameters may not be used in const operations fn main() {} |
