Add revisions to const generic issue UI tests.

This commit is contained in:
Hameer Abbasi 2020-09-09 13:28:41 +02:00
parent 0855263dcd
commit 5d7e7c25e4
42 changed files with 467 additions and 149 deletions

View File

@ -1,4 +1,6 @@
#![feature(const_generics)]
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]
// All of these three items must be in `lib2` to reproduce the error

View File

@ -0,0 +1,10 @@
error: constant expression depends on a generic parameter
--> $DIR/issue-61935.rs:10:14
|
LL | Self:FooImpl<{N==0}>
| ^^^^^^^^^^^^^^^
|
= note: this may fail depending on what value the parameter takes
error: aborting due to previous error

View File

@ -0,0 +1,10 @@
error: generic parameters must not be used inside of non trivial constant values
--> $DIR/issue-61935.rs:10:23
|
LL | Self:FooImpl<{N==0}>
| ^ non-trivial anonymous constants must not depend on the parameter `N`
|
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
error: aborting due to previous error

View File

@ -1,12 +1,15 @@
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete
// revisions: full min
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]
trait Foo {}
impl<const N: usize> Foo for [(); N]
where
Self:FooImpl<{N==0}>
//~^ERROR constant expression depends on a generic parameter
//[full]~^ERROR constant expression depends on a generic parameter
//[min]~^^ERROR generic parameters must not be used inside of non trivial constant values
{}
trait FooImpl<const IS_ZERO: bool>{}

View File

@ -1,19 +0,0 @@
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/issue-61935.rs:1:12
|
LL | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
error: constant expression depends on a generic parameter
--> $DIR/issue-61935.rs:8:14
|
LL | Self:FooImpl<{N==0}>
| ^^^^^^^^^^^^^^^
|
= note: this may fail depending on what value the parameter takes
error: aborting due to previous error; 1 warning emitted

View File

@ -0,0 +1,10 @@
warning: unused variable: `foo`
--> $DIR/issue-62187-encountered-polymorphic-const.rs:17:9
|
LL | let foo = <[u8; 2]>::BIT_LEN;
| ^^^ help: if this is intentional, prefix it with an underscore: `_foo`
|
= note: `#[warn(unused_variables)]` on by default
warning: 1 warning emitted

View File

@ -0,0 +1,10 @@
warning: unused variable: `foo`
--> $DIR/issue-62187-encountered-polymorphic-const.rs:17:9
|
LL | let foo = <[u8; 2]>::BIT_LEN;
| ^^^ help: if this is intentional, prefix it with an underscore: `_foo`
|
= note: `#[warn(unused_variables)]` on by default
warning: 1 warning emitted

View File

@ -1,7 +1,9 @@
// run-pass
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete
// revisions: full min
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]
pub trait BitLen: Sized {
const BIT_LEN: usize;

View File

@ -1,19 +0,0 @@
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/issue-62187-encountered-polymorphic-const.rs:3:12
|
LL | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
warning: unused variable: `foo`
--> $DIR/issue-62187-encountered-polymorphic-const.rs:15:9
|
LL | let foo = <[u8; 2]>::BIT_LEN;
| ^^^ help: if this is intentional, prefix it with an underscore: `_foo`
|
= note: `#[warn(unused_variables)]` on by default
warning: 2 warnings emitted

View File

@ -1,5 +1,5 @@
error: constant expression depends on a generic parameter
--> $DIR/issue-62220.rs:10:27
--> $DIR/issue-62220.rs:13:27
|
LL | pub fn trunc(self) -> (TruncatedVector<T, { N }>, T) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -0,0 +1,10 @@
error: generic parameters must not be used inside of non trivial constant values
--> $DIR/issue-62220.rs:8:59
|
LL | pub type TruncatedVector<T, const N: usize> = Vector<T, { N - 1 }>;
| ^ non-trivial anonymous constants must not depend on the parameter `N`
|
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
error: aborting due to previous error

View File

@ -1,14 +1,17 @@
#![allow(incomplete_features)]
#![feature(const_generics)]
// revisions: full min
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]
pub struct Vector<T, const N: usize>([T; N]);
pub type TruncatedVector<T, const N: usize> = Vector<T, { N - 1 }>;
//[min]~^ ERROR generic parameters must not be used inside of non trivial constant values
impl<T, const N: usize> Vector<T, { N }> {
/// Drop the last component and return the vector with one fewer dimension.
pub fn trunc(self) -> (TruncatedVector<T, { N }>, T) {
//~^ ERROR constant expression depends on a generic parameter
//[full]~^ ERROR constant expression depends on a generic parameter
unimplemented!()
}
}

