1
Fork 0

Tweak wording of non-const traits used as const bounds

Use verbose suggestions and add additional labels/notes.

Add more test cases for stable/nightly and feature enabled/disabled.
This commit is contained in:
Esteban Küber 2024-12-09 19:34:43 +00:00
parent f6cb952dc1
commit 4007fc9a0f
49 changed files with 1121 additions and 194 deletions

View file

@ -96,12 +96,14 @@ hir_analysis_coercion_between_struct_same_note = expected coercion between the s
hir_analysis_coercion_between_struct_single_note = expected a single field to be coerced, none found
hir_analysis_const_bound_for_non_const_trait =
`{$modifier}` can only be applied to `#[const_trait]` traits
hir_analysis_const_bound_for_non_const_trait = `{$modifier}` can only be applied to `#[const_trait]` traits
.label = can't be applied to `{$trait_name}`
.note = `{$trait_name}` can't be used with `{$modifier}` because it isn't annotated with `#[const_trait]`
.suggestion = {$suggestion_pre}mark `{$trait_name}` as `#[const_trait]` to allow it to have `const` implementations
hir_analysis_const_impl_for_non_const_trait =
const `impl` for trait `{$trait_name}` which is not marked with `#[const_trait]`
.suggestion = mark `{$trait_name}` as const
hir_analysis_const_impl_for_non_const_trait = const `impl` for trait `{$trait_name}` which is not marked with `#[const_trait]`
.label = this trait is not `const`
.suggestion = {$suggestion_pre}mark `{$trait_name}` as `#[const_trait]` to allow it to have `const` implementations
.note = marking a trait with `#[const_trait]` ensures all default method bodies are `const`
.adding = adding a non-const method body in the future would be a breaking change

View file

@ -1637,11 +1637,23 @@ fn check_impl_constness(
}
let trait_name = tcx.item_name(trait_def_id).to_string();
let (local_trait_span, suggestion_pre) =
match (trait_def_id.is_local(), tcx.sess.is_nightly_build()) {
(true, true) => (
Some(tcx.def_span(trait_def_id).shrink_to_lo()),
if tcx.features().const_trait_impl() {
""
} else {
"enable `#![feature(const_trait_impl)]` in your crate and "
},
),
(false, _) | (_, false) => (None, ""),
};
Some(tcx.dcx().emit_err(errors::ConstImplForNonConstTrait {
trait_ref_span: hir_trait_ref.path.span,
trait_name,
local_trait_span:
trait_def_id.as_local().map(|_| tcx.def_span(trait_def_id).shrink_to_lo()),
local_trait_span,
suggestion_pre,
marking: (),
adding: (),
}))

View file

@ -530,10 +530,16 @@ pub(crate) struct GenericArgsOnOverriddenImpl {
#[diag(hir_analysis_const_impl_for_non_const_trait)]
pub(crate) struct ConstImplForNonConstTrait {
#[primary_span]
#[label]
pub trait_ref_span: Span,
pub trait_name: String,
#[suggestion(applicability = "machine-applicable", code = "#[const_trait]")]
#[suggestion(
applicability = "machine-applicable",
code = "#[const_trait] ",
style = "verbose"
)]
pub local_trait_span: Option<Span>,
pub suggestion_pre: &'static str,
#[note]
pub marking: (),
#[note(hir_analysis_adding)]
@ -544,8 +550,19 @@ pub(crate) struct ConstImplForNonConstTrait {
#[diag(hir_analysis_const_bound_for_non_const_trait)]
pub(crate) struct ConstBoundForNonConstTrait {
#[primary_span]
#[label]
pub span: Span,
pub modifier: &'static str,
#[note]
pub def_span: Option<Span>,
pub suggestion_pre: &'static str,
#[suggestion(
applicability = "machine-applicable",
code = "#[const_trait] ",
style = "verbose"
)]
pub suggestion: Option<Span>,
pub trait_name: String,
}
#[derive(Diagnostic)]

View file

@ -737,9 +737,26 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
if let hir::BoundConstness::Always(span) | hir::BoundConstness::Maybe(span) = constness
&& !self.tcx().is_const_trait(trait_def_id)
{
let (def_span, suggestion, suggestion_pre) =
match (trait_def_id.is_local(), self.tcx().sess.is_nightly_build()) {
(true, true) => (
None,
Some(tcx.def_span(trait_def_id).shrink_to_lo()),
if self.tcx().features().const_trait_impl() {
""
} else {
"enable `#![feature(const_trait_impl)]` in your crate and "
},
),
(false, _) | (_, false) => (Some(tcx.def_span(trait_def_id)), None, ""),
};
self.dcx().emit_err(crate::errors::ConstBoundForNonConstTrait {
span,
modifier: constness.as_str(),
def_span,
trait_name: self.tcx().def_path_str(trait_def_id),
suggestion_pre,
suggestion,
});
}

View file

