diff --git a/compiler/rustc_resolve/messages.ftl b/compiler/rustc_resolve/messages.ftl index 39e9a9cc58afd..b5c3960c270ff 100644 --- a/compiler/rustc_resolve/messages.ftl +++ b/compiler/rustc_resolve/messages.ftl @@ -117,7 +117,7 @@ resolve_const_param_in_enum_discriminant = const parameters may not be used in enum discriminant values resolve_const_param_in_non_trivial_anon_const = - const parameters may only be used as standalone arguments here, i.e. `{$name}` + const parameters may only be used as standalone arguments in {$place}, i.e. `{$name}` resolve_constructor_private_if_any_field_private = a constructor is private if any of the fields is private diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 75eed1e9ad3fc..0eabc28239daf 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -900,7 +900,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { ResolutionError::ParamInTyOfConstParam { name } => { self.dcx().create_err(errs::ParamInTyOfConstParam { span, name }) } - ResolutionError::ParamInNonTrivialAnonConst { name, param_kind: is_type } => { + ResolutionError::ParamInNonTrivialAnonConst { name, param_kind: is_type, place } => { self.dcx().create_err(errs::ParamInNonTrivialAnonConst { span, name, @@ -910,6 +910,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { .sess .is_nightly_build() .then_some(errs::ParamInNonTrivialAnonConstHelp), + place: place.unwrap(), }) } ResolutionError::ParamInEnumDiscriminant { name, param_kind: is_type } => self diff --git a/compiler/rustc_resolve/src/errors.rs b/compiler/rustc_resolve/src/errors.rs index d6b1e4de6ea1a..2ae8f4d70bd69 100644 --- a/compiler/rustc_resolve/src/errors.rs +++ b/compiler/rustc_resolve/src/errors.rs @@ -4,7 +4,7 @@ use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_span::{Ident, Span, Symbol}; use crate::Res; -use crate::late::PatternSource; +use crate::late::{AnonConstKind, PatternSource}; #[derive(Diagnostic)] #[diag(resolve_generic_params_from_outer_item, code = E0401)] @@ -384,6 +384,7 @@ pub(crate) struct ParamInNonTrivialAnonConst { pub(crate) param_kind: ParamKindInNonTrivialAnonConst, #[subdiagnostic] pub(crate) help: Option, + pub(crate) place: AnonConstKind, } #[derive(Subdiagnostic)] diff --git a/compiler/rustc_resolve/src/ident.rs b/compiler/rustc_resolve/src/ident.rs index 71cc68af499db..1cd8746db891d 100644 --- a/compiler/rustc_resolve/src/ident.rs +++ b/compiler/rustc_resolve/src/ident.rs @@ -1160,7 +1160,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { res_err = Some((span, CannotCaptureDynamicEnvironmentInFnItem)); } } - RibKind::ConstantItem(_, item) => { + RibKind::ConstantItem(_, item, _) => { // Still doesn't deal with upvars if let Some(span) = finalize { let (span, resolution_error) = match item { @@ -1260,7 +1260,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { } } - RibKind::ConstantItem(trivial, _) => { + RibKind::ConstantItem(trivial, _, kind) => { if let ConstantHasGenerics::No(cause) = trivial { // HACK(min_const_generics): If we encounter `Self` in an anonymous // constant we can't easily tell if it's generic at this stage, so @@ -1291,6 +1291,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { name: rib_ident.name, param_kind: ParamKindInNonTrivialAnonConst::Type, + place: kind, } } }; @@ -1350,7 +1351,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { } } - RibKind::ConstantItem(trivial, _) => { + RibKind::ConstantItem(trivial, _, kind) => { if let ConstantHasGenerics::No(cause) = trivial { if let Some(span) = finalize { let error = match cause { @@ -1366,6 +1367,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { param_kind: ParamKindInNonTrivialAnonConst::Const { name: rib_ident.name, }, + place: kind, } } }; diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index a3a770502ded1..6e4f0371ab85b 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -66,7 +66,7 @@ pub(crate) enum PatternSource { } #[derive(Copy, Clone, Debug, PartialEq, Eq)] -enum IsRepeatExpr { +pub(crate) enum IsRepeatExpr { No, Yes, } @@ -76,13 +76,27 @@ struct IsNeverPattern; /// Describes whether an `AnonConst` is a type level const arg or /// some other form of anon const (i.e. inline consts or enum discriminants) #[derive(Copy, Clone, Debug, PartialEq, Eq)] -enum AnonConstKind { +pub(crate) enum AnonConstKind { EnumDiscriminant, FieldDefaultValue, InlineConst, ConstArg(IsRepeatExpr), } +impl IntoDiagArg for AnonConstKind { + fn into_diag_arg(self, _: &mut Option) -> DiagArgValue { + DiagArgValue::Str(Cow::Borrowed(match self { + AnonConstKind::EnumDiscriminant => "enum discriminant", + AnonConstKind::FieldDefaultValue => "field default value", + AnonConstKind::InlineConst => "inline const", + AnonConstKind::ConstArg(is_repeat_expr) => match is_repeat_expr { + IsRepeatExpr::No => "const generic args", + IsRepeatExpr::Yes => "array repeat expression", + }, + })) + } +} + impl PatternSource { fn descr(self) -> &'static str { match self { @@ -209,7 +223,7 @@ pub(crate) enum RibKind<'ra> { /// /// The item may reference generic parameters in trivial constant expressions. /// All other constants aren't allowed to use generic params at all. - ConstantItem(ConstantHasGenerics, Option<(Ident, ConstantItemKind)>), + ConstantItem(ConstantHasGenerics, Option<(Ident, ConstantItemKind)>, Option), /// We passed through a module. Module(Module<'ra>), @@ -3017,22 +3031,31 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { &mut self, is_repeat: IsRepeatExpr, may_use_generics: ConstantHasGenerics, + anon_const_kind: Option, item: Option<(Ident, ConstantItemKind)>, f: impl FnOnce(&mut Self), ) { let f = |this: &mut Self| { - this.with_rib(ValueNS, RibKind::ConstantItem(may_use_generics, item), |this| { - this.with_rib( - TypeNS, - RibKind::ConstantItem( - may_use_generics.force_yes_if(is_repeat == IsRepeatExpr::Yes), - item, - ), - |this| { - this.with_label_rib(RibKind::ConstantItem(may_use_generics, item), f); - }, - ) - }) + this.with_rib( + ValueNS, + RibKind::ConstantItem(may_use_generics, item, anon_const_kind), + |this| { + this.with_rib( + TypeNS, + RibKind::ConstantItem( + may_use_generics.force_yes_if(is_repeat == IsRepeatExpr::Yes), + item, + anon_const_kind, + ), + |this| { + this.with_label_rib( + RibKind::ConstantItem(may_use_generics, item, anon_const_kind), + f, + ); + }, + ) + }, + ) }; if let ConstantHasGenerics::No(cause) = may_use_generics { @@ -3548,9 +3571,13 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { fn resolve_const_body(&mut self, expr: &'ast Expr, item: Option<(Ident, ConstantItemKind)>) { self.with_lifetime_rib(LifetimeRibKind::Elided(LifetimeRes::Infer), |this| { - this.with_constant_rib(IsRepeatExpr::No, ConstantHasGenerics::Yes, item, |this| { - this.visit_expr(expr) - }); + this.with_constant_rib( + IsRepeatExpr::No, + ConstantHasGenerics::Yes, + None, + item, + |this| this.visit_expr(expr), + ); }) } @@ -4757,11 +4784,17 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { } }; - self.with_constant_rib(is_repeat_expr, may_use_generics, None, |this| { - this.with_lifetime_rib(LifetimeRibKind::Elided(LifetimeRes::Infer), |this| { - resolve_expr(this); - }); - }); + self.with_constant_rib( + is_repeat_expr, + may_use_generics, + Some(anon_const_kind), + None, + |this| { + this.with_lifetime_rib(LifetimeRibKind::Elided(LifetimeRes::Infer), |this| { + resolve_expr(this); + }); + }, + ); } fn resolve_expr_field(&mut self, f: &'ast ExprField, e: &'ast Expr) { diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 69095942f5246..41caeb581a15c 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -35,8 +35,8 @@ use tracing::debug; use super::NoConstantGenericsReason; use crate::diagnostics::{ImportSuggestion, LabelSuggestion, TypoSuggestion}; use crate::late::{ - AliasPossibility, LateResolutionVisitor, LifetimeBinderKind, LifetimeRes, LifetimeRibKind, - LifetimeUseSet, QSelf, RibKind, + AliasPossibility, AnonConstKind, LateResolutionVisitor, LifetimeBinderKind, LifetimeRes, + LifetimeRibKind, LifetimeUseSet, QSelf, RibKind, }; use crate::ty::fast_reject::SimplifiedType; use crate::{ @@ -3337,6 +3337,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { .sess .is_nightly_build() .then_some(errors::ParamInNonTrivialAnonConstHelp), + place: AnonConstKind::InlineConst, }) .emit(); } diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 27e14e0e62bf0..453a0f2c16736 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -91,6 +91,8 @@ pub mod rustdoc; pub use macros::registered_tools_ast; +use crate::late::AnonConstKind; + rustc_fluent_macro::fluent_messages! { "../messages.ftl" } #[derive(Debug)] @@ -285,7 +287,11 @@ enum ResolutionError<'ra> { /// generic parameters must not be used inside const evaluations. /// /// This error is only emitted when using `min_const_generics`. - ParamInNonTrivialAnonConst { name: Symbol, param_kind: ParamKindInNonTrivialAnonConst }, + ParamInNonTrivialAnonConst { + name: Symbol, + param_kind: ParamKindInNonTrivialAnonConst, + place: Option, + }, /// generic parameters must not be used inside enum discriminants. /// /// This error is emitted even with `generic_const_exprs`. diff --git a/tests/ui/const-generics/const-arg-in-const-arg.min.stderr b/tests/ui/const-generics/const-arg-in-const-arg.min.stderr index ebb3e821e07b7..e4ee0cf414e08 100644 --- a/tests/ui/const-generics/const-arg-in-const-arg.min.stderr +++ b/tests/ui/const-generics/const-arg-in-const-arg.min.stderr @@ -13,7 +13,7 @@ error: generic parameters may not be used in const operations LL | let _: [u8; bar::()]; | ^ cannot perform const operation using `N` | - = help: const parameters may only be used as standalone arguments here, i.e. `N` + = help: const parameters may only be used as standalone arguments in const generic args, i.e. `N` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error: generic parameters may not be used in const operations @@ -58,7 +58,7 @@ error: generic parameters may not be used in const operations LL | let _ = [0; bar::()]; | ^ cannot perform const operation using `N` | - = help: const parameters may only be used as standalone arguments here, i.e. `N` + = help: const parameters may only be used as standalone arguments in array repeat expression, i.e. `N` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error: generic parameters may not be used in const operations @@ -112,7 +112,7 @@ error: generic parameters may not be used in const operations LL | let _: Foo<{ bar::() }>; | ^ cannot perform const operation using `N` | - = help: const parameters may only be used as standalone arguments here, i.e. `N` + = help: const parameters may only be used as standalone arguments in const generic args, i.e. `N` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error: generic parameters may not be used in const operations @@ -166,7 +166,7 @@ error: generic parameters may not be used in const operations LL | let _ = Foo::<{ bar::() }>; | ^ cannot perform const operation using `N` | - = help: const parameters may only be used as standalone arguments here, i.e. `N` + = help: const parameters may only be used as standalone arguments in const generic args, i.e. `N` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error: generic parameters may not be used in const operations diff --git a/tests/ui/const-generics/defaults/complex-generic-default-expr.min.stderr b/tests/ui/const-generics/defaults/complex-generic-default-expr.min.stderr index e41e488371a8a..b0f0326791b3f 100644 --- a/tests/ui/const-generics/defaults/complex-generic-default-expr.min.stderr +++ b/tests/ui/const-generics/defaults/complex-generic-default-expr.min.stderr @@ -4,7 +4,7 @@ error: generic parameters may not be used in const operations LL | struct Foo; | ^ cannot perform const operation using `N` | - = help: const parameters may only be used as standalone arguments here, i.e. `N` + = help: const parameters may only be used as standalone arguments in const generic args, i.e. `N` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error: generic parameters may not be used in const operations diff --git a/tests/ui/const-generics/early/const_arg_trivial_macro_expansion-4.stderr b/tests/ui/const-generics/early/const_arg_trivial_macro_expansion-4.stderr index a1aee041b1fc5..b9cba0b008985 100644 --- a/tests/ui/const-generics/early/const_arg_trivial_macro_expansion-4.stderr +++ b/tests/ui/const-generics/early/const_arg_trivial_macro_expansion-4.stderr @@ -7,7 +7,7 @@ LL | N LL | fn foo() -> Foo<{ arg!{} arg!{} }> { loop {} } | ------ in this macro invocation | - = help: const parameters may only be used as standalone arguments here, i.e. `N` + = help: const parameters may only be used as standalone arguments in const generic args, i.e. `N` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions = note: this error originates in the macro `arg` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -20,7 +20,7 @@ LL | N LL | fn foo() -> Foo<{ arg!{} arg!{} }> { loop {} } | ------ in this macro invocation | - = help: const parameters may only be used as standalone arguments here, i.e. `N` + = help: const parameters may only be used as standalone arguments in const generic args, i.e. `N` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions = note: this error originates in the macro `arg` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -30,7 +30,7 @@ error: generic parameters may not be used in const operations LL | fn bar() -> [(); { empty!{}; N }] { loop {} } | ^ cannot perform const operation using `N` | - = help: const parameters may only be used as standalone arguments here, i.e. `N` + = help: const parameters may only be used as standalone arguments in const generic args, i.e. `N` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error: aborting due to 3 previous errors diff --git a/tests/ui/const-generics/early/macro_rules-braces.stderr b/tests/ui/const-generics/early/macro_rules-braces.stderr index 30efa18982be6..2c45f42c014c9 100644 --- a/tests/ui/const-generics/early/macro_rules-braces.stderr +++ b/tests/ui/const-generics/early/macro_rules-braces.stderr @@ -26,7 +26,7 @@ error: generic parameters may not be used in const operations LL | let _: foo!({{ N }}); | ^ cannot perform const operation using `N` | - = help: const parameters may only be used as standalone arguments here, i.e. `N` + = help: const parameters may only be used as standalone arguments in const generic args, i.e. `N` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error: generic parameters may not be used in const operations @@ -35,7 +35,7 @@ error: generic parameters may not be used in const operations LL | let _: bar!({ N }); | ^ cannot perform const operation using `N` | - = help: const parameters may only be used as standalone arguments here, i.e. `N` + = help: const parameters may only be used as standalone arguments in const generic args, i.e. `N` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error: generic parameters may not be used in const operations @@ -44,7 +44,7 @@ error: generic parameters may not be used in const operations LL | let _: baz!({{ N }}); | ^ cannot perform const operation using `N` | - = help: const parameters may only be used as standalone arguments here, i.e. `N` + = help: const parameters may only be used as standalone arguments in const generic args, i.e. `N` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error: generic parameters may not be used in const operations @@ -53,7 +53,7 @@ error: generic parameters may not be used in const operations LL | let _: biz!({ N }); | ^ cannot perform const operation using `N` | - = help: const parameters may only be used as standalone arguments here, i.e. `N` + = help: const parameters may only be used as standalone arguments in const generic args, i.e. `N` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error: aborting due to 6 previous errors diff --git a/tests/ui/const-generics/early/trivial-const-arg-macro-nested-braces-2.stderr b/tests/ui/const-generics/early/trivial-const-arg-macro-nested-braces-2.stderr index d68715b4d8b70..6bbdb9a39e560 100644 --- a/tests/ui/const-generics/early/trivial-const-arg-macro-nested-braces-2.stderr +++ b/tests/ui/const-generics/early/trivial-const-arg-macro-nested-braces-2.stderr @@ -7,7 +7,7 @@ LL | N LL | fn foo() -> A<{{ y!() }}> { | ---- in this macro invocation | - = help: const parameters may only be used as standalone arguments here, i.e. `N` + = help: const parameters may only be used as standalone arguments in const generic args, i.e. `N` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions = note: this error originates in the macro `y` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/const-generics/early/trivial-const-arg-macro-nested-braces.stderr b/tests/ui/const-generics/early/trivial-const-arg-macro-nested-braces.stderr index 1171b359f1703..c33b670839318 100644 --- a/tests/ui/const-generics/early/trivial-const-arg-macro-nested-braces.stderr +++ b/tests/ui/const-generics/early/trivial-const-arg-macro-nested-braces.stderr @@ -7,7 +7,7 @@ LL | { N } LL | fn foo() -> A<{ y!() }> { | ---- in this macro invocation | - = help: const parameters may only be used as standalone arguments here, i.e. `N` + = help: const parameters may only be used as standalone arguments in const generic args, i.e. `N` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions = note: this error originates in the macro `y` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/const-generics/early/trivial-const-arg-nested-braces.stderr b/tests/ui/const-generics/early/trivial-const-arg-nested-braces.stderr index b812e3333d9ca..68aeed4539a8e 100644 --- a/tests/ui/const-generics/early/trivial-const-arg-nested-braces.stderr +++ b/tests/ui/const-generics/early/trivial-const-arg-nested-braces.stderr @@ -4,7 +4,7 @@ error: generic parameters may not be used in const operations LL | fn foo() -> A<{ { N } }> { | ^ cannot perform const operation using `N` | - = help: const parameters may only be used as standalone arguments here, i.e. `N` + = help: const parameters may only be used as standalone arguments in const generic args, i.e. `N` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.min.stderr b/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.min.stderr index 1f93c4f89098d..5ca01ad81ec72 100644 --- a/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.min.stderr +++ b/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.min.stderr @@ -4,7 +4,7 @@ error: generic parameters may not be used in const operations LL | struct ArithArrayLen([u32; 0 + N]); | ^ cannot perform const operation using `N` | - = help: const parameters may only be used as standalone arguments here, i.e. `N` + = help: const parameters may only be used as standalone arguments in const generic args, i.e. `N` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error: generic parameters may not be used in const operations @@ -13,7 +13,7 @@ error: generic parameters may not be used in const operations LL | arr: [u8; CFG.arr_size], | ^^^ cannot perform const operation using `CFG` | - = help: const parameters may only be used as standalone arguments here, i.e. `CFG` + = help: const parameters may only be used as standalone arguments in const generic args, i.e. `CFG` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error: `Config` is forbidden as the type of a const generic parameter diff --git a/tests/ui/const-generics/generic_const_exprs/bad-multiply.stderr b/tests/ui/const-generics/generic_const_exprs/bad-multiply.stderr index 7719831e20cdb..bca65d89ec413 100644 --- a/tests/ui/const-generics/generic_const_exprs/bad-multiply.stderr +++ b/tests/ui/const-generics/generic_const_exprs/bad-multiply.stderr @@ -4,7 +4,7 @@ error: generic parameters may not be used in const operations LL | SmallVec<{ D * 2 }>:, | ^ cannot perform const operation using `D` | - = help: const parameters may only be used as standalone arguments here, i.e. `D` + = help: const parameters may only be used as standalone arguments in const generic args, i.e. `D` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error[E0747]: constant provided when a type was expected diff --git a/tests/ui/const-generics/generic_const_exprs/feature-gate-generic_const_exprs.stderr b/tests/ui/const-generics/generic_const_exprs/feature-gate-generic_const_exprs.stderr index 3208bbbd86b88..de73fb3f008b5 100644 --- a/tests/ui/const-generics/generic_const_exprs/feature-gate-generic_const_exprs.stderr +++ b/tests/ui/const-generics/generic_const_exprs/feature-gate-generic_const_exprs.stderr @@ -4,7 +4,7 @@ error: generic parameters may not be used in const operations LL | type Arr = [u8; N - 1]; | ^ cannot perform const operation using `N` | - = help: const parameters may only be used as standalone arguments here, i.e. `N` + = help: const parameters may only be used as standalone arguments in const generic args, i.e. `N` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/generic_const_exprs/issue-72787.min.stderr b/tests/ui/const-generics/generic_const_exprs/issue-72787.min.stderr index cccf6dc6ae01c..b9b4a30c69b4c 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-72787.min.stderr +++ b/tests/ui/const-generics/generic_const_exprs/issue-72787.min.stderr @@ -4,7 +4,7 @@ error: generic parameters may not be used in const operations LL | Condition<{ LHS <= RHS }>: True | ^^^ cannot perform const operation using `LHS` | - = help: const parameters may only be used as standalone arguments here, i.e. `LHS` + = help: const parameters may only be used as standalone arguments in const generic args, i.e. `LHS` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error: generic parameters may not be used in const operations @@ -13,7 +13,7 @@ error: generic parameters may not be used in const operations LL | Condition<{ LHS <= RHS }>: True | ^^^ cannot perform const operation using `RHS` | - = help: const parameters may only be used as standalone arguments here, i.e. `RHS` + = help: const parameters may only be used as standalone arguments in const generic args, i.e. `RHS` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error: generic parameters may not be used in const operations @@ -22,7 +22,7 @@ error: generic parameters may not be used in const operations LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True, | ^ cannot perform const operation using `I` | - = help: const parameters may only be used as standalone arguments here, i.e. `I` + = help: const parameters may only be used as standalone arguments in const generic args, i.e. `I` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error: generic parameters may not be used in const operations @@ -31,7 +31,7 @@ error: generic parameters may not be used in const operations LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True, | ^ cannot perform const operation using `J` | - = help: const parameters may only be used as standalone arguments here, i.e. `J` + = help: const parameters may only be used as standalone arguments in const generic args, i.e. `J` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error: aborting due to 4 previous errors diff --git a/tests/ui/const-generics/generic_const_exprs/issue-72819-generic-in-const-eval.min.stderr b/tests/ui/const-generics/generic_const_exprs/issue-72819-generic-in-const-eval.min.stderr index f91a2a302869e..7f7238c3b0a41 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-72819-generic-in-const-eval.min.stderr +++ b/tests/ui/const-generics/generic_const_exprs/issue-72819-generic-in-const-eval.min.stderr @@ -4,7 +4,7 @@ error: generic parameters may not be used in const operations LL | where Assert::<{N < usize::MAX / 2}>: IsTrue, | ^ cannot perform const operation using `N` | - = help: const parameters may only be used as standalone arguments here, i.e. `N` + = help: const parameters may only be used as standalone arguments in const generic args, i.e. `N` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/generic_const_exprs/trivial-anon-const-use-cases.min.stderr b/tests/ui/const-generics/generic_const_exprs/trivial-anon-const-use-cases.min.stderr index 6a868e95c8955..4442a821742c1 100644 --- a/tests/ui/const-generics/generic_const_exprs/trivial-anon-const-use-cases.min.stderr +++ b/tests/ui/const-generics/generic_const_exprs/trivial-anon-const-use-cases.min.stderr @@ -4,7 +4,7 @@ error: generic parameters may not be used in const operations LL | stuff: [u8; { S + 1 }], // `S + 1` is NOT a valid const expression in this context. | ^ cannot perform const operation using `S` | - = help: const parameters may only be used as standalone arguments here, i.e. `S` + = help: const parameters may only be used as standalone arguments in const generic args, i.e. `S` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/issues/issue-68366.min.stderr b/tests/ui/const-generics/issues/issue-68366.min.stderr index 4d721e958cbc7..68415262b0fa0 100644 --- a/tests/ui/const-generics/issues/issue-68366.min.stderr +++ b/tests/ui/const-generics/issues/issue-68366.min.stderr @@ -4,7 +4,7 @@ error: generic parameters may not be used in const operations LL | impl Collatz<{Some(N)}> {} | ^ cannot perform const operation using `N` | - = help: const parameters may only be used as standalone arguments here, i.e. `N` + = help: const parameters may only be used as standalone arguments in const generic args, i.e. `N` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error: `Option` is forbidden as the type of a const generic parameter diff --git a/tests/ui/const-generics/issues/issue-76701-ty-param-in-const.stderr b/tests/ui/const-generics/issues/issue-76701-ty-param-in-const.stderr index e58c894a27034..599c29032fe12 100644 --- a/tests/ui/const-generics/issues/issue-76701-ty-param-in-const.stderr +++ b/tests/ui/const-generics/issues/issue-76701-ty-param-in-const.stderr @@ -13,7 +13,7 @@ error: generic parameters may not be used in const operations LL | fn const_param() -> [u8; N + 1] { | ^ cannot perform const operation using `N` | - = help: const parameters may only be used as standalone arguments here, i.e. `N` + = help: const parameters may only be used as standalone arguments in const generic args, i.e. `N` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/issues/issue-80375.stderr b/tests/ui/const-generics/issues/issue-80375.stderr index 9a15e0380a193..a9a0ed49ad1cc 100644 --- a/tests/ui/const-generics/issues/issue-80375.stderr +++ b/tests/ui/const-generics/issues/issue-80375.stderr @@ -4,7 +4,7 @@ error: generic parameters may not be used in const operations LL | struct MyArray([u8; COUNT + 1]); | ^^^^^ cannot perform const operation using `COUNT` | - = help: const parameters may only be used as standalone arguments here, i.e. `COUNT` + = help: const parameters may only be used as standalone arguments in const generic args, i.e. `COUNT` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/legacy-const-generics-bad.stderr b/tests/ui/const-generics/legacy-const-generics-bad.stderr index a8681d6205309..a097a2ce398ff 100644 --- a/tests/ui/const-generics/legacy-const-generics-bad.stderr +++ b/tests/ui/const-generics/legacy-const-generics-bad.stderr @@ -16,7 +16,7 @@ error: generic parameters may not be used in const operations LL | legacy_const_generics::foo(0, N + 1, 2); | ^ cannot perform const operation using `N` | - = help: const parameters may only be used as standalone arguments here, i.e. `N` + = help: const parameters may only be used as standalone arguments in const generic args, i.e. `N` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/min_const_generics/complex-expression.stderr b/tests/ui/const-generics/min_const_generics/complex-expression.stderr index 35039bb41090d..6f9faf1f85dd3 100644 --- a/tests/ui/const-generics/min_const_generics/complex-expression.stderr +++ b/tests/ui/const-generics/min_const_generics/complex-expression.stderr @@ -4,7 +4,7 @@ error: generic parameters may not be used in const operations LL | struct Break0([u8; { N + 1 }]); | ^ cannot perform const operation using `N` | - = help: const parameters may only be used as standalone arguments here, i.e. `N` + = help: const parameters may only be used as standalone arguments in const generic args, i.e. `N` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error: generic parameters may not be used in const operations @@ -13,7 +13,7 @@ error: generic parameters may not be used in const operations LL | struct Break1([u8; { { N } }]); | ^ cannot perform const operation using `N` | - = help: const parameters may only be used as standalone arguments here, i.e. `N` + = help: const parameters may only be used as standalone arguments in const generic args, i.e. `N` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error: generic parameters may not be used in const operations @@ -22,7 +22,7 @@ error: generic parameters may not be used in const operations LL | let _: [u8; N + 1]; | ^ cannot perform const operation using `N` | - = help: const parameters may only be used as standalone arguments here, i.e. `N` + = help: const parameters may only be used as standalone arguments in const generic args, i.e. `N` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error: generic parameters may not be used in const operations @@ -31,7 +31,7 @@ error: generic parameters may not be used in const operations LL | let _ = [0; N + 1]; | ^ cannot perform const operation using `N` | - = help: const parameters may only be used as standalone arguments here, i.e. `N` + = help: const parameters may only be used as standalone arguments in array repeat expression, i.e. `N` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error: generic parameters may not be used in const operations diff --git a/tests/ui/const-generics/repeat_expr_hack_gives_right_generics.stderr b/tests/ui/const-generics/repeat_expr_hack_gives_right_generics.stderr index fe32fbcc87d57..96f206378e62e 100644 --- a/tests/ui/const-generics/repeat_expr_hack_gives_right_generics.stderr +++ b/tests/ui/const-generics/repeat_expr_hack_gives_right_generics.stderr @@ -4,7 +4,7 @@ error: generic parameters may not be used in const operations LL | bar::<{ [1; N] }>(); | ^ cannot perform const operation using `N` | - = help: const parameters may only be used as standalone arguments here, i.e. `N` + = help: const parameters may only be used as standalone arguments in const generic args, i.e. `N` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error: generic parameters may not be used in const operations @@ -13,7 +13,7 @@ error: generic parameters may not be used in const operations LL | bar::<{ [1; { N + 1 }] }>(); | ^ cannot perform const operation using `N` | - = help: const parameters may only be used as standalone arguments here, i.e. `N` + = help: const parameters may only be used as standalone arguments in const generic args, i.e. `N` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error: aborting due to 2 previous errors