From 4dcd02e3aa1b8101d24aa4ef8d887627407539a1 Mon Sep 17 00:00:00 2001 From: khyperia <953151+khyperia@users.noreply.github.com> Date: Wed, 23 Sep 2026 10:50:17 +0000 Subject: [PATCH] rename direct_const_arg! to gca! Co-authored-by: Boxy --- compiler/rustc_ast/src/ast.rs | 10 +- compiler/rustc_ast/src/util/classify.rs | 6 +- compiler/rustc_ast/src/visit.rs | 2 +- compiler/rustc_ast_lowering/src/expr.rs | 4 +- compiler/rustc_ast_lowering/src/lib.rs | 31 +++--- compiler/rustc_ast_pretty/src/pprust/state.rs | 4 +- .../rustc_ast_pretty/src/pprust/state/expr.rs | 4 +- .../src/assert/context.rs | 2 +- .../src/{direct_const_arg.rs => gca.rs} | 7 +- compiler/rustc_builtin_macros/src/lib.rs | 4 +- compiler/rustc_feature/src/unstable.rs | 4 +- compiler/rustc_hir/src/hir.rs | 2 +- .../src/check/compare_impl_item.rs | 4 +- .../src/hir_ty_lowering/mod.rs | 8 +- compiler/rustc_lint/src/unused.rs | 4 +- compiler/rustc_middle/src/queries.rs | 4 +- compiler/rustc_parse/src/parser/expr.rs | 2 +- compiler/rustc_passes/src/input_stats.rs | 4 +- compiler/rustc_resolve/src/late.rs | 2 +- compiler/rustc_span/src/symbol.rs | 2 +- library/core/src/marker.rs | 8 +- library/std/src/lib.rs | 2 + ...macroless-const-item-generic-const-args.md | 6 +- .../macroless-generic-const-args.md | 16 ++-- .../min-generic-const-args.md | 28 +++--- .../clippy_utils/src/check_proc_macro.rs | 2 +- src/tools/clippy/clippy_utils/src/sugg.rs | 2 +- .../clippy/tests/ui/crashes/mgca-16691.rs | 4 +- src/tools/rustfmt/src/expr.rs | 2 +- src/tools/rustfmt/src/types.rs | 2 +- src/tools/rustfmt/src/utils.rs | 2 +- .../rustfmt/tests/source/direct_const_arg.rs | 15 --- src/tools/rustfmt/tests/source/gca.rs | 17 ++++ .../rustfmt/tests/target/direct_const_arg.rs | 15 --- src/tools/rustfmt/tests/target/gca.rs | 17 ++++ tests/crashes/138009.rs | 5 +- tests/crashes/149809.rs | 8 +- tests/crashes/150049.rs | 5 +- tests/crashes/150749.rs | 6 +- tests/debuginfo/associated-const-bindings.rs | 5 +- tests/pretty/direct-const-arg.rs | 10 -- .../{direct-const-arg.pp => gca-macro.pp} | 9 +- tests/pretty/gca-macro.rs | 12 +++ .../rustdoc-html/type-const-free-in-array.rs | 4 +- .../type-const-inherent-with-body.rs | 4 +- .../type-const-in-array-len-wrong-type.rs | 4 +- .../type-const-in-array-len-wrong-type.stderr | 2 +- .../type-const-in-array-len.rs | 8 +- .../duplicate-bound-err.rs | 6 +- .../associated-type-bounds/duplicate-bound.rs | 4 +- .../type-const-inherent-impl-normalize.rs | 4 +- .../type-const-inherent-impl-normalize.stderr | 10 +- .../resolved-region-var-max-universe.rs | 4 +- .../resolved-region-var-max-universe.stderr | 2 +- .../associated-const-bindings/ambiguity.rs | 4 +- .../ambiguity.stderr | 8 +- .../associated-const-bindings/assoc-const.rs | 4 +- .../coexisting-with-type-binding.rs | 4 +- .../associated-const-bindings/coherence.rs | 4 +- .../coherence.stderr | 2 +- .../const_evaluatable_unchecked.rs | 4 +- .../dyn-compat-basic.rs | 4 +- .../dyn-compat-const-mismatch.rs | 4 +- .../dyn-compat-const-mismatch.stderr | 2 +- ...ompat-const-param-default-mentions-self.rs | 4 +- ...t-const-param-default-mentions-self.stderr | 2 +- ...und-on-assoc-const-allowed-and-enforced.rs | 4 +- ...on-assoc-const-allowed-and-enforced.stderr | 6 +- ...elf-const-projections-in-assoc-const-ty.rs | 4 +- ...const-projections-in-assoc-const-ty.stderr | 4 +- ...ompat-self-const-projections-in-methods.rs | 6 +- .../equality-unused-issue-126729.rs | 12 ++- .../equality_bound_with_infer.rs | 4 +- .../mismatched-types-with-generic-in-ace.rs | 4 +- ...ismatched-types-with-generic-in-ace.stderr | 8 +- .../wf-mismatch-3.rs | 4 +- .../wf-mismatch-3.stderr | 6 +- ...-on-failed-eval-with-vars-fail.next.stderr | 16 ++-- ...ambiguous-on-failed-eval-with-vars-fail.rs | 6 +- tests/ui/const-generics/gca/assoc-const.rs | 7 +- .../gca/basic-different-definitions.rs | 4 +- tests/ui/const-generics/gca/basic.rs | 6 +- tests/ui/const-generics/gca/coherence-ok.rs | 6 +- .../gca/gca-anon-const-rejected.rs | 4 +- .../gca/gca-anon-const-rejected.stderr | 6 +- ...st-arg-fn-call.rs => gca-macro-fn-call.rs} | 0 ...n-call.stderr => gca-macro-fn-call.stderr} | 10 +- .../gca/non-type-equality-fail.rs | 9 +- .../gca/non-type-equality-fail.stderr | 20 ++-- .../ui/const-generics/gca/rhs-but-not-root.rs | 6 +- .../gca/rhs-but-not-root.stderr | 6 +- .../suggest-const-item-for-generic-expr.rs | 2 +- .../ui/const-generics/gca/wf-inherentimpl.rs | 3 +- .../auxiliary/non_local_type_const.rs | 4 +- .../inherent-type-const.rs | 6 +- .../mgca/adt_expr_arg_simple.rs | 4 +- .../mgca/adt_expr_arg_simple.stderr | 8 +- .../mgca/adt_expr_infers_from_value.rs | 3 +- .../mgca/array-const-arg-len-mismatch.rs | 3 +- .../mgca/array-const-arg-len-mismatch.stderr | 20 ++-- .../mgca/array-expr-complex.r1.stderr | 6 +- .../mgca/array-expr-complex.r2.stderr | 6 +- .../mgca/array-expr-complex.r3.stderr | 6 +- .../const-generics/mgca/array-expr-complex.rs | 8 +- .../mgca/array_expr_arg_complex.rs | 6 +- .../mgca/array_expr_arg_complex.stderr | 12 +-- .../mgca/assoc-const-projection-in-bound.rs | 4 +- .../mgca/bad-const-arg-fn-154539.rs | 4 +- .../mgca/bad-const-arg-fn-154539.stderr | 6 +- .../mgca/bad-direct-const-arg.rs | 15 --- .../mgca/bad-direct-const-arg.stderr | 20 ---- tests/ui/const-generics/mgca/bad-gca-macro.rs | 17 ++++ .../const-generics/mgca/bad-gca-macro.stderr | 20 ++++ .../mgca/bad-type_const-syntax.rs | 13 ++- .../mgca/bad-type_const-syntax.stderr | 60 +++++++++--- .../mgca/braced-const-infer-in-body.rs | 8 +- .../mgca/braced-const-infer-in-body.stderr | 8 +- .../concrete-expr-with-generics-in-env.rs | 9 +- ...const-arg-coherence-conflicting-methods.rs | 4 +- ...t-arg-coherence-conflicting-methods.stderr | 6 +- .../const-arg-mismatched-literal-suffix.rs | 4 +- ...const-arg-mismatched-literal-suffix.stderr | 4 +- .../mgca/cyclic-type-const-151251.rs | 4 +- .../mgca/cyclic-type-const-151251.stderr | 4 +- .../mgca/direct-const-arg-correct-rib.stderr | 8 -- .../mgca/direct-const-arg-multiple-exprs.rs | 5 - .../direct-const-arg-multiple-exprs.stderr | 8 -- .../mgca/direct_const_arg-infer-as-type.rs | 13 --- .../direct_const_arg-infer-as-type.stderr | 15 --- .../mgca/explicit_anon_consts.rs | 22 +++-- .../mgca/explicit_anon_consts.stderr | 54 +++++------ .../mgca/free-const-recursive.gca.stderr | 8 +- .../mgca/free-const-recursive.min_gca.stderr | 4 +- .../mgca/free-const-recursive.rs | 4 +- ...orrect-rib.rs => gca-macro-correct-rib.rs} | 6 +- .../mgca/gca-macro-correct-rib.stderr | 8 ++ ...ture-gate.rs => gca-macro-feature-gate.rs} | 4 +- ...e.stderr => gca-macro-feature-gate.stderr} | 20 ++-- .../mgca/gca-macro-infer-as-type.rs | 14 +++ .../mgca/gca-macro-infer-as-type.stderr | 15 +++ .../mgca/gca-macro-multiple-exprs.rs | 6 ++ .../mgca/gca-macro-multiple-exprs.stderr | 8 ++ ...eric-args-on-enum-variant-segments-fail.rs | 7 +- ...-args-on-enum-variant-segments-fail.stderr | 38 ++++---- .../generic-args-on-enum-variant-segments.rs | 6 +- ...eneric_const_items-mismatched-array-len.rs | 4 +- ...ic_const_items-mismatched-array-len.stderr | 4 +- ...onst_parameter_types-inferred-array-len.rs | 5 +- .../mgca/generic_const_type_mismatch.rs | 4 +- .../mgca/generic_const_type_mismatch.stderr | 6 +- .../mgca/inherent-alias-default.rs | 6 +- ...t-const-arg-owner-issue-159172.expr.stderr | 13 --- ...d-gca-macro-owner-issue-159172.expr.stderr | 13 +++ ...> invalid-gca-macro-owner-issue-159172.rs} | 10 +- ...id-gca-macro-owner-issue-159172.ty.stderr} | 6 +- .../mgca/macro-const-arg-infer.rs | 5 +- .../mgca/macro-const-arg-infer.stderr | 14 +-- ...ixed-direct-anon-expression-diagnostics.rs | 4 +- ...-direct-anon-expression-diagnostics.stderr | 8 +- ...onst_args.rs => multi_braced_gca_macro.rs} | 0 .../non-local-const-without-type_const.stderr | 2 +- .../mgca/none-as-usize-const-arg.rs | 4 +- .../mgca/none-as-usize-const-arg.stderr | 16 ++-- .../opaque-ty-assoc-const-equality-117923.rs | 4 +- tests/ui/const-generics/mgca/paren.rs | 52 +++++----- .../mgca/projection-const-recursive.rs | 4 +- .../mgca/projection-const-recursive.stderr | 8 +- .../const-generics/mgca/static-const-arg.rs | 6 +- .../mgca/static-const-arg.stderr | 12 +-- .../mgca/suggest-direct-const.fixed | 33 ++++--- .../mgca/suggest-direct-const.rs | 21 +++-- .../mgca/suggest-direct-const.stderr | 94 +++++++++---------- .../mgca/syntactic-type-mismatch.rs | 6 +- .../mgca/syntactic-type-mismatch.stderr | 10 +- .../mgca/tuple_ctor_complex_args.rs | 3 +- .../mgca/tuple_ctor_complex_args.stderr | 8 +- .../mgca/tuple_ctor_erroneous.rs | 3 +- .../mgca/tuple_ctor_erroneous.stderr | 22 ++--- .../mgca/tuple_expr_arg_complex.rs | 10 +- .../mgca/tuple_expr_arg_complex.stderr | 24 ++--- .../mgca/tuple_expr_arg_simple.rs | 10 +- .../type-const-assoc-const-without-body.rs | 4 +- ...type-const-assoc-const-without-body.stderr | 8 +- .../mgca/type-const-associated-default.rs | 3 +- .../mgca/type-const-associated-default.stderr | 6 +- .../mgca/type-const-ctor-148953.rs | 5 +- .../type-const-free-anon-const-mismatch.rs | 6 +- ...type-const-free-anon-const-mismatch.stderr | 8 +- ...st-free-value-type-mismatch.current.stderr | 6 +- ...const-free-value-type-mismatch.next.stderr | 8 +- .../type-const-free-value-type-mismatch.rs | 4 +- .../type-const-free-value-used-in-body.rs | 6 +- .../type-const-free-value-used-in-body.stderr | 8 +- ...nherent-value-type-mismatch.current.stderr | 6 +- ...t-inherent-value-type-mismatch.next.stderr | 8 +- ...type-const-inherent-value-type-mismatch.rs | 4 +- .../mgca/type-const-used-in-trait.rs | 4 +- ...e-const-value-type-mismatch.current.stderr | 10 +- ...type-const-value-type-mismatch.next.stderr | 10 +- .../mgca/type-const-value-type-mismatch.rs | 4 +- .../mgca/type_const-adt-expr-missing-field.rs | 6 +- .../type_const-adt-expr-missing-field.stderr | 16 ++-- .../mgca/type_const-array-return.rs | 4 +- ..._const-generic-param-in-type.nogate.stderr | 18 ++-- .../mgca/type_const-generic-param-in-type.rs | 19 ++-- .../mgca/type_const-incemental-compile.rs | 4 +- .../type_const-inherent-const-omitted-type.rs | 4 +- ...e_const-inherent-const-omitted-type.stderr | 12 +-- .../type_const-mismatched-type-incremental.rs | 11 ++- ...e_const-mismatched-type-incremental.stderr | 16 ++-- .../mgca/type_const-mismatched-types.rs | 8 +- .../mgca/type_const-mismatched-types.stderr | 16 ++-- .../mgca/type_const-not-constparamty.rs | 6 +- .../mgca/type_const-not-constparamty.stderr | 10 +- .../mgca/type_const-on-generic-expr.rs | 6 +- .../mgca/type_const-on-generic-expr.stderr | 12 +-- .../mgca/type_const-on-generic_expr-2.rs | 8 +- .../mgca/type_const-on-generic_expr-2.stderr | 18 ++-- .../type_const-only-in-impl-omitted-type.rs | 6 +- ...ype_const-only-in-impl-omitted-type.stderr | 20 ++-- .../mgca/type_const-only-in-impl.rs | 6 +- .../mgca/type_const-only-in-impl.stderr | 10 +- .../mgca/type_const-only-in-trait.rs | 4 +- .../mgca/type_const-only-in-trait.stderr | 6 +- .../ui/const-generics/mgca/type_const-pub.rs | 4 +- .../mgca/type_const-recursive.rs | 4 +- .../mgca/type_const-recursive.stderr | 4 +- .../ui/const-generics/mgca/type_const-use.rs | 4 +- .../mgca/type_const_in_pattern.rs | 8 +- .../unbraced_const_block_const_arg_gated.rs | 6 +- ...nbraced_const_block_const_arg_gated.stderr | 24 ++--- .../mgca/unmarked-free-const.rs | 4 +- .../mgca/unmarked-free-const.stderr | 12 +-- .../type-const-ice-issue-151631.rs | 4 +- .../type-const-ice-issue-151631.stderr | 10 +- .../type-relative-path-144547.rs | 2 +- ...ems-before-lowering-ices.ice_155125.stderr | 8 +- ...ems-before-lowering-ices.ice_155127.stderr | 2 +- ...ems-before-lowering-ices.ice_155128.stderr | 6 +- ...ems-before-lowering-ices.ice_155164.stderr | 6 +- ...ems-before-lowering-ices.ice_155202.stderr | 4 +- .../hir-crate-items-before-lowering-ices.rs | 6 +- .../inside-const-body-ice-155300.rs | 4 +- .../inside-const-body-ice-155300.stderr | 8 +- .../ui/delegation/wrong-fn-kind-ice-159127.rs | 6 +- .../wrong-fn-kind-ice-159127.stderr | 8 +- .../feature-gate-generic-const-args.rs | 4 +- .../feature-gate-generic-const-args.stderr | 6 +- .../feature-gate-mgca-type-const-syntax.rs | 10 +- ...feature-gate-mgca-type-const-syntax.stderr | 24 ++--- .../feature-gate-min-generic-const-args.rs | 4 +- ...feature-gate-min-generic-const-args.stderr | 16 ++-- .../assoc-const-bindings.rs | 7 +- .../assoc-const-no-infer-ice-115806.rs | 6 +- .../assoc-const-no-infer-ice-115806.stderr | 6 +- .../type-const-nested-assoc-const.rs | 6 +- .../object-lifetime-default-inherent-gac.rs | 8 +- ...bject-lifetime-default-inherent-gac.stderr | 4 +- .../assoc-const-projection-issue-151878.rs | 4 +- .../overlap-due-to-unsatisfied-const-bound.rs | 4 +- ...rlap-due-to-unsatisfied-const-bound.stderr | 2 +- tests/ui/supertrait-shadowing/assoc-const.rs | 4 +- .../supertrait-shadowing/common-ancestor-2.rs | 3 +- .../common-ancestor-2.stderr | 18 ++-- .../supertrait-shadowing/common-ancestor-3.rs | 5 +- .../common-ancestor-3.stderr | 30 +++--- .../supertrait-shadowing/common-ancestor.rs | 3 +- .../common-ancestor.stderr | 18 ++-- .../no-common-ancestor-2.rs | 5 +- .../no-common-ancestor-2.stderr | 22 ++--- tests/ui/supertrait-shadowing/out-of-scope.rs | 3 +- .../ui/supertrait-shadowing/type-dependent.rs | 3 +- .../next-solver/normalize-const-item-type.rs | 8 +- .../normalize-const-item-type.stderr | 18 ++-- 274 files changed, 1325 insertions(+), 1042 deletions(-) rename compiler/rustc_builtin_macros/src/{direct_const_arg.rs => gca.rs} (81%) delete mode 100644 src/tools/rustfmt/tests/source/direct_const_arg.rs create mode 100644 src/tools/rustfmt/tests/source/gca.rs delete mode 100644 src/tools/rustfmt/tests/target/direct_const_arg.rs create mode 100644 src/tools/rustfmt/tests/target/gca.rs delete mode 100644 tests/pretty/direct-const-arg.rs rename tests/pretty/{direct-const-arg.pp => gca-macro.pp} (60%) create mode 100644 tests/pretty/gca-macro.rs rename tests/ui/const-generics/gca/{direct-const-arg-fn-call.rs => gca-macro-fn-call.rs} (100%) rename tests/ui/const-generics/gca/{direct-const-arg-fn-call.stderr => gca-macro-fn-call.stderr} (81%) delete mode 100644 tests/ui/const-generics/mgca/bad-direct-const-arg.rs delete mode 100644 tests/ui/const-generics/mgca/bad-direct-const-arg.stderr create mode 100644 tests/ui/const-generics/mgca/bad-gca-macro.rs create mode 100644 tests/ui/const-generics/mgca/bad-gca-macro.stderr delete mode 100644 tests/ui/const-generics/mgca/direct-const-arg-correct-rib.stderr delete mode 100644 tests/ui/const-generics/mgca/direct-const-arg-multiple-exprs.rs delete mode 100644 tests/ui/const-generics/mgca/direct-const-arg-multiple-exprs.stderr delete mode 100644 tests/ui/const-generics/mgca/direct_const_arg-infer-as-type.rs delete mode 100644 tests/ui/const-generics/mgca/direct_const_arg-infer-as-type.stderr rename tests/ui/const-generics/mgca/{direct-const-arg-correct-rib.rs => gca-macro-correct-rib.rs} (57%) create mode 100644 tests/ui/const-generics/mgca/gca-macro-correct-rib.stderr rename tests/ui/const-generics/mgca/{direct-const-arg-feature-gate.rs => gca-macro-feature-gate.rs} (52%) rename tests/ui/const-generics/mgca/{direct-const-arg-feature-gate.stderr => gca-macro-feature-gate.stderr} (56%) create mode 100644 tests/ui/const-generics/mgca/gca-macro-infer-as-type.rs create mode 100644 tests/ui/const-generics/mgca/gca-macro-infer-as-type.stderr create mode 100644 tests/ui/const-generics/mgca/gca-macro-multiple-exprs.rs create mode 100644 tests/ui/const-generics/mgca/gca-macro-multiple-exprs.stderr delete mode 100644 tests/ui/const-generics/mgca/invalid-direct-const-arg-owner-issue-159172.expr.stderr create mode 100644 tests/ui/const-generics/mgca/invalid-gca-macro-owner-issue-159172.expr.stderr rename tests/ui/const-generics/mgca/{invalid-direct-const-arg-owner-issue-159172.rs => invalid-gca-macro-owner-issue-159172.rs} (57%) rename tests/ui/const-generics/mgca/{invalid-direct-const-arg-owner-issue-159172.ty.stderr => invalid-gca-macro-owner-issue-159172.ty.stderr} (58%) rename tests/ui/const-generics/mgca/{multi_braced_direct_const_args.rs => multi_braced_gca_macro.rs} (100%) diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 5b9f3231fc744..2f1a547e05a48 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -1623,7 +1623,7 @@ impl Expr { | ExprKind::UnsafeBinderCast(..) | ExprKind::While(..) | ExprKind::Yield(YieldKind::Postfix(..)) - | ExprKind::DirectConstArg(..) + | ExprKind::GcaMacro(..) | ExprKind::Err(_) | ExprKind::Dummy => prefix_attrs_precedence(&self.attrs), } @@ -1920,8 +1920,8 @@ pub enum ExprKind { UnsafeBinderCast(UnsafeBinderCastKind, Box, Option>), - /// An mGCA `direct_const_arg!()` expression. - DirectConstArg(Box), + /// An mGCA `gca!()` expression. + GcaMacro(Box), /// Placeholder for an expression that wasn't syntactically well formed in some way. Err(ErrorGuaranteed), @@ -2579,8 +2579,8 @@ pub enum TyKind { FieldOf(Box, Option, Ident), /// A view of a type. `T.{ field_1, field_2 }`. View(Box, #[visitable(ignore)] ThinVec), - /// An mGCA `direct_const_arg!()` expression. - DirectConstArg(Box), + /// An mGCA `gca!()` expression. + GcaMacro(Box), /// Sometimes we need a dummy value when no error has occurred. Dummy, /// Placeholder for a kind that has failed to be defined. diff --git a/compiler/rustc_ast/src/util/classify.rs b/compiler/rustc_ast/src/util/classify.rs index e799f73ff544f..c4c181743543e 100644 --- a/compiler/rustc_ast/src/util/classify.rs +++ b/compiler/rustc_ast/src/util/classify.rs @@ -158,7 +158,7 @@ pub fn leading_labeled_expr(mut expr: &ast::Expr) -> bool { | Yeet(..) | Yield(..) | UnsafeBinderCast(..) - | DirectConstArg(..) + | GcaMacro(..) | Err(..) | Dummy => return false, } @@ -244,7 +244,7 @@ pub fn expr_trailing_brace(mut expr: &ast::Expr) -> Option> { | Try(_) | Yeet(None) | UnsafeBinderCast(..) - | DirectConstArg(..) + | GcaMacro(..) | Err(_) | Dummy => { break None; @@ -307,7 +307,7 @@ fn type_trailing_braced_mac_call(mut ty: &ast::Ty) -> Option<&ast::MacCall> { | ast::TyKind::Pat(..) | ast::TyKind::FieldOf(..) | ast::TyKind::View(..) - | ast::TyKind::DirectConstArg(..) + | ast::TyKind::GcaMacro(..) | ast::TyKind::Dummy | ast::TyKind::Err(..) => break None, } diff --git a/compiler/rustc_ast/src/visit.rs b/compiler/rustc_ast/src/visit.rs index 4270ac0656deb..ec77de62607ce 100644 --- a/compiler/rustc_ast/src/visit.rs +++ b/compiler/rustc_ast/src/visit.rs @@ -1112,7 +1112,7 @@ macro_rules! common_visitor_and_walkers { visit_visitable!(vis, bytes), ExprKind::UnsafeBinderCast(kind, expr, ty) => visit_visitable!(vis, kind, expr, ty), - ExprKind::DirectConstArg(expr) => + ExprKind::GcaMacro(expr) => visit_visitable!(vis, expr), ExprKind::Err(_guar) => {} ExprKind::Dummy => {} diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index c3bc86a352644..f4bfec24e3b1b 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -544,8 +544,8 @@ impl<'hir> LoweringContext<'_, 'hir> { ExprKind::MacCall(_) => panic!("{:?} shouldn't exist here", e.span), - ExprKind::DirectConstArg(expr) => { - let e = self.emit_bad_direct_const_arg(e.span, expr, "expression"); + ExprKind::GcaMacro(expr) => { + let e = self.emit_bad_gca_macro(e.span, expr, "expression"); hir::ExprKind::Err(e) } }; diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 7ff6a2538c1e7..ba5a9b52f7dd1 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -1489,9 +1489,7 @@ impl<'hir> LoweringContext<'_, 'hir> { let ct = self.arena.alloc(ct); return GenericArg::Const(ct.try_as_ambig_ct().unwrap()); } - TyKind::DirectConstArg(expr) - if self.tcx.features().min_generic_const_args() => - { + TyKind::GcaMacro(expr) if self.tcx.features().min_generic_const_args() => { let ct = match self.can_lower_expr_to_const_arg_direct( expr, DirectConstArgContext::MacrolessMinGenericConstArgs, @@ -1797,8 +1795,8 @@ impl<'hir> LoweringContext<'_, 'hir> { let fields = self.arena.alloc_slice(fields); hir::TyKind::View(ty, fields) } - TyKind::DirectConstArg(expr) => { - let e = self.emit_bad_direct_const_arg(t.span, expr, "type"); + TyKind::GcaMacro(expr) => { + let e = self.emit_bad_gca_macro(t.span, expr, "type"); hir::TyKind::Err(e) } TyKind::Dummy => panic!("`TyKind::Dummy` should never be lowered"), @@ -1807,16 +1805,16 @@ impl<'hir> LoweringContext<'_, 'hir> { hir::Ty { kind, span: self.lower_span(t.span), hir_id: self.lower_node_id(t.id) } } - pub(crate) fn emit_bad_direct_const_arg( + pub(crate) fn emit_bad_gca_macro( &mut self, span: Span, expr: &Expr, expected: &'static str, ) -> ErrorGuaranteed { - let msg = format!("expected {expected}, found `direct_const_arg!()` constant"); + let msg = format!("expected {expected}, found `gca!()` constant"); if expr::WillCreateDefIdsVisitor.visit_expr(expr).is_break() { // FIXME(mgca): make this non-fatal once we have a better way to handle - // nested items in invalid `direct_const_arg!()` arguments. + // nested items in invalid `gca!()` arguments. self.dcx().span_fatal(span, msg) } else { self.dcx().span_err(span, msg) @@ -2711,9 +2709,9 @@ impl<'hir> LoweringContext<'_, 'hir> { .is_ok() } else { // do not check can_lower_expr_to_const_arg_direct, but rather just - // ExprKind::DirectConstArg, because we don't want e.g. + // ExprKind::GcaMacro, because we don't want e.g. // `impl { const C: u8 = N; }` to be a direct-rhs const - matches!(body, Expr { kind: ExprKind::DirectConstArg(_), .. }) + matches!(body, Expr { kind: ExprKind::GcaMacro(_), .. }) } }; if self.tcx.features().min_generic_const_args() @@ -2816,7 +2814,7 @@ impl<'hir> LoweringContext<'_, 'hir> { Ok(()) } (ExprKind::ConstBlock(_), MacrolessMinGenericConstArgs) => Ok(()), - (ExprKind::DirectConstArg(_), MacrolessMinGenericConstArgs | MinGenericConstArgs) => { + (ExprKind::GcaMacro(_), MacrolessMinGenericConstArgs | MinGenericConstArgs) => { // Always report this as able to be represented directly. If it turns out not to be, // `lower_expr_to_const_arg_direct` will report an error. Ok(()) @@ -2998,11 +2996,10 @@ impl<'hir> LoweringContext<'_, 'hir> { span, } } - ExprKind::DirectConstArg(expr) => { + ExprKind::GcaMacro(expr) => { // `can_lower_expr_to_const_arg_direct` always returns success upon encountering a - // ExprKind::DirectConstArg, which effectively forces the expression to be lowered - // as a direct arg. If it actually turns out to not be possible, emit an error - // instead. + // ExprKind::GcaMacro, which effectively forces the expression to be lowered as a + // direct arg. If it actually turns out to not be possible, emit an error instead. // Always use MacrolessMinGenericConstArgs, even if we're under regular GCA, because // that's what the macro means: to enter a context that is like macroless GCA. match self.can_lower_expr_to_const_arg_direct( @@ -3354,12 +3351,12 @@ enum DirectConstArgContext { /// The only allowed direct const arg representation is simple paths that nameres to generic /// const parameters. Stable, - /// The allowed representations are what is allowed on stable, plus the `direct_const_arg!` macro. + /// The allowed representations are what is allowed on stable, plus the `gca!` macro. MinGenericConstArgs, /// Expressions attempt to be lowered directly, and if that fails, the expression falls back to /// being represented as an anon const. /// - /// This context is also used under MinGenericConstArgs inside a `direct_const_arg!` macro, for + /// This context is also used under MinGenericConstArgs inside a `gca!` macro, for /// simplicity, as they allow the same code. MacrolessMinGenericConstArgs, } diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs index d97bf7a2a6db3..6637ed356f557 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state.rs @@ -1460,8 +1460,8 @@ impl<'a> State<'a> { self.print_type(ty); self.print_view(fields); } - ast::TyKind::DirectConstArg(expr) => { - self.word_nbsp("core::direct_const_arg!"); + ast::TyKind::GcaMacro(expr) => { + self.word_nbsp("core::gca!"); self.popen(); self.print_expr(expr, FixupContext::default()); self.pclose(); diff --git a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs index b6c22e7da9cb1..d6e8f69dbfa03 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs @@ -883,8 +883,8 @@ impl<'a> State<'a> { self.word("/*DUMMY*/"); self.pclose(); } - ast::ExprKind::DirectConstArg(expr) => { - self.word_nbsp("core::direct_const_arg!"); + ast::ExprKind::GcaMacro(expr) => { + self.word_nbsp("core::gca!"); self.popen(); self.print_expr(expr, FixupContext::default()); self.pclose() diff --git a/compiler/rustc_builtin_macros/src/assert/context.rs b/compiler/rustc_builtin_macros/src/assert/context.rs index aa339ce7f4252..cb3ea2475721e 100644 --- a/compiler/rustc_builtin_macros/src/assert/context.rs +++ b/compiler/rustc_builtin_macros/src/assert/context.rs @@ -321,7 +321,7 @@ impl<'cx, 'a> Context<'cx, 'a> { | ExprKind::Yeet(_) | ExprKind::Become(_) | ExprKind::Yield(_) - | ExprKind::DirectConstArg(_) + | ExprKind::GcaMacro(_) | ExprKind::UnsafeBinderCast(..) => {} } } diff --git a/compiler/rustc_builtin_macros/src/direct_const_arg.rs b/compiler/rustc_builtin_macros/src/gca.rs similarity index 81% rename from compiler/rustc_builtin_macros/src/direct_const_arg.rs rename to compiler/rustc_builtin_macros/src/gca.rs index 6af503e9a4681..ba26b16d06be5 100644 --- a/compiler/rustc_builtin_macros/src/direct_const_arg.rs +++ b/compiler/rustc_builtin_macros/src/gca.rs @@ -10,8 +10,7 @@ pub(crate) fn expand<'cx>( span: Span, tts: TokenStream, ) -> MacroExpanderResult<'cx> { - let ExpandResult::Ready(expr) = get_single_expr_from_tts(cx, span, tts, "direct_const_arg!") - else { + let ExpandResult::Ready(expr) = get_single_expr_from_tts(cx, span, tts, "gca!") else { return ExpandResult::Retry(()); }; let expr = match expr { @@ -23,12 +22,12 @@ pub(crate) fn expand<'cx>( ExpandResult::Ready(Box::new(base::MacEager { expr: Some(Box::new(ast::Expr { id, - kind: ast::ExprKind::DirectConstArg(expr.clone()), + kind: ast::ExprKind::GcaMacro(expr.clone()), span, attrs: Default::default(), tokens: None, })), - ty: Some(Box::new(ast::Ty { id, kind: ast::TyKind::DirectConstArg(expr), span })), + ty: Some(Box::new(ast::Ty { id, kind: ast::TyKind::GcaMacro(expr), span })), ..Default::default() })) } diff --git a/compiler/rustc_builtin_macros/src/lib.rs b/compiler/rustc_builtin_macros/src/lib.rs index 57759bb113401..c564e14776c91 100644 --- a/compiler/rustc_builtin_macros/src/lib.rs +++ b/compiler/rustc_builtin_macros/src/lib.rs @@ -34,12 +34,12 @@ mod define_opaque; mod derive; mod deriving; mod diagnostics; -mod direct_const_arg; mod edition_panic; mod eii; mod env; mod format; mod format_foreign; +mod gca; mod global_allocator; mod iter; mod log_syntax; @@ -83,11 +83,11 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) { concat_bytes: concat_bytes::expand_concat_bytes, const_format_args: format::expand_format_args, core_panic: edition_panic::expand_panic, - direct_const_arg: direct_const_arg::expand, env: env::expand_env, file: source_util::expand_file, format_args: format::expand_format_args, format_args_nl: format::expand_format_args_nl, + gca: gca::expand, global_asm: asm::expand_global_asm, include: source_util::expand_include, include_bytes: source_util::expand_include_bytes, diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 94e3b77c6b575..a020ff315e470 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -610,9 +610,9 @@ declare_features! ( /// Provides a way to concatenate identifiers using metavariable expressions. (unstable, macro_metavar_expr_concat, "1.81.0", Some(124225)), /// Allows directly represented generic_const_args as the rhs of const items without the - /// `direct_const_arg!` macro. + /// `gca!` macro. (incomplete, macroless_const_item_generic_const_args, "CURRENT_RUSTC_VERSION", Some(162540)), - /// Allows directly represented generic_const_args without the `direct_const_arg!` macro. + /// Allows directly represented generic_const_args without the `gca!` macro. (incomplete, macroless_generic_const_args, "1.99.0", Some(159006)), /// Allows `#[marker]` on certain traits allowing overlapping implementations. (unstable, marker_trait_attr, "1.30.0", Some(29864)), diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index ee79680d7d1e9..203f2bb935133 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -554,7 +554,7 @@ pub enum InferArgKind { /// determined during HIR ty lowering. TypeOrConst, /// An infer argument with unambiguous const syntax, e.g. S<{ _ }> or - /// S. It can only be inferred to a const. + /// S. It can only be inferred to a const. Const, } diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs index 01f4f5cc527d6..af380929c446e 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs @@ -2171,7 +2171,7 @@ pub(super) fn compare_const_directness<'tcx>( tcx.dcx() .struct_span_err( tcx.def_span(impl_const_item.def_id), - "implementation of a `#[rustc_always_gca]` must have a `direct_const_arg!` RHS", + "implementation of a `#[rustc_always_gca]` must have a `gca!` RHS", ) .with_span_note( tcx.def_span(trait_const_item.def_id), @@ -2182,7 +2182,7 @@ pub(super) fn compare_const_directness<'tcx>( tcx.dcx() .struct_span_err( tcx.def_span(impl_const_item.def_id), - "implementation of a regular const cannot have a `direct_const_arg!` RHS", + "implementation of a regular const cannot have a `gca!` RHS", ) .with_span_note( tcx.def_span(trait_const_item.def_id), diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs index e7ecde09ce27b..99694554b00af 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs @@ -3147,9 +3147,9 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { let body_span = tcx.hir_body(body_id).value.span; err.multipart_suggestion( - "add direct_const_arg!() to the right-hand side of the constant", + "add gca!() to the right-hand side of the constant", vec![ - (body_span.shrink_to_lo(), String::from("core::direct_const_arg!(")), + (body_span.shrink_to_lo(), String::from("core::gca!(")), (body_span.shrink_to_hi(), String::from(")")), ], Applicability::MaybeIncorrect, @@ -3165,9 +3165,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { ); } } else { - err.note( - "only consts with a `direct_const_arg!` right-hand side may be used in types", - ); + err.note("only consts with a `gca!` right-hand side may be used in types"); } Err(err.emit_err()) } diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index 17c078615c411..2651ce55281fe 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -198,8 +198,8 @@ trait UnusedDelimLint { | Paren(_) | Become(_) => true, Call(..) | MethodCall(_) | Let(..) | Field(..) | MacCall(_) | FormatArgs(_) => false, - // `direct_const_arg!()` is invalid in function/method argument position. - DirectConstArg(_) => false, + // `gca!()` is invalid in function/method argument position. + GcaMacro(_) => false, // don't lint for placeholder/error-recovery Underscore | Err(_) | Dummy => false, } diff --git a/compiler/rustc_middle/src/queries.rs b/compiler/rustc_middle/src/queries.rs index 9e1bafa4fd2a2..8612adb8aa975 100644 --- a/compiler/rustc_middle/src/queries.rs +++ b/compiler/rustc_middle/src/queries.rs @@ -287,8 +287,8 @@ rustc_queries! { } /// Returns the const of the RHS of a (free or assoc) const item, if it is a `type const`, or if - /// it is a directly represented `const` (i.e. a const with a `direct_const_arg!` RHS, or a - /// const that `feature(macroless_generic_const_args)` has decided is direct). + /// it is a directly represented `const` (i.e. a const with a `gca!` RHS, or a const that + /// `feature(macroless_generic_const_args)` has decided is direct). /// /// When a const item is used in a type-level expression, like in equality for an assoc const /// projection, this allows us to retrieve the typesystem-appropriate representation of the diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 5bc30ae7ba325..a5c31672a2bc7 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -4358,7 +4358,7 @@ impl MutVisitor for CondChecker<'_> { | ExprKind::IncludedBytes(_) | ExprKind::FormatArgs(_) | ExprKind::Err(_) - | ExprKind::DirectConstArg(_) + | ExprKind::GcaMacro(_) | ExprKind::Dummy => { // These would forbid any let expressions they contain already. } diff --git a/compiler/rustc_passes/src/input_stats.rs b/compiler/rustc_passes/src/input_stats.rs index 961e6e63a81da..c7bcbfe82f3f2 100644 --- a/compiler/rustc_passes/src/input_stats.rs +++ b/compiler/rustc_passes/src/input_stats.rs @@ -661,7 +661,7 @@ impl<'v> ast_visit::Visitor<'v> for StatCollector<'v> { If, While, ForLoop, Loop, Match, Closure, Block, Await, Move, Use, TryBlock, Assign, AssignOp, Field, Index, Range, Underscore, Path, AddrOf, Break, Continue, Ret, InlineAsm, FormatArgs, OffsetOf, MacCall, Struct, Repeat, Paren, Try, Yield, Yeet, - Become, IncludedBytes, Gen, UnsafeBinderCast, Err, Dummy, DirectConstArg + Become, IncludedBytes, Gen, UnsafeBinderCast, GcaMacro, Err, Dummy ] ); ast_visit::walk_expr(self, e) @@ -691,7 +691,7 @@ impl<'v> ast_visit::Visitor<'v> for StatCollector<'v> { CVarArgs, FieldOf, View, - DirectConstArg, + GcaMacro, Dummy, Err ] diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 7d90b93b62375..aab01d43acba9 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -1034,7 +1034,7 @@ impl<'ast, 'ra, 'tcx> Visitor<'ast> for LateResolutionVisitor<'_, 'ast, 'ra, 'tc self.visit_ty(element_ty); self.resolve_anon_const(length, AnonConstKind::ArrayLength); } - TyKind::DirectConstArg(expr) => self.resolve_anon_const_manual( + TyKind::GcaMacro(expr) => self.resolve_anon_const_manual( true, AnonConstKind::ConstArg(IsRepeatExpr::No), |this| this.resolve_expr(expr, None), diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index bd70e5acab4d7..748c2c23fd10d 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -848,7 +848,6 @@ symbols! { diagnostic_opaque, dialect, direct, - direct_const_arg, discriminant_kind, discriminant_type, discriminant_value, @@ -1068,6 +1067,7 @@ symbols! { future_output, future_trait, fxsr, + gca, gdb_script_file, ge, gen_blocks, diff --git a/library/core/src/marker.rs b/library/core/src/marker.rs index 217f29d6a86e1..e67c7114d6d6a 100644 --- a/library/core/src/marker.rs +++ b/library/core/src/marker.rs @@ -1076,13 +1076,13 @@ pub trait Tuple {} /// Creates a new style directly represented const argument. /// ```ignore (cannot test this from within core yet) -/// const BAR: usize = direct_const_arg!(N); -/// const FOO: usize = direct_const_arg!(BAR::); +/// const BAR: usize = gca!(N); +/// const FOO: usize = gca!(BAR::); /// ``` -#[rustc_builtin_macro(direct_const_arg)] +#[rustc_builtin_macro(gca)] #[unstable(feature = "min_generic_const_args", issue = "132980")] #[macro_export] -macro_rules! direct_const_arg { +macro_rules! gca { ($($arg:tt)*) => { /* compiler built-in */ }; diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index acc8cdfc8281d..93b129c5c6641 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -758,6 +758,8 @@ pub use core::concat_bytes; )] #[unstable(feature = "derive_macro_global_path", issue = "154645")] pub use core::derive; +#[unstable(feature = "min_generic_const_args", issue = "132980")] +pub use core::gca; #[stable(feature = "matches_macro", since = "1.42.0")] pub use core::matches; #[stable(feature = "core_primitive", since = "1.43.0")] diff --git a/src/doc/unstable-book/src/language-features/macroless-const-item-generic-const-args.md b/src/doc/unstable-book/src/language-features/macroless-const-item-generic-const-args.md index df9172e04b9ac..feb03a633d1bd 100644 --- a/src/doc/unstable-book/src/language-features/macroless-const-item-generic-const-args.md +++ b/src/doc/unstable-book/src/language-features/macroless-const-item-generic-const-args.md @@ -1,6 +1,6 @@ # macroless_generic_const_args -Enables implementing const items under `#![feature(min_generic_const_args)]` and `#![feature(generic_const_args)]` without the `direct_const_arg!` macro. +Enables implementing const items under `#![feature(min_generic_const_args)]` and `#![feature(generic_const_args)]` without the `gca!` macro. The tracking issue for this feature is: [#162540] @@ -11,7 +11,7 @@ The tracking issue for this feature is: [#162540] Warning: This feature is incomplete; its design and syntax may change. Related features: -- [min_generic_const_args]. See that doc for what the `direct_const_arg!` is. This feature enables +- [min_generic_const_args]. See that doc for what the `gca!` is. This feature enables support for directly represented const arguments as the rhs of const items without the macro. - [macroless_generic_const_args]. For a version of this feature that works for const arguments in other positions @@ -39,7 +39,7 @@ trait Trait { } impl Trait for () { - const ASSOC: usize = core::direct_const_arg!(N); + const ASSOC: usize = core::gca!(N); } fn foo() { diff --git a/src/doc/unstable-book/src/language-features/macroless-generic-const-args.md b/src/doc/unstable-book/src/language-features/macroless-generic-const-args.md index 410834a79712e..fadc2260bfbdc 100644 --- a/src/doc/unstable-book/src/language-features/macroless-generic-const-args.md +++ b/src/doc/unstable-book/src/language-features/macroless-generic-const-args.md @@ -1,6 +1,6 @@ # macroless_generic_const_args -Enables using `#![feature(min_generic_const_args)]` without the `direct_const_arg!` macro. +Enables using `#![feature(min_generic_const_args)]` without the `gca!` macro. The tracking issue for this feature is: [#159006] @@ -11,7 +11,7 @@ The tracking issue for this feature is: [#159006] Warning: This feature is incomplete; its design and syntax may change. Related features: -- [min_generic_const_args]. See that doc for what the `direct_const_arg!` is. This feature enables +- [min_generic_const_args]. See that doc for what the `gca!` is. This feature enables support for directly represented const arguments without the macro. - [macroless_const_item_generic_const_args]. For a version of this feature that works for const arguments as the right hand side of a const item. @@ -39,13 +39,13 @@ trait Bar { struct Baz; impl Bar for Baz { - const VAL: usize = core::direct_const_arg!(2); - const VAL2: usize = core::direct_const_arg!(const { Self::VAL * 2 }); + const VAL: usize = core::gca!(2); + const VAL2: usize = core::gca!(const { Self::VAL * 2 }); } struct Foo { - arr1: [usize; core::direct_const_arg!(B::VAL)], - arr2: [usize; core::direct_const_arg!(B::VAL2)], + arr1: [usize; core::gca!(B::VAL)], + arr2: [usize; core::gca!(B::VAL2)], } ``` @@ -66,8 +66,8 @@ struct Baz; impl Bar for Baz { // note these still need a macro, macroless for these is `macroless_const_item_generic_const_args` - const VAL: usize = core::direct_const_arg!(2); - const VAL2: usize = core::direct_const_arg!(const { Self::VAL * 2 }); + const VAL: usize = core::gca!(2); + const VAL2: usize = core::gca!(const { Self::VAL * 2 }); } struct Foo { diff --git a/src/doc/unstable-book/src/language-features/min-generic-const-args.md b/src/doc/unstable-book/src/language-features/min-generic-const-args.md index 0d33af9092cf6..920bc0e36c1ba 100644 --- a/src/doc/unstable-book/src/language-features/min-generic-const-args.md +++ b/src/doc/unstable-book/src/language-features/min-generic-const-args.md @@ -23,36 +23,36 @@ Related features: [macroless_generic_const_args], [generic_const_args], [generic [generic_const_args]: generic-const-args.md [generic_const_items]: generic-const-items.md -## `direct_const_arg!` macro +## `gca!` macro -This feature introduces a new macro: `direct_const_arg!`. +This feature introduces a new macro: `gca!`. When an expression is used as a generic argument, it is typically lowered as an "anon const", which is an expression -that is opaque to the type system and cannot contain generics. Using `direct_const_arg!` instead represents the +that is opaque to the type system and cannot contain generics. Using `gca!` instead represents the expression "directly", i.e. without an anon const, in a way that is visible to the type system. -(Note that plain paths to generic parameters are always represented directly, without `direct_const_arg!`, as this +(Note that plain paths to generic parameters are always represented directly, without `gca!`, as this already works on stable) -See [macroless_generic_const_args] as a feature to disable the requirement of writing `direct_const_arg!`. +See [macroless_generic_const_args] as a feature to disable the requirement of writing `gca!`. [macroless_generic_const_args]: macroless-generic-const-args.md ## direct const items -This feature introduces a new item kind: consts with a `direct_const_arg!` right-hand side. +This feature introduces a new item kind: consts with a `gca!` right-hand side. Constants with a direct right-hand side are allowed to be used in type contexts, e.g.: ```compile_fail #![allow(incomplete_features)] #![feature(min_generic_const_args)] -const X: usize = core::direct_const_arg!(1); +const X: usize = core::gca!(1); const Y: usize = 1; struct Foo { - good_arr: [(); core::direct_const_arg!(X)], // Allowed - bad_arr: [(); core::direct_const_arg!(Y)], // Will not compile + good_arr: [(); core::gca!(X)], // Allowed + bad_arr: [(); core::gca!(Y)], // Will not compile } ``` @@ -72,13 +72,13 @@ trait Bar { struct Baz; impl Bar for Baz { - const VAL: usize = core::direct_const_arg!(2); - const VAL2: usize = core::direct_const_arg!(const { Self::VAL * 2 }); + const VAL: usize = core::gca!(2); + const VAL2: usize = core::gca!(const { Self::VAL * 2 }); } struct Foo { - arr1: [usize; core::direct_const_arg!(B::VAL)], - arr2: [usize; core::direct_const_arg!(B::VAL2)], + arr1: [usize; core::gca!(B::VAL)], + arr2: [usize; core::gca!(B::VAL2)], } ``` @@ -122,7 +122,7 @@ const fn inc(val: usize) -> usize { val + 1 } -const INC: usize = core::direct_const_arg!(const { inc(VAL) }); +const INC: usize = core::gca!(const { inc(VAL) }); const ARR: [usize; INC] = [0; INC]; ``` diff --git a/src/tools/clippy/clippy_utils/src/check_proc_macro.rs b/src/tools/clippy/clippy_utils/src/check_proc_macro.rs index c8ee7c5a1034f..baff6a99fc9e0 100644 --- a/src/tools/clippy/clippy_utils/src/check_proc_macro.rs +++ b/src/tools/clippy/clippy_utils/src/check_proc_macro.rs @@ -539,7 +539,7 @@ fn ast_ty_search_pat(ty: &ast::Ty) -> (Pat, Pat) { | TyKind::Pat(..) | TyKind::FieldOf(..) | TyKind::View(..) - | TyKind::DirectConstArg(..) + | TyKind::GcaMacro(..) // unused | TyKind::CVarArgs diff --git a/src/tools/clippy/clippy_utils/src/sugg.rs b/src/tools/clippy/clippy_utils/src/sugg.rs index 3d4645f72fce3..d2045c1346ee5 100644 --- a/src/tools/clippy/clippy_utils/src/sugg.rs +++ b/src/tools/clippy/clippy_utils/src/sugg.rs @@ -248,7 +248,7 @@ impl<'a> Sugg<'a> { | ast::ExprKind::Array(..) | ast::ExprKind::While(..) | ast::ExprKind::Await(..) - | ast::ExprKind::DirectConstArg(..) + | ast::ExprKind::GcaMacro(..) | ast::ExprKind::Err(_) | ast::ExprKind::Dummy | ast::ExprKind::UnsafeBinderCast(..) => Sugg::NonParen(snippet(expr.span)), diff --git a/src/tools/clippy/tests/ui/crashes/mgca-16691.rs b/src/tools/clippy/tests/ui/crashes/mgca-16691.rs index 7e45f96fa9a9a..554528905fc85 100644 --- a/src/tools/clippy/tests/ui/crashes/mgca-16691.rs +++ b/src/tools/clippy/tests/ui/crashes/mgca-16691.rs @@ -2,6 +2,8 @@ #![expect(incomplete_features)] #![feature(min_generic_const_args)] +use std::gca; + trait Trait { #[rustc_always_gca] const N: usize; @@ -9,7 +11,7 @@ trait Trait { } impl Trait for () { - const N: usize = core::direct_const_arg!(3); + const N: usize = gca!(3); fn process() { const N: usize = <()>::N; _ = 0..Self::N; diff --git a/src/tools/rustfmt/src/expr.rs b/src/tools/rustfmt/src/expr.rs index f0e56ffb8ea1a..48f17fb0fd1a8 100644 --- a/src/tools/rustfmt/src/expr.rs +++ b/src/tools/rustfmt/src/expr.rs @@ -430,7 +430,7 @@ pub(crate) fn format_expr( | ast::ExprKind::IncludedBytes(..) | ast::ExprKind::OffsetOf(..) | ast::ExprKind::UnsafeBinderCast(..) - | ast::ExprKind::DirectConstArg(..) => { + | ast::ExprKind::GcaMacro(..) => { // These don't normally occur in the AST because macros aren't expanded. However, // rustfmt tries to parse macro arguments when formatting macros, so it's not totally // impossible for rustfmt to come across one of these nodes when formatting a file. diff --git a/src/tools/rustfmt/src/types.rs b/src/tools/rustfmt/src/types.rs index e2c92e58062ae..d119cd50c846a 100644 --- a/src/tools/rustfmt/src/types.rs +++ b/src/tools/rustfmt/src/types.rs @@ -1043,7 +1043,7 @@ impl Rewrite for ast::Ty { result.push_str(&rewrite); Ok(result) } - ast::TyKind::Pat(..) | ast::TyKind::View(..) | ast::TyKind::DirectConstArg(..) => { + ast::TyKind::Pat(..) | ast::TyKind::View(..) | ast::TyKind::GcaMacro(..) => { // These don't normally occur in the AST because macros aren't expanded. However, // rustfmt tries to parse macro arguments when formatting macros, so it's not // totally impossible for rustfmt to come across these nodes when formatting a file. diff --git a/src/tools/rustfmt/src/utils.rs b/src/tools/rustfmt/src/utils.rs index 6f9fa7ff7024f..f7933ac52f75c 100644 --- a/src/tools/rustfmt/src/utils.rs +++ b/src/tools/rustfmt/src/utils.rs @@ -562,7 +562,7 @@ pub(crate) fn is_block_expr(context: &RewriteContext<'_>, expr: &ast::Expr, repr | ast::ExprKind::Unary(_, ref expr) | ast::ExprKind::Try(ref expr) | ast::ExprKind::Yield(YieldKind::Prefix(Some(ref expr))) - | ast::ExprKind::DirectConstArg(ref expr) => is_block_expr(context, expr, repr), + | ast::ExprKind::GcaMacro(ref expr) => is_block_expr(context, expr, repr), ast::ExprKind::Closure(ref closure) => is_block_expr(context, &closure.body, repr), // This can only be a string lit ast::ExprKind::Lit(_) => { diff --git a/src/tools/rustfmt/tests/source/direct_const_arg.rs b/src/tools/rustfmt/tests/source/direct_const_arg.rs deleted file mode 100644 index 6486d782cc1f5..0000000000000 --- a/src/tools/rustfmt/tests/source/direct_const_arg.rs +++ /dev/null @@ -1,15 +0,0 @@ -// direct_const_arg! is a built-in macro relevant to min_generic_const_args; its contents should be -// formatted as if its contents were passed through unchanged (the macro changes the semantics of -// the contained expression, the syntax is unchanged) - -#![feature(min_generic_const_args)] - -trait Trait { - #[rustc_always_gca] - const TYPE_CONST: usize; -} - -struct S; - -fn parsed_as_expr_kind(_: S<{ core::direct_const_arg!( T :: TYPE_CONST ) }>) {} -fn parsed_as_ty_kind(_: S< core::direct_const_arg!( T :: TYPE_CONST ) >) {} diff --git a/src/tools/rustfmt/tests/source/gca.rs b/src/tools/rustfmt/tests/source/gca.rs new file mode 100644 index 0000000000000..ab394c21b8b32 --- /dev/null +++ b/src/tools/rustfmt/tests/source/gca.rs @@ -0,0 +1,17 @@ +// gca! is a built-in macro relevant to min_generic_const_args; its contents should be formatted as +// if its contents were passed through unchanged (the macro changes the semantics of the contained +// expression, the syntax is unchanged) + +#![feature(min_generic_const_args)] + +use std::gca; + +trait Trait { + #[rustc_always_gca] + const TYPE_CONST: usize; +} + +struct S; + +fn parsed_as_expr_kind(_: S<{ gca!( T :: TYPE_CONST ) }>) {} +fn parsed_as_ty_kind(_: S< gca!( T :: TYPE_CONST ) >) {} diff --git a/src/tools/rustfmt/tests/target/direct_const_arg.rs b/src/tools/rustfmt/tests/target/direct_const_arg.rs deleted file mode 100644 index 94a6c864b78ef..0000000000000 --- a/src/tools/rustfmt/tests/target/direct_const_arg.rs +++ /dev/null @@ -1,15 +0,0 @@ -// direct_const_arg! is a built-in macro relevant to min_generic_const_args; its contents should be -// formatted as if its contents were passed through unchanged (the macro changes the semantics of -// the contained expression, the syntax is unchanged) - -#![feature(min_generic_const_args)] - -trait Trait { - #[rustc_always_gca] - const TYPE_CONST: usize; -} - -struct S; - -fn parsed_as_expr_kind(_: S<{ core::direct_const_arg!(T::TYPE_CONST) }>) {} -fn parsed_as_ty_kind(_: S) {} diff --git a/src/tools/rustfmt/tests/target/gca.rs b/src/tools/rustfmt/tests/target/gca.rs new file mode 100644 index 0000000000000..8110bb0d2c827 --- /dev/null +++ b/src/tools/rustfmt/tests/target/gca.rs @@ -0,0 +1,17 @@ +// gca! is a built-in macro relevant to min_generic_const_args; its contents should be formatted as +// if its contents were passed through unchanged (the macro changes the semantics of the contained +// expression, the syntax is unchanged) + +#![feature(min_generic_const_args)] + +use std::gca; + +trait Trait { + #[rustc_always_gca] + const TYPE_CONST: usize; +} + +struct S; + +fn parsed_as_expr_kind(_: S<{ gca!(T::TYPE_CONST) }>) {} +fn parsed_as_ty_kind(_: S) {} diff --git a/tests/crashes/138009.rs b/tests/crashes/138009.rs index 15c34a848e05f..494e3fb827ddb 100644 --- a/tests/crashes/138009.rs +++ b/tests/crashes/138009.rs @@ -1,6 +1,9 @@ //@ known-bug: #138009 #![feature(min_generic_const_args)] + +use std::gca; + #[repr(simd)] -struct T([isize; core::direct_const_arg!(N)]); +struct T([isize; gca!(N)]); static X: T = T(); diff --git a/tests/crashes/149809.rs b/tests/crashes/149809.rs index c2392a9c41eb2..b1172b72b17cd 100644 --- a/tests/crashes/149809.rs +++ b/tests/crashes/149809.rs @@ -1,12 +1,16 @@ //@ known-bug: #149809 #![feature(min_generic_const_args)] #![feature(inherent_associated_types)] + +use std::gca; + struct Qux<'a> { x: &'a (), } + impl<'a> Qux<'a> { - const LEN: usize = core::direct_const_arg!(4); - fn foo(_: [u8; core::direct_const_arg!(Qux::LEN)]) {} + const LEN: usize = gca!(4); + fn foo(_: [u8; gca!(Qux::LEN)]) {} } fn main() {} diff --git a/tests/crashes/150049.rs b/tests/crashes/150049.rs index 45289679e04ba..994e257a28d59 100644 --- a/tests/crashes/150049.rs +++ b/tests/crashes/150049.rs @@ -1,12 +1,15 @@ //@ known-bug: #150049 #![feature(min_generic_const_args)] #![feature(inherent_associated_types)] + +use std::gca; + struct Foo<'a> { x: &'a (), } impl<'a> Foo<'a> { - fn foo(_: [u8; core::direct_const_arg!(Foo::X)]) { + fn foo(_: [u8; gca!(Foo::X)]) { std::mem::transmute([4]) } } diff --git a/tests/crashes/150749.rs b/tests/crashes/150749.rs index 59d07f9860b9a..8e4e413236c82 100644 --- a/tests/crashes/150749.rs +++ b/tests/crashes/150749.rs @@ -1,12 +1,16 @@ //@ known-bug: #150749 #![feature(min_generic_const_args)] +use std::gca; + trait CollectArray { fn inner_array(); } + impl CollectArray for () { fn inner_array() { - let temp_ptr: [(); core::direct_const_arg!(Self)]; + let temp_ptr: [(); gca!(Self)]; } } + fn main() {} diff --git a/tests/debuginfo/associated-const-bindings.rs b/tests/debuginfo/associated-const-bindings.rs index 1a7ca6a5b0a95..171d457925522 100644 --- a/tests/debuginfo/associated-const-bindings.rs +++ b/tests/debuginfo/associated-const-bindings.rs @@ -13,12 +13,15 @@ #![feature(min_generic_const_args)] #![expect(unused_variables, incomplete_features)] +use std::gca; + trait Trait { #[rustc_always_gca] const N: usize; } + impl Trait for () { - const N: usize = core::direct_const_arg!(101); + const N: usize = gca!(101); } fn main() { diff --git a/tests/pretty/direct-const-arg.rs b/tests/pretty/direct-const-arg.rs deleted file mode 100644 index 330c1cac024de..0000000000000 --- a/tests/pretty/direct-const-arg.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ pretty-mode:expanded -//@ pp-exact:direct-const-arg.pp -#![feature(min_generic_const_args)] - -fn f() {} - -fn main() { - f::(); - f::<{ core::direct_const_arg!(2) }>(); -} diff --git a/tests/pretty/direct-const-arg.pp b/tests/pretty/gca-macro.pp similarity index 60% rename from tests/pretty/direct-const-arg.pp rename to tests/pretty/gca-macro.pp index a76ed9a480e71..8912d790b337a 100644 --- a/tests/pretty/direct-const-arg.pp +++ b/tests/pretty/gca-macro.pp @@ -1,15 +1,14 @@ #![feature(prelude_import)] #![no_std] //@ pretty-mode:expanded -//@ pp-exact:direct-const-arg.pp +//@ pp-exact:gca-macro.pp #![feature(min_generic_const_args)] extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; +use std::gca; + fn f() {} -fn main() { - f::(); - f::<{ core::direct_const_arg! (2) }>(); -} +fn main() { f::(); f::<{ core::gca! (2) }>(); } diff --git a/tests/pretty/gca-macro.rs b/tests/pretty/gca-macro.rs new file mode 100644 index 0000000000000..248fd4424e1da --- /dev/null +++ b/tests/pretty/gca-macro.rs @@ -0,0 +1,12 @@ +//@ pretty-mode:expanded +//@ pp-exact:gca-macro.pp +#![feature(min_generic_const_args)] + +use std::gca; + +fn f() {} + +fn main() { + f::(); + f::<{ gca!(2) }>(); +} diff --git a/tests/rustdoc-html/type-const-free-in-array.rs b/tests/rustdoc-html/type-const-free-in-array.rs index 4583e20fb8998..3fd6b21e34eea 100644 --- a/tests/rustdoc-html/type-const-free-in-array.rs +++ b/tests/rustdoc-html/type-const-free-in-array.rs @@ -2,7 +2,9 @@ #![feature(min_generic_const_args, macroless_generic_const_args)] #![expect(incomplete_features)] -const N: usize = core::direct_const_arg!(2); +use std::gca; + +const N: usize = gca!(2); //@ has 'foo/trait.CollectArray.html' //@ has - '//pre[@class="rust item-decl"]/code' '[A; N]' diff --git a/tests/rustdoc-html/type-const-inherent-with-body.rs b/tests/rustdoc-html/type-const-inherent-with-body.rs index a209ac47dcb0d..030ca8608a02d 100644 --- a/tests/rustdoc-html/type-const-inherent-with-body.rs +++ b/tests/rustdoc-html/type-const-inherent-with-body.rs @@ -2,10 +2,12 @@ #![feature(min_generic_const_args, macroless_generic_const_args, inherent_associated_types)] #![expect(incomplete_features)] +use std::gca; + pub struct Foo; impl Foo { - const LEN: usize = core::direct_const_arg!(4); + const LEN: usize = gca!(4); } //@ has 'foo/fn.mk_array.html' diff --git a/tests/ui/associated-consts/type-const-in-array-len-wrong-type.rs b/tests/ui/associated-consts/type-const-in-array-len-wrong-type.rs index 919aba47aea28..bb5e7ad4be181 100644 --- a/tests/ui/associated-consts/type-const-in-array-len-wrong-type.rs +++ b/tests/ui/associated-consts/type-const-in-array-len-wrong-type.rs @@ -5,10 +5,12 @@ inherent_associated_types )] +use std::gca; + struct OnDiskDirEntry<'a>(&'a ()); impl<'a> OnDiskDirEntry<'a> { - const LFN_FRAGMENT_LEN: i64 = core::direct_const_arg!(2); + const LFN_FRAGMENT_LEN: i64 = gca!(2); fn lfn_contents() -> [char; Self::LFN_FRAGMENT_LEN] { //~^ ERROR the constant `2` is not of type `usize` diff --git a/tests/ui/associated-consts/type-const-in-array-len-wrong-type.stderr b/tests/ui/associated-consts/type-const-in-array-len-wrong-type.stderr index dcb88f77f82cd..80c477ed43f29 100644 --- a/tests/ui/associated-consts/type-const-in-array-len-wrong-type.stderr +++ b/tests/ui/associated-consts/type-const-in-array-len-wrong-type.stderr @@ -1,5 +1,5 @@ error: the constant `2` is not of type `usize` - --> $DIR/type-const-in-array-len-wrong-type.rs:13:26 + --> $DIR/type-const-in-array-len-wrong-type.rs:15:26 | LL | fn lfn_contents() -> [char; Self::LFN_FRAGMENT_LEN] { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `i64` diff --git a/tests/ui/associated-consts/type-const-in-array-len.rs b/tests/ui/associated-consts/type-const-in-array-len.rs index 0f53aa9dd56fe..b4cf05a618255 100644 --- a/tests/ui/associated-consts/type-const-in-array-len.rs +++ b/tests/ui/associated-consts/type-const-in-array-len.rs @@ -2,10 +2,12 @@ #![feature(min_generic_const_args, macroless_generic_const_args, inherent_associated_types)] +use std::gca; + // Test case from #138226: generic impl with multiple type parameters struct Foo(A, B); impl Foo { - const LEN: usize = core::direct_const_arg!(4); + const LEN: usize = gca!(4); fn foo() { let _ = [5; Self::LEN]; @@ -15,7 +17,7 @@ impl Foo { // Test case from #138226: generic impl with const parameter struct Bar; impl Bar { - const LEN: usize = core::direct_const_arg!(4); + const LEN: usize = gca!(4); fn bar() { let _ = [0; Self::LEN]; @@ -25,7 +27,7 @@ impl Bar { // Test case from #150960: non-generic impl with const block struct Baz; impl Baz { - const LEN: usize = core::direct_const_arg!(4); + const LEN: usize = gca!(4); fn baz() { let _ = [0; { Self::LEN }]; diff --git a/tests/ui/associated-type-bounds/duplicate-bound-err.rs b/tests/ui/associated-type-bounds/duplicate-bound-err.rs index 0d1ab691c5c7f..5dc2ad6a3a56c 100644 --- a/tests/ui/associated-type-bounds/duplicate-bound-err.rs +++ b/tests/ui/associated-type-bounds/duplicate-bound-err.rs @@ -4,7 +4,7 @@ #![expect(incomplete_features)] #![allow(refining_impl_trait_internal)] -use std::iter; +use std::{gca, iter}; fn rpit1() -> impl Iterator { iter::empty() @@ -55,7 +55,7 @@ trait Trait { impl Trait for () { type Gat = (); - const ASSOC: i32 = core::direct_const_arg!(3); + const ASSOC: i32 = gca!(3); fn foo() {} } @@ -63,7 +63,7 @@ impl Trait for () { impl Trait for u32 { type Gat = (); - const ASSOC: i32 = core::direct_const_arg!(4); + const ASSOC: i32 = gca!(4); fn foo() -> u32 { 42 diff --git a/tests/ui/associated-type-bounds/duplicate-bound.rs b/tests/ui/associated-type-bounds/duplicate-bound.rs index 233b1ffb6ce76..68f9c373cd49c 100644 --- a/tests/ui/associated-type-bounds/duplicate-bound.rs +++ b/tests/ui/associated-type-bounds/duplicate-bound.rs @@ -5,8 +5,8 @@ #![expect(incomplete_features)] #![allow(dead_code, refining_impl_trait_internal, type_alias_bounds)] -use std::iter; use std::mem::ManuallyDrop; +use std::{gca, iter}; struct Si1> { f: T, @@ -198,7 +198,7 @@ trait Trait { impl Trait for () { type Gat = (); - const ASSOC: i32 = core::direct_const_arg!(3); + const ASSOC: i32 = gca!(3); fn foo() {} } diff --git a/tests/ui/associated-types/type-const-inherent-impl-normalize.rs b/tests/ui/associated-types/type-const-inherent-impl-normalize.rs index 63fa8eff1473b..8a0d14554d201 100644 --- a/tests/ui/associated-types/type-const-inherent-impl-normalize.rs +++ b/tests/ui/associated-types/type-const-inherent-impl-normalize.rs @@ -1,8 +1,8 @@ struct S; impl S { - const LEN: usize = core::direct_const_arg!(1); + const LEN: usize = std::gca!(1); //~^ ERROR: use of unstable library feature `min_generic_const_args` [E0658] - //~| ERROR: expected expression, found `direct_const_arg!()` + //~| ERROR: expected expression, found `gca!()` fn arr() { [8; Self::LEN] } diff --git a/tests/ui/associated-types/type-const-inherent-impl-normalize.stderr b/tests/ui/associated-types/type-const-inherent-impl-normalize.stderr index 421c2a83a19b9..9ee66984529de 100644 --- a/tests/ui/associated-types/type-const-inherent-impl-normalize.stderr +++ b/tests/ui/associated-types/type-const-inherent-impl-normalize.stderr @@ -1,18 +1,18 @@ error[E0658]: use of unstable library feature `min_generic_const_args` --> $DIR/type-const-inherent-impl-normalize.rs:3:24 | -LL | const LEN: usize = core::direct_const_arg!(1); - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | const LEN: usize = std::gca!(1); + | ^^^^^^^^ | = note: see issue #132980 for more information = help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: expected expression, found `direct_const_arg!()` constant +error: expected expression, found `gca!()` constant --> $DIR/type-const-inherent-impl-normalize.rs:3:24 | -LL | const LEN: usize = core::direct_const_arg!(1); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | const LEN: usize = std::gca!(1); + | ^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/assumptions_on_binders/resolved-region-var-max-universe.rs b/tests/ui/assumptions_on_binders/resolved-region-var-max-universe.rs index ffc605c0d51e0..378af46decb96 100644 --- a/tests/ui/assumptions_on_binders/resolved-region-var-max-universe.rs +++ b/tests/ui/assumptions_on_binders/resolved-region-var-max-universe.rs @@ -10,12 +10,14 @@ #![feature(min_generic_const_args, inherent_associated_types, generic_const_items)] +use std::gca; + struct Parent<'a> { a: &'a str, } impl<'a> Parent<'a> { - const CT: usize = core::direct_const_arg!(0); + const CT: usize = gca!(0); } fn check() diff --git a/tests/ui/assumptions_on_binders/resolved-region-var-max-universe.stderr b/tests/ui/assumptions_on_binders/resolved-region-var-max-universe.stderr index e77a0994fc2db..3cdd01182f84c 100644 --- a/tests/ui/assumptions_on_binders/resolved-region-var-max-universe.stderr +++ b/tests/ui/assumptions_on_binders/resolved-region-var-max-universe.stderr @@ -1,5 +1,5 @@ error[E0425]: cannot find type `T` in this scope - --> $DIR/resolved-region-var-max-universe.rs:23:23 + --> $DIR/resolved-region-var-max-universe.rs:25:23 | LL | [(); Parent::CT::]:, | ^ not found in this scope diff --git a/tests/ui/const-generics/associated-const-bindings/ambiguity.rs b/tests/ui/const-generics/associated-const-bindings/ambiguity.rs index 88c1212fe2c93..a8d66c950a064 100644 --- a/tests/ui/const-generics/associated-const-bindings/ambiguity.rs +++ b/tests/ui/const-generics/associated-const-bindings/ambiguity.rs @@ -4,6 +4,8 @@ #![feature(adt_const_params, min_generic_const_args, unsized_const_params)] #![allow(incomplete_features)] +use std::gca; + trait Trait0: Parent0 + Parent0 {} trait Parent0 { #[rustc_always_gca] @@ -23,7 +25,7 @@ trait Parent2 { const C: &'static str; } -fn take1(_: impl Trait1) {} +fn take1(_: impl Trait1) {} //~^ ERROR ambiguous associated constant `C` in bounds of `Trait1` fn main() {} diff --git a/tests/ui/const-generics/associated-const-bindings/ambiguity.stderr b/tests/ui/const-generics/associated-const-bindings/ambiguity.stderr index 5ed843de96074..88f356d1297bc 100644 --- a/tests/ui/const-generics/associated-const-bindings/ambiguity.stderr +++ b/tests/ui/const-generics/associated-const-bindings/ambiguity.stderr @@ -1,5 +1,5 @@ error[E0222]: ambiguous associated constant `K` in bounds of `Trait0` - --> $DIR/ambiguity.rs:13:25 + --> $DIR/ambiguity.rs:15:25 | LL | const K: (); | ----------- @@ -17,7 +17,7 @@ LL | fn take0(_: impl Trait0) {} T: Parent0::K = const {} error[E0222]: ambiguous associated constant `C` in bounds of `Trait1` - --> $DIR/ambiguity.rs:26:25 + --> $DIR/ambiguity.rs:28:25 | LL | const C: i32; | ------------ ambiguous `C` from `Parent1` @@ -25,8 +25,8 @@ LL | const C: i32; LL | const C: &'static str; | --------------------- ambiguous `C` from `Parent2` ... -LL | fn take1(_: impl Trait1) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ambiguous associated constant `C` +LL | fn take1(_: impl Trait1) {} + | ^^^^^^^^^^^^^^^^^ ambiguous associated constant `C` | = help: consider introducing a new type parameter `T` and adding `where` constraints: where diff --git a/tests/ui/const-generics/associated-const-bindings/assoc-const.rs b/tests/ui/const-generics/associated-const-bindings/assoc-const.rs index 598924316590c..d7e5ce3229dfd 100644 --- a/tests/ui/const-generics/associated-const-bindings/assoc-const.rs +++ b/tests/ui/const-generics/associated-const-bindings/assoc-const.rs @@ -2,6 +2,8 @@ #![feature(min_generic_const_args)] #![allow(unused, incomplete_features)] +use std::gca; + pub trait Foo { #[rustc_always_gca] const N: usize; @@ -10,7 +12,7 @@ pub trait Foo { pub struct Bar; impl Foo for Bar { - const N: usize = core::direct_const_arg!(3); + const N: usize = gca!(3); } fn foo>() {} diff --git a/tests/ui/const-generics/associated-const-bindings/coexisting-with-type-binding.rs b/tests/ui/const-generics/associated-const-bindings/coexisting-with-type-binding.rs index a6c86ce4b867d..f6fa6ece02ad9 100644 --- a/tests/ui/const-generics/associated-const-bindings/coexisting-with-type-binding.rs +++ b/tests/ui/const-generics/associated-const-bindings/coexisting-with-type-binding.rs @@ -8,6 +8,8 @@ #![feature(adt_const_params, min_generic_const_args, unsized_const_params)] #![allow(incomplete_features)] +use std::gca; + trait Trait: SuperTrait { type N; type Q; @@ -23,6 +25,6 @@ trait SuperTrait { fn take0(_: impl Trait) {} -fn take1(_: impl Trait) {} +fn take1(_: impl Trait) {} fn main() {} diff --git a/tests/ui/const-generics/associated-const-bindings/coherence.rs b/tests/ui/const-generics/associated-const-bindings/coherence.rs index aa26c6f4cd18f..d5764bfc93b61 100644 --- a/tests/ui/const-generics/associated-const-bindings/coherence.rs +++ b/tests/ui/const-generics/associated-const-bindings/coherence.rs @@ -1,12 +1,14 @@ #![feature(min_generic_const_args)] #![expect(incomplete_features)] +use std::gca; + pub trait IsVoid { #[rustc_always_gca] const IS_VOID: bool; } impl IsVoid for () { - const IS_VOID: bool = core::direct_const_arg!(true); + const IS_VOID: bool = gca!(true); } pub trait Maybe {} diff --git a/tests/ui/const-generics/associated-const-bindings/coherence.stderr b/tests/ui/const-generics/associated-const-bindings/coherence.stderr index ca1c968801243..519c95719a732 100644 --- a/tests/ui/const-generics/associated-const-bindings/coherence.stderr +++ b/tests/ui/const-generics/associated-const-bindings/coherence.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `Maybe` for type `()` - --> $DIR/coherence.rs:14:1 + --> $DIR/coherence.rs:16:1 | LL | impl Maybe for () {} | ----------------- first implementation here diff --git a/tests/ui/const-generics/associated-const-bindings/const_evaluatable_unchecked.rs b/tests/ui/const-generics/associated-const-bindings/const_evaluatable_unchecked.rs index a472118e51a82..7f7aec0ebcdd5 100644 --- a/tests/ui/const-generics/associated-const-bindings/const_evaluatable_unchecked.rs +++ b/tests/ui/const-generics/associated-const-bindings/const_evaluatable_unchecked.rs @@ -7,9 +7,11 @@ #![feature(min_generic_const_args, associated_type_defaults)] #![allow(incomplete_features)] +use std::gca; + pub trait TraitA { #[rustc_always_gca] - const K: u8 = core::direct_const_arg!(0); + const K: u8 = gca!(0); } pub trait TraitB {} diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-basic.rs b/tests/ui/const-generics/associated-const-bindings/dyn-compat-basic.rs index 3a896b6b2e1fa..cddb6eb88e937 100644 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-basic.rs +++ b/tests/ui/const-generics/associated-const-bindings/dyn-compat-basic.rs @@ -6,6 +6,8 @@ #![feature(min_generic_const_args)] #![expect(incomplete_features)] +use std::gca; + trait Trait: SuperTrait { #[rustc_always_gca] const K: usize; @@ -24,7 +26,7 @@ trait Bound { } impl Bound for () { - const N: usize = core::direct_const_arg!(10); + const N: usize = gca!(10); } fn main() { diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-mismatch.rs b/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-mismatch.rs index a28805f87b0f8..c38431c8e1d78 100644 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-mismatch.rs +++ b/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-mismatch.rs @@ -3,13 +3,15 @@ #![feature(min_generic_const_args)] #![expect(incomplete_features)] +use std::gca; + trait Trait { #[rustc_always_gca] const N: usize; } impl Trait for () { - const N: usize = core::direct_const_arg!(1); + const N: usize = gca!(1); } fn main() { diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-mismatch.stderr b/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-mismatch.stderr index ea781f784a9b0..82b4f7ca9ba6e 100644 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-mismatch.stderr +++ b/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-mismatch.stderr @@ -1,5 +1,5 @@ error[E0271]: type mismatch resolving `<() as Trait>::N == 0` - --> $DIR/dyn-compat-const-mismatch.rs:16:32 + --> $DIR/dyn-compat-const-mismatch.rs:18:32 | LL | let _: &dyn Trait = &(); | ^^^ expected `0`, found `1` diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-param-default-mentions-self.rs b/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-param-default-mentions-self.rs index f957a60a78b0b..b6d67f8fd8b19 100644 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-param-default-mentions-self.rs +++ b/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-param-default-mentions-self.rs @@ -4,6 +4,8 @@ #![feature(min_generic_const_args, macroless_generic_const_args)] #![expect(incomplete_features)] +use std::gca; + trait X::N }> {} trait Y { @@ -12,7 +14,7 @@ trait Y { } impl Y for T { - const N: usize = core::direct_const_arg!(1); + const N: usize = gca!(1); } fn main() { diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-param-default-mentions-self.stderr b/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-param-default-mentions-self.stderr index 365bae2188b00..bfe1e213e330b 100644 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-param-default-mentions-self.stderr +++ b/tests/ui/const-generics/associated-const-bindings/dyn-compat-const-param-default-mentions-self.stderr @@ -1,5 +1,5 @@ error[E0393]: the const parameter `N` must be explicitly specified - --> $DIR/dyn-compat-const-param-default-mentions-self.rs:19:16 + --> $DIR/dyn-compat-const-param-default-mentions-self.rs:21:16 | LL | trait X::N }> {} | -------------------------------------------- const parameter `N` must be specified for this diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-bound-on-assoc-const-allowed-and-enforced.rs b/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-bound-on-assoc-const-allowed-and-enforced.rs index 16fb2af1c4b54..2d282ace5436a 100644 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-bound-on-assoc-const-allowed-and-enforced.rs +++ b/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-bound-on-assoc-const-allowed-and-enforced.rs @@ -5,13 +5,15 @@ #![feature(min_generic_const_args, generic_const_items)] #![expect(incomplete_features)] +use std::gca; + trait Trait { #[rustc_always_gca] const N: i32 where Self: Bound; } impl Trait for () { - const N: i32 = core::direct_const_arg!(0); + const N: i32 = gca!(0); } trait Bound {} diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-bound-on-assoc-const-allowed-and-enforced.stderr b/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-bound-on-assoc-const-allowed-and-enforced.stderr index 770e7b561fadd..38a5ec4e1a9f8 100644 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-bound-on-assoc-const-allowed-and-enforced.stderr +++ b/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-bound-on-assoc-const-allowed-and-enforced.stderr @@ -1,16 +1,16 @@ error[E0277]: the trait bound `(): Bound` is not satisfied - --> $DIR/dyn-compat-self-bound-on-assoc-const-allowed-and-enforced.rs:22:32 + --> $DIR/dyn-compat-self-bound-on-assoc-const-allowed-and-enforced.rs:24:32 | LL | let _: &dyn Trait = &(); | ^^^ the trait `Bound` is not implemented for `()` | help: this trait has no implementations, consider adding one - --> $DIR/dyn-compat-self-bound-on-assoc-const-allowed-and-enforced.rs:17:1 + --> $DIR/dyn-compat-self-bound-on-assoc-const-allowed-and-enforced.rs:19:1 | LL | trait Bound {} | ^^^^^^^^^^^ note: required by a bound in `Trait::N` - --> $DIR/dyn-compat-self-bound-on-assoc-const-allowed-and-enforced.rs:10:30 + --> $DIR/dyn-compat-self-bound-on-assoc-const-allowed-and-enforced.rs:12:30 | LL | trait Trait { LL | #[rustc_always_gca] diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-assoc-const-ty.rs b/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-assoc-const-ty.rs index b2f0b25041056..53746231f46d7 100644 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-assoc-const-ty.rs +++ b/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-assoc-const-ty.rs @@ -13,6 +13,8 @@ )] #![expect(incomplete_features)] +use std::gca; + trait A { type Ty: std::marker::ConstParamTy_; #[rustc_always_gca] @@ -21,7 +23,7 @@ trait A { impl A for () { type Ty = i32; - const CT: i32 = core::direct_const_arg!(0); + const CT: i32 = gca!(0); } fn main() { diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-assoc-const-ty.stderr b/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-assoc-const-ty.stderr index e3873eae6f04f..50faeaf4eed9e 100644 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-assoc-const-ty.stderr +++ b/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-assoc-const-ty.stderr @@ -1,11 +1,11 @@ error: type annotations needed for the literal - --> $DIR/dyn-compat-self-const-projections-in-assoc-const-ty.rs:34:33 + --> $DIR/dyn-compat-self-const-projections-in-assoc-const-ty.rs:36:33 | LL | let _: dyn A; | ^ error: type annotations needed for the literal - --> $DIR/dyn-compat-self-const-projections-in-assoc-const-ty.rs:36:34 + --> $DIR/dyn-compat-self-const-projections-in-assoc-const-ty.rs:38:34 | LL | let _: &dyn A = &(); | ^ diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-methods.rs b/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-methods.rs index 148f5b8654af0..7cd8d6ef36302 100644 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-methods.rs +++ b/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-methods.rs @@ -14,6 +14,8 @@ #![feature(min_generic_const_args, macroless_generic_const_args)] #![expect(incomplete_features)] +use std::gca; + trait Trait { #[rustc_always_gca] const N: usize; @@ -22,7 +24,7 @@ trait Trait { } impl Trait for u8 { - const N: usize = core::direct_const_arg!(2); + const N: usize = gca!(2); fn process(&self, [x, y]: [u8; Self::N]) -> [u8; Self::N] { [self * x, self + y] @@ -30,7 +32,7 @@ impl Trait for u8 { } impl Trait for [u8; N] { - const N: usize = core::direct_const_arg!(N); + const N: usize = gca!(N); fn process(&self, other: [u8; Self::N]) -> [u8; Self::N] { let mut result = [0; _]; diff --git a/tests/ui/const-generics/associated-const-bindings/equality-unused-issue-126729.rs b/tests/ui/const-generics/associated-const-bindings/equality-unused-issue-126729.rs index 7b05da5623b10..0b4e871ceb5c6 100644 --- a/tests/ui/const-generics/associated-const-bindings/equality-unused-issue-126729.rs +++ b/tests/ui/const-generics/associated-const-bindings/equality-unused-issue-126729.rs @@ -4,13 +4,15 @@ #![allow(incomplete_features)] #![deny(dead_code)] +use std::gca; + trait Tr { #[rustc_always_gca] const I: i32; } impl Tr for () { - const I: i32 = core::direct_const_arg!(1); + const I: i32 = gca!(1); } fn foo() -> impl Tr {} @@ -23,20 +25,22 @@ trait Tr2 { } impl Tr2 for () { - const J: i32 = core::direct_const_arg!(1); - const K: i32 = core::direct_const_arg!(1); + const J: i32 = gca!(1); + const K: i32 = gca!(1); } fn foo2() -> impl Tr2 {} mod t { + use std::gca; + pub trait Tr3 { #[rustc_always_gca] const L: i32; } impl Tr3 for () { - const L: i32 = core::direct_const_arg!(1); + const L: i32 = gca!(1); } } diff --git a/tests/ui/const-generics/associated-const-bindings/equality_bound_with_infer.rs b/tests/ui/const-generics/associated-const-bindings/equality_bound_with_infer.rs index 01589ac645b05..3027357d0fb7e 100644 --- a/tests/ui/const-generics/associated-const-bindings/equality_bound_with_infer.rs +++ b/tests/ui/const-generics/associated-const-bindings/equality_bound_with_infer.rs @@ -3,6 +3,8 @@ #![feature(min_generic_const_args, generic_const_items)] #![expect(incomplete_features)] +use std::gca; + // Regression test for #133066 where we would try to evaluate `<() as Foo>::ASSOC<_>` even // though it contained inference variables, which would cause ICEs. @@ -12,7 +14,7 @@ trait Foo { } impl Foo for () { - const ASSOC: u32 = core::direct_const_arg!(N); + const ASSOC: u32 = gca!(N); } fn bar = 10>>() {} diff --git a/tests/ui/const-generics/associated-const-bindings/mismatched-types-with-generic-in-ace.rs b/tests/ui/const-generics/associated-const-bindings/mismatched-types-with-generic-in-ace.rs index 818609486d20c..9ef5c902062e3 100644 --- a/tests/ui/const-generics/associated-const-bindings/mismatched-types-with-generic-in-ace.rs +++ b/tests/ui/const-generics/associated-const-bindings/mismatched-types-with-generic-in-ace.rs @@ -1,13 +1,15 @@ #![feature(generic_const_items, min_generic_const_args)] #![expect(incomplete_features)] +use std::gca; + trait Foo { #[rustc_always_gca] const ASSOC: u32; } impl Foo for () { - const ASSOC: u32 = core::direct_const_arg!(N); + const ASSOC: u32 = gca!(N); } fn bar = { N }>>() {} diff --git a/tests/ui/const-generics/associated-const-bindings/mismatched-types-with-generic-in-ace.stderr b/tests/ui/const-generics/associated-const-bindings/mismatched-types-with-generic-in-ace.stderr index e879cafdc86ea..1eaa635e13532 100644 --- a/tests/ui/const-generics/associated-const-bindings/mismatched-types-with-generic-in-ace.stderr +++ b/tests/ui/const-generics/associated-const-bindings/mismatched-types-with-generic-in-ace.stderr @@ -1,11 +1,11 @@ error: the constant `N` is not of type `u32` - --> $DIR/mismatched-types-with-generic-in-ace.rs:13:29 + --> $DIR/mismatched-types-with-generic-in-ace.rs:15:29 | LL | fn bar = { N }>>() {} | ^^^^^^^^^^^^^^^^ expected `u32`, found `u64` | note: required by a const generic parameter in `Foo::ASSOC` - --> $DIR/mismatched-types-with-generic-in-ace.rs:6:17 + --> $DIR/mismatched-types-with-generic-in-ace.rs:8:17 | LL | trait Foo { LL | #[rustc_always_gca] @@ -13,13 +13,13 @@ LL | const ASSOC: u32; | ^^^^^^^^^^^^ required by this const generic parameter in `Foo::ASSOC` error: the constant `10` is not of type `u32` - --> $DIR/mismatched-types-with-generic-in-ace.rs:17:5 + --> $DIR/mismatched-types-with-generic-in-ace.rs:19:5 | LL | bar::<10_u64, ()>(); | ^^^^^^^^^^^^^^^^^^^ expected `u32`, found `u64` | note: required by a const generic parameter in `Foo::ASSOC` - --> $DIR/mismatched-types-with-generic-in-ace.rs:6:17 + --> $DIR/mismatched-types-with-generic-in-ace.rs:8:17 | LL | trait Foo { LL | #[rustc_always_gca] diff --git a/tests/ui/const-generics/associated-const-bindings/wf-mismatch-3.rs b/tests/ui/const-generics/associated-const-bindings/wf-mismatch-3.rs index d5682e7de1294..0180aa4694f67 100644 --- a/tests/ui/const-generics/associated-const-bindings/wf-mismatch-3.rs +++ b/tests/ui/const-generics/associated-const-bindings/wf-mismatch-3.rs @@ -4,6 +4,8 @@ #![feature(min_generic_const_args, macroless_generic_const_args)] #![expect(incomplete_features)] +use std::gca; + trait Trait { #[rustc_always_gca] const CT: bool; @@ -14,7 +16,7 @@ trait Bound { const N: u32; } impl Bound for () { - const N: u32 = core::direct_const_arg!(0); + const N: u32 = gca!(0); } fn f() { diff --git a/tests/ui/const-generics/associated-const-bindings/wf-mismatch-3.stderr b/tests/ui/const-generics/associated-const-bindings/wf-mismatch-3.stderr index f921e5893b51e..ddcf1d00dfbd8 100644 --- a/tests/ui/const-generics/associated-const-bindings/wf-mismatch-3.stderr +++ b/tests/ui/const-generics/associated-const-bindings/wf-mismatch-3.stderr @@ -1,17 +1,17 @@ error: the constant `0` is not of type `bool` - --> $DIR/wf-mismatch-3.rs:24:20 + --> $DIR/wf-mismatch-3.rs:26:20 | LL | fn g(_: impl Trait::N }>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `u32` | note: required by a const generic parameter in `g` - --> $DIR/wf-mismatch-3.rs:24:20 + --> $DIR/wf-mismatch-3.rs:26:20 | LL | fn g(_: impl Trait::N }>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this const generic parameter in `g` error: the constant `0` is not of type `bool` - --> $DIR/wf-mismatch-3.rs:21:12 + --> $DIR/wf-mismatch-3.rs:23:12 | LL | let _: dyn Trait::N }>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `u32` diff --git a/tests/ui/const-generics/gca/ambiguous-on-failed-eval-with-vars-fail.next.stderr b/tests/ui/const-generics/gca/ambiguous-on-failed-eval-with-vars-fail.next.stderr index 3b53adb07a2b9..0bbfe0626470d 100644 --- a/tests/ui/const-generics/gca/ambiguous-on-failed-eval-with-vars-fail.next.stderr +++ b/tests/ui/const-generics/gca/ambiguous-on-failed-eval-with-vars-fail.next.stderr @@ -1,13 +1,13 @@ error[E0284]: type annotations needed for `([(); _], [(); 10])` - --> $DIR/ambiguous-on-failed-eval-with-vars-fail.rs:31:9 + --> $DIR/ambiguous-on-failed-eval-with-vars-fail.rs:33:9 | LL | let (mut arr, mut arr_with_weird_len) = free(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ------ type must be known at this point | note: required by a const generic parameter in `free` - --> $DIR/ambiguous-on-failed-eval-with-vars-fail.rs:26:9 + --> $DIR/ambiguous-on-failed-eval-with-vars-fail.rs:28:9 | -LL | fn free() -> ([(); N], [(); core::direct_const_arg!(FREE::)]) { +LL | fn free() -> ([(); N], [(); gca!(FREE::)]) { | ^^^^^^^^^^^^^^ required by this const generic parameter in `free` help: consider giving this pattern a type, where the value of const parameter `N` is specified | @@ -15,7 +15,7 @@ LL | let (mut arr, mut arr_with_weird_len): ([_; N], _) = free(); | +++++++++++++ error[E0271]: type mismatch resolving `FREE<10> == 2` - --> $DIR/ambiguous-on-failed-eval-with-vars-fail.rs:37:45 + --> $DIR/ambiguous-on-failed-eval-with-vars-fail.rs:39:45 | LL | let (mut arr, mut arr_with_weird_len) = free(); | ^^^^^^ expected `2`, found `10` @@ -24,16 +24,16 @@ LL | let (mut arr, mut arr_with_weird_len) = free(); found constant `10` error[E0284]: type annotations needed for `([(); _], [(); 10])` - --> $DIR/ambiguous-on-failed-eval-with-vars-fail.rs:48:9 + --> $DIR/ambiguous-on-failed-eval-with-vars-fail.rs:50:9 | LL | let (mut arr, mut arr_with_weird_len) = proj(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ------ type must be known at this point | = note: cannot satisfy `::PROJ<_> == 10` note: required by a const generic parameter in `proj` - --> $DIR/ambiguous-on-failed-eval-with-vars-fail.rs:43:9 + --> $DIR/ambiguous-on-failed-eval-with-vars-fail.rs:45:9 | -LL | fn proj() -> ([(); N], [(); core::direct_const_arg!(::PROJ::)]) { +LL | fn proj() -> ([(); N], [(); gca!(::PROJ::)]) { | ^^^^^^^^^^^^^^ required by this const generic parameter in `proj` help: consider giving this pattern a type, where the value of const parameter `N` is specified | @@ -41,7 +41,7 @@ LL | let (mut arr, mut arr_with_weird_len): ([_; N], _) = proj(); | +++++++++++++ error[E0271]: type mismatch resolving `::PROJ<10> == 2` - --> $DIR/ambiguous-on-failed-eval-with-vars-fail.rs:54:45 + --> $DIR/ambiguous-on-failed-eval-with-vars-fail.rs:56:45 | LL | let (mut arr, mut arr_with_weird_len) = proj(); | ^^^^^^ expected `2`, found `10` diff --git a/tests/ui/const-generics/gca/ambiguous-on-failed-eval-with-vars-fail.rs b/tests/ui/const-generics/gca/ambiguous-on-failed-eval-with-vars-fail.rs index 8ee278af6ef56..a178a0f0d0b95 100644 --- a/tests/ui/const-generics/gca/ambiguous-on-failed-eval-with-vars-fail.rs +++ b/tests/ui/const-generics/gca/ambiguous-on-failed-eval-with-vars-fail.rs @@ -12,6 +12,8 @@ )] #![expect(incomplete_features)] +use std::gca; + const FREE: usize = 10; trait Trait { @@ -23,7 +25,7 @@ impl Trait for S { const PROJ: usize = 10; } -fn free() -> ([(); N], [(); core::direct_const_arg!(FREE::)]) { +fn free() -> ([(); N], [(); gca!(FREE::)]) { loop {} } @@ -40,7 +42,7 @@ fn test_free_mismatch() { arr = [(); 10]; } -fn proj() -> ([(); N], [(); core::direct_const_arg!(::PROJ::)]) { +fn proj() -> ([(); N], [(); gca!(::PROJ::)]) { loop {} } diff --git a/tests/ui/const-generics/gca/assoc-const.rs b/tests/ui/const-generics/gca/assoc-const.rs index 8a8d1b52e7e5a..316084e5b8cf9 100644 --- a/tests/ui/const-generics/gca/assoc-const.rs +++ b/tests/ui/const-generics/gca/assoc-const.rs @@ -2,12 +2,14 @@ //@ compile-flags: -Znext-solver #![feature(min_generic_const_args, generic_const_args)] +use std::gca; + trait Trait { const ASSOC: usize; } impl Trait for T { - const ASSOC: usize = core::direct_const_arg!(T::RIGID); + const ASSOC: usize = gca!(T::RIGID); } trait Other { @@ -15,8 +17,7 @@ trait Other { } fn foo() { - let a: [(); core::direct_const_arg!(::ASSOC)] = - [(); core::direct_const_arg!(T::RIGID)]; + let a: [(); gca!(::ASSOC)] = [(); gca!(T::RIGID)]; } fn main() {} diff --git a/tests/ui/const-generics/gca/basic-different-definitions.rs b/tests/ui/const-generics/gca/basic-different-definitions.rs index a80e50a6cb9e9..215b28c985113 100644 --- a/tests/ui/const-generics/gca/basic-different-definitions.rs +++ b/tests/ui/const-generics/gca/basic-different-definitions.rs @@ -6,10 +6,12 @@ #![feature(generic_const_args)] #![expect(incomplete_features)] +use std::gca; + const ADD1: usize = N + 1; const INC: usize = N + 1; -const ARR: [(); core::direct_const_arg!(ADD1::<0>)] = [(); core::direct_const_arg!(INC::<0>)]; +const ARR: [(); gca!(ADD1::<0>)] = [(); gca!(INC::<0>)]; fn main() {} diff --git a/tests/ui/const-generics/gca/basic.rs b/tests/ui/const-generics/gca/basic.rs index 55712a80f2195..c6158023a1be5 100644 --- a/tests/ui/const-generics/gca/basic.rs +++ b/tests/ui/const-generics/gca/basic.rs @@ -6,10 +6,12 @@ #![feature(generic_const_args)] #![expect(incomplete_features)] +use std::gca; + const ADD1: usize = N + 1; -const INC: usize = core::direct_const_arg!(ADD1::); +const INC: usize = gca!(ADD1::); -const ARR: [(); core::direct_const_arg!(ADD1::<0>)] = [(); core::direct_const_arg!(INC::<0>)]; +const ARR: [(); gca!(ADD1::<0>)] = [(); gca!(INC::<0>)]; fn main() {} diff --git a/tests/ui/const-generics/gca/coherence-ok.rs b/tests/ui/const-generics/gca/coherence-ok.rs index 5feebd2b2a6fb..4ea66eb8e290d 100644 --- a/tests/ui/const-generics/gca/coherence-ok.rs +++ b/tests/ui/const-generics/gca/coherence-ok.rs @@ -3,13 +3,15 @@ #![feature(generic_const_items, min_generic_const_args, generic_const_args)] #![expect(incomplete_features)] +use std::gca; + // computing different values with the same const item should be fine const ADD1: usize = N + 1; trait Trait {} -impl Trait for [(); core::direct_const_arg!(ADD1::<1>)] {} -impl Trait for [(); core::direct_const_arg!(ADD1::<2>)] {} +impl Trait for [(); gca!(ADD1::<1>)] {} +impl Trait for [(); gca!(ADD1::<2>)] {} fn main() {} diff --git a/tests/ui/const-generics/gca/gca-anon-const-rejected.rs b/tests/ui/const-generics/gca/gca-anon-const-rejected.rs index 72babbcfe0401..9cb0891127dd8 100644 --- a/tests/ui/const-generics/gca/gca-anon-const-rejected.rs +++ b/tests/ui/const-generics/gca/gca-anon-const-rejected.rs @@ -4,6 +4,8 @@ // `const FOO: usize = N + 1;` #![feature(generic_const_args, min_generic_const_args, generic_const_items)] -const FOO: usize = core::direct_const_arg!(const { N + 1 }); //~ ERROR generic parameters in const blocks are not allowed; use a named `const` item instead +use std::gca; + +const FOO: usize = gca!(const { N + 1 }); //~ ERROR generic parameters in const blocks are not allowed; use a named `const` item instead fn main() {} diff --git a/tests/ui/const-generics/gca/gca-anon-const-rejected.stderr b/tests/ui/const-generics/gca/gca-anon-const-rejected.stderr index 1b98cd734afd2..93d4c1ce76e39 100644 --- a/tests/ui/const-generics/gca/gca-anon-const-rejected.stderr +++ b/tests/ui/const-generics/gca/gca-anon-const-rejected.stderr @@ -1,8 +1,8 @@ error: generic parameters in const blocks are not allowed; use a named `const` item instead - --> $DIR/gca-anon-const-rejected.rs:7:68 + --> $DIR/gca-anon-const-rejected.rs:9:49 | -LL | const FOO: usize = core::direct_const_arg!(const { N + 1 }); - | ^ +LL | const FOO: usize = gca!(const { N + 1 }); + | ^ | = help: consider factoring the expression into a `type const` item and use it as the const argument instead diff --git a/tests/ui/const-generics/gca/direct-const-arg-fn-call.rs b/tests/ui/const-generics/gca/gca-macro-fn-call.rs similarity index 100% rename from tests/ui/const-generics/gca/direct-const-arg-fn-call.rs rename to tests/ui/const-generics/gca/gca-macro-fn-call.rs diff --git a/tests/ui/const-generics/gca/direct-const-arg-fn-call.stderr b/tests/ui/const-generics/gca/gca-macro-fn-call.stderr similarity index 81% rename from tests/ui/const-generics/gca/direct-const-arg-fn-call.stderr rename to tests/ui/const-generics/gca/gca-macro-fn-call.stderr index b73cc02dae915..1399bcb1dee92 100644 --- a/tests/ui/const-generics/gca/direct-const-arg-fn-call.stderr +++ b/tests/ui/const-generics/gca/gca-macro-fn-call.stderr @@ -1,29 +1,29 @@ error: complex const arguments must be placed inside of a `const` block - --> $DIR/direct-const-arg-fn-call.rs:35:23 + --> $DIR/gca-macro-fn-call.rs:35:23 | LL | fn bad(_: FieldName<{ FieldName::len() }>) {} | ^^^^^^^^^^^^^^^^ error: complex const arguments must be placed inside of a `const` block - --> $DIR/direct-const-arg-fn-call.rs:44:31 + --> $DIR/gca-macro-fn-call.rs:44:31 | LL | fn bad_tracing(_: FieldName<{ FieldName::len_of("id") }>) {} | ^^^^^^^^^^^^^^^^^^^^^^^ error: complex const arguments must be placed inside of a `const` block - --> $DIR/direct-const-arg-fn-call.rs:61:23 + --> $DIR/gca-macro-fn-call.rs:61:23 | LL | fn bad_union(_: Tag<{ Tag::width() }>) {} | ^^^^^^^^^^^^ error: complex const arguments must be placed inside of a `const` block - --> $DIR/direct-const-arg-fn-call.rs:70:28 + --> $DIR/gca-macro-fn-call.rs:70:28 | LL | fn bad_prim(_: FieldName<{ u32::from_str_radix("10", 10) }>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: complex const arguments must be placed inside of a `const` block - --> $DIR/direct-const-arg-fn-call.rs:81:31 + --> $DIR/gca-macro-fn-call.rs:81:31 | LL | fn bad_foreign(_: FieldName<{ Opaque::foo() }>) {} | ^^^^^^^^^^^^^ diff --git a/tests/ui/const-generics/gca/non-type-equality-fail.rs b/tests/ui/const-generics/gca/non-type-equality-fail.rs index e058648e3da54..1ea34829c6c6a 100644 --- a/tests/ui/const-generics/gca/non-type-equality-fail.rs +++ b/tests/ui/const-generics/gca/non-type-equality-fail.rs @@ -3,6 +3,8 @@ #![feature(min_generic_const_args, generic_const_args)] #![expect(incomplete_features)] +use std::gca; + trait Trait { const PROJECTED_A: usize; const PROJECTED_B: usize; @@ -27,14 +29,13 @@ const FREE_B: usize = 1; struct Struct; fn f() { - let _: Struct<{ core::direct_const_arg!( as Trait>::PROJECTED_A) }> = - Struct::<{ core::direct_const_arg!( as Trait>::PROJECTED_B) }>; + let _: Struct<{ gca!( as Trait>::PROJECTED_A) }> = + Struct::<{ gca!( as Trait>::PROJECTED_B) }>; //~^ ERROR mismatched types } fn g() { - let _: Struct<{ core::direct_const_arg!(T::PROJECTED_A) }> = - Struct::<{ core::direct_const_arg!(T::PROJECTED_B) }>; + let _: Struct<{ gca!(T::PROJECTED_A) }> = Struct::<{ gca!(T::PROJECTED_B) }>; //~^ ERROR mismatched types } diff --git a/tests/ui/const-generics/gca/non-type-equality-fail.stderr b/tests/ui/const-generics/gca/non-type-equality-fail.stderr index 28557d76d84e5..413ccf59a3290 100644 --- a/tests/ui/const-generics/gca/non-type-equality-fail.stderr +++ b/tests/ui/const-generics/gca/non-type-equality-fail.stderr @@ -1,21 +1,21 @@ error[E0308]: mismatched types - --> $DIR/non-type-equality-fail.rs:31:9 + --> $DIR/non-type-equality-fail.rs:33:9 | -LL | let _: Struct<{ core::direct_const_arg!( as Trait>::PROJECTED_A) }> = - | --------------------------------------------------------------------------------- expected due to this -LL | Struct::<{ core::direct_const_arg!( as Trait>::PROJECTED_B) }>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected ` as Trait>::PROJECTED_A`, found ` as Trait>::PROJECTED_B` +LL | let _: Struct<{ gca!( as Trait>::PROJECTED_A) }> = + | -------------------------------------------------------------- expected due to this +LL | Struct::<{ gca!( as Trait>::PROJECTED_B) }>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected ` as Trait>::PROJECTED_A`, found ` as Trait>::PROJECTED_B` | = note: expected struct `Struct< as Trait>::PROJECTED_A>` found struct `Struct< as Trait>::PROJECTED_B>` error[E0308]: mismatched types - --> $DIR/non-type-equality-fail.rs:37:9 + --> $DIR/non-type-equality-fail.rs:38:47 | -LL | let _: Struct<{ core::direct_const_arg!(T::PROJECTED_A) }> = - | --------------------------------------------------- expected due to this -LL | Struct::<{ core::direct_const_arg!(T::PROJECTED_B) }>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `::PROJECTED_A`, found `::PROJECTED_B` +LL | let _: Struct<{ gca!(T::PROJECTED_A) }> = Struct::<{ gca!(T::PROJECTED_B) }>; + | -------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `::PROJECTED_A`, found `::PROJECTED_B` + | | + | expected due to this | = note: expected struct `Struct<::PROJECTED_A>` found struct `Struct<::PROJECTED_B>` diff --git a/tests/ui/const-generics/gca/rhs-but-not-root.rs b/tests/ui/const-generics/gca/rhs-but-not-root.rs index 2c5f1e050a3fe..4f355c84e4875 100644 --- a/tests/ui/const-generics/gca/rhs-but-not-root.rs +++ b/tests/ui/const-generics/gca/rhs-but-not-root.rs @@ -4,9 +4,11 @@ #![feature(generic_const_args)] #![expect(incomplete_features)] +use std::gca; + // Anon consts must be the root of the RHS to be GCA. -const FOO: usize = core::direct_const_arg!(ID::); +const FOO: usize = gca!(ID::); //~^ ERROR generic parameters in const blocks are not allowed; use a named `const` item instead -const ID: usize = core::direct_const_arg!(N); +const ID: usize = gca!(N); fn main() {} diff --git a/tests/ui/const-generics/gca/rhs-but-not-root.stderr b/tests/ui/const-generics/gca/rhs-but-not-root.stderr index 6b2e5d61112d9..d34d7f6b51a74 100644 --- a/tests/ui/const-generics/gca/rhs-but-not-root.stderr +++ b/tests/ui/const-generics/gca/rhs-but-not-root.stderr @@ -1,8 +1,8 @@ error: generic parameters in const blocks are not allowed; use a named `const` item instead - --> $DIR/rhs-but-not-root.rs:8:73 + --> $DIR/rhs-but-not-root.rs:10:54 | -LL | const FOO: usize = core::direct_const_arg!(ID::); - | ^ +LL | const FOO: usize = gca!(ID::); + | ^ | = help: consider factoring the expression into a `type const` item and use it as the const argument instead diff --git a/tests/ui/const-generics/gca/suggest-const-item-for-generic-expr.rs b/tests/ui/const-generics/gca/suggest-const-item-for-generic-expr.rs index f6415412e0df4..85be63fd83b59 100644 --- a/tests/ui/const-generics/gca/suggest-const-item-for-generic-expr.rs +++ b/tests/ui/const-generics/gca/suggest-const-item-for-generic-expr.rs @@ -1,7 +1,7 @@ // Regression test for https://github.com/rust-lang/rust/issues/156729 // // When a generic parameter is used in a const operation, the diagnostic should -// suggest creating a `direct_const_arg!` item as an alternative to `generic_const_exprs`. +// suggest creating a `gca!` item as an alternative to `generic_const_exprs`. use std::mem::size_of; diff --git a/tests/ui/const-generics/gca/wf-inherentimpl.rs b/tests/ui/const-generics/gca/wf-inherentimpl.rs index c0a7e7f930877..8248c7b01832a 100644 --- a/tests/ui/const-generics/gca/wf-inherentimpl.rs +++ b/tests/ui/const-generics/gca/wf-inherentimpl.rs @@ -5,10 +5,11 @@ #![feature(inherent_associated_types)] #![feature(generic_const_args, min_generic_const_args)] //[old]~^ ERROR `generic_const_args` requires -Znext-solver=globally to be enabled +use std::gca; struct Foo; impl Foo { const SIZE: usize = { todo!() }; - fn to_bytes() -> [u8; core::direct_const_arg!(Self::SIZE)] { + fn to_bytes() -> [u8; gca!(Self::SIZE)] { todo!() } } diff --git a/tests/ui/const-generics/generic_const_exprs/auxiliary/non_local_type_const.rs b/tests/ui/const-generics/generic_const_exprs/auxiliary/non_local_type_const.rs index 689a981e5469b..b4401b182be4e 100644 --- a/tests/ui/const-generics/generic_const_exprs/auxiliary/non_local_type_const.rs +++ b/tests/ui/const-generics/generic_const_exprs/auxiliary/non_local_type_const.rs @@ -1,4 +1,6 @@ #![feature(min_generic_const_args)] #![allow(incomplete_features)] -pub const NON_LOCAL_CONST: char = core::direct_const_arg!('a'); +use std::gca; + +pub const NON_LOCAL_CONST: char = gca!('a'); diff --git a/tests/ui/const-generics/generic_const_parameter_types/inherent-type-const.rs b/tests/ui/const-generics/generic_const_parameter_types/inherent-type-const.rs index be91b0a5933bd..97edbef7df10d 100644 --- a/tests/ui/const-generics/generic_const_parameter_types/inherent-type-const.rs +++ b/tests/ui/const-generics/generic_const_parameter_types/inherent-type-const.rs @@ -10,15 +10,17 @@ const_param_ty_trait )] +use std::gca; + struct ThreeTypes(T1, T2, T3); impl ThreeTypes { - const INHERENT: [T3; 0] = core::direct_const_arg!([]); + const INHERENT: [T3; 0] = gca!([]); } struct Struct; -fn f() -> Struct<{ core::direct_const_arg!(ThreeTypes::::INHERENT) }> { +fn f() -> Struct<{ gca!(ThreeTypes::::INHERENT) }> { Struct } diff --git a/tests/ui/const-generics/mgca/adt_expr_arg_simple.rs b/tests/ui/const-generics/mgca/adt_expr_arg_simple.rs index 34fca58ff4e00..32714ca551fbc 100644 --- a/tests/ui/const-generics/mgca/adt_expr_arg_simple.rs +++ b/tests/ui/const-generics/mgca/adt_expr_arg_simple.rs @@ -1,6 +1,8 @@ #![feature(min_generic_const_args, macroless_generic_const_args, adt_const_params)] #![expect(incomplete_features)] +use std::gca; + #[derive(Eq, PartialEq, std::marker::ConstParamTy)] enum Option { Some(T), @@ -26,7 +28,7 @@ fn bar() { // this on the other hand is not allowed as `N + 1` is not a legal // const argument - foo::<{ core::direct_const_arg!(Some:: { 0: N + 1 }) }>(); + foo::<{ gca!(Some:: { 0: N + 1 }) }>(); //~^ ERROR: complex const arguments must be placed inside of a `const` block // this also is not allowed as generic parameters cannot be used diff --git a/tests/ui/const-generics/mgca/adt_expr_arg_simple.stderr b/tests/ui/const-generics/mgca/adt_expr_arg_simple.stderr index 7b1249773f0cb..0213c447b59ca 100644 --- a/tests/ui/const-generics/mgca/adt_expr_arg_simple.stderr +++ b/tests/ui/const-generics/mgca/adt_expr_arg_simple.stderr @@ -1,11 +1,11 @@ error: complex const arguments must be placed inside of a `const` block - --> $DIR/adt_expr_arg_simple.rs:29:54 + --> $DIR/adt_expr_arg_simple.rs:31:35 | -LL | foo::<{ core::direct_const_arg!(Some:: { 0: N + 1 }) }>(); - | ^^^^^ +LL | foo::<{ gca!(Some:: { 0: N + 1 }) }>(); + | ^^^^^ error: generic parameters may not be used in const operations - --> $DIR/adt_expr_arg_simple.rs:34:38 + --> $DIR/adt_expr_arg_simple.rs:36:38 | LL | foo::<{ Some:: { 0: const { N + 1 } } }>(); | ^ diff --git a/tests/ui/const-generics/mgca/adt_expr_infers_from_value.rs b/tests/ui/const-generics/mgca/adt_expr_infers_from_value.rs index bcd6660dc3533..3db15a2aef49c 100644 --- a/tests/ui/const-generics/mgca/adt_expr_infers_from_value.rs +++ b/tests/ui/const-generics/mgca/adt_expr_infers_from_value.rs @@ -10,6 +10,7 @@ )] #![expect(incomplete_features)] +use std::gca; use std::marker::{ConstParamTy, ConstParamTy_, PhantomData}; #[derive(PartialEq, Eq, ConstParamTy)] @@ -17,7 +18,7 @@ struct Foo { field: T, } -const WRAP: Foo = core::direct_const_arg!(Foo:: { field: N }); +const WRAP: Foo = gca!(Foo:: { field: N }); fn main() { // What we're trying to accomplish here is winding up with an equality relation diff --git a/tests/ui/const-generics/mgca/array-const-arg-len-mismatch.rs b/tests/ui/const-generics/mgca/array-const-arg-len-mismatch.rs index f2c8a242dbcc0..78e9c0821fa88 100644 --- a/tests/ui/const-generics/mgca/array-const-arg-len-mismatch.rs +++ b/tests/ui/const-generics/mgca/array-const-arg-len-mismatch.rs @@ -6,6 +6,7 @@ #![feature(adt_const_params, min_generic_const_args, macroless_generic_const_args)] #![feature(unsized_const_params, generic_const_parameter_types)] +use std::gca; use std::marker::ConstParamTy_; fn foo() -> [T; N] { @@ -21,7 +22,7 @@ trait Trait { struct S; impl Trait for S { - const LEN: usize = core::direct_const_arg!(3); + const LEN: usize = gca!(3); } fn baz::LEN]>() {} diff --git a/tests/ui/const-generics/mgca/array-const-arg-len-mismatch.stderr b/tests/ui/const-generics/mgca/array-const-arg-len-mismatch.stderr index 82a9cfc86b5d7..72c2a367c7246 100644 --- a/tests/ui/const-generics/mgca/array-const-arg-len-mismatch.stderr +++ b/tests/ui/const-generics/mgca/array-const-arg-len-mismatch.stderr @@ -1,59 +1,59 @@ error: the constant `*b""` is not of type `[u8; 2]` - --> $DIR/array-const-arg-len-mismatch.rs:30:11 + --> $DIR/array-const-arg-len-mismatch.rs:31:11 | LL | foo::(); | ^^ expected `[u8; 2]`, found `[u8; 0]` | note: required by a const generic parameter in `foo` - --> $DIR/array-const-arg-len-mismatch.rs:11:42 + --> $DIR/array-const-arg-len-mismatch.rs:12:42 | LL | fn foo() -> [T; N] { | ^^^^^^^^^^^^^^^ required by this const generic parameter in `foo` error: the constant `*b"\x00\x00\x00"` is not of type `[u8; 2]` - --> $DIR/array-const-arg-len-mismatch.rs:32:11 + --> $DIR/array-const-arg-len-mismatch.rs:33:11 | LL | foo::(); | ^^ expected `[u8; 2]`, found `[u8; 3]` | note: required by a const generic parameter in `foo` - --> $DIR/array-const-arg-len-mismatch.rs:11:42 + --> $DIR/array-const-arg-len-mismatch.rs:12:42 | LL | fn foo() -> [T; N] { | ^^^^^^^^^^^^^^^ required by this const generic parameter in `foo` error: the constant `*b""` is not of type `[u8; 2]` - --> $DIR/array-const-arg-len-mismatch.rs:34:13 + --> $DIR/array-const-arg-len-mismatch.rs:35:13 | LL | bar::<{ [] }>(); | ^^ expected `[u8; 2]`, found `[u8; 0]` | note: required by a const generic parameter in `bar` - --> $DIR/array-const-arg-len-mismatch.rs:15:8 + --> $DIR/array-const-arg-len-mismatch.rs:16:8 | LL | fn bar() {} | ^^^^^^^^^^^^^^^^ required by this const generic parameter in `bar` error: the constant `*b"\x01\x02\x03"` is not of type `[u8; 2]` - --> $DIR/array-const-arg-len-mismatch.rs:36:13 + --> $DIR/array-const-arg-len-mismatch.rs:37:13 | LL | bar::<{ [1, 2, 3] }>(); | ^^^^^^^^^ expected `[u8; 2]`, found `[u8; 3]` | note: required by a const generic parameter in `bar` - --> $DIR/array-const-arg-len-mismatch.rs:15:8 + --> $DIR/array-const-arg-len-mismatch.rs:16:8 | LL | fn bar() {} | ^^^^^^^^^^^^^^^^ required by this const generic parameter in `bar` error: the constant `*b"*"` is not of type `[u8; 3]` - --> $DIR/array-const-arg-len-mismatch.rs:38:13 + --> $DIR/array-const-arg-len-mismatch.rs:39:13 | LL | baz::<{ [42] }>(); | ^^^^ expected `[u8; 3]`, found `[u8; 1]` | note: required by a const generic parameter in `baz` - --> $DIR/array-const-arg-len-mismatch.rs:27:8 + --> $DIR/array-const-arg-len-mismatch.rs:28:8 | LL | fn baz::LEN]>() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this const generic parameter in `baz` diff --git a/tests/ui/const-generics/mgca/array-expr-complex.r1.stderr b/tests/ui/const-generics/mgca/array-expr-complex.r1.stderr index a226d7ff0c225..2e3b2172b7325 100644 --- a/tests/ui/const-generics/mgca/array-expr-complex.r1.stderr +++ b/tests/ui/const-generics/mgca/array-expr-complex.r1.stderr @@ -1,8 +1,8 @@ error: complex const arguments must be placed inside of a `const` block - --> $DIR/array-expr-complex.rs:11:52 + --> $DIR/array-expr-complex.rs:13:33 | -LL | takes_array::<{ core::direct_const_arg!([1, 2, 1 + 2]) }>(); - | ^^^^^ +LL | takes_array::<{ gca!([1, 2, 1 + 2]) }>(); + | ^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/mgca/array-expr-complex.r2.stderr b/tests/ui/const-generics/mgca/array-expr-complex.r2.stderr index cc1e70c1d9a7a..2b25efb6ab090 100644 --- a/tests/ui/const-generics/mgca/array-expr-complex.r2.stderr +++ b/tests/ui/const-generics/mgca/array-expr-complex.r2.stderr @@ -1,8 +1,8 @@ error: complex const arguments must be placed inside of a `const` block - --> $DIR/array-expr-complex.rs:14:45 + --> $DIR/array-expr-complex.rs:16:26 | -LL | takes_array::<{ core::direct_const_arg!([X; 3]) }>(); - | ^^^^^^ +LL | takes_array::<{ gca!([X; 3]) }>(); + | ^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/mgca/array-expr-complex.r3.stderr b/tests/ui/const-generics/mgca/array-expr-complex.r3.stderr index cc52abe0e8fb8..09515bafa7025 100644 --- a/tests/ui/const-generics/mgca/array-expr-complex.r3.stderr +++ b/tests/ui/const-generics/mgca/array-expr-complex.r3.stderr @@ -1,8 +1,8 @@ error: complex const arguments must be placed inside of a `const` block - --> $DIR/array-expr-complex.rs:17:45 + --> $DIR/array-expr-complex.rs:19:26 | -LL | takes_array::<{ core::direct_const_arg!([0; Y]) }>(); - | ^^^^^^ +LL | takes_array::<{ gca!([0; Y]) }>(); + | ^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/mgca/array-expr-complex.rs b/tests/ui/const-generics/mgca/array-expr-complex.rs index 7f5a77fdff3df..be3b85e2bd240 100644 --- a/tests/ui/const-generics/mgca/array-expr-complex.rs +++ b/tests/ui/const-generics/mgca/array-expr-complex.rs @@ -3,18 +3,20 @@ #![expect(incomplete_features)] #![feature(min_generic_const_args, adt_const_params)] +use std::gca; + fn takes_array() {} fn generic_caller() { // not supported yet #[cfg(r1)] - takes_array::<{ core::direct_const_arg!([1, 2, 1 + 2]) }>(); + takes_array::<{ gca!([1, 2, 1 + 2]) }>(); //[r1]~^ ERROR: complex const arguments must be placed inside of a `const` block #[cfg(r2)] - takes_array::<{ core::direct_const_arg!([X; 3]) }>(); + takes_array::<{ gca!([X; 3]) }>(); //[r2]~^ ERROR: complex const arguments must be placed inside of a `const` block #[cfg(r3)] - takes_array::<{ core::direct_const_arg!([0; Y]) }>(); + takes_array::<{ gca!([0; Y]) }>(); //[r3]~^ ERROR: complex const arguments must be placed inside of a `const` block } diff --git a/tests/ui/const-generics/mgca/array_expr_arg_complex.rs b/tests/ui/const-generics/mgca/array_expr_arg_complex.rs index 3d62adae09ada..76534f12d80c8 100644 --- a/tests/ui/const-generics/mgca/array_expr_arg_complex.rs +++ b/tests/ui/const-generics/mgca/array_expr_arg_complex.rs @@ -1,6 +1,8 @@ #![feature(min_generic_const_args, adt_const_params, unsized_const_params)] #![expect(incomplete_features)] +use std::gca; + trait Trait { #[rustc_always_gca] const ASSOC: usize; @@ -10,8 +12,8 @@ fn takes_array() {} fn takes_tuple_with_array() {} fn generic_caller() { - takes_array::<{ core::direct_const_arg!([N, N + 1]) }>(); //~ ERROR complex const arguments must be placed inside of a `const` block - takes_tuple_with_array::<{ core::direct_const_arg!(([N, N + 1], N)) }>(); //~ ERROR complex const arguments must be placed inside of a `const` block + takes_array::<{ gca!([N, N + 1]) }>(); //~ ERROR complex const arguments must be placed inside of a `const` block + takes_tuple_with_array::<{ gca!(([N, N + 1], N)) }>(); //~ ERROR complex const arguments must be placed inside of a `const` block } fn main() {} diff --git a/tests/ui/const-generics/mgca/array_expr_arg_complex.stderr b/tests/ui/const-generics/mgca/array_expr_arg_complex.stderr index c7db1e4753f8c..b044775b80c94 100644 --- a/tests/ui/const-generics/mgca/array_expr_arg_complex.stderr +++ b/tests/ui/const-generics/mgca/array_expr_arg_complex.stderr @@ -1,14 +1,14 @@ error: complex const arguments must be placed inside of a `const` block - --> $DIR/array_expr_arg_complex.rs:13:49 + --> $DIR/array_expr_arg_complex.rs:15:30 | -LL | takes_array::<{ core::direct_const_arg!([N, N + 1]) }>(); - | ^^^^^ +LL | takes_array::<{ gca!([N, N + 1]) }>(); + | ^^^^^ error: complex const arguments must be placed inside of a `const` block - --> $DIR/array_expr_arg_complex.rs:14:61 + --> $DIR/array_expr_arg_complex.rs:16:42 | -LL | takes_tuple_with_array::<{ core::direct_const_arg!(([N, N + 1], N)) }>(); - | ^^^^^ +LL | takes_tuple_with_array::<{ gca!(([N, N + 1], N)) }>(); + | ^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/mgca/assoc-const-projection-in-bound.rs b/tests/ui/const-generics/mgca/assoc-const-projection-in-bound.rs index 1b4c5b60edb72..9601cbc997f45 100644 --- a/tests/ui/const-generics/mgca/assoc-const-projection-in-bound.rs +++ b/tests/ui/const-generics/mgca/assoc-const-projection-in-bound.rs @@ -4,6 +4,8 @@ #![feature(min_generic_const_args, macroless_generic_const_args)] #![allow(dead_code)] +use std::gca; + trait Abc {} trait A { @@ -12,7 +14,7 @@ trait A { } impl A for T { - const VALUE: usize = core::direct_const_arg!(0); + const VALUE: usize = gca!(0); } trait S {} diff --git a/tests/ui/const-generics/mgca/bad-const-arg-fn-154539.rs b/tests/ui/const-generics/mgca/bad-const-arg-fn-154539.rs index e3d1f577d4f60..a4ad2cccaa544 100644 --- a/tests/ui/const-generics/mgca/bad-const-arg-fn-154539.rs +++ b/tests/ui/const-generics/mgca/bad-const-arg-fn-154539.rs @@ -1,8 +1,10 @@ #![feature(min_generic_const_args)] +use std::gca; + trait Iter< const FN: fn() = { - core::direct_const_arg!(|| { + gca!(|| { //~^ ERROR complex const arguments must be placed inside of a `const` block use std::io::*; write!(_, "") diff --git a/tests/ui/const-generics/mgca/bad-const-arg-fn-154539.stderr b/tests/ui/const-generics/mgca/bad-const-arg-fn-154539.stderr index 96fcea9e906cf..49796692d9dcc 100644 --- a/tests/ui/const-generics/mgca/bad-const-arg-fn-154539.stderr +++ b/tests/ui/const-generics/mgca/bad-const-arg-fn-154539.stderr @@ -1,8 +1,8 @@ error: complex const arguments must be placed inside of a `const` block - --> $DIR/bad-const-arg-fn-154539.rs:5:33 + --> $DIR/bad-const-arg-fn-154539.rs:7:14 | -LL | core::direct_const_arg!(|| { - | _________________________________^ +LL | gca!(|| { + | ______________^ LL | | LL | | use std::io::*; LL | | write!(_, "") diff --git a/tests/ui/const-generics/mgca/bad-direct-const-arg.rs b/tests/ui/const-generics/mgca/bad-direct-const-arg.rs deleted file mode 100644 index 59fdccf29b7b5..0000000000000 --- a/tests/ui/const-generics/mgca/bad-direct-const-arg.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ edition: 2024 - -//! Reject direct const arguments in value/type positions without unrelated brace suggestions. -#![feature(min_generic_const_args)] -#![deny(unused_braces)] - -fn main(x: core::direct_const_arg!(2)) { - //~^ ERROR expected type, found `direct_const_arg!()` constant - let _ = core::direct_const_arg!(2); - //~^ ERROR expected expression, found `direct_const_arg!()` constant - consume({ core::direct_const_arg!(2) }); - //~^ ERROR expected expression, found `direct_const_arg!()` constant -} - -fn consume(_: usize) {} diff --git a/tests/ui/const-generics/mgca/bad-direct-const-arg.stderr b/tests/ui/const-generics/mgca/bad-direct-const-arg.stderr deleted file mode 100644 index d54a2c4400ea7..0000000000000 --- a/tests/ui/const-generics/mgca/bad-direct-const-arg.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: expected expression, found `direct_const_arg!()` constant - --> $DIR/bad-direct-const-arg.rs:9:13 - | -LL | let _ = core::direct_const_arg!(2); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: expected expression, found `direct_const_arg!()` constant - --> $DIR/bad-direct-const-arg.rs:11:15 - | -LL | consume({ core::direct_const_arg!(2) }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: expected type, found `direct_const_arg!()` constant - --> $DIR/bad-direct-const-arg.rs:7:12 - | -LL | fn main(x: core::direct_const_arg!(2)) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 3 previous errors - diff --git a/tests/ui/const-generics/mgca/bad-gca-macro.rs b/tests/ui/const-generics/mgca/bad-gca-macro.rs new file mode 100644 index 0000000000000..50f2ebe65e818 --- /dev/null +++ b/tests/ui/const-generics/mgca/bad-gca-macro.rs @@ -0,0 +1,17 @@ +//@ edition: 2024 + +//! Reject direct const arguments in value/type positions without unrelated brace suggestions. +#![feature(min_generic_const_args)] +#![deny(unused_braces)] + +use std::gca; + +fn main(x: gca!(2)) { + //~^ ERROR expected type, found `gca!()` constant + let _ = gca!(2); + //~^ ERROR expected expression, found `gca!()` constant + consume({ gca!(2) }); + //~^ ERROR expected expression, found `gca!()` constant +} + +fn consume(_: usize) {} diff --git a/tests/ui/const-generics/mgca/bad-gca-macro.stderr b/tests/ui/const-generics/mgca/bad-gca-macro.stderr new file mode 100644 index 0000000000000..e22bfc76d43c7 --- /dev/null +++ b/tests/ui/const-generics/mgca/bad-gca-macro.stderr @@ -0,0 +1,20 @@ +error: expected expression, found `gca!()` constant + --> $DIR/bad-gca-macro.rs:11:13 + | +LL | let _ = gca!(2); + | ^^^^^^^ + +error: expected expression, found `gca!()` constant + --> $DIR/bad-gca-macro.rs:13:15 + | +LL | consume({ gca!(2) }); + | ^^^^^^^ + +error: expected type, found `gca!()` constant + --> $DIR/bad-gca-macro.rs:9:12 + | +LL | fn main(x: gca!(2)) { + | ^^^^^^^ + +error: aborting due to 3 previous errors + diff --git a/tests/ui/const-generics/mgca/bad-type_const-syntax.rs b/tests/ui/const-generics/mgca/bad-type_const-syntax.rs index 9ffc2b70eecaf..c0391d54e423d 100644 --- a/tests/ui/const-generics/mgca/bad-type_const-syntax.rs +++ b/tests/ui/const-generics/mgca/bad-type_const-syntax.rs @@ -2,15 +2,22 @@ trait Tr { #[rustc_always_gca] //~^ ERROR: the `rustc_always_gca` attribute is an experimental feature [E0658] const N: usize; + #[rustc_always_gca] + //~^ ERROR: the `rustc_always_gca` attribute is an experimental feature [E0658] + const M: usize; } struct S; impl Tr for S { - const N: usize = core::direct_const_arg!(0); + const N: usize = core::gca!(0); + //~^ ERROR: use of unstable library feature `min_generic_const_args` [E0658] + //~| ERROR: implementation of a `#[rustc_always_gca]` must have a `gca!` RHS + //~| ERROR: expected expression, found `gca!()` constant + const M: usize = std::gca!(0); //~^ ERROR: use of unstable library feature `min_generic_const_args` [E0658] - //~| ERROR: implementation of a `#[rustc_always_gca]` must have a `direct_const_arg!` RHS - //~| ERROR: expected expression, found `direct_const_arg!()` constant + //~| ERROR: implementation of a `#[rustc_always_gca]` must have a `gca!` RHS + //~| ERROR: expected expression, found `gca!()` constant } fn main() {} diff --git a/tests/ui/const-generics/mgca/bad-type_const-syntax.stderr b/tests/ui/const-generics/mgca/bad-type_const-syntax.stderr index 31be797b12590..0e8c2f4971a41 100644 --- a/tests/ui/const-generics/mgca/bad-type_const-syntax.stderr +++ b/tests/ui/const-generics/mgca/bad-type_const-syntax.stderr @@ -1,8 +1,18 @@ error[E0658]: use of unstable library feature `min_generic_const_args` - --> $DIR/bad-type_const-syntax.rs:10:22 + --> $DIR/bad-type_const-syntax.rs:13:22 | -LL | const N: usize = core::direct_const_arg!(0); - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | const N: usize = core::gca!(0); + | ^^^^^^^^^ + | + = note: see issue #132980 for more information + = help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: use of unstable library feature `min_generic_const_args` + --> $DIR/bad-type_const-syntax.rs:17:22 + | +LL | const M: usize = std::gca!(0); + | ^^^^^^^^ | = note: see issue #132980 for more information = help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable @@ -18,16 +28,32 @@ LL | #[rustc_always_gca] = help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: expected expression, found `direct_const_arg!()` constant - --> $DIR/bad-type_const-syntax.rs:10:22 +error[E0658]: the `rustc_always_gca` attribute is an experimental feature + --> $DIR/bad-type_const-syntax.rs:5:7 + | +LL | #[rustc_always_gca] + | ^^^^^^^^^^^^^^^^ | -LL | const N: usize = core::direct_const_arg!(0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: see issue #132980 for more information + = help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error: expected expression, found `gca!()` constant + --> $DIR/bad-type_const-syntax.rs:13:22 + | +LL | const N: usize = core::gca!(0); + | ^^^^^^^^^^^^^ -error: implementation of a `#[rustc_always_gca]` must have a `direct_const_arg!` RHS - --> $DIR/bad-type_const-syntax.rs:10:5 +error: expected expression, found `gca!()` constant + --> $DIR/bad-type_const-syntax.rs:17:22 | -LL | const N: usize = core::direct_const_arg!(0); +LL | const M: usize = std::gca!(0); + | ^^^^^^^^^^^^ + +error: implementation of a `#[rustc_always_gca]` must have a `gca!` RHS + --> $DIR/bad-type_const-syntax.rs:13:5 + | +LL | const N: usize = core::gca!(0); | ^^^^^^^^^^^^^^ | note: trait declaration of const is marked as `#[rustc_always_gca]` @@ -36,6 +62,18 @@ note: trait declaration of const is marked as `#[rustc_always_gca]` LL | const N: usize; | ^^^^^^^^^^^^^^ -error: aborting due to 4 previous errors +error: implementation of a `#[rustc_always_gca]` must have a `gca!` RHS + --> $DIR/bad-type_const-syntax.rs:17:5 + | +LL | const M: usize = std::gca!(0); + | ^^^^^^^^^^^^^^ + | +note: trait declaration of const is marked as `#[rustc_always_gca]` + --> $DIR/bad-type_const-syntax.rs:7:5 + | +LL | const M: usize; + | ^^^^^^^^^^^^^^ + +error: aborting due to 8 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/const-generics/mgca/braced-const-infer-in-body.rs b/tests/ui/const-generics/mgca/braced-const-infer-in-body.rs index a696ff5964e7f..38851a6e5130f 100644 --- a/tests/ui/const-generics/mgca/braced-const-infer-in-body.rs +++ b/tests/ui/const-generics/mgca/braced-const-infer-in-body.rs @@ -3,6 +3,8 @@ #![feature(min_generic_const_args)] #![feature(macroless_generic_const_args)] +use std::gca; + trait Trait {} impl Trait for i32 {} @@ -13,11 +15,11 @@ fn main() { // Const-only infer args used for a type parameter are rejected. let _z: &[&dyn Trait<{ _ }>] = &[&0i32]; //~^ ERROR: constant provided when a type was expected - let _y: &dyn Trait = &0i32; + let _y: &dyn Trait = &0i32; //~^ ERROR: constant provided when a type was expected let _a: S<{ _ }> = S::<3>; - let _b: S = S::<3>; - let _c: S<{ core::direct_const_arg!(_) }> = S::<3>; + let _b: S = S::<3>; + let _c: S<{ gca!(_) }> = S::<3>; let _d: S<_> = S::<3>; } diff --git a/tests/ui/const-generics/mgca/braced-const-infer-in-body.stderr b/tests/ui/const-generics/mgca/braced-const-infer-in-body.stderr index dec966c111253..2a7960c57b1e9 100644 --- a/tests/ui/const-generics/mgca/braced-const-infer-in-body.stderr +++ b/tests/ui/const-generics/mgca/braced-const-infer-in-body.stderr @@ -1,14 +1,14 @@ error[E0747]: constant provided when a type was expected - --> $DIR/braced-const-infer-in-body.rs:14:28 + --> $DIR/braced-const-infer-in-body.rs:16:28 | LL | let _z: &[&dyn Trait<{ _ }>] = &[&0i32]; | ^ error[E0747]: constant provided when a type was expected - --> $DIR/braced-const-infer-in-body.rs:16:48 + --> $DIR/braced-const-infer-in-body.rs:18:29 | -LL | let _y: &dyn Trait = &0i32; - | ^ +LL | let _y: &dyn Trait = &0i32; + | ^ error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/mgca/concrete-expr-with-generics-in-env.rs b/tests/ui/const-generics/mgca/concrete-expr-with-generics-in-env.rs index b365de395e80d..9f6a62aa60e17 100644 --- a/tests/ui/const-generics/mgca/concrete-expr-with-generics-in-env.rs +++ b/tests/ui/const-generics/mgca/concrete-expr-with-generics-in-env.rs @@ -3,8 +3,7 @@ #![expect(incomplete_features)] #![feature(min_generic_const_args, generic_const_items)] -extern crate core; -use core::direct_const_arg; +use std::gca; pub trait Tr { #[rustc_always_gca] @@ -18,9 +17,9 @@ pub trait Tr { pub struct S; impl Tr for S { - const N1: usize = core::direct_const_arg!(0); - const N2: usize = core::direct_const_arg!(1); - const N3: usize = core::direct_const_arg!(2); + const N1: usize = gca!(0); + const N2: usize = gca!(1); + const N3: usize = gca!(2); } fn main() {} diff --git a/tests/ui/const-generics/mgca/const-arg-coherence-conflicting-methods.rs b/tests/ui/const-generics/mgca/const-arg-coherence-conflicting-methods.rs index c89c6a14a367a..e19b71153b1e5 100644 --- a/tests/ui/const-generics/mgca/const-arg-coherence-conflicting-methods.rs +++ b/tests/ui/const-generics/mgca/const-arg-coherence-conflicting-methods.rs @@ -3,7 +3,9 @@ #![expect(incomplete_features)] #![feature(min_generic_const_args)] -const C: usize = core::direct_const_arg!(0); +use std::gca; + +const C: usize = gca!(0); pub struct A {} impl A { fn fun1() {} diff --git a/tests/ui/const-generics/mgca/const-arg-coherence-conflicting-methods.stderr b/tests/ui/const-generics/mgca/const-arg-coherence-conflicting-methods.stderr index 3d74d1db206e1..c82f8a96167ba 100644 --- a/tests/ui/const-generics/mgca/const-arg-coherence-conflicting-methods.stderr +++ b/tests/ui/const-generics/mgca/const-arg-coherence-conflicting-methods.stderr @@ -1,11 +1,11 @@ error[E0107]: missing generics for struct `A` - --> $DIR/const-arg-coherence-conflicting-methods.rs:12:6 + --> $DIR/const-arg-coherence-conflicting-methods.rs:14:6 | LL | impl A { | ^ expected 1 generic argument | note: struct defined here, with 1 generic parameter: `M` - --> $DIR/const-arg-coherence-conflicting-methods.rs:7:12 + --> $DIR/const-arg-coherence-conflicting-methods.rs:9:12 | LL | pub struct A {} | ^ -------------- @@ -15,7 +15,7 @@ LL | impl A { | +++ error[E0592]: duplicate definitions with name `fun1` - --> $DIR/const-arg-coherence-conflicting-methods.rs:9:5 + --> $DIR/const-arg-coherence-conflicting-methods.rs:11:5 | LL | fn fun1() {} | ^^^^^^^^^ duplicate definitions for `fun1` diff --git a/tests/ui/const-generics/mgca/const-arg-mismatched-literal-suffix.rs b/tests/ui/const-generics/mgca/const-arg-mismatched-literal-suffix.rs index df2dd048e6a43..c4e941edbb4de 100644 --- a/tests/ui/const-generics/mgca/const-arg-mismatched-literal-suffix.rs +++ b/tests/ui/const-generics/mgca/const-arg-mismatched-literal-suffix.rs @@ -1,7 +1,9 @@ #![feature(min_generic_const_args)] #![expect(incomplete_features)] -const CONST: usize = core::direct_const_arg!(1_i32); +use std::gca; + +const CONST: usize = gca!(1_i32); //~^ ERROR the constant `1` is not of type `usize` //~| NOTE expected `usize`, found `i32` diff --git a/tests/ui/const-generics/mgca/const-arg-mismatched-literal-suffix.stderr b/tests/ui/const-generics/mgca/const-arg-mismatched-literal-suffix.stderr index 49f9f76d6cb1b..3f009d17be58a 100644 --- a/tests/ui/const-generics/mgca/const-arg-mismatched-literal-suffix.stderr +++ b/tests/ui/const-generics/mgca/const-arg-mismatched-literal-suffix.stderr @@ -1,7 +1,7 @@ error: the constant `1` is not of type `usize` - --> $DIR/const-arg-mismatched-literal-suffix.rs:4:1 + --> $DIR/const-arg-mismatched-literal-suffix.rs:6:1 | -LL | const CONST: usize = core::direct_const_arg!(1_i32); +LL | const CONST: usize = gca!(1_i32); | ^^^^^^^^^^^^^^^^^^ expected `usize`, found `i32` error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/mgca/cyclic-type-const-151251.rs b/tests/ui/const-generics/mgca/cyclic-type-const-151251.rs index 89320472a3913..7c0a6c9f7771b 100644 --- a/tests/ui/const-generics/mgca/cyclic-type-const-151251.rs +++ b/tests/ui/const-generics/mgca/cyclic-type-const-151251.rs @@ -4,7 +4,9 @@ #![feature(generic_const_exprs)] #![expect(incomplete_features)] -const A: u8 = core::direct_const_arg!(A); +use std::gca; + +const A: u8 = gca!(A); //~^ ERROR cycle detected when computing the type-level value for `A` fn main() {} diff --git a/tests/ui/const-generics/mgca/cyclic-type-const-151251.stderr b/tests/ui/const-generics/mgca/cyclic-type-const-151251.stderr index ac37da026f95f..934057da24139 100644 --- a/tests/ui/const-generics/mgca/cyclic-type-const-151251.stderr +++ b/tests/ui/const-generics/mgca/cyclic-type-const-151251.stderr @@ -1,7 +1,7 @@ error[E0391]: cycle detected when computing the type-level value for `A` - --> $DIR/cyclic-type-const-151251.rs:7:1 + --> $DIR/cyclic-type-const-151251.rs:9:1 | -LL | const A: u8 = core::direct_const_arg!(A); +LL | const A: u8 = gca!(A); | ^^^^^^^^^^^ | = note: ...which immediately requires computing the type-level value for `A` again diff --git a/tests/ui/const-generics/mgca/direct-const-arg-correct-rib.stderr b/tests/ui/const-generics/mgca/direct-const-arg-correct-rib.stderr deleted file mode 100644 index 76f189e38e4d5..0000000000000 --- a/tests/ui/const-generics/mgca/direct-const-arg-correct-rib.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: attempt to use a non-constant value in a constant - --> $DIR/direct-const-arg-correct-rib.rs:8:42 - | -LL | let _: V; - | ^^^^ help: try using `Self` - -error: aborting due to 1 previous error - diff --git a/tests/ui/const-generics/mgca/direct-const-arg-multiple-exprs.rs b/tests/ui/const-generics/mgca/direct-const-arg-multiple-exprs.rs deleted file mode 100644 index 8c802e563db7c..0000000000000 --- a/tests/ui/const-generics/mgca/direct-const-arg-multiple-exprs.rs +++ /dev/null @@ -1,5 +0,0 @@ -#![feature(min_generic_const_args)] -struct S; -fn foo(_: S) {} -//~^ ERROR direct_const_arg! takes 1 argument -fn main() {} diff --git a/tests/ui/const-generics/mgca/direct-const-arg-multiple-exprs.stderr b/tests/ui/const-generics/mgca/direct-const-arg-multiple-exprs.stderr deleted file mode 100644 index 6f54a563ffbfc..0000000000000 --- a/tests/ui/const-generics/mgca/direct-const-arg-multiple-exprs.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: direct_const_arg! takes 1 argument - --> $DIR/direct-const-arg-multiple-exprs.rs:3:45 - | -LL | fn foo(_: S) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/const-generics/mgca/direct_const_arg-infer-as-type.rs b/tests/ui/const-generics/mgca/direct_const_arg-infer-as-type.rs deleted file mode 100644 index 9e2c744c617c5..0000000000000 --- a/tests/ui/const-generics/mgca/direct_const_arg-infer-as-type.rs +++ /dev/null @@ -1,13 +0,0 @@ -//! `direct_const_arg!(_)` used to be allowed to infer to a type as a compiler -//! implementation quirk. Since it uses explicit const argument syntax, -//! it is now rejected when passed as a type argument -#![feature(min_generic_const_args)] - -struct S(T); - -fn main() { - let _: S = S(2u32); - //~^ ERROR: constant provided when a type was expected - let _: S<{ core::direct_const_arg!(_) }> = S(2u32); - //~^ ERROR: constant provided when a type was expected -} diff --git a/tests/ui/const-generics/mgca/direct_const_arg-infer-as-type.stderr b/tests/ui/const-generics/mgca/direct_const_arg-infer-as-type.stderr deleted file mode 100644 index 07e0faf0ba792..0000000000000 --- a/tests/ui/const-generics/mgca/direct_const_arg-infer-as-type.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0747]: constant provided when a type was expected - --> $DIR/direct_const_arg-infer-as-type.rs:9:38 - | -LL | let _: S = S(2u32); - | ^ - -error[E0747]: constant provided when a type was expected - --> $DIR/direct_const_arg-infer-as-type.rs:11:40 - | -LL | let _: S<{ core::direct_const_arg!(_) }> = S(2u32); - | ^ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0747`. diff --git a/tests/ui/const-generics/mgca/explicit_anon_consts.rs b/tests/ui/const-generics/mgca/explicit_anon_consts.rs index 2fc1a0ea4b8ed..3c7c1da90ed39 100644 --- a/tests/ui/const-generics/mgca/explicit_anon_consts.rs +++ b/tests/ui/const-generics/mgca/explicit_anon_consts.rs @@ -4,13 +4,15 @@ // DefIds which were created for const args. #![crate_type = "lib"] +use std::gca; + struct Foo; type Adt1 = Foo; type Adt2 = Foo<{ N }>; type Adt3 = Foo; //~^ ERROR: generic parameters may not be used in const operations -type Adt4 = Foo; +type Adt4 = Foo; //~^ ERROR: complex const arguments must be placed inside of a `const` block type Adt5 = Foo; @@ -18,7 +20,7 @@ type Arr = [(); N]; type Arr2 = [(); { N }]; type Arr3 = [(); const { N }]; //~^ ERROR: generic parameters may not be used in const operations -type Arr4 = [(); core::direct_const_arg!(1 + 1)]; +type Arr4 = [(); gca!(1 + 1)]; //~^ ERROR: complex const arguments must be placed inside of a `const` block type Arr5 = [(); const { 1 + 1 }]; @@ -27,24 +29,24 @@ fn repeats() -> [(); N] { let _2 = [(); { N }]; let _3 = [(); const { N }]; //~^ ERROR: generic parameters may not be used in const operations - let _4 = [(); core::direct_const_arg!(1 + 1)]; + let _4 = [(); gca!(1 + 1)]; //~^ ERROR: complex const arguments must be placed inside of a `const` block let _5 = [(); const { 1 + 1 }]; let _6: [(); const { N }] = todo!(); //~^ ERROR: generic parameters may not be used in const operations } -const ITEM1: usize = core::direct_const_arg!(N); +const ITEM1: usize = gca!(N); -const ITEM2: usize = core::direct_const_arg!({ N }); +const ITEM2: usize = gca!({ N }); -const ITEM3: usize = core::direct_const_arg!(const { N }); +const ITEM3: usize = gca!(const { N }); //~^ ERROR: generic parameters may not be used in const operations -const ITEM4: usize = core::direct_const_arg!(1 + 1); +const ITEM4: usize = gca!(1 + 1); //~^ ERROR: complex const arguments must be placed inside of a `const` block -const ITEM5: usize = core::direct_const_arg!(const { 1 + 1 }); +const ITEM5: usize = gca!(const { 1 + 1 }); trait Trait { #[rustc_always_gca] @@ -58,7 +60,7 @@ fn ace_bounds< T2: Trait, T3: Trait, //~^ ERROR: generic parameters may not be used in const operations - T4: Trait, + T4: Trait, //~^ ERROR: complex const arguments must be placed inside of a `const` block T5: Trait, >() { @@ -68,6 +70,6 @@ struct Default1; struct Default2; struct Default3; //~^ ERROR: generic parameters may not be used in const operations -struct Default4; +struct Default4; //~^ ERROR: complex const arguments must be placed inside of a `const` block struct Default5; diff --git a/tests/ui/const-generics/mgca/explicit_anon_consts.stderr b/tests/ui/const-generics/mgca/explicit_anon_consts.stderr index aa479bce84a7e..ad533df5138f5 100644 --- a/tests/ui/const-generics/mgca/explicit_anon_consts.stderr +++ b/tests/ui/const-generics/mgca/explicit_anon_consts.stderr @@ -1,49 +1,49 @@ error: complex const arguments must be placed inside of a `const` block - --> $DIR/explicit_anon_consts.rs:13:57 + --> $DIR/explicit_anon_consts.rs:15:38 | -LL | type Adt4 = Foo; - | ^^^^^ +LL | type Adt4 = Foo; + | ^^^^^ error: complex const arguments must be placed inside of a `const` block - --> $DIR/explicit_anon_consts.rs:21:58 + --> $DIR/explicit_anon_consts.rs:23:39 | -LL | type Arr4 = [(); core::direct_const_arg!(1 + 1)]; - | ^^^^^ +LL | type Arr4 = [(); gca!(1 + 1)]; + | ^^^^^ error: complex const arguments must be placed inside of a `const` block - --> $DIR/explicit_anon_consts.rs:30:43 + --> $DIR/explicit_anon_consts.rs:32:24 | -LL | let _4 = [(); core::direct_const_arg!(1 + 1)]; - | ^^^^^ +LL | let _4 = [(); gca!(1 + 1)]; + | ^^^^^ error: complex const arguments must be placed inside of a `const` block - --> $DIR/explicit_anon_consts.rs:44:62 + --> $DIR/explicit_anon_consts.rs:46:43 | -LL | const ITEM4: usize = core::direct_const_arg!(1 + 1); - | ^^^^^ +LL | const ITEM4: usize = gca!(1 + 1); + | ^^^^^ error: complex const arguments must be placed inside of a `const` block - --> $DIR/explicit_anon_consts.rs:61:49 + --> $DIR/explicit_anon_consts.rs:63:30 | -LL | T4: Trait, - | ^^^^^ +LL | T4: Trait, + | ^^^^^ error: complex const arguments must be placed inside of a `const` block - --> $DIR/explicit_anon_consts.rs:71:76 + --> $DIR/explicit_anon_consts.rs:73:57 | -LL | struct Default4; - | ^^^^^ +LL | struct Default4; + | ^^^^^ error: generic parameters may not be used in const operations - --> $DIR/explicit_anon_consts.rs:41:70 + --> $DIR/explicit_anon_consts.rs:43:51 | -LL | const ITEM3: usize = core::direct_const_arg!(const { N }); - | ^ +LL | const ITEM3: usize = gca!(const { N }); + | ^ | = help: add `#![feature(generic_const_args)]` and extract the expression into a `type const` item error: generic parameters may not be used in const operations - --> $DIR/explicit_anon_consts.rs:59:31 + --> $DIR/explicit_anon_consts.rs:61:31 | LL | T3: Trait, | ^ @@ -51,7 +51,7 @@ LL | T3: Trait, = help: add `#![feature(generic_const_args)]` and extract the expression into a `type const` item error: generic parameters may not be used in const operations - --> $DIR/explicit_anon_consts.rs:69:58 + --> $DIR/explicit_anon_consts.rs:71:58 | LL | struct Default3; | ^ @@ -59,7 +59,7 @@ LL | struct Default3; = help: add `#![feature(generic_const_args)]` and extract the expression into a `type const` item error: generic parameters may not be used in const operations - --> $DIR/explicit_anon_consts.rs:28:27 + --> $DIR/explicit_anon_consts.rs:30:27 | LL | let _3 = [(); const { N }]; | ^ @@ -67,7 +67,7 @@ LL | let _3 = [(); const { N }]; = help: add `#![feature(generic_const_args)]` and extract the expression into a `type const` item error: generic parameters may not be used in const operations - --> $DIR/explicit_anon_consts.rs:33:26 + --> $DIR/explicit_anon_consts.rs:35:26 | LL | let _6: [(); const { N }] = todo!(); | ^ @@ -75,7 +75,7 @@ LL | let _6: [(); const { N }] = todo!(); = help: add `#![feature(generic_const_args)]` and extract the expression into a `type const` item error: generic parameters may not be used in const operations - --> $DIR/explicit_anon_consts.rs:11:41 + --> $DIR/explicit_anon_consts.rs:13:41 | LL | type Adt3 = Foo; | ^ @@ -83,7 +83,7 @@ LL | type Adt3 = Foo; = help: add `#![feature(generic_const_args)]` and extract the expression into a `type const` item error: generic parameters may not be used in const operations - --> $DIR/explicit_anon_consts.rs:19:42 + --> $DIR/explicit_anon_consts.rs:21:42 | LL | type Arr3 = [(); const { N }]; | ^ diff --git a/tests/ui/const-generics/mgca/free-const-recursive.gca.stderr b/tests/ui/const-generics/mgca/free-const-recursive.gca.stderr index fdbfeae464f8d..7bdab2d09acda 100644 --- a/tests/ui/const-generics/mgca/free-const-recursive.gca.stderr +++ b/tests/ui/const-generics/mgca/free-const-recursive.gca.stderr @@ -1,13 +1,13 @@ error[E0275]: overflow evaluating the requirement `A == _` - --> $DIR/free-const-recursive.rs:11:1 + --> $DIR/free-const-recursive.rs:13:1 | -LL | const A: () = core::direct_const_arg!(A); +LL | const A: () = gca!(A); | ^^^^^^^^^^^ error[E0275]: overflow evaluating the requirement `the constant `A` has type `()`` - --> $DIR/free-const-recursive.rs:11:1 + --> $DIR/free-const-recursive.rs:13:1 | -LL | const A: () = core::direct_const_arg!(A); +LL | const A: () = gca!(A); | ^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/mgca/free-const-recursive.min_gca.stderr b/tests/ui/const-generics/mgca/free-const-recursive.min_gca.stderr index 5f588a00055b6..3dcce0ad7eea6 100644 --- a/tests/ui/const-generics/mgca/free-const-recursive.min_gca.stderr +++ b/tests/ui/const-generics/mgca/free-const-recursive.min_gca.stderr @@ -1,7 +1,7 @@ error[E0391]: cycle detected when computing the type-level value for `A` - --> $DIR/free-const-recursive.rs:11:1 + --> $DIR/free-const-recursive.rs:13:1 | -LL | const A: () = core::direct_const_arg!(A); +LL | const A: () = gca!(A); | ^^^^^^^^^^^ | = note: ...which immediately requires computing the type-level value for `A` again diff --git a/tests/ui/const-generics/mgca/free-const-recursive.rs b/tests/ui/const-generics/mgca/free-const-recursive.rs index 6d4d78b46dccc..3fdeb37aa5d5d 100644 --- a/tests/ui/const-generics/mgca/free-const-recursive.rs +++ b/tests/ui/const-generics/mgca/free-const-recursive.rs @@ -8,7 +8,9 @@ #![expect(incomplete_features)] #![cfg_attr(gca, feature(generic_const_args))] -const A: () = core::direct_const_arg!(A); +use std::gca; + +const A: () = gca!(A); //[gca]~^ ERROR: overflow evaluating the requirement `A == _` //[gca]~| ERROR: overflow evaluating the requirement `the constant `A` has type `()`` //[min_gca]~^^^ ERROR: cycle detected when computing the type-level value for `A` diff --git a/tests/ui/const-generics/mgca/direct-const-arg-correct-rib.rs b/tests/ui/const-generics/mgca/gca-macro-correct-rib.rs similarity index 57% rename from tests/ui/const-generics/mgca/direct-const-arg-correct-rib.rs rename to tests/ui/const-generics/mgca/gca-macro-correct-rib.rs index 9f088a05b98f9..b03bbb7faacc3 100644 --- a/tests/ui/const-generics/mgca/direct-const-arg-correct-rib.rs +++ b/tests/ui/const-generics/mgca/gca-macro-correct-rib.rs @@ -1,11 +1,13 @@ -//! make sure TyKind::DirectConstArg resolves properly with the correct ribs and doesn't ICE +//! make sure TyKind::GcaMacro resolves properly with the correct ribs and doesn't ICE #![feature(min_generic_const_args)] +use std::gca; + struct S; struct V; impl S { fn f(self) { - let _: V; + let _: V; //~^ ERROR attempt to use a non-constant value in a constant } } diff --git a/tests/ui/const-generics/mgca/gca-macro-correct-rib.stderr b/tests/ui/const-generics/mgca/gca-macro-correct-rib.stderr new file mode 100644 index 0000000000000..baf864f60f8f0 --- /dev/null +++ b/tests/ui/const-generics/mgca/gca-macro-correct-rib.stderr @@ -0,0 +1,8 @@ +error: attempt to use a non-constant value in a constant + --> $DIR/gca-macro-correct-rib.rs:10:23 + | +LL | let _: V; + | ^^^^ help: try using `Self` + +error: aborting due to 1 previous error + diff --git a/tests/ui/const-generics/mgca/direct-const-arg-feature-gate.rs b/tests/ui/const-generics/mgca/gca-macro-feature-gate.rs similarity index 52% rename from tests/ui/const-generics/mgca/direct-const-arg-feature-gate.rs rename to tests/ui/const-generics/mgca/gca-macro-feature-gate.rs index 16ba349a29be6..1f4d302110490 100644 --- a/tests/ui/const-generics/mgca/direct-const-arg-feature-gate.rs +++ b/tests/ui/const-generics/mgca/gca-macro-feature-gate.rs @@ -1,5 +1,5 @@ -fn foo(_: [(); core::direct_const_arg!(N)]) {} +fn foo(_: [(); std::gca!(N)]) {} //~^ ERROR use of unstable library feature `min_generic_const_args` -//~| ERROR expected expression, found `direct_const_arg!()` constant +//~| ERROR expected expression, found `gca!()` constant //~| ERROR generic parameters may not be used in const operations fn main() {} diff --git a/tests/ui/const-generics/mgca/direct-const-arg-feature-gate.stderr b/tests/ui/const-generics/mgca/gca-macro-feature-gate.stderr similarity index 56% rename from tests/ui/const-generics/mgca/direct-const-arg-feature-gate.stderr rename to tests/ui/const-generics/mgca/gca-macro-feature-gate.stderr index a2927d0625b55..70586b9b288b4 100644 --- a/tests/ui/const-generics/mgca/direct-const-arg-feature-gate.stderr +++ b/tests/ui/const-generics/mgca/gca-macro-feature-gate.stderr @@ -1,28 +1,28 @@ error[E0658]: use of unstable library feature `min_generic_const_args` - --> $DIR/direct-const-arg-feature-gate.rs:1:32 + --> $DIR/gca-macro-feature-gate.rs:1:32 | -LL | fn foo(_: [(); core::direct_const_arg!(N)]) {} - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(_: [(); std::gca!(N)]) {} + | ^^^^^^^^ | = note: see issue #132980 for more information = help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: generic parameters may not be used in const operations - --> $DIR/direct-const-arg-feature-gate.rs:1:56 + --> $DIR/gca-macro-feature-gate.rs:1:42 | -LL | fn foo(_: [(); core::direct_const_arg!(N)]) {} - | ^ cannot perform const operation using `N` +LL | fn foo(_: [(); std::gca!(N)]) {} + | ^ cannot perform const operation using `N` | = help: const parameters may only be used as standalone arguments here, i.e. `N` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions = help: alternatively, you can use `#![feature(generic_const_args)]` and extract the expression into a `type const` item -error: expected expression, found `direct_const_arg!()` constant - --> $DIR/direct-const-arg-feature-gate.rs:1:32 +error: expected expression, found `gca!()` constant + --> $DIR/gca-macro-feature-gate.rs:1:32 | -LL | fn foo(_: [(); core::direct_const_arg!(N)]) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(_: [(); std::gca!(N)]) {} + | ^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/const-generics/mgca/gca-macro-infer-as-type.rs b/tests/ui/const-generics/mgca/gca-macro-infer-as-type.rs new file mode 100644 index 0000000000000..155626ad9d47f --- /dev/null +++ b/tests/ui/const-generics/mgca/gca-macro-infer-as-type.rs @@ -0,0 +1,14 @@ +//! `gca!(_)` used to be allowed to infer to a type as a compiler implementation quirk. Since it +//! uses explicit const argument syntax, it is now rejected when passed as a type argument +#![feature(min_generic_const_args)] + +use std::gca; + +struct S(T); + +fn main() { + let _: S = S(2u32); + //~^ ERROR: constant provided when a type was expected + let _: S<{ gca!(_) }> = S(2u32); + //~^ ERROR: constant provided when a type was expected +} diff --git a/tests/ui/const-generics/mgca/gca-macro-infer-as-type.stderr b/tests/ui/const-generics/mgca/gca-macro-infer-as-type.stderr new file mode 100644 index 0000000000000..22c20958b6626 --- /dev/null +++ b/tests/ui/const-generics/mgca/gca-macro-infer-as-type.stderr @@ -0,0 +1,15 @@ +error[E0747]: constant provided when a type was expected + --> $DIR/gca-macro-infer-as-type.rs:10:19 + | +LL | let _: S = S(2u32); + | ^ + +error[E0747]: constant provided when a type was expected + --> $DIR/gca-macro-infer-as-type.rs:12:21 + | +LL | let _: S<{ gca!(_) }> = S(2u32); + | ^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0747`. diff --git a/tests/ui/const-generics/mgca/gca-macro-multiple-exprs.rs b/tests/ui/const-generics/mgca/gca-macro-multiple-exprs.rs new file mode 100644 index 0000000000000..518fc63d68bb9 --- /dev/null +++ b/tests/ui/const-generics/mgca/gca-macro-multiple-exprs.rs @@ -0,0 +1,6 @@ +#![feature(min_generic_const_args)] +use std::gca; +struct S; +fn foo(_: S) {} +//~^ ERROR gca! takes 1 argument +fn main() {} diff --git a/tests/ui/const-generics/mgca/gca-macro-multiple-exprs.stderr b/tests/ui/const-generics/mgca/gca-macro-multiple-exprs.stderr new file mode 100644 index 0000000000000..992d981624924 --- /dev/null +++ b/tests/ui/const-generics/mgca/gca-macro-multiple-exprs.stderr @@ -0,0 +1,8 @@ +error: gca! takes 1 argument + --> $DIR/gca-macro-multiple-exprs.rs:4:45 + | +LL | fn foo(_: S) {} + | ^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/const-generics/mgca/generic-args-on-enum-variant-segments-fail.rs b/tests/ui/const-generics/mgca/generic-args-on-enum-variant-segments-fail.rs index b435dcde6dc93..4f71ad857cf5a 100644 --- a/tests/ui/const-generics/mgca/generic-args-on-enum-variant-segments-fail.rs +++ b/tests/ui/const-generics/mgca/generic-args-on-enum-variant-segments-fail.rs @@ -1,5 +1,6 @@ #![feature(min_generic_const_args)] #![feature(adt_const_params, unsized_const_params)] +use std::gca; #[derive(PartialEq, Eq, std::marker::ConstParamTy)] pub enum Enum { Unit, @@ -10,10 +11,10 @@ pub mod module { pub use super::Enum::Store; } fn main() { - const _: Enum<()> = core::direct_const_arg!(Enum::<()>::Unit::<()>); + const _: Enum<()> = gca!(Enum::<()>::Unit::<()>); //~^ ERROR: type arguments are not allowed on unit variant `Unit` [E0109] - const _: Enum<()> = core::direct_const_arg!(Enum::<()>::Tuple::<()>()); + const _: Enum<()> = gca!(Enum::<()>::Tuple::<()>()); //~^ ERROR: type arguments are not allowed on tuple variant `Tuple` [E0109] - const _: Enum<()> = core::direct_const_arg!(self::::Enum::<()>::Store); + const _: Enum<()> = gca!(self::::Enum::<()>::Store); //~^ ERROR: type arguments are not allowed on module `generic_args_on_enum_variant_segments_fail` [E0109] } diff --git a/tests/ui/const-generics/mgca/generic-args-on-enum-variant-segments-fail.stderr b/tests/ui/const-generics/mgca/generic-args-on-enum-variant-segments-fail.stderr index 3a6c7a17544c8..02903379932ae 100644 --- a/tests/ui/const-generics/mgca/generic-args-on-enum-variant-segments-fail.stderr +++ b/tests/ui/const-generics/mgca/generic-args-on-enum-variant-segments-fail.stderr @@ -1,40 +1,40 @@ error[E0109]: type arguments are not allowed on unit variant `Unit` - --> $DIR/generic-args-on-enum-variant-segments-fail.rs:13:68 + --> $DIR/generic-args-on-enum-variant-segments-fail.rs:14:49 | -LL | const _: Enum<()> = core::direct_const_arg!(Enum::<()>::Unit::<()>); - | ---- ^^ type argument not allowed - | | - | not allowed on unit variant `Unit` +LL | const _: Enum<()> = gca!(Enum::<()>::Unit::<()>); + | ---- ^^ type argument not allowed + | | + | not allowed on unit variant `Unit` | = note: generic arguments are not allowed on both an enum and its variant's path segments simultaneously; they are only valid in one place or the other help: remove the generics arguments from one of the path segments | -LL - const _: Enum<()> = core::direct_const_arg!(Enum::<()>::Unit::<()>); -LL + const _: Enum<()> = core::direct_const_arg!(Enum::<()>::Unit); +LL - const _: Enum<()> = gca!(Enum::<()>::Unit::<()>); +LL + const _: Enum<()> = gca!(Enum::<()>::Unit); | error[E0109]: type arguments are not allowed on tuple variant `Tuple` - --> $DIR/generic-args-on-enum-variant-segments-fail.rs:15:69 + --> $DIR/generic-args-on-enum-variant-segments-fail.rs:16:50 | -LL | const _: Enum<()> = core::direct_const_arg!(Enum::<()>::Tuple::<()>()); - | ----- ^^ type argument not allowed - | | - | not allowed on tuple variant `Tuple` +LL | const _: Enum<()> = gca!(Enum::<()>::Tuple::<()>()); + | ----- ^^ type argument not allowed + | | + | not allowed on tuple variant `Tuple` | = note: generic arguments are not allowed on both an enum and its variant's path segments simultaneously; they are only valid in one place or the other help: remove the generics arguments from one of the path segments | -LL - const _: Enum<()> = core::direct_const_arg!(Enum::<()>::Tuple::<()>()); -LL + const _: Enum<()> = core::direct_const_arg!(Enum::<()>::Tuple()); +LL - const _: Enum<()> = gca!(Enum::<()>::Tuple::<()>()); +LL + const _: Enum<()> = gca!(Enum::<()>::Tuple()); | error[E0109]: type arguments are not allowed on module `generic_args_on_enum_variant_segments_fail` - --> $DIR/generic-args-on-enum-variant-segments-fail.rs:17:56 + --> $DIR/generic-args-on-enum-variant-segments-fail.rs:18:37 | -LL | const _: Enum<()> = core::direct_const_arg!(self::::Enum::<()>::Store); - | ---- ^^^ type argument not allowed - | | - | not allowed on module `generic_args_on_enum_variant_segments_fail` +LL | const _: Enum<()> = gca!(self::::Enum::<()>::Store); + | ---- ^^^ type argument not allowed + | | + | not allowed on module `generic_args_on_enum_variant_segments_fail` error: aborting due to 3 previous errors diff --git a/tests/ui/const-generics/mgca/generic-args-on-enum-variant-segments.rs b/tests/ui/const-generics/mgca/generic-args-on-enum-variant-segments.rs index 234bca78d6cb3..94782da82f150 100644 --- a/tests/ui/const-generics/mgca/generic-args-on-enum-variant-segments.rs +++ b/tests/ui/const-generics/mgca/generic-args-on-enum-variant-segments.rs @@ -3,6 +3,8 @@ #![feature(min_generic_const_args)] #![feature(adt_const_params, unsized_const_params)] +use std::gca; + #[derive(PartialEq, Eq, std::marker::ConstParamTy)] enum Enum { Unit, @@ -10,7 +12,7 @@ enum Enum { Store(T), } -const _: Enum<()> = core::direct_const_arg!(Enum::<()>::Unit); -const _: Enum<()> = core::direct_const_arg!(Enum::<()>::Tuple()); +const _: Enum<()> = gca!(Enum::<()>::Unit); +const _: Enum<()> = gca!(Enum::<()>::Tuple()); fn main() {} diff --git a/tests/ui/const-generics/mgca/generic_const_items-mismatched-array-len.rs b/tests/ui/const-generics/mgca/generic_const_items-mismatched-array-len.rs index 2c680a37ea1f9..fad1703e3bfee 100644 --- a/tests/ui/const-generics/mgca/generic_const_items-mismatched-array-len.rs +++ b/tests/ui/const-generics/mgca/generic_const_items-mismatched-array-len.rs @@ -3,6 +3,8 @@ #![feature(adt_const_params, min_generic_const_args, macroless_generic_const_args)] #![feature(generic_const_parameter_types)] +use std::gca; + trait Trait { #[rustc_always_gca] const LEN: usize; @@ -10,7 +12,7 @@ trait Trait { struct S; impl Trait for S { - const LEN: usize = core::direct_const_arg!(2); + const LEN: usize = gca!(2); } fn foo::LEN]>() -> [u8; ::LEN] { diff --git a/tests/ui/const-generics/mgca/generic_const_items-mismatched-array-len.stderr b/tests/ui/const-generics/mgca/generic_const_items-mismatched-array-len.stderr index c9ee69146f326..4906b05939900 100644 --- a/tests/ui/const-generics/mgca/generic_const_items-mismatched-array-len.stderr +++ b/tests/ui/const-generics/mgca/generic_const_items-mismatched-array-len.stderr @@ -1,11 +1,11 @@ error: the constant `*b"\x01\x02\x03"` is not of type `[u8; ::LEN]` - --> $DIR/generic_const_items-mismatched-array-len.rs:21:11 + --> $DIR/generic_const_items-mismatched-array-len.rs:23:11 | LL | foo::() | ^ expected `[u8; ::LEN]`, found `[u8; 3]` | note: required by a const generic parameter in `foo` - --> $DIR/generic_const_items-mismatched-array-len.rs:16:18 + --> $DIR/generic_const_items-mismatched-array-len.rs:18:18 | LL | fn foo::LEN]>() -> [u8; ::LEN] { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this const generic parameter in `foo` diff --git a/tests/ui/const-generics/mgca/generic_const_parameter_types-inferred-array-len.rs b/tests/ui/const-generics/mgca/generic_const_parameter_types-inferred-array-len.rs index 5891e66aa77b0..eb32077dcfaca 100644 --- a/tests/ui/const-generics/mgca/generic_const_parameter_types-inferred-array-len.rs +++ b/tests/ui/const-generics/mgca/generic_const_parameter_types-inferred-array-len.rs @@ -1,8 +1,11 @@ //@ check-pass #![feature(min_adt_const_params, min_generic_const_args, generic_const_parameter_types)] + +use std::gca; + fn foo() {} fn main() { - foo::<_, core::direct_const_arg!([0, 1, 2, 3])>(); + foo::<_, gca!([0, 1, 2, 3])>(); } diff --git a/tests/ui/const-generics/mgca/generic_const_type_mismatch.rs b/tests/ui/const-generics/mgca/generic_const_type_mismatch.rs index 928205d4bc4df..55443874a36d1 100644 --- a/tests/ui/const-generics/mgca/generic_const_type_mismatch.rs +++ b/tests/ui/const-generics/mgca/generic_const_type_mismatch.rs @@ -7,13 +7,15 @@ min_generic_const_args, const_param_ty_trait )] + +use std::gca; use std::marker::ConstParamTy_; struct Foo { field: T, } -const WRAP: T = core::direct_const_arg!(Foo:: { field: 1 }); +const WRAP: T = gca!(Foo:: { field: 1 }); //~^ ERROR: type annotations needed for the literal fn main() {} diff --git a/tests/ui/const-generics/mgca/generic_const_type_mismatch.stderr b/tests/ui/const-generics/mgca/generic_const_type_mismatch.stderr index d7f89bede8d4d..241e396c11569 100644 --- a/tests/ui/const-generics/mgca/generic_const_type_mismatch.stderr +++ b/tests/ui/const-generics/mgca/generic_const_type_mismatch.stderr @@ -1,8 +1,8 @@ error: type annotations needed for the literal - --> $DIR/generic_const_type_mismatch.rs:16:77 + --> $DIR/generic_const_type_mismatch.rs:18:58 | -LL | const WRAP: T = core::direct_const_arg!(Foo:: { field: 1 }); - | ^ +LL | const WRAP: T = gca!(Foo:: { field: 1 }); + | ^ error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/mgca/inherent-alias-default.rs b/tests/ui/const-generics/mgca/inherent-alias-default.rs index 9ba6d1d15e856..2ef400454a195 100644 --- a/tests/ui/const-generics/mgca/inherent-alias-default.rs +++ b/tests/ui/const-generics/mgca/inherent-alias-default.rs @@ -5,11 +5,13 @@ //! ensure_ok(). This test just makes sure that codepath is hit in tests. #![feature(min_generic_const_args, inherent_associated_types)] +use std::gca; + struct Struct(T1, T2, T3); impl Struct { - const INHERENT: usize = core::direct_const_arg!(2); + const INHERENT: usize = gca!(2); } -struct WithDefault::INHERENT) }>; +struct WithDefault::INHERENT) }>; fn main() {} diff --git a/tests/ui/const-generics/mgca/invalid-direct-const-arg-owner-issue-159172.expr.stderr b/tests/ui/const-generics/mgca/invalid-direct-const-arg-owner-issue-159172.expr.stderr deleted file mode 100644 index 016c7afc4b8b5..0000000000000 --- a/tests/ui/const-generics/mgca/invalid-direct-const-arg-owner-issue-159172.expr.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error: expected expression, found `direct_const_arg!()` constant - --> $DIR/invalid-direct-const-arg-owner-issue-159172.rs:21:13 - | -LL | let _ = core::direct_const_arg!(|| { - | _____________^ -LL | | -LL | | use std::io::*; -LL | | write!(_, "") -LL | | }); - | |______^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/const-generics/mgca/invalid-gca-macro-owner-issue-159172.expr.stderr b/tests/ui/const-generics/mgca/invalid-gca-macro-owner-issue-159172.expr.stderr new file mode 100644 index 0000000000000..d579038f3cd7b --- /dev/null +++ b/tests/ui/const-generics/mgca/invalid-gca-macro-owner-issue-159172.expr.stderr @@ -0,0 +1,13 @@ +error: expected expression, found `gca!()` constant + --> $DIR/invalid-gca-macro-owner-issue-159172.rs:23:13 + | +LL | let _ = gca!(|| { + | _____________^ +LL | | +LL | | use std::io::*; +LL | | write!(_, "") +LL | | }); + | |______^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/const-generics/mgca/invalid-direct-const-arg-owner-issue-159172.rs b/tests/ui/const-generics/mgca/invalid-gca-macro-owner-issue-159172.rs similarity index 57% rename from tests/ui/const-generics/mgca/invalid-direct-const-arg-owner-issue-159172.rs rename to tests/ui/const-generics/mgca/invalid-gca-macro-owner-issue-159172.rs index 80673ec127adf..0b0f30fd5b9fe 100644 --- a/tests/ui/const-generics/mgca/invalid-direct-const-arg-owner-issue-159172.rs +++ b/tests/ui/const-generics/mgca/invalid-gca-macro-owner-issue-159172.rs @@ -1,10 +1,12 @@ //@ revisions: ty expr #![feature(min_generic_const_args)] +use std::gca; + #[cfg(ty)] trait Iter< - const C: core::direct_const_arg!(|| { - //[ty]~^ ERROR expected type, found `direct_const_arg!()` constant + const C: gca!(|| { + //[ty]~^ ERROR expected type, found `gca!()` constant use std::io::*; let mut buffer = std::fs::File::create("foo.txt")?; write!(buffer, "oh no")?; @@ -18,8 +20,8 @@ fn main() {} #[cfg(expr)] fn main() { - let _ = core::direct_const_arg!(|| { - //[expr]~^ ERROR expected expression, found `direct_const_arg!()` constant + let _ = gca!(|| { + //[expr]~^ ERROR expected expression, found `gca!()` constant use std::io::*; write!(_, "") }); diff --git a/tests/ui/const-generics/mgca/invalid-direct-const-arg-owner-issue-159172.ty.stderr b/tests/ui/const-generics/mgca/invalid-gca-macro-owner-issue-159172.ty.stderr similarity index 58% rename from tests/ui/const-generics/mgca/invalid-direct-const-arg-owner-issue-159172.ty.stderr rename to tests/ui/const-generics/mgca/invalid-gca-macro-owner-issue-159172.ty.stderr index 936153ce52b75..b3882df585ac0 100644 --- a/tests/ui/const-generics/mgca/invalid-direct-const-arg-owner-issue-159172.ty.stderr +++ b/tests/ui/const-generics/mgca/invalid-gca-macro-owner-issue-159172.ty.stderr @@ -1,7 +1,7 @@ -error: expected type, found `direct_const_arg!()` constant - --> $DIR/invalid-direct-const-arg-owner-issue-159172.rs:6:14 +error: expected type, found `gca!()` constant + --> $DIR/invalid-gca-macro-owner-issue-159172.rs:8:14 | -LL | const C: core::direct_const_arg!(|| { +LL | const C: gca!(|| { | ______________^ LL | | LL | | use std::io::*; diff --git a/tests/ui/const-generics/mgca/macro-const-arg-infer.rs b/tests/ui/const-generics/mgca/macro-const-arg-infer.rs index a768228d94d28..010b1c240e2a6 100644 --- a/tests/ui/const-generics/mgca/macro-const-arg-infer.rs +++ b/tests/ui/const-generics/mgca/macro-const-arg-infer.rs @@ -1,6 +1,9 @@ //! Regression test for https://github.com/rust-lang/rust/issues/153198 #![feature(min_generic_const_args)] #![allow(incomplete_features)] + +use std::gca; + macro_rules! y { ( $($matcher:tt)*) => { _ //~ ERROR: constant provided when a type was expected @@ -11,7 +14,7 @@ macro_rules! y { struct A; //~ ERROR: type parameter `T` is never used const y: A< - core::direct_const_arg!(y! { + gca!(y! { x }), > = 1; diff --git a/tests/ui/const-generics/mgca/macro-const-arg-infer.stderr b/tests/ui/const-generics/mgca/macro-const-arg-infer.stderr index b46114bf4bd5f..a791b9d17fcce 100644 --- a/tests/ui/const-generics/mgca/macro-const-arg-infer.stderr +++ b/tests/ui/const-generics/mgca/macro-const-arg-infer.stderr @@ -1,5 +1,5 @@ error[E0392]: type parameter `T` is never used - --> $DIR/macro-const-arg-infer.rs:11:10 + --> $DIR/macro-const-arg-infer.rs:14:10 | LL | struct A; | ^ unused type parameter @@ -8,29 +8,29 @@ LL | struct A; = help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead error[E0747]: constant provided when a type was expected - --> $DIR/macro-const-arg-infer.rs:6:9 + --> $DIR/macro-const-arg-infer.rs:9:9 | LL | macro_rules! y { LL | ( $($matcher:tt)*) => { LL | _ | ^ ... -LL | core::direct_const_arg!(y! { - | _____________________________- +LL | gca!(y! { + | __________- LL | | x LL | | }), | |_____- in this macro invocation error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants - --> $DIR/macro-const-arg-infer.rs:6:9 + --> $DIR/macro-const-arg-infer.rs:9:9 | LL | macro_rules! y { LL | ( $($matcher:tt)*) => { LL | _ | ^ not allowed in type signatures ... -LL | core::direct_const_arg!(y! { - | _____________________________- +LL | gca!(y! { + | __________- LL | | x LL | | }), | |_____- in this macro invocation diff --git a/tests/ui/const-generics/mgca/mixed-direct-anon-expression-diagnostics.rs b/tests/ui/const-generics/mgca/mixed-direct-anon-expression-diagnostics.rs index 1653fd63ed3f8..b4214f5f74e89 100644 --- a/tests/ui/const-generics/mgca/mixed-direct-anon-expression-diagnostics.rs +++ b/tests/ui/const-generics/mgca/mixed-direct-anon-expression-diagnostics.rs @@ -5,12 +5,14 @@ #![feature(min_generic_const_args, min_adt_const_params)] #![allow(incomplete_features)] +use std::gca; + fn f() {} fn g() { f::<{ (N, 1 + 1) }>(); //~^ ERROR: generic parameters may not be used in const operations - f::<{ core::direct_const_arg!((N, 1 + 1)) }>(); + f::<{ gca!((N, 1 + 1)) }>(); //~^ ERROR: complex const arguments must be placed inside of a `const` block } diff --git a/tests/ui/const-generics/mgca/mixed-direct-anon-expression-diagnostics.stderr b/tests/ui/const-generics/mgca/mixed-direct-anon-expression-diagnostics.stderr index 50f849b6389ee..920143d33626f 100644 --- a/tests/ui/const-generics/mgca/mixed-direct-anon-expression-diagnostics.stderr +++ b/tests/ui/const-generics/mgca/mixed-direct-anon-expression-diagnostics.stderr @@ -1,11 +1,11 @@ error: complex const arguments must be placed inside of a `const` block - --> $DIR/mixed-direct-anon-expression-diagnostics.rs:13:39 + --> $DIR/mixed-direct-anon-expression-diagnostics.rs:15:20 | -LL | f::<{ core::direct_const_arg!((N, 1 + 1)) }>(); - | ^^^^^ +LL | f::<{ gca!((N, 1 + 1)) }>(); + | ^^^^^ error: generic parameters may not be used in const operations - --> $DIR/mixed-direct-anon-expression-diagnostics.rs:11:12 + --> $DIR/mixed-direct-anon-expression-diagnostics.rs:13:12 | LL | f::<{ (N, 1 + 1) }>(); | ^ diff --git a/tests/ui/const-generics/mgca/multi_braced_direct_const_args.rs b/tests/ui/const-generics/mgca/multi_braced_gca_macro.rs similarity index 100% rename from tests/ui/const-generics/mgca/multi_braced_direct_const_args.rs rename to tests/ui/const-generics/mgca/multi_braced_gca_macro.rs diff --git a/tests/ui/const-generics/mgca/non-local-const-without-type_const.stderr b/tests/ui/const-generics/mgca/non-local-const-without-type_const.stderr index 593eac88122c0..a9a6c168b8d14 100644 --- a/tests/ui/const-generics/mgca/non-local-const-without-type_const.stderr +++ b/tests/ui/const-generics/mgca/non-local-const-without-type_const.stderr @@ -4,7 +4,7 @@ error: use of `const` in the type system not marked as direct LL | let x = [(); non_local_const::N]; | ^^^^^^^^^^^^^^^^^^ | - = note: only consts with a `direct_const_arg!` right-hand side may be used in types + = note: only consts with a `gca!` right-hand side may be used in types error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/mgca/none-as-usize-const-arg.rs b/tests/ui/const-generics/mgca/none-as-usize-const-arg.rs index c21f1d0014ad5..d691aaaa6cf88 100644 --- a/tests/ui/const-generics/mgca/none-as-usize-const-arg.rs +++ b/tests/ui/const-generics/mgca/none-as-usize-const-arg.rs @@ -3,11 +3,13 @@ #![feature(generic_const_exprs)] #![feature(min_generic_const_args)] +use std::gca; + fn pass_enum { //~^ ERROR: missing parameters for function definition //~| ERROR: defaults for generic parameters are not allowed here //~| ERROR: overly complex generic constant - pass_enum::<{ core::direct_const_arg!(None) }> + pass_enum::<{ gca!(None) }> //~^ ERROR: missing generics for enum `Option` [E0107] } diff --git a/tests/ui/const-generics/mgca/none-as-usize-const-arg.stderr b/tests/ui/const-generics/mgca/none-as-usize-const-arg.stderr index dbd1ac607e88c..2cba595e2048b 100644 --- a/tests/ui/const-generics/mgca/none-as-usize-const-arg.stderr +++ b/tests/ui/const-generics/mgca/none-as-usize-const-arg.stderr @@ -1,5 +1,5 @@ error: missing parameters for function definition - --> $DIR/none-as-usize-const-arg.rs:6:59 + --> $DIR/none-as-usize-const-arg.rs:8:59 | LL | fn pass_enum { | ^ @@ -10,24 +10,24 @@ LL | fn pass_enum() { | ++ error: defaults for generic parameters are not allowed here - --> $DIR/none-as-usize-const-arg.rs:6:30 + --> $DIR/none-as-usize-const-arg.rs:8:30 | LL | fn pass_enum { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0107]: missing generics for enum `Option` - --> $DIR/none-as-usize-const-arg.rs:10:43 + --> $DIR/none-as-usize-const-arg.rs:12:24 | -LL | pass_enum::<{ core::direct_const_arg!(None) }> - | ^^^^ expected 1 generic argument +LL | pass_enum::<{ gca!(None) }> + | ^^^^ expected 1 generic argument | help: add missing generic argument | -LL | pass_enum::<{ core::direct_const_arg!(None) }> - | +++ +LL | pass_enum::<{ gca!(None) }> + | +++ error: overly complex generic constant - --> $DIR/none-as-usize-const-arg.rs:6:47 + --> $DIR/none-as-usize-const-arg.rs:8:47 | LL | fn pass_enum { | ^^^^^^^^^^^ const blocks are not supported in generic constants diff --git a/tests/ui/const-generics/mgca/opaque-ty-assoc-const-equality-117923.rs b/tests/ui/const-generics/mgca/opaque-ty-assoc-const-equality-117923.rs index ee336ea3f61e7..71112d632b5d8 100644 --- a/tests/ui/const-generics/mgca/opaque-ty-assoc-const-equality-117923.rs +++ b/tests/ui/const-generics/mgca/opaque-ty-assoc-const-equality-117923.rs @@ -3,6 +3,8 @@ #![feature(min_generic_const_args, macroless_generic_const_args)] #![allow(incomplete_features, dead_code)] +use std::gca; + trait Trait { #[rustc_always_gca] const CT: usize; @@ -13,7 +15,7 @@ struct Type { } impl Trait for Type { - const CT: usize = core::direct_const_arg!(N); + const CT: usize = gca!(N); } fn func() -> impl Trait as Trait>::CT }> { diff --git a/tests/ui/const-generics/mgca/paren.rs b/tests/ui/const-generics/mgca/paren.rs index de9e726a756f0..df60c06531755 100644 --- a/tests/ui/const-generics/mgca/paren.rs +++ b/tests/ui/const-generics/mgca/paren.rs @@ -2,35 +2,37 @@ //! See also: tests/ui/const-generics/paren.rs #![feature(min_generic_const_args, generic_const_items)] +use std::gca; + struct Thing; -const A: usize = core::direct_const_arg!(N); +const A: usize = gca!(N); fn f() { - let _: [u32; core::direct_const_arg!(_)] = [5; 5]; - let _: [u32; core::direct_const_arg!((_))] = [5; 5]; - let _: [u32; core::direct_const_arg!({ _ })] = [5; 5]; - let _: [u32; core::direct_const_arg!({ (_) })] = [5; 5]; - let _: [u32; core::direct_const_arg!(N)] = [5; _]; - let _: [u32; core::direct_const_arg!((N))] = [5; _]; - let _: [u32; core::direct_const_arg!({ N })] = [5; _]; - let _: [u32; core::direct_const_arg!({ (N) })] = [5; _]; - let _: [u32; core::direct_const_arg!(A::)] = [5; _]; - let _: [u32; core::direct_const_arg!((A::))] = [5; _]; - let _: [u32; core::direct_const_arg!({ A:: })] = [5; _]; - let _: [u32; core::direct_const_arg!({ (A::) })] = [5; _]; - let _: Thing = Thing::<5>; - let _: Thing = Thing::<5>; - let _: Thing = Thing::<5>; - let _: Thing = Thing::<5>; - let _: Thing = Thing; - let _: Thing = Thing; - let _: Thing = Thing; - let _: Thing = Thing; - let _: Thing)> = Thing; - let _: Thing))> = Thing; - let _: Thing })> = Thing; - let _: Thing) })> = Thing; + let _: [u32; gca!(_)] = [5; 5]; + let _: [u32; gca!((_))] = [5; 5]; + let _: [u32; gca!({ _ })] = [5; 5]; + let _: [u32; gca!({ (_) })] = [5; 5]; + let _: [u32; gca!(N)] = [5; _]; + let _: [u32; gca!((N))] = [5; _]; + let _: [u32; gca!({ N })] = [5; _]; + let _: [u32; gca!({ (N) })] = [5; _]; + let _: [u32; gca!(A::)] = [5; _]; + let _: [u32; gca!((A::))] = [5; _]; + let _: [u32; gca!({ A:: })] = [5; _]; + let _: [u32; gca!({ (A::) })] = [5; _]; + let _: Thing = Thing::<5>; + let _: Thing = Thing::<5>; + let _: Thing = Thing::<5>; + let _: Thing = Thing::<5>; + let _: Thing = Thing; + let _: Thing = Thing; + let _: Thing = Thing; + let _: Thing = Thing; + let _: Thing)> = Thing; + let _: Thing))> = Thing; + let _: Thing })> = Thing; + let _: Thing) })> = Thing; } fn main() {} diff --git a/tests/ui/const-generics/mgca/projection-const-recursive.rs b/tests/ui/const-generics/mgca/projection-const-recursive.rs index 0f1e30e0e610b..4a4b0c918e80a 100644 --- a/tests/ui/const-generics/mgca/projection-const-recursive.rs +++ b/tests/ui/const-generics/mgca/projection-const-recursive.rs @@ -6,13 +6,15 @@ #![feature(min_generic_const_args)] #![expect(incomplete_features)] +use std::gca; + trait Trait { #[rustc_always_gca] const A: (); } impl Trait for () { - const A: () = core::direct_const_arg!(<() as Trait>::A); + const A: () = gca!(<() as Trait>::A); //~^ ERROR: overflow evaluating the requirement `<() as Trait>::A == _` //~| ERROR: overflow evaluating the requirement `the constant `<() as Trait>::A` has type `()`` } diff --git a/tests/ui/const-generics/mgca/projection-const-recursive.stderr b/tests/ui/const-generics/mgca/projection-const-recursive.stderr index 54f94ea2e8e2e..1ffb6a88cc0f3 100644 --- a/tests/ui/const-generics/mgca/projection-const-recursive.stderr +++ b/tests/ui/const-generics/mgca/projection-const-recursive.stderr @@ -1,13 +1,13 @@ error[E0275]: overflow evaluating the requirement `<() as Trait>::A == _` - --> $DIR/projection-const-recursive.rs:15:5 + --> $DIR/projection-const-recursive.rs:17:5 | -LL | const A: () = core::direct_const_arg!(<() as Trait>::A); +LL | const A: () = gca!(<() as Trait>::A); | ^^^^^^^^^^^ error[E0275]: overflow evaluating the requirement `the constant `<() as Trait>::A` has type `()`` - --> $DIR/projection-const-recursive.rs:15:5 + --> $DIR/projection-const-recursive.rs:17:5 | -LL | const A: () = core::direct_const_arg!(<() as Trait>::A); +LL | const A: () = gca!(<() as Trait>::A); | ^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/mgca/static-const-arg.rs b/tests/ui/const-generics/mgca/static-const-arg.rs index 8afc57c1c2785..cc97267b4726e 100644 --- a/tests/ui/const-generics/mgca/static-const-arg.rs +++ b/tests/ui/const-generics/mgca/static-const-arg.rs @@ -5,14 +5,16 @@ #![feature(min_generic_const_args)] #![allow(incomplete_features)] +use std::gca; + static A: u32 = 0; struct Foo; -const _: Foo<{ core::direct_const_arg!(A) }> = Foo; +const _: Foo<{ gca!(A) }> = Foo; //~^ ERROR static items cannot be used as const arguments -const _: Foo = Foo; +const _: Foo = Foo; //~^ ERROR static items cannot be used as const arguments fn main() {} diff --git a/tests/ui/const-generics/mgca/static-const-arg.stderr b/tests/ui/const-generics/mgca/static-const-arg.stderr index d2f878545971b..1ba21dc552961 100644 --- a/tests/ui/const-generics/mgca/static-const-arg.stderr +++ b/tests/ui/const-generics/mgca/static-const-arg.stderr @@ -1,14 +1,14 @@ error: static items cannot be used as const arguments - --> $DIR/static-const-arg.rs:12:40 + --> $DIR/static-const-arg.rs:14:21 | -LL | const _: Foo<{ core::direct_const_arg!(A) }> = Foo; - | ^ +LL | const _: Foo<{ gca!(A) }> = Foo; + | ^ error: static items cannot be used as const arguments - --> $DIR/static-const-arg.rs:15:38 + --> $DIR/static-const-arg.rs:17:19 | -LL | const _: Foo = Foo; - | ^ +LL | const _: Foo = Foo; + | ^ error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/mgca/suggest-direct-const.fixed b/tests/ui/const-generics/mgca/suggest-direct-const.fixed index 6a6af81570255..044d875f1b4bb 100644 --- a/tests/ui/const-generics/mgca/suggest-direct-const.fixed +++ b/tests/ui/const-generics/mgca/suggest-direct-const.fixed @@ -4,35 +4,38 @@ #![allow(dead_code)] mod impl_item { + use std::gca; pub struct Bar; impl Bar { - pub const PUBLIC: usize = core::direct_const_arg!(1); - pub(crate) const RESTRICTED: usize = core::direct_const_arg!(1); - const PRIVATE: usize = core::direct_const_arg!(1); + pub const PUBLIC: usize = core::gca!(1); + pub(crate) const RESTRICTED: usize = core::gca!(1); + const PRIVATE: usize = core::gca!(1); } - pub struct Foo1([u8; core::direct_const_arg!(Bar::PUBLIC)]); + pub struct Foo1([u8; gca!(Bar::PUBLIC)]); //~^ ERROR: use of `const` in the type system not marked as direct - pub struct Foo2([u8; core::direct_const_arg!(Bar::RESTRICTED)]); + pub struct Foo2([u8; gca!(Bar::RESTRICTED)]); //~^ ERROR: use of `const` in the type system not marked as direct - pub struct Foo3([u8; core::direct_const_arg!(Bar::PRIVATE)]); + pub struct Foo3([u8; gca!(Bar::PRIVATE)]); //~^ ERROR: use of `const` in the type system not marked as direct } mod top_level_item { - pub const PUBLIC: usize = core::direct_const_arg!(1); - pub(crate) const RESTRICTED: usize = core::direct_const_arg!(1); - const PRIVATE: usize = core::direct_const_arg!(1); + use std::gca; + pub const PUBLIC: usize = core::gca!(1); + pub(crate) const RESTRICTED: usize = core::gca!(1); + const PRIVATE: usize = core::gca!(1); - pub struct Foo1([u8; core::direct_const_arg!(PUBLIC)]); + pub struct Foo1([u8; gca!(PUBLIC)]); //~^ ERROR: use of `const` in the type system not marked as direct - pub struct Foo2([u8; core::direct_const_arg!(RESTRICTED)]); + pub struct Foo2([u8; gca!(RESTRICTED)]); //~^ ERROR: use of `const` in the type system not marked as direct - pub struct Foo3([u8; core::direct_const_arg!(PRIVATE)]); + pub struct Foo3([u8; gca!(PRIVATE)]); //~^ ERROR: use of `const` in the type system not marked as direct } mod trait_item { + use std::gca; pub trait Foo { #[rustc_always_gca] const PUBLIC: usize; //~^ ERROR: [E0449] @@ -41,11 +44,11 @@ mod trait_item { #[rustc_always_gca] const PRIVATE: usize; } - pub struct Bar([u8; core::direct_const_arg!(T::PUBLIC)]); + pub struct Bar([u8; gca!(T::PUBLIC)]); //~^ ERROR: use of `const` in the type system not marked as direct - pub struct Bar2([u8; core::direct_const_arg!(T::RESTRICTED)]); + pub struct Bar2([u8; gca!(T::RESTRICTED)]); //~^ ERROR: use of `const` in the type system not marked as direct - pub struct Bar3([u8; core::direct_const_arg!(T::PRIVATE)]); + pub struct Bar3([u8; gca!(T::PRIVATE)]); //~^ ERROR: use of `const` in the type system not marked as direct } diff --git a/tests/ui/const-generics/mgca/suggest-direct-const.rs b/tests/ui/const-generics/mgca/suggest-direct-const.rs index 05b538a6cd1d9..e4f394e9c18bd 100644 --- a/tests/ui/const-generics/mgca/suggest-direct-const.rs +++ b/tests/ui/const-generics/mgca/suggest-direct-const.rs @@ -4,6 +4,7 @@ #![allow(dead_code)] mod impl_item { + use std::gca; pub struct Bar; impl Bar { pub const PUBLIC: usize = 1; @@ -11,28 +12,30 @@ mod impl_item { const PRIVATE: usize = 1; } - pub struct Foo1([u8; core::direct_const_arg!(Bar::PUBLIC)]); + pub struct Foo1([u8; gca!(Bar::PUBLIC)]); //~^ ERROR: use of `const` in the type system not marked as direct - pub struct Foo2([u8; core::direct_const_arg!(Bar::RESTRICTED)]); + pub struct Foo2([u8; gca!(Bar::RESTRICTED)]); //~^ ERROR: use of `const` in the type system not marked as direct - pub struct Foo3([u8; core::direct_const_arg!(Bar::PRIVATE)]); + pub struct Foo3([u8; gca!(Bar::PRIVATE)]); //~^ ERROR: use of `const` in the type system not marked as direct } mod top_level_item { + use std::gca; pub const PUBLIC: usize = 1; pub(crate) const RESTRICTED: usize = 1; const PRIVATE: usize = 1; - pub struct Foo1([u8; core::direct_const_arg!(PUBLIC)]); + pub struct Foo1([u8; gca!(PUBLIC)]); //~^ ERROR: use of `const` in the type system not marked as direct - pub struct Foo2([u8; core::direct_const_arg!(RESTRICTED)]); + pub struct Foo2([u8; gca!(RESTRICTED)]); //~^ ERROR: use of `const` in the type system not marked as direct - pub struct Foo3([u8; core::direct_const_arg!(PRIVATE)]); + pub struct Foo3([u8; gca!(PRIVATE)]); //~^ ERROR: use of `const` in the type system not marked as direct } mod trait_item { + use std::gca; pub trait Foo { pub const PUBLIC: usize; //~^ ERROR: [E0449] @@ -41,11 +44,11 @@ mod trait_item { const PRIVATE: usize; } - pub struct Bar([u8; core::direct_const_arg!(T::PUBLIC)]); + pub struct Bar([u8; gca!(T::PUBLIC)]); //~^ ERROR: use of `const` in the type system not marked as direct - pub struct Bar2([u8; core::direct_const_arg!(T::RESTRICTED)]); + pub struct Bar2([u8; gca!(T::RESTRICTED)]); //~^ ERROR: use of `const` in the type system not marked as direct - pub struct Bar3([u8; core::direct_const_arg!(T::PRIVATE)]); + pub struct Bar3([u8; gca!(T::PRIVATE)]); //~^ ERROR: use of `const` in the type system not marked as direct } diff --git a/tests/ui/const-generics/mgca/suggest-direct-const.stderr b/tests/ui/const-generics/mgca/suggest-direct-const.stderr index 69eeee156675d..d2cef03c3c3f2 100644 --- a/tests/ui/const-generics/mgca/suggest-direct-const.stderr +++ b/tests/ui/const-generics/mgca/suggest-direct-const.stderr @@ -1,5 +1,5 @@ error[E0449]: visibility qualifiers are not permitted here - --> $DIR/suggest-direct-const.rs:37:9 + --> $DIR/suggest-direct-const.rs:40:9 | LL | pub const PUBLIC: usize; | ^^^ help: remove the qualifier @@ -7,7 +7,7 @@ LL | pub const PUBLIC: usize; = note: trait items always share the visibility of their trait error[E0449]: visibility qualifiers are not permitted here - --> $DIR/suggest-direct-const.rs:39:9 + --> $DIR/suggest-direct-const.rs:42:9 | LL | pub(crate) const RESTRICTED: usize; | ^^^^^^^^^^ help: remove the qualifier @@ -15,76 +15,76 @@ LL | pub(crate) const RESTRICTED: usize; = note: trait items always share the visibility of their trait error: use of `const` in the type system not marked as direct - --> $DIR/suggest-direct-const.rs:14:50 + --> $DIR/suggest-direct-const.rs:15:31 | -LL | pub struct Foo1([u8; core::direct_const_arg!(Bar::PUBLIC)]); - | ^^^^^^^^^^^ +LL | pub struct Foo1([u8; gca!(Bar::PUBLIC)]); + | ^^^^^^^^^^^ | -help: add direct_const_arg!() to the right-hand side of the constant +help: add gca!() to the right-hand side of the constant | -LL | pub const PUBLIC: usize = core::direct_const_arg!(1); - | ++++++++++++++++++++++++ + +LL | pub const PUBLIC: usize = core::gca!(1); + | +++++++++++ + error: use of `const` in the type system not marked as direct - --> $DIR/suggest-direct-const.rs:16:50 + --> $DIR/suggest-direct-const.rs:17:31 | -LL | pub struct Foo2([u8; core::direct_const_arg!(Bar::RESTRICTED)]); - | ^^^^^^^^^^^^^^^ +LL | pub struct Foo2([u8; gca!(Bar::RESTRICTED)]); + | ^^^^^^^^^^^^^^^ | -help: add direct_const_arg!() to the right-hand side of the constant +help: add gca!() to the right-hand side of the constant | -LL | pub(crate) const RESTRICTED: usize = core::direct_const_arg!(1); - | ++++++++++++++++++++++++ + +LL | pub(crate) const RESTRICTED: usize = core::gca!(1); + | +++++++++++ + error: use of `const` in the type system not marked as direct - --> $DIR/suggest-direct-const.rs:18:50 + --> $DIR/suggest-direct-const.rs:19:31 | -LL | pub struct Foo3([u8; core::direct_const_arg!(Bar::PRIVATE)]); - | ^^^^^^^^^^^^ +LL | pub struct Foo3([u8; gca!(Bar::PRIVATE)]); + | ^^^^^^^^^^^^ | -help: add direct_const_arg!() to the right-hand side of the constant +help: add gca!() to the right-hand side of the constant | -LL | const PRIVATE: usize = core::direct_const_arg!(1); - | ++++++++++++++++++++++++ + +LL | const PRIVATE: usize = core::gca!(1); + | +++++++++++ + error: use of `const` in the type system not marked as direct - --> $DIR/suggest-direct-const.rs:27:50 + --> $DIR/suggest-direct-const.rs:29:31 | -LL | pub struct Foo1([u8; core::direct_const_arg!(PUBLIC)]); - | ^^^^^^ +LL | pub struct Foo1([u8; gca!(PUBLIC)]); + | ^^^^^^ | -help: add direct_const_arg!() to the right-hand side of the constant +help: add gca!() to the right-hand side of the constant | -LL | pub const PUBLIC: usize = core::direct_const_arg!(1); - | ++++++++++++++++++++++++ + +LL | pub const PUBLIC: usize = core::gca!(1); + | +++++++++++ + error: use of `const` in the type system not marked as direct - --> $DIR/suggest-direct-const.rs:29:50 + --> $DIR/suggest-direct-const.rs:31:31 | -LL | pub struct Foo2([u8; core::direct_const_arg!(RESTRICTED)]); - | ^^^^^^^^^^ +LL | pub struct Foo2([u8; gca!(RESTRICTED)]); + | ^^^^^^^^^^ | -help: add direct_const_arg!() to the right-hand side of the constant +help: add gca!() to the right-hand side of the constant | -LL | pub(crate) const RESTRICTED: usize = core::direct_const_arg!(1); - | ++++++++++++++++++++++++ + +LL | pub(crate) const RESTRICTED: usize = core::gca!(1); + | +++++++++++ + error: use of `const` in the type system not marked as direct - --> $DIR/suggest-direct-const.rs:31:50 + --> $DIR/suggest-direct-const.rs:33:31 | -LL | pub struct Foo3([u8; core::direct_const_arg!(PRIVATE)]); - | ^^^^^^^ +LL | pub struct Foo3([u8; gca!(PRIVATE)]); + | ^^^^^^^ | -help: add direct_const_arg!() to the right-hand side of the constant +help: add gca!() to the right-hand side of the constant | -LL | const PRIVATE: usize = core::direct_const_arg!(1); - | ++++++++++++++++++++++++ + +LL | const PRIVATE: usize = core::gca!(1); + | +++++++++++ + error: use of `const` in the type system not marked as direct - --> $DIR/suggest-direct-const.rs:44:57 + --> $DIR/suggest-direct-const.rs:47:38 | -LL | pub struct Bar([u8; core::direct_const_arg!(T::PUBLIC)]); - | ^^^^^^^^^ +LL | pub struct Bar([u8; gca!(T::PUBLIC)]); + | ^^^^^^^^^ | help: add `#[rustc_always_gca]` to the constant | @@ -92,10 +92,10 @@ LL | #[rustc_always_gca] pub const PUBLIC: usize; | +++++++++++++++++++ error: use of `const` in the type system not marked as direct - --> $DIR/suggest-direct-const.rs:46:58 + --> $DIR/suggest-direct-const.rs:49:39 | -LL | pub struct Bar2([u8; core::direct_const_arg!(T::RESTRICTED)]); - | ^^^^^^^^^^^^^ +LL | pub struct Bar2([u8; gca!(T::RESTRICTED)]); + | ^^^^^^^^^^^^^ | help: add `#[rustc_always_gca]` to the constant | @@ -103,10 +103,10 @@ LL | #[rustc_always_gca] pub(crate) const RESTRICTED: usize; | +++++++++++++++++++ error: use of `const` in the type system not marked as direct - --> $DIR/suggest-direct-const.rs:48:58 + --> $DIR/suggest-direct-const.rs:51:39 | -LL | pub struct Bar3([u8; core::direct_const_arg!(T::PRIVATE)]); - | ^^^^^^^^^^ +LL | pub struct Bar3([u8; gca!(T::PRIVATE)]); + | ^^^^^^^^^^ | help: add `#[rustc_always_gca]` to the constant | diff --git a/tests/ui/const-generics/mgca/syntactic-type-mismatch.rs b/tests/ui/const-generics/mgca/syntactic-type-mismatch.rs index 2fd3dea527370..bb0349ccb604a 100644 --- a/tests/ui/const-generics/mgca/syntactic-type-mismatch.rs +++ b/tests/ui/const-generics/mgca/syntactic-type-mismatch.rs @@ -4,10 +4,12 @@ #![feature(min_generic_const_args)] #![expect(incomplete_features)] -const T0: _ = core::direct_const_arg!(()); +use std::gca; + +const T0: _ = gca!(()); //~^ ERROR: the placeholder `_` is not allowed within types on item signatures for constants [E0121] -const T1 = core::direct_const_arg!([0]); +const T1 = gca!([0]); //~^ ERROR: missing type for `const` item fn main() {} diff --git a/tests/ui/const-generics/mgca/syntactic-type-mismatch.stderr b/tests/ui/const-generics/mgca/syntactic-type-mismatch.stderr index 6f0544c80a480..3d09bbdab6072 100644 --- a/tests/ui/const-generics/mgca/syntactic-type-mismatch.stderr +++ b/tests/ui/const-generics/mgca/syntactic-type-mismatch.stderr @@ -1,18 +1,18 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants - --> $DIR/syntactic-type-mismatch.rs:7:11 + --> $DIR/syntactic-type-mismatch.rs:9:11 | -LL | const T0: _ = core::direct_const_arg!(()); +LL | const T0: _ = gca!(()); | ^ not allowed in type signatures error: missing type for `const` item - --> $DIR/syntactic-type-mismatch.rs:10:9 + --> $DIR/syntactic-type-mismatch.rs:12:9 | -LL | const T1 = core::direct_const_arg!([0]); +LL | const T1 = gca!([0]); | ^ | help: provide a type for the item | -LL | const T1: = core::direct_const_arg!([0]); +LL | const T1: = gca!([0]); | ++++++++ error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/mgca/tuple_ctor_complex_args.rs b/tests/ui/const-generics/mgca/tuple_ctor_complex_args.rs index 8bdafd6c270f8..bd9d77eee3a85 100644 --- a/tests/ui/const-generics/mgca/tuple_ctor_complex_args.rs +++ b/tests/ui/const-generics/mgca/tuple_ctor_complex_args.rs @@ -1,6 +1,7 @@ #![feature(min_generic_const_args, macroless_generic_const_args, adt_const_params)] #![expect(incomplete_features)] +use std::gca; use std::marker::ConstParamTy; #[derive(Eq, PartialEq, ConstParamTy)] @@ -9,7 +10,7 @@ struct Point(u32, u32); fn with_point() {} fn test() { - with_point::<{ core::direct_const_arg!(Point(N + 1, N)) }>(); + with_point::<{ gca!(Point(N + 1, N)) }>(); //~^ ERROR complex const arguments must be placed inside of a `const` block with_point::<{ Point(const { N + 1 }, N) }>(); diff --git a/tests/ui/const-generics/mgca/tuple_ctor_complex_args.stderr b/tests/ui/const-generics/mgca/tuple_ctor_complex_args.stderr index 9b7c40d91515b..481afef0ee4e4 100644 --- a/tests/ui/const-generics/mgca/tuple_ctor_complex_args.stderr +++ b/tests/ui/const-generics/mgca/tuple_ctor_complex_args.stderr @@ -1,11 +1,11 @@ error: complex const arguments must be placed inside of a `const` block - --> $DIR/tuple_ctor_complex_args.rs:12:50 + --> $DIR/tuple_ctor_complex_args.rs:13:31 | -LL | with_point::<{ core::direct_const_arg!(Point(N + 1, N)) }>(); - | ^^^^^ +LL | with_point::<{ gca!(Point(N + 1, N)) }>(); + | ^^^^^ error: generic parameters may not be used in const operations - --> $DIR/tuple_ctor_complex_args.rs:15:34 + --> $DIR/tuple_ctor_complex_args.rs:16:34 | LL | with_point::<{ Point(const { N + 1 }, N) }>(); | ^ diff --git a/tests/ui/const-generics/mgca/tuple_ctor_erroneous.rs b/tests/ui/const-generics/mgca/tuple_ctor_erroneous.rs index d121566868a95..abe225e3f9291 100644 --- a/tests/ui/const-generics/mgca/tuple_ctor_erroneous.rs +++ b/tests/ui/const-generics/mgca/tuple_ctor_erroneous.rs @@ -1,6 +1,7 @@ #![feature(min_generic_const_args, macroless_generic_const_args, adt_const_params)] #![expect(incomplete_features)] +use std::gca; use std::marker::ConstParamTy; #[derive(Eq, PartialEq, ConstParamTy)] @@ -12,7 +13,7 @@ enum MyEnum { Unit, } -const CONST_ITEM: u32 = core::direct_const_arg!(42); +const CONST_ITEM: u32 = gca!(42); fn accepts_point() {} fn accepts_enum>() {} diff --git a/tests/ui/const-generics/mgca/tuple_ctor_erroneous.stderr b/tests/ui/const-generics/mgca/tuple_ctor_erroneous.stderr index b9bbfcc37469d..56b11b2894aa2 100644 --- a/tests/ui/const-generics/mgca/tuple_ctor_erroneous.stderr +++ b/tests/ui/const-generics/mgca/tuple_ctor_erroneous.stderr @@ -1,5 +1,5 @@ error[E0425]: cannot find function, tuple struct or tuple variant `UnresolvedIdent` in this scope - --> $DIR/tuple_ctor_erroneous.rs:29:23 + --> $DIR/tuple_ctor_erroneous.rs:30:23 | LL | accepts_point::<{ UnresolvedIdent(N, N) }>(); | ^^^^^^^^^^^^^^^ not found in this scope @@ -10,61 +10,61 @@ LL | fn test_errors() { | +++++++++++++++++++++++++++++++++++ error: tuple constructor has 2 arguments but 1 were provided - --> $DIR/tuple_ctor_erroneous.rs:23:23 + --> $DIR/tuple_ctor_erroneous.rs:24:23 | LL | accepts_point::<{ Point(N) }>(); | ^^^^^^^^ error: tuple constructor has 2 arguments but 3 were provided - --> $DIR/tuple_ctor_erroneous.rs:26:23 + --> $DIR/tuple_ctor_erroneous.rs:27:23 | LL | accepts_point::<{ Point(N, N, N) }>(); | ^^^^^^^^^^^^^^ error: tuple constructor with invalid base path - --> $DIR/tuple_ctor_erroneous.rs:29:23 + --> $DIR/tuple_ctor_erroneous.rs:30:23 | LL | accepts_point::<{ UnresolvedIdent(N, N) }>(); | ^^^^^^^^^^^^^^^^^^^^^ error: function items cannot be used as const args - --> $DIR/tuple_ctor_erroneous.rs:33:23 + --> $DIR/tuple_ctor_erroneous.rs:34:23 | LL | accepts_point::<{ non_ctor(N, N) }>(); | ^^^^^^^^ error: tuple constructor with invalid base path - --> $DIR/tuple_ctor_erroneous.rs:33:23 + --> $DIR/tuple_ctor_erroneous.rs:34:23 | LL | accepts_point::<{ non_ctor(N, N) }>(); | ^^^^^^^^^^^^^^ error: tuple constructor with invalid base path - --> $DIR/tuple_ctor_erroneous.rs:37:23 + --> $DIR/tuple_ctor_erroneous.rs:38:23 | LL | accepts_point::<{ CONST_ITEM(N, N) }>(); | ^^^^^^^^^^^^^^^^ error: the constant `Point` is not of type `Point` - --> $DIR/tuple_ctor_erroneous.rs:40:23 + --> $DIR/tuple_ctor_erroneous.rs:41:23 | LL | accepts_point::<{ Point }>(); | ^^^^^ expected `Point`, found struct constructor | note: required by a const generic parameter in `accepts_point` - --> $DIR/tuple_ctor_erroneous.rs:17:18 + --> $DIR/tuple_ctor_erroneous.rs:18:18 | LL | fn accepts_point() {} | ^^^^^^^^^^^^^^ required by this const generic parameter in `accepts_point` error: the constant `MyEnum::::Variant` is not of type `MyEnum` - --> $DIR/tuple_ctor_erroneous.rs:43:22 + --> $DIR/tuple_ctor_erroneous.rs:44:22 | LL | accepts_enum::<{ MyEnum::Variant:: }>(); | ^^^^^^^^^^^^^^^^^^^^^^ expected `MyEnum`, found enum constructor | note: required by a const generic parameter in `accepts_enum` - --> $DIR/tuple_ctor_erroneous.rs:18:17 + --> $DIR/tuple_ctor_erroneous.rs:19:17 | LL | fn accepts_enum>() {} | ^^^^^^^^^^^^^^^^^^^^ required by this const generic parameter in `accepts_enum` diff --git a/tests/ui/const-generics/mgca/tuple_expr_arg_complex.rs b/tests/ui/const-generics/mgca/tuple_expr_arg_complex.rs index c932fdd248dae..ea0edad9e673f 100644 --- a/tests/ui/const-generics/mgca/tuple_expr_arg_complex.rs +++ b/tests/ui/const-generics/mgca/tuple_expr_arg_complex.rs @@ -1,6 +1,8 @@ #![feature(min_generic_const_args, adt_const_params, unsized_const_params)] #![expect(incomplete_features)] +use std::gca; + trait Trait { #[rustc_always_gca] const ASSOC: usize; @@ -10,11 +12,11 @@ fn takes_tuple() {} fn takes_nested_tuple() {} fn generic_caller() { - takes_tuple::<{ core::direct_const_arg!((N, N + 1)) }>(); //~ ERROR complex const arguments must be placed inside of a `const` block - takes_tuple::<{ core::direct_const_arg!((N, T::ASSOC + 1)) }>(); //~ ERROR complex const arguments must be placed inside of a `const` block + takes_tuple::<{ gca!((N, N + 1)) }>(); //~ ERROR complex const arguments must be placed inside of a `const` block + takes_tuple::<{ gca!((N, T::ASSOC + 1)) }>(); //~ ERROR complex const arguments must be placed inside of a `const` block - takes_nested_tuple::<{ core::direct_const_arg!((N, (N, N + 1))) }>(); //~ ERROR complex const arguments must be placed inside of a `const` block - takes_nested_tuple::<{ core::direct_const_arg!((N, (N, const { N + 1 }))) }>(); //~ ERROR generic parameters may not be used in const operations + takes_nested_tuple::<{ gca!((N, (N, N + 1))) }>(); //~ ERROR complex const arguments must be placed inside of a `const` block + takes_nested_tuple::<{ gca!((N, (N, const { N + 1 }))) }>(); //~ ERROR generic parameters may not be used in const operations } fn main() {} diff --git a/tests/ui/const-generics/mgca/tuple_expr_arg_complex.stderr b/tests/ui/const-generics/mgca/tuple_expr_arg_complex.stderr index 1ab93b1995749..045b9dd790919 100644 --- a/tests/ui/const-generics/mgca/tuple_expr_arg_complex.stderr +++ b/tests/ui/const-generics/mgca/tuple_expr_arg_complex.stderr @@ -1,26 +1,26 @@ error: complex const arguments must be placed inside of a `const` block - --> $DIR/tuple_expr_arg_complex.rs:13:49 + --> $DIR/tuple_expr_arg_complex.rs:15:30 | -LL | takes_tuple::<{ core::direct_const_arg!((N, N + 1)) }>(); - | ^^^^^ +LL | takes_tuple::<{ gca!((N, N + 1)) }>(); + | ^^^^^ error: complex const arguments must be placed inside of a `const` block - --> $DIR/tuple_expr_arg_complex.rs:14:49 + --> $DIR/tuple_expr_arg_complex.rs:16:30 | -LL | takes_tuple::<{ core::direct_const_arg!((N, T::ASSOC + 1)) }>(); - | ^^^^^^^^^^^^ +LL | takes_tuple::<{ gca!((N, T::ASSOC + 1)) }>(); + | ^^^^^^^^^^^^ error: complex const arguments must be placed inside of a `const` block - --> $DIR/tuple_expr_arg_complex.rs:16:60 + --> $DIR/tuple_expr_arg_complex.rs:18:41 | -LL | takes_nested_tuple::<{ core::direct_const_arg!((N, (N, N + 1))) }>(); - | ^^^^^ +LL | takes_nested_tuple::<{ gca!((N, (N, N + 1))) }>(); + | ^^^^^ error: generic parameters may not be used in const operations - --> $DIR/tuple_expr_arg_complex.rs:17:68 + --> $DIR/tuple_expr_arg_complex.rs:19:49 | -LL | takes_nested_tuple::<{ core::direct_const_arg!((N, (N, const { N + 1 }))) }>(); - | ^ +LL | takes_nested_tuple::<{ gca!((N, (N, const { N + 1 }))) }>(); + | ^ | = help: add `#![feature(generic_const_args)]` and extract the expression into a `type const` item diff --git a/tests/ui/const-generics/mgca/tuple_expr_arg_simple.rs b/tests/ui/const-generics/mgca/tuple_expr_arg_simple.rs index 70ca61c63c538..b4e664e1ca680 100644 --- a/tests/ui/const-generics/mgca/tuple_expr_arg_simple.rs +++ b/tests/ui/const-generics/mgca/tuple_expr_arg_simple.rs @@ -3,6 +3,8 @@ #![feature(min_generic_const_args, adt_const_params, unsized_const_params)] #![expect(incomplete_features)] +use std::gca; + trait Trait { #[rustc_always_gca] const ASSOC: u32; @@ -12,11 +14,11 @@ fn takes_tuple() {} fn takes_nested_tuple() {} fn generic_caller() { - takes_tuple::<{ core::direct_const_arg!((N, N2)) }>(); - takes_tuple::<{ core::direct_const_arg!((N, T::ASSOC)) }>(); + takes_tuple::<{ gca!((N, N2)) }>(); + takes_tuple::<{ gca!((N, T::ASSOC)) }>(); - takes_nested_tuple::<{ core::direct_const_arg!((N, (N, N2))) }>(); - takes_nested_tuple::<{ core::direct_const_arg!((N, (N, T::ASSOC))) }>(); + takes_nested_tuple::<{ gca!((N, (N, N2))) }>(); + takes_nested_tuple::<{ gca!((N, (N, T::ASSOC))) }>(); } fn main() {} diff --git a/tests/ui/const-generics/mgca/type-const-assoc-const-without-body.rs b/tests/ui/const-generics/mgca/type-const-assoc-const-without-body.rs index 7b9923994b0ac..d41110e594514 100644 --- a/tests/ui/const-generics/mgca/type-const-assoc-const-without-body.rs +++ b/tests/ui/const-generics/mgca/type-const-assoc-const-without-body.rs @@ -3,6 +3,8 @@ #![feature(min_generic_const_args)] #![expect(incomplete_features)] +use std::gca; + trait Tr { #[rustc_always_gca] const SIZE: usize; @@ -13,7 +15,7 @@ struct T; impl Tr for T { const SIZE: usize; //~^ ERROR associated constant in `impl` without body - //~| ERROR implementation of a `#[rustc_always_gca]` must have a `direct_const_arg!` RHS + //~| ERROR implementation of a `#[rustc_always_gca]` must have a `gca!` RHS } fn main() {} diff --git a/tests/ui/const-generics/mgca/type-const-assoc-const-without-body.stderr b/tests/ui/const-generics/mgca/type-const-assoc-const-without-body.stderr index 7425c09bb8a6a..ac0a3054d000f 100644 --- a/tests/ui/const-generics/mgca/type-const-assoc-const-without-body.stderr +++ b/tests/ui/const-generics/mgca/type-const-assoc-const-without-body.stderr @@ -1,19 +1,19 @@ error: associated constant in `impl` without body - --> $DIR/type-const-assoc-const-without-body.rs:14:5 + --> $DIR/type-const-assoc-const-without-body.rs:16:5 | LL | const SIZE: usize; | ^^^^^^^^^^^^^^^^^- | | | help: provide a definition for the constant: `= ;` -error: implementation of a `#[rustc_always_gca]` must have a `direct_const_arg!` RHS - --> $DIR/type-const-assoc-const-without-body.rs:14:5 +error: implementation of a `#[rustc_always_gca]` must have a `gca!` RHS + --> $DIR/type-const-assoc-const-without-body.rs:16:5 | LL | const SIZE: usize; | ^^^^^^^^^^^^^^^^^ | note: trait declaration of const is marked as `#[rustc_always_gca]` - --> $DIR/type-const-assoc-const-without-body.rs:8:5 + --> $DIR/type-const-assoc-const-without-body.rs:10:5 | LL | const SIZE: usize; | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/const-generics/mgca/type-const-associated-default.rs b/tests/ui/const-generics/mgca/type-const-associated-default.rs index a6d7869261b24..f2591248269cc 100644 --- a/tests/ui/const-generics/mgca/type-const-associated-default.rs +++ b/tests/ui/const-generics/mgca/type-const-associated-default.rs @@ -1,8 +1,9 @@ #![feature(min_generic_const_args)] #![expect(incomplete_features)] +use std::gca; trait Trait { #[rustc_always_gca] - const N: usize = core::direct_const_arg!(10); + const N: usize = gca!(10); //~^ ERROR associated type defaults are unstable } diff --git a/tests/ui/const-generics/mgca/type-const-associated-default.stderr b/tests/ui/const-generics/mgca/type-const-associated-default.stderr index e2443d4e288e0..e08a8c75bc68e 100644 --- a/tests/ui/const-generics/mgca/type-const-associated-default.stderr +++ b/tests/ui/const-generics/mgca/type-const-associated-default.stderr @@ -1,8 +1,8 @@ error[E0658]: associated type defaults are unstable - --> $DIR/type-const-associated-default.rs:5:5 + --> $DIR/type-const-associated-default.rs:6:5 | -LL | const N: usize = core::direct_const_arg!(10); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | const N: usize = gca!(10); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #29661 for more information = help: add `#![feature(associated_type_defaults)]` to the crate attributes to enable diff --git a/tests/ui/const-generics/mgca/type-const-ctor-148953.rs b/tests/ui/const-generics/mgca/type-const-ctor-148953.rs index 2c5ce1a3f260d..774cab562cb61 100644 --- a/tests/ui/const-generics/mgca/type-const-ctor-148953.rs +++ b/tests/ui/const-generics/mgca/type-const-ctor-148953.rs @@ -10,13 +10,14 @@ #![feature(min_generic_const_args, adt_const_params)] #![expect(incomplete_features)] +use std::gca; use std::marker::ConstParamTy; #[derive(ConstParamTy, PartialEq, Eq)] struct S; impl S { - const N: S = core::direct_const_arg!(S); + const N: S = gca!(S); } #[derive(ConstParamTy, PartialEq, Eq)] @@ -25,7 +26,7 @@ enum E { } impl E { - const M: E = core::direct_const_arg!({ E::V }); + const M: E = gca!({ E::V }); } fn main() {} diff --git a/tests/ui/const-generics/mgca/type-const-free-anon-const-mismatch.rs b/tests/ui/const-generics/mgca/type-const-free-anon-const-mismatch.rs index 31f5ce56f3979..3b76abd2edc3c 100644 --- a/tests/ui/const-generics/mgca/type-const-free-anon-const-mismatch.rs +++ b/tests/ui/const-generics/mgca/type-const-free-anon-const-mismatch.rs @@ -2,10 +2,12 @@ #![feature(min_generic_const_args)] -const X: usize = core::direct_const_arg!(const { N }); +use std::gca; + +const X: usize = gca!(const { N }); //~^ ERROR type annotations needed -const N: usize = core::direct_const_arg!("this isn't a usize"); +const N: usize = gca!("this isn't a usize"); //~^ ERROR the constant `"this isn't a usize"` is not of type `usize` fn main() {} diff --git a/tests/ui/const-generics/mgca/type-const-free-anon-const-mismatch.stderr b/tests/ui/const-generics/mgca/type-const-free-anon-const-mismatch.stderr index f8655132e9574..60dd8699d180f 100644 --- a/tests/ui/const-generics/mgca/type-const-free-anon-const-mismatch.stderr +++ b/tests/ui/const-generics/mgca/type-const-free-anon-const-mismatch.stderr @@ -1,15 +1,15 @@ error[E0284]: type annotations needed - --> $DIR/type-const-free-anon-const-mismatch.rs:5:1 + --> $DIR/type-const-free-anon-const-mismatch.rs:7:1 | -LL | const X: usize = core::direct_const_arg!(const { N }); +LL | const X: usize = gca!(const { N }); | ^^^^^^^^^^^^^^ cannot infer the value of the constant `_` | = note: cannot satisfy `X::{constant#0} == _` error: the constant `"this isn't a usize"` is not of type `usize` - --> $DIR/type-const-free-anon-const-mismatch.rs:8:1 + --> $DIR/type-const-free-anon-const-mismatch.rs:10:1 | -LL | const N: usize = core::direct_const_arg!("this isn't a usize"); +LL | const N: usize = gca!("this isn't a usize"); | ^^^^^^^^^^^^^^ expected `usize`, found `&'static str` error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/mgca/type-const-free-value-type-mismatch.current.stderr b/tests/ui/const-generics/mgca/type-const-free-value-type-mismatch.current.stderr index 425de1e1b1d4b..a2bd54b0b2b21 100644 --- a/tests/ui/const-generics/mgca/type-const-free-value-type-mismatch.current.stderr +++ b/tests/ui/const-generics/mgca/type-const-free-value-type-mismatch.current.stderr @@ -1,11 +1,11 @@ error: the constant `"this isn't a usize"` is not of type `usize` - --> $DIR/type-const-free-value-type-mismatch.rs:8:1 + --> $DIR/type-const-free-value-type-mismatch.rs:10:1 | -LL | const N: usize = core::direct_const_arg!("this isn't a usize"); +LL | const N: usize = gca!("this isn't a usize"); | ^^^^^^^^^^^^^^ expected `usize`, found `&'static str` error[E0308]: mismatched types - --> $DIR/type-const-free-value-type-mismatch.rs:11:11 + --> $DIR/type-const-free-value-type-mismatch.rs:13:11 | LL | fn f() -> [u8; const { N }] {} | - ^^^^^^^^^^^^^^^^^ expected `[u8; const { N }]`, found `()` diff --git a/tests/ui/const-generics/mgca/type-const-free-value-type-mismatch.next.stderr b/tests/ui/const-generics/mgca/type-const-free-value-type-mismatch.next.stderr index 74fb8ab8999d9..d6b719115cad3 100644 --- a/tests/ui/const-generics/mgca/type-const-free-value-type-mismatch.next.stderr +++ b/tests/ui/const-generics/mgca/type-const-free-value-type-mismatch.next.stderr @@ -1,11 +1,11 @@ error: the constant `"this isn't a usize"` is not of type `usize` - --> $DIR/type-const-free-value-type-mismatch.rs:8:1 + --> $DIR/type-const-free-value-type-mismatch.rs:10:1 | -LL | const N: usize = core::direct_const_arg!("this isn't a usize"); +LL | const N: usize = gca!("this isn't a usize"); | ^^^^^^^^^^^^^^ expected `usize`, found `&'static str` error[E0284]: type annotations needed - --> $DIR/type-const-free-value-type-mismatch.rs:11:11 + --> $DIR/type-const-free-value-type-mismatch.rs:13:11 | LL | fn f() -> [u8; const { N }] {} | ^^^^^^^^^^^^^^^^^ cannot infer the value of the constant `_` @@ -13,7 +13,7 @@ LL | fn f() -> [u8; const { N }] {} = note: cannot satisfy `f::{constant#0} == _` error[E0308]: mismatched types - --> $DIR/type-const-free-value-type-mismatch.rs:11:11 + --> $DIR/type-const-free-value-type-mismatch.rs:13:11 | LL | fn f() -> [u8; const { N }] {} | - ^^^^^^^^^^^^^^^^^ expected `[u8; _]`, found `()` diff --git a/tests/ui/const-generics/mgca/type-const-free-value-type-mismatch.rs b/tests/ui/const-generics/mgca/type-const-free-value-type-mismatch.rs index 7cb465d114935..f49ac09ea3fcc 100644 --- a/tests/ui/const-generics/mgca/type-const-free-value-type-mismatch.rs +++ b/tests/ui/const-generics/mgca/type-const-free-value-type-mismatch.rs @@ -5,7 +5,9 @@ //@[next] compile-flags: -Znext-solver //@ compile-flags: -Zvalidate-mir -const N: usize = core::direct_const_arg!("this isn't a usize"); +use std::gca; + +const N: usize = gca!("this isn't a usize"); //~^ ERROR the constant `"this isn't a usize"` is not of type `usize` fn f() -> [u8; const { N }] {} diff --git a/tests/ui/const-generics/mgca/type-const-free-value-used-in-body.rs b/tests/ui/const-generics/mgca/type-const-free-value-used-in-body.rs index c1e0044b0947c..509bf3debc878 100644 --- a/tests/ui/const-generics/mgca/type-const-free-value-used-in-body.rs +++ b/tests/ui/const-generics/mgca/type-const-free-value-used-in-body.rs @@ -4,10 +4,12 @@ //@ compile-flags: --emit=mir -const CONST: usize = core::direct_const_arg!(1u32); +use std::gca; + +const CONST: usize = gca!(1u32); //~^ ERROR the constant `1` is not of type `usize` -const S: bool = core::direct_const_arg!(1i32); +const S: bool = gca!(1i32); //~^ ERROR the constant `1` is not of type `bool` fn main() { diff --git a/tests/ui/const-generics/mgca/type-const-free-value-used-in-body.stderr b/tests/ui/const-generics/mgca/type-const-free-value-used-in-body.stderr index 1e20f48b7515c..a03b3db0a73f3 100644 --- a/tests/ui/const-generics/mgca/type-const-free-value-used-in-body.stderr +++ b/tests/ui/const-generics/mgca/type-const-free-value-used-in-body.stderr @@ -1,13 +1,13 @@ error: the constant `1` is not of type `usize` - --> $DIR/type-const-free-value-used-in-body.rs:7:1 + --> $DIR/type-const-free-value-used-in-body.rs:9:1 | -LL | const CONST: usize = core::direct_const_arg!(1u32); +LL | const CONST: usize = gca!(1u32); | ^^^^^^^^^^^^^^^^^^ expected `usize`, found `u32` error: the constant `1` is not of type `bool` - --> $DIR/type-const-free-value-used-in-body.rs:10:1 + --> $DIR/type-const-free-value-used-in-body.rs:12:1 | -LL | const S: bool = core::direct_const_arg!(1i32); +LL | const S: bool = gca!(1i32); | ^^^^^^^^^^^^^ expected `bool`, found `i32` error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/mgca/type-const-inherent-value-type-mismatch.current.stderr b/tests/ui/const-generics/mgca/type-const-inherent-value-type-mismatch.current.stderr index 017bc22d7fe0f..1b87914503453 100644 --- a/tests/ui/const-generics/mgca/type-const-inherent-value-type-mismatch.current.stderr +++ b/tests/ui/const-generics/mgca/type-const-inherent-value-type-mismatch.current.stderr @@ -1,11 +1,11 @@ error: the constant `"this isn't a usize"` is not of type `usize` - --> $DIR/type-const-inherent-value-type-mismatch.rs:13:5 + --> $DIR/type-const-inherent-value-type-mismatch.rs:15:5 | -LL | const N: usize = core::direct_const_arg!("this isn't a usize"); +LL | const N: usize = gca!("this isn't a usize"); | ^^^^^^^^^^^^^^ expected `usize`, found `&'static str` error[E0308]: mismatched types - --> $DIR/type-const-inherent-value-type-mismatch.rs:17:11 + --> $DIR/type-const-inherent-value-type-mismatch.rs:19:11 | LL | fn f() -> [u8; const { Struct::N }] {} | - ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `[u8; const { Struct::N }]`, found `()` diff --git a/tests/ui/const-generics/mgca/type-const-inherent-value-type-mismatch.next.stderr b/tests/ui/const-generics/mgca/type-const-inherent-value-type-mismatch.next.stderr index 111a1801d7adb..0da310a55c369 100644 --- a/tests/ui/const-generics/mgca/type-const-inherent-value-type-mismatch.next.stderr +++ b/tests/ui/const-generics/mgca/type-const-inherent-value-type-mismatch.next.stderr @@ -1,5 +1,5 @@ error[E0284]: type annotations needed - --> $DIR/type-const-inherent-value-type-mismatch.rs:17:11 + --> $DIR/type-const-inherent-value-type-mismatch.rs:19:11 | LL | fn f() -> [u8; const { Struct::N }] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the constant `_` @@ -7,13 +7,13 @@ LL | fn f() -> [u8; const { Struct::N }] {} = note: cannot satisfy `f::{constant#0} == _` error: the constant `"this isn't a usize"` is not of type `usize` - --> $DIR/type-const-inherent-value-type-mismatch.rs:13:5 + --> $DIR/type-const-inherent-value-type-mismatch.rs:15:5 | -LL | const N: usize = core::direct_const_arg!("this isn't a usize"); +LL | const N: usize = gca!("this isn't a usize"); | ^^^^^^^^^^^^^^ expected `usize`, found `&'static str` error[E0308]: mismatched types - --> $DIR/type-const-inherent-value-type-mismatch.rs:17:11 + --> $DIR/type-const-inherent-value-type-mismatch.rs:19:11 | LL | fn f() -> [u8; const { Struct::N }] {} | - ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `[u8; _]`, found `()` diff --git a/tests/ui/const-generics/mgca/type-const-inherent-value-type-mismatch.rs b/tests/ui/const-generics/mgca/type-const-inherent-value-type-mismatch.rs index a08f31e686f2f..3a0fdd6bfd0ea 100644 --- a/tests/ui/const-generics/mgca/type-const-inherent-value-type-mismatch.rs +++ b/tests/ui/const-generics/mgca/type-const-inherent-value-type-mismatch.rs @@ -7,10 +7,12 @@ #![feature(min_generic_const_args)] +use std::gca; + struct Struct; impl Struct { - const N: usize = core::direct_const_arg!("this isn't a usize"); + const N: usize = gca!("this isn't a usize"); //~^ ERROR the constant `"this isn't a usize"` is not of type `usize` } diff --git a/tests/ui/const-generics/mgca/type-const-used-in-trait.rs b/tests/ui/const-generics/mgca/type-const-used-in-trait.rs index 71bdc472e2e22..1f921960710c5 100644 --- a/tests/ui/const-generics/mgca/type-const-used-in-trait.rs +++ b/tests/ui/const-generics/mgca/type-const-used-in-trait.rs @@ -3,7 +3,9 @@ #![feature(min_generic_const_args)] #![expect(incomplete_features)] -const N: usize = core::direct_const_arg!(2); +use std::gca; + +const N: usize = gca!(2); trait CollectArray { fn inner_array(&mut self) -> [A; N]; diff --git a/tests/ui/const-generics/mgca/type-const-value-type-mismatch.current.stderr b/tests/ui/const-generics/mgca/type-const-value-type-mismatch.current.stderr index 614946eb7dc0f..dc7f73f2549e8 100644 --- a/tests/ui/const-generics/mgca/type-const-value-type-mismatch.current.stderr +++ b/tests/ui/const-generics/mgca/type-const-value-type-mismatch.current.stderr @@ -1,11 +1,11 @@ error[E0053]: method `arr` has an incompatible type for trait - --> $DIR/type-const-value-type-mismatch.rs:22:5 + --> $DIR/type-const-value-type-mismatch.rs:24:5 | LL | fn arr() -> [u8; const { Self::LEN }] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an array with a size of 0, found one with a size of const { Self::LEN } | note: type in trait - --> $DIR/type-const-value-type-mismatch.rs:15:5 + --> $DIR/type-const-value-type-mismatch.rs:17:5 | LL | fn arr() -> [u8; Self::LEN]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,13 +13,13 @@ LL | fn arr() -> [u8; Self::LEN]; found signature `fn() -> [u8; const { Self::LEN }]` error: the constant `0` is not of type `usize` - --> $DIR/type-const-value-type-mismatch.rs:19:5 + --> $DIR/type-const-value-type-mismatch.rs:21:5 | -LL | const LEN: usize = core::direct_const_arg!(0u8); +LL | const LEN: usize = gca!(0u8); | ^^^^^^^^^^^^^^^^ expected `usize`, found `u8` error[E0308]: mismatched types - --> $DIR/type-const-value-type-mismatch.rs:22:17 + --> $DIR/type-const-value-type-mismatch.rs:24:17 | LL | fn arr() -> [u8; const { Self::LEN }] {} | --- ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `[u8; const { Self::LEN }]`, found `()` diff --git a/tests/ui/const-generics/mgca/type-const-value-type-mismatch.next.stderr b/tests/ui/const-generics/mgca/type-const-value-type-mismatch.next.stderr index 9180bf19727cf..8e006112641a3 100644 --- a/tests/ui/const-generics/mgca/type-const-value-type-mismatch.next.stderr +++ b/tests/ui/const-generics/mgca/type-const-value-type-mismatch.next.stderr @@ -1,17 +1,17 @@ error[E0271]: type mismatch resolving `::LEN == _` - --> $DIR/type-const-value-type-mismatch.rs:22:5 + --> $DIR/type-const-value-type-mismatch.rs:24:5 | LL | fn arr() -> [u8; const { Self::LEN }] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ error: the constant `0` is not of type `usize` - --> $DIR/type-const-value-type-mismatch.rs:19:5 + --> $DIR/type-const-value-type-mismatch.rs:21:5 | -LL | const LEN: usize = core::direct_const_arg!(0u8); +LL | const LEN: usize = gca!(0u8); | ^^^^^^^^^^^^^^^^ expected `usize`, found `u8` error[E0284]: type annotations needed - --> $DIR/type-const-value-type-mismatch.rs:22:17 + --> $DIR/type-const-value-type-mismatch.rs:24:17 | LL | fn arr() -> [u8; const { Self::LEN }] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the constant `_` @@ -19,7 +19,7 @@ LL | fn arr() -> [u8; const { Self::LEN }] {} = note: cannot satisfy `::arr::{constant#0}::{constant#0} == _` error[E0308]: mismatched types - --> $DIR/type-const-value-type-mismatch.rs:22:17 + --> $DIR/type-const-value-type-mismatch.rs:24:17 | LL | fn arr() -> [u8; const { Self::LEN }] {} | --- ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `[u8; _]`, found `()` diff --git a/tests/ui/const-generics/mgca/type-const-value-type-mismatch.rs b/tests/ui/const-generics/mgca/type-const-value-type-mismatch.rs index 5609924575693..0a9f90e90de7f 100644 --- a/tests/ui/const-generics/mgca/type-const-value-type-mismatch.rs +++ b/tests/ui/const-generics/mgca/type-const-value-type-mismatch.rs @@ -7,6 +7,8 @@ #![feature(min_generic_const_args, macroless_generic_const_args)] +use std::gca; + pub struct A; pub trait Array { @@ -16,7 +18,7 @@ pub trait Array { } impl Array for A { - const LEN: usize = core::direct_const_arg!(0u8); + const LEN: usize = gca!(0u8); //~^ ERROR the constant `0` is not of type `usize` fn arr() -> [u8; const { Self::LEN }] {} diff --git a/tests/ui/const-generics/mgca/type_const-adt-expr-missing-field.rs b/tests/ui/const-generics/mgca/type_const-adt-expr-missing-field.rs index 4d4fcdb03164b..421b6b4cb5993 100644 --- a/tests/ui/const-generics/mgca/type_const-adt-expr-missing-field.rs +++ b/tests/ui/const-generics/mgca/type_const-adt-expr-missing-field.rs @@ -5,9 +5,11 @@ #![feature(macroless_generic_const_args)] #![feature(generic_const_items)] -const ADD1: usize = core::direct_const_arg!(const { N + 1 }); +use std::gca; + +const ADD1: usize = gca!(const { N + 1 }); //~^ ERROR: unconstrained generic constant -const AliasFnUnused: ADD1 = core::direct_const_arg!(ADD1::<{ Some:: {} }>); +const AliasFnUnused: ADD1 = gca!(ADD1::<{ Some:: {} }>); //~^ ERROR: cannot find type `ADD1` in this scope [E0573] //~| ERROR: struct expression with missing field initialiser for `0` diff --git a/tests/ui/const-generics/mgca/type_const-adt-expr-missing-field.stderr b/tests/ui/const-generics/mgca/type_const-adt-expr-missing-field.stderr index 7a5a299320459..623ae087687f5 100644 --- a/tests/ui/const-generics/mgca/type_const-adt-expr-missing-field.stderr +++ b/tests/ui/const-generics/mgca/type_const-adt-expr-missing-field.stderr @@ -1,27 +1,27 @@ error[E0573]: cannot find type `ADD1` in this scope - --> $DIR/type_const-adt-expr-missing-field.rs:10:22 + --> $DIR/type_const-adt-expr-missing-field.rs:12:22 | -LL | const AliasFnUnused: ADD1 = core::direct_const_arg!(ADD1::<{ Some:: {} }>); +LL | const AliasFnUnused: ADD1 = gca!(ADD1::<{ Some:: {} }>); | ^^^^ not found in this scope | = note: a constant named `ADD1` exists in another namespace error: unconstrained generic constant - --> $DIR/type_const-adt-expr-missing-field.rs:8:1 + --> $DIR/type_const-adt-expr-missing-field.rs:10:1 | -LL | const ADD1: usize = core::direct_const_arg!(const { N + 1 }); +LL | const ADD1: usize = gca!(const { N + 1 }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: try adding a `where` bound | -LL | const ADD1: usize where [(); const { N + 1 }]: = core::direct_const_arg!(const { N + 1 }); +LL | const ADD1: usize where [(); const { N + 1 }]: = gca!(const { N + 1 }); | ++++++++++++++++++++++++++++ error: struct expression with missing field initialiser for `0` - --> $DIR/type_const-adt-expr-missing-field.rs:10:62 + --> $DIR/type_const-adt-expr-missing-field.rs:12:43 | -LL | const AliasFnUnused: ADD1 = core::direct_const_arg!(ADD1::<{ Some:: {} }>); - | ^^^^^^^^^^^^^^^^ +LL | const AliasFnUnused: ADD1 = gca!(ADD1::<{ Some:: {} }>); + | ^^^^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/const-generics/mgca/type_const-array-return.rs b/tests/ui/const-generics/mgca/type_const-array-return.rs index 5b8f50925529d..ed27f0df8599b 100644 --- a/tests/ui/const-generics/mgca/type_const-array-return.rs +++ b/tests/ui/const-generics/mgca/type_const-array-return.rs @@ -3,6 +3,8 @@ #![expect(incomplete_features)] #![feature(min_generic_const_args, macroless_generic_const_args)] +use std::gca; + pub struct A; pub trait Array { @@ -12,7 +14,7 @@ pub trait Array { } impl Array for A { - const LEN: usize = core::direct_const_arg!(4); + const LEN: usize = gca!(4); #[allow(unused_braces)] fn arr() -> [u8; const { Self::LEN }] { diff --git a/tests/ui/const-generics/mgca/type_const-generic-param-in-type.nogate.stderr b/tests/ui/const-generics/mgca/type_const-generic-param-in-type.nogate.stderr index 03251f4c7bd2b..46be38bb1a53d 100644 --- a/tests/ui/const-generics/mgca/type_const-generic-param-in-type.nogate.stderr +++ b/tests/ui/const-generics/mgca/type_const-generic-param-in-type.nogate.stderr @@ -1,37 +1,37 @@ error[E0770]: the type of const parameters must not depend on other generic parameters - --> $DIR/type_const-generic-param-in-type.rs:12:1 + --> $DIR/type_const-generic-param-in-type.rs:13:1 | -LL | const FOO: [T; 0] = core::direct_const_arg!([]); +LL | const FOO: [T; 0] = gca!([]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `[T; 0]` must not depend on other generic parameter error[E0770]: the type of const parameters must not depend on other generic parameters - --> $DIR/type_const-generic-param-in-type.rs:15:1 + --> $DIR/type_const-generic-param-in-type.rs:16:1 | -LL | const BAR: StructWithConstParam = +LL | const BAR: StructWithConstParam = gca!(StructWithConstParam::); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `StructWithConstParam` must not depend on other generic parameter error[E0770]: the type of const parameters must not depend on other generic parameters --> $DIR/type_const-generic-param-in-type.rs:19:1 | -LL | const BAZ<'a>: [&'a (); 0] = core::direct_const_arg!([]); +LL | const BAZ<'a>: [&'a (); 0] = gca!([]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `[&'a (); 0]` must not depend on other generic parameter error[E0770]: the type of const parameters must not depend on other generic parameters --> $DIR/type_const-generic-param-in-type.rs:37:5 | -LL | const ASSOC: [T; 0] = core::direct_const_arg!([]); +LL | const ASSOC: [T; 0] = gca!([]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `[T; 0]` must not depend on other generic parameter error[E0770]: the type of const parameters must not depend on other generic parameters --> $DIR/type_const-generic-param-in-type.rs:40:5 | -LL | const ASSOC_CONST: StructWithConstParam = +LL | const ASSOC_CONST: StructWithConstParam = gca!(StructWithConstParam::); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `StructWithConstParam` must not depend on other generic parameter error[E0770]: the type of const parameters must not depend on other generic parameters - --> $DIR/type_const-generic-param-in-type.rs:44:5 + --> $DIR/type_const-generic-param-in-type.rs:43:5 | -LL | const ASSOC_LT<'a>: [&'a (); 0] = core::direct_const_arg!([]); +LL | const ASSOC_LT<'a>: [&'a (); 0] = gca!([]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `[&'a (); 0]` must not depend on other generic parameter error[E0770]: the type of const parameters must not depend on other generic parameters diff --git a/tests/ui/const-generics/mgca/type_const-generic-param-in-type.rs b/tests/ui/const-generics/mgca/type_const-generic-param-in-type.rs index e5e36b79eca57..d8c1627858257 100644 --- a/tests/ui/const-generics/mgca/type_const-generic-param-in-type.rs +++ b/tests/ui/const-generics/mgca/type_const-generic-param-in-type.rs @@ -4,19 +4,19 @@ #![feature(adt_const_params, unsized_const_params, min_generic_const_args, generic_const_items)] #![cfg_attr(gate, feature(generic_const_parameter_types))] +use std::gca; use std::marker::ConstParamTy; #[derive(ConstParamTy, PartialEq, Eq, Debug)] struct StructWithConstParam; -const FOO: [T; 0] = core::direct_const_arg!([]); +const FOO: [T; 0] = gca!([]); //[nogate]~^ ERROR the type of const parameters must not depend on other generic parameters -const BAR: StructWithConstParam = - //[nogate]~^ ERROR the type of const parameters must not depend on other generic parameters - core::direct_const_arg!(StructWithConstParam::); +const BAR: StructWithConstParam = gca!(StructWithConstParam::); +//[nogate]~^ ERROR the type of const parameters must not depend on other generic parameters -const BAZ<'a>: [&'a (); 0] = core::direct_const_arg!([]); +const BAZ<'a>: [&'a (); 0] = gca!([]); //[nogate]~^ ERROR the type of const parameters must not depend on other generic parameters trait Tr { @@ -34,14 +34,13 @@ trait Tr { } impl Tr for () { - const ASSOC: [T; 0] = core::direct_const_arg!([]); + const ASSOC: [T; 0] = gca!([]); //[nogate]~^ ERROR the type of const parameters must not depend on other generic parameters - const ASSOC_CONST: StructWithConstParam = - //[nogate]~^ ERROR the type of const parameters must not depend on other generic parameters - core::direct_const_arg!(StructWithConstParam::); + const ASSOC_CONST: StructWithConstParam = gca!(StructWithConstParam::); + //[nogate]~^ ERROR the type of const parameters must not depend on other generic parameters - const ASSOC_LT<'a>: [&'a (); 0] = core::direct_const_arg!([]); + const ASSOC_LT<'a>: [&'a (); 0] = gca!([]); //[nogate]~^ ERROR the type of const parameters must not depend on other generic parameters } diff --git a/tests/ui/const-generics/mgca/type_const-incemental-compile.rs b/tests/ui/const-generics/mgca/type_const-incemental-compile.rs index 59581327cbb2d..7f82050044fad 100644 --- a/tests/ui/const-generics/mgca/type_const-incemental-compile.rs +++ b/tests/ui/const-generics/mgca/type_const-incemental-compile.rs @@ -6,5 +6,7 @@ #![expect(incomplete_features)] #![feature(min_generic_const_args)] -const TYPE_CONST: usize = core::direct_const_arg!(0); +use std::gca; + +const TYPE_CONST: usize = gca!(0); fn main() {} diff --git a/tests/ui/const-generics/mgca/type_const-inherent-const-omitted-type.rs b/tests/ui/const-generics/mgca/type_const-inherent-const-omitted-type.rs index 81c567f034e1e..32d052204ee27 100644 --- a/tests/ui/const-generics/mgca/type_const-inherent-const-omitted-type.rs +++ b/tests/ui/const-generics/mgca/type_const-inherent-const-omitted-type.rs @@ -1,10 +1,12 @@ #![expect(incomplete_features)] #![feature(min_generic_const_args)] +use std::gca; + struct A; impl A { - const B = core::direct_const_arg!(4); + const B = gca!(4); //~^ ERROR: missing type for `const` item //~| ERROR: type annotations needed for the literal } diff --git a/tests/ui/const-generics/mgca/type_const-inherent-const-omitted-type.stderr b/tests/ui/const-generics/mgca/type_const-inherent-const-omitted-type.stderr index 742e5aff86285..04f8051509ab1 100644 --- a/tests/ui/const-generics/mgca/type_const-inherent-const-omitted-type.stderr +++ b/tests/ui/const-generics/mgca/type_const-inherent-const-omitted-type.stderr @@ -1,19 +1,19 @@ error: missing type for `const` item - --> $DIR/type_const-inherent-const-omitted-type.rs:7:12 + --> $DIR/type_const-inherent-const-omitted-type.rs:9:12 | -LL | const B = core::direct_const_arg!(4); +LL | const B = gca!(4); | ^ | help: provide a type for the item | -LL | const B: = core::direct_const_arg!(4); +LL | const B: = gca!(4); | ++++++++ error: type annotations needed for the literal - --> $DIR/type_const-inherent-const-omitted-type.rs:7:39 + --> $DIR/type_const-inherent-const-omitted-type.rs:9:20 | -LL | const B = core::direct_const_arg!(4); - | ^ +LL | const B = gca!(4); + | ^ error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/mgca/type_const-mismatched-type-incremental.rs b/tests/ui/const-generics/mgca/type_const-mismatched-type-incremental.rs index af59430e5b6ef..620c49cc6fe0f 100644 --- a/tests/ui/const-generics/mgca/type_const-mismatched-type-incremental.rs +++ b/tests/ui/const-generics/mgca/type_const-mismatched-type-incremental.rs @@ -2,10 +2,13 @@ //! //@ incremental #![feature(min_generic_const_args)] -const R: usize = core::direct_const_arg!(1_i32); //~ ERROR: the constant `1` is not of type `usize` -const U: usize = core::direct_const_arg!(-1_i32); //~ ERROR: the constant `-1` is not of type `usize` -const S: bool = core::direct_const_arg!(1i32); //~ ERROR: the constant `1` is not of type `bool` -const T: bool = core::direct_const_arg!(-1i32); //~ ERROR: the constant `-1` is not of type `bool` + +use std::gca; + +const R: usize = gca!(1_i32); //~ ERROR: the constant `1` is not of type `usize` +const U: usize = gca!(-1_i32); //~ ERROR: the constant `-1` is not of type `usize` +const S: bool = gca!(1i32); //~ ERROR: the constant `1` is not of type `bool` +const T: bool = gca!(-1i32); //~ ERROR: the constant `-1` is not of type `bool` fn main() { R; diff --git a/tests/ui/const-generics/mgca/type_const-mismatched-type-incremental.stderr b/tests/ui/const-generics/mgca/type_const-mismatched-type-incremental.stderr index 86c807d9df356..2b05fe422b4a6 100644 --- a/tests/ui/const-generics/mgca/type_const-mismatched-type-incremental.stderr +++ b/tests/ui/const-generics/mgca/type_const-mismatched-type-incremental.stderr @@ -1,25 +1,25 @@ error: the constant `1` is not of type `usize` - --> $DIR/type_const-mismatched-type-incremental.rs:5:1 + --> $DIR/type_const-mismatched-type-incremental.rs:8:1 | -LL | const R: usize = core::direct_const_arg!(1_i32); +LL | const R: usize = gca!(1_i32); | ^^^^^^^^^^^^^^ expected `usize`, found `i32` error: the constant `-1` is not of type `usize` - --> $DIR/type_const-mismatched-type-incremental.rs:6:1 + --> $DIR/type_const-mismatched-type-incremental.rs:9:1 | -LL | const U: usize = core::direct_const_arg!(-1_i32); +LL | const U: usize = gca!(-1_i32); | ^^^^^^^^^^^^^^ expected `usize`, found `i32` error: the constant `1` is not of type `bool` - --> $DIR/type_const-mismatched-type-incremental.rs:7:1 + --> $DIR/type_const-mismatched-type-incremental.rs:10:1 | -LL | const S: bool = core::direct_const_arg!(1i32); +LL | const S: bool = gca!(1i32); | ^^^^^^^^^^^^^ expected `bool`, found `i32` error: the constant `-1` is not of type `bool` - --> $DIR/type_const-mismatched-type-incremental.rs:8:1 + --> $DIR/type_const-mismatched-type-incremental.rs:11:1 | -LL | const T: bool = core::direct_const_arg!(-1i32); +LL | const T: bool = gca!(-1i32); | ^^^^^^^^^^^^^ expected `bool`, found `i32` error: aborting due to 4 previous errors diff --git a/tests/ui/const-generics/mgca/type_const-mismatched-types.rs b/tests/ui/const-generics/mgca/type_const-mismatched-types.rs index 9dbba436520c6..d4169868903b2 100644 --- a/tests/ui/const-generics/mgca/type_const-mismatched-types.rs +++ b/tests/ui/const-generics/mgca/type_const-mismatched-types.rs @@ -1,10 +1,12 @@ #![expect(incomplete_features)] #![feature(min_generic_const_args)] -const FREE: u32 = core::direct_const_arg!(5_usize); +use std::gca; + +const FREE: u32 = gca!(5_usize); //~^ ERROR the constant `5` is not of type `u32` -const FREE2: isize = core::direct_const_arg!(FREE); +const FREE2: isize = gca!(FREE); //~^ ERROR the constant `5` is not of type `u32` //~| ERROR the constant `5` is not of type `isize` @@ -14,7 +16,7 @@ trait Tr { } impl Tr for () { - const N: usize = core::direct_const_arg!(false); + const N: usize = gca!(false); //~^ ERROR the constant `false` is not of type `usize` } diff --git a/tests/ui/const-generics/mgca/type_const-mismatched-types.stderr b/tests/ui/const-generics/mgca/type_const-mismatched-types.stderr index e4b3e39180361..3cba92197dcae 100644 --- a/tests/ui/const-generics/mgca/type_const-mismatched-types.stderr +++ b/tests/ui/const-generics/mgca/type_const-mismatched-types.stderr @@ -1,25 +1,25 @@ error: the constant `5` is not of type `u32` - --> $DIR/type_const-mismatched-types.rs:4:1 + --> $DIR/type_const-mismatched-types.rs:6:1 | -LL | const FREE: u32 = core::direct_const_arg!(5_usize); +LL | const FREE: u32 = gca!(5_usize); | ^^^^^^^^^^^^^^^ expected `u32`, found `usize` error: the constant `5` is not of type `u32` - --> $DIR/type_const-mismatched-types.rs:7:1 + --> $DIR/type_const-mismatched-types.rs:9:1 | -LL | const FREE2: isize = core::direct_const_arg!(FREE); +LL | const FREE2: isize = gca!(FREE); | ^^^^^^^^^^^^^^^^^^ expected `u32`, found `usize` error: the constant `5` is not of type `isize` - --> $DIR/type_const-mismatched-types.rs:7:1 + --> $DIR/type_const-mismatched-types.rs:9:1 | -LL | const FREE2: isize = core::direct_const_arg!(FREE); +LL | const FREE2: isize = gca!(FREE); | ^^^^^^^^^^^^^^^^^^ expected `isize`, found `usize` error: the constant `false` is not of type `usize` - --> $DIR/type_const-mismatched-types.rs:17:5 + --> $DIR/type_const-mismatched-types.rs:19:5 | -LL | const N: usize = core::direct_const_arg!(false); +LL | const N: usize = gca!(false); | ^^^^^^^^^^^^^^ expected `usize`, found `bool` error: aborting due to 4 previous errors diff --git a/tests/ui/const-generics/mgca/type_const-not-constparamty.rs b/tests/ui/const-generics/mgca/type_const-not-constparamty.rs index 27debb924ffd6..bc26ee967f573 100644 --- a/tests/ui/const-generics/mgca/type_const-not-constparamty.rs +++ b/tests/ui/const-generics/mgca/type_const-not-constparamty.rs @@ -1,11 +1,13 @@ #![expect(incomplete_features)] #![feature(min_generic_const_args)] +use std::gca; + struct S; // FIXME(mgca): need support for ctors without anon const // (we use a const-block to trigger an anon const here) -const FREE: S = core::direct_const_arg!(const { S }); +const FREE: S = gca!(const { S }); //~^ ERROR `S` must implement `ConstParamTy` to be used as the type of a const generic parameter trait Tr { @@ -17,7 +19,7 @@ trait Tr { impl Tr for S { // FIXME(mgca): need support for ctors without anon const // (we use a const-block to trigger an anon const here) - const N: S = core::direct_const_arg!(const { S }); + const N: S = gca!(const { S }); //~^ ERROR `S` must implement `ConstParamTy` to be used as the type of a const generic parameter } diff --git a/tests/ui/const-generics/mgca/type_const-not-constparamty.stderr b/tests/ui/const-generics/mgca/type_const-not-constparamty.stderr index 7492432119943..9c55277eb3b39 100644 --- a/tests/ui/const-generics/mgca/type_const-not-constparamty.stderr +++ b/tests/ui/const-generics/mgca/type_const-not-constparamty.stderr @@ -1,7 +1,7 @@ error[E0741]: `S` must implement `ConstParamTy` to be used as the type of a const generic parameter - --> $DIR/type_const-not-constparamty.rs:8:13 + --> $DIR/type_const-not-constparamty.rs:10:13 | -LL | const FREE: S = core::direct_const_arg!(const { S }); +LL | const FREE: S = gca!(const { S }); | ^ | help: add `#[derive(ConstParamTy, PartialEq, Eq)]` to the struct @@ -11,9 +11,9 @@ LL | struct S; | error[E0741]: `S` must implement `ConstParamTy` to be used as the type of a const generic parameter - --> $DIR/type_const-not-constparamty.rs:20:14 + --> $DIR/type_const-not-constparamty.rs:22:14 | -LL | const N: S = core::direct_const_arg!(const { S }); +LL | const N: S = gca!(const { S }); | ^ | help: add `#[derive(ConstParamTy, PartialEq, Eq)]` to the struct @@ -23,7 +23,7 @@ LL | struct S; | error[E0741]: `S` must implement `ConstParamTy` to be used as the type of a const generic parameter - --> $DIR/type_const-not-constparamty.rs:13:14 + --> $DIR/type_const-not-constparamty.rs:15:14 | LL | const N: S; | ^ diff --git a/tests/ui/const-generics/mgca/type_const-on-generic-expr.rs b/tests/ui/const-generics/mgca/type_const-on-generic-expr.rs index 574a5febadaac..ce6ca6cf01bf0 100644 --- a/tests/ui/const-generics/mgca/type_const-on-generic-expr.rs +++ b/tests/ui/const-generics/mgca/type_const-on-generic-expr.rs @@ -1,10 +1,12 @@ #![expect(incomplete_features)] #![feature(min_generic_const_args, generic_const_items)] -const FREE1: usize = core::direct_const_arg!(const { std::mem::size_of::() }); +use std::gca; + +const FREE1: usize = gca!(const { std::mem::size_of::() }); //~^ ERROR generic parameters may not be used in const operations -const FREE2: usize = core::direct_const_arg!(const { I + 1 }); +const FREE2: usize = gca!(const { I + 1 }); //~^ ERROR generic parameters may not be used in const operations fn main() {} diff --git a/tests/ui/const-generics/mgca/type_const-on-generic-expr.stderr b/tests/ui/const-generics/mgca/type_const-on-generic-expr.stderr index 1e11af4de9571..545675ead06a5 100644 --- a/tests/ui/const-generics/mgca/type_const-on-generic-expr.stderr +++ b/tests/ui/const-generics/mgca/type_const-on-generic-expr.stderr @@ -1,16 +1,16 @@ error: generic parameters may not be used in const operations - --> $DIR/type_const-on-generic-expr.rs:4:77 + --> $DIR/type_const-on-generic-expr.rs:6:58 | -LL | const FREE1: usize = core::direct_const_arg!(const { std::mem::size_of::() }); - | ^ +LL | const FREE1: usize = gca!(const { std::mem::size_of::() }); + | ^ | = help: add `#![feature(generic_const_args)]` and extract the expression into a `type const` item error: generic parameters may not be used in const operations - --> $DIR/type_const-on-generic-expr.rs:7:70 + --> $DIR/type_const-on-generic-expr.rs:9:51 | -LL | const FREE2: usize = core::direct_const_arg!(const { I + 1 }); - | ^ +LL | const FREE2: usize = gca!(const { I + 1 }); + | ^ | = help: add `#![feature(generic_const_args)]` and extract the expression into a `type const` item diff --git a/tests/ui/const-generics/mgca/type_const-on-generic_expr-2.rs b/tests/ui/const-generics/mgca/type_const-on-generic_expr-2.rs index b82eb2f046485..59898c76f4e78 100644 --- a/tests/ui/const-generics/mgca/type_const-on-generic_expr-2.rs +++ b/tests/ui/const-generics/mgca/type_const-on-generic_expr-2.rs @@ -1,6 +1,8 @@ #![expect(incomplete_features)] #![feature(min_generic_const_args, generic_const_items)] +use std::gca; + pub trait Tr { #[rustc_always_gca] const N1: usize; @@ -13,11 +15,11 @@ pub trait Tr { pub struct S; impl Tr for S { - const N1: usize = core::direct_const_arg!(const { std::mem::size_of::() }); + const N1: usize = gca!(const { std::mem::size_of::() }); //~^ ERROR generic parameters may not be used in const operations - const N2: usize = core::direct_const_arg!(const { I + 1 }); + const N2: usize = gca!(const { I + 1 }); //~^ ERROR generic parameters may not be used in const operations - const N3: usize = core::direct_const_arg!(const { 2 & X }); + const N3: usize = gca!(const { 2 & X }); //~^ ERROR generic parameters may not be used in const operations } diff --git a/tests/ui/const-generics/mgca/type_const-on-generic_expr-2.stderr b/tests/ui/const-generics/mgca/type_const-on-generic_expr-2.stderr index cac6858b937c0..4eb207e110fdb 100644 --- a/tests/ui/const-generics/mgca/type_const-on-generic_expr-2.stderr +++ b/tests/ui/const-generics/mgca/type_const-on-generic_expr-2.stderr @@ -1,24 +1,24 @@ error: generic parameters may not be used in const operations - --> $DIR/type_const-on-generic_expr-2.rs:16:78 + --> $DIR/type_const-on-generic_expr-2.rs:18:59 | -LL | const N1: usize = core::direct_const_arg!(const { std::mem::size_of::() }); - | ^ +LL | const N1: usize = gca!(const { std::mem::size_of::() }); + | ^ | = help: add `#![feature(generic_const_args)]` and extract the expression into a `type const` item error: generic parameters may not be used in const operations - --> $DIR/type_const-on-generic_expr-2.rs:18:71 + --> $DIR/type_const-on-generic_expr-2.rs:20:52 | -LL | const N2: usize = core::direct_const_arg!(const { I + 1 }); - | ^ +LL | const N2: usize = gca!(const { I + 1 }); + | ^ | = help: add `#![feature(generic_const_args)]` and extract the expression into a `type const` item error: generic parameters may not be used in const operations - --> $DIR/type_const-on-generic_expr-2.rs:20:59 + --> $DIR/type_const-on-generic_expr-2.rs:22:40 | -LL | const N3: usize = core::direct_const_arg!(const { 2 & X }); - | ^ +LL | const N3: usize = gca!(const { 2 & X }); + | ^ | = help: add `#![feature(generic_const_args)]` and extract the expression into a `type const` item diff --git a/tests/ui/const-generics/mgca/type_const-only-in-impl-omitted-type.rs b/tests/ui/const-generics/mgca/type_const-only-in-impl-omitted-type.rs index 853eb37aae3f0..5a716807fc3e4 100644 --- a/tests/ui/const-generics/mgca/type_const-only-in-impl-omitted-type.rs +++ b/tests/ui/const-generics/mgca/type_const-only-in-impl-omitted-type.rs @@ -1,6 +1,8 @@ #![expect(incomplete_features)] #![feature(min_generic_const_args)] +use std::gca; + trait BadTr { const NUM: usize; } @@ -8,10 +10,10 @@ trait BadTr { struct GoodS; impl BadTr for GoodS { - const NUM: = core::direct_const_arg!(84); + const NUM: = gca!(84); //~^ ERROR: missing type for `const` item //~| ERROR: type annotations needed for the literal - //~| ERROR: implementation of a regular const cannot have a `direct_const_arg!` RHS + //~| ERROR: implementation of a regular const cannot have a `gca!` RHS } fn accept_bad_tr>(_x: &T) {} diff --git a/tests/ui/const-generics/mgca/type_const-only-in-impl-omitted-type.stderr b/tests/ui/const-generics/mgca/type_const-only-in-impl-omitted-type.stderr index 445d5d4a2efd9..18dc857d1deb0 100644 --- a/tests/ui/const-generics/mgca/type_const-only-in-impl-omitted-type.stderr +++ b/tests/ui/const-generics/mgca/type_const-only-in-impl-omitted-type.stderr @@ -1,29 +1,29 @@ error: missing type for `const` item - --> $DIR/type_const-only-in-impl-omitted-type.rs:11:15 + --> $DIR/type_const-only-in-impl-omitted-type.rs:13:15 | -LL | const NUM: = core::direct_const_arg!(84); +LL | const NUM: = gca!(84); | ^ help: provide a type for the associated constant: `usize` error: type annotations needed for the literal - --> $DIR/type_const-only-in-impl-omitted-type.rs:11:42 + --> $DIR/type_const-only-in-impl-omitted-type.rs:13:23 | -LL | const NUM: = core::direct_const_arg!(84); - | ^^ +LL | const NUM: = gca!(84); + | ^^ -error: implementation of a regular const cannot have a `direct_const_arg!` RHS - --> $DIR/type_const-only-in-impl-omitted-type.rs:11:5 +error: implementation of a regular const cannot have a `gca!` RHS + --> $DIR/type_const-only-in-impl-omitted-type.rs:13:5 | -LL | const NUM: = core::direct_const_arg!(84); +LL | const NUM: = gca!(84); | ^^^^^^^^^^ | note: trait declaration of const is not marked as `#[rustc_always_gca]` - --> $DIR/type_const-only-in-impl-omitted-type.rs:5:5 + --> $DIR/type_const-only-in-impl-omitted-type.rs:7:5 | LL | const NUM: usize; | ^^^^^^^^^^^^^^^^ error: use of trait associated const not defined as `#[rustc_always_gca]` - --> $DIR/type_const-only-in-impl-omitted-type.rs:17:43 + --> $DIR/type_const-only-in-impl-omitted-type.rs:19:43 | LL | fn accept_bad_tr>(_x: &T) {} | ^^^^^^^^^^^ diff --git a/tests/ui/const-generics/mgca/type_const-only-in-impl.rs b/tests/ui/const-generics/mgca/type_const-only-in-impl.rs index 3f8b924af0799..f536e810348d8 100644 --- a/tests/ui/const-generics/mgca/type_const-only-in-impl.rs +++ b/tests/ui/const-generics/mgca/type_const-only-in-impl.rs @@ -1,6 +1,8 @@ #![expect(incomplete_features)] #![feature(min_generic_const_args)] +use std::gca; + trait BadTr { const NUM: usize; } @@ -8,8 +10,8 @@ trait BadTr { struct GoodS; impl BadTr for GoodS { - const NUM: usize = core::direct_const_arg!(84); - //~^ ERROR implementation of a regular const cannot have a `direct_const_arg!` RHS + const NUM: usize = gca!(84); + //~^ ERROR implementation of a regular const cannot have a `gca!` RHS } fn accept_bad_tr>(_x: &T) {} diff --git a/tests/ui/const-generics/mgca/type_const-only-in-impl.stderr b/tests/ui/const-generics/mgca/type_const-only-in-impl.stderr index cc32eafad40fc..99b49c6e8bdcd 100644 --- a/tests/ui/const-generics/mgca/type_const-only-in-impl.stderr +++ b/tests/ui/const-generics/mgca/type_const-only-in-impl.stderr @@ -1,17 +1,17 @@ -error: implementation of a regular const cannot have a `direct_const_arg!` RHS - --> $DIR/type_const-only-in-impl.rs:11:5 +error: implementation of a regular const cannot have a `gca!` RHS + --> $DIR/type_const-only-in-impl.rs:13:5 | -LL | const NUM: usize = core::direct_const_arg!(84); +LL | const NUM: usize = gca!(84); | ^^^^^^^^^^^^^^^^ | note: trait declaration of const is not marked as `#[rustc_always_gca]` - --> $DIR/type_const-only-in-impl.rs:5:5 + --> $DIR/type_const-only-in-impl.rs:7:5 | LL | const NUM: usize; | ^^^^^^^^^^^^^^^^ error: use of trait associated const not defined as `#[rustc_always_gca]` - --> $DIR/type_const-only-in-impl.rs:15:43 + --> $DIR/type_const-only-in-impl.rs:17:43 | LL | fn accept_bad_tr>(_x: &T) {} | ^^^^^^^^^^^ diff --git a/tests/ui/const-generics/mgca/type_const-only-in-trait.rs b/tests/ui/const-generics/mgca/type_const-only-in-trait.rs index 82c5a6f8417a5..687adf8371272 100644 --- a/tests/ui/const-generics/mgca/type_const-only-in-trait.rs +++ b/tests/ui/const-generics/mgca/type_const-only-in-trait.rs @@ -1,6 +1,8 @@ #![expect(incomplete_features)] #![feature(min_generic_const_args)] +use std::gca; + trait GoodTr { #[rustc_always_gca] const NUM: usize; @@ -10,7 +12,7 @@ struct BadS; impl GoodTr for BadS { const NUM: usize = 42; - //~^ ERROR implementation of a `#[rustc_always_gca]` must have a `direct_const_arg!` RHS + //~^ ERROR implementation of a `#[rustc_always_gca]` must have a `gca!` RHS } fn accept_good_tr>(_x: &T) {} diff --git a/tests/ui/const-generics/mgca/type_const-only-in-trait.stderr b/tests/ui/const-generics/mgca/type_const-only-in-trait.stderr index e2ba59133925f..cab3f9b08aec1 100644 --- a/tests/ui/const-generics/mgca/type_const-only-in-trait.stderr +++ b/tests/ui/const-generics/mgca/type_const-only-in-trait.stderr @@ -1,11 +1,11 @@ -error: implementation of a `#[rustc_always_gca]` must have a `direct_const_arg!` RHS - --> $DIR/type_const-only-in-trait.rs:12:5 +error: implementation of a `#[rustc_always_gca]` must have a `gca!` RHS + --> $DIR/type_const-only-in-trait.rs:14:5 | LL | const NUM: usize = 42; | ^^^^^^^^^^^^^^^^ | note: trait declaration of const is marked as `#[rustc_always_gca]` - --> $DIR/type_const-only-in-trait.rs:6:5 + --> $DIR/type_const-only-in-trait.rs:8:5 | LL | const NUM: usize; | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/const-generics/mgca/type_const-pub.rs b/tests/ui/const-generics/mgca/type_const-pub.rs index 36936e22726d4..9499e7e952384 100644 --- a/tests/ui/const-generics/mgca/type_const-pub.rs +++ b/tests/ui/const-generics/mgca/type_const-pub.rs @@ -5,7 +5,9 @@ #![expect(incomplete_features)] #![feature(min_generic_const_args)] -pub const TYPE_CONST: usize = core::direct_const_arg!(1); +use std::gca; + +pub const TYPE_CONST: usize = gca!(1); fn main() { print!("{}", TYPE_CONST) } diff --git a/tests/ui/const-generics/mgca/type_const-recursive.rs b/tests/ui/const-generics/mgca/type_const-recursive.rs index 1963cdce9fe4c..c7178da8f437c 100644 --- a/tests/ui/const-generics/mgca/type_const-recursive.rs +++ b/tests/ui/const-generics/mgca/type_const-recursive.rs @@ -1,7 +1,9 @@ #![expect(incomplete_features)] #![feature(min_generic_const_args)] -const A: u8 = core::direct_const_arg!(A); +use std::gca; + +const A: u8 = gca!(A); //~^ ERROR: cycle detected when computing the type-level value for `A` [E0391] fn main() {} diff --git a/tests/ui/const-generics/mgca/type_const-recursive.stderr b/tests/ui/const-generics/mgca/type_const-recursive.stderr index 2dd4102b472bc..551fc016b2c73 100644 --- a/tests/ui/const-generics/mgca/type_const-recursive.stderr +++ b/tests/ui/const-generics/mgca/type_const-recursive.stderr @@ -1,7 +1,7 @@ error[E0391]: cycle detected when computing the type-level value for `A` - --> $DIR/type_const-recursive.rs:4:1 + --> $DIR/type_const-recursive.rs:6:1 | -LL | const A: u8 = core::direct_const_arg!(A); +LL | const A: u8 = gca!(A); | ^^^^^^^^^^^ | = note: ...which immediately requires computing the type-level value for `A` again diff --git a/tests/ui/const-generics/mgca/type_const-use.rs b/tests/ui/const-generics/mgca/type_const-use.rs index cef0d10f0c4ed..e8900e0d4e69e 100644 --- a/tests/ui/const-generics/mgca/type_const-use.rs +++ b/tests/ui/const-generics/mgca/type_const-use.rs @@ -3,7 +3,9 @@ #![expect(incomplete_features)] #![feature(min_generic_const_args)] -const CONST: usize = core::direct_const_arg!(1); +use std::gca; + +const CONST: usize = gca!(1); fn uses_const() { CONST; diff --git a/tests/ui/const-generics/mgca/type_const_in_pattern.rs b/tests/ui/const-generics/mgca/type_const_in_pattern.rs index 01fae246f9293..52d824343c2a6 100644 --- a/tests/ui/const-generics/mgca/type_const_in_pattern.rs +++ b/tests/ui/const-generics/mgca/type_const_in_pattern.rs @@ -3,12 +3,14 @@ #![expect(incomplete_features)] #![allow(irrefutable_let_patterns)] -const CONST: usize = core::direct_const_arg!(1_usize); +use std::gca; + +const CONST: usize = gca!(1_usize); struct Inherent; impl Inherent { - const BAR: usize = core::direct_const_arg!(1_usize); + const BAR: usize = gca!(1_usize); } trait Trait { @@ -19,7 +21,7 @@ trait Trait { struct Assoc; impl Trait for Assoc { - const BAZ: usize = core::direct_const_arg!(1_usize); + const BAZ: usize = gca!(1_usize); } fn main() { diff --git a/tests/ui/const-generics/mgca/unbraced_const_block_const_arg_gated.rs b/tests/ui/const-generics/mgca/unbraced_const_block_const_arg_gated.rs index e341727407143..9e6370c485a0b 100644 --- a/tests/ui/const-generics/mgca/unbraced_const_block_const_arg_gated.rs +++ b/tests/ui/const-generics/mgca/unbraced_const_block_const_arg_gated.rs @@ -1,5 +1,7 @@ #![feature(adt_const_params)] +use std::gca; + #[derive(Eq, PartialEq, std::marker::ConstParamTy)] struct Inner; @@ -32,9 +34,9 @@ fn generic() { const NON_TYPE_CONST: usize = const { 1 }; -const TYPE_CONST: usize = core::direct_const_arg!(const { 1 }); +const TYPE_CONST: usize = gca!(const { 1 }); //~^ ERROR: use of unstable library feature `min_generic_const_args` [E0658] -//~| ERROR: expected expression, found `direct_const_arg!()` constant +//~| ERROR: expected expression, found `gca!()` constant static STATIC: usize = const { 1 }; diff --git a/tests/ui/const-generics/mgca/unbraced_const_block_const_arg_gated.stderr b/tests/ui/const-generics/mgca/unbraced_const_block_const_arg_gated.stderr index bd2b5238a9356..8467c3abdc942 100644 --- a/tests/ui/const-generics/mgca/unbraced_const_block_const_arg_gated.stderr +++ b/tests/ui/const-generics/mgca/unbraced_const_block_const_arg_gated.stderr @@ -1,15 +1,15 @@ error[E0658]: use of unstable library feature `min_generic_const_args` - --> $DIR/unbraced_const_block_const_arg_gated.rs:35:27 + --> $DIR/unbraced_const_block_const_arg_gated.rs:37:27 | -LL | const TYPE_CONST: usize = core::direct_const_arg!(const { 1 }); - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | const TYPE_CONST: usize = gca!(const { 1 }); + | ^^^ | = note: see issue #132980 for more information = help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: unbraced const blocks as const args are experimental - --> $DIR/unbraced_const_block_const_arg_gated.rs:7:27 + --> $DIR/unbraced_const_block_const_arg_gated.rs:9:27 | LL | const PARAM_TY: Inner, | ^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | const PARAM_TY: Inner, = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: unbraced const blocks as const args are experimental - --> $DIR/unbraced_const_block_const_arg_gated.rs:9:28 + --> $DIR/unbraced_const_block_const_arg_gated.rs:11:28 | LL | const DEFAULT: usize = const { 1 }, | ^^^^^^^^^^^ @@ -29,7 +29,7 @@ LL | const DEFAULT: usize = const { 1 }, = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: unbraced const blocks as const args are experimental - --> $DIR/unbraced_const_block_const_arg_gated.rs:14:23 + --> $DIR/unbraced_const_block_const_arg_gated.rs:16:23 | LL | type NormalTy = Inner; | ^^^^^^^^^^^ @@ -39,7 +39,7 @@ LL | type NormalTy = Inner; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: unbraced const blocks as const args are experimental - --> $DIR/unbraced_const_block_const_arg_gated.rs:22:18 + --> $DIR/unbraced_const_block_const_arg_gated.rs:24:18 | LL | let _: Inner; | ^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | let _: Inner; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: unbraced const blocks as const args are experimental - --> $DIR/unbraced_const_block_const_arg_gated.rs:28:19 + --> $DIR/unbraced_const_block_const_arg_gated.rs:30:19 | LL | generic::(); | ^^^^^^^^^^^ @@ -58,11 +58,11 @@ LL | generic::(); = help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: expected expression, found `direct_const_arg!()` constant - --> $DIR/unbraced_const_block_const_arg_gated.rs:35:27 +error: expected expression, found `gca!()` constant + --> $DIR/unbraced_const_block_const_arg_gated.rs:37:27 | -LL | const TYPE_CONST: usize = core::direct_const_arg!(const { 1 }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | const TYPE_CONST: usize = gca!(const { 1 }); + | ^^^^^^^^^^^^^^^^^ error: aborting due to 7 previous errors diff --git a/tests/ui/const-generics/mgca/unmarked-free-const.rs b/tests/ui/const-generics/mgca/unmarked-free-const.rs index e118b486f2c77..04cf63b71ed07 100644 --- a/tests/ui/const-generics/mgca/unmarked-free-const.rs +++ b/tests/ui/const-generics/mgca/unmarked-free-const.rs @@ -3,9 +3,11 @@ #![feature(min_generic_const_args)] #![allow(incomplete_features)] +use std::gca; + const N: usize = 4; fn main() { - let x = [(); core::direct_const_arg!(N)]; + let x = [(); gca!(N)]; //~^ ERROR use of `const` in the type system not marked as direct } diff --git a/tests/ui/const-generics/mgca/unmarked-free-const.stderr b/tests/ui/const-generics/mgca/unmarked-free-const.stderr index 246a8200247c1..de797a46f33ce 100644 --- a/tests/ui/const-generics/mgca/unmarked-free-const.stderr +++ b/tests/ui/const-generics/mgca/unmarked-free-const.stderr @@ -1,13 +1,13 @@ error: use of `const` in the type system not marked as direct - --> $DIR/unmarked-free-const.rs:9:42 + --> $DIR/unmarked-free-const.rs:11:23 | -LL | let x = [(); core::direct_const_arg!(N)]; - | ^ +LL | let x = [(); gca!(N)]; + | ^ | -help: add direct_const_arg!() to the right-hand side of the constant +help: add gca!() to the right-hand side of the constant | -LL | const N: usize = core::direct_const_arg!(4); - | ++++++++++++++++++++++++ + +LL | const N: usize = core::gca!(4); + | +++++++++++ + error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/type-const-ice-issue-151631.rs b/tests/ui/const-generics/type-const-ice-issue-151631.rs index 8112d21a923f0..6133feba70a3b 100644 --- a/tests/ui/const-generics/type-const-ice-issue-151631.rs +++ b/tests/ui/const-generics/type-const-ice-issue-151631.rs @@ -3,6 +3,8 @@ #![feature(min_generic_const_args)] #![expect(incomplete_features)] +use std::gca; + trait SuperTrait {} trait Trait: SuperTrait { #[rustc_always_gca] @@ -10,7 +12,7 @@ trait Trait: SuperTrait { } impl Trait for () { //~^ ERROR: the trait bound `(): SuperTrait` is not satisfied - const K: u32 = core::direct_const_arg!(const { 1 }); + const K: u32 = gca!(const { 1 }); } fn check(_: impl Trait) {} diff --git a/tests/ui/const-generics/type-const-ice-issue-151631.stderr b/tests/ui/const-generics/type-const-ice-issue-151631.stderr index aa934b91fb5a4..2a42518efc790 100644 --- a/tests/ui/const-generics/type-const-ice-issue-151631.stderr +++ b/tests/ui/const-generics/type-const-ice-issue-151631.stderr @@ -1,22 +1,22 @@ error[E0277]: the trait bound `(): SuperTrait` is not satisfied - --> $DIR/type-const-ice-issue-151631.rs:11:16 + --> $DIR/type-const-ice-issue-151631.rs:13:16 | LL | impl Trait for () { | ^^ the trait `SuperTrait` is not implemented for `()` | help: this trait has no implementations, consider adding one - --> $DIR/type-const-ice-issue-151631.rs:6:1 + --> $DIR/type-const-ice-issue-151631.rs:8:1 | LL | trait SuperTrait {} | ^^^^^^^^^^^^^^^^ note: required by a bound in `Trait` - --> $DIR/type-const-ice-issue-151631.rs:7:14 + --> $DIR/type-const-ice-issue-151631.rs:9:14 | LL | trait Trait: SuperTrait { | ^^^^^^^^^^ required by this bound in `Trait` error[E0271]: type mismatch resolving `<() as Trait>::K == 0` - --> $DIR/type-const-ice-issue-151631.rs:19:11 + --> $DIR/type-const-ice-issue-151631.rs:21:11 | LL | check(()); | ----- ^^ expected `0`, found `1` @@ -26,7 +26,7 @@ LL | check(()); = note: expected constant `0` found constant `1` note: required by a bound in `check` - --> $DIR/type-const-ice-issue-151631.rs:16:24 + --> $DIR/type-const-ice-issue-151631.rs:18:24 | LL | fn check(_: impl Trait) {} | ^^^^^ required by this bound in `check` diff --git a/tests/ui/const-generics/type-relative-path-144547.rs b/tests/ui/const-generics/type-relative-path-144547.rs index 399918ec6cffc..35722efd17fd4 100644 --- a/tests/ui/const-generics/type-relative-path-144547.rs +++ b/tests/ui/const-generics/type-relative-path-144547.rs @@ -22,7 +22,7 @@ struct Info; impl LevelInfo for Info { #[cfg(mgca)] - const SUPPORTED_SLOTS: usize = core::direct_const_arg!(1); + const SUPPORTED_SLOTS: usize = std::gca!(1); #[cfg(not(mgca))] const SUPPORTED_SLOTS: usize = 1; diff --git a/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155125.stderr b/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155125.stderr index 30aad09279447..290c5a492fa90 100644 --- a/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155125.stderr +++ b/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155125.stderr @@ -1,5 +1,5 @@ error[E0428]: the name `foo` is defined multiple times - --> $DIR/hir-crate-items-before-lowering-ices.rs:13:17 + --> $DIR/hir-crate-items-before-lowering-ices.rs:14:17 | LL | fn foo() {} | -------- previous definition of the value `foo` here @@ -9,10 +9,10 @@ LL | reuse foo; = note: `foo` must be defined only once in the value namespace of this block error: complex const arguments must be placed inside of a `const` block - --> $DIR/hir-crate-items-before-lowering-ices.rs:11:37 + --> $DIR/hir-crate-items-before-lowering-ices.rs:12:18 | -LL | core::direct_const_arg!({ - | _____________________________________^ +LL | gca!({ + | __________________^ LL | | fn foo() {} LL | | reuse foo; LL | | 2 diff --git a/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155127.stderr b/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155127.stderr index e38645655a8a5..571a0f7198df9 100644 --- a/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155127.stderr +++ b/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155127.stderr @@ -1,5 +1,5 @@ error: the `deprecated` attribute cannot be used on delegations - --> $DIR/hir-crate-items-before-lowering-ices.rs:27:11 + --> $DIR/hir-crate-items-before-lowering-ices.rs:28:11 | LL | #[deprecated] | ^^^^^^^^^^ diff --git a/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155128.stderr b/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155128.stderr index 674035c79f019..9f1e95d570b53 100644 --- a/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155128.stderr +++ b/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155128.stderr @@ -1,5 +1,5 @@ error: delegation's target expression is specified for function with no params - --> $DIR/hir-crate-items-before-lowering-ices.rs:37:18 + --> $DIR/hir-crate-items-before-lowering-ices.rs:38:18 | LL | reuse a as b { | __________________^ @@ -10,7 +10,7 @@ LL | | } | |_____^ error[E0061]: this function takes 0 arguments but 1 argument was supplied - --> $DIR/hir-crate-items-before-lowering-ices.rs:37:11 + --> $DIR/hir-crate-items-before-lowering-ices.rs:38:11 | LL | reuse a as b { | ___________^______- @@ -21,7 +21,7 @@ LL | | } | |_____- unexpected argument of type `fn() {foo::<_>}` | note: function defined here - --> $DIR/hir-crate-items-before-lowering-ices.rs:35:8 + --> $DIR/hir-crate-items-before-lowering-ices.rs:36:8 | LL | fn a() {} | ^ diff --git a/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155164.stderr b/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155164.stderr index b44a3c4174540..132c93b6c5532 100644 --- a/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155164.stderr +++ b/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155164.stderr @@ -1,8 +1,8 @@ error: complex const arguments must be placed inside of a `const` block - --> $DIR/hir-crate-items-before-lowering-ices.rs:48:37 + --> $DIR/hir-crate-items-before-lowering-ices.rs:50:18 | -LL | core::direct_const_arg!({ - | _____________________________________^ +LL | gca!({ + | __________________^ LL | | LL | | struct W; LL | | impl W { diff --git a/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155202.stderr b/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155202.stderr index 5012905807597..d331191ac24e0 100644 --- a/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155202.stderr +++ b/tests/ui/delegation/hir-crate-items-before-lowering-ices.ice_155202.stderr @@ -1,5 +1,5 @@ error: function cannot return without recursing - --> $DIR/hir-crate-items-before-lowering-ices.rs:67:22 + --> $DIR/hir-crate-items-before-lowering-ices.rs:69:22 | LL | reuse Trait::bar { | ^^^ @@ -9,7 +9,7 @@ LL | reuse Trait::bar { | = help: a `loop` may express intention better if this is on purpose note: the lint level is defined here - --> $DIR/hir-crate-items-before-lowering-ices.rs:61:8 + --> $DIR/hir-crate-items-before-lowering-ices.rs:63:8 | LL | #[deny(unconditional_recursion)] | ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/delegation/hir-crate-items-before-lowering-ices.rs b/tests/ui/delegation/hir-crate-items-before-lowering-ices.rs index 5689a29cafe11..cbe6cdd06df7e 100644 --- a/tests/ui/delegation/hir-crate-items-before-lowering-ices.rs +++ b/tests/ui/delegation/hir-crate-items-before-lowering-ices.rs @@ -5,10 +5,11 @@ #[cfg(ice_155125)] mod ice_155125 { + use std::gca; struct S; impl S< - core::direct_const_arg!({ //[ice_155125]~ ERROR: complex const arguments must be placed inside of a `const` block + gca!({ //[ice_155125]~ ERROR: complex const arguments must be placed inside of a `const` block fn foo() {} reuse foo; //[ice_155125]~ ERROR: the name `foo` is defined multiple times 2 @@ -43,9 +44,10 @@ mod ice_155128 { #[cfg(ice_155164)] mod ice_155164 { + use std::gca; struct X { inner: std::iter::Map< - core::direct_const_arg!({ + gca!({ //[ice_155164]~^ ERROR: complex const arguments must be placed inside of a `const` block struct W; impl W { diff --git a/tests/ui/delegation/inside-const-body-ice-155300.rs b/tests/ui/delegation/inside-const-body-ice-155300.rs index 2d13007bc807b..224f84845b354 100644 --- a/tests/ui/delegation/inside-const-body-ice-155300.rs +++ b/tests/ui/delegation/inside-const-body-ice-155300.rs @@ -1,11 +1,13 @@ #![feature(min_generic_const_args)] #![feature(fn_delegation)] +use std::gca; + pub struct S; impl S< - core::direct_const_arg!({ + gca!({ //~^ ERROR: complex const arguments must be placed inside of a `const` block fn foo() {} reuse foo::<> as bar; diff --git a/tests/ui/delegation/inside-const-body-ice-155300.stderr b/tests/ui/delegation/inside-const-body-ice-155300.stderr index f0cb830109f8a..d30f240556ac4 100644 --- a/tests/ui/delegation/inside-const-body-ice-155300.stderr +++ b/tests/ui/delegation/inside-const-body-ice-155300.stderr @@ -1,5 +1,5 @@ error[E0428]: the name `bar` is defined multiple times - --> $DIR/inside-const-body-ice-155300.rs:12:13 + --> $DIR/inside-const-body-ice-155300.rs:14:13 | LL | reuse foo::<> as bar; | --------------------- previous definition of the value `bar` here @@ -9,10 +9,10 @@ LL | reuse bar; = note: `bar` must be defined only once in the value namespace of this block error: complex const arguments must be placed inside of a `const` block - --> $DIR/inside-const-body-ice-155300.rs:8:33 + --> $DIR/inside-const-body-ice-155300.rs:10:14 | -LL | core::direct_const_arg!({ - | _________________________________^ +LL | gca!({ + | ______________^ LL | | LL | | fn foo() {} LL | | reuse foo::<> as bar; diff --git a/tests/ui/delegation/wrong-fn-kind-ice-159127.rs b/tests/ui/delegation/wrong-fn-kind-ice-159127.rs index e117826ef099c..e1cde084600fd 100644 --- a/tests/ui/delegation/wrong-fn-kind-ice-159127.rs +++ b/tests/ui/delegation/wrong-fn-kind-ice-159127.rs @@ -1,9 +1,11 @@ #![feature(fn_delegation)] #![feature(min_generic_const_args)] +use std::gca; + impl - core::direct_const_arg!({ - //~^ ERROR: expected type, found `direct_const_arg!()` constant + gca!({ + //~^ ERROR: expected type, found `gca!()` constant fn foo() {} reuse foo::<>as bar; reuse bar; diff --git a/tests/ui/delegation/wrong-fn-kind-ice-159127.stderr b/tests/ui/delegation/wrong-fn-kind-ice-159127.stderr index bc218f39ab65a..8afa2c45bdc4b 100644 --- a/tests/ui/delegation/wrong-fn-kind-ice-159127.stderr +++ b/tests/ui/delegation/wrong-fn-kind-ice-159127.stderr @@ -1,5 +1,5 @@ error[E0428]: the name `bar` is defined multiple times - --> $DIR/wrong-fn-kind-ice-159127.rs:9:9 + --> $DIR/wrong-fn-kind-ice-159127.rs:11:9 | LL | reuse foo::<>as bar; | -------------------- previous definition of the value `bar` here @@ -8,10 +8,10 @@ LL | reuse bar; | = note: `bar` must be defined only once in the value namespace of this block -error: expected type, found `direct_const_arg!()` constant - --> $DIR/wrong-fn-kind-ice-159127.rs:5:5 +error: expected type, found `gca!()` constant + --> $DIR/wrong-fn-kind-ice-159127.rs:7:5 | -LL | / core::direct_const_arg!({ +LL | / gca!({ LL | | LL | | fn foo() {} LL | | reuse foo::<>as bar; diff --git a/tests/ui/feature-gates/feature-gate-generic-const-args.rs b/tests/ui/feature-gates/feature-gate-generic-const-args.rs index c9403a269a8bc..e5bc617d96e4d 100644 --- a/tests/ui/feature-gates/feature-gate-generic-const-args.rs +++ b/tests/ui/feature-gates/feature-gate-generic-const-args.rs @@ -1,7 +1,9 @@ #![feature(generic_const_items, min_generic_const_args)] #![expect(incomplete_features)] -const INC: usize = core::direct_const_arg!(const { N + 1 }); +use std::gca; + +const INC: usize = gca!(const { N + 1 }); //~^ ERROR generic parameters may not be used in const operations //~| HELP add `#![feature(generic_const_args)]` diff --git a/tests/ui/feature-gates/feature-gate-generic-const-args.stderr b/tests/ui/feature-gates/feature-gate-generic-const-args.stderr index 6094430968f51..7d4c5a67c56a6 100644 --- a/tests/ui/feature-gates/feature-gate-generic-const-args.stderr +++ b/tests/ui/feature-gates/feature-gate-generic-const-args.stderr @@ -1,8 +1,8 @@ error: generic parameters may not be used in const operations - --> $DIR/feature-gate-generic-const-args.rs:4:68 + --> $DIR/feature-gate-generic-const-args.rs:6:49 | -LL | const INC: usize = core::direct_const_arg!(const { N + 1 }); - | ^ +LL | const INC: usize = gca!(const { N + 1 }); + | ^ | = help: add `#![feature(generic_const_args)]` and extract the expression into a `type const` item diff --git a/tests/ui/feature-gates/feature-gate-mgca-type-const-syntax.rs b/tests/ui/feature-gates/feature-gate-mgca-type-const-syntax.rs index 9737d9c521ac7..8da5824d9c49c 100644 --- a/tests/ui/feature-gates/feature-gate-mgca-type-const-syntax.rs +++ b/tests/ui/feature-gates/feature-gate-mgca-type-const-syntax.rs @@ -1,6 +1,6 @@ -const FOO: u8 = core::direct_const_arg!(10); +const FOO: u8 = std::gca!(10); //~^ ERROR use of unstable library feature `min_generic_const_args` [E0658] -//~| ERROR expected expression, found `direct_const_arg!()` constant +//~| ERROR expected expression, found `gca!()` constant trait Bar { #[rustc_always_gca] @@ -9,10 +9,10 @@ trait Bar { } impl Bar for bool { - const BAR: bool = core::direct_const_arg!(false); + const BAR: bool = std::gca!(false); //~^ ERROR use of unstable library feature `min_generic_const_args` [E0658] - //~| ERROR expected expression, found `direct_const_arg!()` constant - //~| ERROR implementation of a `#[rustc_always_gca]` must have a `direct_const_arg!` RHS + //~| ERROR expected expression, found `gca!()` constant + //~| ERROR implementation of a `#[rustc_always_gca]` must have a `gca!` RHS } fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-mgca-type-const-syntax.stderr b/tests/ui/feature-gates/feature-gate-mgca-type-const-syntax.stderr index 2daf2e1056b95..3ee23f4883e05 100644 --- a/tests/ui/feature-gates/feature-gate-mgca-type-const-syntax.stderr +++ b/tests/ui/feature-gates/feature-gate-mgca-type-const-syntax.stderr @@ -1,8 +1,8 @@ error[E0658]: use of unstable library feature `min_generic_const_args` --> $DIR/feature-gate-mgca-type-const-syntax.rs:1:17 | -LL | const FOO: u8 = core::direct_const_arg!(10); - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | const FOO: u8 = std::gca!(10); + | ^^^^^^^^ | = note: see issue #132980 for more information = help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable @@ -11,18 +11,18 @@ LL | const FOO: u8 = core::direct_const_arg!(10); error[E0658]: use of unstable library feature `min_generic_const_args` --> $DIR/feature-gate-mgca-type-const-syntax.rs:12:23 | -LL | const BAR: bool = core::direct_const_arg!(false); - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | const BAR: bool = std::gca!(false); + | ^^^^^^^^ | = note: see issue #132980 for more information = help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: expected expression, found `direct_const_arg!()` constant +error: expected expression, found `gca!()` constant --> $DIR/feature-gate-mgca-type-const-syntax.rs:1:17 | -LL | const FOO: u8 = core::direct_const_arg!(10); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | const FOO: u8 = std::gca!(10); + | ^^^^^^^^^^^^^ error[E0658]: the `rustc_always_gca` attribute is an experimental feature --> $DIR/feature-gate-mgca-type-const-syntax.rs:6:7 @@ -34,16 +34,16 @@ LL | #[rustc_always_gca] = help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: expected expression, found `direct_const_arg!()` constant +error: expected expression, found `gca!()` constant --> $DIR/feature-gate-mgca-type-const-syntax.rs:12:23 | -LL | const BAR: bool = core::direct_const_arg!(false); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | const BAR: bool = std::gca!(false); + | ^^^^^^^^^^^^^^^^ -error: implementation of a `#[rustc_always_gca]` must have a `direct_const_arg!` RHS +error: implementation of a `#[rustc_always_gca]` must have a `gca!` RHS --> $DIR/feature-gate-mgca-type-const-syntax.rs:12:5 | -LL | const BAR: bool = core::direct_const_arg!(false); +LL | const BAR: bool = std::gca!(false); | ^^^^^^^^^^^^^^^ | note: trait declaration of const is marked as `#[rustc_always_gca]` diff --git a/tests/ui/feature-gates/feature-gate-min-generic-const-args.rs b/tests/ui/feature-gates/feature-gate-min-generic-const-args.rs index a39d07eca0ee7..07f278f04591a 100644 --- a/tests/ui/feature-gates/feature-gate-min-generic-const-args.rs +++ b/tests/ui/feature-gates/feature-gate-min-generic-const-args.rs @@ -5,10 +5,10 @@ trait Trait { } // FIXME(mgca): add suggestion for mgca to this error -fn foo() -> [u8; core::direct_const_arg!(::ASSOC)] { +fn foo() -> [u8; std::gca!(::ASSOC)] { //~^ ERROR generic parameters may not be used in const operations //~| ERROR: use of unstable library feature `min_generic_const_args` [E0658] - //~| ERROR: expected expression, found `direct_const_arg!()` + //~| ERROR: expected expression, found `gca!()` loop {} } diff --git a/tests/ui/feature-gates/feature-gate-min-generic-const-args.stderr b/tests/ui/feature-gates/feature-gate-min-generic-const-args.stderr index eac9545d29681..f709affb8a819 100644 --- a/tests/ui/feature-gates/feature-gate-min-generic-const-args.stderr +++ b/tests/ui/feature-gates/feature-gate-min-generic-const-args.stderr @@ -1,18 +1,18 @@ error[E0658]: use of unstable library feature `min_generic_const_args` --> $DIR/feature-gate-min-generic-const-args.rs:8:28 | -LL | fn foo() -> [u8; core::direct_const_arg!(::ASSOC)] { - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo() -> [u8; std::gca!(::ASSOC)] { + | ^^^^^^^^ | = note: see issue #132980 for more information = help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: generic parameters may not be used in const operations - --> $DIR/feature-gate-min-generic-const-args.rs:8:53 + --> $DIR/feature-gate-min-generic-const-args.rs:8:39 | -LL | fn foo() -> [u8; core::direct_const_arg!(::ASSOC)] { - | ^ cannot perform const operation using `T` +LL | fn foo() -> [u8; std::gca!(::ASSOC)] { + | ^ cannot perform const operation using `T` | = note: type parameters may not be used in const expressions = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions @@ -28,11 +28,11 @@ LL | #[rustc_always_gca] = help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: expected expression, found `direct_const_arg!()` constant +error: expected expression, found `gca!()` constant --> $DIR/feature-gate-min-generic-const-args.rs:8:28 | -LL | fn foo() -> [u8; core::direct_const_arg!(::ASSOC)] { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo() -> [u8; std::gca!(::ASSOC)] { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 4 previous errors diff --git a/tests/ui/generic-const-items/assoc-const-bindings.rs b/tests/ui/generic-const-items/assoc-const-bindings.rs index 596c47de98f86..2e0929a56867c 100644 --- a/tests/ui/generic-const-items/assoc-const-bindings.rs +++ b/tests/ui/generic-const-items/assoc-const-bindings.rs @@ -4,6 +4,7 @@ #![feature(adt_const_params, const_param_ty_trait, generic_const_parameter_types)] #![expect(incomplete_features)] +use std::gca; use std::marker::{ConstParamTy, ConstParamTy_}; trait Owner { @@ -16,9 +17,9 @@ trait Owner { } impl Owner for () { - const C: u32 = core::direct_const_arg!(N); - const K: u32 = core::direct_const_arg!(const { 99 + 1 }); - const Q: Maybe = core::direct_const_arg!(Maybe::Nothing::); + const C: u32 = gca!(N); + const K: u32 = gca!(const { 99 + 1 }); + const Q: Maybe = gca!(Maybe::Nothing::); } fn take0(_: impl Owner = { N }>) {} diff --git a/tests/ui/generic-const-items/assoc-const-no-infer-ice-115806.rs b/tests/ui/generic-const-items/assoc-const-no-infer-ice-115806.rs index 31bca180df8a8..d1b88db9466ef 100644 --- a/tests/ui/generic-const-items/assoc-const-no-infer-ice-115806.rs +++ b/tests/ui/generic-const-items/assoc-const-no-infer-ice-115806.rs @@ -4,13 +4,15 @@ #![feature(associated_type_defaults)] #![allow(incomplete_features)] +use std::gca; + pub struct NoPin; impl Pins for NoPin {} pub trait PinA { #[rustc_always_gca] - const A: &'static () = core::direct_const_arg!(const { &() }); + const A: &'static () = gca!(const { &() }); } pub trait Pins {} @@ -18,7 +20,7 @@ pub trait Pins {} impl Pins for T //~^ ERROR conflicting implementations of trait `Pins<_>` for type `NoPin` where - T: PinA + T: PinA { } diff --git a/tests/ui/generic-const-items/assoc-const-no-infer-ice-115806.stderr b/tests/ui/generic-const-items/assoc-const-no-infer-ice-115806.stderr index 515ee3f0af8be..65ec6a2c4e46e 100644 --- a/tests/ui/generic-const-items/assoc-const-no-infer-ice-115806.stderr +++ b/tests/ui/generic-const-items/assoc-const-no-infer-ice-115806.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `Pins<_>` for type `NoPin` - --> $DIR/assoc-const-no-infer-ice-115806.rs:18:1 + --> $DIR/assoc-const-no-infer-ice-115806.rs:20:1 | LL | impl Pins for NoPin {} | --------------------------- first implementation here @@ -7,8 +7,8 @@ LL | impl Pins for NoPin {} LL | / impl Pins for T LL | | LL | | where -LL | | T: PinA - | |__________________________________________________________________^ conflicting implementation for `NoPin` +LL | | T: PinA + | |_______________________________________________^ conflicting implementation for `NoPin` | = note: downstream crates may implement trait `PinA<_>` for type `NoPin` diff --git a/tests/ui/generic-const-items/type-const-nested-assoc-const.rs b/tests/ui/generic-const-items/type-const-nested-assoc-const.rs index 64df0183f101e..4d91d7edc8f16 100644 --- a/tests/ui/generic-const-items/type-const-nested-assoc-const.rs +++ b/tests/ui/generic-const-items/type-const-nested-assoc-const.rs @@ -3,7 +3,9 @@ #![feature(generic_const_items, min_generic_const_args)] #![allow(incomplete_features)] -const CT: usize = core::direct_const_arg!(::N); +use std::gca; + +const CT: usize = gca!(::N); trait Trait { #[rustc_always_gca] @@ -11,7 +13,7 @@ trait Trait { } impl Trait for T { - const N: usize = core::direct_const_arg!(0); + const N: usize = gca!(0); } fn f(_x: [(); CT::<()>]) {} diff --git a/tests/ui/object-lifetime/object-lifetime-default-inherent-gac.rs b/tests/ui/object-lifetime/object-lifetime-default-inherent-gac.rs index 4b415a230cbd4..8e77c40b113d9 100644 --- a/tests/ui/object-lifetime/object-lifetime-default-inherent-gac.rs +++ b/tests/ui/object-lifetime/object-lifetime-default-inherent-gac.rs @@ -13,10 +13,12 @@ #![expect(incomplete_features)] mod own { + use std::gca; + // the lifetime comes from the own generics struct Parent; impl Parent { - const CT<'a, T: 'a + super::AbideBy<'a> + ?Sized>: usize = core::direct_const_arg!(0); + const CT<'a, T: 'a + super::AbideBy<'a> + ?Sized>: usize = gca!(0); } // FIXME: Ideally, we would deduce `dyn Trait + 'r` from the bound `'a` on ty param `T` of @@ -31,10 +33,12 @@ mod own { } mod parent { + use std::gca; + // the lifetime comes from the parent generics struct Parent<'a>(&'a ()); impl<'a> Parent<'a> { - const CT + ?Sized>: usize = core::direct_const_arg!(0); + const CT + ?Sized>: usize = gca!(0); } //FIXME: Ideally, we would deduce `dyn Trait + 'r` from the bound `'a` on ty param `T` of diff --git a/tests/ui/object-lifetime/object-lifetime-default-inherent-gac.stderr b/tests/ui/object-lifetime/object-lifetime-default-inherent-gac.stderr index 1461caea1bbed..97d5fcd582681 100644 --- a/tests/ui/object-lifetime/object-lifetime-default-inherent-gac.stderr +++ b/tests/ui/object-lifetime/object-lifetime-default-inherent-gac.stderr @@ -1,5 +1,5 @@ error[E0228]: cannot deduce the lifetime bound for this trait object type from context - --> $DIR/object-lifetime-default-inherent-gac.rs:27:31 + --> $DIR/object-lifetime-default-inherent-gac.rs:29:31 | LL | [(); Parent::CT::<'r, dyn super::Trait>]:, | ^^^^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | [(); Parent::CT::<'r, dyn super::Trait + /* 'a */>]:, | ++++++++++ error[E0228]: cannot deduce the lifetime bound for this trait object type from context - --> $DIR/object-lifetime-default-inherent-gac.rs:45:33 + --> $DIR/object-lifetime-default-inherent-gac.rs:49:33 | LL | [(); Parent::<'r>::CT::]:, | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/sanitizer/cfi/assoc-const-projection-issue-151878.rs b/tests/ui/sanitizer/cfi/assoc-const-projection-issue-151878.rs index 113ef41f532f0..6db3ebceb1cff 100644 --- a/tests/ui/sanitizer/cfi/assoc-const-projection-issue-151878.rs +++ b/tests/ui/sanitizer/cfi/assoc-const-projection-issue-151878.rs @@ -7,9 +7,11 @@ #![feature(min_generic_const_args, macroless_generic_const_args, associated_type_defaults)] #![expect(incomplete_features)] +use std::gca; + trait Trait { #[rustc_always_gca] - const N: usize = core::direct_const_arg!(0); + const N: usize = gca!(0); fn process(&self, _: [u8; Self::N]) {} } diff --git a/tests/ui/specialization/overlap-due-to-unsatisfied-const-bound.rs b/tests/ui/specialization/overlap-due-to-unsatisfied-const-bound.rs index a57e86127da7b..33b3aa4cd2430 100644 --- a/tests/ui/specialization/overlap-due-to-unsatisfied-const-bound.rs +++ b/tests/ui/specialization/overlap-due-to-unsatisfied-const-bound.rs @@ -2,12 +2,14 @@ #![feature(min_generic_const_args, specialization)] +use std::gca; + pub trait IsVoid { #[rustc_always_gca] const IS_VOID: bool; } impl IsVoid for T { - default const IS_VOID: bool = core::direct_const_arg!(false); + default const IS_VOID: bool = gca!(false); } pub trait NotVoid {} diff --git a/tests/ui/specialization/overlap-due-to-unsatisfied-const-bound.stderr b/tests/ui/specialization/overlap-due-to-unsatisfied-const-bound.stderr index 3ec3e83cc1d44..eda6b57ca8f7a 100644 --- a/tests/ui/specialization/overlap-due-to-unsatisfied-const-bound.stderr +++ b/tests/ui/specialization/overlap-due-to-unsatisfied-const-bound.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `Maybe<()>` for type `()` - --> $DIR/overlap-due-to-unsatisfied-const-bound.rs:18:1 + --> $DIR/overlap-due-to-unsatisfied-const-bound.rs:20:1 | LL | impl Maybe for T {} | ---------------------- first implementation here diff --git a/tests/ui/supertrait-shadowing/assoc-const.rs b/tests/ui/supertrait-shadowing/assoc-const.rs index 0fd798217d77a..9e49004e7c836 100644 --- a/tests/ui/supertrait-shadowing/assoc-const.rs +++ b/tests/ui/supertrait-shadowing/assoc-const.rs @@ -4,6 +4,8 @@ #![feature(min_generic_const_args)] #![allow(dead_code)] +use std::gca; + trait A { const CONST: i32; } @@ -16,7 +18,7 @@ trait B: A { const CONST: i32; } impl B for T { - const CONST: i32 = core::direct_const_arg!(2); + const CONST: i32 = gca!(2); } trait C: B {} diff --git a/tests/ui/supertrait-shadowing/common-ancestor-2.rs b/tests/ui/supertrait-shadowing/common-ancestor-2.rs index b1ff2e895eb48..4844b0a43aa89 100644 --- a/tests/ui/supertrait-shadowing/common-ancestor-2.rs +++ b/tests/ui/supertrait-shadowing/common-ancestor-2.rs @@ -6,6 +6,7 @@ #![warn(shadowing_supertrait_items)] #![allow(dead_code)] +use std::gca; use std::mem::size_of; trait A { @@ -45,7 +46,7 @@ trait C: A + B { } impl C for T { type Assoc = i32; - const CONST: i32 = core::direct_const_arg!(3); + const CONST: i32 = gca!(3); } fn main() { diff --git a/tests/ui/supertrait-shadowing/common-ancestor-2.stderr b/tests/ui/supertrait-shadowing/common-ancestor-2.stderr index 3e47a33991007..35f8a434fe861 100644 --- a/tests/ui/supertrait-shadowing/common-ancestor-2.stderr +++ b/tests/ui/supertrait-shadowing/common-ancestor-2.stderr @@ -1,11 +1,11 @@ warning: trait item `hello` from `C` shadows identically named item from supertrait - --> $DIR/common-ancestor-2.rs:36:5 + --> $DIR/common-ancestor-2.rs:37:5 | LL | fn hello(&self) -> &'static str { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: items from several supertraits are shadowed: `B` and `A` - --> $DIR/common-ancestor-2.rs:12:5 + --> $DIR/common-ancestor-2.rs:13:5 | LL | fn hello(&self) -> &'static str { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -19,13 +19,13 @@ LL | #![warn(shadowing_supertrait_items)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: trait item `Assoc` from `C` shadows identically named item from supertrait - --> $DIR/common-ancestor-2.rs:40:5 + --> $DIR/common-ancestor-2.rs:41:5 | LL | type Assoc; | ^^^^^^^^^^ | note: items from several supertraits are shadowed: `B` and `A` - --> $DIR/common-ancestor-2.rs:15:5 + --> $DIR/common-ancestor-2.rs:16:5 | LL | type Assoc; | ^^^^^^^^^^ @@ -34,13 +34,13 @@ LL | type Assoc; | ^^^^^^^^^^ warning: trait item `CONST` from `C` shadows identically named item from supertrait - --> $DIR/common-ancestor-2.rs:43:5 + --> $DIR/common-ancestor-2.rs:44:5 | LL | const CONST: i32; | ^^^^^^^^^^^^^^^^ | note: items from several supertraits are shadowed: `B` and `A` - --> $DIR/common-ancestor-2.rs:16:5 + --> $DIR/common-ancestor-2.rs:17:5 | LL | const CONST: i32; | ^^^^^^^^^^^^^^^^ @@ -49,18 +49,18 @@ LL | const CONST: i32; | ^^^^^^^^^^^^^^^^ warning: trait item `hello` from `C` shadows identically named item from supertrait - --> $DIR/common-ancestor-2.rs:52:19 + --> $DIR/common-ancestor-2.rs:53:19 | LL | assert_eq!(().hello(), "C"); | ^^^^^ | note: item from `C` shadows a supertrait item - --> $DIR/common-ancestor-2.rs:36:5 + --> $DIR/common-ancestor-2.rs:37:5 | LL | fn hello(&self) -> &'static str { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: items from several supertraits are shadowed: `A` and `B` - --> $DIR/common-ancestor-2.rs:12:5 + --> $DIR/common-ancestor-2.rs:13:5 | LL | fn hello(&self) -> &'static str { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/supertrait-shadowing/common-ancestor-3.rs b/tests/ui/supertrait-shadowing/common-ancestor-3.rs index ba8689d3a43f2..c815919c7e318 100644 --- a/tests/ui/supertrait-shadowing/common-ancestor-3.rs +++ b/tests/ui/supertrait-shadowing/common-ancestor-3.rs @@ -6,6 +6,7 @@ #![warn(shadowing_supertrait_items)] #![allow(dead_code)] +use std::gca; use std::mem::size_of; trait A { @@ -45,7 +46,7 @@ trait C: A + B { } impl C for T { type Assoc = i32; - const CONST: i32 = core::direct_const_arg!(3); + const CONST: i32 = gca!(3); } // `D` extends `C` which extends `B` and `A` @@ -63,7 +64,7 @@ trait D: C { } impl D for T { type Assoc = i64; - const CONST: i32 = core::direct_const_arg!(4); + const CONST: i32 = gca!(4); } fn main() { diff --git a/tests/ui/supertrait-shadowing/common-ancestor-3.stderr b/tests/ui/supertrait-shadowing/common-ancestor-3.stderr index 2fd7ff0003c74..b18355f1a7920 100644 --- a/tests/ui/supertrait-shadowing/common-ancestor-3.stderr +++ b/tests/ui/supertrait-shadowing/common-ancestor-3.stderr @@ -1,11 +1,11 @@ warning: trait item `hello` from `C` shadows identically named item from supertrait - --> $DIR/common-ancestor-3.rs:36:5 + --> $DIR/common-ancestor-3.rs:37:5 | LL | fn hello(&self) -> &'static str { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: items from several supertraits are shadowed: `B` and `A` - --> $DIR/common-ancestor-3.rs:12:5 + --> $DIR/common-ancestor-3.rs:13:5 | LL | fn hello(&self) -> &'static str { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -19,13 +19,13 @@ LL | #![warn(shadowing_supertrait_items)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: trait item `Assoc` from `C` shadows identically named item from supertrait - --> $DIR/common-ancestor-3.rs:40:5 + --> $DIR/common-ancestor-3.rs:41:5 | LL | type Assoc; | ^^^^^^^^^^ | note: items from several supertraits are shadowed: `B` and `A` - --> $DIR/common-ancestor-3.rs:15:5 + --> $DIR/common-ancestor-3.rs:16:5 | LL | type Assoc; | ^^^^^^^^^^ @@ -34,13 +34,13 @@ LL | type Assoc; | ^^^^^^^^^^ warning: trait item `CONST` from `C` shadows identically named item from supertrait - --> $DIR/common-ancestor-3.rs:43:5 + --> $DIR/common-ancestor-3.rs:44:5 | LL | const CONST: i32; | ^^^^^^^^^^^^^^^^ | note: items from several supertraits are shadowed: `B` and `A` - --> $DIR/common-ancestor-3.rs:16:5 + --> $DIR/common-ancestor-3.rs:17:5 | LL | const CONST: i32; | ^^^^^^^^^^^^^^^^ @@ -49,13 +49,13 @@ LL | const CONST: i32; | ^^^^^^^^^^^^^^^^ warning: trait item `hello` from `D` shadows identically named item from supertrait - --> $DIR/common-ancestor-3.rs:54:5 + --> $DIR/common-ancestor-3.rs:55:5 | LL | fn hello(&self) -> &'static str { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: items from several supertraits are shadowed: `C`, `B`, and `A` - --> $DIR/common-ancestor-3.rs:12:5 + --> $DIR/common-ancestor-3.rs:13:5 | LL | fn hello(&self) -> &'static str { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -67,13 +67,13 @@ LL | fn hello(&self) -> &'static str { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: trait item `Assoc` from `D` shadows identically named item from supertrait - --> $DIR/common-ancestor-3.rs:58:5 + --> $DIR/common-ancestor-3.rs:59:5 | LL | type Assoc; | ^^^^^^^^^^ | note: items from several supertraits are shadowed: `C`, `B`, and `A` - --> $DIR/common-ancestor-3.rs:15:5 + --> $DIR/common-ancestor-3.rs:16:5 | LL | type Assoc; | ^^^^^^^^^^ @@ -85,13 +85,13 @@ LL | type Assoc; | ^^^^^^^^^^ warning: trait item `CONST` from `D` shadows identically named item from supertrait - --> $DIR/common-ancestor-3.rs:61:5 + --> $DIR/common-ancestor-3.rs:62:5 | LL | const CONST: i32; | ^^^^^^^^^^^^^^^^ | note: items from several supertraits are shadowed: `C`, `B`, and `A` - --> $DIR/common-ancestor-3.rs:16:5 + --> $DIR/common-ancestor-3.rs:17:5 | LL | const CONST: i32; | ^^^^^^^^^^^^^^^^ @@ -103,18 +103,18 @@ LL | const CONST: i32; | ^^^^^^^^^^^^^^^^ warning: trait item `hello` from `D` shadows identically named item from supertrait - --> $DIR/common-ancestor-3.rs:70:19 + --> $DIR/common-ancestor-3.rs:71:19 | LL | assert_eq!(().hello(), "D"); | ^^^^^ | note: item from `D` shadows a supertrait item - --> $DIR/common-ancestor-3.rs:54:5 + --> $DIR/common-ancestor-3.rs:55:5 | LL | fn hello(&self) -> &'static str { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: items from several supertraits are shadowed: `A`, `B`, and `C` - --> $DIR/common-ancestor-3.rs:12:5 + --> $DIR/common-ancestor-3.rs:13:5 | LL | fn hello(&self) -> &'static str { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/supertrait-shadowing/common-ancestor.rs b/tests/ui/supertrait-shadowing/common-ancestor.rs index 7acc4bcad56ca..e89167c9215fd 100644 --- a/tests/ui/supertrait-shadowing/common-ancestor.rs +++ b/tests/ui/supertrait-shadowing/common-ancestor.rs @@ -6,6 +6,7 @@ #![warn(shadowing_supertrait_items)] #![allow(dead_code)] +use std::gca; use std::mem::size_of; trait A { @@ -33,7 +34,7 @@ trait B: A { } impl B for T { type Assoc = i16; - const CONST: i32 = core::direct_const_arg!(2); + const CONST: i32 = gca!(2); } fn main() { diff --git a/tests/ui/supertrait-shadowing/common-ancestor.stderr b/tests/ui/supertrait-shadowing/common-ancestor.stderr index a0b885b58eb5f..99ea66a166dbd 100644 --- a/tests/ui/supertrait-shadowing/common-ancestor.stderr +++ b/tests/ui/supertrait-shadowing/common-ancestor.stderr @@ -1,11 +1,11 @@ warning: trait item `hello` from `B` shadows identically named item from supertrait - --> $DIR/common-ancestor.rs:24:5 + --> $DIR/common-ancestor.rs:25:5 | LL | fn hello(&self) -> &'static str { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: item from `A` is shadowed by a subtrait item - --> $DIR/common-ancestor.rs:12:5 + --> $DIR/common-ancestor.rs:13:5 | LL | fn hello(&self) -> &'static str { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -16,42 +16,42 @@ LL | #![warn(shadowing_supertrait_items)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: trait item `Assoc` from `B` shadows identically named item from supertrait - --> $DIR/common-ancestor.rs:28:5 + --> $DIR/common-ancestor.rs:29:5 | LL | type Assoc; | ^^^^^^^^^^ | note: item from `A` is shadowed by a subtrait item - --> $DIR/common-ancestor.rs:15:5 + --> $DIR/common-ancestor.rs:16:5 | LL | type Assoc; | ^^^^^^^^^^ warning: trait item `CONST` from `B` shadows identically named item from supertrait - --> $DIR/common-ancestor.rs:31:5 + --> $DIR/common-ancestor.rs:32:5 | LL | const CONST: i32; | ^^^^^^^^^^^^^^^^ | note: item from `A` is shadowed by a subtrait item - --> $DIR/common-ancestor.rs:16:5 + --> $DIR/common-ancestor.rs:17:5 | LL | const CONST: i32; | ^^^^^^^^^^^^^^^^ warning: trait item `hello` from `B` shadows identically named item from supertrait - --> $DIR/common-ancestor.rs:40:19 + --> $DIR/common-ancestor.rs:41:19 | LL | assert_eq!(().hello(), "B"); | ^^^^^ | note: item from `B` shadows a supertrait item - --> $DIR/common-ancestor.rs:24:5 + --> $DIR/common-ancestor.rs:25:5 | LL | fn hello(&self) -> &'static str { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: item from `A` is shadowed by a subtrait item - --> $DIR/common-ancestor.rs:12:5 + --> $DIR/common-ancestor.rs:13:5 | LL | fn hello(&self) -> &'static str { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/supertrait-shadowing/no-common-ancestor-2.rs b/tests/ui/supertrait-shadowing/no-common-ancestor-2.rs index 64d34ccb8c9ae..3462ac4e37d4d 100644 --- a/tests/ui/supertrait-shadowing/no-common-ancestor-2.rs +++ b/tests/ui/supertrait-shadowing/no-common-ancestor-2.rs @@ -1,6 +1,7 @@ #![feature(supertrait_item_shadowing)] #![feature(min_generic_const_args)] +use std::gca; use std::mem::size_of; trait A { @@ -37,7 +38,7 @@ trait C: A + B { } impl C for T { type Assoc = i32; - const CONST: i32 = core::direct_const_arg!(3); + const CONST: i32 = gca!(3); } // Since `D` is not a subtrait of `C`, @@ -53,7 +54,7 @@ trait D: B { } impl D for T { type Assoc = i64; - const CONST: i32 = core::direct_const_arg!(4); + const CONST: i32 = gca!(4); } fn main() { diff --git a/tests/ui/supertrait-shadowing/no-common-ancestor-2.stderr b/tests/ui/supertrait-shadowing/no-common-ancestor-2.stderr index 85c0937c03d9c..220a26d7757a0 100644 --- a/tests/ui/supertrait-shadowing/no-common-ancestor-2.stderr +++ b/tests/ui/supertrait-shadowing/no-common-ancestor-2.stderr @@ -1,26 +1,26 @@ error[E0034]: multiple applicable items in scope - --> $DIR/no-common-ancestor-2.rs:60:8 + --> $DIR/no-common-ancestor-2.rs:61:8 | LL | ().hello(); | ^^^^^ multiple `hello` found | note: candidate #1 is defined in an impl of the trait `A` for the type `T` - --> $DIR/no-common-ancestor-2.rs:7:5 + --> $DIR/no-common-ancestor-2.rs:8:5 | LL | fn hello(&self) -> &'static str { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: candidate #2 is defined in an impl of the trait `B` for the type `T` - --> $DIR/no-common-ancestor-2.rs:19:5 + --> $DIR/no-common-ancestor-2.rs:20:5 | LL | fn hello(&self) -> &'static str { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: candidate #3 is defined in an impl of the trait `C` for the type `T` - --> $DIR/no-common-ancestor-2.rs:31:5 + --> $DIR/no-common-ancestor-2.rs:32:5 | LL | fn hello(&self) -> &'static str { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: candidate #4 is defined in an impl of the trait `D` for the type `T` - --> $DIR/no-common-ancestor-2.rs:47:5 + --> $DIR/no-common-ancestor-2.rs:48:5 | LL | fn hello(&self) -> &'static str { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -46,7 +46,7 @@ LL + D::hello(&()); | error[E0221]: ambiguous associated type `Assoc` in bounds of `T` - --> $DIR/no-common-ancestor-2.rs:66:23 + --> $DIR/no-common-ancestor-2.rs:67:23 | LL | type Assoc; | ---------- ambiguous `Assoc` from `A` @@ -85,28 +85,28 @@ LL + let _ = size_of::<::Assoc>(); | error[E0034]: multiple applicable items in scope - --> $DIR/no-common-ancestor-2.rs:68:16 + --> $DIR/no-common-ancestor-2.rs:69:16 | LL | let _ = T::CONST; | ^^^^^ multiple `CONST` found | note: candidate #1 is defined in the trait `A` - --> $DIR/no-common-ancestor-2.rs:11:5 + --> $DIR/no-common-ancestor-2.rs:12:5 | LL | const CONST: i32; | ^^^^^^^^^^^^^^^^ note: candidate #2 is defined in the trait `B` - --> $DIR/no-common-ancestor-2.rs:23:5 + --> $DIR/no-common-ancestor-2.rs:24:5 | LL | const CONST: i32; | ^^^^^^^^^^^^^^^^ note: candidate #3 is defined in the trait `C` - --> $DIR/no-common-ancestor-2.rs:36:5 + --> $DIR/no-common-ancestor-2.rs:37:5 | LL | const CONST: i32; | ^^^^^^^^^^^^^^^^ note: candidate #4 is defined in the trait `D` - --> $DIR/no-common-ancestor-2.rs:52:5 + --> $DIR/no-common-ancestor-2.rs:53:5 | LL | const CONST: i32; | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/supertrait-shadowing/out-of-scope.rs b/tests/ui/supertrait-shadowing/out-of-scope.rs index 11c7477cc3f8a..fc967e525dc40 100644 --- a/tests/ui/supertrait-shadowing/out-of-scope.rs +++ b/tests/ui/supertrait-shadowing/out-of-scope.rs @@ -6,6 +6,7 @@ use std::mem::size_of; mod out_of_scope { + use std::gca; pub trait Subtrait: super::Supertrait { fn hello(&self) -> &'static str { "subtrait" @@ -16,7 +17,7 @@ mod out_of_scope { } impl Subtrait for T { type Assoc = i16; - const CONST: i32 = core::direct_const_arg!(2); + const CONST: i32 = gca!(2); } } diff --git a/tests/ui/supertrait-shadowing/type-dependent.rs b/tests/ui/supertrait-shadowing/type-dependent.rs index 0287bb7ad43a8..b2c31b352deee 100644 --- a/tests/ui/supertrait-shadowing/type-dependent.rs +++ b/tests/ui/supertrait-shadowing/type-dependent.rs @@ -6,6 +6,7 @@ #![feature(supertrait_item_shadowing)] #![allow(dead_code)] +use std::gca; use std::mem::size_of; trait A { @@ -30,7 +31,7 @@ trait B: A { } impl B for T { type Assoc = i16; - const CONST: i32 = core::direct_const_arg!(2); + const CONST: i32 = gca!(2); } fn foo() -> &'static str { diff --git a/tests/ui/traits/next-solver/normalize-const-item-type.rs b/tests/ui/traits/next-solver/normalize-const-item-type.rs index 873b0bb690e4c..3b70e8718488b 100644 --- a/tests/ui/traits/next-solver/normalize-const-item-type.rs +++ b/tests/ui/traits/next-solver/normalize-const-item-type.rs @@ -3,6 +3,7 @@ #![feature(min_generic_const_args)] #![feature(generic_const_args)] +use std::gca; use std::marker::PhantomData; trait Project1<'a> { @@ -21,14 +22,15 @@ impl> Project2 for PhantomData { type Assoc2 = usize; } -const N: as Project2>::Assoc2 = 2_usize; +const N: as Project2>::Assoc2 = 2_usize; -fn func(_: [(); core::direct_const_arg!(N::)]) +fn func(_: [(); gca!(N::)]) //~^ ERROR: type mismatch resolving `N == _` [E0271] //~| ERROR: the type `[(); N::]` is not well-formed //~| ERROR: type mismatch resolving `N == _` [E0271] where for<'a> u32: Project1<'a>, -{} +{ +} fn main() {} diff --git a/tests/ui/traits/next-solver/normalize-const-item-type.stderr b/tests/ui/traits/next-solver/normalize-const-item-type.stderr index 67f4f596f40bf..926ba7e43b2f5 100644 --- a/tests/ui/traits/next-solver/normalize-const-item-type.stderr +++ b/tests/ui/traits/next-solver/normalize-const-item-type.stderr @@ -1,20 +1,20 @@ error[E0271]: type mismatch resolving `N == _` - --> $DIR/normalize-const-item-type.rs:26:12 + --> $DIR/normalize-const-item-type.rs:27:12 | -LL | fn func(_: [(); core::direct_const_arg!(N::)]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ +LL | fn func(_: [(); gca!(N::)]) + | ^^^^^^^^^^^^^^^^^^^^ types differ error: the type `[(); N::]` is not well-formed - --> $DIR/normalize-const-item-type.rs:26:12 + --> $DIR/normalize-const-item-type.rs:27:12 | -LL | fn func(_: [(); core::direct_const_arg!(N::)]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn func(_: [(); gca!(N::)]) + | ^^^^^^^^^^^^^^^^^^^^ error[E0271]: type mismatch resolving `N == _` - --> $DIR/normalize-const-item-type.rs:26:12 + --> $DIR/normalize-const-item-type.rs:27:12 | -LL | fn func(_: [(); core::direct_const_arg!(N::)]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ +LL | fn func(_: [(); gca!(N::)]) + | ^^^^^^^^^^^^^^^^^^^^ types differ | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`