View File

@ -0,0 +1,10 @@
error: constant expression depends on a generic parameter
--> $DIR/issue-62456.rs:7:20
|
LL | let _ = [0u64; N + 1];
| ^^^^^
|
= note: this may fail depending on what value the parameter takes
error: aborting due to previous error

View File

@ -0,0 +1,10 @@
error: generic parameters must not be used inside of non trivial constant values
--> $DIR/issue-62456.rs:7:20
|
LL | let _ = [0u64; N + 1];
| ^ non-trivial anonymous constants must not depend on the parameter `N`
|
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
error: aborting due to previous error

View File

@ -1,9 +1,12 @@
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete
// revisions: full min
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]
fn foo<const N: usize>() {
let _ = [0u64; N + 1];
//~^ ERROR constant expression depends on a generic parameter
//[full]~^ ERROR constant expression depends on a generic parameter
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values
}
fn main() {}

View File

@ -1,19 +0,0 @@
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/issue-62456.rs:1:12
|
LL | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
error: constant expression depends on a generic parameter
--> $DIR/issue-62456.rs:5:20
|
LL | let _ = [0u64; N + 1];
| ^^^^^
|
= note: this may fail depending on what value the parameter takes
error: aborting due to previous error; 1 warning emitted

View File

@ -1,5 +1,5 @@
error: constant expression depends on a generic parameter
--> $DIR/issue-62504.rs:18:25
--> $DIR/issue-62504.rs:19:25
|
LL | ArrayHolder([0; Self::SIZE])
| ^^^^^^^^^^

View File

@ -0,0 +1,10 @@
error: generic parameters must not be used inside of non trivial constant values
--> $DIR/issue-62504.rs:19:25
|
LL | ArrayHolder([0; Self::SIZE])
| ^^^^^^^^^^ non-trivial anonymous constants must not depend on the parameter `Self`
|
= help: it is currently only allowed to use either `Self` or `{ Self }` as generic constants
error: aborting due to previous error

View File