@ -0,0 +1,66 @@
error: `~const` is not allowed here
--> const-super-trait.rs:7:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^
|
note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds
--> const-super-trait.rs:7:1
|
LL | trait Bar: ~const Foo {}
| ^^^^^^^^^^^^^^^^^^^^^^^^
error[E0658]: const trait impls are experimental
--> const-super-trait.rs:7:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^
|
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: const trait impls are experimental
--> const-super-trait.rs:9:17
|
LL | const fn foo<T: ~const Bar>(x: &T) {
| ^^^^^^
|
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: `~const` can only be applied to `#[const_trait]` traits
--> const-super-trait.rs:7:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^ can't be applied to `Foo`
|
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Foo {
| ++++++++++++++
error: `~const` can only be applied to `#[const_trait]` traits
--> const-super-trait.rs:9:17
|
LL | const fn foo<T: ~const Bar>(x: &T) {
| ^^^^^^ can't be applied to `Bar`
|
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Bar: ~const Foo {}
| ++++++++++++++
error[E0015]: cannot call non-const fn `<T as Foo>::a` in constant functions
--> const-super-trait.rs:10:7
|
LL | x.a();
| ^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
error: aborting due to 6 previous errors
Some errors have detailed explanations: E0015, E0658.
For more information about an error, try `rustc --explain E0015`.

View file

@ -0,0 +1,45 @@
error: `~const` is not allowed here
--> const-super-trait.rs:7:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^
|
note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds
--> const-super-trait.rs:7:1
|
LL | trait Bar: ~const Foo {}
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: `~const` can only be applied to `#[const_trait]` traits
--> const-super-trait.rs:7:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^ can't be applied to `Foo`
|
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Foo {
| ++++++++++++++
error: `~const` can only be applied to `#[const_trait]` traits
--> const-super-trait.rs:9:17
|
LL | const fn foo<T: ~const Bar>(x: &T) {
| ^^^^^^ can't be applied to `Bar`
|
help: mark `Bar` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Bar: ~const Foo {}
| ++++++++++++++
error[E0015]: cannot call non-const fn `<T as Foo>::a` in constant functions
--> const-super-trait.rs:10:7
|
LL | x.a();
| ^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0015`.

View file

@ -0,0 +1,64 @@
error: `~const` is not allowed here
--> const-super-trait.rs:7:12
|
7 | trait Bar: ~const Foo {}
| ^^^^^^
|
note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds
--> const-super-trait.rs:7:1
|
7 | trait Bar: ~const Foo {}
| ^^^^^^^^^^^^^^^^^^^^^^^^
error[E0658]: const trait impls are experimental
--> const-super-trait.rs:7:12
|
7 | trait Bar: ~const Foo {}
| ^^^^^^
|
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
error[E0658]: const trait impls are experimental
--> const-super-trait.rs:9:17
|
9 | const fn foo<T: ~const Bar>(x: &T) {
| ^^^^^^
|
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
error: `~const` can only be applied to `#[const_trait]` traits
--> const-super-trait.rs:7:12
|
7 | trait Bar: ~const Foo {}
| ^^^^^^ can't be applied to `Foo`
|
note: `Foo` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> const-super-trait.rs:3:1
|
3 | trait Foo {
| ^^^^^^^^^
error: `~const` can only be applied to `#[const_trait]` traits
--> const-super-trait.rs:9:17
|
9 | const fn foo<T: ~const Bar>(x: &T) {
| ^^^^^^ can't be applied to `Bar`
|
note: `Bar` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> const-super-trait.rs:7:1
|
7 | trait Bar: ~const Foo {}
| ^^^^^^^^^^^^^^^^^^^^^
error[E0015]: cannot call non-const fn `<T as Foo>::a` in constant functions
--> const-super-trait.rs:10:7
|
10 | x.a();
| ^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
error: aborting due to 6 previous errors
Some errors have detailed explanations: E0015, E0658.
For more information about an error, try `rustc --explain E0015`.

View file

@ -0,0 +1,54 @@
error: `~const` is not allowed here
--> const-super-trait.rs:7:12
|
7 | trait Bar: ~const Foo {}
| ^^^^^^
|
note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds
--> const-super-trait.rs:7:1
|
7 | trait Bar: ~const Foo {}
| ^^^^^^^^^^^^^^^^^^^^^^^^
error[E0554]: `#![feature]` may not be used on the NIGHTLY release channel
--> const-super-trait.rs:1:30
|
1 | #![cfg_attr(feature_enabled, feature(const_trait_impl))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error: `~const` can only be applied to `#[const_trait]` traits
--> const-super-trait.rs:7:12
|
7 | trait Bar: ~const Foo {}
| ^^^^^^ can't be applied to `Foo`
|
note: `Foo` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> const-super-trait.rs:3:1
|
3 | trait Foo {
| ^^^^^^^^^
error: `~const` can only be applied to `#[const_trait]` traits
--> const-super-trait.rs:9:17
|
9 | const fn foo<T: ~const Bar>(x: &T) {
| ^^^^^^ can't be applied to `Bar`
|
note: `Bar` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> const-super-trait.rs:7:1
|
7 | trait Bar: ~const Foo {}
| ^^^^^^^^^^^^^^^^^^^^^
error[E0015]: cannot call non-const fn `<T as Foo>::a` in constant functions
--> const-super-trait.rs:10:7
|
10 | x.a();
| ^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0015, E0554.
For more information about an error, try `rustc --explain E0015`.

View file

@ -0,0 +1,13 @@
#![cfg_attr(feature_enabled, feature(const_trait_impl))]
trait Foo {
fn a(&self);
}
trait Bar: ~const Foo {}
const fn foo<T: ~const Bar>(x: &T) {
x.a();
}
fn main() {}

View file

@ -0,0 +1,59 @@
// Test output of const super trait errors in both stable and nightly.
// We don't want to provide suggestions on stable that only make sense in nightly.
use run_make_support::{diff, rustc};
fn main() {
let out = rustc()
.input("const-super-trait.rs")
.env("RUSTC_BOOTSTRAP", "-1")
.cfg("feature_enabled")
.run_fail()
.assert_stderr_not_contains(
"as `#[const_trait]` to allow it to have `const` implementations",
)
.stderr_utf8();
diff()
.expected_file("const-super-trait-stable-enabled.stderr")
.normalize(
"may not be used on the .* release channel",
"may not be used on the NIGHTLY release channel",
)
.actual_text("(rustc)", &out)
.run();
let out = rustc()
.input("const-super-trait.rs")
.cfg("feature_enabled")
.ui_testing()
.run_fail()
.assert_stderr_not_contains("enable `#![feature(const_trait_impl)]` in your crate and mark")
.assert_stderr_contains("as `#[const_trait]` to allow it to have `const` implementations")
.stderr_utf8();
diff()
.expected_file("const-super-trait-nightly-enabled.stderr")
.actual_text("(rustc)", &out)
.run();
let out = rustc()
.input("const-super-trait.rs")
.env("RUSTC_BOOTSTRAP", "-1")
.run_fail()
.assert_stderr_not_contains("enable `#![feature(const_trait_impl)]` in your crate and mark")
.assert_stderr_not_contains(
"as `#[const_trait]` to allow it to have `const` implementations",
)
.stderr_utf8();
diff()
.expected_file("const-super-trait-stable-disabled.stderr")
.actual_text("(rustc)", &out)
.run();
let out = rustc()
.input("const-super-trait.rs")
.ui_testing()
.run_fail()
.assert_stderr_contains("enable `#![feature(const_trait_impl)]` in your crate and mark")
.stderr_utf8();
diff()
.expected_file("const-super-trait-nightly-disabled.stderr")
.actual_text("(rustc)", &out)
.run();
}

View file

@ -2,7 +2,7 @@ error: const `impl` for trait `FromResidual` which is not marked with `#[const_t
--> $DIR/const-try.rs:15:12
|
LL | impl const FromResidual<Error> for TryMe {
| ^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^ this trait is not `const`
|
= 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
@ -11,7 +11,7 @@ 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 {
| ^^^
| ^^^ this trait is not `const`
|
= 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

View file

@ -14,110 +14,145 @@ error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/fn_trait_refs.rs:14:8
|
LL | T: ~const Fn<()> + ~const Destruct,
| ^^^^^^
| ^^^^^^ can't be applied to `Fn`
|
note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/fn_trait_refs.rs:14:8
|
LL | T: ~const Fn<()> + ~const Destruct,
| ^^^^^^
| ^^^^^^ can't be applied to `Fn`
|
note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/fn_trait_refs.rs:14:8
|
LL | T: ~const Fn<()> + ~const Destruct,
| ^^^^^^
| ^^^^^^ can't be applied to `Fn`
|
note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/fn_trait_refs.rs:21:8
|
LL | T: ~const FnMut<()> + ~const Destruct,
| ^^^^^^
| ^^^^^^ can't be applied to `FnMut`
|
note: `FnMut` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/fn_trait_refs.rs:21:8
|
LL | T: ~const FnMut<()> + ~const Destruct,
| ^^^^^^
| ^^^^^^ can't be applied to `FnMut`
|
note: `FnMut` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/fn_trait_refs.rs:21:8
|
LL | T: ~const FnMut<()> + ~const Destruct,
| ^^^^^^
| ^^^^^^ can't be applied to `FnMut`
|
note: `FnMut` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/fn_trait_refs.rs:28:8
|
LL | T: ~const FnOnce<()>,
| ^^^^^^
| ^^^^^^ can't be applied to `FnOnce`
|
note: `FnOnce` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/fn_trait_refs.rs:28:8
|
LL | T: ~const FnOnce<()>,
| ^^^^^^
| ^^^^^^ can't be applied to `FnOnce`
|
note: `FnOnce` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/fn_trait_refs.rs:28:8
|
LL | T: ~const FnOnce<()>,
| ^^^^^^
| ^^^^^^ can't be applied to `FnOnce`
|
note: `FnOnce` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/fn_trait_refs.rs:35:8
|
LL | T: ~const Fn<()> + ~const Destruct,
| ^^^^^^
| ^^^^^^ can't be applied to `Fn`
|
note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/fn_trait_refs.rs:35:8
|
LL | T: ~const Fn<()> + ~const Destruct,
| ^^^^^^
| ^^^^^^ can't be applied to `Fn`
|
note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/fn_trait_refs.rs:35:8
|
LL | T: ~const Fn<()> + ~const Destruct,
| ^^^^^^
| ^^^^^^ can't be applied to `Fn`
|
note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/fn_trait_refs.rs:49:8
|
LL | T: ~const FnMut<()> + ~const Destruct,
| ^^^^^^
| ^^^^^^ can't be applied to `FnMut`
|
note: `FnMut` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/fn_trait_refs.rs:49:8
|
LL | T: ~const FnMut<()> + ~const Destruct,
| ^^^^^^
| ^^^^^^ can't be applied to `FnMut`
|
note: `FnMut` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/fn_trait_refs.rs:49:8
|
LL | T: ~const FnMut<()> + ~const Destruct,
| ^^^^^^
| ^^^^^^ can't be applied to `FnMut`
|
note: `FnMut` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: the trait bound `fn() -> i32 {one}: const Destruct` is not satisfied

View file

@ -2,7 +2,7 @@ error: const `impl` for trait `Default` which is not marked with `#[const_trait]
--> $DIR/rustc-impl-const-stability.rs:15:12
|
LL | impl const Default for Data {
| ^^^^^^^
| ^^^^^^^ this trait is not `const`
|
= 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

View file

@ -2,14 +2,19 @@ error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/unstable-const-fn-in-libcore.rs:19:32
|
LL | const fn unwrap_or_else<F: ~const FnOnce() -> T>(self, f: F) -> T {
| ^^^^^^
| ^^^^^^ can't be applied to `FnOnce`
|
note: `FnOnce` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/unstable-const-fn-in-libcore.rs:19:32
|
LL | const fn unwrap_or_else<F: ~const FnOnce() -> T>(self, f: F) -> T {
| ^^^^^^
| ^^^^^^ can't be applied to `FnOnce`
|
note: `FnOnce` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0015]: cannot call non-const closure in constant functions

View file

@ -2,14 +2,19 @@ error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/normalize-tait-in-const.rs:26:35
|
LL | const fn with_positive<F: for<'a> ~const Fn(&'a Alias<'a>) + ~const Destruct>(fun: F) {
| ^^^^^^
| ^^^^^^ can't be applied to `Fn`
|
note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/normalize-tait-in-const.rs:26:35
|
LL | const fn with_positive<F: for<'a> ~const Fn(&'a Alias<'a>) + ~const Destruct>(fun: F) {
| ^^^^^^
| ^^^^^^ can't be applied to `Fn`
|
note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0277]: the trait bound `for<'a, 'b> fn(&'a foo::Alias<'b>) {foo}: const Destruct` is not satisfied

View file

@ -2,42 +2,57 @@ error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const_trait_impl.rs:34:9
|
LL | impl<T: ~const Default> const A for T {
| ^^^^^^
| ^^^^^^ can't be applied to `Default`
|
note: `Default` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/default.rs:LL:COL
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const_trait_impl.rs:40:9
|
LL | impl<T: ~const Default + ~const Sup> const A for T {
| ^^^^^^
| ^^^^^^ can't be applied to `Default`
|
note: `Default` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/default.rs:LL:COL
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const_trait_impl.rs:46:9
|
LL | impl<T: ~const Default + ~const Sub> const A for T {
| ^^^^^^
| ^^^^^^ can't be applied to `Default`
|
note: `Default` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/default.rs:LL:COL
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const_trait_impl.rs:40:9
|
LL | impl<T: ~const Default + ~const Sup> const A for T {
| ^^^^^^
| ^^^^^^ can't be applied to `Default`
|
note: `Default` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/default.rs:LL:COL
= 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:9
|
LL | impl<T: ~const Default> const A for T {
| ^^^^^^
| ^^^^^^ can't be applied to `Default`
|
note: `Default` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/default.rs:LL:COL
= 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:46:9
|
LL | impl<T: ~const Default + ~const Sub> const A for T {
| ^^^^^^
| ^^^^^^ can't be applied to `Default`
|
note: `Default` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/default.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 6 previous errors

View file

@ -2,7 +2,7 @@ error: const `impl` for trait `PartialEq` which is not marked with `#[const_trai
--> $DIR/call-const-trait-method-pass.rs:15:12
|
LL | impl const PartialEq for Int {
| ^^^^^^^^^
| ^^^^^^^^^ this trait is not `const`
|
= 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

View file

@ -2,14 +2,19 @@ error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/call-generic-in-impl.rs:10:9
|
LL | impl<T: ~const PartialEq> const MyPartialEq for T {
| ^^^^^^
| ^^^^^^ can't be applied to `PartialEq`
|
note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/cmp.rs:LL:COL
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/call-generic-in-impl.rs:10:9
|
LL | impl<T: ~const PartialEq> const MyPartialEq for T {
| ^^^^^^
| ^^^^^^ can't be applied to `PartialEq`
|
note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/cmp.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0015]: cannot call non-const fn `<T as PartialEq>::eq` in constant functions

View file

@ -2,7 +2,7 @@ error: const `impl` for trait `PartialEq` which is not marked with `#[const_trai
--> $DIR/call-generic-method-chain.rs:11:12
|
LL | impl const PartialEq for S {
| ^^^^^^^^^
| ^^^^^^^^^ this trait is not `const`
|
= 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
@ -11,28 +11,38 @@ error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/call-generic-method-chain.rs:20:25
|
LL | const fn equals_self<T: ~const PartialEq>(t: &T) -> bool {
| ^^^^^^
| ^^^^^^ can't be applied to `PartialEq`
|
note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/cmp.rs:LL:COL
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/call-generic-method-chain.rs:20:25
|
LL | const fn equals_self<T: ~const PartialEq>(t: &T) -> bool {
| ^^^^^^
| ^^^^^^ can't be applied to `PartialEq`
|
note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/cmp.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/call-generic-method-chain.rs:24:33
|
LL | const fn equals_self_wrapper<T: ~const PartialEq>(t: &T) -> bool {
| ^^^^^^
| ^^^^^^ can't be applied to `PartialEq`
|
note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/cmp.rs:LL:COL
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/call-generic-method-chain.rs:24:33
|
LL | const fn equals_self_wrapper<T: ~const PartialEq>(t: &T) -> bool {
| ^^^^^^
| ^^^^^^ can't be applied to `PartialEq`
|
note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/cmp.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0015]: cannot call non-const operator in constant functions

View file

@ -2,7 +2,7 @@ error: const `impl` for trait `PartialEq` which is not marked with `#[const_trai
--> $DIR/call-generic-method-dup-bound.rs:9:12
|
LL | impl const PartialEq for S {
| ^^^^^^^^^
| ^^^^^^^^^ this trait is not `const`
|
= 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
@ -11,28 +11,38 @@ error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/call-generic-method-dup-bound.rs:20:37
|
LL | const fn equals_self<T: PartialEq + ~const PartialEq>(t: &T) -> bool {
| ^^^^^^
| ^^^^^^ can't be applied to `PartialEq`
|
note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/cmp.rs:LL:COL
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/call-generic-method-dup-bound.rs:20:37
|
LL | const fn equals_self<T: PartialEq + ~const PartialEq>(t: &T) -> bool {
| ^^^^^^
| ^^^^^^ can't be applied to `PartialEq`
|
note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/cmp.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/call-generic-method-dup-bound.rs:27:30
|
LL | const fn equals_self2<T: A + ~const PartialEq>(t: &T) -> bool {
| ^^^^^^
| ^^^^^^ can't be applied to `PartialEq`
|
note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/cmp.rs:LL:COL
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/call-generic-method-dup-bound.rs:27:30
|
LL | const fn equals_self2<T: A + ~const PartialEq>(t: &T) -> bool {
| ^^^^^^
| ^^^^^^ can't be applied to `PartialEq`
|
note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/cmp.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0015]: cannot call non-const operator in constant functions

View file

@ -2,7 +2,7 @@ error: const `impl` for trait `PartialEq` which is not marked with `#[const_trai
--> $DIR/call-generic-method-pass.rs:11:12
|
LL | impl const PartialEq for S {
| ^^^^^^^^^
| ^^^^^^^^^ this trait is not `const`
|
= 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
@ -11,14 +11,19 @@ error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/call-generic-method-pass.rs:20:25
|
LL | const fn equals_self<T: ~const PartialEq>(t: &T) -> bool {
| ^^^^^^
| ^^^^^^ can't be applied to `PartialEq`
|
note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/cmp.rs:LL:COL
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/call-generic-method-pass.rs:20:25
|
LL | const fn equals_self<T: ~const PartialEq>(t: &T) -> bool {
| ^^^^^^
| ^^^^^^ can't be applied to `PartialEq`
|
note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/cmp.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0015]: cannot call non-const operator in constant functions

View file

@ -2,21 +2,35 @@ error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-bounds-non-const-trait.rs:6:21
|
LL | const fn perform<T: ~const NonConst>() {}
| ^^^^^^
| ^^^^^^ can't be applied to `NonConst`
|
help: mark `NonConst` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait NonConst {}
| ++++++++++++++
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-bounds-non-const-trait.rs:6:21
|
LL | const fn perform<T: ~const NonConst>() {}
| ^^^^^^
| ^^^^^^ can't be applied to `NonConst`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: mark `NonConst` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait NonConst {}
| ++++++++++++++
error: `const` can only be applied to `#[const_trait]` traits
--> $DIR/const-bounds-non-const-trait.rs:10:15
|
LL | fn operate<T: const NonConst>() {}
| ^^^^^
| ^^^^^ can't be applied to `NonConst`
|
help: mark `NonConst` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait NonConst {}
| ++++++++++++++
error: aborting due to 3 previous errors

View file

@ -2,22 +2,29 @@ error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-closure-parse-not-item.rs:7:25
|
LL | const fn test() -> impl ~const Fn() {
| ^^^^^^
| ^^^^^^ can't be applied to `Fn`
|
note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-closure-parse-not-item.rs:7:25
|
LL | const fn test() -> impl ~const Fn() {
| ^^^^^^
| ^^^^^^ can't be applied to `Fn`
|
note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-closure-parse-not-item.rs:7:25
|
LL | const fn test() -> impl ~const Fn() {
| ^^^^^^
| ^^^^^^ can't be applied to `Fn`
|
note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 3 previous errors

View file

@ -2,14 +2,19 @@ error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-closure-trait-method-fail.rs:14:32
|
LL | const fn need_const_closure<T: ~const FnOnce(()) -> i32>(x: T) -> i32 {
| ^^^^^^
| ^^^^^^ can't be applied to `FnOnce`
|
note: `FnOnce` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-closure-trait-method-fail.rs:14:32
|
LL | const fn need_const_closure<T: ~const FnOnce(()) -> i32>(x: T) -> i32 {
| ^^^^^^
| ^^^^^^ can't be applied to `FnOnce`
|
note: `FnOnce` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0015]: cannot call non-const closure in constant functions

View file

@ -2,14 +2,19 @@ error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-closure-trait-method.rs:14:32
|
LL | const fn need_const_closure<T: ~const FnOnce(()) -> i32>(x: T) -> i32 {
| ^^^^^^
| ^^^^^^ can't be applied to `FnOnce`
|
note: `FnOnce` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-closure-trait-method.rs:14:32
|
LL | const fn need_const_closure<T: ~const FnOnce(()) -> i32>(x: T) -> i32 {
| ^^^^^^
| ^^^^^^ can't be applied to `FnOnce`
|
note: `FnOnce` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0015]: cannot call non-const closure in constant functions

View file

@ -2,56 +2,76 @@ error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-closures.rs:8:12
|
LL | F: ~const FnOnce() -> u8,
| ^^^^^^
| ^^^^^^ can't be applied to `FnOnce`
|
note: `FnOnce` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-closures.rs:9:12
|
LL | F: ~const FnMut() -> u8,
| ^^^^^^
| ^^^^^^ can't be applied to `FnMut`
|
note: `FnMut` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-closures.rs:10:12
|
LL | F: ~const Fn() -> u8,
| ^^^^^^
| ^^^^^^ can't be applied to `Fn`
|
note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-closures.rs:8:12
|
LL | F: ~const FnOnce() -> u8,
| ^^^^^^
| ^^^^^^ can't be applied to `FnOnce`
|
note: `FnOnce` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-closures.rs:9:12
|
LL | F: ~const FnMut() -> u8,
| ^^^^^^
| ^^^^^^ can't be applied to `FnMut`
|
note: `FnMut` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-closures.rs:10:12
|
LL | F: ~const Fn() -> u8,
| ^^^^^^
| ^^^^^^ can't be applied to `Fn`
|
note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-closures.rs:23:20
|
LL | const fn answer<F: ~const Fn() -> u8>(f: &F) -> u8 {
| ^^^^^^
| ^^^^^^ can't be applied to `Fn`
|
note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/const-closures.rs:23:20
|
LL | const fn answer<F: ~const Fn() -> u8>(f: &F) -> u8 {
| ^^^^^^
| ^^^^^^ can't be applied to `Fn`
|
note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0015]: cannot call non-const closure in constant functions

View file

@ -1,14 +1,15 @@
error: const `impl` for trait `A` which is not marked with `#[const_trait]`
--> $DIR/const-impl-requires-const-trait.rs:6:12
|
LL | pub trait A {}
| - help: mark `A` as const: `#[const_trait]`
LL |
LL | impl const A for () {}
| ^
| ^ this trait is not `const`
|
= 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
help: mark `A` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] pub trait A {}
| ++++++++++++++
error: aborting due to 1 previous error

View file

@ -11,7 +11,7 @@ error: const `impl` for trait `Default` which is not marked with `#[const_trait]
--> $DIR/derive-const-gate.rs:1:16
|
LL | #[derive_const(Default)]
| ^^^^^^^
| ^^^^^^^ this trait is not `const`
|
= 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

View file

@ -2,7 +2,7 @@ error: const `impl` for trait `Default` which is not marked with `#[const_trait]
--> $DIR/derive-const-non-const-type.rs:10:16
|
LL | #[derive_const(Default)]
| ^^^^^^^
| ^^^^^^^ this trait is not `const`
|
= 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

View file

@ -14,7 +14,7 @@ error: const `impl` for trait `Default` which is not marked with `#[const_trait]
--> $DIR/derive-const-use.rs:7:12
|
LL | impl const Default for A {
| ^^^^^^^
| ^^^^^^^ this trait is not `const`
|
= 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
@ -23,7 +23,7 @@ error: const `impl` for trait `Default` which is not marked with `#[const_trait]
--> $DIR/derive-const-use.rs:15:16
|
LL | #[derive_const(Default, PartialEq)]
| ^^^^^^^
| ^^^^^^^ this trait is not `const`
|
= 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
@ -33,7 +33,7 @@ error: const `impl` for trait `PartialEq` which is not marked with `#[const_trai
--> $DIR/derive-const-use.rs:11:12
|
LL | impl const PartialEq for A {
| ^^^^^^^^^
| ^^^^^^^^^ this trait is not `const`
|
= 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
@ -42,7 +42,7 @@ error: const `impl` for trait `PartialEq` which is not marked with `#[const_trai
--> $DIR/derive-const-use.rs:15:25
|
LL | #[derive_const(Default, PartialEq)]
| ^^^^^^^^^
| ^^^^^^^^^ this trait is not `const`
|
= 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

View file

@ -2,13 +2,16 @@ error: const `impl` for trait `PartialEq` which is not marked with `#[const_trai
--> $DIR/derive-const-with-params.rs:7:16
|
LL | #[derive_const(PartialEq)]
| ^^^^^^^^^
| ^^^^^^^^^ this trait is not `const`
|
= 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
|
note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/cmp.rs:LL:COL
error[E0015]: cannot call non-const operator in constant functions
--> $DIR/derive-const-with-params.rs:8:23

View file

@ -12,22 +12,29 @@ error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/ice-112822-expected-type-for-param.rs:3:25
|
LL | const fn test() -> impl ~const Fn() {
| ^^^^^^
| ^^^^^^ can't be applied to `Fn`
|
note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/ice-112822-expected-type-for-param.rs:3:25
|
LL | const fn test() -> impl ~const Fn() {
| ^^^^^^
| ^^^^^^ can't be applied to `Fn`
|
note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/ice-112822-expected-type-for-param.rs:3:25
|
LL | const fn test() -> impl ~const Fn() {
| ^^^^^^
| ^^^^^^ can't be applied to `Fn`
|
note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0015]: cannot call non-const operator in constant functions

View file

@ -1,32 +1,39 @@
error: const `impl` for trait `Foo` which is not marked with `#[const_trait]`
--> $DIR/spec-effectvar-ice.rs:10:15
|
LL | trait Foo {}
| - help: mark `Foo` as const: `#[const_trait]`
LL |
LL | impl<T> const Foo for T {}
| ^^^
| ^^^ this trait is not `const`
|
= 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
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Foo {}
| ++++++++++++++
error: const `impl` for trait `Foo` which is not marked with `#[const_trait]`
--> $DIR/spec-effectvar-ice.rs:13:15
|
LL | trait Foo {}
| - help: mark `Foo` as const: `#[const_trait]`
...
LL | impl<T> const Foo for T where T: const Specialize {}
| ^^^
| ^^^ this trait is not `const`
|
= 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
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Foo {}
| ++++++++++++++
error: `const` can only be applied to `#[const_trait]` traits
--> $DIR/spec-effectvar-ice.rs:13:34
|
LL | impl<T> const Foo for T where T: const Specialize {}
| ^^^^^
| ^^^^^ can't be applied to `Specialize`
|
help: mark `Specialize` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Specialize {}
| ++++++++++++++
error: specialization impl does not specialize any associated items
--> $DIR/spec-effectvar-ice.rs:13:1

View file

@ -2,7 +2,7 @@ error: const `impl` for trait `FromResidual` which is not marked with `#[const_t
--> $DIR/ice-119717-constant-lifetime.rs:6:15
|
LL | impl<T> const FromResidual for T {
| ^^^^^^^^^^^^
| ^^^^^^^^^^^^ this trait is not `const`
|
= 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

View file

@ -2,14 +2,19 @@ error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/ice-123664-unexpected-bound-var.rs:4:27
|
LL | const fn with_positive<F: ~const Fn()>() {}
| ^^^^^^
| ^^^^^^ can't be applied to `Fn`
|
note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/ice-123664-unexpected-bound-var.rs:4:27
|
LL | const fn with_positive<F: ~const Fn()>() {}
| ^^^^^^
| ^^^^^^ can't be applied to `Fn`
|
note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 2 previous errors

View file

@ -2,7 +2,7 @@ error: const `impl` for trait `FromResidual` which is not marked with `#[const_t
--> $DIR/ice-126148-failed-to-normalize.rs:8:12
|
LL | impl const FromResidual<Error> for TryMe {}
| ^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^ this trait is not `const`
|
= 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
@ -19,7 +19,7 @@ error: const `impl` for trait `Try` which is not marked with `#[const_trait]`
--> $DIR/ice-126148-failed-to-normalize.rs:12:12
|
LL | impl const Try for TryMe {
| ^^^
| ^^^ this trait is not `const`
|
= 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

View file

@ -2,14 +2,19 @@ error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/non-const-op-in-closure-in-const.rs:10:44
|
LL | impl<A, B> const Convert<B> for A where B: ~const From<A> {
| ^^^^^^
| ^^^^^^ can't be applied to `From`
|
note: `From` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/convert/mod.rs:LL:COL
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/non-const-op-in-closure-in-const.rs:10:44
|
LL | impl<A, B> const Convert<B> for A where B: ~const From<A> {
| ^^^^^^
| ^^^^^^ can't be applied to `From`
|
note: `From` can't be used with `~const` because it isn't annotated with `#[const_trait]`
--> $SRC_DIR/core/src/convert/mod.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0015]: cannot call non-const fn `<B as From<A>>::from` in constant functions

View file

@ -14,23 +14,36 @@ error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-2.rs:11:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^
| ^^^^^^ can't be applied to `Foo`
|
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Foo {
| ++++++++++++++
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-2.rs:11:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^
| ^^^^^^ can't be applied to `Foo`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Foo {
| ++++++++++++++
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-2.rs:11:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^
| ^^^^^^ can't be applied to `Foo`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Foo {
| ++++++++++++++
error[E0015]: cannot call non-const fn `<T as Foo>::a` in constant functions
--> $DIR/super-traits-fail-2.rs:20:7

View file

@ -2,39 +2,60 @@ error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-2.rs:11:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^
| ^^^^^^ can't be applied to `Foo`
|
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Foo {
| ++++++++++++++
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-2.rs:11:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^
| ^^^^^^ can't be applied to `Foo`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Foo {
| ++++++++++++++
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-2.rs:11:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^
| ^^^^^^ can't be applied to `Foo`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Foo {
| ++++++++++++++
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-2.rs:11:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^
| ^^^^^^ can't be applied to `Foo`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Foo {
| ++++++++++++++
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-2.rs:11:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^
| ^^^^^^ can't be applied to `Foo`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Foo {
| ++++++++++++++
error[E0015]: cannot call non-const fn `<T as Foo>::a` in constant functions
--> $DIR/super-traits-fail-2.rs:20:7

View file

@ -0,0 +1,102 @@
error: `~const` is not allowed here
--> $DIR/super-traits-fail-3.rs:23:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^
|
note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds
--> $DIR/super-traits-fail-3.rs:23:1
|
LL | trait Bar: ~const Foo {}
| ^^^^^^^^^^^^^^^^^^^^^^^^
error[E0658]: const trait impls are experimental
--> $DIR/super-traits-fail-3.rs:23:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^
|
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: const trait impls are experimental
--> $DIR/super-traits-fail-3.rs:32:17
|
LL | const fn foo<T: ~const Bar>(x: &T) {
| ^^^^^^
|
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-3.rs:23:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^ can't be applied to `Foo`
|
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Foo {
| ++++++++++++++
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-3.rs:23:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^ can't be applied to `Foo`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Foo {
| ++++++++++++++
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-3.rs:23:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^ can't be applied to `Foo`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Foo {
| ++++++++++++++
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-3.rs:32:17
|
LL | const fn foo<T: ~const Bar>(x: &T) {
| ^^^^^^ can't be applied to `Bar`
|
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Bar: ~const Foo {}
| ++++++++++++++
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-3.rs:32:17
|
LL | const fn foo<T: ~const Bar>(x: &T) {
| ^^^^^^ can't be applied to `Bar`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Bar: ~const Foo {}
| ++++++++++++++
error[E0015]: cannot call non-const fn `<T as Foo>::a` in constant functions
--> $DIR/super-traits-fail-3.rs:36:7
|
LL | x.a();
| ^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
error: aborting due to 9 previous errors
Some errors have detailed explanations: E0015, E0658.
For more information about an error, try `rustc --explain E0015`.

View file

@ -0,0 +1,102 @@
error: `~const` is not allowed here
--> $DIR/super-traits-fail-3.rs:23:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^
|
note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds
--> $DIR/super-traits-fail-3.rs:23:1
|
LL | trait Bar: ~const Foo {}
| ^^^^^^^^^^^^^^^^^^^^^^^^
error[E0658]: const trait impls are experimental
--> $DIR/super-traits-fail-3.rs:23:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^
|
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: const trait impls are experimental
--> $DIR/super-traits-fail-3.rs:32:17
|
LL | const fn foo<T: ~const Bar>(x: &T) {
| ^^^^^^
|
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-3.rs:23:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^ can't be applied to `Foo`
|
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Foo {
| ++++++++++++++
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-3.rs:23:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^ can't be applied to `Foo`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Foo {
| ++++++++++++++
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-3.rs:23:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^ can't be applied to `Foo`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Foo {
| ++++++++++++++
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-3.rs:32:17
|
LL | const fn foo<T: ~const Bar>(x: &T) {
| ^^^^^^ can't be applied to `Bar`
|
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Bar: ~const Foo {}
| ++++++++++++++
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-3.rs:32:17
|
LL | const fn foo<T: ~const Bar>(x: &T) {
| ^^^^^^ can't be applied to `Bar`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Bar: ~const Foo {}
| ++++++++++++++
error[E0015]: cannot call non-const fn `<T as Foo>::a` in constant functions
--> $DIR/super-traits-fail-3.rs:36:7
|
LL | x.a();
| ^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
error: aborting due to 9 previous errors
Some errors have detailed explanations: E0015, E0658.
For more information about an error, try `rustc --explain E0015`.

View file

@ -1,49 +0,0 @@
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-3.rs:13:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-3.rs:13:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-3.rs:13:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-3.rs:13:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-3.rs:13:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0015]: cannot call non-const fn `<T as Foo>::a` in constant functions
--> $DIR/super-traits-fail-3.rs:24:7
|
LL | x.a();
| ^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
error: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0015`.

View file

@ -0,0 +1,53 @@
error[E0658]: const trait impls are experimental
--> $DIR/super-traits-fail-3.rs:23:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^
|
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: const trait impls are experimental
--> $DIR/super-traits-fail-3.rs:32:17
|
LL | const fn foo<T: ~const Bar>(x: &T) {
| ^^^^^^
|
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: `const_trait` is a temporary placeholder for marking a trait that is suitable for `const` `impls` and all default bodies as `const`, which may be removed or renamed in the future.
--> $DIR/super-traits-fail-3.rs:15:37
|
LL | #[cfg_attr(any(yyy, yyn, nyy, nyn), const_trait)]
| ^^^^^^^^^^^
|
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: `const_trait` is a temporary placeholder for marking a trait that is suitable for `const` `impls` and all default bodies as `const`, which may be removed or renamed in the future.
--> $DIR/super-traits-fail-3.rs:21:37
|
LL | #[cfg_attr(any(yyy, yny, nyy, nyn), const_trait)]
| ^^^^^^^^^^^
|
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: cannot call conditionally-const method `<T as Foo>::a` in constant functions
--> $DIR/super-traits-fail-3.rs:36:5
|
LL | x.a();
| ^^^^^
|
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0658`.

View file

@ -0,0 +1,53 @@
error[E0658]: const trait impls are experimental
--> $DIR/super-traits-fail-3.rs:23:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^
|
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: const trait impls are experimental
--> $DIR/super-traits-fail-3.rs:32:17
|
LL | const fn foo<T: ~const Bar>(x: &T) {
| ^^^^^^
|
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: `const_trait` is a temporary placeholder for marking a trait that is suitable for `const` `impls` and all default bodies as `const`, which may be removed or renamed in the future.
--> $DIR/super-traits-fail-3.rs:15:37
|
LL | #[cfg_attr(any(yyy, yyn, nyy, nyn), const_trait)]
| ^^^^^^^^^^^
|
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: `const_trait` is a temporary placeholder for marking a trait that is suitable for `const` `impls` and all default bodies as `const`, which may be removed or renamed in the future.
--> $DIR/super-traits-fail-3.rs:21:37
|
LL | #[cfg_attr(any(yyy, yny, nyy, nyn), const_trait)]
| ^^^^^^^^^^^
|
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: cannot call conditionally-const method `<T as Foo>::a` in constant functions
--> $DIR/super-traits-fail-3.rs:36:5
|
LL | x.a();
| ^^^^^
|
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0658`.

View file

@ -1,29 +1,42 @@
//@ compile-flags: -Znext-solver
#![feature(const_trait_impl)]
#![cfg_attr(any(yyy, yyn, yny, ynn), feature(const_trait_impl))]
//@ revisions: yy yn ny nn
//@[yy] check-pass
//@ revisions: yyy yyn yny ynn nyy nyn nny nnn
//@[yyy] check-pass
/// yyy: feature enabled, Foo is const, Bar is const
/// yyn: feature enabled, Foo is const, Bar is not const
/// yny: feature enabled, Foo is not const, Bar is const
/// ynn: feature enabled, Foo is not const, Bar is not const
/// nyy: feature not enabled, Foo is const, Bar is const
/// nyn: feature not enabled, Foo is const, Bar is not const
/// nny: feature not enabled, Foo is not const, Bar is const
/// nnn: feature not enabled, Foo is not const, Bar is not const
#[cfg_attr(any(yy, yn), const_trait)]
#[cfg_attr(any(yyy, yyn, nyy, nyn), const_trait)]
//[nyy,nyn]~^ ERROR: `const_trait` is a temporary placeholder for marking a trait that is suitable for `const` `impls` and all default bodies as `const`, which may be removed or renamed in the future
trait Foo {
fn a(&self);
}
#[cfg_attr(any(yy, ny), const_trait)]
#[cfg_attr(any(yyy, yny, nyy, nyn), const_trait)]
//[nyy,nyn]~^ ERROR: `const_trait` is a temporary placeholder for marking a trait that is suitable for `const` `impls` and all default bodies as `const`, which may be removed or renamed in the future
trait Bar: ~const Foo {}
//[ny,nn]~^ ERROR: `~const` can only be applied to `#[const_trait]`
//[ny,nn]~| ERROR: `~const` can only be applied to `#[const_trait]`
//[ny,nn]~| ERROR: `~const` can only be applied to `#[const_trait]`
//[ny]~| ERROR: `~const` can only be applied to `#[const_trait]`
//[ny]~| ERROR: `~const` can only be applied to `#[const_trait]`
//[yn,nn]~^^^^^^ ERROR: `~const` is not allowed here
//[yny,ynn,nny,nnn]~^ ERROR: `~const` can only be applied to `#[const_trait]`
//[yny,ynn,nny,nnn]~| ERROR: `~const` can only be applied to `#[const_trait]`
//[yny,ynn,nny,nnn]~| ERROR: `~const` can only be applied to `#[const_trait]`
//[yny]~^^^^ ERROR: `~const` can only be applied to `#[const_trait]`
//[yny]~| ERROR: `~const` can only be applied to `#[const_trait]`
//[yyn,ynn,nny,nnn]~^^^^^^ ERROR: `~const` is not allowed here
//[nyy,nyn,nny,nnn]~^^^^^^^ ERROR: const trait impls are experimental
const fn foo<T: ~const Bar>(x: &T) {
//[yn,nn]~^ ERROR: `~const` can only be applied to `#[const_trait]`
//[yn,nn]~| ERROR: `~const` can only be applied to `#[const_trait]`
//[yyn,ynn,nny,nnn]~^ ERROR: `~const` can only be applied to `#[const_trait]`
//[yyn,ynn,nny,nnn]~| ERROR: `~const` can only be applied to `#[const_trait]`
//[nyy,nyn,nny,nnn]~^^^ ERROR: const trait impls are experimental
x.a();
//[yn]~^ ERROR: the trait bound `T: ~const Foo` is not satisfied
//[nn,ny]~^^ ERROR: cannot call non-const fn `<T as Foo>::a` in constant functions
//[yyn]~^ ERROR: the trait bound `T: ~const Foo` is not satisfied
//[ynn,yny,nny,nnn]~^^ ERROR: cannot call non-const fn `<T as Foo>::a` in constant functions
//[nyy,nyn]~^^^ ERROR: cannot call conditionally-const method `<T as Foo>::a` in constant functions
}
fn main() {}

View file

@ -1,53 +1,75 @@
error: `~const` is not allowed here
--> $DIR/super-traits-fail-3.rs:13:12
--> $DIR/super-traits-fail-3.rs:23:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^
|
note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds
--> $DIR/super-traits-fail-3.rs:13:1
--> $DIR/super-traits-fail-3.rs:23:1
|
LL | trait Bar: ~const Foo {}
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-3.rs:13:12
--> $DIR/super-traits-fail-3.rs:23:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^
| ^^^^^^ can't be applied to `Foo`
|
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Foo {
| ++++++++++++++
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-3.rs:13:12
--> $DIR/super-traits-fail-3.rs:23:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^
| ^^^^^^ can't be applied to `Foo`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Foo {
| ++++++++++++++
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-3.rs:13:12
--> $DIR/super-traits-fail-3.rs:23:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^
| ^^^^^^ can't be applied to `Foo`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Foo {
| ++++++++++++++
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-3.rs:21:17
--> $DIR/super-traits-fail-3.rs:32:17
|
LL | const fn foo<T: ~const Bar>(x: &T) {
| ^^^^^^
| ^^^^^^ can't be applied to `Bar`
|
help: mark `Bar` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Bar: ~const Foo {}
| ++++++++++++++
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-3.rs:21:17
--> $DIR/super-traits-fail-3.rs:32:17
|
LL | const fn foo<T: ~const Bar>(x: &T) {
| ^^^^^^
| ^^^^^^ can't be applied to `Bar`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: mark `Bar` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Bar: ~const Foo {}
| ++++++++++++++
error[E0015]: cannot call non-const fn `<T as Foo>::a` in constant functions
--> $DIR/super-traits-fail-3.rs:24:7
--> $DIR/super-traits-fail-3.rs:36:7
|
LL | x.a();
| ^^^

View file

@ -0,0 +1,70 @@
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-3.rs:23:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^ can't be applied to `Foo`
|
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Foo {
| ++++++++++++++
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-3.rs:23:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^ can't be applied to `Foo`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Foo {
| ++++++++++++++
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-3.rs:23:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^ can't be applied to `Foo`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Foo {
| ++++++++++++++
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-3.rs:23:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^ can't be applied to `Foo`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Foo {
| ++++++++++++++
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-3.rs:23:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^ can't be applied to `Foo`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Foo {
| ++++++++++++++
error[E0015]: cannot call non-const fn `<T as Foo>::a` in constant functions
--> $DIR/super-traits-fail-3.rs:36:7
|
LL | x.a();
| ^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
error: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0015`.

View file

@ -1,31 +1,40 @@
error: `~const` is not allowed here
--> $DIR/super-traits-fail-3.rs:13:12
--> $DIR/super-traits-fail-3.rs:23:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^
|
note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds
--> $DIR/super-traits-fail-3.rs:13:1
--> $DIR/super-traits-fail-3.rs:23:1
|
LL | trait Bar: ~const Foo {}
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-3.rs:21:17
--> $DIR/super-traits-fail-3.rs:32:17
|
LL | const fn foo<T: ~const Bar>(x: &T) {
| ^^^^^^
| ^^^^^^ can't be applied to `Bar`
|
help: mark `Bar` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Bar: ~const Foo {}
| ++++++++++++++
error: `~const` can only be applied to `#[const_trait]` traits
--> $DIR/super-traits-fail-3.rs:21:17
--> $DIR/super-traits-fail-3.rs:32:17
|
LL | const fn foo<T: ~const Bar>(x: &T) {
| ^^^^^^
| ^^^^^^ can't be applied to `Bar`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: mark `Bar` as `#[const_trait]` to allow it to have `const` implementations
|
LL | #[const_trait] trait Bar: ~const Foo {}
| ++++++++++++++
error[E0277]: the trait bound `T: ~const Foo` is not satisfied
--> $DIR/super-traits-fail-3.rs:24:7
--> $DIR/super-traits-fail-3.rs:36:7
|
LL | x.a();
| ^

View file

@ -2,7 +2,7 @@ error: const `impl` for trait `Try` which is not marked with `#[const_trait]`
--> $DIR/trait-default-body-stability.rs:19:12
|
LL | impl const Try for T {
| ^^^
| ^^^ this trait is not `const`
|
= 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
@ -11,7 +11,7 @@ error: const `impl` for trait `FromResidual` which is not marked with `#[const_t
--> $DIR/trait-default-body-stability.rs:34:12
|
LL | impl const FromResidual for T {
| ^^^^^^^^^^^^
| ^^^^^^^^^^^^ this trait is not `const`
|
= 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