From 535bc781f81d26883783b726770da94e4918c711 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sun, 22 Dec 2024 01:46:44 +0000 Subject: [PATCH 1/5] Fix item bounds in old solver --- .../src/traits/effects.rs | 165 +++++++++++++++--- .../assoc-type-const-bound-usage-0.rs | 3 +- .../assoc-type-const-bound-usage-1.rs | 3 +- .../assoc-type-const-bound-usage-1.stderr | 35 ---- ...pe-const-bound-usage-fail-2.current.stderr | 15 ++ ...type-const-bound-usage-fail-2.next.stderr} | 4 +- .../assoc-type-const-bound-usage-fail-2.rs | 9 +- ...ype-const-bound-usage-fail.current.stderr} | 4 +- ...oc-type-const-bound-usage-fail.next.stderr | 15 ++ .../assoc-type-const-bound-usage-fail.rs | 3 +- ...-type.stderr => assoc-type.current.stderr} | 4 +- .../const-traits/assoc-type.next.stderr | 15 ++ tests/ui/traits/const-traits/assoc-type.rs | 3 +- 13 files changed, 201 insertions(+), 77 deletions(-) delete mode 100644 tests/ui/traits/const-traits/assoc-type-const-bound-usage-1.stderr create mode 100644 tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.current.stderr rename tests/ui/traits/const-traits/{assoc-type-const-bound-usage-fail-2.stderr => assoc-type-const-bound-usage-fail-2.next.stderr} (79%) rename tests/ui/traits/const-traits/{assoc-type-const-bound-usage-fail.stderr => assoc-type-const-bound-usage-fail.current.stderr} (77%) create mode 100644 tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.next.stderr rename tests/ui/traits/const-traits/{assoc-type.stderr => assoc-type.current.stderr} (86%) create mode 100644 tests/ui/traits/const-traits/assoc-type.next.stderr diff --git a/compiler/rustc_trait_selection/src/traits/effects.rs b/compiler/rustc_trait_selection/src/traits/effects.rs index b17a489a857db..91484ef99dbb8 100644 --- a/compiler/rustc_trait_selection/src/traits/effects.rs +++ b/compiler/rustc_trait_selection/src/traits/effects.rs @@ -1,13 +1,15 @@ use rustc_hir as hir; -use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes, InferCtxt}; +use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes}; use rustc_infer::traits::{ImplSource, Obligation, PredicateObligation}; use rustc_middle::span_bug; use rustc_middle::ty::fast_reject::DeepRejectCtxt; use rustc_middle::ty::{self, TypingMode}; +use rustc_type_ir::elaborate::elaborate; use rustc_type_ir::solve::NoSolution; -use thin_vec::ThinVec; +use thin_vec::{ThinVec, thin_vec}; use super::SelectionContext; +use super::normalize::normalize_with_depth_to; pub type HostEffectObligation<'tcx> = Obligation<'tcx, ty::HostEffectPredicate<'tcx>>; @@ -38,6 +40,12 @@ pub fn evaluate_host_effect_obligation<'tcx>( Err(EvaluationFailure::NoSolution) => {} } + match evaluate_host_effect_from_item_bounds(selcx, obligation) { + Ok(result) => return Ok(result), + Err(EvaluationFailure::Ambiguous) => return Err(EvaluationFailure::Ambiguous), + Err(EvaluationFailure::NoSolution) => {} + } + match evaluate_host_effect_from_selection_candiate(selcx, obligation) { Ok(result) => return Ok(result), Err(EvaluationFailure::Ambiguous) => return Err(EvaluationFailure::Ambiguous), @@ -48,24 +56,45 @@ pub fn evaluate_host_effect_obligation<'tcx>( } fn match_candidate<'tcx>( - infcx: &InferCtxt<'tcx>, + selcx: &mut SelectionContext<'_, 'tcx>, obligation: &HostEffectObligation<'tcx>, candidate: ty::Binder<'tcx, ty::HostEffectPredicate<'tcx>>, + candidate_is_unnormalized: bool, + more_nested: impl FnOnce(&mut SelectionContext<'_, 'tcx>, &mut ThinVec>), ) -> Result>, NoSolution> { if !candidate.skip_binder().constness.satisfies(obligation.predicate.constness) { return Err(NoSolution); } - let candidate = infcx.instantiate_binder_with_fresh_vars( + let mut candidate = selcx.infcx.instantiate_binder_with_fresh_vars( obligation.cause.span, BoundRegionConversionTime::HigherRankedType, candidate, ); - let mut nested = infcx - .at(&obligation.cause, obligation.param_env) - .eq(DefineOpaqueTypes::Yes, obligation.predicate.trait_ref, candidate.trait_ref)? - .into_obligations(); + let mut nested = thin_vec![]; + + // Unlike param-env bounds, item bounds may not be normalized. + if candidate_is_unnormalized { + candidate = normalize_with_depth_to( + selcx, + obligation.param_env, + obligation.cause.clone(), + obligation.recursion_depth, + candidate, + &mut nested, + ); + } + + nested.extend( + selcx + .infcx + .at(&obligation.cause, obligation.param_env) + .eq(DefineOpaqueTypes::Yes, obligation.predicate.trait_ref, candidate.trait_ref)? + .into_obligations(), + ); + + more_nested(selcx, &mut nested); for nested in &mut nested { nested.set_depth_from_parent(obligation.recursion_depth); @@ -82,36 +111,116 @@ fn evaluate_host_effect_from_bounds<'tcx>( let drcx = DeepRejectCtxt::relate_rigid_rigid(selcx.tcx()); let mut candidate = None; - for predicate in obligation.param_env.caller_bounds() { - let bound_predicate = predicate.kind(); - if let ty::ClauseKind::HostEffect(data) = predicate.kind().skip_binder() { - let data = bound_predicate.rebind(data); - if data.skip_binder().trait_ref.def_id != obligation.predicate.trait_ref.def_id { - continue; + for clause in obligation.param_env.caller_bounds() { + let bound_clause = clause.kind(); + let ty::ClauseKind::HostEffect(data) = bound_clause.skip_binder() else { + continue; + }; + let data = bound_clause.rebind(data); + if data.skip_binder().trait_ref.def_id != obligation.predicate.trait_ref.def_id { + continue; + } + + if !drcx + .args_may_unify(obligation.predicate.trait_ref.args, data.skip_binder().trait_ref.args) + { + continue; + } + + let is_match = + infcx.probe(|_| match_candidate(selcx, obligation, data, false, |_, _| {}).is_ok()); + + if is_match { + if candidate.is_some() { + return Err(EvaluationFailure::Ambiguous); + } else { + candidate = Some(data); } + } + } - if !drcx.args_may_unify( - obligation.predicate.trait_ref.args, - data.skip_binder().trait_ref.args, + if let Some(data) = candidate { + Ok(match_candidate(selcx, obligation, data, false, |_, _| {}) + .expect("candidate matched before, so it should match again")) + } else { + Err(EvaluationFailure::NoSolution) + } +} + +fn evaluate_host_effect_from_item_bounds<'tcx>( + selcx: &mut SelectionContext<'_, 'tcx>, + obligation: &HostEffectObligation<'tcx>, +) -> Result>, EvaluationFailure> { + let infcx = selcx.infcx; + let tcx = infcx.tcx; + let drcx = DeepRejectCtxt::relate_rigid_rigid(selcx.tcx()); + let mut candidate = None; + + let mut consider_ty = obligation.predicate.self_ty(); + while let ty::Alias(kind @ (ty::Projection | ty::Opaque), alias_ty) = *consider_ty.kind() { + if tcx.is_conditionally_const(alias_ty.def_id) { + for clause in elaborate( + tcx, + tcx.explicit_implied_const_bounds(alias_ty.def_id) + .iter_instantiated_copied(tcx, alias_ty.args) + .map(|(trait_ref, _)| { + trait_ref.to_host_effect_clause(tcx, obligation.predicate.constness) + }), ) { - continue; - } + let bound_clause = clause.kind(); + let ty::ClauseKind::HostEffect(data) = bound_clause.skip_binder() else { + unreachable!("should not elaborate non-HostEffect from HostEffect") + }; + let data = bound_clause.rebind(data); + if data.skip_binder().trait_ref.def_id != obligation.predicate.trait_ref.def_id { + continue; + } - let is_match = infcx.probe(|_| match_candidate(infcx, obligation, data).is_ok()); + if !drcx.args_may_unify( + obligation.predicate.trait_ref.args, + data.skip_binder().trait_ref.args, + ) { + continue; + } - if is_match { - if candidate.is_some() { - return Err(EvaluationFailure::Ambiguous); - } else { - candidate = Some(data); + let is_match = infcx + .probe(|_| match_candidate(selcx, obligation, data, true, |_, _| {}).is_ok()); + + if is_match { + if candidate.is_some() { + return Err(EvaluationFailure::Ambiguous); + } else { + candidate = Some((data, alias_ty)); + } } } } + + if kind != ty::Projection { + break; + } + + consider_ty = alias_ty.self_ty(); } - if let Some(data) = candidate { - Ok(match_candidate(infcx, obligation, data) - .expect("candidate matched before, so it should match again")) + if let Some((data, alias_ty)) = candidate { + Ok(match_candidate(selcx, obligation, data, true, |selcx, nested| { + // An alias bound only holds if we also check the const conditions + // of the alias, so we need to register those, too. + let const_conditions = normalize_with_depth_to( + selcx, + obligation.param_env, + obligation.cause.clone(), + obligation.recursion_depth, + tcx.const_conditions(alias_ty.def_id).instantiate(tcx, alias_ty.args), + nested, + ); + nested.extend(const_conditions.into_iter().map(|(trait_ref, _)| { + obligation + .with(tcx, trait_ref.to_host_effect_clause(tcx, obligation.predicate.constness)) + })); + }) + .expect("candidate matched before, so it should match again")) } else { Err(EvaluationFailure::NoSolution) } diff --git a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-0.rs b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-0.rs index bac7ee023f479..9141d327aee87 100644 --- a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-0.rs +++ b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-0.rs @@ -1,4 +1,5 @@ -//@ compile-flags: -Znext-solver +//@ revisions: current next +//@[next] compile-flags: -Znext-solver //@ check-pass #![feature(const_trait_impl)] diff --git a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-1.rs b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-1.rs index a0375cda079a7..19e86b50d3321 100644 --- a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-1.rs +++ b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-1.rs @@ -1,5 +1,4 @@ -//@ compile-flags: -Znext-solver -//@ known-bug: unknown +//@ check-pass #![feature(const_trait_impl, generic_const_exprs)] #![allow(incomplete_features)] diff --git a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-1.stderr b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-1.stderr deleted file mode 100644 index 8d1c85c0c8aa0..0000000000000 --- a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-1.stderr +++ /dev/null @@ -1,35 +0,0 @@ -error: `-Znext-solver=globally` and `generic_const_exprs` are incompatible, using them at the same time is not allowed - --> $DIR/assoc-type-const-bound-usage-1.rs:4:30 - | -LL | #![feature(const_trait_impl, generic_const_exprs)] - | ^^^^^^^^^^^^^^^^^^^ - | - = help: remove one of these features - -error[E0284]: type annotations needed: cannot normalize `unqualified::{constant#0}` - --> $DIR/assoc-type-const-bound-usage-1.rs:15:37 - | -LL | fn unqualified() -> Type<{ T::Assoc::func() }> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot normalize `unqualified::{constant#0}` - -error[E0284]: type annotations needed: cannot normalize `qualified::{constant#0}` - --> $DIR/assoc-type-const-bound-usage-1.rs:19:35 - | -LL | fn qualified() -> Type<{ ::Assoc::func() }> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot normalize `qualified::{constant#0}` - -error[E0284]: type annotations needed: cannot normalize `unqualified::{constant#0}` - --> $DIR/assoc-type-const-bound-usage-1.rs:16:5 - | -LL | Type - | ^^^^ cannot normalize `unqualified::{constant#0}` - -error[E0284]: type annotations needed: cannot normalize `qualified::{constant#0}` - --> $DIR/assoc-type-const-bound-usage-1.rs:20:5 - | -LL | Type - | ^^^^ cannot normalize `qualified::{constant#0}` - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0284`. diff --git a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.current.stderr b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.current.stderr new file mode 100644 index 0000000000000..03da9159bea0b --- /dev/null +++ b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.current.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `U: ~const Other` is not satisfied + --> $DIR/assoc-type-const-bound-usage-fail-2.rs:24:5 + | +LL | T::Assoc::::func(); + | ^^^^^^^^^^^^^ + +error[E0277]: the trait bound `U: ~const Other` is not satisfied + --> $DIR/assoc-type-const-bound-usage-fail-2.rs:27:5 + | +LL | ::Assoc::::func(); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.stderr b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.next.stderr similarity index 79% rename from tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.stderr rename to tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.next.stderr index c7af0a220ca31..ce58b486a16ef 100644 --- a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.stderr +++ b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.next.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `::Assoc: ~const Trait` is not satisfied - --> $DIR/assoc-type-const-bound-usage-fail-2.rs:23:5 + --> $DIR/assoc-type-const-bound-usage-fail-2.rs:24:5 | LL | T::Assoc::::func(); | ^^^^^^^^^^^^^ error[E0277]: the trait bound `::Assoc: ~const Trait` is not satisfied - --> $DIR/assoc-type-const-bound-usage-fail-2.rs:25:5 + --> $DIR/assoc-type-const-bound-usage-fail-2.rs:27:5 | LL | ::Assoc::::func(); | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.rs b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.rs index b3a636b0f713d..bdd98eaf541f8 100644 --- a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.rs +++ b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.rs @@ -1,4 +1,5 @@ -//@ compile-flags: -Znext-solver +//@ revisions: current next +//@[next] compile-flags: -Znext-solver // Check that `~const` item bounds only hold if the where clauses on the // associated type are also const. @@ -21,9 +22,11 @@ trait Other {} const fn fails() { T::Assoc::::func(); - //~^ ERROR the trait bound `::Assoc: ~const Trait` is not satisfied + //[current]~^ ERROR the trait bound `U: ~const Other` is not satisfied + //[next]~^^ ERROR the trait bound `::Assoc: ~const Trait` is not satisfied ::Assoc::::func(); - //~^ ERROR the trait bound `::Assoc: ~const Trait` is not satisfied + //[current]~^ ERROR the trait bound `U: ~const Other` is not satisfied + //[next]~^^ ERROR the trait bound `::Assoc: ~const Trait` is not satisfied } const fn works() { diff --git a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.stderr b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.current.stderr similarity index 77% rename from tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.stderr rename to tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.current.stderr index 99fc924ad06b9..9c29a894749e9 100644 --- a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.stderr +++ b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.current.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `T: ~const Trait` is not satisfied - --> $DIR/assoc-type-const-bound-usage-fail.rs:16:5 + --> $DIR/assoc-type-const-bound-usage-fail.rs:17:5 | LL | T::Assoc::func(); | ^^^^^^^^ error[E0277]: the trait bound `T: ~const Trait` is not satisfied - --> $DIR/assoc-type-const-bound-usage-fail.rs:18:5 + --> $DIR/assoc-type-const-bound-usage-fail.rs:19:5 | LL | ::Assoc::func(); | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.next.stderr b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.next.stderr new file mode 100644 index 0000000000000..9c29a894749e9 --- /dev/null +++ b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.next.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `T: ~const Trait` is not satisfied + --> $DIR/assoc-type-const-bound-usage-fail.rs:17:5 + | +LL | T::Assoc::func(); + | ^^^^^^^^ + +error[E0277]: the trait bound `T: ~const Trait` is not satisfied + --> $DIR/assoc-type-const-bound-usage-fail.rs:19:5 + | +LL | ::Assoc::func(); + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.rs b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.rs index ce01086f0dc0b..3761fea19684d 100644 --- a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.rs +++ b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.rs @@ -1,4 +1,5 @@ -//@ compile-flags: -Znext-solver +//@ revisions: current next +//@[next] compile-flags: -Znext-solver // Check that `~const` item bounds only hold if the parent trait is `~const`. // i.e. check that we validate the const conditions for the associated type diff --git a/tests/ui/traits/const-traits/assoc-type.stderr b/tests/ui/traits/const-traits/assoc-type.current.stderr similarity index 86% rename from tests/ui/traits/const-traits/assoc-type.stderr rename to tests/ui/traits/const-traits/assoc-type.current.stderr index b318675b6123f..4bf9acfbd6507 100644 --- a/tests/ui/traits/const-traits/assoc-type.stderr +++ b/tests/ui/traits/const-traits/assoc-type.current.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `NonConstAdd: ~const Add` is not satisfied - --> $DIR/assoc-type.rs:36:16 + --> $DIR/assoc-type.rs:37:16 | LL | type Bar = NonConstAdd; | ^^^^^^^^^^^ | note: required by a bound in `Foo::Bar` - --> $DIR/assoc-type.rs:32:15 + --> $DIR/assoc-type.rs:33:15 | LL | type Bar: ~const Add; | ^^^^^^ required by this bound in `Foo::Bar` diff --git a/tests/ui/traits/const-traits/assoc-type.next.stderr b/tests/ui/traits/const-traits/assoc-type.next.stderr new file mode 100644 index 0000000000000..4bf9acfbd6507 --- /dev/null +++ b/tests/ui/traits/const-traits/assoc-type.next.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `NonConstAdd: ~const Add` is not satisfied + --> $DIR/assoc-type.rs:37:16 + | +LL | type Bar = NonConstAdd; + | ^^^^^^^^^^^ + | +note: required by a bound in `Foo::Bar` + --> $DIR/assoc-type.rs:33:15 + | +LL | type Bar: ~const Add; + | ^^^^^^ required by this bound in `Foo::Bar` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/const-traits/assoc-type.rs b/tests/ui/traits/const-traits/assoc-type.rs index 32c91fa51f135..a169b61994cbf 100644 --- a/tests/ui/traits/const-traits/assoc-type.rs +++ b/tests/ui/traits/const-traits/assoc-type.rs @@ -1,4 +1,5 @@ -//@ compile-flags: -Znext-solver +//@ revisions: current next +//@[next] compile-flags: -Znext-solver #![feature(const_trait_impl)] From 5a8d970e4ff9b4167531013ba0694189e7ed2527 Mon Sep 17 00:00:00 2001 From: Mostafa Khaled Date: Sun, 22 Dec 2024 21:38:23 +0200 Subject: [PATCH 2/5] Fixes safety docs for `dyn Any + Send {+ Sync}` --- library/core/src/any.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/library/core/src/any.rs b/library/core/src/any.rs index 58107b1e7d074..17d9455592787 100644 --- a/library/core/src/any.rs +++ b/library/core/src/any.rs @@ -423,7 +423,8 @@ impl dyn Any + Send { /// /// # Safety /// - /// Same as the method on the type `dyn Any`. + /// The contained value must be of type `T`. Calling this method + /// with the incorrect type is *undefined behavior*. #[unstable(feature = "downcast_unchecked", issue = "90850")] #[inline] pub unsafe fn downcast_ref_unchecked(&self) -> &T { @@ -451,7 +452,8 @@ impl dyn Any + Send { /// /// # Safety /// - /// Same as the method on the type `dyn Any`. + /// The contained value must be of type `T`. Calling this method + /// with the incorrect type is *undefined behavior*. #[unstable(feature = "downcast_unchecked", issue = "90850")] #[inline] pub unsafe fn downcast_mut_unchecked(&mut self) -> &mut T { @@ -552,6 +554,10 @@ impl dyn Any + Send + Sync { /// assert_eq!(*x.downcast_ref_unchecked::(), 1); /// } /// ``` + /// # Safety + /// + /// The contained value must be of type `T`. Calling this method + /// with the incorrect type is *undefined behavior*. #[unstable(feature = "downcast_unchecked", issue = "90850")] #[inline] pub unsafe fn downcast_ref_unchecked(&self) -> &T { @@ -576,6 +582,10 @@ impl dyn Any + Send + Sync { /// /// assert_eq!(*x.downcast_ref::().unwrap(), 2); /// ``` + /// # Safety + /// + /// The contained value must be of type `T`. Calling this method + /// with the incorrect type is *undefined behavior*. #[unstable(feature = "downcast_unchecked", issue = "90850")] #[inline] pub unsafe fn downcast_mut_unchecked(&mut self) -> &mut T { From af1c8da172a9d9d18af4a7e1c59bfecd2f051111 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 23 Dec 2024 15:30:27 +0100 Subject: [PATCH 3/5] core: fix const ptr::swap_nonoverlapping when there are pointers at odd offsets in the type --- library/core/src/intrinsics/mod.rs | 14 ++-- library/core/src/ptr/mod.rs | 73 +++++++++++-------- library/core/tests/lib.rs | 1 + library/core/tests/ptr.rs | 63 +++++++++++++--- .../consts/missing_span_in_backtrace.stderr | 3 + 5 files changed, 106 insertions(+), 48 deletions(-) diff --git a/library/core/src/intrinsics/mod.rs b/library/core/src/intrinsics/mod.rs index 3e53c0497cc78..42b8eb33a1a95 100644 --- a/library/core/src/intrinsics/mod.rs +++ b/library/core/src/intrinsics/mod.rs @@ -3795,7 +3795,7 @@ where /// See [`const_eval_select()`] for the rules and requirements around that intrinsic. pub(crate) macro const_eval_select { ( - @capture { $($arg:ident : $ty:ty = $val:expr),* $(,)? } $( -> $ret:ty )? : + @capture$([$($binders:tt)*])? { $($arg:ident : $ty:ty = $val:expr),* $(,)? } $( -> $ret:ty )? : if const $(#[$compiletime_attr:meta])* $compiletime:block else @@ -3803,7 +3803,7 @@ pub(crate) macro const_eval_select { ) => { // Use the `noinline` arm, after adding explicit `inline` attributes $crate::intrinsics::const_eval_select!( - @capture { $($arg : $ty = $val),* } $(-> $ret)? : + @capture$([$($binders)*])? { $($arg : $ty = $val),* } $(-> $ret)? : #[noinline] if const #[inline] // prevent codegen on this function @@ -3817,7 +3817,7 @@ pub(crate) macro const_eval_select { }, // With a leading #[noinline], we don't add inline attributes ( - @capture { $($arg:ident : $ty:ty = $val:expr),* $(,)? } $( -> $ret:ty )? : + @capture$([$($binders:tt)*])? { $($arg:ident : $ty:ty = $val:expr),* $(,)? } $( -> $ret:ty )? : #[noinline] if const $(#[$compiletime_attr:meta])* $compiletime:block @@ -3825,12 +3825,12 @@ pub(crate) macro const_eval_select { $(#[$runtime_attr:meta])* $runtime:block ) => {{ $(#[$runtime_attr])* - fn runtime($($arg: $ty),*) $( -> $ret )? { + fn runtime$(<$($binders)*>)?($($arg: $ty),*) $( -> $ret )? { $runtime } $(#[$compiletime_attr])* - const fn compiletime($($arg: $ty),*) $( -> $ret )? { + const fn compiletime$(<$($binders)*>)?($($arg: $ty),*) $( -> $ret )? { // Don't warn if one of the arguments is unused. $(let _ = $arg;)* @@ -3842,14 +3842,14 @@ pub(crate) macro const_eval_select { // We support leaving away the `val` expressions for *all* arguments // (but not for *some* arguments, that's too tricky). ( - @capture { $($arg:ident : $ty:ty),* $(,)? } $( -> $ret:ty )? : + @capture$([$($binders:tt)*])? { $($arg:ident : $ty:ty),* $(,)? } $( -> $ret:ty )? : if const $(#[$compiletime_attr:meta])* $compiletime:block else $(#[$runtime_attr:meta])* $runtime:block ) => { $crate::intrinsics::const_eval_select!( - @capture { $($arg : $ty = $arg),* } $(-> $ret)? : + @capture$([$($binders)*])? { $($arg : $ty = $arg),* } $(-> $ret)? : if const $(#[$compiletime_attr])* $compiletime else diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs index 1423e7ea8d10c..e6e13eaff7b0f 100644 --- a/library/core/src/ptr/mod.rs +++ b/library/core/src/ptr/mod.rs @@ -395,6 +395,7 @@ #![allow(clippy::not_unsafe_ptr_arg_deref)] use crate::cmp::Ordering; +use crate::intrinsics::const_eval_select; use crate::marker::FnPtr; use crate::mem::{self, MaybeUninit, SizedTypeProperties}; use crate::{fmt, hash, intrinsics, ub_checks}; @@ -1074,25 +1075,6 @@ pub const unsafe fn swap(x: *mut T, y: *mut T) { #[rustc_const_unstable(feature = "const_swap_nonoverlapping", issue = "133668")] #[rustc_diagnostic_item = "ptr_swap_nonoverlapping"] pub const unsafe fn swap_nonoverlapping(x: *mut T, y: *mut T, count: usize) { - #[allow(unused)] - macro_rules! attempt_swap_as_chunks { - ($ChunkTy:ty) => { - if mem::align_of::() >= mem::align_of::<$ChunkTy>() - && mem::size_of::() % mem::size_of::<$ChunkTy>() == 0 - { - let x: *mut $ChunkTy = x.cast(); - let y: *mut $ChunkTy = y.cast(); - let count = count * (mem::size_of::() / mem::size_of::<$ChunkTy>()); - // SAFETY: these are the same bytes that the caller promised were - // ok, just typed as `MaybeUninit`s instead of as `T`s. - // The `if` condition above ensures that we're not violating - // alignment requirements, and that the division is exact so - // that we don't lose any bytes off the end. - return unsafe { swap_nonoverlapping_simple_untyped(x, y, count) }; - } - }; - } - ub_checks::assert_unsafe_precondition!( check_language_ub, "ptr::swap_nonoverlapping requires that both pointer arguments are aligned and non-null \ @@ -1111,19 +1093,48 @@ pub const unsafe fn swap_nonoverlapping(x: *mut T, y: *mut T, count: usize) { } ); - // Split up the slice into small power-of-two-sized chunks that LLVM is able - // to vectorize (unless it's a special type with more-than-pointer alignment, - // because we don't want to pessimize things like slices of SIMD vectors.) - if mem::align_of::() <= mem::size_of::() - && (!mem::size_of::().is_power_of_two() - || mem::size_of::() > mem::size_of::() * 2) - { - attempt_swap_as_chunks!(usize); - attempt_swap_as_chunks!(u8); - } + const_eval_select!( + @capture[T] { x: *mut T, y: *mut T, count: usize }: + if const { + // At compile-time we want to always copy this in chunks of `T`, to ensure that if there + // are pointers inside `T` we will copy them in one go rather than trying to copy a part + // of a pointer (which would not work). + // SAFETY: Same preconditions as this function + unsafe { swap_nonoverlapping_simple_untyped(x, y, count) } + } else { + macro_rules! attempt_swap_as_chunks { + ($ChunkTy:ty) => { + if mem::align_of::() >= mem::align_of::<$ChunkTy>() + && mem::size_of::() % mem::size_of::<$ChunkTy>() == 0 + { + let x: *mut $ChunkTy = x.cast(); + let y: *mut $ChunkTy = y.cast(); + let count = count * (mem::size_of::() / mem::size_of::<$ChunkTy>()); + // SAFETY: these are the same bytes that the caller promised were + // ok, just typed as `MaybeUninit`s instead of as `T`s. + // The `if` condition above ensures that we're not violating + // alignment requirements, and that the division is exact so + // that we don't lose any bytes off the end. + return unsafe { swap_nonoverlapping_simple_untyped(x, y, count) }; + } + }; + } + + // Split up the slice into small power-of-two-sized chunks that LLVM is able + // to vectorize (unless it's a special type with more-than-pointer alignment, + // because we don't want to pessimize things like slices of SIMD vectors.) + if mem::align_of::() <= mem::size_of::() + && (!mem::size_of::().is_power_of_two() + || mem::size_of::() > mem::size_of::() * 2) + { + attempt_swap_as_chunks!(usize); + attempt_swap_as_chunks!(u8); + } - // SAFETY: Same preconditions as this function - unsafe { swap_nonoverlapping_simple_untyped(x, y, count) } + // SAFETY: Same preconditions as this function + unsafe { swap_nonoverlapping_simple_untyped(x, y, count) } + } + ) } /// Same behavior and safety conditions as [`swap_nonoverlapping`] diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs index 89b65eefd027e..9f0ab7b3f2977 100644 --- a/library/core/tests/lib.rs +++ b/library/core/tests/lib.rs @@ -16,6 +16,7 @@ #![feature(const_black_box)] #![feature(const_eval_select)] #![feature(const_swap)] +#![feature(const_swap_nonoverlapping)] #![feature(const_trait_impl)] #![feature(core_intrinsics)] #![feature(core_io_borrowed_buf)] diff --git a/library/core/tests/ptr.rs b/library/core/tests/ptr.rs index 454b13a7ee389..e6825d8e39e2c 100644 --- a/library/core/tests/ptr.rs +++ b/library/core/tests/ptr.rs @@ -860,7 +860,10 @@ fn swap_copy_untyped() { } #[test] -fn test_const_copy() { +fn test_const_copy_ptr() { + // `copy` and `copy_nonoverlapping` are thin layers on top of intrinsics. Ensure they correctly + // deal with pointers even when the pointers cross the boundary from one "element" being copied + // to another. const { let ptr1 = &1; let mut ptr2 = &666; @@ -899,21 +902,61 @@ fn test_const_copy() { } #[test] -fn test_const_swap() { +fn test_const_swap_ptr() { + // The `swap` functions are implemented in the library, they are not primitives. + // Only `swap_nonoverlapping` takes a count; pointers that cross multiple elements + // are *not* supported. + // We put the pointer at an odd offset in the type and copy them as an array of bytes, + // which should catch most of the ways that the library implementation can get it wrong. + + #[cfg(target_pointer_width = "32")] + type HalfPtr = i16; + #[cfg(target_pointer_width = "64")] + type HalfPtr = i32; + + #[repr(C, packed)] + #[allow(unused)] + struct S { + f1: HalfPtr, + // Crucially this field is at an offset that is not a multiple of the pointer size. + ptr: &'static i32, + // Make sure the entire type does not have a power-of-2 size: + // make it 3 pointers in size. This used to hit a bug in `swap_nonoverlapping`. + f2: [HalfPtr; 3], + } + + // Ensure the entire thing is usize-aligned, so in principle this + // looks like it could be eligible for a `usize` copying loop. + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + struct A(S); + const { - let mut ptr1 = &1; - let mut ptr2 = &666; + let mut s1 = A(S { ptr: &1, f1: 0, f2: [0; 3] }); + let mut s2 = A(S { ptr: &666, f1: 0, f2: [0; 3] }); - // Swap ptr1 and ptr2, bytewise. `swap` does not take a count - // so the best we can do is use an array. - type T = [u8; mem::size_of::<&i32>()]; + // Swap ptr1 and ptr2, as an array. + type T = [u8; mem::size_of::()]; unsafe { - ptr::swap(ptr::from_mut(&mut ptr1).cast::(), ptr::from_mut(&mut ptr2).cast::()); + ptr::swap(ptr::from_mut(&mut s1).cast::(), ptr::from_mut(&mut s2).cast::()); } // Make sure they still work. - assert!(*ptr1 == 666); - assert!(*ptr2 == 1); + assert!(*s1.0.ptr == 666); + assert!(*s2.0.ptr == 1); + + // Swap them back, again as an array. + unsafe { + ptr::swap_nonoverlapping( + ptr::from_mut(&mut s1).cast::(), + ptr::from_mut(&mut s2).cast::(), + 1, + ); + } + + // Make sure they still work. + assert!(*s1.0.ptr == 1); + assert!(*s2.0.ptr == 666); }; } diff --git a/tests/ui/consts/missing_span_in_backtrace.stderr b/tests/ui/consts/missing_span_in_backtrace.stderr index 72d15702e8913..05ae7305dbc09 100644 --- a/tests/ui/consts/missing_span_in_backtrace.stderr +++ b/tests/ui/consts/missing_span_in_backtrace.stderr @@ -7,6 +7,8 @@ note: inside `std::ptr::read::>>` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: inside `std::ptr::swap_nonoverlapping_simple_untyped::>` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL +note: inside `swap_nonoverlapping::compiletime::>` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: inside `swap_nonoverlapping::>` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: inside `X` @@ -20,6 +22,7 @@ note: inside `X` | |_________^ = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported + = note: this error originates in the macro `$crate::intrinsics::const_eval_select` which comes from the expansion of the macro `const_eval_select` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error From 98cc5a77bdf0b8815de05b1e41620940959b3a45 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Mon, 23 Dec 2024 11:22:29 -0800 Subject: [PATCH 4/5] Belay new reviews for workingjubilee My queue is at-capacity, effectively. --- triagebot.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/triagebot.toml b/triagebot.toml index eefb87aa298f2..da652ef70420a 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -997,6 +997,7 @@ users_on_vacation = [ "jyn514", "celinval", "nnethercote", + "workingjubilee", ] [[assign.warn_non_default_branch.exceptions]] From 92f93f6d1127cd8f2438474ebe4620231f5d5473 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Mon, 23 Dec 2024 21:49:48 +0000 Subject: [PATCH 5/5] Note def descr in NonConstFunctionCall --- compiler/rustc_const_eval/messages.ftl | 2 +- .../rustc_const_eval/src/check_consts/ops.rs | 1 + compiler/rustc_const_eval/src/errors.rs | 1 + .../rustc_error_codes/src/error_codes/E0015.md | 2 +- .../const-super-trait-nightly-disabled.stderr | 2 +- .../const-super-trait-nightly-enabled.stderr | 2 +- .../const-super-trait-stable-disabled.stderr | 2 +- .../const-super-trait-stable-enabled.stderr | 2 +- tests/ui/asm/non-const.rs | 2 +- tests/ui/asm/non-const.stderr | 2 +- tests/ui/borrowck/issue-64453.rs | 2 +- tests/ui/borrowck/issue-64453.stderr | 2 +- tests/ui/const-generics/nested-type.full.stderr | 2 +- tests/ui/const-generics/nested-type.min.stderr | 2 +- tests/ui/const-generics/nested-type.rs | 2 +- tests/ui/consts/const-call.rs | 2 +- tests/ui/consts/const-call.stderr | 2 +- tests/ui/consts/const-eval/format.rs | 6 +++--- tests/ui/consts/const-eval/format.stderr | 6 +++--- .../const-eval/ub-slice-get-unchecked.stderr | 2 +- .../const-extern-fn-call-extern-fn.rs | 4 ++-- .../const-extern-fn-call-extern-fn.stderr | 4 ++-- .../ui/consts/const-fn-not-safe-for-const.stderr | 2 +- tests/ui/consts/control-flow/issue-46843.rs | 2 +- tests/ui/consts/control-flow/issue-46843.stderr | 2 +- tests/ui/consts/issue-16538.stderr | 2 +- tests/ui/consts/issue-32829-2.rs | 6 +++--- tests/ui/consts/issue-32829-2.stderr | 6 +++--- tests/ui/consts/issue-43105.rs | 2 +- tests/ui/consts/issue-43105.stderr | 2 +- .../consts/min_const_fn/bad_const_fn_body_ice.rs | 2 +- .../min_const_fn/bad_const_fn_body_ice.stderr | 2 +- tests/ui/consts/mir_check_nonconst.rs | 2 +- tests/ui/consts/mir_check_nonconst.stderr | 2 +- tests/ui/error-codes/E0010-teach.rs | 2 +- tests/ui/error-codes/E0010-teach.stderr | 2 +- tests/ui/error-codes/E0010.rs | 2 +- tests/ui/error-codes/E0010.stderr | 2 +- tests/ui/error-codes/E0015.rs | 2 +- tests/ui/error-codes/E0015.stderr | 2 +- tests/ui/explicit-tail-calls/constck.rs | 4 ++-- tests/ui/explicit-tail-calls/constck.stderr | 4 ++-- tests/ui/issues/issue-7364.rs | 2 +- tests/ui/issues/issue-7364.stderr | 2 +- tests/ui/resolve/issue-39559-2.stderr | 4 ++-- tests/ui/static/static-mut-not-constant.rs | 2 +- tests/ui/static/static-mut-not-constant.stderr | 2 +- .../static/static-vec-repeat-not-constant.stderr | 2 +- tests/ui/statics/check-values-constraints.rs | 2 +- tests/ui/statics/check-values-constraints.stderr | 16 ++++++++-------- .../call-const-trait-method-pass.stderr | 2 +- .../const-traits/call-generic-in-impl.stderr | 2 +- .../call-generic-method-chain.stderr | 2 +- .../call-generic-method-dup-bound.stderr | 2 +- .../const-traits/call-generic-method-pass.stderr | 2 +- .../const-check-fns-in-const-impl.rs | 2 +- .../const-check-fns-in-const-impl.stderr | 2 +- .../const_closure-const_trait_impl-ice-113381.rs | 2 +- ...st_closure-const_trait_impl-ice-113381.stderr | 2 +- .../derive-const-non-const-type.stderr | 2 +- .../const_derives/derive-const-use.stderr | 6 +++--- .../ice-112822-expected-type-for-param.rs | 2 +- .../ice-112822-expected-type-for-param.stderr | 2 +- .../inline-incorrect-early-bound-in-ctfe.rs | 2 +- .../inline-incorrect-early-bound-in-ctfe.stderr | 2 +- tests/ui/traits/const-traits/issue-79450.rs | 2 +- tests/ui/traits/const-traits/issue-79450.stderr | 2 +- tests/ui/traits/const-traits/issue-88155.rs | 2 +- tests/ui/traits/const-traits/issue-88155.stderr | 2 +- ...non-const-op-const-closure-non-const-outer.rs | 2 +- ...const-op-const-closure-non-const-outer.stderr | 2 +- .../non-const-op-in-closure-in-const.stderr | 2 +- .../const-traits/std-impl-gate.gated.stderr | 2 +- tests/ui/traits/const-traits/std-impl-gate.rs | 2 +- .../const-traits/std-impl-gate.stock.stderr | 2 +- .../const-traits/super-traits-fail-2.nn.stderr | 2 +- .../const-traits/super-traits-fail-2.ny.stderr | 2 +- .../traits/const-traits/super-traits-fail-2.rs | 2 +- .../const-traits/super-traits-fail-3.nnn.stderr | 2 +- .../const-traits/super-traits-fail-3.nny.stderr | 2 +- .../traits/const-traits/super-traits-fail-3.rs | 2 +- .../const-traits/super-traits-fail-3.ynn.stderr | 2 +- .../const-traits/super-traits-fail-3.yny.stderr | 2 +- .../typeck/typeck_type_placeholder_item.stderr | 4 ++-- 84 files changed, 107 insertions(+), 105 deletions(-) diff --git a/compiler/rustc_const_eval/messages.ftl b/compiler/rustc_const_eval/messages.ftl index c31c94495d015..0c2242b810b69 100644 --- a/compiler/rustc_const_eval/messages.ftl +++ b/compiler/rustc_const_eval/messages.ftl @@ -253,7 +253,7 @@ const_eval_non_const_fmt_macro_call = cannot call non-const formatting macro in {const_eval_const_context}s const_eval_non_const_fn_call = - cannot call non-const fn `{$def_path_str}` in {const_eval_const_context}s + cannot call non-const {$def_descr} `{$def_path_str}` in {const_eval_const_context}s const_eval_non_const_impl = impl defined here, but it is not `const` diff --git a/compiler/rustc_const_eval/src/check_consts/ops.rs b/compiler/rustc_const_eval/src/check_consts/ops.rs index afb7900c4b0f2..ebd680ac28a2e 100644 --- a/compiler/rustc_const_eval/src/check_consts/ops.rs +++ b/compiler/rustc_const_eval/src/check_consts/ops.rs @@ -304,6 +304,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> { } _ => ccx.dcx().create_err(errors::NonConstFnCall { span, + def_descr: ccx.tcx.def_descr(callee), def_path_str: ccx.tcx.def_path_str_with_args(callee, args), kind: ccx.const_kind(), }), diff --git a/compiler/rustc_const_eval/src/errors.rs b/compiler/rustc_const_eval/src/errors.rs index 80236ee05b7ff..57534540019bb 100644 --- a/compiler/rustc_const_eval/src/errors.rs +++ b/compiler/rustc_const_eval/src/errors.rs @@ -192,6 +192,7 @@ pub(crate) struct NonConstFnCall { #[primary_span] pub span: Span, pub def_path_str: String, + pub def_descr: &'static str, pub kind: ConstContext, } diff --git a/compiler/rustc_error_codes/src/error_codes/E0015.md b/compiler/rustc_error_codes/src/error_codes/E0015.md index ac78f66adada0..244cc47624388 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0015.md +++ b/compiler/rustc_error_codes/src/error_codes/E0015.md @@ -7,7 +7,7 @@ fn create_some() -> Option { Some(1) } -// error: cannot call non-const fn `create_some` in constants +// error: cannot call non-const function `create_some` in constants const FOO: Option = create_some(); ``` 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 596f7c510be52..82f57864d859e 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 @@ -52,7 +52,7 @@ help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `#[ LL | #[const_trait] trait Bar: ~const Foo {} | ++++++++++++++ -error[E0015]: cannot call non-const fn `::a` in constant functions +error[E0015]: cannot call non-const method `::a` in constant functions --> const-super-trait.rs:10:7 | LL | x.a(); 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 7235278d1bd78..8f4c78ccfa4c2 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 @@ -32,7 +32,7 @@ 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 +error[E0015]: cannot call non-const method `::a` in constant functions --> const-super-trait.rs:10:7 | LL | x.a(); 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 eacdaf5e36909..b7cd7097f4447 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 @@ -50,7 +50,7 @@ note: `Bar` can't be used with `~const` because it isn't annotated with `#[const 7 | trait Bar: ~const Foo {} | ^^^^^^^^^^^^^^^^^^^^^ -error[E0015]: cannot call non-const fn `::a` in constant functions +error[E0015]: cannot call non-const method `::a` in constant functions --> const-super-trait.rs:10:7 | 10 | x.a(); 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 9ddec6e422c06..4c59d870671d0 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 @@ -40,7 +40,7 @@ note: `Bar` can't be used with `~const` because it isn't annotated with `#[const 7 | trait Bar: ~const Foo {} | ^^^^^^^^^^^^^^^^^^^^^ -error[E0015]: cannot call non-const fn `::a` in constant functions +error[E0015]: cannot call non-const method `::a` in constant functions --> const-super-trait.rs:10:7 | 10 | x.a(); diff --git a/tests/ui/asm/non-const.rs b/tests/ui/asm/non-const.rs index 63c4656322610..dc9317b90b117 100644 --- a/tests/ui/asm/non-const.rs +++ b/tests/ui/asm/non-const.rs @@ -8,4 +8,4 @@ fn main() {} fn non_const_fn(x: i32) -> i32 { x } global_asm!("/* {} */", const non_const_fn(0)); -//~^ERROR: cannot call non-const fn +//~^ERROR: cannot call non-const function diff --git a/tests/ui/asm/non-const.stderr b/tests/ui/asm/non-const.stderr index 5fae2ac984378..eac4fe841bffd 100644 --- a/tests/ui/asm/non-const.stderr +++ b/tests/ui/asm/non-const.stderr @@ -1,4 +1,4 @@ -error[E0015]: cannot call non-const fn `non_const_fn` in constants +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)); diff --git a/tests/ui/borrowck/issue-64453.rs b/tests/ui/borrowck/issue-64453.rs index 5f1f35d6ca9bb..587bf0e80f50c 100644 --- a/tests/ui/borrowck/issue-64453.rs +++ b/tests/ui/borrowck/issue-64453.rs @@ -2,7 +2,7 @@ struct Project; struct Value; static settings_dir: String = format!(""); -//~^ ERROR cannot call non-const fn +//~^ ERROR cannot call non-const function fn from_string(_: String) -> Value { Value diff --git a/tests/ui/borrowck/issue-64453.stderr b/tests/ui/borrowck/issue-64453.stderr index 98b05ead64918..8ec9a10f09f4d 100644 --- a/tests/ui/borrowck/issue-64453.stderr +++ b/tests/ui/borrowck/issue-64453.stderr @@ -1,4 +1,4 @@ -error[E0015]: cannot call non-const fn `format` in statics +error[E0015]: cannot call non-const function `format` in statics --> $DIR/issue-64453.rs:4:31 | LL | static settings_dir: String = format!(""); diff --git a/tests/ui/const-generics/nested-type.full.stderr b/tests/ui/const-generics/nested-type.full.stderr index 04dc84ea3cf5a..e5a1f230380d3 100644 --- a/tests/ui/const-generics/nested-type.full.stderr +++ b/tests/ui/const-generics/nested-type.full.stderr @@ -1,4 +1,4 @@ -error[E0015]: cannot call non-const fn `Foo::{constant#0}::Foo::<17>::value` in constants +error[E0015]: cannot call non-const associated function `Foo::{constant#0}::Foo::<17>::value` in constants --> $DIR/nested-type.rs:15:5 | LL | Foo::<17>::value() diff --git a/tests/ui/const-generics/nested-type.min.stderr b/tests/ui/const-generics/nested-type.min.stderr index cdc0b9807d937..8282acd4ea7b1 100644 --- a/tests/ui/const-generics/nested-type.min.stderr +++ b/tests/ui/const-generics/nested-type.min.stderr @@ -1,4 +1,4 @@ -error[E0015]: cannot call non-const fn `Foo::{constant#0}::Foo::<17>::value` in constants +error[E0015]: cannot call non-const associated function `Foo::{constant#0}::Foo::<17>::value` in constants --> $DIR/nested-type.rs:15:5 | LL | Foo::<17>::value() diff --git a/tests/ui/const-generics/nested-type.rs b/tests/ui/const-generics/nested-type.rs index a9d106237b399..ddd84d472bfa1 100644 --- a/tests/ui/const-generics/nested-type.rs +++ b/tests/ui/const-generics/nested-type.rs @@ -13,7 +13,7 @@ struct Foo::value() - //~^ ERROR cannot call non-const fn + //~^ ERROR cannot call non-const associated function }]>; //[min]~^^^^^^^^^^^^ ERROR `[u8; { diff --git a/tests/ui/consts/const-call.rs b/tests/ui/consts/const-call.rs index 28e89559fe538..851b66f76238c 100644 --- a/tests/ui/consts/const-call.rs +++ b/tests/ui/consts/const-call.rs @@ -4,5 +4,5 @@ fn f(x: usize) -> usize { fn main() { let _ = [0; f(2)]; - //~^ ERROR cannot call non-const fn + //~^ ERROR cannot call non-const function } diff --git a/tests/ui/consts/const-call.stderr b/tests/ui/consts/const-call.stderr index 4e7098a5c8fa6..b9dcf5addb519 100644 --- a/tests/ui/consts/const-call.stderr +++ b/tests/ui/consts/const-call.stderr @@ -1,4 +1,4 @@ -error[E0015]: cannot call non-const fn `f` in constants +error[E0015]: cannot call non-const function `f` in constants --> $DIR/const-call.rs:6:17 | LL | let _ = [0; f(2)]; diff --git a/tests/ui/consts/const-eval/format.rs b/tests/ui/consts/const-eval/format.rs index b12df824a3377..e56d15e935bc5 100644 --- a/tests/ui/consts/const-eval/format.rs +++ b/tests/ui/consts/const-eval/format.rs @@ -1,14 +1,14 @@ const fn failure() { panic!("{:?}", 0); //~^ ERROR cannot call non-const formatting macro in constant functions - //~| ERROR cannot call non-const fn `Arguments::<'_>::new_v1::<1, 1>` in constant functions + //~| ERROR cannot call non-const associated function `Arguments::<'_>::new_v1::<1, 1>` in constant functions } const fn print() { println!("{:?}", 0); //~^ ERROR cannot call non-const formatting macro in constant functions - //~| ERROR cannot call non-const fn `Arguments::<'_>::new_v1::<2, 1>` in constant functions - //~| ERROR cannot call non-const fn `_print` in constant functions + //~| ERROR cannot call non-const associated function `Arguments::<'_>::new_v1::<2, 1>` in constant functions + //~| ERROR cannot call non-const function `_print` in constant functions } fn main() {} diff --git a/tests/ui/consts/const-eval/format.stderr b/tests/ui/consts/const-eval/format.stderr index ce3f9f2190e5a..25ed44e0f3382 100644 --- a/tests/ui/consts/const-eval/format.stderr +++ b/tests/ui/consts/const-eval/format.stderr @@ -7,7 +7,7 @@ LL | panic!("{:?}", 0); = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = note: this error originates in the macro `$crate::const_format_args` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0015]: cannot call non-const fn `Arguments::<'_>::new_v1::<1, 1>` in constant functions +error[E0015]: cannot call non-const associated function `Arguments::<'_>::new_v1::<1, 1>` in constant functions --> $DIR/format.rs:2:5 | LL | panic!("{:?}", 0); @@ -25,7 +25,7 @@ LL | println!("{:?}", 0); = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0015]: cannot call non-const fn `Arguments::<'_>::new_v1::<2, 1>` in constant functions +error[E0015]: cannot call non-const associated function `Arguments::<'_>::new_v1::<2, 1>` in constant functions --> $DIR/format.rs:8:5 | LL | println!("{:?}", 0); @@ -34,7 +34,7 @@ LL | println!("{:?}", 0); = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0015]: cannot call non-const fn `_print` in constant functions +error[E0015]: cannot call non-const function `_print` in constant functions --> $DIR/format.rs:8:5 | LL | println!("{:?}", 0); diff --git a/tests/ui/consts/const-eval/ub-slice-get-unchecked.stderr b/tests/ui/consts/const-eval/ub-slice-get-unchecked.stderr index 94aa3ee4d7a1f..6e428079afe8e 100644 --- a/tests/ui/consts/const-eval/ub-slice-get-unchecked.stderr +++ b/tests/ui/consts/const-eval/ub-slice-get-unchecked.stderr @@ -1,4 +1,4 @@ -error[E0015]: cannot call non-const fn `core::slice::::get_unchecked::>` in constants +error[E0015]: cannot call non-const method `core::slice::::get_unchecked::>` in constants --> $DIR/ub-slice-get-unchecked.rs:7:29 | LL | const B: &[()] = unsafe { A.get_unchecked(3..1) }; diff --git a/tests/ui/consts/const-extern-fn/const-extern-fn-call-extern-fn.rs b/tests/ui/consts/const-extern-fn/const-extern-fn-call-extern-fn.rs index 31c15400f84a4..0b475087d550a 100644 --- a/tests/ui/consts/const-extern-fn/const-extern-fn-call-extern-fn.rs +++ b/tests/ui/consts/const-extern-fn/const-extern-fn-call-extern-fn.rs @@ -5,7 +5,7 @@ extern "C" { const extern "C" fn bar() { unsafe { regular_in_block(); - //~^ ERROR: cannot call non-const fn + //~^ ERROR: cannot call non-const function } } @@ -14,7 +14,7 @@ extern "C" fn regular() {} const extern "C" fn foo() { unsafe { regular(); - //~^ ERROR: cannot call non-const fn + //~^ ERROR: cannot call non-const function } } 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 5d37f524e03db..1fa881cf42b6a 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,4 +1,4 @@ -error[E0015]: cannot call non-const fn `regular_in_block` in constant functions +error[E0015]: cannot call non-const function `regular_in_block` in constant functions --> $DIR/const-extern-fn-call-extern-fn.rs:7:9 | LL | regular_in_block(); @@ -6,7 +6,7 @@ LL | regular_in_block(); | = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants -error[E0015]: cannot call non-const fn `regular` in constant functions +error[E0015]: cannot call non-const function `regular` in constant functions --> $DIR/const-extern-fn-call-extern-fn.rs:16:9 | LL | regular(); 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 674e05a0ba99a..e8f0566e73dd8 100644 --- a/tests/ui/consts/const-fn-not-safe-for-const.stderr +++ b/tests/ui/consts/const-fn-not-safe-for-const.stderr @@ -1,4 +1,4 @@ -error[E0015]: cannot call non-const fn `random` in constant functions +error[E0015]: cannot call non-const function `random` in constant functions --> $DIR/const-fn-not-safe-for-const.rs:14:5 | LL | random() diff --git a/tests/ui/consts/control-flow/issue-46843.rs b/tests/ui/consts/control-flow/issue-46843.rs index ddddc8505c635..fd6366d3c18cf 100644 --- a/tests/ui/consts/control-flow/issue-46843.rs +++ b/tests/ui/consts/control-flow/issue-46843.rs @@ -8,7 +8,7 @@ fn non_const() -> Thing { } pub const Q: i32 = match non_const() { - //~^ ERROR cannot call non-const fn + //~^ ERROR cannot call non-const function Thing::This => 1, Thing::That => 0 }; diff --git a/tests/ui/consts/control-flow/issue-46843.stderr b/tests/ui/consts/control-flow/issue-46843.stderr index 69bf78839be77..42eb035647c0e 100644 --- a/tests/ui/consts/control-flow/issue-46843.stderr +++ b/tests/ui/consts/control-flow/issue-46843.stderr @@ -1,4 +1,4 @@ -error[E0015]: cannot call non-const fn `non_const` in constants +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() { diff --git a/tests/ui/consts/issue-16538.stderr b/tests/ui/consts/issue-16538.stderr index c4f5364b4d784..8bd11541a7dff 100644 --- a/tests/ui/consts/issue-16538.stderr +++ b/tests/ui/consts/issue-16538.stderr @@ -1,4 +1,4 @@ -error[E0015]: cannot call non-const fn `Y::foo` in statics +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); diff --git a/tests/ui/consts/issue-32829-2.rs b/tests/ui/consts/issue-32829-2.rs index d70b5a8c4e13a..c7ad0979293d7 100644 --- a/tests/ui/consts/issue-32829-2.rs +++ b/tests/ui/consts/issue-32829-2.rs @@ -8,7 +8,7 @@ const bad : u32 = { const bad_two : u32 = { { invalid(); - //~^ ERROR: cannot call non-const fn `invalid` + //~^ ERROR: cannot call non-const function `invalid` 0 } }; @@ -30,7 +30,7 @@ static bad_four : u32 = { static bad_five : u32 = { { invalid(); - //~^ ERROR: cannot call non-const fn `invalid` + //~^ ERROR: cannot call non-const function `invalid` 0 } }; @@ -52,7 +52,7 @@ static mut bad_seven : u32 = { static mut bad_eight : u32 = { { invalid(); - //~^ ERROR: cannot call non-const fn `invalid` + //~^ ERROR: cannot call non-const function `invalid` 0 } }; diff --git a/tests/ui/consts/issue-32829-2.stderr b/tests/ui/consts/issue-32829-2.stderr index bd0b8c15b558d..eedd9d34e550e 100644 --- a/tests/ui/consts/issue-32829-2.stderr +++ b/tests/ui/consts/issue-32829-2.stderr @@ -1,4 +1,4 @@ -error[E0015]: cannot call non-const fn `invalid` in constants +error[E0015]: cannot call non-const function `invalid` in constants --> $DIR/issue-32829-2.rs:10:9 | LL | invalid(); @@ -6,7 +6,7 @@ LL | invalid(); | = note: calls in constants are limited to constant functions, tuple structs and tuple variants -error[E0015]: cannot call non-const fn `invalid` in statics +error[E0015]: cannot call non-const function `invalid` in statics --> $DIR/issue-32829-2.rs:32:9 | LL | invalid(); @@ -15,7 +15,7 @@ LL | 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 fn `invalid` in statics +error[E0015]: cannot call non-const function `invalid` in statics --> $DIR/issue-32829-2.rs:54:9 | LL | invalid(); diff --git a/tests/ui/consts/issue-43105.rs b/tests/ui/consts/issue-43105.rs index a4ee34c0532f3..738b73416e0d0 100644 --- a/tests/ui/consts/issue-43105.rs +++ b/tests/ui/consts/issue-43105.rs @@ -1,7 +1,7 @@ fn xyz() -> u8 { 42 } const NUM: u8 = xyz(); -//~^ ERROR cannot call non-const fn +//~^ ERROR cannot call non-const function fn main() { match 1 { diff --git a/tests/ui/consts/issue-43105.stderr b/tests/ui/consts/issue-43105.stderr index 0e08feb58de9b..c030c0f5fcdec 100644 --- a/tests/ui/consts/issue-43105.stderr +++ b/tests/ui/consts/issue-43105.stderr @@ -1,4 +1,4 @@ -error[E0015]: cannot call non-const fn `xyz` in constants +error[E0015]: cannot call non-const function `xyz` in constants --> $DIR/issue-43105.rs:3:17 | LL | const NUM: u8 = xyz(); diff --git a/tests/ui/consts/min_const_fn/bad_const_fn_body_ice.rs b/tests/ui/consts/min_const_fn/bad_const_fn_body_ice.rs index 258997597ea9d..6a6b0e666e1c3 100644 --- a/tests/ui/consts/min_const_fn/bad_const_fn_body_ice.rs +++ b/tests/ui/consts/min_const_fn/bad_const_fn_body_ice.rs @@ -1,7 +1,7 @@ const fn foo(a: i32) -> Vec { vec![1, 2, 3] //~^ ERROR allocations are not allowed - //~| ERROR cannot call non-const fn + //~| ERROR cannot call non-const method } fn main() {} 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 74234108911dd..8e52a7aa35e1e 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 @@ -6,7 +6,7 @@ LL | vec![1, 2, 3] | = 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 fn `slice::::into_vec::` in constant functions +error[E0015]: cannot call non-const method `slice::::into_vec::` in constant functions --> $DIR/bad_const_fn_body_ice.rs:2:5 | LL | vec![1, 2, 3] diff --git a/tests/ui/consts/mir_check_nonconst.rs b/tests/ui/consts/mir_check_nonconst.rs index b6f34b922fae5..eede36bd6ed81 100644 --- a/tests/ui/consts/mir_check_nonconst.rs +++ b/tests/ui/consts/mir_check_nonconst.rs @@ -6,6 +6,6 @@ fn bar() -> Foo { } static foo: Foo = bar(); -//~^ ERROR cannot call non-const fn +//~^ ERROR cannot call non-const function fn main() {} diff --git a/tests/ui/consts/mir_check_nonconst.stderr b/tests/ui/consts/mir_check_nonconst.stderr index 95d64622ad7a4..e930fa2103d5d 100644 --- a/tests/ui/consts/mir_check_nonconst.stderr +++ b/tests/ui/consts/mir_check_nonconst.stderr @@ -1,4 +1,4 @@ -error[E0015]: cannot call non-const fn `bar` in statics +error[E0015]: cannot call non-const function `bar` in statics --> $DIR/mir_check_nonconst.rs:8:19 | LL | static foo: Foo = bar(); diff --git a/tests/ui/error-codes/E0010-teach.rs b/tests/ui/error-codes/E0010-teach.rs index 146e68df14a87..0eef24783873c 100644 --- a/tests/ui/error-codes/E0010-teach.rs +++ b/tests/ui/error-codes/E0010-teach.rs @@ -3,5 +3,5 @@ #![allow(warnings)] const CON: Vec = vec![1, 2, 3]; //~ ERROR E0010 -//~| ERROR cannot call non-const fn +//~| ERROR cannot call non-const method fn main() {} diff --git a/tests/ui/error-codes/E0010-teach.stderr b/tests/ui/error-codes/E0010-teach.stderr index 37a9892ccbf49..82bbe01aef792 100644 --- a/tests/ui/error-codes/E0010-teach.stderr +++ b/tests/ui/error-codes/E0010-teach.stderr @@ -7,7 +7,7 @@ LL | const CON: Vec = vec![1, 2, 3]; = note: The runtime heap is not yet available at compile-time, so no runtime heap allocations can be created. = 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 fn `slice::::into_vec::` in constants +error[E0015]: cannot call non-const method `slice::::into_vec::` in constants --> $DIR/E0010-teach.rs:5:23 | LL | const CON: Vec = vec![1, 2, 3]; diff --git a/tests/ui/error-codes/E0010.rs b/tests/ui/error-codes/E0010.rs index 11721efffcb5f..edb96714dd320 100644 --- a/tests/ui/error-codes/E0010.rs +++ b/tests/ui/error-codes/E0010.rs @@ -1,5 +1,5 @@ #![allow(warnings)] const CON: Vec = vec![1, 2, 3]; //~ ERROR E0010 -//~| ERROR cannot call non-const fn +//~| ERROR cannot call non-const method fn main() {} diff --git a/tests/ui/error-codes/E0010.stderr b/tests/ui/error-codes/E0010.stderr index 0894722242260..87b722b5f6566 100644 --- a/tests/ui/error-codes/E0010.stderr +++ b/tests/ui/error-codes/E0010.stderr @@ -6,7 +6,7 @@ LL | const CON: Vec = vec![1, 2, 3]; | = 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 fn `slice::::into_vec::` in constants +error[E0015]: cannot call non-const method `slice::::into_vec::` in constants --> $DIR/E0010.rs:3:23 | LL | const CON: Vec = vec![1, 2, 3]; diff --git a/tests/ui/error-codes/E0015.rs b/tests/ui/error-codes/E0015.rs index b0211358d8166..7a80308d7bbab 100644 --- a/tests/ui/error-codes/E0015.rs +++ b/tests/ui/error-codes/E0015.rs @@ -3,6 +3,6 @@ fn create_some() -> Option { } const FOO: Option = create_some(); -//~^ ERROR cannot call non-const fn `create_some` in constants [E0015] +//~^ ERROR cannot call non-const function `create_some` in constants [E0015] fn main() {} diff --git a/tests/ui/error-codes/E0015.stderr b/tests/ui/error-codes/E0015.stderr index 9d892a3e0985d..0c983d2843492 100644 --- a/tests/ui/error-codes/E0015.stderr +++ b/tests/ui/error-codes/E0015.stderr @@ -1,4 +1,4 @@ -error[E0015]: cannot call non-const fn `create_some` in constants +error[E0015]: cannot call non-const function `create_some` in constants --> $DIR/E0015.rs:5:25 | LL | const FOO: Option = create_some(); diff --git a/tests/ui/explicit-tail-calls/constck.rs b/tests/ui/explicit-tail-calls/constck.rs index 36fc3ef6f995b..4179fe8caf362 100644 --- a/tests/ui/explicit-tail-calls/constck.rs +++ b/tests/ui/explicit-tail-calls/constck.rs @@ -4,14 +4,14 @@ const fn f() { if false { become not_const(); - //~^ error: cannot call non-const fn `not_const` in constant functions + //~^ error: cannot call non-const function `not_const` in constant functions } } const fn g((): ()) { if false { become yes_const(not_const()); - //~^ error: cannot call non-const fn `not_const` in constant functions + //~^ error: cannot call non-const function `not_const` in constant functions } } diff --git a/tests/ui/explicit-tail-calls/constck.stderr b/tests/ui/explicit-tail-calls/constck.stderr index d9967c45fa03c..c223d273b383f 100644 --- a/tests/ui/explicit-tail-calls/constck.stderr +++ b/tests/ui/explicit-tail-calls/constck.stderr @@ -1,4 +1,4 @@ -error[E0015]: cannot call non-const fn `not_const` in constant functions +error[E0015]: cannot call non-const function `not_const` in constant functions --> $DIR/constck.rs:6:16 | LL | become not_const(); @@ -6,7 +6,7 @@ LL | become not_const(); | = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants -error[E0015]: cannot call non-const fn `not_const` in constant functions +error[E0015]: cannot call non-const function `not_const` in constant functions --> $DIR/constck.rs:13:26 | LL | become yes_const(not_const()); diff --git a/tests/ui/issues/issue-7364.rs b/tests/ui/issues/issue-7364.rs index 0608f902fde08..4ce9beb68cd3f 100644 --- a/tests/ui/issues/issue-7364.rs +++ b/tests/ui/issues/issue-7364.rs @@ -3,6 +3,6 @@ use std::cell::RefCell; // Regression test for issue 7364 static boxed: Box> = Box::new(RefCell::new(0)); //~^ ERROR `RefCell` cannot be shared between threads safely [E0277] -//~| ERROR cannot call non-const fn +//~| ERROR cannot call non-const associated function fn main() { } diff --git a/tests/ui/issues/issue-7364.stderr b/tests/ui/issues/issue-7364.stderr index 65ec1d750537a..a47a90c90ce16 100644 --- a/tests/ui/issues/issue-7364.stderr +++ b/tests/ui/issues/issue-7364.stderr @@ -11,7 +11,7 @@ note: required because it appears within the type `Box>` --> $SRC_DIR/alloc/src/boxed.rs:LL:COL = note: shared static variables must have a type that implements `Sync` -error[E0015]: cannot call non-const fn `Box::>::new` in statics +error[E0015]: cannot call non-const associated function `Box::>::new` in statics --> $DIR/issue-7364.rs:4:37 | LL | static boxed: Box> = Box::new(RefCell::new(0)); diff --git a/tests/ui/resolve/issue-39559-2.stderr b/tests/ui/resolve/issue-39559-2.stderr index ea27e7bd2508f..f6e6917d01e6d 100644 --- a/tests/ui/resolve/issue-39559-2.stderr +++ b/tests/ui/resolve/issue-39559-2.stderr @@ -1,4 +1,4 @@ -error[E0015]: cannot call non-const fn `::dim` in constants +error[E0015]: cannot call non-const associated function `::dim` in constants --> $DIR/issue-39559-2.rs:14:24 | LL | let array: [usize; Dim3::dim()] @@ -6,7 +6,7 @@ LL | let array: [usize; Dim3::dim()] | = note: calls in constants are limited to constant functions, tuple structs and tuple variants -error[E0015]: cannot call non-const fn `::dim` in constants +error[E0015]: cannot call non-const associated function `::dim` in constants --> $DIR/issue-39559-2.rs:16:15 | LL | = [0; Dim3::dim()]; diff --git a/tests/ui/static/static-mut-not-constant.rs b/tests/ui/static/static-mut-not-constant.rs index d501e5c295657..3830b46828707 100644 --- a/tests/ui/static/static-mut-not-constant.rs +++ b/tests/ui/static/static-mut-not-constant.rs @@ -1,4 +1,4 @@ static mut a: Box = Box::new(3); -//~^ ERROR cannot call non-const fn +//~^ ERROR cannot call non-const associated function fn main() {} diff --git a/tests/ui/static/static-mut-not-constant.stderr b/tests/ui/static/static-mut-not-constant.stderr index 46dc175cb2982..f28ea0b1689ab 100644 --- a/tests/ui/static/static-mut-not-constant.stderr +++ b/tests/ui/static/static-mut-not-constant.stderr @@ -1,4 +1,4 @@ -error[E0015]: cannot call non-const fn `Box::::new` in statics +error[E0015]: cannot call non-const associated function `Box::::new` in statics --> $DIR/static-mut-not-constant.rs:1:28 | LL | static mut a: Box = Box::new(3); diff --git a/tests/ui/static/static-vec-repeat-not-constant.stderr b/tests/ui/static/static-vec-repeat-not-constant.stderr index a3b930323d5b2..e6ff199ae0198 100644 --- a/tests/ui/static/static-vec-repeat-not-constant.stderr +++ b/tests/ui/static/static-vec-repeat-not-constant.stderr @@ -1,4 +1,4 @@ -error[E0015]: cannot call non-const fn `foo` in statics +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]; diff --git a/tests/ui/statics/check-values-constraints.rs b/tests/ui/statics/check-values-constraints.rs index 005a77988956e..9df76b5c1497f 100644 --- a/tests/ui/statics/check-values-constraints.rs +++ b/tests/ui/statics/check-values-constraints.rs @@ -89,7 +89,7 @@ static mut STATIC13: SafeStruct = static mut STATIC14: SafeStruct = SafeStruct { field1: SafeEnum::Variant1, - field2: SafeEnum::Variant4("str".to_string()), //~ ERROR cannot call non-const fn + field2: SafeEnum::Variant4("str".to_string()), //~ ERROR cannot call non-const method }; static STATIC15: &'static [Vec] = &[ diff --git a/tests/ui/statics/check-values-constraints.stderr b/tests/ui/statics/check-values-constraints.stderr index b4ee34530d3bd..eb2d37d297e9f 100644 --- a/tests/ui/statics/check-values-constraints.stderr +++ b/tests/ui/statics/check-values-constraints.stderr @@ -19,7 +19,7 @@ LL | static STATIC11: Vec = vec![MyOwned]; | = 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 fn `slice::::into_vec::` in statics +error[E0015]: cannot call non-const method `slice::::into_vec::` in statics --> $DIR/check-values-constraints.rs:81:33 | LL | static STATIC11: Vec = vec![MyOwned]; @@ -29,7 +29,7 @@ LL | static STATIC11: Vec = vec![MyOwned]; = 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 fn `::to_string` in statics +error[E0015]: cannot call non-const method `::to_string` in statics --> $DIR/check-values-constraints.rs:92:38 | LL | field2: SafeEnum::Variant4("str".to_string()), @@ -46,7 +46,7 @@ LL | vec![MyOwned], | = 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 fn `slice::::into_vec::` in statics +error[E0015]: cannot call non-const method `slice::::into_vec::` in statics --> $DIR/check-values-constraints.rs:96:5 | LL | vec![MyOwned], @@ -64,7 +64,7 @@ LL | vec![MyOwned], | = 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 fn `slice::::into_vec::` in statics +error[E0015]: cannot call non-const method `slice::::into_vec::` in statics --> $DIR/check-values-constraints.rs:98:5 | LL | vec![MyOwned], @@ -82,7 +82,7 @@ LL | &vec![MyOwned], | = 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 fn `slice::::into_vec::` in statics +error[E0015]: cannot call non-const method `slice::::into_vec::` in statics --> $DIR/check-values-constraints.rs:103:6 | LL | &vec![MyOwned], @@ -100,7 +100,7 @@ LL | &vec![MyOwned], | = 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 fn `slice::::into_vec::` in statics +error[E0015]: cannot call non-const method `slice::::into_vec::` in statics --> $DIR/check-values-constraints.rs:105:6 | LL | &vec![MyOwned], @@ -118,7 +118,7 @@ LL | static STATIC19: Vec = vec![3]; | = 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 fn `slice::::into_vec::` in statics +error[E0015]: cannot call non-const method `slice::::into_vec::` in statics --> $DIR/check-values-constraints.rs:111:31 | LL | static STATIC19: Vec = vec![3]; @@ -136,7 +136,7 @@ LL | static x: Vec = vec![3]; | = 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 fn `slice::::into_vec::` in statics +error[E0015]: cannot call non-const method `slice::::into_vec::` in statics --> $DIR/check-values-constraints.rs:117:32 | LL | static x: Vec = vec![3]; 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 ef494bde98ce3..7746f103ac368 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 @@ -7,7 +7,7 @@ LL | impl const PartialEq for Int { = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` = note: adding a non-const method body in the future would be a breaking change -error[E0015]: cannot call non-const fn `::eq` in constant functions +error[E0015]: cannot call non-const method `::eq` in constant functions --> $DIR/call-const-trait-method-pass.rs:20:15 | LL | !self.eq(other) 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 58d0997f5a341..a45dfd95b4a46 100644 --- a/tests/ui/traits/const-traits/call-generic-in-impl.stderr +++ b/tests/ui/traits/const-traits/call-generic-in-impl.stderr @@ -17,7 +17,7 @@ note: `PartialEq` can't be used with `~const` because it isn't annotated with `# --> $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 +error[E0015]: cannot call non-const method `::eq` in constant functions --> $DIR/call-generic-in-impl.rs:12:9 | LL | PartialEq::eq(self, other) 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 d7a2a18649400..40b4f14733f0c 100644 --- a/tests/ui/traits/const-traits/call-generic-method-chain.stderr +++ b/tests/ui/traits/const-traits/call-generic-method-chain.stderr @@ -53,7 +53,7 @@ LL | *t == *t | = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants -error[E0015]: cannot call non-const fn `::eq` in constant functions +error[E0015]: cannot call non-const method `::eq` in constant functions --> $DIR/call-generic-method-chain.rs:16:15 | LL | !self.eq(other) 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 90465d0a5b2db..c74f5cf786c1e 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 @@ -53,7 +53,7 @@ LL | *t == *t | = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants -error[E0015]: cannot call non-const fn `::eq` in constant functions +error[E0015]: cannot call non-const method `::eq` in constant functions --> $DIR/call-generic-method-dup-bound.rs:14:15 | LL | !self.eq(other) 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 a7626a4e99d26..1a33ff5ab450f 100644 --- a/tests/ui/traits/const-traits/call-generic-method-pass.stderr +++ b/tests/ui/traits/const-traits/call-generic-method-pass.stderr @@ -34,7 +34,7 @@ LL | *t == *t | = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants -error[E0015]: cannot call non-const fn `::eq` in constant functions +error[E0015]: cannot call non-const method `::eq` in constant functions --> $DIR/call-generic-method-pass.rs:16:15 | LL | !self.eq(other) diff --git a/tests/ui/traits/const-traits/const-check-fns-in-const-impl.rs b/tests/ui/traits/const-traits/const-check-fns-in-const-impl.rs index 0330ed5ca8b25..f7686ea6139b5 100644 --- a/tests/ui/traits/const-traits/const-check-fns-in-const-impl.rs +++ b/tests/ui/traits/const-traits/const-check-fns-in-const-impl.rs @@ -12,7 +12,7 @@ fn non_const() {} impl const T for S { fn foo() { non_const() } - //~^ ERROR cannot call non-const fn + //~^ ERROR cannot call non-const function } fn main() {} 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 d111a9d56390f..599a5503b0f33 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 @@ -1,4 +1,4 @@ -error[E0015]: cannot call non-const fn `non_const` in constant functions +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() } diff --git a/tests/ui/traits/const-traits/const_closure-const_trait_impl-ice-113381.rs b/tests/ui/traits/const-traits/const_closure-const_trait_impl-ice-113381.rs index 877249135cd97..92427039b4333 100644 --- a/tests/ui/traits/const-traits/const_closure-const_trait_impl-ice-113381.rs +++ b/tests/ui/traits/const-traits/const_closure-const_trait_impl-ice-113381.rs @@ -12,6 +12,6 @@ impl Foo for () { fn main() { (const || { (()).foo() })(); - //~^ ERROR: cannot call non-const fn `<() as Foo>::foo` in constant functions + //~^ ERROR: cannot call non-const method `<() as Foo>::foo` in constant functions // FIXME(const_trait_impl) this should probably say constant closures } diff --git a/tests/ui/traits/const-traits/const_closure-const_trait_impl-ice-113381.stderr b/tests/ui/traits/const-traits/const_closure-const_trait_impl-ice-113381.stderr index 243e94087bbdd..c08642ba5a31c 100644 --- a/tests/ui/traits/const-traits/const_closure-const_trait_impl-ice-113381.stderr +++ b/tests/ui/traits/const-traits/const_closure-const_trait_impl-ice-113381.stderr @@ -1,4 +1,4 @@ -error[E0015]: cannot call non-const fn `<() as Foo>::foo` in constant functions +error[E0015]: cannot call non-const method `<() as Foo>::foo` in constant functions --> $DIR/const_closure-const_trait_impl-ice-113381.rs:14:22 | LL | (const || { (()).foo() })(); 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 8a6401afcf19f..64564de2a0ce4 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 @@ -8,7 +8,7 @@ LL | #[derive_const(Default)] = note: adding a non-const method body in the future would be a breaking change = note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0015]: cannot call non-const fn `::default` in constant functions +error[E0015]: cannot call non-const associated function `::default` in constant functions --> $DIR/derive-const-non-const-type.rs:11:14 | LL | #[derive_const(Default)] 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 3b06f4d801a41..9ad3b0c1617a5 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 @@ -48,7 +48,7 @@ LL | #[derive_const(Default, PartialEq)] = 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[E0015]: cannot call non-const fn `::default` in constants +error[E0015]: cannot call non-const associated function `::default` in constants --> $DIR/derive-const-use.rs:18:35 | LL | const _: () = assert!(S((), A) == S::default()); @@ -64,7 +64,7 @@ LL | const _: () = assert!(S((), A) == S::default()); | = note: calls in constants are limited to constant functions, tuple structs and tuple variants -error[E0015]: cannot call non-const fn `<() as Default>::default` in constant functions +error[E0015]: cannot call non-const associated function `<() as Default>::default` in constant functions --> $DIR/derive-const-use.rs:16:14 | LL | #[derive_const(Default, PartialEq)] @@ -75,7 +75,7 @@ LL | pub struct S((), A); = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0015]: cannot call non-const fn `::default` in constant functions +error[E0015]: cannot call non-const associated function `::default` in constant functions --> $DIR/derive-const-use.rs:16:18 | LL | #[derive_const(Default, PartialEq)] diff --git a/tests/ui/traits/const-traits/ice-112822-expected-type-for-param.rs b/tests/ui/traits/const-traits/ice-112822-expected-type-for-param.rs index 8ff15dd09cc0a..4cb013b932309 100644 --- a/tests/ui/traits/const-traits/ice-112822-expected-type-for-param.rs +++ b/tests/ui/traits/const-traits/ice-112822-expected-type-for-param.rs @@ -10,7 +10,7 @@ const fn test() -> impl ~const Fn() { match sl { [first, remainder @ ..] => { assert_eq!(first, &b'f'); - //~^ ERROR cannot call non-const fn + //~^ ERROR cannot call non-const function //~| ERROR cannot call non-const operator } [] => panic!(), diff --git a/tests/ui/traits/const-traits/ice-112822-expected-type-for-param.stderr b/tests/ui/traits/const-traits/ice-112822-expected-type-for-param.stderr index 280f8807f5fda..8d9371bf9f692 100644 --- a/tests/ui/traits/const-traits/ice-112822-expected-type-for-param.stderr +++ b/tests/ui/traits/const-traits/ice-112822-expected-type-for-param.stderr @@ -46,7 +46,7 @@ LL | assert_eq!(first, &b'f'); = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0015]: cannot call non-const fn `core::panicking::assert_failed::<&u8, &u8>` in constant functions +error[E0015]: cannot call non-const function `core::panicking::assert_failed::<&u8, &u8>` in constant functions --> $DIR/ice-112822-expected-type-for-param.rs:12:17 | LL | assert_eq!(first, &b'f'); diff --git a/tests/ui/traits/const-traits/inline-incorrect-early-bound-in-ctfe.rs b/tests/ui/traits/const-traits/inline-incorrect-early-bound-in-ctfe.rs index 86cb38e0bcfd5..da533d5e321eb 100644 --- a/tests/ui/traits/const-traits/inline-incorrect-early-bound-in-ctfe.rs +++ b/tests/ui/traits/const-traits/inline-incorrect-early-bound-in-ctfe.rs @@ -24,7 +24,7 @@ impl Trait for () { const fn foo() { ().foo(); - //~^ ERROR cannot call non-const fn `<() as Trait>::foo` in constant functions + //~^ ERROR cannot call non-const method `<() as Trait>::foo` in constant functions } const UWU: () = foo(); 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 c4547f4c43d1f..ad0829ff05fb0 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 @@ -7,7 +7,7 @@ LL | fn foo(self); LL | fn foo(self) { | ^ found 1 type parameter -error[E0015]: cannot call non-const fn `<() as Trait>::foo` in constant functions +error[E0015]: cannot call non-const method `<() as Trait>::foo` in constant functions --> $DIR/inline-incorrect-early-bound-in-ctfe.rs:26:8 | LL | ().foo(); diff --git a/tests/ui/traits/const-traits/issue-79450.rs b/tests/ui/traits/const-traits/issue-79450.rs index 521576d27ef9d..5ba5036ce277a 100644 --- a/tests/ui/traits/const-traits/issue-79450.rs +++ b/tests/ui/traits/const-traits/issue-79450.rs @@ -6,7 +6,7 @@ trait Tr { fn req(&self); fn prov(&self) { - println!("lul"); //~ ERROR: cannot call non-const fn `_print` in constant functions + println!("lul"); //~ ERROR: cannot call non-const function `_print` in constant functions self.req(); } } diff --git a/tests/ui/traits/const-traits/issue-79450.stderr b/tests/ui/traits/const-traits/issue-79450.stderr index 85996c212118f..5bdebbbfb032b 100644 --- a/tests/ui/traits/const-traits/issue-79450.stderr +++ b/tests/ui/traits/const-traits/issue-79450.stderr @@ -1,4 +1,4 @@ -error[E0015]: cannot call non-const fn `_print` in constant functions +error[E0015]: cannot call non-const function `_print` in constant functions --> $DIR/issue-79450.rs:9:9 | LL | println!("lul"); diff --git a/tests/ui/traits/const-traits/issue-88155.rs b/tests/ui/traits/const-traits/issue-88155.rs index 08739de831389..a26128a6ecc23 100644 --- a/tests/ui/traits/const-traits/issue-88155.rs +++ b/tests/ui/traits/const-traits/issue-88155.rs @@ -9,7 +9,7 @@ pub trait A { pub const fn foo() -> bool { T::assoc() //FIXME ~^ ERROR the trait bound - //FIXME ~| ERROR cannot call non-const fn + //FIXME ~| ERROR cannot call non-const function } fn main() {} diff --git a/tests/ui/traits/const-traits/issue-88155.stderr b/tests/ui/traits/const-traits/issue-88155.stderr index 157b54214fa73..2e140ac9ff6b6 100644 --- a/tests/ui/traits/const-traits/issue-88155.stderr +++ b/tests/ui/traits/const-traits/issue-88155.stderr @@ -1,4 +1,4 @@ -error[E0015]: cannot call non-const fn `::assoc` in constant functions +error[E0015]: cannot call non-const associated function `::assoc` in constant functions --> $DIR/issue-88155.rs:10:5 | LL | T::assoc() diff --git a/tests/ui/traits/const-traits/non-const-op-const-closure-non-const-outer.rs b/tests/ui/traits/const-traits/non-const-op-const-closure-non-const-outer.rs index cd8bb5963ada2..fa0f786964488 100644 --- a/tests/ui/traits/const-traits/non-const-op-const-closure-non-const-outer.rs +++ b/tests/ui/traits/const-traits/non-const-op-const-closure-non-const-outer.rs @@ -11,5 +11,5 @@ impl Foo for () { fn main() { (const || { (()).foo() })(); - //~^ ERROR: cannot call non-const fn + //~^ ERROR: cannot call non-const method } diff --git a/tests/ui/traits/const-traits/non-const-op-const-closure-non-const-outer.stderr b/tests/ui/traits/const-traits/non-const-op-const-closure-non-const-outer.stderr index 97ad83130d444..2d33406c22240 100644 --- a/tests/ui/traits/const-traits/non-const-op-const-closure-non-const-outer.stderr +++ b/tests/ui/traits/const-traits/non-const-op-const-closure-non-const-outer.stderr @@ -1,4 +1,4 @@ -error[E0015]: cannot call non-const fn `<() as Foo>::foo` in constant functions +error[E0015]: cannot call non-const method `<() as Foo>::foo` in constant functions --> $DIR/non-const-op-const-closure-non-const-outer.rs:13:22 | LL | (const || { (()).foo() })(); 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 4ddb1e8c5a9f9..190af5e7c2dd1 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 @@ -17,7 +17,7 @@ note: `From` can't be used with `~const` because it isn't annotated with `#[cons --> $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 +error[E0015]: cannot call non-const associated function `>::from` in constant functions --> $DIR/non-const-op-in-closure-in-const.rs:12:9 | LL | B::from(self) diff --git a/tests/ui/traits/const-traits/std-impl-gate.gated.stderr b/tests/ui/traits/const-traits/std-impl-gate.gated.stderr index f3b171307618d..a78cf8ce61ea9 100644 --- a/tests/ui/traits/const-traits/std-impl-gate.gated.stderr +++ b/tests/ui/traits/const-traits/std-impl-gate.gated.stderr @@ -4,7 +4,7 @@ error[E0635]: unknown feature `const_default_impls` LL | #![cfg_attr(gated, feature(const_trait_impl, const_default_impls))] | ^^^^^^^^^^^^^^^^^^^ -error[E0015]: cannot call non-const fn ` as Default>::default` in constant functions +error[E0015]: cannot call non-const associated function ` as Default>::default` in constant functions --> $DIR/std-impl-gate.rs:13:5 | LL | Default::default() diff --git a/tests/ui/traits/const-traits/std-impl-gate.rs b/tests/ui/traits/const-traits/std-impl-gate.rs index a9e2ff06290a8..84091931997f4 100644 --- a/tests/ui/traits/const-traits/std-impl-gate.rs +++ b/tests/ui/traits/const-traits/std-impl-gate.rs @@ -11,7 +11,7 @@ fn non_const_context() -> Vec { const fn const_context() -> Vec { Default::default() - //[stock]~^ ERROR cannot call non-const fn + //[stock]~^ ERROR cannot call non-const associated function } fn main() { 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 7240b5f4a94c2..8728f652ef937 100644 --- a/tests/ui/traits/const-traits/std-impl-gate.stock.stderr +++ b/tests/ui/traits/const-traits/std-impl-gate.stock.stderr @@ -1,4 +1,4 @@ -error[E0015]: cannot call non-const fn ` as Default>::default` in constant functions +error[E0015]: cannot call non-const associated function ` as Default>::default` in constant functions --> $DIR/std-impl-gate.rs:13:5 | LL | Default::default() 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 51b88cf87022a..8f88e3aa8bc6d 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 @@ -45,7 +45,7 @@ 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 +error[E0015]: cannot call non-const method `::a` in constant functions --> $DIR/super-traits-fail-2.rs:20:7 | LL | x.a(); 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 38fb6f05412f4..087e80de788e0 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 @@ -57,7 +57,7 @@ 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 +error[E0015]: cannot call non-const method `::a` in constant functions --> $DIR/super-traits-fail-2.rs:20:7 | LL | x.a(); diff --git a/tests/ui/traits/const-traits/super-traits-fail-2.rs b/tests/ui/traits/const-traits/super-traits-fail-2.rs index 53a84bcdd1bb9..6cc9d7394767a 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-2.rs +++ b/tests/ui/traits/const-traits/super-traits-fail-2.rs @@ -19,7 +19,7 @@ trait Bar: ~const Foo {} const fn foo(x: &T) { x.a(); //[yy,yn]~^ ERROR the trait bound `T: ~const Foo` - //[nn,ny]~^^ ERROR cannot call non-const fn `::a` in constant functions + //[nn,ny]~^^ ERROR cannot call non-const method `::a` in constant functions } fn main() {} 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 fd802fde5bd5a..a5ef716a62a5d 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 @@ -88,7 +88,7 @@ help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `#[ LL | #[const_trait] trait Bar: ~const Foo {} | ++++++++++++++ -error[E0015]: cannot call non-const fn `::a` in constant functions +error[E0015]: cannot call non-const method `::a` in constant functions --> $DIR/super-traits-fail-3.rs:36:7 | LL | x.a(); 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 fd802fde5bd5a..a5ef716a62a5d 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 @@ -88,7 +88,7 @@ help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `#[ LL | #[const_trait] trait Bar: ~const Foo {} | ++++++++++++++ -error[E0015]: cannot call non-const fn `::a` in constant functions +error[E0015]: cannot call non-const method `::a` in constant functions --> $DIR/super-traits-fail-3.rs:36:7 | LL | x.a(); 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 aa27554e7f895..d7e0cdc26edd0 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.rs +++ b/tests/ui/traits/const-traits/super-traits-fail-3.rs @@ -35,7 +35,7 @@ const fn foo(x: &T) { //[nyy,nyn,nny,nnn]~^^^ ERROR: const trait impls are experimental x.a(); //[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 + //[ynn,yny,nny,nnn]~^^ ERROR: cannot call non-const method `::a` in constant functions //[nyy,nyn]~^^^ ERROR: cannot call conditionally-const method `::a` in constant functions } 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 16424696eeb51..f22bdd472e538 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 @@ -68,7 +68,7 @@ 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 +error[E0015]: cannot call non-const method `::a` in constant functions --> $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 index c81544c4bf5b7..14b50815b8e9c 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 @@ -57,7 +57,7 @@ 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 +error[E0015]: cannot call non-const method `::a` in constant functions --> $DIR/super-traits-fail-3.rs:36:7 | LL | x.a(); diff --git a/tests/ui/typeck/typeck_type_placeholder_item.stderr b/tests/ui/typeck/typeck_type_placeholder_item.stderr index 5e32d5c429ef0..e62ebae5fd24b 100644 --- a/tests/ui/typeck/typeck_type_placeholder_item.stderr +++ b/tests/ui/typeck/typeck_type_placeholder_item.stderr @@ -668,7 +668,7 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures LL | type F: std::ops::Fn(_); | ^ not allowed in type signatures -error[E0015]: cannot call non-const fn ` as Iterator>::filter::<{closure@$DIR/typeck_type_placeholder_item.rs:230:29: 230:32}>` in constants +error[E0015]: cannot call non-const method ` as Iterator>::filter::<{closure@$DIR/typeck_type_placeholder_item.rs:230:29: 230:32}>` in constants --> $DIR/typeck_type_placeholder_item.rs:230:22 | LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x); @@ -676,7 +676,7 @@ LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x); | = note: calls in constants are limited to constant functions, tuple structs and tuple variants -error[E0015]: cannot call non-const fn `, {closure@$DIR/typeck_type_placeholder_item.rs:230:29: 230:32}> as Iterator>::map::` in constants +error[E0015]: cannot call non-const method `, {closure@$DIR/typeck_type_placeholder_item.rs:230:29: 230:32}> as Iterator>::map::` in constants --> $DIR/typeck_type_placeholder_item.rs:230:45 | LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x);