@ -1,7 +1,8 @@
// Regression test for #62504
#![feature(const_generics)]
// revisions: full min
#![allow(incomplete_features)]
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]
trait HasSize {
const SIZE: usize;
@ -16,7 +17,8 @@ struct ArrayHolder<const X: usize>([u32; X]);
impl<const X: usize> ArrayHolder<X> {
pub const fn new() -> Self {
ArrayHolder([0; Self::SIZE])
//~^ ERROR constant expression depends on a generic parameter
//[full]~^ ERROR constant expression depends on a generic parameter
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values
}
}

View File

@ -0,0 +1,11 @@
error: `NoMatch` is forbidden as the type of a const generic parameter
--> $DIR/issue-62579-no-match.rs:10:17
|
LL | fn foo<const T: NoMatch>() -> bool {
| ^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= note: more complex types are supported with `#[feature(const_generics)]`
error: aborting due to previous error

View File

@ -1,12 +1,14 @@
// run-pass
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete
// [full] run-pass
// revisions: full min
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]
#[derive(PartialEq, Eq)]
struct NoMatch;
fn foo<const T: NoMatch>() -> bool {
//[min]~^ ERROR `NoMatch` is forbidden as the type of a const generic parameter
true
}

View File

@ -1,11 +0,0 @@
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/issue-62579-no-match.rs:3:12
|
LL | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
warning: 1 warning emitted

View File

@ -0,0 +1,28 @@
error[E0770]: the type of const parameters must not depend on other generic parameters
--> $DIR/issue-62878.rs:6:38
|
LL | fn foo<const N: usize, const A: [u8; N]>() {}
| ^ the type must not depend on the parameter `N`
error[E0107]: wrong number of const arguments: expected 2, found 1
--> $DIR/issue-62878.rs:11:5
|
LL | foo::<_, {[1]}>();
| ^^^^^^^^^^^^^^^ expected 2 const arguments
error[E0107]: wrong number of type arguments: expected 0, found 1
--> $DIR/issue-62878.rs:11:11
|
LL | foo::<_, {[1]}>();
| ^ unexpected type argument
error[E0308]: mismatched types
--> $DIR/issue-62878.rs:11:15
|
LL | foo::<_, {[1]}>();
| ^^^ expected `usize`, found array `[{integer}; 1]`
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0107, E0308, E0770.
For more information about an error, try `rustc --explain E0107`.

View File

@ -0,0 +1,18 @@
error[E0770]: the type of const parameters must not depend on other generic parameters
--> $DIR/issue-62878.rs:6:38
|
LL | fn foo<const N: usize, const A: [u8; N]>() {}
| ^ the type must not depend on the parameter `N`
error: `[u8; _]` is forbidden as the type of a const generic parameter
--> $DIR/issue-62878.rs:6:33
|
LL | fn foo<const N: usize, const A: [u8; N]>() {}
| ^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= note: more complex types are supported with `#[feature(const_generics)]`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0770`.

View File

@ -1,11 +1,15 @@
#![feature(const_generics)] //~ WARN the feature `const_generics` is incomplete
// revisions: full min
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]
fn foo<const N: usize, const A: [u8; N]>() {}
//~^ ERROR the type of const parameters must not
//[min]~| ERROR `[u8; _]` is forbidden as the type of a const generic parameter
fn main() {
foo::<_, {[1]}>();
//~^ ERROR wrong number of const arguments
//~| ERROR wrong number of type arguments
//~| ERROR mismatched types
//[full]~^ ERROR wrong number of const arguments
//[full]~| ERROR wrong number of type arguments
//[full]~| ERROR mismatched types
}

View File

@ -1,37 +1,46 @@
error[E0770]: the type of const parameters must not depend on other generic parameters
--> $DIR/issue-62878.rs:3:38
--> $DIR/issue-62878.rs:5:38
|
LL | fn foo<const N: usize, const A: [u8; N]>() {}
| ^ the type must not depend on the parameter `N`
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/issue-62878.rs:1:12
error[E0658]: const generics are unstable
--> $DIR/issue-62878.rs:5:14
|
LL | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
LL | fn foo<const N: usize, const A: [u8; N]>() {}
| ^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
= note: see issue #74878 <https://github.com/rust-lang/rust/issues/74878> for more information
= help: add `#![feature(min_const_generics)]` to the crate attributes to enable
error[E0658]: const generics are unstable
--> $DIR/issue-62878.rs:5:30
|
LL | fn foo<const N: usize, const A: [u8; N]>() {}
| ^
|
= note: see issue #74878 <https://github.com/rust-lang/rust/issues/74878> for more information
= help: add `#![feature(min_const_generics)]` to the crate attributes to enable
error[E0107]: wrong number of const arguments: expected 2, found 1
--> $DIR/issue-62878.rs:7:5
--> $DIR/issue-62878.rs:11:5
|
LL | foo::<_, {[1]}>();
| ^^^^^^^^^^^^^^^ expected 2 const arguments
error[E0107]: wrong number of type arguments: expected 0, found 1
--> $DIR/issue-62878.rs:7:11
--> $DIR/issue-62878.rs:11:11
|
LL | foo::<_, {[1]}>();
| ^ unexpected type argument
error[E0308]: mismatched types
--> $DIR/issue-62878.rs:7:15
--> $DIR/issue-62878.rs:11:15
|
LL | foo::<_, {[1]}>();
| ^^^ expected `usize`, found array `[{integer}; 1]`
error: aborting due to 4 previous errors; 1 warning emitted
error: aborting due to 6 previous errors
Some errors have detailed explanations: E0107, E0308, E0770.
Some errors have detailed explanations: E0107, E0308, E0658, E0770.
For more information about an error, try `rustc --explain E0107`.

View File

@ -1,14 +1,5 @@
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/issue-67185-2.rs:1:12
|
LL | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
error[E0277]: the trait bound `[u16; 3]: Bar` is not satisfied
--> $DIR/issue-67185-2.rs:15:1
--> $DIR/issue-67185-2.rs:17:1
|
LL | / trait Foo
LL | |
@ -26,7 +17,7 @@ LL | | }
= help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
error[E0277]: the trait bound `[[u16; 3]; 2]: Bar` is not satisfied
--> $DIR/issue-67185-2.rs:15:1
--> $DIR/issue-67185-2.rs:17:1
|
LL | / trait Foo
LL | |
@ -44,7 +35,7 @@ LL | | }
= help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
error[E0277]: the trait bound `[u16; 3]: Bar` is not satisfied
--> $DIR/issue-67185-2.rs:25:6
--> $DIR/issue-67185-2.rs:27:6
|
LL | trait Foo
| --- required by a bound in this
@ -60,7 +51,7 @@ LL | impl Foo for FooImpl {}
<[u16; 4] as Bar>
error[E0277]: the trait bound `[[u16; 3]; 2]: Bar` is not satisfied
--> $DIR/issue-67185-2.rs:25:6
--> $DIR/issue-67185-2.rs:27:6
|
LL | trait Foo
| --- required by a bound in this
@ -76,7 +67,7 @@ LL | impl Foo for FooImpl {}
<[u16; 4] as Bar>
error[E0277]: the trait bound `[[u16; 3]; 2]: Bar` is not satisfied
--> $DIR/issue-67185-2.rs:29:14
--> $DIR/issue-67185-2.rs:31:14
|
LL | trait Foo
| --- required by a bound in this
@ -92,7 +83,7 @@ LL | fn f(_: impl Foo) {}
<[u16; 4] as Bar>
error[E0277]: the trait bound `[u16; 3]: Bar` is not satisfied
--> $DIR/issue-67185-2.rs:29:14
--> $DIR/issue-67185-2.rs:31:14
|
LL | trait Foo
| --- required by a bound in this
@ -107,6 +98,6 @@ LL | fn f(_: impl Foo) {}
<[[u16; 3]; 3] as Bar>
<[u16; 4] as Bar>
error: aborting due to 6 previous errors; 1 warning emitted
error: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@ -0,0 +1,103 @@
error[E0277]: the trait bound `[u16; 3]: Bar` is not satisfied
--> $DIR/issue-67185-2.rs:17:1
|
LL | / trait Foo
LL | |
LL | | where
LL | | [<u8 as Baz>::Quaks; 2]: Bar,
LL | | <u8 as Baz>::Quaks: Bar,
LL | | {
LL | | }
| |_^ the trait `Bar` is not implemented for `[u16; 3]`
|
= help: the following implementations were found:
<[[u16; 3]; 3] as Bar>
<[u16; 4] as Bar>
= help: see issue #48214
= help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
error[E0277]: the trait bound `[[u16; 3]; 2]: Bar` is not satisfied
--> $DIR/issue-67185-2.rs:17:1
|
LL | / trait Foo
LL | |
LL | | where
LL | | [<u8 as Baz>::Quaks; 2]: Bar,
LL | | <u8 as Baz>::Quaks: Bar,
LL | | {
LL | | }
| |_^ the trait `Bar` is not implemented for `[[u16; 3]; 2]`
|
= help: the following implementations were found:
<[[u16; 3]; 3] as Bar>
<[u16; 4] as Bar>
= help: see issue #48214
= help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
error[E0277]: the trait bound `[u16; 3]: Bar` is not satisfied
--> $DIR/issue-67185-2.rs:27:6
|
LL | trait Foo
| --- required by a bound in this
...
LL | <u8 as Baz>::Quaks: Bar,
| --- required by this bound in `Foo`
...
LL | impl Foo for FooImpl {}
| ^^^ the trait `Bar` is not implemented for `[u16; 3]`
|
= help: the following implementations were found:
<[[u16; 3]; 3] as Bar>
<[u16; 4] as Bar>
error[E0277]: the trait bound `[[u16; 3]; 2]: Bar` is not satisfied
--> $DIR/issue-67185-2.rs:27:6
|
LL | trait Foo
| --- required by a bound in this
...
LL | [<u8 as Baz>::Quaks; 2]: Bar,
| --- required by this bound in `Foo`
...
LL | impl Foo for FooImpl {}
| ^^^ the trait `Bar` is not implemented for `[[u16; 3]; 2]`
|
= help: the following implementations were found:
<[[u16; 3]; 3] as Bar>
<[u16; 4] as Bar>
error[E0277]: the trait bound `[[u16; 3]; 2]: Bar` is not satisfied
--> $DIR/issue-67185-2.rs:31:14
|
LL | trait Foo
| --- required by a bound in this
...
LL | [<u8 as Baz>::Quaks; 2]: Bar,
| --- required by this bound in `Foo`
...
LL | fn f(_: impl Foo) {}
| ^^^ the trait `Bar` is not implemented for `[[u16; 3]; 2]`
|
= help: the following implementations were found:
<[[u16; 3]; 3] as Bar>
<[u16; 4] as Bar>
error[E0277]: the trait bound `[u16; 3]: Bar` is not satisfied
--> $DIR/issue-67185-2.rs:31:14
|
LL | trait Foo
| --- required by a bound in this
...
LL | <u8 as Baz>::Quaks: Bar,
| --- required by this bound in `Foo`
...
LL | fn f(_: impl Foo) {}
| ^^^ the trait `Bar` is not implemented for `[u16; 3]`
|
= help: the following implementations were found:
<[[u16; 3]; 3] as Bar>
<[u16; 4] as Bar>
error: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@ -1,5 +1,7 @@
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete
// revisions: full min
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]
trait Baz {
type Quaks;

View File

@ -0,0 +1,10 @@
error: generic parameters must not be used inside of non trivial constant values
--> $DIR/issue-67739.rs:12:30
|
LL | [0u8; mem::size_of::<Self::Associated>()];
| ^^^^^^^^^^^^^^^^ non-trivial anonymous constants must not depend on the parameter `Self`
|
= help: it is currently only allowed to use either `Self` or `{ Self }` as generic constants
error: aborting due to previous error

View File

@ -1,7 +1,7 @@
// Regression test for #67739
#![allow(incomplete_features)]
#![feature(const_generics)]
// revisions: full min
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]
use std::mem;
@ -10,7 +10,8 @@ pub trait Trait {
fn associated_size(&self) -> usize {
[0u8; mem::size_of::<Self::Associated>()];
//~^ ERROR constant expression depends on a generic parameter
//[full]~^ ERROR constant expression depends on a generic parameter
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values
0
}
}

