diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs index 8218126ea29c3..e0506c0c5fd1f 100644 --- a/compiler/rustc_codegen_llvm/src/context.rs +++ b/compiler/rustc_codegen_llvm/src/context.rs @@ -159,6 +159,11 @@ pub(crate) unsafe fn create_module<'ll>( // See https://github.com/llvm/llvm-project/pull/112084 target_data_layout = target_data_layout.replace("-i128:128", ""); } + if sess.target.arch.starts_with("powerpc64") { + // LLVM 20 updates the powerpc64 layout to correctly align 128 bit integers to 128 bit. + // See https://github.com/llvm/llvm-project/pull/118004 + target_data_layout = target_data_layout.replace("-i128:128", ""); + } } // Ensure the data-layout values hardcoded remain the defaults. diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index db2b03d9aeda8..07eb89e604136 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -230,6 +230,8 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option(sess: &Session, s: &'a str) -> Option Some(LLVMFeature::new("v9")), ("sparc", "v8plus") if get_version().0 < 19 => None, + ("powerpc", "power8-crypto") => Some(LLVMFeature::new("crypto")), (_, s) => Some(LLVMFeature::new(s)), } } diff --git a/compiler/rustc_hir_analysis/messages.ftl b/compiler/rustc_hir_analysis/messages.ftl index 070d63b48b7bd..32498d9c5ab5b 100644 --- a/compiler/rustc_hir_analysis/messages.ftl +++ b/compiler/rustc_hir_analysis/messages.ftl @@ -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_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_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]` + .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 diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index 8f9b062603127..96d2714252af9 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -1638,11 +1638,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: (), })) diff --git a/compiler/rustc_hir_analysis/src/errors.rs b/compiler/rustc_hir_analysis/src/errors.rs index 4142dcff226bf..7f62ccc91f09a 100644 --- a/compiler/rustc_hir_analysis/src/errors.rs +++ b/compiler/rustc_hir_analysis/src/errors.rs @@ -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, + 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, + pub suggestion_pre: &'static str, + #[suggestion( + applicability = "machine-applicable", + code = "#[const_trait] ", + style = "verbose" + )] + pub suggestion: Option, + pub trait_name: String, } #[derive(Diagnostic)] diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs index 3313339abb313..09e46517cea8b 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs @@ -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, }); } diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index 0e079b037691e..30f02b80ea626 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -403,6 +403,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }) | hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Const(..), .. }) => true, + hir::Node::Pat(_) => { + self.dcx().span_delayed_bug(expr.span, "place expr not allowed in pattern"); + true + } + // These nodes do not have direct sub-exprs. hir::Node::Param(_) | hir::Node::Item(_) @@ -415,7 +420,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { | hir::Node::Ty(_) | hir::Node::AssocItemConstraint(_) | hir::Node::TraitRef(_) - | hir::Node::Pat(_) | hir::Node::PatField(_) | hir::Node::LetStmt(_) | hir::Node::Synthetic diff --git a/compiler/rustc_target/src/spec/targets/powerpc64_ibm_aix.rs b/compiler/rustc_target/src/spec/targets/powerpc64_ibm_aix.rs index 0f361054f7a02..edabbbf5f005b 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc64_ibm_aix.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc64_ibm_aix.rs @@ -19,7 +19,7 @@ pub(crate) fn target() -> Target { std: None, // ? }, pointer_width: 64, - data_layout: "E-m:a-Fi64-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(), + data_layout: "E-m:a-Fi64-i64:64-i128:128-n32:64-S128-v256:256:256-v512:512:512".into(), arch: "powerpc64".into(), options: base, } diff --git a/compiler/rustc_target/src/spec/targets/powerpc64_unknown_freebsd.rs b/compiler/rustc_target/src/spec/targets/powerpc64_unknown_freebsd.rs index 680b024cb6e60..68a3718035cd9 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc64_unknown_freebsd.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc64_unknown_freebsd.rs @@ -17,7 +17,7 @@ pub(crate) fn target() -> Target { std: Some(true), }, pointer_width: 64, - data_layout: "E-m:e-Fn32-i64:64-n32:64".into(), + data_layout: "E-m:e-Fn32-i64:64-i128:128-n32:64".into(), arch: "powerpc64".into(), options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, } diff --git a/compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_gnu.rs index 5acd9205a8c74..351ffa65eba8e 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_gnu.rs @@ -17,7 +17,7 @@ pub(crate) fn target() -> Target { std: Some(true), }, pointer_width: 64, - data_layout: "E-m:e-Fi64-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(), + data_layout: "E-m:e-Fi64-i64:64-i128:128-n32:64-S128-v256:256:256-v512:512:512".into(), arch: "powerpc64".into(), options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, } diff --git a/compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_musl.rs index 62c30aebc518e..a964f417799f6 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_musl.rs @@ -17,7 +17,7 @@ pub(crate) fn target() -> Target { std: Some(true), }, pointer_width: 64, - data_layout: "E-m:e-Fn32-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(), + data_layout: "E-m:e-Fn32-i64:64-i128:128-n32:64-S128-v256:256:256-v512:512:512".into(), arch: "powerpc64".into(), options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, } diff --git a/compiler/rustc_target/src/spec/targets/powerpc64_unknown_openbsd.rs b/compiler/rustc_target/src/spec/targets/powerpc64_unknown_openbsd.rs index c723847cada73..31fbb14152407 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc64_unknown_openbsd.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc64_unknown_openbsd.rs @@ -17,7 +17,7 @@ pub(crate) fn target() -> Target { std: Some(true), }, pointer_width: 64, - data_layout: "E-m:e-Fn32-i64:64-n32:64".into(), + data_layout: "E-m:e-Fn32-i64:64-i128:128-n32:64".into(), arch: "powerpc64".into(), options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base }, } diff --git a/compiler/rustc_target/src/spec/targets/powerpc64_wrs_vxworks.rs b/compiler/rustc_target/src/spec/targets/powerpc64_wrs_vxworks.rs index 1d3d9f1b77df8..c37aa8d502ad7 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc64_wrs_vxworks.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc64_wrs_vxworks.rs @@ -17,7 +17,7 @@ pub(crate) fn target() -> Target { std: Some(true), }, pointer_width: 64, - data_layout: "E-m:e-Fi64-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(), + data_layout: "E-m:e-Fi64-i64:64-i128:128-n32:64-S128-v256:256:256-v512:512:512".into(), arch: "powerpc64".into(), options: TargetOptions { endian: Endian::Big, ..base }, } diff --git a/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_freebsd.rs b/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_freebsd.rs index 0c1218bd05939..13885c7326a71 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_freebsd.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_freebsd.rs @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { std: Some(true), }, pointer_width: 64, - data_layout: "e-m:e-Fn32-i64:64-n32:64".into(), + data_layout: "e-m:e-Fn32-i64:64-i128:128-n32:64".into(), arch: "powerpc64".into(), options: TargetOptions { mcount: "_mcount".into(), ..base }, } diff --git a/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_linux_gnu.rs index 23913687a1fd8..06ae54063cef4 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_linux_gnu.rs @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { std: Some(true), }, pointer_width: 64, - data_layout: "e-m:e-Fn32-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(), + data_layout: "e-m:e-Fn32-i64:64-i128:128-n32:64-S128-v256:256:256-v512:512:512".into(), arch: "powerpc64".into(), options: TargetOptions { mcount: "_mcount".into(), ..base }, } diff --git a/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_linux_musl.rs index 50946ae4ce66d..04fe5f9af335e 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc64le_unknown_linux_musl.rs @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { std: Some(true), }, pointer_width: 64, - data_layout: "e-m:e-Fn32-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(), + data_layout: "e-m:e-Fn32-i64:64-i128:128-n32:64-S128-v256:256:256-v512:512:512".into(), arch: "powerpc64".into(), options: TargetOptions { mcount: "_mcount".into(), ..base }, } diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index 67c047dddfcf4..3a1306072658d 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -412,6 +412,7 @@ const POWERPC_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[ ("partword-atomics", Unstable(sym::powerpc_target_feature), &[]), ("power10-vector", Unstable(sym::powerpc_target_feature), &["power9-vector"]), ("power8-altivec", Unstable(sym::powerpc_target_feature), &["altivec"]), + ("power8-crypto", Unstable(sym::powerpc_target_feature), &["power8-altivec"]), ("power8-vector", Unstable(sym::powerpc_target_feature), &["vsx", "power8-altivec"]), ("power9-altivec", Unstable(sym::powerpc_target_feature), &["power8-altivec"]), ("power9-vector", Unstable(sym::powerpc_target_feature), &["power8-vector", "power9-altivec"]), diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs index 0ad1cad6914ad..6b601405e1c2a 100644 --- a/library/core/src/ptr/non_null.rs +++ b/library/core/src/ptr/non_null.rs @@ -217,7 +217,7 @@ impl NonNull { /// } /// ``` #[stable(feature = "nonnull", since = "1.25.0")] - #[rustc_const_unstable(feature = "const_nonnull_new", issue = "93235")] + #[rustc_const_stable(feature = "const_nonnull_new", since = "CURRENT_RUSTC_VERSION")] #[inline] pub const fn new(ptr: *mut T) -> Option { if !ptr.is_null() { diff --git a/library/core/src/ptr/unique.rs b/library/core/src/ptr/unique.rs index ebdc918a729c7..4810ebe01f9bb 100644 --- a/library/core/src/ptr/unique.rs +++ b/library/core/src/ptr/unique.rs @@ -92,8 +92,6 @@ impl Unique { /// Creates a new `Unique` if `ptr` is non-null. #[inline] - // rustc_const_unstable attribute can be removed when `const_nonnull_new` is stable - #[rustc_const_unstable(feature = "ptr_internals", issue = "none")] pub const fn new(ptr: *mut T) -> Option { if let Some(pointer) = NonNull::new(ptr) { Some(Unique { pointer, _marker: PhantomData }) diff --git a/library/core/src/task/wake.rs b/library/core/src/task/wake.rs index 6762ed54e5c9b..bfffcc24a46a2 100644 --- a/library/core/src/task/wake.rs +++ b/library/core/src/task/wake.rs @@ -61,7 +61,6 @@ impl RawWaker { } #[stable(feature = "noop_waker", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_stable(feature = "noop_waker", since = "CURRENT_RUSTC_VERSION")] const NOOP: RawWaker = { const VTABLE: RawWakerVTable = RawWakerVTable::new( // Cloning just returns a new no-op raw waker diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs index a4a794691fe38..89b65eefd027e 100644 --- a/library/core/tests/lib.rs +++ b/library/core/tests/lib.rs @@ -15,7 +15,6 @@ #![feature(clone_to_uninit)] #![feature(const_black_box)] #![feature(const_eval_select)] -#![feature(const_nonnull_new)] #![feature(const_swap)] #![feature(const_trait_impl)] #![feature(core_intrinsics)] diff --git a/src/tools/run-make-support/src/command.rs b/src/tools/run-make-support/src/command.rs index 9e09527d6d08d..e73413085fade 100644 --- a/src/tools/run-make-support/src/command.rs +++ b/src/tools/run-make-support/src/command.rs @@ -329,7 +329,7 @@ impl CompletedProcess { /// Checks that `stderr` does not contain the regex pattern `unexpected`. #[track_caller] pub fn assert_stderr_not_contains_regex>(&self, unexpected: S) -> &Self { - assert_not_contains_regex(&self.stdout_utf8(), unexpected); + assert_not_contains_regex(&self.stderr_utf8(), unexpected); self } diff --git a/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-disabled.stderr b/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-disabled.stderr new file mode 100644 index 0000000000000..596f7c510be52 --- /dev/null +++ b/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-disabled.stderr @@ -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 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(x: &T) { + | ^^^^^^ + | + = note: see issue #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(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 `::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`. diff --git a/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-enabled.stderr b/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-enabled.stderr new file mode 100644 index 0000000000000..7235278d1bd78 --- /dev/null +++ b/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-enabled.stderr @@ -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(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 `::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`. diff --git a/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-disabled.stderr b/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-disabled.stderr new file mode 100644 index 0000000000000..eacdaf5e36909 --- /dev/null +++ b/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-disabled.stderr @@ -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 for more information + +error[E0658]: const trait impls are experimental + --> const-super-trait.rs:9:17 + | +9 | const fn foo(x: &T) { + | ^^^^^^ + | + = note: see issue #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(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 `::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`. diff --git a/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-enabled.stderr b/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-enabled.stderr new file mode 100644 index 0000000000000..9ddec6e422c06 --- /dev/null +++ b/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-enabled.stderr @@ -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(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 `::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`. diff --git a/tests/run-make/const-trait-stable-toolchain/const-super-trait.rs b/tests/run-make/const-trait-stable-toolchain/const-super-trait.rs new file mode 100644 index 0000000000000..b2ee96d79f704 --- /dev/null +++ b/tests/run-make/const-trait-stable-toolchain/const-super-trait.rs @@ -0,0 +1,13 @@ +#![cfg_attr(feature_enabled, feature(const_trait_impl))] + +trait Foo { + fn a(&self); +} + +trait Bar: ~const Foo {} + +const fn foo(x: &T) { + x.a(); +} + +fn main() {} diff --git a/tests/run-make/const-trait-stable-toolchain/rmake.rs b/tests/run-make/const-trait-stable-toolchain/rmake.rs new file mode 100644 index 0000000000000..241de11ed59ca --- /dev/null +++ b/tests/run-make/const-trait-stable-toolchain/rmake.rs @@ -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(); +} diff --git a/tests/ui/check-cfg/target_feature.stderr b/tests/ui/check-cfg/target_feature.stderr index 2674a97a551e4..3df1545cd4aa0 100644 --- a/tests/ui/check-cfg/target_feature.stderr +++ b/tests/ui/check-cfg/target_feature.stderr @@ -153,6 +153,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `popcnt` `power10-vector` `power8-altivec` +`power8-crypto` `power8-vector` `power9-altivec` `power9-vector` diff --git a/tests/ui/consts/const-try.stderr b/tests/ui/consts/const-try.stderr index abb03a74c82a4..4209ca1d52665 100644 --- a/tests/ui/consts/const-try.stderr +++ b/tests/ui/consts/const-try.stderr @@ -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 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 diff --git a/tests/ui/consts/fn_trait_refs.stderr b/tests/ui/consts/fn_trait_refs.stderr index bb7ff76b1255c..e0dbecff8e587 100644 --- a/tests/ui/consts/fn_trait_refs.stderr +++ b/tests/ui/consts/fn_trait_refs.stderr @@ -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 diff --git a/tests/ui/consts/rustc-impl-const-stability.stderr b/tests/ui/consts/rustc-impl-const-stability.stderr index 4a58b5c86034e..19c6bb5907f82 100644 --- a/tests/ui/consts/rustc-impl-const-stability.stderr +++ b/tests/ui/consts/rustc-impl-const-stability.stderr @@ -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 diff --git a/tests/ui/consts/unstable-const-fn-in-libcore.stderr b/tests/ui/consts/unstable-const-fn-in-libcore.stderr index f40c1871e90b9..32693edbfcbda 100644 --- a/tests/ui/consts/unstable-const-fn-in-libcore.stderr +++ b/tests/ui/consts/unstable-const-fn-in-libcore.stderr @@ -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 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 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 diff --git a/tests/ui/impl-trait/normalize-tait-in-const.stderr b/tests/ui/impl-trait/normalize-tait-in-const.stderr index 1dd84f10ad862..0f79cefeaecb7 100644 --- a/tests/ui/impl-trait/normalize-tait-in-const.stderr +++ b/tests/ui/impl-trait/normalize-tait-in-const.stderr @@ -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 ~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 ~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 diff --git a/tests/ui/never_type/never-in-range-pat.rs b/tests/ui/never_type/never-in-range-pat.rs new file mode 100644 index 0000000000000..ae2d76c172ea0 --- /dev/null +++ b/tests/ui/never_type/never-in-range-pat.rs @@ -0,0 +1,16 @@ +// Regression test for . + +// Make sure we don't ICE when there's `!` in a range pattern. +// +// This shouldn't be allowed anyways, but we only deny it during MIR +// building, so make sure we handle it semi-gracefully during typeck. + +#![feature(never_type)] + +fn main() { + let x: !; + match 1 { + 0..x => {} + //~^ ERROR only `char` and numeric types are allowed in range patterns + } +} diff --git a/tests/ui/never_type/never-in-range-pat.stderr b/tests/ui/never_type/never-in-range-pat.stderr new file mode 100644 index 0000000000000..c78be5350e0f0 --- /dev/null +++ b/tests/ui/never_type/never-in-range-pat.stderr @@ -0,0 +1,11 @@ +error[E0029]: only `char` and numeric types are allowed in range patterns + --> $DIR/never-in-range-pat.rs:13:12 + | +LL | 0..x => {} + | - ^ this is of type `!` but it should be `char` or numeric + | | + | this is of type `{integer}` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0029`. diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/invalid-dlltool.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/invalid-dlltool.rs index bcf6dda7a44dc..057242246f0ed 100644 --- a/tests/ui/rfcs/rfc-2627-raw-dylib/invalid-dlltool.rs +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/invalid-dlltool.rs @@ -1,7 +1,7 @@ // Tests that failing to run dlltool will raise an error. //@ needs-dlltool -//@ compile-flags: --crate-type lib --emit link -Cdlltool=does_not_exit.exe +//@ compile-flags: --crate-type lib --emit link -Cdlltool=does_not_exist.exe #[link(name = "foo", kind = "raw-dylib")] extern "C" { fn f(x: i32); diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/invalid-dlltool.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/invalid-dlltool.stderr index 9dbeee49f5345..4bbad9b30a79a 100644 --- a/tests/ui/rfcs/rfc-2627-raw-dylib/invalid-dlltool.stderr +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/invalid-dlltool.stderr @@ -1,4 +1,4 @@ -error: Error calling dlltool 'does_not_exit.exe': program not found +error: Error calling dlltool 'does_not_exist.exe': program not found error: aborting due to 1 previous error diff --git a/tests/ui/specialization/const_trait_impl.stderr b/tests/ui/specialization/const_trait_impl.stderr index 607fc06823e42..3e1260ff09c92 100644 --- a/tests/ui/specialization/const_trait_impl.stderr +++ b/tests/ui/specialization/const_trait_impl.stderr @@ -2,42 +2,57 @@ error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/const_trait_impl.rs:34:9 | LL | impl 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 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 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 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 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 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 diff --git a/tests/ui/traits/const-traits/call-const-trait-method-pass.stderr b/tests/ui/traits/const-traits/call-const-trait-method-pass.stderr index 1e48a0331cca2..ef494bde98ce3 100644 --- a/tests/ui/traits/const-traits/call-const-trait-method-pass.stderr +++ b/tests/ui/traits/const-traits/call-const-trait-method-pass.stderr @@ -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 diff --git a/tests/ui/traits/const-traits/call-generic-in-impl.stderr b/tests/ui/traits/const-traits/call-generic-in-impl.stderr index 52ee04425b2c7..58d0997f5a341 100644 --- a/tests/ui/traits/const-traits/call-generic-in-impl.stderr +++ b/tests/ui/traits/const-traits/call-generic-in-impl.stderr @@ -2,14 +2,19 @@ error: `~const` can only be applied to `#[const_trait]` traits --> $DIR/call-generic-in-impl.rs:10:9 | LL | impl 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 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 `::eq` in constant functions diff --git a/tests/ui/traits/const-traits/call-generic-method-chain.stderr b/tests/ui/traits/const-traits/call-generic-method-chain.stderr index 21fb19daad4aa..d7a2a18649400 100644 --- a/tests/ui/traits/const-traits/call-generic-method-chain.stderr +++ b/tests/ui/traits/const-traits/call-generic-method-chain.stderr @@ -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: &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: &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: &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: &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 diff --git a/tests/ui/traits/const-traits/call-generic-method-dup-bound.stderr b/tests/ui/traits/const-traits/call-generic-method-dup-bound.stderr index 845949a38bf5a..90465d0a5b2db 100644 --- a/tests/ui/traits/const-traits/call-generic-method-dup-bound.stderr +++ b/tests/ui/traits/const-traits/call-generic-method-dup-bound.stderr @@ -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: &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: &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: &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: &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 diff --git a/tests/ui/traits/const-traits/call-generic-method-pass.stderr b/tests/ui/traits/const-traits/call-generic-method-pass.stderr index 0c0037e36b86d..a7626a4e99d26 100644 --- a/tests/ui/traits/const-traits/call-generic-method-pass.stderr +++ b/tests/ui/traits/const-traits/call-generic-method-pass.stderr @@ -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: &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: &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 diff --git a/tests/ui/traits/const-traits/const-bounds-non-const-trait.stderr b/tests/ui/traits/const-traits/const-bounds-non-const-trait.stderr index 2436c97ccf2ca..f97d3a9181e06 100644 --- a/tests/ui/traits/const-traits/const-bounds-non-const-trait.stderr +++ b/tests/ui/traits/const-traits/const-bounds-non-const-trait.stderr @@ -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() {} - | ^^^^^^ + | ^^^^^^ 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() {} - | ^^^^^^ + | ^^^^^^ 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() {} - | ^^^^^ + | ^^^^^ 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 diff --git a/tests/ui/traits/const-traits/const-closure-parse-not-item.stderr b/tests/ui/traits/const-traits/const-closure-parse-not-item.stderr index 0970cd5225fba..57afa2257b7d4 100644 --- a/tests/ui/traits/const-traits/const-closure-parse-not-item.stderr +++ b/tests/ui/traits/const-traits/const-closure-parse-not-item.stderr @@ -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 diff --git a/tests/ui/traits/const-traits/const-closure-trait-method-fail.stderr b/tests/ui/traits/const-traits/const-closure-trait-method-fail.stderr index a76dc3e82af71..2a97846ccb448 100644 --- a/tests/ui/traits/const-traits/const-closure-trait-method-fail.stderr +++ b/tests/ui/traits/const-traits/const-closure-trait-method-fail.stderr @@ -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 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 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 diff --git a/tests/ui/traits/const-traits/const-closure-trait-method.stderr b/tests/ui/traits/const-traits/const-closure-trait-method.stderr index d37ff3d727cea..9c63b7e63a65d 100644 --- a/tests/ui/traits/const-traits/const-closure-trait-method.stderr +++ b/tests/ui/traits/const-traits/const-closure-trait-method.stderr @@ -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 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 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 diff --git a/tests/ui/traits/const-traits/const-closures.stderr b/tests/ui/traits/const-traits/const-closures.stderr index 8ceaae16d8e70..92f3ba2082072 100644 --- a/tests/ui/traits/const-traits/const-closures.stderr +++ b/tests/ui/traits/const-traits/const-closures.stderr @@ -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 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 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 diff --git a/tests/ui/traits/const-traits/const-impl-requires-const-trait.stderr b/tests/ui/traits/const-traits/const-impl-requires-const-trait.stderr index bcaae38194959..c728eda069ecb 100644 --- a/tests/ui/traits/const-traits/const-impl-requires-const-trait.stderr +++ b/tests/ui/traits/const-traits/const-impl-requires-const-trait.stderr @@ -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 diff --git a/tests/ui/traits/const-traits/const_derives/derive-const-gate.stderr b/tests/ui/traits/const-traits/const_derives/derive-const-gate.stderr index 95f6f32f21d3c..fae871a4c85ac 100644 --- a/tests/ui/traits/const-traits/const_derives/derive-const-gate.stderr +++ b/tests/ui/traits/const-traits/const_derives/derive-const-gate.stderr @@ -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 diff --git a/tests/ui/traits/const-traits/const_derives/derive-const-non-const-type.stderr b/tests/ui/traits/const-traits/const_derives/derive-const-non-const-type.stderr index 9492000a5631e..8a6401afcf19f 100644 --- a/tests/ui/traits/const-traits/const_derives/derive-const-non-const-type.stderr +++ b/tests/ui/traits/const-traits/const_derives/derive-const-non-const-type.stderr @@ -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 diff --git a/tests/ui/traits/const-traits/const_derives/derive-const-use.stderr b/tests/ui/traits/const-traits/const_derives/derive-const-use.stderr index 6f4fc90f6363f..3b06f4d801a41 100644 --- a/tests/ui/traits/const-traits/const_derives/derive-const-use.stderr +++ b/tests/ui/traits/const-traits/const_derives/derive-const-use.stderr @@ -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 diff --git a/tests/ui/traits/const-traits/const_derives/derive-const-with-params.stderr b/tests/ui/traits/const-traits/const_derives/derive-const-with-params.stderr index 21cf64f89ea84..6b1405712ef7d 100644 --- a/tests/ui/traits/const-traits/const_derives/derive-const-with-params.stderr +++ b/tests/ui/traits/const-traits/const_derives/derive-const-with-params.stderr @@ -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 diff --git a/tests/ui/traits/const-traits/effects/ice-112822-expected-type-for-param.stderr b/tests/ui/traits/const-traits/effects/ice-112822-expected-type-for-param.stderr index 879d966b1f97b..280f8807f5fda 100644 --- a/tests/ui/traits/const-traits/effects/ice-112822-expected-type-for-param.stderr +++ b/tests/ui/traits/const-traits/effects/ice-112822-expected-type-for-param.stderr @@ -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 diff --git a/tests/ui/traits/const-traits/effects/spec-effectvar-ice.stderr b/tests/ui/traits/const-traits/effects/spec-effectvar-ice.stderr index 5659102c5e5c4..474d96698d56b 100644 --- a/tests/ui/traits/const-traits/effects/spec-effectvar-ice.stderr +++ b/tests/ui/traits/const-traits/effects/spec-effectvar-ice.stderr @@ -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 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 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 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 diff --git a/tests/ui/traits/const-traits/ice-119717-constant-lifetime.stderr b/tests/ui/traits/const-traits/ice-119717-constant-lifetime.stderr index 9e22422ad3b94..5af263de28c48 100644 --- a/tests/ui/traits/const-traits/ice-119717-constant-lifetime.stderr +++ b/tests/ui/traits/const-traits/ice-119717-constant-lifetime.stderr @@ -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 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 diff --git a/tests/ui/traits/const-traits/ice-123664-unexpected-bound-var.stderr b/tests/ui/traits/const-traits/ice-123664-unexpected-bound-var.stderr index 1178c90fce541..821b257af8807 100644 --- a/tests/ui/traits/const-traits/ice-123664-unexpected-bound-var.stderr +++ b/tests/ui/traits/const-traits/ice-123664-unexpected-bound-var.stderr @@ -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() {} - | ^^^^^^ + | ^^^^^^ 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() {} - | ^^^^^^ + | ^^^^^^ 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 diff --git a/tests/ui/traits/const-traits/ice-126148-failed-to-normalize.stderr b/tests/ui/traits/const-traits/ice-126148-failed-to-normalize.stderr index 9bd493e5fdbbf..41f99c2d375e6 100644 --- a/tests/ui/traits/const-traits/ice-126148-failed-to-normalize.stderr +++ b/tests/ui/traits/const-traits/ice-126148-failed-to-normalize.stderr @@ -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 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 diff --git a/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.stderr b/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.stderr index 837effb7ca4cf..4ddb1e8c5a9f9 100644 --- a/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.stderr +++ b/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.stderr @@ -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 const Convert for A where B: ~const From { - | ^^^^^^ + | ^^^^^^ 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 const Convert for A where B: ~const From { - | ^^^^^^ + | ^^^^^^ 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 `>::from` in constant functions diff --git a/tests/ui/traits/const-traits/super-traits-fail-2.nn.stderr b/tests/ui/traits/const-traits/super-traits-fail-2.nn.stderr index e7f54b4c5bdda..51b88cf87022a 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-2.nn.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-2.nn.stderr @@ -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 `::a` in constant functions --> $DIR/super-traits-fail-2.rs:20:7 diff --git a/tests/ui/traits/const-traits/super-traits-fail-2.ny.stderr b/tests/ui/traits/const-traits/super-traits-fail-2.ny.stderr index a09fe81f71696..38fb6f05412f4 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-2.ny.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-2.ny.stderr @@ -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 `::a` in constant functions --> $DIR/super-traits-fail-2.rs:20:7 diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.nnn.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.nnn.stderr new file mode 100644 index 0000000000000..fd802fde5bd5a --- /dev/null +++ b/tests/ui/traits/const-traits/super-traits-fail-3.nnn.stderr @@ -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 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(x: &T) { + | ^^^^^^ + | + = note: see issue #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(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(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 `::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`. diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.nny.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.nny.stderr new file mode 100644 index 0000000000000..fd802fde5bd5a --- /dev/null +++ b/tests/ui/traits/const-traits/super-traits-fail-3.nny.stderr @@ -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 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(x: &T) { + | ^^^^^^ + | + = note: see issue #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(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(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 `::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`. diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.ny.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.ny.stderr deleted file mode 100644 index a880c2a22061f..0000000000000 --- a/tests/ui/traits/const-traits/super-traits-fail-3.ny.stderr +++ /dev/null @@ -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 `::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`. diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.nyn.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.nyn.stderr new file mode 100644 index 0000000000000..8abda1c8f8afe --- /dev/null +++ b/tests/ui/traits/const-traits/super-traits-fail-3.nyn.stderr @@ -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 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(x: &T) { + | ^^^^^^ + | + = note: see issue #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 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 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 `::a` in constant functions + --> $DIR/super-traits-fail-3.rs:36:5 + | +LL | x.a(); + | ^^^^^ + | + = note: see issue #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`. diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.nyy.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.nyy.stderr new file mode 100644 index 0000000000000..8abda1c8f8afe --- /dev/null +++ b/tests/ui/traits/const-traits/super-traits-fail-3.nyy.stderr @@ -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 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(x: &T) { + | ^^^^^^ + | + = note: see issue #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 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 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 `::a` in constant functions + --> $DIR/super-traits-fail-3.rs:36:5 + | +LL | x.a(); + | ^^^^^ + | + = note: see issue #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`. diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.rs b/tests/ui/traits/const-traits/super-traits-fail-3.rs index bd95ae8d96a9d..aa27554e7f895 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.rs +++ b/tests/ui/traits/const-traits/super-traits-fail-3.rs @@ -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(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 `::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 `::a` in constant functions + //[nyy,nyn]~^^^ ERROR: cannot call conditionally-const method `::a` in constant functions } fn main() {} diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.nn.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.ynn.stderr similarity index 51% rename from tests/ui/traits/const-traits/super-traits-fail-3.nn.stderr rename to tests/ui/traits/const-traits/super-traits-fail-3.ynn.stderr index 599b8c826f7ae..16424696eeb51 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.nn.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.ynn.stderr @@ -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(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(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 `::a` in constant functions - --> $DIR/super-traits-fail-3.rs:24:7 + --> $DIR/super-traits-fail-3.rs:36:7 | LL | x.a(); | ^^^ diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.yny.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.yny.stderr new file mode 100644 index 0000000000000..c81544c4bf5b7 --- /dev/null +++ b/tests/ui/traits/const-traits/super-traits-fail-3.yny.stderr @@ -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 `::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`. diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.yn.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.yyn.stderr similarity index 55% rename from tests/ui/traits/const-traits/super-traits-fail-3.yn.stderr rename to tests/ui/traits/const-traits/super-traits-fail-3.yyn.stderr index ecee348222d1f..3270611dace2e 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.yn.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.yyn.stderr @@ -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(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(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(); | ^ diff --git a/tests/ui/traits/const-traits/trait-default-body-stability.stderr b/tests/ui/traits/const-traits/trait-default-body-stability.stderr index b471cb81c3b8d..77b81211e8152 100644 --- a/tests/ui/traits/const-traits/trait-default-body-stability.stderr +++ b/tests/ui/traits/const-traits/trait-default-body-stability.stderr @@ -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 diff --git a/triagebot.toml b/triagebot.toml index 665108cccd38a..6eb4cb50d0deb 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -1014,7 +1014,6 @@ compiler = [ "@Noratrieb", "@oli-obk", "@petrochenkov", - "@pnkfelix", "@SparrowLii", "@wesleywiser", ] @@ -1107,7 +1106,6 @@ types = [ ] borrowck = [ "@davidtwco", - "@pnkfelix", "@matthewjasper" ] ast_lowering = [