From a6a83d3d4ed4666ccc5cff4043e2ce89279ad6a4 Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Fri, 21 Jun 2024 11:57:24 +0000 Subject: [PATCH] bless tests --- tests/crashes/120503.rs | 10 - tests/crashes/121536.rs | 20 -- .../ui/consts/const-block-const-bound.stderr | 8 +- tests/ui/consts/const-float-classify.rs | 3 +- tests/ui/consts/const-float-classify.stderr | 214 +++++++++++++++ tests/ui/consts/const_cmp_type_id.stderr | 22 +- tests/ui/consts/fn_trait_refs.stderr | 32 ++- .../impl-trait/normalize-tait-in-const.stderr | 8 +- tests/ui/intrinsics/not-overridden.rs | 2 +- .../ui/intrinsics/safe-intrinsic-mismatch.rs | 4 +- .../intrinsics/safe-intrinsic-mismatch.stderr | 11 +- .../call-generic-in-impl.rs | 3 +- .../call-generic-in-impl.stderr | 8 + .../call-generic-method-chain.rs | 3 +- .../call-generic-method-chain.stderr | 62 +++++ .../call-generic-method-dup-bound.rs | 3 +- .../call-generic-method-dup-bound.stderr | 76 ++++++ .../call-generic-method-fail.rs | 4 +- .../call-generic-method-fail.stderr | 12 - .../call-generic-method-pass.rs | 3 +- .../call-generic-method-pass.stderr | 56 ++++ .../const-and-non-const-impl.stderr | 18 +- .../const-drop-bound.stderr | 20 +- .../const-drop-fail-2.stderr | 8 +- .../const-drop-fail.precise.stderr | 8 +- .../const-drop-fail.stock.stderr | 8 +- .../const-drop.precise.stderr | 8 +- .../const-drop.stock.stderr | 8 +- .../const-impl-trait.stderr | 256 ++++++++++++++++-- .../const_derives/derive-const-use.stderr | 78 +++++- .../const_derives/derive-const-with-params.rs | 3 +- .../derive-const-with-params.stderr | 40 +++ .../ice-112822-expected-type-for-param.rs | 3 +- .../ice-112822-expected-type-for-param.stderr | 47 +--- .../effects/minicore.rs | 4 +- .../effects/minicore.stderr | 9 + .../ice-120503-async-const-method.rs | 18 ++ .../ice-120503-async-const-method.stderr | 92 +++++++ .../ice-121536-const-method.rs | 17 ++ .../ice-121536-const-method.stderr | 19 ++ .../issue-92111.stderr | 8 +- tests/ui/ufcs/ufcs-qpath-self-mismatch.stderr | 26 +- 42 files changed, 1077 insertions(+), 185 deletions(-) delete mode 100644 tests/crashes/120503.rs delete mode 100644 tests/crashes/121536.rs create mode 100644 tests/ui/consts/const-float-classify.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-in-impl.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-chain.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-dup-bound.stderr delete mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-fail.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-pass.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-with-params.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/effects/minicore.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/ice-120503-async-const-method.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/ice-120503-async-const-method.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/ice-121536-const-method.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/ice-121536-const-method.stderr diff --git a/tests/crashes/120503.rs b/tests/crashes/120503.rs deleted file mode 100644 index 28f1e3dfd94c4..0000000000000 --- a/tests/crashes/120503.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ known-bug: #120503 -#![feature(effects)] - -trait MyTrait {} - -impl MyTrait for i32 { - async const fn bar(&self) { - main8().await; - } -} diff --git a/tests/crashes/121536.rs b/tests/crashes/121536.rs deleted file mode 100644 index 000e7cb15eb2f..0000000000000 --- a/tests/crashes/121536.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ known-bug: #121536 -#![feature(effects)] - -#[derive(Debug, Clone, Copy)] -pub struct Vec3 { - pub x: f32, - pub y: f32, - pub z: f32, -} - -impl std::ops::Add for Vec3 { - type Output = Vec3; - const fn add(self, b: Vec3) -> Self::Output { - Vec3 { - x: self.x + b.x, - y: self.y + b.y, - z: self.z + b.z, - } - } -} diff --git a/tests/ui/consts/const-block-const-bound.stderr b/tests/ui/consts/const-block-const-bound.stderr index 81790a62f61da..42a42ae3938b7 100644 --- a/tests/ui/consts/const-block-const-bound.stderr +++ b/tests/ui/consts/const-block-const-bound.stderr @@ -1,3 +1,9 @@ +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/const-block-const-bound.rs:8:22 + | +LL | const fn f(x: T) {} + | ^^^^^^^^ + error[E0493]: destructor of `T` cannot be evaluated at compile-time --> $DIR/const-block-const-bound.rs:8:32 | @@ -6,6 +12,6 @@ LL | const fn f(x: T) {} | | | the destructor for this type cannot be evaluated in constant functions -error: aborting due to 1 previous error +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0493`. diff --git a/tests/ui/consts/const-float-classify.rs b/tests/ui/consts/const-float-classify.rs index 44772fb731369..ae094003c89e2 100644 --- a/tests/ui/consts/const-float-classify.rs +++ b/tests/ui/consts/const-float-classify.rs @@ -1,5 +1,6 @@ //@ compile-flags: -Zmir-opt-level=0 -//@ run-pass +//@ known-bug: #110395 +// FIXME(effects) run-pass #![feature(const_float_bits_conv)] #![feature(const_float_classify)] diff --git a/tests/ui/consts/const-float-classify.stderr b/tests/ui/consts/const-float-classify.stderr new file mode 100644 index 0000000000000..9ecd7b83681e1 --- /dev/null +++ b/tests/ui/consts/const-float-classify.stderr @@ -0,0 +1,214 @@ +error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]` + --> $DIR/const-float-classify.rs:12:12 + | +LL | impl const PartialEq 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 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[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` + --> $DIR/const-float-classify.rs:12:12 + | +LL | impl const PartialEq 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` + --> $DIR/const-float-classify.rs:12:12 + | +LL | impl const PartialEq 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` + --> $DIR/const-float-classify.rs:12:12 + | +LL | impl const PartialEq 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` + --> $DIR/const-float-classify.rs:12:12 + | +LL | impl const PartialEq 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` + --> $DIR/const-float-classify.rs:12:12 + | +LL | impl const PartialEq 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` + --> $DIR/const-float-classify.rs:12:12 + | +LL | impl const PartialEq 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` + --> $DIR/const-float-classify.rs:12:12 + | +LL | impl const PartialEq 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` + --> $DIR/const-float-classify.rs:12:12 + | +LL | impl const PartialEq 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 + +Some errors have detailed explanations: E0207, E0284. +For more information about an error, try `rustc --explain E0207`. diff --git a/tests/ui/consts/const_cmp_type_id.stderr b/tests/ui/consts/const_cmp_type_id.stderr index 98f5b3a5e90d3..f9628e5443b8d 100644 --- a/tests/ui/consts/const_cmp_type_id.stderr +++ b/tests/ui/consts/const_cmp_type_id.stderr @@ -10,25 +10,7 @@ error[E0080]: evaluation of constant value failed LL | const _A: bool = TypeId::of::() < TypeId::of::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ calling non-const function `::lt` -error[E0308]: mismatched types - --> $DIR/const_cmp_type_id.rs:8:13 - | -LL | assert!(TypeId::of::() == TypeId::of::()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `host`, found `true` - | - = note: expected constant `host` - found constant `true` - -error[E0308]: mismatched types - --> $DIR/const_cmp_type_id.rs:9:13 - | -LL | assert!(TypeId::of::<()>() != TypeId::of::()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `host`, found `true` - | - = note: expected constant `host` - found constant `true` - -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0080, E0131, E0308. +Some errors have detailed explanations: E0080, E0131. For more information about an error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/fn_trait_refs.stderr b/tests/ui/consts/fn_trait_refs.stderr index 4fb82c0683dc6..42a6026cfbad3 100644 --- a/tests/ui/consts/fn_trait_refs.stderr +++ b/tests/ui/consts/fn_trait_refs.stderr @@ -4,12 +4,24 @@ error[E0635]: unknown feature `const_fn_trait_ref_impls` LL | #![feature(const_fn_trait_ref_impls)] | ^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0635]: unknown feature `const_cmp` + --> $DIR/fn_trait_refs.rs:8:12 + | +LL | #![feature(const_cmp)] + | ^^^^^^^^^ + error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/fn_trait_refs.rs:15:15 | LL | T: ~const Fn<()> + ~const Destruct, | ^^^^^^ +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/fn_trait_refs.rs:15:31 + | +LL | T: ~const Fn<()> + ~const Destruct, + | ^^^^^^^^ + error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/fn_trait_refs.rs:15:15 | @@ -24,6 +36,12 @@ error: `~const` can only be applied to `#[const_trait]` traits LL | T: ~const FnMut<()> + ~const Destruct, | ^^^^^^^^^ +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/fn_trait_refs.rs:22:34 + | +LL | T: ~const FnMut<()> + ~const Destruct, + | ^^^^^^^^ + error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/fn_trait_refs.rs:22:15 | @@ -52,6 +70,12 @@ error: `~const` can only be applied to `#[const_trait]` traits LL | T: ~const Fn<()> + ~const Destruct, | ^^^^^^ +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/fn_trait_refs.rs:36:31 + | +LL | T: ~const Fn<()> + ~const Destruct, + | ^^^^^^^^ + error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/fn_trait_refs.rs:36:15 | @@ -66,6 +90,12 @@ error: `~const` can only be applied to `#[const_trait]` traits LL | T: ~const FnMut<()> + ~const Destruct, | ^^^^^^^^^ +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/fn_trait_refs.rs:50:34 + | +LL | T: ~const FnMut<()> + ~const Destruct, + | ^^^^^^^^ + error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/fn_trait_refs.rs:50:15 | @@ -182,7 +212,7 @@ LL | const fn test_fn_mut(mut f: T) -> (T::Output, T::Output) LL | } | - value is dropped here -error: aborting due to 20 previous errors +error: aborting due to 25 previous errors Some errors have detailed explanations: E0015, E0493, E0635. For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/impl-trait/normalize-tait-in-const.stderr b/tests/ui/impl-trait/normalize-tait-in-const.stderr index 5e3c0ea054bdd..73f4d4c388563 100644 --- a/tests/ui/impl-trait/normalize-tait-in-const.stderr +++ b/tests/ui/impl-trait/normalize-tait-in-const.stderr @@ -4,6 +4,12 @@ error: `~const` can only be applied to `#[const_trait]` traits LL | const fn with_positive Fn(&'a Alias<'a>) + ~const Destruct>(fun: F) { | ^^^^^^^^^^^^^^^^^ +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/normalize-tait-in-const.rs:27:69 + | +LL | const fn with_positive Fn(&'a Alias<'a>) + ~const Destruct>(fun: F) { + | ^^^^^^^^ + error[E0015]: cannot call non-const closure in constant functions --> $DIR/normalize-tait-in-const.rs:28:5 | @@ -29,7 +35,7 @@ LL | fun(filter_positive()); LL | } | - value is dropped here -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors Some errors have detailed explanations: E0015, E0493. For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/intrinsics/not-overridden.rs b/tests/ui/intrinsics/not-overridden.rs index d6655b51905ae..a53071e304d89 100644 --- a/tests/ui/intrinsics/not-overridden.rs +++ b/tests/ui/intrinsics/not-overridden.rs @@ -1,6 +1,6 @@ //! Check that intrinsics that do not get overridden, but are marked as such, //! cause an error instead of silently invoking the body. -#![feature(rustc_attrs, effects)] +#![feature(rustc_attrs/* , effects*/)] // FIXME(effects) //@ build-fail //@ failure-status:101 //@ normalize-stderr-test ".*note: .*\n\n" -> "" diff --git a/tests/ui/intrinsics/safe-intrinsic-mismatch.rs b/tests/ui/intrinsics/safe-intrinsic-mismatch.rs index 23cd5f1083534..c116ba7a62eeb 100644 --- a/tests/ui/intrinsics/safe-intrinsic-mismatch.rs +++ b/tests/ui/intrinsics/safe-intrinsic-mismatch.rs @@ -1,6 +1,6 @@ #![feature(intrinsics)] #![feature(rustc_attrs)] -#![feature(effects)] +// FIXME(effects) do this with revisions #![feature(effects)] extern "rust-intrinsic" { fn size_of() -> usize; //~ ERROR intrinsic safety mismatch @@ -19,7 +19,7 @@ const fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {} mod foo { #[rustc_intrinsic] unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {} - //~^ ERROR wrong number of const parameters + // FIXME(effects) ~^ ERROR wrong number of const parameters } fn main() {} diff --git a/tests/ui/intrinsics/safe-intrinsic-mismatch.stderr b/tests/ui/intrinsics/safe-intrinsic-mismatch.stderr index d73d5bab8d76a..7f37e0f821118 100644 --- a/tests/ui/intrinsics/safe-intrinsic-mismatch.stderr +++ b/tests/ui/intrinsics/safe-intrinsic-mismatch.stderr @@ -42,13 +42,6 @@ LL | const fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {} = note: expected signature `unsafe fn(_, _, _)` found signature `fn(_, _, _)` -error[E0094]: intrinsic has wrong number of const parameters: found 0, expected 1 - --> $DIR/safe-intrinsic-mismatch.rs:21:31 - | -LL | unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {} - | ^ expected 1 const parameter - -error: aborting due to 7 previous errors +error: aborting due to 6 previous errors -Some errors have detailed explanations: E0094, E0308. -For more information about an error, try `rustc --explain E0094`. +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-in-impl.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-in-impl.rs index b63458b39e95d..6b3a4ae1b95ee 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-in-impl.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-in-impl.rs @@ -1,4 +1,5 @@ -//@ check-pass +//@ known-bug: #110395 +// FIXME(effects) check-pass #![feature(const_trait_impl)] #[const_trait] diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-in-impl.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-in-impl.stderr new file mode 100644 index 0000000000000..12027c4d71362 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-in-impl.stderr @@ -0,0 +1,8 @@ +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/call-generic-in-impl.rs:10:16 + | +LL | impl const MyPartialEq for T { + | ^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-chain.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-chain.rs index 37b2de0fd2d49..9df694a02f596 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-chain.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-chain.rs @@ -1,6 +1,7 @@ //! Basic test for calling methods on generic type parameters in `const fn`. -//@ check-pass +//@ known-bug: #110395 +// FIXME(effects) check-pass #![feature(const_trait_impl, effects)] diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-chain.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-chain.stderr new file mode 100644 index 0000000000000..4b0d304c5bee2 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-chain.stderr @@ -0,0 +1,62 @@ +error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]` + --> $DIR/call-generic-method-chain.rs:10:12 + | +LL | impl const PartialEq for S { + | ^^^^^^^^^ + | + = 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/call-generic-method-chain.rs:10:6 + | +LL | impl const PartialEq for S { + | ^^^^^ 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: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/call-generic-method-chain.rs:19:32 + | +LL | const fn equals_self(t: &T) -> bool { + | ^^^^^^^^^ + +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/call-generic-method-chain.rs:23:40 + | +LL | const fn equals_self_wrapper(t: &T) -> bool { + | ^^^^^^^^^ + +error[E0284]: type annotations needed + --> $DIR/call-generic-method-chain.rs:27:22 + | +LL | pub const EQ: bool = equals_self_wrapper(&S); + | ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the constant `_` + | +note: required for `S` to implement `PartialEq` + --> $DIR/call-generic-method-chain.rs:10:12 + | +LL | impl const PartialEq for S { + | ----- ^^^^^^^^^ ^ + | | + | unsatisfied trait bound introduced here + +error[E0284]: type annotations needed + --> $DIR/call-generic-method-chain.rs:15:10 + | +LL | !self.eq(other) + | ^^^^^^^^^^^^^^ cannot infer the value of the constant `_` + | +note: required for `S` to implement `PartialEq` + --> $DIR/call-generic-method-chain.rs:10:12 + | +LL | impl const PartialEq for S { + | ----- ^^^^^^^^^ ^ + | | + | unsatisfied trait bound introduced here + +error: aborting due to 6 previous errors + +Some errors have detailed explanations: E0207, E0284. +For more information about an error, try `rustc --explain E0207`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-dup-bound.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-dup-bound.rs index ea8fd00556191..f46a34911f193 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-dup-bound.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-dup-bound.rs @@ -1,4 +1,5 @@ -//@ check-pass +//@ known-bug: #110395 +// FIXME(effects) check-pass #![feature(const_trait_impl, effects)] diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-dup-bound.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-dup-bound.stderr new file mode 100644 index 0000000000000..69f7029516091 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-dup-bound.stderr @@ -0,0 +1,76 @@ +error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]` + --> $DIR/call-generic-method-dup-bound.rs:8:12 + | +LL | impl const PartialEq for S { + | ^^^^^^^^^ + | + = 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/call-generic-method-dup-bound.rs:8:6 + | +LL | impl const PartialEq for S { + | ^^^^^ 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: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/call-generic-method-dup-bound.rs:19:44 + | +LL | const fn equals_self(t: &T) -> bool { + | ^^^^^^^^^ + +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/call-generic-method-dup-bound.rs:26:37 + | +LL | const fn equals_self2(t: &T) -> bool { + | ^^^^^^^^^ + +error[E0284]: type annotations needed + --> $DIR/call-generic-method-dup-bound.rs:30:22 + | +LL | pub const EQ: bool = equals_self(&S) && equals_self2(&S); + | ^^^^^^^^^^^^^^^ cannot infer the value of the constant `_` + | +note: required for `S` to implement `PartialEq` + --> $DIR/call-generic-method-dup-bound.rs:8:12 + | +LL | impl const PartialEq for S { + | ----- ^^^^^^^^^ ^ + | | + | unsatisfied trait bound introduced here + +error[E0284]: type annotations needed + --> $DIR/call-generic-method-dup-bound.rs:30:41 + | +LL | pub const EQ: bool = equals_self(&S) && equals_self2(&S); + | ^^^^^^^^^^^^^^^^ cannot infer the value of the constant `_` + | +note: required for `S` to implement `PartialEq` + --> $DIR/call-generic-method-dup-bound.rs:8:12 + | +LL | impl const PartialEq for S { + | ----- ^^^^^^^^^ ^ + | | + | unsatisfied trait bound introduced here + +error[E0284]: type annotations needed + --> $DIR/call-generic-method-dup-bound.rs:13:10 + | +LL | !self.eq(other) + | ^^^^^^^^^^^^^^ cannot infer the value of the constant `_` + | +note: required for `S` to implement `PartialEq` + --> $DIR/call-generic-method-dup-bound.rs:8:12 + | +LL | impl const PartialEq for S { + | ----- ^^^^^^^^^ ^ + | | + | unsatisfied trait bound introduced here + +error: aborting due to 7 previous errors + +Some errors have detailed explanations: E0207, E0284. +For more information about an error, try `rustc --explain E0207`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-fail.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-fail.rs index 043939750a856..cc5f218ae2def 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-fail.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-fail.rs @@ -1,8 +1,10 @@ +//@ check-pass + #![feature(const_trait_impl, effects)] pub const fn equals_self(t: &T) -> bool { *t == *t - //~^ ERROR mismatched types + // FIXME(effects) ~^ ERROR mismatched types // FIXME(effects): diagnostic } diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-fail.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-fail.stderr deleted file mode 100644 index 5074c4a22610b..0000000000000 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-fail.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/call-generic-method-fail.rs:4:5 - | -LL | *t == *t - | ^^^^^^^^ expected `host`, found `true` - | - = note: expected constant `host` - found constant `true` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-pass.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-pass.rs index 55d8afa8d47c6..413685d8b3443 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-pass.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-pass.rs @@ -1,6 +1,7 @@ //! Basic test for calling methods on generic type parameters in `const fn`. -//@ check-pass +//@ known-bug: #110395 +// FIXME(effects) check-pass #![feature(const_trait_impl, effects)] diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-pass.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-pass.stderr new file mode 100644 index 0000000000000..1bba23e2892ee --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-pass.stderr @@ -0,0 +1,56 @@ +error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]` + --> $DIR/call-generic-method-pass.rs:10:12 + | +LL | impl const PartialEq for S { + | ^^^^^^^^^ + | + = 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/call-generic-method-pass.rs:10:6 + | +LL | impl const PartialEq for S { + | ^^^^^ 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: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/call-generic-method-pass.rs:19:32 + | +LL | const fn equals_self(t: &T) -> bool { + | ^^^^^^^^^ + +error[E0284]: type annotations needed + --> $DIR/call-generic-method-pass.rs:23:22 + | +LL | pub const EQ: bool = equals_self(&S); + | ^^^^^^^^^^^^^^^ cannot infer the value of the constant `_` + | +note: required for `S` to implement `PartialEq` + --> $DIR/call-generic-method-pass.rs:10:12 + | +LL | impl const PartialEq for S { + | ----- ^^^^^^^^^ ^ + | | + | unsatisfied trait bound introduced here + +error[E0284]: type annotations needed + --> $DIR/call-generic-method-pass.rs:15:10 + | +LL | !self.eq(other) + | ^^^^^^^^^^^^^^ cannot infer the value of the constant `_` + | +note: required for `S` to implement `PartialEq` + --> $DIR/call-generic-method-pass.rs:10:12 + | +LL | impl const PartialEq for S { + | ----- ^^^^^^^^^ ^ + | | + | unsatisfied trait bound introduced here + +error: aborting due to 5 previous errors + +Some errors have detailed explanations: E0207, E0284. +For more information about an error, try `rustc --explain E0207`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-and-non-const-impl.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-and-non-const-impl.stderr index 54bc434772297..8916450df2d4b 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-and-non-const-impl.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-and-non-const-impl.stderr @@ -1,3 +1,12 @@ +error[E0119]: conflicting implementations of trait `Add` for type `Int` + --> $DIR/const-and-non-const-impl.rs:23:1 + | +LL | impl std::ops::Add for Int { + | -------------------------- first implementation here +... +LL | impl const std::ops::Add for Int { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Int` + error[E0117]: only traits defined in the current crate can be implemented for primitive types --> $DIR/const-and-non-const-impl.rs:7:1 | @@ -10,15 +19,6 @@ LL | impl const std::ops::Add for i32 { | = note: define and implement a trait or new type instead -error[E0119]: conflicting implementations of trait `Add` for type `Int` - --> $DIR/const-and-non-const-impl.rs:23:1 - | -LL | impl std::ops::Add for Int { - | -------------------------- first implementation here -... -LL | impl const std::ops::Add for Int { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Int` - error: aborting due to 2 previous errors Some errors have detailed explanations: E0117, E0119. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-bound.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-bound.stderr index 16ed615907b13..be197006f021a 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-bound.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-bound.stderr @@ -1,9 +1,27 @@ +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/const-drop-bound.rs:9:68 + | +LL | const fn foo(res: Result) -> Option where E: ~const Destruct { + | ^^^^^^^^ + +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/const-drop-bound.rs:20:15 + | +LL | T: ~const Destruct, + | ^^^^^^^^ + +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/const-drop-bound.rs:21:15 + | +LL | E: ~const Destruct, + | ^^^^^^^^ + error[E0493]: destructor of `E` cannot be evaluated at compile-time --> $DIR/const-drop-bound.rs:12:13 | LL | Err(_e) => None, | ^^ the destructor for this type cannot be evaluated in constant functions -error: aborting due to 1 previous error +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0493`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.stderr index 6f75924f0aa64..085d9e710125a 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.stderr @@ -1,3 +1,9 @@ +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/const-drop-fail-2.rs:21:26 + | +LL | const fn check(_: T) {} + | ^^^^^^^^ + error[E0493]: destructor of `T` cannot be evaluated at compile-time --> $DIR/const-drop-fail-2.rs:21:36 | @@ -6,6 +12,6 @@ LL | const fn check(_: T) {} | | | the destructor for this type cannot be evaluated in constant functions -error: aborting due to 1 previous error +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0493`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr index 9afa2072dde95..e95215d471566 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr @@ -1,3 +1,9 @@ +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/const-drop-fail.rs:24:26 + | +LL | const fn check(_: T) {} + | ^^^^^^^^ + error[E0493]: destructor of `T` cannot be evaluated at compile-time --> $DIR/const-drop-fail.rs:24:36 | @@ -54,7 +60,7 @@ LL | | } | |_- in this macro invocation = note: this error originates in the macro `check_all` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors Some errors have detailed explanations: E0080, E0493. For more information about an error, try `rustc --explain E0080`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr index 09ebf55c57c7a..f9bd9953fcfd3 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr @@ -1,3 +1,9 @@ +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/const-drop-fail.rs:24:26 + | +LL | const fn check(_: T) {} + | ^^^^^^^^ + error[E0493]: destructor of `T` cannot be evaluated at compile-time --> $DIR/const-drop-fail.rs:24:36 | @@ -6,6 +12,6 @@ LL | const fn check(_: T) {} | | | the destructor for this type cannot be evaluated in constant functions -error: aborting due to 1 previous error +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0493`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.precise.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.precise.stderr index 5ff3be713a7ca..6aace10589605 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.precise.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.precise.stderr @@ -1,3 +1,9 @@ +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/const-drop.rs:19:22 + | +LL | const fn a(_: T) {} + | ^^^^^^^^ + error[E0493]: destructor of `S<'_>` cannot be evaluated at compile-time --> $DIR/const-drop.rs:24:13 | @@ -86,7 +92,7 @@ LL | | } | |_- in this macro invocation = note: this error originates in the macro `implements_const_drop` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 5 previous errors +error: aborting due to 6 previous errors Some errors have detailed explanations: E0080, E0493. For more information about an error, try `rustc --explain E0080`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.stock.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.stock.stderr index 40e39cbefbc6d..18dd4543c3d39 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.stock.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.stock.stderr @@ -1,3 +1,9 @@ +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/const-drop.rs:19:22 + | +LL | const fn a(_: T) {} + | ^^^^^^^^ + error[E0493]: destructor of `S<'_>` cannot be evaluated at compile-time --> $DIR/const-drop.rs:24:13 | @@ -14,6 +20,6 @@ LL | const fn a(_: T) {} | | | the destructor for this type cannot be evaluated in constant functions -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0493`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-trait.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-trait.stderr index 03038eb5c84ad..af50a115c69f7 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-trait.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-trait.stderr @@ -1,28 +1,244 @@ -error[E0277]: can't compare `()` with `()` - --> $DIR/const-impl-trait.rs:36:17 +error[E0635]: unknown feature `const_cmp` + --> $DIR/const-impl-trait.rs:8:5 | -LL | assert!(cmp(&())); - | --- ^^^ no implementation for `() == ()` +LL | const_cmp, + | ^^^^^^^^^ + +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/const-impl-trait.rs:13:30 + | +LL | const fn cmp(a: &impl ~const PartialEq) -> bool { + | ^^^^^^^^^ + +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/const-impl-trait.rs:17:30 + | +LL | const fn wrap(x: impl ~const PartialEq + ~const Destruct) + | ^^^^^^^^^ + +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/const-impl-trait.rs:17:49 + | +LL | const fn wrap(x: impl ~const PartialEq + ~const Destruct) + | ^^^^^^^^ + +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/const-impl-trait.rs:18:20 + | +LL | -> impl ~const PartialEq + ~const Destruct + | ^^^^^^^^^ + +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/const-impl-trait.rs:18:39 + | +LL | -> impl ~const PartialEq + ~const Destruct + | ^^^^^^^^ + +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/const-impl-trait.rs:18:20 + | +LL | -> impl ~const PartialEq + ~const Destruct + | ^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/const-impl-trait.rs:18:39 + | +LL | -> impl ~const PartialEq + ~const Destruct + | ^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/const-impl-trait.rs:25:29 + | +LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy; + | ^^^^^^^^^ + +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/const-impl-trait.rs:25:48 + | +LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy; + | ^^^^^^^^ + +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/const-impl-trait.rs:25:29 + | +LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy; + | ^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/const-impl-trait.rs:25:48 + | +LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy; + | ^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/const-impl-trait.rs:25:29 + | +LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy; + | ^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/const-impl-trait.rs:25:48 + | +LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy; + | ^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/const-impl-trait.rs:29:29 + | +LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy { + | ^^^^^^^^^ + +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/const-impl-trait.rs:29:48 + | +LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy { + | ^^^^^^^^ + +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/const-impl-trait.rs:29:29 + | +LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy { + | ^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/const-impl-trait.rs:29:48 + | +LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy { + | ^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/const-impl-trait.rs:50:41 + | +LL | const fn apit(_: impl ~const T + ~const Destruct) {} + | ^^^^^^^^ + +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/const-impl-trait.rs:54:73 + | +LL | const fn apit_assoc_bound(_: impl IntoIterator + ~const Destruct) {} + | ^^^^^^^^ + +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/const-impl-trait.rs:25:29 + | +LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy; + | ^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/const-impl-trait.rs:25:48 + | +LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy; + | ^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0493]: destructor of `impl PartialEq + Destruct` cannot be evaluated at compile-time + --> $DIR/const-impl-trait.rs:37:26 + | +LL | assert!(wrap(123) == wrap(123)); + | ^^^^^^^^^- value is dropped here + | | + | the destructor for this type cannot be evaluated in constants + +error[E0493]: destructor of `impl PartialEq + Destruct` cannot be evaluated at compile-time + --> $DIR/const-impl-trait.rs:37:26 + | +LL | assert!(wrap(123) == wrap(123)); + | ^^^^^^^^^- value is dropped here + | | + | the destructor for this type cannot be evaluated in constants + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0493]: destructor of `impl PartialEq + Destruct` cannot be evaluated at compile-time + --> $DIR/const-impl-trait.rs:37:13 + | +LL | assert!(wrap(123) == wrap(123)); + | ^^^^^^^^^ - value is dropped here | | - | required by a bound introduced by this call + | the destructor for this type cannot be evaluated in constants + +error[E0493]: destructor of `impl PartialEq + Destruct` cannot be evaluated at compile-time + --> $DIR/const-impl-trait.rs:37:13 | - = help: the trait `const PartialEq` is not implemented for `()` - = help: the trait `PartialEq` is implemented for `()` -note: required by a bound in `cmp` - --> $DIR/const-impl-trait.rs:13:23 +LL | assert!(wrap(123) == wrap(123)); + | ^^^^^^^^^ - value is dropped here + | | + | the destructor for this type cannot be evaluated in constants | -LL | const fn cmp(a: &impl ~const PartialEq) -> bool { - | ^^^^^^^^^^^^^^^^ required by this bound in `cmp` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0493]: destructor of `impl PartialEq + Destruct` cannot be evaluated at compile-time + --> $DIR/const-impl-trait.rs:38:26 + | +LL | assert!(wrap(123) != wrap(456)); + | ^^^^^^^^^- value is dropped here + | | + | the destructor for this type cannot be evaluated in constants + +error[E0493]: destructor of `impl PartialEq + Destruct` cannot be evaluated at compile-time + --> $DIR/const-impl-trait.rs:38:26 + | +LL | assert!(wrap(123) != wrap(456)); + | ^^^^^^^^^- value is dropped here + | | + | the destructor for this type cannot be evaluated in constants + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0493]: destructor of `impl PartialEq + Destruct` cannot be evaluated at compile-time + --> $DIR/const-impl-trait.rs:38:13 + | +LL | assert!(wrap(123) != wrap(456)); + | ^^^^^^^^^ - value is dropped here + | | + | the destructor for this type cannot be evaluated in constants + +error[E0493]: destructor of `impl PartialEq + Destruct` cannot be evaluated at compile-time + --> $DIR/const-impl-trait.rs:38:13 + | +LL | assert!(wrap(123) != wrap(456)); + | ^^^^^^^^^ - value is dropped here + | | + | the destructor for this type cannot be evaluated in constants + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0493]: destructor of `impl ~const T + ~const Destruct` cannot be evaluated at compile-time + --> $DIR/const-impl-trait.rs:50:15 + | +LL | const fn apit(_: impl ~const T + ~const Destruct) {} + | ^ - value is dropped here + | | + | the destructor for this type cannot be evaluated in constant functions -error[E0369]: binary operation `==` cannot be applied to type `&impl ~const PartialEq` - --> $DIR/const-impl-trait.rs:14:7 +error[E0493]: destructor of `impl IntoIterator + ~const Destruct` cannot be evaluated at compile-time + --> $DIR/const-impl-trait.rs:54:27 | -LL | a == a - | - ^^ - &impl ~const PartialEq - | | - | &impl ~const PartialEq +LL | const fn apit_assoc_bound(_: impl IntoIterator + ~const Destruct) {} + | ^ - value is dropped here + | | + | the destructor for this type cannot be evaluated in constant functions -error: aborting due to 2 previous errors +error: aborting due to 32 previous errors -Some errors have detailed explanations: E0277, E0369. -For more information about an error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0493, E0635. +For more information about an error, try `rustc --explain E0493`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-use.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-use.stderr index 86dfc521fea72..82a971a36a8da 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-use.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-use.stderr @@ -1,3 +1,9 @@ +error[E0635]: unknown feature `const_cmp` + --> $DIR/derive-const-use.rs:3:30 + | +LL | #![feature(const_trait_impl, const_cmp, const_default_impls, derive_const, effects)] + | ^^^^^^^^^ + error[E0635]: unknown feature `const_default_impls` --> $DIR/derive-const-use.rs:3:41 | @@ -22,6 +28,24 @@ LL | impl const Default for A { = 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: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]` + --> $DIR/derive-const-use.rs:11:12 + | +LL | impl const PartialEq 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[E0207]: the const parameter `host` is not constrained by the impl trait, self type, or predicates + --> $DIR/derive-const-use.rs:11:6 + | +LL | impl const PartialEq for A { + | ^^^^^ 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: const `impl` for trait `Default` which is not marked with `#[const_trait]` --> $DIR/derive-const-use.rs:15:16 | @@ -37,6 +61,22 @@ error[E0207]: the const parameter `host` is not constrained by the impl trait, s = 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: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]` + --> $DIR/derive-const-use.rs:15:25 + | +LL | #[derive_const(Default, PartialEq)] + | ^^^^^^^^^ + | + = 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 + = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0207]: the const parameter `host` is not constrained by the impl trait, self type, or predicates + | + = 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 + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error[E0284]: type annotations needed --> $DIR/derive-const-use.rs:18:35 | @@ -50,16 +90,17 @@ LL | #[derive_const(Default, PartialEq)] | ^^^^^^^ unsatisfied trait bound introduced in this `derive` macro = note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0308]: mismatched types - --> $DIR/derive-const-use.rs:16:14 +error[E0284]: type annotations needed + --> $DIR/derive-const-use.rs:18:23 | -LL | #[derive_const(Default, PartialEq)] - | --------- in this derive macro expansion -LL | pub struct S((), A); - | ^^ expected `host`, found `true` +LL | const _: () = assert!(S((), A) == S::default()); + | ^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the constant `_` + | +note: required for `S` to implement `PartialEq` + --> $DIR/derive-const-use.rs:15:25 | - = note: expected constant `host` - found constant `true` +LL | #[derive_const(Default, PartialEq)] + | ^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0284]: type annotations needed @@ -79,7 +120,24 @@ LL | impl const Default for A { | unsatisfied trait bound introduced here = note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 8 previous errors +error[E0284]: type annotations needed + --> $DIR/derive-const-use.rs:16:18 + | +LL | #[derive_const(Default, PartialEq)] + | --------- in this derive macro expansion +LL | pub struct S((), A); + | ^ cannot infer the value of the constant `_` + | +note: required for `A` to implement `PartialEq` + --> $DIR/derive-const-use.rs:11:12 + | +LL | impl const PartialEq for A { + | ----- ^^^^^^^^^ ^ + | | + | unsatisfied trait bound introduced here + = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 14 previous errors -Some errors have detailed explanations: E0207, E0284, E0308, E0635. +Some errors have detailed explanations: E0207, E0284, E0635. For more information about an error, try `rustc --explain E0207`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-with-params.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-with-params.rs index 0eb422728c631..c032c76d38f6d 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-with-params.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-with-params.rs @@ -1,4 +1,5 @@ -//@ check-pass +//@ known-bug: #110395 +// FIXME(effects) check-pass #![feature(derive_const)] #![feature(const_trait_impl, effects)] diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-with-params.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-with-params.stderr new file mode 100644 index 0000000000000..0e7d826db5435 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-with-params.stderr @@ -0,0 +1,40 @@ +error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]` + --> $DIR/derive-const-with-params.rs:7:16 + | +LL | #[derive_const(PartialEq)] + | ^^^^^^^^^ + | + = 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 + = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/derive-const-with-params.rs:7:16 + | +LL | #[derive_const(PartialEq)] + | ^^^^^^^^^ + | + = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0207]: the const parameter `host` is not constrained by the impl trait, self type, or predicates + | + = 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[E0284]: type annotations needed + --> $DIR/derive-const-with-params.rs:11:5 + | +LL | a == b + | ^^^^^^ cannot infer the value of the constant `_` + | +note: required for `Reverse` to implement `PartialEq` + --> $DIR/derive-const-with-params.rs:7:16 + | +LL | #[derive_const(PartialEq)] + | ^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro + = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0207, E0284. +For more information about an error, try `rustc --explain E0207`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/ice-112822-expected-type-for-param.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/ice-112822-expected-type-for-param.rs index 21197fcaa273a..306770fc245b9 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/ice-112822-expected-type-for-param.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/ice-112822-expected-type-for-param.rs @@ -3,14 +3,13 @@ const fn test() -> impl ~const Fn() { //~^ ERROR `~const` can only be applied to `#[const_trait]` traits //~| ERROR `~const` can only be applied to `#[const_trait]` traits - //~| ERROR cycle detected const move || { //~ ERROR const closures are experimental let sl: &[u8] = b"foo"; match sl { [first, remainder @ ..] => { assert_eq!(first, &b'f'); - //~^ ERROR can't compare `&u8` with `&u8` + //~^ ERROR cannot call non-const fn } [] => panic!(), } diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/ice-112822-expected-type-for-param.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/ice-112822-expected-type-for-param.stderr index 2f8051109173d..e15f697b29e9f 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/ice-112822-expected-type-for-param.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/ice-112822-expected-type-for-param.stderr @@ -1,5 +1,5 @@ error[E0658]: const closures are experimental - --> $DIR/ice-112822-expected-type-for-param.rs:7:5 + --> $DIR/ice-112822-expected-type-for-param.rs:6:5 | LL | const move || { | ^^^^^ @@ -22,47 +22,16 @@ LL | const fn test() -> impl ~const Fn() { | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0277]: can't compare `&u8` with `&u8` - --> $DIR/ice-112822-expected-type-for-param.rs:12:17 +error[E0015]: cannot call non-const fn `core::panicking::assert_failed::<&u8, &u8>` in constant functions + --> $DIR/ice-112822-expected-type-for-param.rs:11:17 | LL | assert_eq!(first, &b'f'); - | ^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `&u8 == &u8` + | ^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: the trait `~const PartialEq<&u8>` is not implemented for `&u8` + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0391]: cycle detected when computing type of opaque `test::{opaque#0}` - --> $DIR/ice-112822-expected-type-for-param.rs:3:20 - | -LL | const fn test() -> impl ~const Fn() { - | ^^^^^^^^^^^^^^^^ - | -note: ...which requires borrow-checking `test`... - --> $DIR/ice-112822-expected-type-for-param.rs:3:1 - | -LL | const fn test() -> impl ~const Fn() { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires promoting constants in MIR for `test`... - --> $DIR/ice-112822-expected-type-for-param.rs:3:1 - | -LL | const fn test() -> impl ~const Fn() { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires const checking `test`... - --> $DIR/ice-112822-expected-type-for-param.rs:3:1 - | -LL | const fn test() -> impl ~const Fn() { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: ...which requires computing whether `test::{opaque#0}` is freeze... - = note: ...which requires evaluating trait selection obligation `test::{opaque#0}: core::marker::Freeze`... - = note: ...which again requires computing type of opaque `test::{opaque#0}`, completing the cycle -note: cycle used when computing type of `test::{opaque#0}` - --> $DIR/ice-112822-expected-type-for-param.rs:3:20 - | -LL | const fn test() -> impl ~const Fn() { - | ^^^^^^^^^^^^^^^^ - = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information - -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors -Some errors have detailed explanations: E0277, E0391, E0658. -For more information about an error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0015, E0658. +For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/minicore.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/minicore.rs index 281cfdaef28cc..af88a73b4d692 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/minicore.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/minicore.rs @@ -1,4 +1,6 @@ -//@ check-pass +//@ known-bug: #110395 +// FIXME(effects) check-pass +// FIXME(effects) fix intrinsics const parameter counting #![crate_type = "lib"] #![feature(no_core, lang_items, unboxed_closures, auto_traits, intrinsics, rustc_attrs, staged_api)] diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/minicore.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/minicore.stderr new file mode 100644 index 0000000000000..d9450216dacb5 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/minicore.stderr @@ -0,0 +1,9 @@ +error[E0094]: intrinsic has wrong number of const parameters: found 1, expected 0 + --> $DIR/minicore.rs:517:27 + | +LL | const fn const_eval_select( + | ^^^^^^^^^^^^^^^^^^^^^^^ expected 0 const parameters + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0094`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/ice-120503-async-const-method.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/ice-120503-async-const-method.rs new file mode 100644 index 0000000000000..482a1aef06b57 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/ice-120503-async-const-method.rs @@ -0,0 +1,18 @@ +//@ edition: 2021 +#![feature(effects)] + +trait MyTrait {} + +impl MyTrait for i32 { + async const fn bar(&self) { + //~^ ERROR expected one of `extern` + //~| ERROR functions in trait impls cannot be declared const + //~| ERROR functions cannot be both `const` and `async` + //~| ERROR method `bar` is not a member + //~| ERROR cycle detected when computing type + main8().await; + //~^ ERROR cannot find function + } +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/ice-120503-async-const-method.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/ice-120503-async-const-method.stderr new file mode 100644 index 0000000000000..1110b799c6c47 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/ice-120503-async-const-method.stderr @@ -0,0 +1,92 @@ +error: expected one of `extern`, `fn`, `safe`, or `unsafe`, found keyword `const` + --> $DIR/ice-120503-async-const-method.rs:7:11 + | +LL | async const fn bar(&self) { + | ------^^^^^ + | | | + | | expected one of `extern`, `fn`, `safe`, or `unsafe` + | help: `const` must come before `async`: `const async` + | + = note: keyword order for functions declaration is `pub`, `default`, `const`, `async`, `unsafe`, `extern` + +error[E0379]: functions in trait impls cannot be declared const + --> $DIR/ice-120503-async-const-method.rs:7:11 + | +LL | async const fn bar(&self) { + | ^^^^^- + | | + | functions in trait impls cannot be const + | help: remove the `const` + +error: functions cannot be both `const` and `async` + --> $DIR/ice-120503-async-const-method.rs:7:5 + | +LL | async const fn bar(&self) { + | -^^^^ ^^^^^ `const` because of this + | | + | _____`async` because of this + | | +LL | | +LL | | +LL | | +... | +LL | | +LL | | } + | |_____- + +error[E0407]: method `bar` is not a member of trait `MyTrait` + --> $DIR/ice-120503-async-const-method.rs:7:5 + | +LL | / async const fn bar(&self) { +LL | | +LL | | +LL | | +... | +LL | | +LL | | } + | |_____^ not a member of trait `MyTrait` + +error[E0425]: cannot find function `main8` in this scope + --> $DIR/ice-120503-async-const-method.rs:13:9 + | +LL | main8().await; + | ^^^^^ help: a function with a similar name exists: `main` +... +LL | fn main() {} + | --------- similarly named function `main` defined here + +error[E0391]: cycle detected when computing type of opaque `::bar::{opaque#0}` + --> $DIR/ice-120503-async-const-method.rs:7:5 + | +LL | async const fn bar(&self) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: ...which requires borrow-checking `::bar`... + --> $DIR/ice-120503-async-const-method.rs:7:5 + | +LL | async const fn bar(&self) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +note: ...which requires promoting constants in MIR for `::bar`... + --> $DIR/ice-120503-async-const-method.rs:7:5 + | +LL | async const fn bar(&self) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +note: ...which requires const checking `::bar`... + --> $DIR/ice-120503-async-const-method.rs:7:5 + | +LL | async const fn bar(&self) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: ...which requires computing whether `::bar::{opaque#0}` is freeze... + = note: ...which requires evaluating trait selection obligation `::bar::{opaque#0}: core::marker::Freeze`... + = note: ...which again requires computing type of opaque `::bar::{opaque#0}`, completing the cycle +note: cycle used when computing type of `::bar::{opaque#0}` + --> $DIR/ice-120503-async-const-method.rs:7:5 + | +LL | async const fn bar(&self) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information + +error: aborting due to 6 previous errors + +Some errors have detailed explanations: E0379, E0391, E0407, E0425. +For more information about an error, try `rustc --explain E0379`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/ice-121536-const-method.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/ice-121536-const-method.rs new file mode 100644 index 0000000000000..fee0a2073e8dd --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/ice-121536-const-method.rs @@ -0,0 +1,17 @@ +#![feature(const_trait_impl, effects)] + +pub struct Vec3; + +#[const_trait] +pub trait Add { + fn add(self) -> Vec3; +} + +impl Add for Vec3 { + const fn add(self) -> Vec3 { + //~^ ERROR functions in trait impls cannot be declared const + self + } +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/ice-121536-const-method.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/ice-121536-const-method.stderr new file mode 100644 index 0000000000000..408958abf6307 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/ice-121536-const-method.stderr @@ -0,0 +1,19 @@ +error[E0379]: functions in trait impls cannot be declared const + --> $DIR/ice-121536-const-method.rs:11:5 + | +LL | const fn add(self) -> Vec3 { + | ^^^^^ functions in trait impls cannot be const + | +help: remove the `const` ... + | +LL - const fn add(self) -> Vec3 { +LL + fn add(self) -> Vec3 { + | +help: ... and declare the impl to be const instead + | +LL | impl const Add for Vec3 { + | +++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0379`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-92111.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-92111.stderr index 2edaca606235b..ecc994a3fe658 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-92111.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-92111.stderr @@ -1,3 +1,9 @@ +error: `~const` can only be applied to `#[const_trait]` traits + --> $DIR/issue-92111.rs:20:22 + | +LL | const fn a(t: T) {} + | ^^^^^^^^ + error[E0493]: destructor of `T` cannot be evaluated at compile-time --> $DIR/issue-92111.rs:20:32 | @@ -6,6 +12,6 @@ LL | const fn a(t: T) {} | | | the destructor for this type cannot be evaluated in constant functions -error: aborting due to 1 previous error +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0493`. diff --git a/tests/ui/ufcs/ufcs-qpath-self-mismatch.stderr b/tests/ui/ufcs/ufcs-qpath-self-mismatch.stderr index 5b8a49d22c739..a0430240dc43b 100644 --- a/tests/ui/ufcs/ufcs-qpath-self-mismatch.stderr +++ b/tests/ui/ufcs/ufcs-qpath-self-mismatch.stderr @@ -11,19 +11,6 @@ LL | >::add(1, 2); `i32` implements `Add<&i32>` `i32` implements `Add` -error[E0277]: cannot add `u32` to `i32` - --> $DIR/ufcs-qpath-self-mismatch.rs:4:5 - | -LL | >::add(1, 2); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `i32 + u32` - | - = help: the trait `Add` is not implemented for `i32` - = help: the following other types implement trait `Add`: - `&'a i32` implements `Add` - `&i32` implements `Add<&i32>` - `i32` implements `Add<&i32>` - `i32` implements `Add` - error[E0308]: mismatched types --> $DIR/ufcs-qpath-self-mismatch.rs:7:28 | @@ -68,6 +55,19 @@ help: change the type of the numeric literal from `u32` to `i32` LL | >::add(1, 2i32); | ~~~ +error[E0277]: cannot add `u32` to `i32` + --> $DIR/ufcs-qpath-self-mismatch.rs:4:5 + | +LL | >::add(1, 2); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `i32 + u32` + | + = help: the trait `Add` is not implemented for `i32` + = help: the following other types implement trait `Add`: + `&'a i32` implements `Add` + `&i32` implements `Add<&i32>` + `i32` implements `Add<&i32>` + `i32` implements `Add` + error: aborting due to 4 previous errors Some errors have detailed explanations: E0277, E0308.