View File

@ -1,5 +1,5 @@
error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates
--> $DIR/issue-68366.rs:10:13
--> $DIR/issue-68366.rs:12:13
|
LL | impl <const N: usize> Collatz<{Some(N)}> {}
| ^ unconstrained const parameter
@ -8,7 +8,7 @@ LL | impl <const N: usize> Collatz<{Some(N)}> {}
= note: proving the result of expressions other than the parameter are unique is not supported
error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates
--> $DIR/issue-68366.rs:15:12
--> $DIR/issue-68366.rs:18:12
|
LL | impl<const N: usize> Foo {}
| ^ unconstrained const parameter

View File

@ -0,0 +1,29 @@
error: generic parameters must not be used inside of non trivial constant values
--> $DIR/issue-68366.rs:12:37
|
LL | impl <const N: usize> Collatz<{Some(N)}> {}
| ^ non-trivial anonymous constants must not depend on the parameter `N`
|
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates
--> $DIR/issue-68366.rs:12:13
|
LL | impl <const N: usize> Collatz<{Some(N)}> {}
| ^ unconstrained const parameter
|
= note: expressions using a const parameter must map each value to a distinct output value
= note: proving the result of expressions other than the parameter are unique is not supported
error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates
--> $DIR/issue-68366.rs:18:12
|
LL | impl<const N: usize> Foo {}
| ^ unconstrained const parameter
|
= note: expressions using a const parameter must map each value to a distinct output value
= note: proving the result of expressions other than the parameter are unique is not supported
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0207`.

View File

@ -2,13 +2,16 @@
// The note should relate to the fact that it cannot be shown forall N that it maps 1-1 to a new
// type.
#![feature(const_generics)]
#![allow(incomplete_features)]
// revisions: full min
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]
struct Collatz<const N: Option<usize>>;
impl <const N: usize> Collatz<{Some(N)}> {}
//~^ ERROR the const parameter
//[min]~^^ generic parameters must not be used inside of non trivial constant values
struct Foo;

View File

@ -1,5 +1,5 @@
error: constant expression depends on a generic parameter
--> $DIR/issue-72787.rs:9:32
--> $DIR/issue-72787.rs:11:32
|
LL | Condition<{ LHS <= RHS }>: True
| ^^^^
@ -7,7 +7,7 @@ LL | Condition<{ LHS <= RHS }>: True
= note: this may fail depending on what value the parameter takes
error: constant expression depends on a generic parameter
--> $DIR/issue-72787.rs:20:42
--> $DIR/issue-72787.rs:27:42
|
LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
| ^^^^
@ -15,7 +15,7 @@ LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
= note: this may fail depending on what value the parameter takes
error: constant expression depends on a generic parameter
--> $DIR/issue-72787.rs:20:42
--> $DIR/issue-72787.rs:27:42
|
LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
| ^^^^
@ -23,7 +23,7 @@ LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
= note: this may fail depending on what value the parameter takes
error: constant expression depends on a generic parameter
--> $DIR/issue-72787.rs:20:42
--> $DIR/issue-72787.rs:27:42
|
LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
| ^^^^
@ -31,7 +31,7 @@ LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
= note: this may fail depending on what value the parameter takes
error: constant expression depends on a generic parameter
--> $DIR/issue-72787.rs:20:42
--> $DIR/issue-72787.rs:27:42
|
LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
| ^^^^

View File

@ -0,0 +1,57 @@
error: generic parameters must not be used inside of non trivial constant values
--> $DIR/issue-72787.rs:11:17
|
LL | Condition<{ LHS <= RHS }>: True
| ^^^ non-trivial anonymous constants must not depend on the parameter `LHS`
|
= help: it is currently only allowed to use either `LHS` or `{ LHS }` as generic constants
error: generic parameters must not be used inside of non trivial constant values
--> $DIR/issue-72787.rs:11:24
|
LL | Condition<{ LHS <= RHS }>: True
| ^^^ non-trivial anonymous constants must not depend on the parameter `RHS`
|
= help: it is currently only allowed to use either `RHS` or `{ RHS }` as generic constants
error: generic parameters must not be used inside of non trivial constant values
--> $DIR/issue-72787.rs:27:25
|
LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
| ^ non-trivial anonymous constants must not depend on the parameter `I`
|
= help: it is currently only allowed to use either `I` or `{ I }` as generic constants
error: generic parameters must not be used inside of non trivial constant values
--> $DIR/issue-72787.rs:27:36
|
LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
| ^ non-trivial anonymous constants must not depend on the parameter `J`
|
= help: it is currently only allowed to use either `J` or `{ J }` as generic constants
error[E0283]: type annotations needed
--> $DIR/issue-72787.rs:22:26
|
LL | pub trait True {}
| -------------- required by this bound in `True`
...
LL | IsLessOrEqual<I, 8>: True,
| ^^^^ cannot infer type for struct `IsLessOrEqual<I, 8_u32>`
|
= note: cannot satisfy `IsLessOrEqual<I, 8_u32>: True`
error[E0283]: type annotations needed
--> $DIR/issue-72787.rs:22:26
|
LL | pub trait True {}
| -------------- required by this bound in `True`
...
LL | IsLessOrEqual<I, 8>: True,
| ^^^^ cannot infer type for struct `IsLessOrEqual<I, 8_u32>`
|
= note: cannot satisfy `IsLessOrEqual<I, 8_u32>: True`
error: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0283`.

