From a2c3913007fa77728464b9d37d827e013f127f6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 23 Jul 2025 18:46:03 +0000 Subject: [PATCH] review comments --- .../rustc_const_eval/src/check_consts/ops.rs | 31 ++++++----------- .../const-super-trait-nightly-disabled.stderr | 3 +- .../const-super-trait-nightly-enabled.stderr | 3 +- .../const-super-trait-stable-disabled.stderr | 3 +- .../const-super-trait-stable-enabled.stderr | 3 +- tests/ui/asm/non-const.stderr | 3 +- tests/ui/borrowck/issue-64453.stderr | 5 ++- .../ui/const-generics/nested-type.full.stderr | 15 +++------ .../ui/const-generics/nested-type.min.stderr | 15 +++------ tests/ui/consts/const-call.stderr | 3 +- tests/ui/consts/const-eval/format.stderr | 3 +- .../const-extern-fn-call-extern-fn.stderr | 8 ++--- .../consts/const-fn-not-safe-for-const.stderr | 3 +- .../ui/consts/control-flow/issue-46843.stderr | 5 ++- tests/ui/consts/issue-16538.stderr | 5 ++- tests/ui/consts/issue-32829-2.stderr | 12 ++----- tests/ui/consts/issue-43105.stderr | 5 ++- .../min_const_fn/bad_const_fn_body_ice.stderr | 3 +- tests/ui/consts/mir_check_nonconst.stderr | 5 ++- tests/ui/error-codes/E0010-teach.stderr | 5 ++- tests/ui/error-codes/E0010.stderr | 5 ++- tests/ui/error-codes/E0015.stderr | 5 ++- tests/ui/explicit-tail-calls/constck.stderr | 8 ++--- tests/ui/resolve/issue-39559-2.stderr | 6 ++-- ...lobal-variable-promotion-error-7364.stderr | 5 ++- .../ui/static/static-mut-not-constant.stderr | 5 ++- .../static-vec-repeat-not-constant.stderr | 5 ++- .../statics/check-values-constraints.stderr | 33 +++++++------------ .../const-check-fns-in-const-impl.stderr | 5 ++- .../const_derives/derive-const-gate.stderr | 4 ++- .../derive-const-non-const-type.stderr | 4 ++- .../const-traits/cross-crate.stock.stderr | 4 +-- .../const-traits/cross-crate.stocknc.stderr | 9 ++--- ...nline-incorrect-early-bound-in-ctfe.stderr | 3 +- .../ui/traits/const-traits/issue-79450.stderr | 3 +- .../ui/traits/const-traits/issue-88155.stderr | 3 +- .../const-traits/staged-api-user-crate.stderr | 3 +- .../const-traits/std-impl-gate.stock.stderr | 3 +- .../super-traits-fail-2.nn.stderr | 3 +- .../super-traits-fail-2.ny.stderr | 3 +- .../super-traits-fail-3.nnn.stderr | 4 +-- .../super-traits-fail-3.nny.stderr | 4 +-- .../super-traits-fail-3.nyn.stderr | 4 +-- .../super-traits-fail-3.nyy.stderr | 4 +-- .../super-traits-fail-3.ynn.stderr | 4 +-- .../super-traits-fail-3.yny.stderr | 4 +-- .../typeck_type_placeholder_item.stderr | 15 ++++----- 47 files changed, 104 insertions(+), 192 deletions(-) diff --git a/compiler/rustc_const_eval/src/check_consts/ops.rs b/compiler/rustc_const_eval/src/check_consts/ops.rs index c958a91f754b..ecb58059600d 100644 --- a/compiler/rustc_const_eval/src/check_consts/ops.rs +++ b/compiler/rustc_const_eval/src/check_consts/ops.rs @@ -4,7 +4,6 @@ use hir::{ConstContext, LangItem}; use rustc_errors::codes::*; use rustc_errors::{Applicability, Diag, MultiSpan}; use rustc_hir as hir; -use rustc_hir::def::DefKind; use rustc_hir::def_id::DefId; use rustc_infer::infer::TyCtxtInferExt; use rustc_infer::traits::{ImplSource, Obligation, ObligationCause}; @@ -12,8 +11,8 @@ use rustc_middle::mir::CallSource; use rustc_middle::span_bug; use rustc_middle::ty::print::{PrintTraitRefExt as _, with_no_trimmed_paths}; use rustc_middle::ty::{ - self, Closure, FnDef, FnPtr, GenericArgKind, GenericArgsRef, Param, TraitRef, Ty, - suggest_constraining_type_param, + self, AssocItemContainer, Closure, FnDef, FnPtr, GenericArgKind, GenericArgsRef, Param, + TraitRef, Ty, suggest_constraining_type_param, }; use rustc_session::parse::add_feature_diagnostics; use rustc_span::{BytePos, Pos, Span, Symbol, sym}; @@ -212,7 +211,6 @@ fn build_error_for_const_call<'tcx>( debug!(?call_kind); - let mut note = true; let mut err = match call_kind { CallKind::Normal { desugaring: Some((kind, self_ty)), .. } => { macro_rules! error { @@ -363,16 +361,9 @@ fn build_error_for_const_call<'tcx>( kind: ccx.const_kind(), non_or_conditionally, }); - let context_span = ccx.tcx.def_span(ccx.def_id()); - err.span_label(context_span, format!( - "calls in {}s are limited to constant functions, tuple structs and tuple variants", - ccx.const_kind(), - )); - note = false; - let def_kind = ccx.tcx.def_kind(callee); - if let DefKind::AssocTy | DefKind::AssocConst | DefKind::AssocFn = def_kind { - let parent = ccx.tcx.parent(callee); - if let DefKind::Trait = ccx.tcx.def_kind(parent) + if let Some(item) = ccx.tcx.opt_associated_item(callee) { + if let AssocItemContainer::Trait = item.container + && let parent = item.container_id(ccx.tcx) && !ccx.tcx.is_const_trait(parent) { let assoc_span = ccx.tcx.def_span(callee); @@ -407,7 +398,7 @@ fn build_error_for_const_call<'tcx>( trait_span.shrink_to_lo(), format!("consider making trait `{trait_name}` const"), format!("#[const_trait]\n{indentation}"), - Applicability::MachineApplicable, + Applicability::MaybeIncorrect, ); } else if !ccx.tcx.sess.is_nightly_build() { err.help("const traits are not yet supported on stable Rust"); @@ -424,12 +415,10 @@ fn build_error_for_const_call<'tcx>( } }; - if note { - err.note(format!( - "calls in {}s are limited to constant functions, tuple structs and tuple variants", - ccx.const_kind(), - )); - } + err.note(format!( + "calls in {}s are limited to constant functions, tuple structs and tuple variants", + ccx.const_kind(), + )); err } 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 index 47f6817b9b64..646688604674 100644 --- 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 @@ -55,8 +55,6 @@ LL | #[const_trait] trait Bar: [const] Foo {} error[E0015]: cannot call non-const method `::a` in constant functions --> const-super-trait.rs:10:7 | -LL | const fn foo(x: &T) { - | ---------------------------------- calls in constant functions are limited to constant functions, tuple structs and tuple variants LL | x.a(); | ^^^ | @@ -68,6 +66,7 @@ LL | trait Foo { LL | fn a(&self); | ------------ this method is not const = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable `#[const_trait]` + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants help: consider making trait `Foo` const | LL + #[const_trait] 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 index 49e2f98c371f..d0e7edf42cdd 100644 --- 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 @@ -35,8 +35,6 @@ LL | #[const_trait] trait Bar: [const] Foo {} error[E0015]: cannot call non-const method `::a` in constant functions --> const-super-trait.rs:10:7 | -LL | const fn foo(x: &T) { - | ---------------------------------- calls in constant functions are limited to constant functions, tuple structs and tuple variants LL | x.a(); | ^^^ | @@ -47,6 +45,7 @@ LL | trait Foo { | ^^^^^^^^^ this trait is not const LL | fn a(&self); | ------------ this method is not const + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants help: consider making trait `Foo` const | LL + #[const_trait] 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 index 62fd9a38b759..e09539684953 100644 --- 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 @@ -53,8 +53,6 @@ note: `Bar` can't be used with `[const]` because it isn't `const` error[E0015]: cannot call non-const method `::a` in constant functions --> const-super-trait.rs:10:7 | -9 | const fn foo(x: &T) { - | ---------------------------------- calls in constant functions are limited to constant functions, tuple structs and tuple variants 10 | x.a(); | ^^^ | @@ -66,6 +64,7 @@ note: method `a` is not const because trait `Foo` is not const 4 | fn a(&self); | ------------ this method is not const = help: const traits are not yet supported on stable Rust + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error: aborting due to 6 previous errors 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 index fc1adbe441ce..9da10eb81d83 100644 --- 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 @@ -43,8 +43,6 @@ note: `Bar` can't be used with `[const]` because it isn't `const` error[E0015]: cannot call non-const method `::a` in constant functions --> const-super-trait.rs:10:7 | -9 | const fn foo(x: &T) { - | ---------------------------------- calls in constant functions are limited to constant functions, tuple structs and tuple variants 10 | x.a(); | ^^^ | @@ -56,6 +54,7 @@ note: method `a` is not const because trait `Foo` is not const 4 | fn a(&self); | ------------ this method is not const = help: const traits are not yet supported on stable Rust + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error: aborting due to 5 previous errors diff --git a/tests/ui/asm/non-const.stderr b/tests/ui/asm/non-const.stderr index da881a12f120..d7a901ba20ee 100644 --- a/tests/ui/asm/non-const.stderr +++ b/tests/ui/asm/non-const.stderr @@ -2,13 +2,14 @@ error[E0015]: cannot call non-const function `non_const_fn` in constants --> $DIR/non-const.rs:10:31 | LL | global_asm!("/* {} */", const non_const_fn(0)); - | ^^^^^^^^^^^^^^^ calls in constants are limited to constant functions, tuple structs and tuple variants + | ^^^^^^^^^^^^^^^ | note: function `non_const_fn` is not const --> $DIR/non-const.rs:8:1 | LL | fn non_const_fn(x: i32) -> i32 { x } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: calls in constants are limited to constant functions, tuple structs and tuple variants error: aborting due to 1 previous error diff --git a/tests/ui/borrowck/issue-64453.stderr b/tests/ui/borrowck/issue-64453.stderr index 47d908276555..29a7363705cd 100644 --- a/tests/ui/borrowck/issue-64453.stderr +++ b/tests/ui/borrowck/issue-64453.stderr @@ -2,12 +2,11 @@ error[E0015]: cannot call non-const function `format` in statics --> $DIR/issue-64453.rs:4:31 | LL | static settings_dir: String = format!(""); - | --------------------------- ^^^^^^^^^^^ - | | - | calls in statics are limited to constant functions, tuple structs and tuple variants + | ^^^^^^^^^^^ | note: function `format` is not const --> $SRC_DIR/alloc/src/fmt.rs:LL:COL + = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/const-generics/nested-type.full.stderr b/tests/ui/const-generics/nested-type.full.stderr index 587de095452d..e5a1f230380d 100644 --- a/tests/ui/const-generics/nested-type.full.stderr +++ b/tests/ui/const-generics/nested-type.full.stderr @@ -1,17 +1,10 @@ error[E0015]: cannot call non-const associated function `Foo::{constant#0}::Foo::<17>::value` in constants --> $DIR/nested-type.rs:15:5 | -LL | struct Foo; -LL | | -LL | | impl Foo { -... | -LL | | Foo::<17>::value() - | | ^^^^^^^^^^^^^^^^^^ -LL | | -LL | | }]>; - | |_- calls in constants are limited to constant functions, tuple structs and tuple variants +LL | Foo::<17>::value() + | ^^^^^^^^^^^^^^^^^^ + | + = note: calls in constants are limited to constant functions, tuple structs and tuple variants error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/nested-type.min.stderr b/tests/ui/const-generics/nested-type.min.stderr index e7d21f8a9894..8282acd4ea7b 100644 --- a/tests/ui/const-generics/nested-type.min.stderr +++ b/tests/ui/const-generics/nested-type.min.stderr @@ -1,17 +1,10 @@ error[E0015]: cannot call non-const associated function `Foo::{constant#0}::Foo::<17>::value` in constants --> $DIR/nested-type.rs:15:5 | -LL | struct Foo; -LL | | -LL | | impl Foo { -... | -LL | | Foo::<17>::value() - | | ^^^^^^^^^^^^^^^^^^ -LL | | -LL | | }]>; - | |_- calls in constants are limited to constant functions, tuple structs and tuple variants +LL | Foo::<17>::value() + | ^^^^^^^^^^^^^^^^^^ + | + = note: calls in constants are limited to constant functions, tuple structs and tuple variants error: `[u8; { struct Foo; diff --git a/tests/ui/consts/const-call.stderr b/tests/ui/consts/const-call.stderr index db375f80b6c6..cc80f73d0bb6 100644 --- a/tests/ui/consts/const-call.stderr +++ b/tests/ui/consts/const-call.stderr @@ -2,13 +2,14 @@ error[E0015]: cannot call non-const function `f` in constants --> $DIR/const-call.rs:6:17 | LL | let _ = [0; f(2)]; - | ^^^^ calls in constants are limited to constant functions, tuple structs and tuple variants + | ^^^^ | note: function `f` is not const --> $DIR/const-call.rs:1:1 | LL | fn f(x: usize) -> usize { | ^^^^^^^^^^^^^^^^^^^^^^^ + = note: calls in constants are limited to constant functions, tuple structs and tuple variants error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/format.stderr b/tests/ui/consts/const-eval/format.stderr index 97b4436a058e..ea191eb5c098 100644 --- a/tests/ui/consts/const-eval/format.stderr +++ b/tests/ui/consts/const-eval/format.stderr @@ -18,13 +18,12 @@ LL | println!("{:?}", 0); error[E0015]: cannot call non-const function `_print` in constant functions --> $DIR/format.rs:7:5 | -LL | const fn print() { - | ---------------- calls in constant functions are limited to constant functions, tuple structs and tuple variants LL | println!("{:?}", 0); | ^^^^^^^^^^^^^^^^^^^ | note: function `_print` is not const --> $SRC_DIR/std/src/io/stdio.rs:LL:COL + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0015]: cannot call non-const formatting macro in constant functions diff --git a/tests/ui/consts/const-extern-fn/const-extern-fn-call-extern-fn.stderr b/tests/ui/consts/const-extern-fn/const-extern-fn-call-extern-fn.stderr index 8f07e038e199..ac0d344d8f48 100644 --- a/tests/ui/consts/const-extern-fn/const-extern-fn-call-extern-fn.stderr +++ b/tests/ui/consts/const-extern-fn/const-extern-fn-call-extern-fn.stderr @@ -1,9 +1,6 @@ error[E0015]: cannot call non-const function `regular_in_block` in constant functions --> $DIR/const-extern-fn-call-extern-fn.rs:7:9 | -LL | const extern "C" fn bar() { - | ------------------------- calls in constant functions are limited to constant functions, tuple structs and tuple variants -LL | unsafe { LL | regular_in_block(); | ^^^^^^^^^^^^^^^^^^ | @@ -12,13 +9,11 @@ note: function `regular_in_block` is not const | LL | fn regular_in_block(); | ^^^^^^^^^^^^^^^^^^^^^^ + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const function `regular` in constant functions --> $DIR/const-extern-fn-call-extern-fn.rs:16:9 | -LL | const extern "C" fn foo() { - | ------------------------- calls in constant functions are limited to constant functions, tuple structs and tuple variants -LL | unsafe { LL | regular(); | ^^^^^^^^^ | @@ -27,6 +22,7 @@ note: function `regular` is not const | LL | extern "C" fn regular() {} | ^^^^^^^^^^^^^^^^^^^^^^^ + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-fn-not-safe-for-const.stderr b/tests/ui/consts/const-fn-not-safe-for-const.stderr index 068c06601c8b..8fd27df5367e 100644 --- a/tests/ui/consts/const-fn-not-safe-for-const.stderr +++ b/tests/ui/consts/const-fn-not-safe-for-const.stderr @@ -1,8 +1,6 @@ error[E0015]: cannot call non-const function `random` in constant functions --> $DIR/const-fn-not-safe-for-const.rs:14:5 | -LL | const fn sub1() -> u32 { - | ---------------------- calls in constant functions are limited to constant functions, tuple structs and tuple variants LL | random() | ^^^^^^^^ | @@ -11,6 +9,7 @@ note: function `random` is not const | LL | fn random() -> u32 { | ^^^^^^^^^^^^^^^^^^ + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error: aborting due to 1 previous error diff --git a/tests/ui/consts/control-flow/issue-46843.stderr b/tests/ui/consts/control-flow/issue-46843.stderr index 310c860f59b4..46b2a6bf1fd3 100644 --- a/tests/ui/consts/control-flow/issue-46843.stderr +++ b/tests/ui/consts/control-flow/issue-46843.stderr @@ -2,15 +2,14 @@ error[E0015]: cannot call non-const function `non_const` in constants --> $DIR/issue-46843.rs:10:26 | LL | pub const Q: i32 = match non_const() { - | ---------------- ^^^^^^^^^^^ - | | - | calls in constants are limited to constant functions, tuple structs and tuple variants + | ^^^^^^^^^^^ | note: function `non_const` is not const --> $DIR/issue-46843.rs:6:1 | LL | fn non_const() -> Thing { | ^^^^^^^^^^^^^^^^^^^^^^^ + = note: calls in constants are limited to constant functions, tuple structs and tuple variants error: aborting due to 1 previous error diff --git a/tests/ui/consts/issue-16538.stderr b/tests/ui/consts/issue-16538.stderr index e78d95dcd186..fd97b4360a46 100644 --- a/tests/ui/consts/issue-16538.stderr +++ b/tests/ui/consts/issue-16538.stderr @@ -2,15 +2,14 @@ error[E0015]: cannot call non-const function `Y::foo` in statics --> $DIR/issue-16538.rs:11:23 | LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X); - | ----------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | calls in statics are limited to constant functions, tuple structs and tuple variants + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: function `foo` is not const --> $DIR/issue-16538.rs:6:5 | LL | pub fn foo(value: *const X) -> *const X { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block diff --git a/tests/ui/consts/issue-32829-2.stderr b/tests/ui/consts/issue-32829-2.stderr index 52398af41eee..b201454866ed 100644 --- a/tests/ui/consts/issue-32829-2.stderr +++ b/tests/ui/consts/issue-32829-2.stderr @@ -1,9 +1,6 @@ error[E0015]: cannot call non-const function `invalid` in constants --> $DIR/issue-32829-2.rs:10:9 | -LL | const bad_two : u32 = { - | ------------------- calls in constants are limited to constant functions, tuple structs and tuple variants -LL | { LL | invalid(); | ^^^^^^^^^ | @@ -12,13 +9,11 @@ note: function `invalid` is not const | LL | fn invalid() {} | ^^^^^^^^^^^^ + = note: calls in constants are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const function `invalid` in statics --> $DIR/issue-32829-2.rs:32:9 | -LL | static bad_five : u32 = { - | --------------------- calls in statics are limited to constant functions, tuple structs and tuple variants -LL | { LL | invalid(); | ^^^^^^^^^ | @@ -27,14 +22,12 @@ note: function `invalid` is not const | LL | fn invalid() {} | ^^^^^^^^^^^^ + = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` error[E0015]: cannot call non-const function `invalid` in statics --> $DIR/issue-32829-2.rs:54:9 | -LL | static mut bad_eight : u32 = { - | -------------------------- calls in statics are limited to constant functions, tuple structs and tuple variants -LL | { LL | invalid(); | ^^^^^^^^^ | @@ -43,6 +36,7 @@ note: function `invalid` is not const | LL | fn invalid() {} | ^^^^^^^^^^^^ + = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` error: aborting due to 3 previous errors diff --git a/tests/ui/consts/issue-43105.stderr b/tests/ui/consts/issue-43105.stderr index 442fbdd107fa..7ec0a2b73afc 100644 --- a/tests/ui/consts/issue-43105.stderr +++ b/tests/ui/consts/issue-43105.stderr @@ -2,15 +2,14 @@ error[E0015]: cannot call non-const function `xyz` in constants --> $DIR/issue-43105.rs:3:17 | LL | const NUM: u8 = xyz(); - | ------------- ^^^^^ - | | - | calls in constants are limited to constant functions, tuple structs and tuple variants + | ^^^^^ | note: function `xyz` is not const --> $DIR/issue-43105.rs:1:1 | LL | fn xyz() -> u8 { 42 } | ^^^^^^^^^^^^^^ + = note: calls in constants are limited to constant functions, tuple structs and tuple variants error: aborting due to 1 previous error diff --git a/tests/ui/consts/min_const_fn/bad_const_fn_body_ice.stderr b/tests/ui/consts/min_const_fn/bad_const_fn_body_ice.stderr index c65abc530bc2..8e52a7aa35e1 100644 --- a/tests/ui/consts/min_const_fn/bad_const_fn_body_ice.stderr +++ b/tests/ui/consts/min_const_fn/bad_const_fn_body_ice.stderr @@ -9,11 +9,10 @@ LL | vec![1, 2, 3] error[E0015]: cannot call non-const method `slice::::into_vec::` in constant functions --> $DIR/bad_const_fn_body_ice.rs:2:5 | -LL | const fn foo(a: i32) -> Vec { - | -------------------------------- calls in constant functions are limited to constant functions, tuple structs and tuple variants LL | vec![1, 2, 3] | ^^^^^^^^^^^^^ | + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors diff --git a/tests/ui/consts/mir_check_nonconst.stderr b/tests/ui/consts/mir_check_nonconst.stderr index ad2056a73707..bb0940ee789b 100644 --- a/tests/ui/consts/mir_check_nonconst.stderr +++ b/tests/ui/consts/mir_check_nonconst.stderr @@ -2,15 +2,14 @@ error[E0015]: cannot call non-const function `bar` in statics --> $DIR/mir_check_nonconst.rs:8:19 | LL | static foo: Foo = bar(); - | --------------- ^^^^^ - | | - | calls in statics are limited to constant functions, tuple structs and tuple variants + | ^^^^^ | note: function `bar` is not const --> $DIR/mir_check_nonconst.rs:4:1 | LL | fn bar() -> Foo { | ^^^^^^^^^^^^^^^ + = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` error: aborting due to 1 previous error diff --git a/tests/ui/error-codes/E0010-teach.stderr b/tests/ui/error-codes/E0010-teach.stderr index 237efbefcf6e..82bbe01aef79 100644 --- a/tests/ui/error-codes/E0010-teach.stderr +++ b/tests/ui/error-codes/E0010-teach.stderr @@ -11,10 +11,9 @@ error[E0015]: cannot call non-const method `slice::::into_vec:: $DIR/E0010-teach.rs:5:23 | LL | const CON: Vec = vec![1, 2, 3]; - | ------------------- ^^^^^^^^^^^^^ - | | - | calls in constants are limited to constant functions, tuple structs and tuple variants + | ^^^^^^^^^^^^^ | + = note: calls in constants are limited to constant functions, tuple structs and tuple variants = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors diff --git a/tests/ui/error-codes/E0010.stderr b/tests/ui/error-codes/E0010.stderr index 2bb87118d242..87b722b5f656 100644 --- a/tests/ui/error-codes/E0010.stderr +++ b/tests/ui/error-codes/E0010.stderr @@ -10,10 +10,9 @@ error[E0015]: cannot call non-const method `slice::::into_vec:: $DIR/E0010.rs:3:23 | LL | const CON: Vec = vec![1, 2, 3]; - | ------------------- ^^^^^^^^^^^^^ - | | - | calls in constants are limited to constant functions, tuple structs and tuple variants + | ^^^^^^^^^^^^^ | + = note: calls in constants are limited to constant functions, tuple structs and tuple variants = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors diff --git a/tests/ui/error-codes/E0015.stderr b/tests/ui/error-codes/E0015.stderr index 4331d7c34b3c..bc457aefaecb 100644 --- a/tests/ui/error-codes/E0015.stderr +++ b/tests/ui/error-codes/E0015.stderr @@ -2,15 +2,14 @@ error[E0015]: cannot call non-const function `create_some` in constants --> $DIR/E0015.rs:5:25 | LL | const FOO: Option = create_some(); - | --------------------- ^^^^^^^^^^^^^ - | | - | calls in constants are limited to constant functions, tuple structs and tuple variants + | ^^^^^^^^^^^^^ | note: function `create_some` is not const --> $DIR/E0015.rs:1:1 | LL | fn create_some() -> Option { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: calls in constants are limited to constant functions, tuple structs and tuple variants error: aborting due to 1 previous error diff --git a/tests/ui/explicit-tail-calls/constck.stderr b/tests/ui/explicit-tail-calls/constck.stderr index 84d7bc3a1bf1..2fc2fb7f9338 100644 --- a/tests/ui/explicit-tail-calls/constck.stderr +++ b/tests/ui/explicit-tail-calls/constck.stderr @@ -1,9 +1,6 @@ error[E0015]: cannot call non-const function `not_const` in constant functions --> $DIR/constck.rs:6:16 | -LL | const fn f() { - | ------------ calls in constant functions are limited to constant functions, tuple structs and tuple variants -LL | if false { LL | become not_const(); | ^^^^^^^^^^^ | @@ -12,13 +9,11 @@ note: function `not_const` is not const | LL | fn not_const() {} | ^^^^^^^^^^^^^^ + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const function `not_const` in constant functions --> $DIR/constck.rs:13:26 | -LL | const fn g((): ()) { - | ------------------ calls in constant functions are limited to constant functions, tuple structs and tuple variants -LL | if false { LL | become yes_const(not_const()); | ^^^^^^^^^^^ | @@ -27,6 +22,7 @@ note: function `not_const` is not const | LL | fn not_const() {} | ^^^^^^^^^^^^^^ + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error: aborting due to 2 previous errors diff --git a/tests/ui/resolve/issue-39559-2.stderr b/tests/ui/resolve/issue-39559-2.stderr index fbbcaa663ae0..4bfa1d1b1322 100644 --- a/tests/ui/resolve/issue-39559-2.stderr +++ b/tests/ui/resolve/issue-39559-2.stderr @@ -2,7 +2,7 @@ error[E0015]: cannot call non-const associated function `::dim` in --> $DIR/issue-39559-2.rs:14:24 | LL | let array: [usize; Dim3::dim()] - | ^^^^^^^^^^^ calls in constants are limited to constant functions, tuple structs and tuple variants + | ^^^^^^^^^^^ | note: associated function `dim` is not const because trait `Dim` is not const --> $DIR/issue-39559-2.rs:1:1 @@ -12,6 +12,7 @@ LL | trait Dim { LL | fn dim() -> usize; | ------------------ this associated function is not const = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable `#[const_trait]` + = note: calls in constants are limited to constant functions, tuple structs and tuple variants help: consider making trait `Dim` const | LL + #[const_trait] @@ -22,7 +23,7 @@ error[E0015]: cannot call non-const associated function `::dim` in --> $DIR/issue-39559-2.rs:16:15 | LL | = [0; Dim3::dim()]; - | ^^^^^^^^^^^ calls in constants are limited to constant functions, tuple structs and tuple variants + | ^^^^^^^^^^^ | note: associated function `dim` is not const because trait `Dim` is not const --> $DIR/issue-39559-2.rs:1:1 @@ -32,6 +33,7 @@ LL | trait Dim { LL | fn dim() -> usize; | ------------------ this associated function is not const = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable `#[const_trait]` + = note: calls in constants are limited to constant functions, tuple structs and tuple variants help: consider making trait `Dim` const | LL + #[const_trait] diff --git a/tests/ui/static/global-variable-promotion-error-7364.stderr b/tests/ui/static/global-variable-promotion-error-7364.stderr index bced8c152020..b9d75676bef8 100644 --- a/tests/ui/static/global-variable-promotion-error-7364.stderr +++ b/tests/ui/static/global-variable-promotion-error-7364.stderr @@ -15,10 +15,9 @@ error[E0015]: cannot call non-const associated function `Box::>:: --> $DIR/global-variable-promotion-error-7364.rs:5:37 | LL | static boxed: Box> = Box::new(RefCell::new(0)); - | --------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | calls in statics are limited to constant functions, tuple structs and tuple variants + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | + = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` error: aborting due to 2 previous errors diff --git a/tests/ui/static/static-mut-not-constant.stderr b/tests/ui/static/static-mut-not-constant.stderr index 7e64d36b26d1..f28ea0b1689a 100644 --- a/tests/ui/static/static-mut-not-constant.stderr +++ b/tests/ui/static/static-mut-not-constant.stderr @@ -2,10 +2,9 @@ error[E0015]: cannot call non-const associated function `Box::::new` in s --> $DIR/static-mut-not-constant.rs:1:28 | LL | static mut a: Box = Box::new(3); - | ------------------------ ^^^^^^^^^^^ - | | - | calls in statics are limited to constant functions, tuple structs and tuple variants + | ^^^^^^^^^^^ | + = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` error: aborting due to 1 previous error diff --git a/tests/ui/static/static-vec-repeat-not-constant.stderr b/tests/ui/static/static-vec-repeat-not-constant.stderr index 24f0986ccc49..fa4033f6a407 100644 --- a/tests/ui/static/static-vec-repeat-not-constant.stderr +++ b/tests/ui/static/static-vec-repeat-not-constant.stderr @@ -2,15 +2,14 @@ error[E0015]: cannot call non-const function `foo` in statics --> $DIR/static-vec-repeat-not-constant.rs:3:25 | LL | static a: [isize; 2] = [foo(); 2]; - | -------------------- ^^^^^ - | | - | calls in statics are limited to constant functions, tuple structs and tuple variants + | ^^^^^ | note: function `foo` is not const --> $DIR/static-vec-repeat-not-constant.rs:1:1 | LL | fn foo() -> isize { 23 } | ^^^^^^^^^^^^^^^^^ + = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` error: aborting due to 1 previous error diff --git a/tests/ui/statics/check-values-constraints.stderr b/tests/ui/statics/check-values-constraints.stderr index dfbb1f6e985c..c54f4830533a 100644 --- a/tests/ui/statics/check-values-constraints.stderr +++ b/tests/ui/statics/check-values-constraints.stderr @@ -23,19 +23,15 @@ error[E0015]: cannot call non-const method `slice::::into_vec::< --> $DIR/check-values-constraints.rs:81:33 | LL | static STATIC11: Vec = vec![MyOwned]; - | ----------------------------- ^^^^^^^^^^^^^ - | | - | calls in statics are limited to constant functions, tuple structs and tuple variants + | ^^^^^^^^^^^^^ | + = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0015]: cannot call non-const method `::to_string` in statics --> $DIR/check-values-constraints.rs:92:38 | -LL | static mut STATIC14: SafeStruct = SafeStruct { - | ------------------------------- calls in statics are limited to constant functions, tuple structs and tuple variants -LL | field1: SafeEnum::Variant1, LL | field2: SafeEnum::Variant4("str".to_string()), | ^^^^^^^^^^^ | @@ -46,6 +42,7 @@ note: method `to_string` is not const because trait `ToString` is not const ::: $SRC_DIR/alloc/src/string.rs:LL:COL | = note: this method is not const + = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` error[E0010]: allocations are not allowed in statics @@ -59,11 +56,10 @@ LL | vec![MyOwned], error[E0015]: cannot call non-const method `slice::::into_vec::` in statics --> $DIR/check-values-constraints.rs:96:5 | -LL | static STATIC15: &'static [Vec] = &[ - | ---------------------------------------- calls in statics are limited to constant functions, tuple structs and tuple variants LL | vec![MyOwned], | ^^^^^^^^^^^^^ | + = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -78,12 +74,10 @@ LL | vec![MyOwned], error[E0015]: cannot call non-const method `slice::::into_vec::` in statics --> $DIR/check-values-constraints.rs:98:5 | -LL | static STATIC15: &'static [Vec] = &[ - | ---------------------------------------- calls in statics are limited to constant functions, tuple structs and tuple variants -... LL | vec![MyOwned], | ^^^^^^^^^^^^^ | + = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -98,11 +92,10 @@ LL | &vec![MyOwned], error[E0015]: cannot call non-const method `slice::::into_vec::` in statics --> $DIR/check-values-constraints.rs:103:6 | -LL | static STATIC16: (&'static Vec, &'static Vec) = ( - | --------------------------------------------------------------- calls in statics are limited to constant functions, tuple structs and tuple variants LL | &vec![MyOwned], | ^^^^^^^^^^^^^ | + = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -117,12 +110,10 @@ LL | &vec![MyOwned], error[E0015]: cannot call non-const method `slice::::into_vec::` in statics --> $DIR/check-values-constraints.rs:105:6 | -LL | static STATIC16: (&'static Vec, &'static Vec) = ( - | --------------------------------------------------------------- calls in statics are limited to constant functions, tuple structs and tuple variants -... LL | &vec![MyOwned], | ^^^^^^^^^^^^^ | + = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -138,10 +129,9 @@ error[E0015]: cannot call non-const method `slice::::into_vec:: $DIR/check-values-constraints.rs:111:31 | LL | static STATIC19: Vec = vec![3]; - | --------------------------- ^^^^^^^ - | | - | calls in statics are limited to constant functions, tuple structs and tuple variants + | ^^^^^^^ | + = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -157,10 +147,9 @@ error[E0015]: cannot call non-const method `slice::::into_vec:: $DIR/check-values-constraints.rs:117:32 | LL | static x: Vec = vec![3]; - | -------------------- ^^^^^^^ - | | - | calls in statics are limited to constant functions, tuple structs and tuple variants + | ^^^^^^^ | + = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/traits/const-traits/const-check-fns-in-const-impl.stderr b/tests/ui/traits/const-traits/const-check-fns-in-const-impl.stderr index 70704780ddce..1a7ec35f3ddb 100644 --- a/tests/ui/traits/const-traits/const-check-fns-in-const-impl.stderr +++ b/tests/ui/traits/const-traits/const-check-fns-in-const-impl.stderr @@ -2,15 +2,14 @@ error[E0015]: cannot call non-const function `non_const` in constant functions --> $DIR/const-check-fns-in-const-impl.rs:14:16 | LL | fn foo() { non_const() } - | -------- ^^^^^^^^^^^ - | | - | calls in constant functions are limited to constant functions, tuple structs and tuple variants + | ^^^^^^^^^^^ | note: function `non_const` is not const --> $DIR/const-check-fns-in-const-impl.rs:11:1 | LL | fn non_const() {} | ^^^^^^^^^^^^^^ + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants 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 ac393825ec72..cbc62d602a47 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 @@ -21,7 +21,9 @@ error[E0015]: cannot call non-const method `Formatter::<'_>::write_str` in const --> $DIR/derive-const-gate.rs:1:16 | LL | #[derive_const(Debug)] - | ^^^^^ calls in constant functions are limited to constant functions, tuple structs and tuple variants + | ^^^^^ + | + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error: aborting due to 3 previous errors 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 9f620fcf81b7..93638801895d 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 @@ -11,7 +11,9 @@ error[E0015]: cannot call non-const method `Formatter::<'_>::debug_tuple_field1_ --> $DIR/derive-const-non-const-type.rs:12:16 | LL | #[derive_const(Debug)] - | ^^^^^ calls in constant functions are limited to constant functions, tuple structs and tuple variants + | ^^^^^ + | + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error: aborting due to 2 previous errors diff --git a/tests/ui/traits/const-traits/cross-crate.stock.stderr b/tests/ui/traits/const-traits/cross-crate.stock.stderr index 89278ff56ad0..44a60c99ae9e 100644 --- a/tests/ui/traits/const-traits/cross-crate.stock.stderr +++ b/tests/ui/traits/const-traits/cross-crate.stock.stderr @@ -1,12 +1,10 @@ error[E0658]: cannot call conditionally-const method `::func` in constant functions --> $DIR/cross-crate.rs:22:11 | -LL | const fn const_context() { - | ------------------------ calls in constant functions are limited to constant functions, tuple structs and tuple variants -... LL | Const.func(); | ^^^^^^ | + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = note: see issue #143874 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 diff --git a/tests/ui/traits/const-traits/cross-crate.stocknc.stderr b/tests/ui/traits/const-traits/cross-crate.stocknc.stderr index 6269e74fd1d2..766c20aa8211 100644 --- a/tests/ui/traits/const-traits/cross-crate.stocknc.stderr +++ b/tests/ui/traits/const-traits/cross-crate.stocknc.stderr @@ -1,21 +1,18 @@ error[E0015]: cannot call non-const method `::func` in constant functions --> $DIR/cross-crate.rs:19:14 | -LL | const fn const_context() { - | ------------------------ calls in constant functions are limited to constant functions, tuple structs and tuple variants -LL | #[cfg(any(stocknc, gatednc))] LL | NonConst.func(); | ^^^^^^ + | + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error[E0658]: cannot call conditionally-const method `::func` in constant functions --> $DIR/cross-crate.rs:22:11 | -LL | const fn const_context() { - | ------------------------ calls in constant functions are limited to constant functions, tuple structs and tuple variants -... LL | Const.func(); | ^^^^^^ | + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = note: see issue #143874 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 diff --git a/tests/ui/traits/const-traits/inline-incorrect-early-bound-in-ctfe.stderr b/tests/ui/traits/const-traits/inline-incorrect-early-bound-in-ctfe.stderr index 092a5ac05b82..ca73ae845550 100644 --- a/tests/ui/traits/const-traits/inline-incorrect-early-bound-in-ctfe.stderr +++ b/tests/ui/traits/const-traits/inline-incorrect-early-bound-in-ctfe.stderr @@ -10,8 +10,6 @@ LL | fn foo(self) { error[E0015]: cannot call non-const method `<() as Trait>::foo` in constant functions --> $DIR/inline-incorrect-early-bound-in-ctfe.rs:26:8 | -LL | const fn foo() { - | -------------- calls in constant functions are limited to constant functions, tuple structs and tuple variants LL | ().foo(); | ^^^^^ | @@ -22,6 +20,7 @@ LL | trait Trait { | ^^^^^^^^^^^ this trait is not const LL | fn foo(self); | ------------- this method is not const + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants help: consider making trait `Trait` const | LL + #[const_trait] diff --git a/tests/ui/traits/const-traits/issue-79450.stderr b/tests/ui/traits/const-traits/issue-79450.stderr index dd78b464e782..d8a9e1898068 100644 --- a/tests/ui/traits/const-traits/issue-79450.stderr +++ b/tests/ui/traits/const-traits/issue-79450.stderr @@ -1,13 +1,12 @@ error[E0015]: cannot call non-const function `_print` in constant functions --> $DIR/issue-79450.rs:9:9 | -LL | fn prov(&self) { - | -------------- calls in constant functions are limited to constant functions, tuple structs and tuple variants LL | println!("lul"); | ^^^^^^^^^^^^^^^ | note: function `_print` is not const --> $SRC_DIR/std/src/io/stdio.rs:LL:COL + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/issue-88155.stderr b/tests/ui/traits/const-traits/issue-88155.stderr index 2df4a0004b6a..4a912cc8274a 100644 --- a/tests/ui/traits/const-traits/issue-88155.stderr +++ b/tests/ui/traits/const-traits/issue-88155.stderr @@ -1,8 +1,6 @@ error[E0015]: cannot call non-const associated function `::assoc` in constant functions --> $DIR/issue-88155.rs:8:5 | -LL | pub const fn foo() -> bool { - | -------------------------------- calls in constant functions are limited to constant functions, tuple structs and tuple variants LL | T::assoc() | ^^^^^^^^^^ | @@ -13,6 +11,7 @@ LL | pub trait A { | ^^^^^^^^^^^ this trait is not const LL | fn assoc() -> bool; | ------------------- this associated function is not const + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants help: consider making trait `A` const | LL + #[const_trait] diff --git a/tests/ui/traits/const-traits/staged-api-user-crate.stderr b/tests/ui/traits/const-traits/staged-api-user-crate.stderr index 1baa8b308284..81611da9e748 100644 --- a/tests/ui/traits/const-traits/staged-api-user-crate.stderr +++ b/tests/ui/traits/const-traits/staged-api-user-crate.stderr @@ -1,11 +1,10 @@ error[E0658]: cannot call conditionally-const associated function `::func` in constant functions --> $DIR/staged-api-user-crate.rs:12:5 | -LL | const fn stable_const_context() { - | ------------------------------- calls in constant functions are limited to constant functions, tuple structs and tuple variants LL | Unstable::func(); | ^^^^^^^^^^^^^^^^ | + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = note: see issue #143874 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 diff --git a/tests/ui/traits/const-traits/std-impl-gate.stock.stderr b/tests/ui/traits/const-traits/std-impl-gate.stock.stderr index 3f40f602eefe..261f68bebdb2 100644 --- a/tests/ui/traits/const-traits/std-impl-gate.stock.stderr +++ b/tests/ui/traits/const-traits/std-impl-gate.stock.stderr @@ -1,11 +1,10 @@ error[E0658]: cannot call conditionally-const associated function ` as Default>::default` in constant functions --> $DIR/std-impl-gate.rs:13:5 | -LL | const fn const_context() -> Vec { - | -------------------------------------- calls in constant functions are limited to constant functions, tuple structs and tuple variants LL | Default::default() | ^^^^^^^^^^^^^^^^^^ | + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = note: see issue #143874 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 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 84fc743e4a2b..c9dc239bef33 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 @@ -48,8 +48,6 @@ LL | #[const_trait] trait Foo { error[E0015]: cannot call non-const method `::a` in constant functions --> $DIR/super-traits-fail-2.rs:20:7 | -LL | const fn foo(x: &T) { - | --------------------------- calls in constant functions are limited to constant functions, tuple structs and tuple variants LL | x.a(); | ^^^ | @@ -60,6 +58,7 @@ LL | trait Foo { | ^^^^^^^^^ this trait is not const LL | fn a(&self); | ------------ this method is not const + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants help: consider making trait `Foo` const | LL + #[const_trait] 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 9d72e149aab2..bfbf6980ab83 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 @@ -60,8 +60,6 @@ LL | #[const_trait] trait Foo { error[E0015]: cannot call non-const method `::a` in constant functions --> $DIR/super-traits-fail-2.rs:20:7 | -LL | const fn foo(x: &T) { - | --------------------------- calls in constant functions are limited to constant functions, tuple structs and tuple variants LL | x.a(); | ^^^ | @@ -72,6 +70,7 @@ LL | trait Foo { | ^^^^^^^^^ this trait is not const LL | fn a(&self); | ------------ this method is not const + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants help: consider making trait `Foo` const | LL + #[const_trait] 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 index 2625f9446061..ea487cbd563f 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.nnn.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.nnn.stderr @@ -91,9 +91,6 @@ LL | #[const_trait] trait Bar: [const] Foo {} error[E0015]: cannot call non-const method `::a` in constant functions --> $DIR/super-traits-fail-3.rs:36:7 | -LL | const fn foo(x: &T) { - | ----------------------------------- calls in constant functions are limited to constant functions, tuple structs and tuple variants -... LL | x.a(); | ^^^ | @@ -105,6 +102,7 @@ LL | trait Foo { LL | fn a(&self); | ------------ this method is not const = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable `#[const_trait]` + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants help: consider making trait `Foo` const | LL + #[const_trait] 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 index 2625f9446061..ea487cbd563f 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.nny.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.nny.stderr @@ -91,9 +91,6 @@ LL | #[const_trait] trait Bar: [const] Foo {} error[E0015]: cannot call non-const method `::a` in constant functions --> $DIR/super-traits-fail-3.rs:36:7 | -LL | const fn foo(x: &T) { - | ----------------------------------- calls in constant functions are limited to constant functions, tuple structs and tuple variants -... LL | x.a(); | ^^^ | @@ -105,6 +102,7 @@ LL | trait Foo { LL | fn a(&self); | ------------ this method is not const = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable `#[const_trait]` + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants help: consider making trait `Foo` const | LL + #[const_trait] 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 index 155263656e36..b00ad706a5fa 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.nyn.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.nyn.stderr @@ -41,12 +41,10 @@ LL | #[cfg_attr(any(yyy, yny, nyy, nyn), const_trait)] error[E0658]: cannot call conditionally-const method `::a` in constant functions --> $DIR/super-traits-fail-3.rs:36:7 | -LL | const fn foo(x: &T) { - | ----------------------------------- calls in constant functions are limited to constant functions, tuple structs and tuple variants -... LL | x.a(); | ^^^ | + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = note: see issue #143874 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 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 index 155263656e36..b00ad706a5fa 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.nyy.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.nyy.stderr @@ -41,12 +41,10 @@ LL | #[cfg_attr(any(yyy, yny, nyy, nyn), const_trait)] error[E0658]: cannot call conditionally-const method `::a` in constant functions --> $DIR/super-traits-fail-3.rs:36:7 | -LL | const fn foo(x: &T) { - | ----------------------------------- calls in constant functions are limited to constant functions, tuple structs and tuple variants -... LL | x.a(); | ^^^ | + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = note: see issue #143874 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 diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.ynn.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.ynn.stderr index 4895b5b0cd08..5951caebe733 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.ynn.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.ynn.stderr @@ -71,9 +71,6 @@ LL | #[const_trait] trait Bar: [const] Foo {} error[E0015]: cannot call non-const method `::a` in constant functions --> $DIR/super-traits-fail-3.rs:36:7 | -LL | const fn foo(x: &T) { - | ----------------------------------- calls in constant functions are limited to constant functions, tuple structs and tuple variants -... LL | x.a(); | ^^^ | @@ -84,6 +81,7 @@ LL | trait Foo { | ^^^^^^^^^ this trait is not const LL | fn a(&self); | ------------ this method is not const + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants help: consider making trait `Foo` const | LL + #[const_trait] 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 index 29bce84326ca..563495204ad7 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.yny.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.yny.stderr @@ -60,9 +60,6 @@ LL | #[const_trait] trait Foo { error[E0015]: cannot call non-const method `::a` in constant functions --> $DIR/super-traits-fail-3.rs:36:7 | -LL | const fn foo(x: &T) { - | ----------------------------------- calls in constant functions are limited to constant functions, tuple structs and tuple variants -... LL | x.a(); | ^^^ | @@ -73,6 +70,7 @@ LL | trait Foo { | ^^^^^^^^^ this trait is not const LL | fn a(&self); | ------------ this method is not const + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants help: consider making trait `Foo` const | LL + #[const_trait] diff --git a/tests/ui/typeck/typeck_type_placeholder_item.stderr b/tests/ui/typeck/typeck_type_placeholder_item.stderr index 0b0f9fbb9be1..0b70ac97fd43 100644 --- a/tests/ui/typeck/typeck_type_placeholder_item.stderr +++ b/tests/ui/typeck/typeck_type_placeholder_item.stderr @@ -669,23 +669,20 @@ error[E0015]: cannot call non-const function `map::` in constants --> $DIR/typeck_type_placeholder_item.rs:231:22 | LL | const _: Option<_> = map(value); - | ------------------ ^^^^^^^^^^ - | | - | calls in constants are limited to constant functions, tuple structs and tuple variants + | ^^^^^^^^^^ | note: function `map` is not const --> $DIR/typeck_type_placeholder_item.rs:222:1 | LL | fn map(_: fn() -> Option<&'static T>) -> Option { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: calls in constants are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const method ` as Iterator>::filter::<{closure@$DIR/typeck_type_placeholder_item.rs:240:29: 240:32}>` in constants --> $DIR/typeck_type_placeholder_item.rs:240:22 | LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x); - | ---------- ^^^^^^^^^^^^^^^^^^^^^^ - | | - | calls in constants are limited to constant functions, tuple structs and tuple variants + | ^^^^^^^^^^^^^^^^^^^^^^ | note: method `filter` is not const because trait `Iterator` is not const --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL @@ -694,14 +691,13 @@ note: method `filter` is not const because trait `Iterator` is not const ::: $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL | = note: this method is not const + = note: calls in constants are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const method `, {closure@$DIR/typeck_type_placeholder_item.rs:240:29: 240:32}> as Iterator>::map::` in constants --> $DIR/typeck_type_placeholder_item.rs:240:45 | LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x); - | ---------- ^^^^^^^^^^^^^^ - | | - | calls in constants are limited to constant functions, tuple structs and tuple variants + | ^^^^^^^^^^^^^^ | note: method `map` is not const because trait `Iterator` is not const --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL @@ -710,6 +706,7 @@ note: method `map` is not const because trait `Iterator` is not const ::: $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL | = note: this method is not const + = note: calls in constants are limited to constant functions, tuple structs and tuple variants error: aborting due to 83 previous errors