未验证 提交 7565ccc3 编写于 作者: T Tyler Mandry 提交者: GitHub

Rollup merge of #76514 - hameerabbasi:const-generics-revs, r=lcnr

Add revisions to const generic issue UI tests.

Fixes #75279.

I have gotten into the flow, so I can do more of these if requested. I'm looking for feedback as to whether my work is on the right track so far.
#![feature(const_generics)]
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]
pub struct Struct<const N: usize>(pub [u8; N]);
......
#![feature(const_generics)]
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]
pub struct Num<const N: usize>;
......
error[E0308]: mismatched types
--> $DIR/const-argument-cross-crate-mismatch.rs:6:67
--> $DIR/const-argument-cross-crate-mismatch.rs:7:67
|
LL | let _ = const_generic_lib::function(const_generic_lib::Struct([0u8, 1u8]));
| ^^^^^^^^^^ expected an array with a fixed size of 3 elements, found one with 2 elements
error[E0308]: mismatched types
--> $DIR/const-argument-cross-crate-mismatch.rs:8:65
--> $DIR/const-argument-cross-crate-mismatch.rs:9:65
|
LL | let _: const_generic_lib::Alias = const_generic_lib::Struct([0u8, 1u8, 2u8]);
| ^^^^^^^^^^^^^^^ expected an array with a fixed size of 2 elements, found one with 3 elements
......
error[E0308]: mismatched types
--> $DIR/const-argument-cross-crate-mismatch.rs:7:67
|
LL | let _ = const_generic_lib::function(const_generic_lib::Struct([0u8, 1u8]));
| ^^^^^^^^^^ expected an array with a fixed size of 3 elements, found one with 2 elements
error[E0308]: mismatched types
--> $DIR/const-argument-cross-crate-mismatch.rs:9:65
|
LL | let _: const_generic_lib::Alias = const_generic_lib::Struct([0u8, 1u8, 2u8]);
| ^^^^^^^^^^^^^^^ expected an array with a fixed size of 2 elements, found one with 3 elements
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0308`.
// aux-build:const_generic_lib.rs
// revisions: full min
extern crate const_generic_lib;
......
// run-pass
// revisions: full min
// aux-build:const_generic_lib.rs
extern crate const_generic_lib;
......
error: type parameters must be declared prior to const parameters
--> $DIR/complex-unord-param.rs:9:41
|
LL | struct NestedArrays<'a, const N: usize, A: 'a, const M: usize, T:'a =u32> {
| ---------------------^----------------------^--------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, A: 'a, T: 'a, const N: usize, const M: usize>`
error: aborting due to previous error
// run-pass
// [full] run-pass
// revisions: full min
// Checks a complicated usage of unordered params
#![feature(const_generics)]
#![allow(incomplete_features)]
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]
#![allow(dead_code)]
struct NestedArrays<'a, const N: usize, A: 'a, const M: usize, T:'a =u32> {
//[min]~^ ERROR type parameters must be declared prior to const parameters
args: &'a [&'a [T; M]; N],
specifier: A,
}
......
error: lifetime parameters must be declared prior to const parameters
--> $DIR/intermixed-lifetime.rs:6:28
--> $DIR/intermixed-lifetime.rs:7:28
|
LL | struct Foo<const N: usize, 'a, T = u32>(&'a (), T);
| -----------------^^---------- help: reorder the parameters: lifetimes, then consts and types: `<'a, const N: usize, T>`
error: lifetime parameters must be declared prior to type parameters
--> $DIR/intermixed-lifetime.rs:9:37
--> $DIR/intermixed-lifetime.rs:11:37
|
LL | struct Bar<const N: usize, T = u32, 'a>(&'a (), T);
| --------------------------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, const N: usize, T>`
......
error: lifetime parameters must be declared prior to const parameters
--> $DIR/intermixed-lifetime.rs:7:28
|
LL | struct Foo<const N: usize, 'a, T = u32>(&'a (), T);
| -----------------^^---------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T, const N: usize>`
error: type parameters must be declared prior to const parameters
--> $DIR/intermixed-lifetime.rs:7:32
|
LL | struct Foo<const N: usize, 'a, T = u32>(&'a (), T);
| ---------------------^------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T, const N: usize>`
error: lifetime parameters must be declared prior to const parameters
--> $DIR/intermixed-lifetime.rs:11:37
|
LL | struct Bar<const N: usize, T = u32, 'a>(&'a (), T);
| --------------------------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T, const N: usize>`
error: type parameters must be declared prior to const parameters
--> $DIR/intermixed-lifetime.rs:11:28
|
LL | struct Bar<const N: usize, T = u32, 'a>(&'a (), T);
| -----------------^----------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T, const N: usize>`
error: aborting due to 4 previous errors
// revisions: full min
// Checks that lifetimes cannot be interspersed between consts and types.
#![feature(const_generics)]
#![allow(incomplete_features)]
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]
struct Foo<const N: usize, 'a, T = u32>(&'a (), T);
//~^ Error lifetime parameters must be declared prior to const parameters
//[min]~^^ Error type parameters must be declared prior to const parameters
struct Bar<const N: usize, T = u32, 'a>(&'a (), T);
//~^ Error lifetime parameters must be declared prior to type parameters
//[full]~^ Error lifetime parameters must be declared prior to type parameters
//[min]~^^ Error type parameters must be declared prior to const parameters
//[min]~| Error lifetime parameters must be declared prior to const parameters
fn main() {}
error: type parameters must be declared prior to const parameters
--> $DIR/simple-defaults.rs:9:40
|
LL | struct FixedOutput<'a, const N: usize, T=u32> {
| ---------------------^----- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T, const N: usize>`
error: aborting due to previous error
// run-pass
// [full] run-pass
// revisions: min full
// Checks some basic test cases for defaults.
#![feature(const_generics)]
#![allow(incomplete_features)]
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]
#![allow(dead_code)]
struct FixedOutput<'a, const N: usize, T=u32> {
//[min]~^ ERROR type parameters must be declared prior to const parameters
out: &'a [T; N],
}
......
#![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
......
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
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
#![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>{}
......
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
// 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;
......@@ -12,5 +14,5 @@ pub trait BitLen: Sized {
}
fn main() {
let foo = <[u8; 2]>::BIT_LEN; //~ WARN unused variable
let _foo = <[u8; 2]>::BIT_LEN;
}
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
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) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
......
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
#![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!()
}
}
......
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
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
#![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() {}
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
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])
| ^^^^^^^^^^
......
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
// 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 @@ impl<const X: usize> HasSize for ArrayHolder<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
}
}
......
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
// 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
}
......
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
error[E0770]: the type of const parameters must not depend on other generic parameters
--> $DIR/issue-62878.rs:3:38
--> $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`
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
|
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[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 4 previous errors
Some errors have detailed explanations: E0107, E0308, E0770.
For more information about an error, try `rustc --explain E0107`.
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`.
#![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
}
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`.
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`.
#![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;
......
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
// 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
}
}
......
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
......
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`.
......@@ -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;
......
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:26: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:26: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:26: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:26:42
|
LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
| ^^^^
......
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:26: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:26: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`.
#![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,16 @@ impl True for Condition<true> {}
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]
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() {
......
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,
| ^^^^^^
......
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
// 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
{
}
......
// revisions: full min
// check-pass
// aux-build:const_generic_issues_lib.rs
extern crate const_generic_issues_lib as lib2;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册