View File

@ -1,5 +1,7 @@
#![feature(const_generics)]
#![allow(incomplete_features)]
// revisions: full min
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]
pub struct IsLessOrEqual<const LHS: u32, const RHS: u32>;
pub struct Condition<const CONDITION: bool>;
@ -7,7 +9,9 @@ pub trait True {}
impl<const LHS: u32, const RHS: u32> True for IsLessOrEqual<LHS, RHS> where
Condition<{ LHS <= RHS }>: True
//~^ Error constant expression depends on a generic parameter
//[full]~^ Error constant expression depends on a generic parameter
//[min]~^^ Error generic parameters must not be used inside of non trivial constant values
//[min]~| Error generic parameters must not be used inside of non trivial constant values
{
}
impl True for Condition<true> {}
@ -16,12 +20,17 @@ struct S<const I: u32, const J: u32>;
impl<const I: u32, const J: u32> S<I, J>
where
IsLessOrEqual<I, 8>: True,
//[min]~^ Error type annotations needed [E0283]
//[min]~| Error type annotations needed [E0283]
// Condition<{ 8 - I <= 8 - J }>: True,
IsLessOrEqual<J, 8>: True,
IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
//~^ Error constant expression depends on a generic parameter
//~| Error constant expression depends on a generic parameter
//~| Error constant expression depends on a generic parameter
//~| Error constant expression depends on a generic parameter
//[full]~^ constant expression depends on a generic parameter
//[full]~| constant expression depends on a generic parameter
//[full]~| constant expression depends on a generic parameter
//[full]~| constant expression depends on a generic parameter
//[min]~^^^^^ Error generic parameters must not be used inside of non trivial constant values
//[min]~| Error generic parameters must not be used inside of non trivial constant values
// Condition<{ 8 - I <= 8 - J }>: True,
{
fn print() {

View File

@ -1,5 +1,5 @@
error: constant expression depends on a generic parameter
--> $DIR/issue-72819-generic-in-const-eval.rs:7:47
--> $DIR/issue-72819-generic-in-const-eval.rs:9:47
|
LL | where Assert::<{N < usize::max_value() / 2}>: IsTrue,
| ^^^^^^

View File

@ -0,0 +1,10 @@
error: generic parameters must not be used inside of non trivial constant values
--> $DIR/issue-72819-generic-in-const-eval.rs:9:17
|
LL | where Assert::<{N < usize::max_value() / 2}>: IsTrue,
| ^ non-trivial anonymous constants must not depend on the parameter `N`
|
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
error: aborting due to previous error

View File

@ -1,11 +1,14 @@
// Regression test for #72819: ICE due to failure in resolving the const generic in `Arr`'s type
// bounds.
// revisions: full min
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]
#![feature(const_generics)]
#![allow(incomplete_features)]
struct Arr<const N: usize>
where Assert::<{N < usize::max_value() / 2}>: IsTrue,
//~^ ERROR constant expression depends on a generic parameter
//[full]~^ ERROR constant expression depends on a generic parameter
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values
{
}

View File

@ -1,3 +1,4 @@
// revisions: full min
// check-pass
// aux-build:const_generic_issues_lib.rs
extern crate const_generic_issues_lib as lib2;