bless tests part 1

This commit is contained in:
Deadbeef 2024-06-25 08:36:40 +00:00
parent 74e7b5bd76
commit b9886c6872
31 changed files with 370 additions and 394 deletions

View File

@ -65,6 +65,10 @@ impl<'tcx> Bounds<'tcx> {
} else {
self.clauses.push(clause);
}
if !tcx.features().effects {
return;
}
// For `T: ~const Tr` or `T: const Tr`, we need to add an additional bound on the
// associated type of `<T as Tr>` and make sure that the effect is compatible.
if let Some(compat_val) = match (tcx.def_kind(defining_def_id), constness) {

View File

@ -1,7 +1,8 @@
//@ build-pass
//@ compile-flags: -Znext-solver
#![feature(const_trait_impl, effects)] //~ WARN the feature `effects` is incomplete
#![allow(incomplete_features)]
#![feature(const_trait_impl, effects)]
#[const_trait]
trait Func<T> {

View File

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

View File

@ -1,6 +1,6 @@
//@ known-bug: #110395
#![feature(generic_const_exprs, adt_const_params, const_trait_impl)]
#![feature(generic_const_exprs, adt_const_params, const_trait_impl, effects)]
#![allow(incomplete_features)]
// test `N + N` unifies with explicit function calls for non-builtin-types

View File

@ -1,3 +1,12 @@
error: const `impl` for trait `Add` which is not marked with `#[const_trait]`
--> $DIR/unify-op-with-fn-call.rs:10:12
|
LL | impl const std::ops::Add for Foo {
| ^^^^^^^^^^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error[E0741]: `Foo` must implement `ConstParamTy` to be used as the type of a const generic parameter
--> $DIR/unify-op-with-fn-call.rs:18:29
|
@ -45,48 +54,6 @@ help: try adding a `where` bound
LL | fn foo2<const N: usize>(a: Evaluatable2<{ N + N }>) where [(); { std::ops::Add::add(N, N) }]: {
| +++++++++++++++++++++++++++++++++++++++++
error[E0015]: cannot call non-const operator in constants
--> $DIR/unify-op-with-fn-call.rs:20:39
|
LL | fn foo<const N: Foo>(a: Evaluatable<{ N + N }>) {
| ^^^^^
|
note: impl defined here, but it is not `const`
--> $DIR/unify-op-with-fn-call.rs:10:1
|
LL | impl const std::ops::Add for Foo {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
help: add `#![feature(effects)]` to the crate attributes to enable
|
LL + #![feature(effects)]
|
error: aborting due to 5 previous errors
error[E0015]: cannot call non-const fn `<Foo as Add>::add` in constants
--> $DIR/unify-op-with-fn-call.rs:21:13
|
LL | bar::<{ std::ops::Add::add(N, N) }>();
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
help: add `#![feature(effects)]` to the crate attributes to enable
|
LL + #![feature(effects)]
|
error[E0015]: cannot call non-const fn `<usize as Add>::add` in constants
--> $DIR/unify-op-with-fn-call.rs:30:14
|
LL | bar2::<{ std::ops::Add::add(N, N) }>();
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
help: add `#![feature(effects)]` to the crate attributes to enable
|
LL + #![feature(effects)]
|
error: aborting due to 7 previous errors
Some errors have detailed explanations: E0015, E0741.
For more information about an error, try `rustc --explain E0015`.
For more information about this error, try `rustc --explain E0741`.

View File

@ -1,7 +1,7 @@
//@ check-pass
#![allow(incomplete_features)]
#![feature(const_trait_impl, generic_const_exprs)]
#![feature(const_trait_impl, effects, generic_const_exprs)]
#[const_trait]
trait ConstName {

View File

@ -5,6 +5,7 @@
#![feature(const_float_bits_conv)]
#![feature(const_float_classify)]
#![feature(const_trait_impl, effects)]
#![allow(incomplete_features)]
// Don't promote
const fn nop<T>(x: T) -> T { x }

View File

@ -1,14 +1,5 @@
warning: the feature `effects` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/const-float-classify.rs:7:30
|
LL | #![feature(const_trait_impl, effects)]
| ^^^^^^^
|
= note: see issue #102090 <https://github.com/rust-lang/rust/issues/102090> for more information
= note: `#[warn(incomplete_features)]` on by default
error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]`
--> $DIR/const-float-classify.rs:12:12
--> $DIR/const-float-classify.rs:13:12
|
LL | impl const PartialEq<NonDet> for bool {
| ^^^^^^^^^^^^^^^^^
@ -16,208 +7,5 @@ LL | impl const PartialEq<NonDet> for bool {
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error[E0207]: the const parameter `host` is not constrained by the impl trait, self type, or predicates
--> $DIR/const-float-classify.rs:12:6
|
LL | impl const PartialEq<NonDet> for bool {
| ^^^^^ 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 1 previous error
error[E0284]: type annotations needed
--> $DIR/const-float-classify.rs:21:35
|
LL | const _: () = assert!($a == $b);
| ^^ cannot infer the value of the constant `_`
...
LL | / suite! {
LL | | [is_nan, is_infinite, is_finite, is_normal, is_sign_positive, is_sign_negative]
LL | | -0.0 / 0.0 => [ true, false, false, false, NonDet, NonDet]
LL | | 0.0 / 0.0 => [ true, false, false, false, NonDet, NonDet]
... |
LL | | -1.0 / 0.0 => [ false, true, false, false, false, true]
LL | | }
| |_- in this macro invocation
|
note: required for `bool` to implement `PartialEq<NonDet>`
--> $DIR/const-float-classify.rs:12:12
|
LL | impl const PartialEq<NonDet> for bool {
| ----- ^^^^^^^^^^^^^^^^^ ^^^^
| |
| unsatisfied trait bound introduced here
= note: this error originates in the macro `const_assert` which comes from the expansion of the macro `suite` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0284]: type annotations needed
--> $DIR/const-float-classify.rs:21:35
|
LL | const _: () = assert!($a == $b);
| ^^ cannot infer the value of the constant `_`
...
LL | / suite! {
LL | | [is_nan, is_infinite, is_finite, is_normal, is_sign_positive, is_sign_negative]
LL | | -0.0 / 0.0 => [ true, false, false, false, NonDet, NonDet]
LL | | 0.0 / 0.0 => [ true, false, false, false, NonDet, NonDet]
... |
LL | | -1.0 / 0.0 => [ false, true, false, false, false, true]
LL | | }
| |_- in this macro invocation
|
note: required for `bool` to implement `PartialEq<NonDet>`
--> $DIR/const-float-classify.rs:12:12
|
LL | impl const PartialEq<NonDet> for bool {
| ----- ^^^^^^^^^^^^^^^^^ ^^^^
| |
| unsatisfied trait bound introduced here
= note: this error originates in the macro `const_assert` which comes from the expansion of the macro `suite` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0284]: type annotations needed
--> $DIR/const-float-classify.rs:21:35
|
LL | const _: () = assert!($a == $b);
| ^^ cannot infer the value of the constant `_`
...
LL | / suite! {
LL | | [is_nan, is_infinite, is_finite, is_normal, is_sign_positive, is_sign_negative]
LL | | -0.0 / 0.0 => [ true, false, false, false, NonDet, NonDet]
LL | | 0.0 / 0.0 => [ true, false, false, false, NonDet, NonDet]
... |
LL | | -1.0 / 0.0 => [ false, true, false, false, false, true]
LL | | }
| |_- in this macro invocation
|
note: required for `bool` to implement `PartialEq<NonDet>`
--> $DIR/const-float-classify.rs:12:12
|
LL | impl const PartialEq<NonDet> for bool {
| ----- ^^^^^^^^^^^^^^^^^ ^^^^
| |
| unsatisfied trait bound introduced here
= note: this error originates in the macro `const_assert` which comes from the expansion of the macro `suite` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0284]: type annotations needed
--> $DIR/const-float-classify.rs:21:35
|
LL | const _: () = assert!($a == $b);
| ^^ cannot infer the value of the constant `_`
...
LL | / suite! {
LL | | [is_nan, is_infinite, is_finite, is_normal, is_sign_positive, is_sign_negative]
LL | | -0.0 / 0.0 => [ true, false, false, false, NonDet, NonDet]
LL | | 0.0 / 0.0 => [ true, false, false, false, NonDet, NonDet]
... |
LL | | -1.0 / 0.0 => [ false, true, false, false, false, true]
LL | | }
| |_- in this macro invocation
|
note: required for `bool` to implement `PartialEq<NonDet>`
--> $DIR/const-float-classify.rs:12:12
|
LL | impl const PartialEq<NonDet> for bool {
| ----- ^^^^^^^^^^^^^^^^^ ^^^^
| |
| unsatisfied trait bound introduced here
= note: this error originates in the macro `const_assert` which comes from the expansion of the macro `suite` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0284]: type annotations needed
--> $DIR/const-float-classify.rs:21:35
|
LL | const _: () = assert!($a == $b);
| ^^ cannot infer the value of the constant `_`
...
LL | / suite! {
LL | | [is_nan, is_infinite, is_finite, is_normal, is_sign_positive, is_sign_negative]
LL | | -0.0 / 0.0 => [ true, false, false, false, NonDet, NonDet]
LL | | 0.0 / 0.0 => [ true, false, false, false, NonDet, NonDet]
... |
LL | | -1.0 / 0.0 => [ false, true, false, false, false, true]
LL | | }
| |_- in this macro invocation
|
note: required for `bool` to implement `PartialEq<NonDet>`
--> $DIR/const-float-classify.rs:12:12
|
LL | impl const PartialEq<NonDet> for bool {
| ----- ^^^^^^^^^^^^^^^^^ ^^^^
| |
| unsatisfied trait bound introduced here
= note: this error originates in the macro `const_assert` which comes from the expansion of the macro `suite` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0284]: type annotations needed
--> $DIR/const-float-classify.rs:21:35
|
LL | const _: () = assert!($a == $b);
| ^^ cannot infer the value of the constant `_`
...
LL | / suite! {
LL | | [is_nan, is_infinite, is_finite, is_normal, is_sign_positive, is_sign_negative]
LL | | -0.0 / 0.0 => [ true, false, false, false, NonDet, NonDet]
LL | | 0.0 / 0.0 => [ true, false, false, false, NonDet, NonDet]
... |
LL | | -1.0 / 0.0 => [ false, true, false, false, false, true]
LL | | }
| |_- in this macro invocation
|
note: required for `bool` to implement `PartialEq<NonDet>`
--> $DIR/const-float-classify.rs:12:12
|
LL | impl const PartialEq<NonDet> for bool {
| ----- ^^^^^^^^^^^^^^^^^ ^^^^
| |
| unsatisfied trait bound introduced here
= note: this error originates in the macro `const_assert` which comes from the expansion of the macro `suite` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0284]: type annotations needed
--> $DIR/const-float-classify.rs:21:35
|
LL | const _: () = assert!($a == $b);
| ^^ cannot infer the value of the constant `_`
...
LL | / suite! {
LL | | [is_nan, is_infinite, is_finite, is_normal, is_sign_positive, is_sign_negative]
LL | | -0.0 / 0.0 => [ true, false, false, false, NonDet, NonDet]
LL | | 0.0 / 0.0 => [ true, false, false, false, NonDet, NonDet]
... |
LL | | -1.0 / 0.0 => [ false, true, false, false, false, true]
LL | | }
| |_- in this macro invocation
|
note: required for `bool` to implement `PartialEq<NonDet>`
--> $DIR/const-float-classify.rs:12:12
|
LL | impl const PartialEq<NonDet> for bool {
| ----- ^^^^^^^^^^^^^^^^^ ^^^^
| |
| unsatisfied trait bound introduced here
= note: this error originates in the macro `const_assert` which comes from the expansion of the macro `suite` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0284]: type annotations needed
--> $DIR/const-float-classify.rs:21:35
|
LL | const _: () = assert!($a == $b);
| ^^ cannot infer the value of the constant `_`
...
LL | / suite! {
LL | | [is_nan, is_infinite, is_finite, is_normal, is_sign_positive, is_sign_negative]
LL | | -0.0 / 0.0 => [ true, false, false, false, NonDet, NonDet]
LL | | 0.0 / 0.0 => [ true, false, false, false, NonDet, NonDet]
... |
LL | | -1.0 / 0.0 => [ false, true, false, false, false, true]
LL | | }
| |_- in this macro invocation
|
note: required for `bool` to implement `PartialEq<NonDet>`
--> $DIR/const-float-classify.rs:12:12
|
LL | impl const PartialEq<NonDet> for bool {
| ----- ^^^^^^^^^^^^^^^^^ ^^^^
| |
| unsatisfied trait bound introduced here
= note: this error originates in the macro `const_assert` which comes from the expansion of the macro `suite` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 10 previous errors; 1 warning emitted
Some errors have detailed explanations: E0207, E0284.
For more information about an error, try `rustc --explain E0207`.

View File

@ -4,8 +4,9 @@
#![crate_type = "lib"]
#![feature(try_trait_v2)]
#![feature(const_trait_impl)]
#![feature(const_trait_impl, effects)]
#![feature(const_try)]
#![allow(incomplete_features)]
use std::ops::{ControlFlow, FromResidual, Try};

View File

@ -1,37 +1,20 @@
error[E0015]: `?` cannot determine the branch of `TryMe` in constant functions
--> $DIR/const-try.rs:33:5
|
LL | TryMe?;
| ^^^^^^
|
note: impl defined here, but it is not `const`
--> $DIR/const-try.rs:21:1
|
LL | impl const Try for TryMe {
| ^^^^^^^^^^^^^^^^^^^^^^^^
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
help: add `#![feature(effects)]` to the crate attributes to enable
|
LL + #![feature(effects)]
|
error[E0015]: `?` cannot convert from residual of `TryMe` in constant functions
--> $DIR/const-try.rs:33:5
|
LL | TryMe?;
| ^^^^^^
|
note: impl defined here, but it is not `const`
--> $DIR/const-try.rs:15:1
error: const `impl` for trait `FromResidual` which is not marked with `#[const_trait]`
--> $DIR/const-try.rs:16:12
|
LL | impl const FromResidual<Error> for TryMe {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
help: add `#![feature(effects)]` to the crate attributes to enable
| ^^^^^^^^^^^^^^^^^^^
|
LL + #![feature(effects)]
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error: const `impl` for trait `Try` which is not marked with `#[const_trait]`
--> $DIR/const-try.rs:22:12
|
LL | impl const Try for TryMe {
| ^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0015`.

View File

@ -1,6 +1,7 @@
//@ known-bug: #102498
#![feature(const_trait_impl, generic_const_exprs)]
#![feature(const_trait_impl, effects, generic_const_exprs)]
#![allow(incomplete_features)]
#[const_trait]
pub trait Tr {

View File

@ -1,36 +1,9 @@
warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/constifconst-call-in-const-position.rs:3:30
|
LL | #![feature(const_trait_impl, generic_const_exprs)]
| ^^^^^^^^^^^^^^^^^^^
|
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
= note: `#[warn(incomplete_features)]` on by default
error[E0015]: cannot call non-const fn `<T as Tr>::a` in constants
--> $DIR/constifconst-call-in-const-position.rs:17:9
|
LL | [0; T::a()]
| ^^^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
help: add `#![feature(effects)]` to the crate attributes to enable
|
LL + #![feature(effects)]
|
error[E0015]: cannot call non-const fn `<T as Tr>::a` in constants
--> $DIR/constifconst-call-in-const-position.rs:16:38
error[E0080]: evaluation of `foo::<()>::{constant#0}` failed
--> $DIR/constifconst-call-in-const-position.rs:17:38
|
LL | const fn foo<T: ~const Tr>() -> [u8; T::a()] {
| ^^^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
help: add `#![feature(effects)]` to the crate attributes to enable
|
LL + #![feature(effects)]
|
| ^^^^^^ calling non-const function `<() as Tr>::a`
error: aborting due to 2 previous errors; 1 warning emitted
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0015`.
For more information about this error, try `rustc --explain E0080`.

View File

@ -4,6 +4,7 @@
struct A();
impl const Drop for A {
//~^ ERROR const `impl` for trait `Drop` which is not marked with `#[const_trait]`
fn drop(&mut self) {}
}

View File

@ -1,5 +1,14 @@
error: const `impl` for trait `Drop` which is not marked with `#[const_trait]`
--> $DIR/promoted-const-drop.rs:6:12
|
LL | impl const Drop for A {
| ^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error[E0716]: temporary value dropped while borrowed
--> $DIR/promoted-const-drop.rs:13:26
--> $DIR/promoted-const-drop.rs:14:26
|
LL | let _: &'static A = &A();
| ---------- ^^^ creates a temporary value which is freed while still in use
@ -10,7 +19,7 @@ LL | }
| - temporary value is freed at the end of this statement
error[E0716]: temporary value dropped while borrowed
--> $DIR/promoted-const-drop.rs:14:28
--> $DIR/promoted-const-drop.rs:15:28
|
LL | let _: &'static [A] = &[C];
| ------------ ^^^ creates a temporary value which is freed while still in use
@ -19,6 +28,6 @@ LL | let _: &'static [A] = &[C];
LL | }
| - temporary value is freed at the end of this statement
error: aborting due to 2 previous errors
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0716`.

View File

@ -1,10 +1,31 @@
error[E0493]: destructor of `Panic` cannot be evaluated at compile-time
error: const `impl` for trait `Drop` which is not marked with `#[const_trait]`
--> $DIR/promoted_const_call.rs:7:12
|
LL | impl const Drop for Panic { fn drop(&mut self) { panic!(); } }
| ^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error[E0716]: temporary value dropped while borrowed
--> $DIR/promoted_const_call.rs:11:26
|
LL | let _: &'static _ = &id(&Panic);
| ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use
| |
| type annotation requires that borrow lasts for `'static`
...
LL | };
| - temporary value is freed at the end of this statement
error[E0716]: temporary value dropped while borrowed
--> $DIR/promoted_const_call.rs:11:30
|
LL | let _: &'static _ = &id(&Panic);
| ^^^^^ - value is dropped here
| |
| the destructor for this type cannot be evaluated in constants
| ---------- ^^^^^ - temporary value is freed at the end of this statement
| | |
| | creates a temporary value which is freed while still in use
| type annotation requires that borrow lasts for `'static`
error[E0716]: temporary value dropped while borrowed
--> $DIR/promoted_const_call.rs:17:26
@ -48,7 +69,6 @@ LL | let _: &'static _ = &&(Panic, 0).1;
LL | }
| - temporary value is freed at the end of this statement
error: aborting due to 5 previous errors
error: aborting due to 7 previous errors
Some errors have detailed explanations: E0493, E0716.
For more information about an error, try `rustc --explain E0493`.
For more information about this error, try `rustc --explain E0716`.

View File

@ -16,15 +16,5 @@ LL | impl const Default for Data {
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error[E0207]: the const parameter `host` is not constrained by the impl trait, self type, or predicates
--> $DIR/rustc-impl-const-stability.rs:15:6
|
LL | impl const Default for Data {
| ^^^^^ 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 1 previous error; 1 warning emitted
error: aborting due to 2 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0207`.

View File

@ -1,4 +1,5 @@
#![feature(const_trait_impl, effects)] //~ WARN the feature `effects` is incomplete
#![allow(incomplete_features)]
#![feature(const_trait_impl, effects)]
#[const_trait]
pub trait MyTrait {

View File

@ -1,6 +1,6 @@
// Tests that trait bounds on specializing trait impls must be `~const` if the
// same bound is present on the default impl and is `~const` there.
//@ check-pass
//@ known-bug: #110395
// FIXME(effects) ^ should error
#![feature(const_trait_impl)]

View File

@ -0,0 +1,41 @@
error[E0049]: method `bar` has 1 const parameter but its trait declaration has 0 const parameters
--> $DIR/const-default-bound-non-const-specialized-bound.rs:16:1
|
LL | #[const_trait]
| ^^^^^^^^^^^^^^ found 1 const parameter
LL | trait Bar {
LL | fn bar();
| - expected 0 const parameters
error: cannot specialize on const impl with non-const impl
--> $DIR/const-default-bound-non-const-specialized-bound.rs:28:1
|
LL | / impl<T> Bar for T
LL | | where
LL | | T: Foo, //FIXME ~ ERROR missing `~const` qualifier
LL | | T: Specialize,
| |__________________^
error[E0049]: method `baz` has 1 const parameter but its trait declaration has 0 const parameters
--> $DIR/const-default-bound-non-const-specialized-bound.rs:36:1
|
LL | #[const_trait]
| ^^^^^^^^^^^^^^ found 1 const parameter
LL | trait Baz {
LL | fn baz();
| - expected 0 const parameters
error[E0049]: method `baz` has 1 const parameter but its trait declaration has 0 const parameters
--> $DIR/const-default-bound-non-const-specialized-bound.rs:36:1
|
LL | #[const_trait]
| ^^^^^^^^^^^^^^ found 1 const parameter
LL | trait Baz {
LL | fn baz();
| - expected 0 const parameters
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0049`.

View File

@ -1,9 +1,10 @@
// Tests that a const default trait impl can be specialized by another const
// trait impl and that the specializing impl will be used during const-eval.
//@ run-pass
//@ known-bug: #110395
// FIXME(effects) run-pass
#![feature(const_trait_impl, effects)] //~ WARN the feature `effects` is incomplete
#![feature(const_trait_impl)]
#![feature(min_specialization)]
#[const_trait]

View File

@ -1,11 +1,36 @@
warning: the feature `effects` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/const-default-const-specialized.rs:6:30
error[E0049]: method `value` has 1 const parameter but its trait declaration has 0 const parameters
--> $DIR/const-default-const-specialized.rs:10:1
|
LL | #![feature(const_trait_impl, effects)]
| ^^^^^^^
LL | #[const_trait]
| ^^^^^^^^^^^^^^ found 1 const parameter
LL | trait Value {
LL | fn value() -> u32;
| - expected 0 const parameters
error[E0049]: method `value` has 1 const parameter but its trait declaration has 0 const parameters
--> $DIR/const-default-const-specialized.rs:10:1
|
= note: see issue #102090 <https://github.com/rust-lang/rust/issues/102090> for more information
= note: `#[warn(incomplete_features)]` on by default
LL | #[const_trait]
| ^^^^^^^^^^^^^^ found 1 const parameter
LL | trait Value {
LL | fn value() -> u32;
| - expected 0 const parameters
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
warning: 1 warning emitted
error[E0015]: cannot call non-const fn `<T as Value>::value` in constant functions
--> $DIR/const-default-const-specialized.rs:16:5
|
LL | T::value()
| ^^^^^^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
help: add `#![feature(effects)]` to the crate attributes to enable
|
LL + #![feature(effects)]
|
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0015, E0049.
For more information about an error, try `rustc --explain E0015`.

View File

@ -1,4 +1,5 @@
//@ check-pass
//@ known-bug: #110395
// FIXME check-pass
#![feature(const_trait_impl)]
#![feature(min_specialization)]

View File

@ -0,0 +1,12 @@
error[E0049]: method `foo` has 1 const parameter but its trait declaration has 0 const parameters
--> $DIR/default-keyword.rs:7:1
|
LL | #[const_trait]
| ^^^^^^^^^^^^^^ found 1 const parameter
LL | trait Foo {
LL | fn foo();
| - expected 0 const parameters
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0049`.

View File

@ -1,6 +1,7 @@
// Tests that `~const` trait bounds can be used to specialize const trait impls.
//@ check-pass
//@ known-bug: #110395
// FIXME check-pass
#![feature(const_trait_impl)]
#![feature(rustc_attrs)]

View File

@ -0,0 +1,43 @@
error[E0049]: method `foo` has 1 const parameter but its trait declaration has 0 const parameters
--> $DIR/issue-95186-specialize-on-tilde-const.rs:14:1
|
LL | #[const_trait]
| ^^^^^^^^^^^^^^ found 1 const parameter
LL | trait Foo {
LL | fn foo();
| - expected 0 const parameters
error[E0049]: method `foo` has 1 const parameter but its trait declaration has 0 const parameters
--> $DIR/issue-95186-specialize-on-tilde-const.rs:14:1
|
LL | #[const_trait]
| ^^^^^^^^^^^^^^ found 1 const parameter
LL | trait Foo {
LL | fn foo();
| - expected 0 const parameters
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0049]: method `bar` has 1 const parameter but its trait declaration has 0 const parameters
--> $DIR/issue-95186-specialize-on-tilde-const.rs:30:1
|
LL | #[const_trait]
| ^^^^^^^^^^^^^^ found 1 const parameter
LL | trait Bar {
LL | fn bar() {}
| - expected 0 const parameters
error[E0049]: method `bar` has 1 const parameter but its trait declaration has 0 const parameters
--> $DIR/issue-95186-specialize-on-tilde-const.rs:30:1
|
LL | #[const_trait]
| ^^^^^^^^^^^^^^ found 1 const parameter
LL | trait Bar {
LL | fn bar() {}
| - expected 0 const parameters
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0049`.

View File

@ -2,7 +2,8 @@
// `T: Foo` in the default impl for the purposes of specialization (i.e., it
// does not think that the user is attempting to specialize on trait `Foo`).
//@ check-pass
//@ known-bug: #110395
// FIXME check-pass
#![feature(rustc_attrs)]
#![feature(min_specialization)]

View File

@ -0,0 +1,43 @@
error[E0049]: method `bar` has 1 const parameter but its trait declaration has 0 const parameters
--> $DIR/issue-95187-same-trait-bound-different-constness.rs:18:1
|
LL | #[const_trait]
| ^^^^^^^^^^^^^^ found 1 const parameter
LL | trait Bar {
LL | fn bar();
| - expected 0 const parameters
error[E0049]: method `bar` has 1 const parameter but its trait declaration has 0 const parameters
--> $DIR/issue-95187-same-trait-bound-different-constness.rs:18:1
|
LL | #[const_trait]
| ^^^^^^^^^^^^^^ found 1 const parameter
LL | trait Bar {
LL | fn bar();
| - expected 0 const parameters
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0049]: method `baz` has 1 const parameter but its trait declaration has 0 const parameters
--> $DIR/issue-95187-same-trait-bound-different-constness.rs:38:1
|
LL | #[const_trait]
| ^^^^^^^^^^^^^^ found 1 const parameter
LL | trait Baz {
LL | fn baz();
| - expected 0 const parameters
error[E0049]: method `baz` has 1 const parameter but its trait declaration has 0 const parameters
--> $DIR/issue-95187-same-trait-bound-different-constness.rs:38:1
|
LL | #[const_trait]
| ^^^^^^^^^^^^^^ found 1 const parameter
LL | trait Baz {
LL | fn baz();
| - expected 0 const parameters
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0049`.

View File

@ -1,9 +1,9 @@
// Tests that a non-const default impl can be specialized by a const trait impl,
// but that the default impl cannot be used in a const context.
//@ known-bug: #110395
// FIXME run-pass
// FIXME(effects) run-pass
#![feature(const_trait_impl, effects)]
#![feature(const_trait_impl)]
#![feature(min_specialization)]
#[const_trait]

View File

@ -1,21 +1,36 @@
warning: the feature `effects` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/non-const-default-const-specialized.rs:6:30
error[E0049]: method `value` has 1 const parameter but its trait declaration has 0 const parameters
--> $DIR/non-const-default-const-specialized.rs:9:1
|
LL | #![feature(const_trait_impl, effects)]
| ^^^^^^^
LL | #[const_trait]
| ^^^^^^^^^^^^^^ found 1 const parameter
LL | trait Value {
LL | fn value() -> u32;
| - expected 0 const parameters
error[E0049]: method `value` has 1 const parameter but its trait declaration has 0 const parameters
--> $DIR/non-const-default-const-specialized.rs:9:1
|
= note: see issue #102090 <https://github.com/rust-lang/rust/issues/102090> for more information
= note: `#[warn(incomplete_features)]` on by default
error[E0119]: conflicting implementations of trait `Value` for type `FortyTwo`
--> $DIR/non-const-default-const-specialized.rs:27:1
LL | #[const_trait]
| ^^^^^^^^^^^^^^ found 1 const parameter
LL | trait Value {
LL | fn value() -> u32;
| - expected 0 const parameters
|
LL | impl<T> Value for T {
| ------------------- first implementation here
...
LL | impl const Value for FortyTwo {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `FortyTwo`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 1 previous error; 1 warning emitted
error[E0015]: cannot call non-const fn `<T as Value>::value` in constant functions
--> $DIR/non-const-default-const-specialized.rs:15:5
|
LL | T::value()
| ^^^^^^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
help: add `#![feature(effects)]` to the crate attributes to enable
|
LL + #![feature(effects)]
|
For more information about this error, try `rustc --explain E0119`.
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0015, E0049.
For more information about an error, try `rustc --explain E0015`.

View File

@ -3,8 +3,8 @@
// (`rustc_const_eval` instead of `rustc_hir_analysis`) Therefore one file as a
// test is not enough.
//@ known-bug: #110395
// FIXME check-pass
#![feature(const_trait_impl, effects)]
#![allow(incomplete_features)]
#[const_trait]
trait Bar {}
@ -19,9 +19,9 @@ trait Foo {
const fn test1<T: ~const Foo + Bar>() {
T::a();
T::b();
//FIXME ~^ ERROR the trait bound
//~^ ERROR mismatched types
T::c::<T>();
//FIXME ~^ ERROR the trait bound
//~^ ERROR mismatched types
}
const fn test2<T: ~const Foo + ~const Bar>() {

View File

@ -1,3 +1,23 @@
error[E0049]: method `foo` has 1 const parameter but its trait declaration has 0 const parameters
--> $DIR/const_trait_impl.rs:6:1
|
LL | #[const_trait]
| ^^^^^^^^^^^^^^ found 1 const parameter
LL | pub unsafe trait Sup {
LL | fn foo() -> u32;
| - expected 0 const parameters
error[E0049]: method `foo` has 1 const parameter but its trait declaration has 0 const parameters
--> $DIR/const_trait_impl.rs:6:1
|
LL | #[const_trait]
| ^^^^^^^^^^^^^^ found 1 const parameter
LL | pub unsafe trait Sup {
LL | fn foo() -> u32;
| - expected 0 const parameters
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const_trait_impl.rs:34:16
|
@ -16,6 +36,37 @@ error: `~const` can only be applied to `#[const_trait]` traits
LL | impl<T: ~const Default + ~const Sub> const A for T {
| ^^^^^^^
error[E0049]: method `a` has 1 const parameter but its trait declaration has 0 const parameters
--> $DIR/const_trait_impl.rs:29:1
|
LL | #[const_trait]
| ^^^^^^^^^^^^^^ found 1 const parameter
LL | pub trait A {
LL | fn a() -> u32;
| - expected 0 const parameters
error[E0049]: method `a` has 1 const parameter but its trait declaration has 0 const parameters
--> $DIR/const_trait_impl.rs:29:1
|
LL | #[const_trait]
| ^^^^^^^^^^^^^^ found 1 const parameter
LL | pub trait A {
LL | fn a() -> u32;
| - expected 0 const parameters
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0049]: method `a` has 1 const parameter but its trait declaration has 0 const parameters
--> $DIR/const_trait_impl.rs:29:1
|
LL | #[const_trait]
| ^^^^^^^^^^^^^^ found 1 const parameter
LL | pub trait A {
LL | fn a() -> u32;
| - expected 0 const parameters
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0015]: cannot call non-const fn `<() as A>::a` in constants
--> $DIR/const_trait_impl.rs:52:23
|
@ -52,6 +103,19 @@ help: add `#![feature(effects)]` to the crate attributes to enable
LL + #![feature(effects)]
|
error: aborting due to 6 previous errors
error[E0015]: cannot call non-const fn `<T as Sup>::foo` in constant functions
--> $DIR/const_trait_impl.rs:48:9
|
LL | T::foo()
| ^^^^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
help: add `#![feature(effects)]` to the crate attributes to enable
|
LL + #![feature(effects)]
|
For more information about this error, try `rustc --explain E0015`.
error: aborting due to 12 previous errors
Some errors have detailed explanations: E0015, E0049.
For more information about an error, try `rustc --explain E0015`.