From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- .../issues/auxiliary/const_generic_issues_lib.rs | 15 +++ .../const-generics/issues/auxiliary/impl-const.rs | 9 ++ .../issues/issue-56445-1.full.stderr | 11 ++ .../const-generics/issues/issue-56445-1.min.stderr | 20 ++++ src/test/ui/const-generics/issues/issue-56445-1.rs | 13 +++ src/test/ui/const-generics/issues/issue-56445-2.rs | 11 ++ .../ui/const-generics/issues/issue-56445-2.stderr | 14 +++ src/test/ui/const-generics/issues/issue-56445-3.rs | 12 +++ .../ui/const-generics/issues/issue-56445-3.stderr | 8 ++ .../issues/issue-60818-struct-constructors.rs | 7 ++ src/test/ui/const-generics/issues/issue-61336-1.rs | 9 ++ src/test/ui/const-generics/issues/issue-61336-2.rs | 13 +++ .../ui/const-generics/issues/issue-61336-2.stderr | 15 +++ src/test/ui/const-generics/issues/issue-61336.rs | 13 +++ .../ui/const-generics/issues/issue-61336.stderr | 15 +++ src/test/ui/const-generics/issues/issue-61422.rs | 24 +++++ src/test/ui/const-generics/issues/issue-61432.rs | 9 ++ .../issue-62187-encountered-polymorphic-const.rs | 12 +++ .../const-generics/issues/issue-62878.full.stderr | 9 ++ .../const-generics/issues/issue-62878.min.stderr | 18 ++++ src/test/ui/const-generics/issues/issue-62878.rs | 11 ++ .../issues/issue-63322-forbid-dyn.full.stderr | 9 ++ .../issues/issue-63322-forbid-dyn.min.stderr | 11 ++ .../issues/issue-63322-forbid-dyn.rs | 17 +++ src/test/ui/const-generics/issues/issue-64519.rs | 17 +++ .../issue-66596-impl-trait-for-str-const-arg.rs | 16 +++ src/test/ui/const-generics/issues/issue-66906.rs | 9 ++ src/test/ui/const-generics/issues/issue-67185-1.rs | 29 ++++++ src/test/ui/const-generics/issues/issue-67185-2.rs | 31 ++++++ .../ui/const-generics/issues/issue-67185-2.stderr | 99 ++++++++++++++++++ .../const-generics/issues/issue-67375.full.stderr | 12 +++ .../const-generics/issues/issue-67375.min.stderr | 21 ++++ src/test/ui/const-generics/issues/issue-67375.rs | 12 +++ .../const-generics/issues/issue-67739.full.stderr | 10 ++ .../const-generics/issues/issue-67739.min.stderr | 10 ++ src/test/ui/const-generics/issues/issue-67739.rs | 18 ++++ .../issues/issue-67945-1.full.stderr | 17 +++ .../const-generics/issues/issue-67945-1.min.stderr | 30 ++++++ src/test/ui/const-generics/issues/issue-67945-1.rs | 19 ++++ .../issues/issue-67945-2.full.stderr | 17 +++ .../const-generics/issues/issue-67945-2.min.stderr | 8 ++ src/test/ui/const-generics/issues/issue-67945-2.rs | 16 +++ .../issues/issue-67945-3.full.stderr | 16 +++ .../const-generics/issues/issue-67945-3.min.stderr | 21 ++++ src/test/ui/const-generics/issues/issue-67945-3.rs | 17 +++ .../issues/issue-67945-4.full.stderr | 16 +++ .../const-generics/issues/issue-67945-4.min.stderr | 21 ++++ src/test/ui/const-generics/issues/issue-67945-4.rs | 16 +++ .../issues/issue-68104-print-stack-overflow.rs | 13 +++ .../const-generics/issues/issue-68366.full.stderr | 21 ++++ .../const-generics/issues/issue-68366.min.stderr | 30 ++++++ src/test/ui/const-generics/issues/issue-68366.rs | 20 ++++ src/test/ui/const-generics/issues/issue-68596.rs | 15 +++ .../issues/issue-68615-adt.min.stderr | 11 ++ .../ui/const-generics/issues/issue-68615-adt.rs | 13 +++ .../issues/issue-68615-array.min.stderr | 11 ++ .../ui/const-generics/issues/issue-68615-array.rs | 13 +++ .../const-generics/issues/issue-69654-run-pass.rs | 15 +++ src/test/ui/const-generics/issues/issue-70125-1.rs | 17 +++ src/test/ui/const-generics/issues/issue-70125-2.rs | 12 +++ src/test/ui/const-generics/issues/issue-70167.rs | 6 ++ .../issues/issue-70180-1-stalled_on.rs | 33 ++++++ .../issues/issue-70180-2-stalled_on.rs | 33 ++++++ src/test/ui/const-generics/issues/issue-70225.rs | 19 ++++ .../const-generics/issues/issue-70273-assoc-fn.rs | 14 +++ .../const-generics/issues/issue-71169.full.stderr | 9 ++ .../const-generics/issues/issue-71169.min.stderr | 18 ++++ src/test/ui/const-generics/issues/issue-71169.rs | 11 ++ src/test/ui/const-generics/issues/issue-71202.rs | 31 ++++++ .../ui/const-generics/issues/issue-71202.stderr | 33 ++++++ .../const-generics/issues/issue-71381.full.stderr | 28 +++++ .../const-generics/issues/issue-71381.min.stderr | 27 +++++ src/test/ui/const-generics/issues/issue-71381.rs | 36 +++++++ .../const-generics/issues/issue-71382.full.stderr | 9 ++ .../const-generics/issues/issue-71382.min.stderr | 8 ++ src/test/ui/const-generics/issues/issue-71382.rs | 25 +++++ src/test/ui/const-generics/issues/issue-71547.rs | 18 ++++ .../const-generics/issues/issue-71611.full.stderr | 16 +++ .../const-generics/issues/issue-71611.min.stderr | 15 +++ src/test/ui/const-generics/issues/issue-71611.rs | 11 ++ src/test/ui/const-generics/issues/issue-71986.rs | 6 ++ .../const-generics/issues/issue-72352.full.stderr | 9 ++ .../const-generics/issues/issue-72352.min.stderr | 8 ++ src/test/ui/const-generics/issues/issue-72352.rs | 22 ++++ src/test/ui/const-generics/issues/issue-72845.rs | 49 +++++++++ .../ui/const-generics/issues/issue-72845.stderr | 12 +++ src/test/ui/const-generics/issues/issue-73120.rs | 10 ++ src/test/ui/const-generics/issues/issue-73260.rs | 19 ++++ .../ui/const-generics/issues/issue-73260.stderr | 21 ++++ .../const-generics/issues/issue-73491.min.stderr | 11 ++ src/test/ui/const-generics/issues/issue-73491.rs | 11 ++ ...7-static-reference-array-const-param.min.stderr | 11 ++ ...sue-73727-static-reference-array-const-param.rs | 14 +++ .../const-generics/issues/issue-74101.min.stderr | 20 ++++ src/test/ui/const-generics/issues/issue-74101.rs | 12 +++ .../const-generics/issues/issue-74255.min.stderr | 11 ++ src/test/ui/const-generics/issues/issue-74255.rs | 20 ++++ src/test/ui/const-generics/issues/issue-74906.rs | 22 ++++ .../const-generics/issues/issue-74950.min.stderr | 47 +++++++++ src/test/ui/const-generics/issues/issue-74950.rs | 24 +++++ .../const-generics/issues/issue-75047.min.stderr | 11 ++ src/test/ui/const-generics/issues/issue-75047.rs | 17 +++ src/test/ui/const-generics/issues/issue-75299.rs | 8 ++ .../issues/issue-76701-ty-param-in-const.rs | 11 ++ .../issues/issue-76701-ty-param-in-const.stderr | 20 ++++ src/test/ui/const-generics/issues/issue-77357.rs | 11 ++ .../ui/const-generics/issues/issue-77357.stderr | 11 ++ src/test/ui/const-generics/issues/issue-79674.rs | 28 +++++ .../ui/const-generics/issues/issue-79674.stderr | 12 +++ src/test/ui/const-generics/issues/issue-80062.rs | 10 ++ .../ui/const-generics/issues/issue-80062.stderr | 11 ++ src/test/ui/const-generics/issues/issue-80375.rs | 4 + .../ui/const-generics/issues/issue-80375.stderr | 11 ++ src/test/ui/const-generics/issues/issue-82956.rs | 33 ++++++ .../ui/const-generics/issues/issue-82956.stderr | 21 ++++ src/test/ui/const-generics/issues/issue-83249.rs | 23 ++++ .../ui/const-generics/issues/issue-83249.stderr | 14 +++ src/test/ui/const-generics/issues/issue-83288.rs | 69 ++++++++++++ src/test/ui/const-generics/issues/issue-83466.rs | 17 +++ .../ui/const-generics/issues/issue-83466.stderr | 22 ++++ src/test/ui/const-generics/issues/issue-83765.rs | 116 +++++++++++++++++++++ .../ui/const-generics/issues/issue-83765.stderr | 21 ++++ src/test/ui/const-generics/issues/issue-83993.rs | 14 +++ src/test/ui/const-generics/issues/issue-84659.rs | 12 +++ .../ui/const-generics/issues/issue-84659.stderr | 10 ++ src/test/ui/const-generics/issues/issue-86033.rs | 20 ++++ src/test/ui/const-generics/issues/issue-86530.rs | 20 ++++ .../ui/const-generics/issues/issue-86530.stderr | 20 ++++ src/test/ui/const-generics/issues/issue-86535-2.rs | 19 ++++ src/test/ui/const-generics/issues/issue-86535.rs | 20 ++++ src/test/ui/const-generics/issues/issue-86820.rs | 24 +++++ .../ui/const-generics/issues/issue-86820.stderr | 16 +++ src/test/ui/const-generics/issues/issue-87076.rs | 20 ++++ src/test/ui/const-generics/issues/issue-87470.rs | 24 +++++ src/test/ui/const-generics/issues/issue-87493.rs | 14 +++ .../ui/const-generics/issues/issue-87493.stderr | 28 +++++ src/test/ui/const-generics/issues/issue-87964.rs | 29 ++++++ src/test/ui/const-generics/issues/issue-88119.rs | 35 +++++++ src/test/ui/const-generics/issues/issue-88468.rs | 13 +++ src/test/ui/const-generics/issues/issue-88997.rs | 14 +++ .../ui/const-generics/issues/issue-88997.stderr | 15 +++ src/test/ui/const-generics/issues/issue-89146.rs | 26 +++++ src/test/ui/const-generics/issues/issue-89304.rs | 20 ++++ src/test/ui/const-generics/issues/issue-89320.rs | 19 ++++ src/test/ui/const-generics/issues/issue-89334.rs | 16 +++ src/test/ui/const-generics/issues/issue-90318.rs | 30 ++++++ .../ui/const-generics/issues/issue-90318.stderr | 29 ++++++ src/test/ui/const-generics/issues/issue-90364.rs | 9 ++ .../ui/const-generics/issues/issue-90364.stderr | 9 ++ src/test/ui/const-generics/issues/issue-90455.rs | 12 +++ .../ui/const-generics/issues/issue-90455.stderr | 10 ++ src/test/ui/const-generics/issues/issue-92186.rs | 12 +++ src/test/ui/const-generics/issues/issue-96654.rs | 15 +++ src/test/ui/const-generics/issues/issue-97278.rs | 14 +++ .../ui/const-generics/issues/issue-97278.stderr | 9 ++ src/test/ui/const-generics/issues/issue-97634.rs | 10 ++ src/test/ui/const-generics/issues/issue-98629.rs | 15 +++ .../ui/const-generics/issues/issue-98629.stderr | 12 +++ src/test/ui/const-generics/issues/issue-99641.rs | 18 ++++ .../ui/const-generics/issues/issue-99641.stderr | 15 +++ 160 files changed, 2921 insertions(+) create mode 100644 src/test/ui/const-generics/issues/auxiliary/const_generic_issues_lib.rs create mode 100644 src/test/ui/const-generics/issues/auxiliary/impl-const.rs create mode 100644 src/test/ui/const-generics/issues/issue-56445-1.full.stderr create mode 100644 src/test/ui/const-generics/issues/issue-56445-1.min.stderr create mode 100644 src/test/ui/const-generics/issues/issue-56445-1.rs create mode 100644 src/test/ui/const-generics/issues/issue-56445-2.rs create mode 100644 src/test/ui/const-generics/issues/issue-56445-2.stderr create mode 100644 src/test/ui/const-generics/issues/issue-56445-3.rs create mode 100644 src/test/ui/const-generics/issues/issue-56445-3.stderr create mode 100644 src/test/ui/const-generics/issues/issue-60818-struct-constructors.rs create mode 100644 src/test/ui/const-generics/issues/issue-61336-1.rs create mode 100644 src/test/ui/const-generics/issues/issue-61336-2.rs create mode 100644 src/test/ui/const-generics/issues/issue-61336-2.stderr create mode 100644 src/test/ui/const-generics/issues/issue-61336.rs create mode 100644 src/test/ui/const-generics/issues/issue-61336.stderr create mode 100644 src/test/ui/const-generics/issues/issue-61422.rs create mode 100644 src/test/ui/const-generics/issues/issue-61432.rs create mode 100644 src/test/ui/const-generics/issues/issue-62187-encountered-polymorphic-const.rs create mode 100644 src/test/ui/const-generics/issues/issue-62878.full.stderr create mode 100644 src/test/ui/const-generics/issues/issue-62878.min.stderr create mode 100644 src/test/ui/const-generics/issues/issue-62878.rs create mode 100644 src/test/ui/const-generics/issues/issue-63322-forbid-dyn.full.stderr create mode 100644 src/test/ui/const-generics/issues/issue-63322-forbid-dyn.min.stderr create mode 100644 src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs create mode 100644 src/test/ui/const-generics/issues/issue-64519.rs create mode 100644 src/test/ui/const-generics/issues/issue-66596-impl-trait-for-str-const-arg.rs create mode 100644 src/test/ui/const-generics/issues/issue-66906.rs create mode 100644 src/test/ui/const-generics/issues/issue-67185-1.rs create mode 100644 src/test/ui/const-generics/issues/issue-67185-2.rs create mode 100644 src/test/ui/const-generics/issues/issue-67185-2.stderr create mode 100644 src/test/ui/const-generics/issues/issue-67375.full.stderr create mode 100644 src/test/ui/const-generics/issues/issue-67375.min.stderr create mode 100644 src/test/ui/const-generics/issues/issue-67375.rs create mode 100644 src/test/ui/const-generics/issues/issue-67739.full.stderr create mode 100644 src/test/ui/const-generics/issues/issue-67739.min.stderr create mode 100644 src/test/ui/const-generics/issues/issue-67739.rs create mode 100644 src/test/ui/const-generics/issues/issue-67945-1.full.stderr create mode 100644 src/test/ui/const-generics/issues/issue-67945-1.min.stderr create mode 100644 src/test/ui/const-generics/issues/issue-67945-1.rs create mode 100644 src/test/ui/const-generics/issues/issue-67945-2.full.stderr create mode 100644 src/test/ui/const-generics/issues/issue-67945-2.min.stderr create mode 100644 src/test/ui/const-generics/issues/issue-67945-2.rs create mode 100644 src/test/ui/const-generics/issues/issue-67945-3.full.stderr create mode 100644 src/test/ui/const-generics/issues/issue-67945-3.min.stderr create mode 100644 src/test/ui/const-generics/issues/issue-67945-3.rs create mode 100644 src/test/ui/const-generics/issues/issue-67945-4.full.stderr create mode 100644 src/test/ui/const-generics/issues/issue-67945-4.min.stderr create mode 100644 src/test/ui/const-generics/issues/issue-67945-4.rs create mode 100644 src/test/ui/const-generics/issues/issue-68104-print-stack-overflow.rs create mode 100644 src/test/ui/const-generics/issues/issue-68366.full.stderr create mode 100644 src/test/ui/const-generics/issues/issue-68366.min.stderr create mode 100644 src/test/ui/const-generics/issues/issue-68366.rs create mode 100644 src/test/ui/const-generics/issues/issue-68596.rs create mode 100644 src/test/ui/const-generics/issues/issue-68615-adt.min.stderr create mode 100644 src/test/ui/const-generics/issues/issue-68615-adt.rs create mode 100644 src/test/ui/const-generics/issues/issue-68615-array.min.stderr create mode 100644 src/test/ui/const-generics/issues/issue-68615-array.rs create mode 100644 src/test/ui/const-generics/issues/issue-69654-run-pass.rs create mode 100644 src/test/ui/const-generics/issues/issue-70125-1.rs create mode 100644 src/test/ui/const-generics/issues/issue-70125-2.rs create mode 100644 src/test/ui/const-generics/issues/issue-70167.rs create mode 100644 src/test/ui/const-generics/issues/issue-70180-1-stalled_on.rs create mode 100644 src/test/ui/const-generics/issues/issue-70180-2-stalled_on.rs create mode 100644 src/test/ui/const-generics/issues/issue-70225.rs create mode 100644 src/test/ui/const-generics/issues/issue-70273-assoc-fn.rs create mode 100644 src/test/ui/const-generics/issues/issue-71169.full.stderr create mode 100644 src/test/ui/const-generics/issues/issue-71169.min.stderr create mode 100644 src/test/ui/const-generics/issues/issue-71169.rs create mode 100644 src/test/ui/const-generics/issues/issue-71202.rs create mode 100644 src/test/ui/const-generics/issues/issue-71202.stderr create mode 100644 src/test/ui/const-generics/issues/issue-71381.full.stderr create mode 100644 src/test/ui/const-generics/issues/issue-71381.min.stderr create mode 100644 src/test/ui/const-generics/issues/issue-71381.rs create mode 100644 src/test/ui/const-generics/issues/issue-71382.full.stderr create mode 100644 src/test/ui/const-generics/issues/issue-71382.min.stderr create mode 100644 src/test/ui/const-generics/issues/issue-71382.rs create mode 100644 src/test/ui/const-generics/issues/issue-71547.rs create mode 100644 src/test/ui/const-generics/issues/issue-71611.full.stderr create mode 100644 src/test/ui/const-generics/issues/issue-71611.min.stderr create mode 100644 src/test/ui/const-generics/issues/issue-71611.rs create mode 100644 src/test/ui/const-generics/issues/issue-71986.rs create mode 100644 src/test/ui/const-generics/issues/issue-72352.full.stderr create mode 100644 src/test/ui/const-generics/issues/issue-72352.min.stderr create mode 100644 src/test/ui/const-generics/issues/issue-72352.rs create mode 100644 src/test/ui/const-generics/issues/issue-72845.rs create mode 100644 src/test/ui/const-generics/issues/issue-72845.stderr create mode 100644 src/test/ui/const-generics/issues/issue-73120.rs create mode 100644 src/test/ui/const-generics/issues/issue-73260.rs create mode 100644 src/test/ui/const-generics/issues/issue-73260.stderr create mode 100644 src/test/ui/const-generics/issues/issue-73491.min.stderr create mode 100644 src/test/ui/const-generics/issues/issue-73491.rs create mode 100644 src/test/ui/const-generics/issues/issue-73727-static-reference-array-const-param.min.stderr create mode 100644 src/test/ui/const-generics/issues/issue-73727-static-reference-array-const-param.rs create mode 100644 src/test/ui/const-generics/issues/issue-74101.min.stderr create mode 100644 src/test/ui/const-generics/issues/issue-74101.rs create mode 100644 src/test/ui/const-generics/issues/issue-74255.min.stderr create mode 100644 src/test/ui/const-generics/issues/issue-74255.rs create mode 100644 src/test/ui/const-generics/issues/issue-74906.rs create mode 100644 src/test/ui/const-generics/issues/issue-74950.min.stderr create mode 100644 src/test/ui/const-generics/issues/issue-74950.rs create mode 100644 src/test/ui/const-generics/issues/issue-75047.min.stderr create mode 100644 src/test/ui/const-generics/issues/issue-75047.rs create mode 100644 src/test/ui/const-generics/issues/issue-75299.rs create mode 100644 src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.rs create mode 100644 src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.stderr create mode 100644 src/test/ui/const-generics/issues/issue-77357.rs create mode 100644 src/test/ui/const-generics/issues/issue-77357.stderr create mode 100644 src/test/ui/const-generics/issues/issue-79674.rs create mode 100644 src/test/ui/const-generics/issues/issue-79674.stderr create mode 100644 src/test/ui/const-generics/issues/issue-80062.rs create mode 100644 src/test/ui/const-generics/issues/issue-80062.stderr create mode 100644 src/test/ui/const-generics/issues/issue-80375.rs create mode 100644 src/test/ui/const-generics/issues/issue-80375.stderr create mode 100644 src/test/ui/const-generics/issues/issue-82956.rs create mode 100644 src/test/ui/const-generics/issues/issue-82956.stderr create mode 100644 src/test/ui/const-generics/issues/issue-83249.rs create mode 100644 src/test/ui/const-generics/issues/issue-83249.stderr create mode 100644 src/test/ui/const-generics/issues/issue-83288.rs create mode 100644 src/test/ui/const-generics/issues/issue-83466.rs create mode 100644 src/test/ui/const-generics/issues/issue-83466.stderr create mode 100644 src/test/ui/const-generics/issues/issue-83765.rs create mode 100644 src/test/ui/const-generics/issues/issue-83765.stderr create mode 100644 src/test/ui/const-generics/issues/issue-83993.rs create mode 100644 src/test/ui/const-generics/issues/issue-84659.rs create mode 100644 src/test/ui/const-generics/issues/issue-84659.stderr create mode 100644 src/test/ui/const-generics/issues/issue-86033.rs create mode 100644 src/test/ui/const-generics/issues/issue-86530.rs create mode 100644 src/test/ui/const-generics/issues/issue-86530.stderr create mode 100644 src/test/ui/const-generics/issues/issue-86535-2.rs create mode 100644 src/test/ui/const-generics/issues/issue-86535.rs create mode 100644 src/test/ui/const-generics/issues/issue-86820.rs create mode 100644 src/test/ui/const-generics/issues/issue-86820.stderr create mode 100644 src/test/ui/const-generics/issues/issue-87076.rs create mode 100644 src/test/ui/const-generics/issues/issue-87470.rs create mode 100644 src/test/ui/const-generics/issues/issue-87493.rs create mode 100644 src/test/ui/const-generics/issues/issue-87493.stderr create mode 100644 src/test/ui/const-generics/issues/issue-87964.rs create mode 100644 src/test/ui/const-generics/issues/issue-88119.rs create mode 100644 src/test/ui/const-generics/issues/issue-88468.rs create mode 100644 src/test/ui/const-generics/issues/issue-88997.rs create mode 100644 src/test/ui/const-generics/issues/issue-88997.stderr create mode 100644 src/test/ui/const-generics/issues/issue-89146.rs create mode 100644 src/test/ui/const-generics/issues/issue-89304.rs create mode 100644 src/test/ui/const-generics/issues/issue-89320.rs create mode 100644 src/test/ui/const-generics/issues/issue-89334.rs create mode 100644 src/test/ui/const-generics/issues/issue-90318.rs create mode 100644 src/test/ui/const-generics/issues/issue-90318.stderr create mode 100644 src/test/ui/const-generics/issues/issue-90364.rs create mode 100644 src/test/ui/const-generics/issues/issue-90364.stderr create mode 100644 src/test/ui/const-generics/issues/issue-90455.rs create mode 100644 src/test/ui/const-generics/issues/issue-90455.stderr create mode 100644 src/test/ui/const-generics/issues/issue-92186.rs create mode 100644 src/test/ui/const-generics/issues/issue-96654.rs create mode 100644 src/test/ui/const-generics/issues/issue-97278.rs create mode 100644 src/test/ui/const-generics/issues/issue-97278.stderr create mode 100644 src/test/ui/const-generics/issues/issue-97634.rs create mode 100644 src/test/ui/const-generics/issues/issue-98629.rs create mode 100644 src/test/ui/const-generics/issues/issue-98629.stderr create mode 100644 src/test/ui/const-generics/issues/issue-99641.rs create mode 100644 src/test/ui/const-generics/issues/issue-99641.stderr (limited to 'src/test/ui/const-generics/issues') diff --git a/src/test/ui/const-generics/issues/auxiliary/const_generic_issues_lib.rs b/src/test/ui/const-generics/issues/auxiliary/const_generic_issues_lib.rs new file mode 100644 index 000000000..6a10ee267 --- /dev/null +++ b/src/test/ui/const-generics/issues/auxiliary/const_generic_issues_lib.rs @@ -0,0 +1,15 @@ +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +// All of these three items must be in `lib2` to reproduce the error + +pub trait TypeFn { + type Output; +} + +pub struct GenericType; + +// Removing the braces around `42` resolves the crash +impl TypeFn for GenericType<{ 40 + 2 }> { + type Output = (); +} diff --git a/src/test/ui/const-generics/issues/auxiliary/impl-const.rs b/src/test/ui/const-generics/issues/auxiliary/impl-const.rs new file mode 100644 index 000000000..de3a40860 --- /dev/null +++ b/src/test/ui/const-generics/issues/auxiliary/impl-const.rs @@ -0,0 +1,9 @@ +#![feature(generic_const_exprs)] + +pub struct Num; + +// Braces around const expression causes crash +impl Num<{5}> { + pub fn five(&self) { + } +} diff --git a/src/test/ui/const-generics/issues/issue-56445-1.full.stderr b/src/test/ui/const-generics/issues/issue-56445-1.full.stderr new file mode 100644 index 000000000..179643a75 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-56445-1.full.stderr @@ -0,0 +1,11 @@ +error[E0771]: use of non-static lifetime `'a` in const generic + --> $DIR/issue-56445-1.rs:9:26 + | +LL | struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>); + | ^^ + | + = note: for more information, see issue #74052 + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0771`. diff --git a/src/test/ui/const-generics/issues/issue-56445-1.min.stderr b/src/test/ui/const-generics/issues/issue-56445-1.min.stderr new file mode 100644 index 000000000..43a5df117 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-56445-1.min.stderr @@ -0,0 +1,20 @@ +error[E0771]: use of non-static lifetime `'a` in const generic + --> $DIR/issue-56445-1.rs:9:26 + | +LL | struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>); + | ^^ + | + = note: for more information, see issue #74052 + +error: `&'static str` is forbidden as the type of a const generic parameter + --> $DIR/issue-56445-1.rs:9:25 + | +LL | struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>); + | ^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = help: more complex types are supported with `#![feature(adt_const_params)]` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0771`. diff --git a/src/test/ui/const-generics/issues/issue-56445-1.rs b/src/test/ui/const-generics/issues/issue-56445-1.rs new file mode 100644 index 000000000..13eb2ea9f --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-56445-1.rs @@ -0,0 +1,13 @@ +// Regression test for https://github.com/rust-lang/rust/issues/56445#issuecomment-518402995. +// revisions: full min +#![cfg_attr(full, feature(adt_const_params))] +#![cfg_attr(full, allow(incomplete_features))] +#![crate_type = "lib"] + +use std::marker::PhantomData; + +struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>); +//~^ ERROR: use of non-static lifetime `'a` in const generic +//[min]~| ERROR: `&'static str` is forbidden as the type of a const generic parameter + +impl Bug<'_, ""> {} diff --git a/src/test/ui/const-generics/issues/issue-56445-2.rs b/src/test/ui/const-generics/issues/issue-56445-2.rs new file mode 100644 index 000000000..e078c8487 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-56445-2.rs @@ -0,0 +1,11 @@ +// Regression test for https://github.com/rust-lang/rust/issues/56445#issuecomment-502095133 +struct OnDiskDirEntry<'a> { _s: &'a usize } + +impl<'a> OnDiskDirEntry<'a> { + const LFN_FRAGMENT_LEN: usize = 2; + + fn lfn_contents(&self) -> [char; Self::LFN_FRAGMENT_LEN] { loop { } } + //~^ ERROR: generic `Self` types are currently not permitted in anonymous constants +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-56445-2.stderr b/src/test/ui/const-generics/issues/issue-56445-2.stderr new file mode 100644 index 000000000..770c80cbb --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-56445-2.stderr @@ -0,0 +1,14 @@ +error: generic `Self` types are currently not permitted in anonymous constants + --> $DIR/issue-56445-2.rs:7:38 + | +LL | fn lfn_contents(&self) -> [char; Self::LFN_FRAGMENT_LEN] { loop { } } + | ^^^^ + | +note: not a concrete type + --> $DIR/issue-56445-2.rs:4:10 + | +LL | impl<'a> OnDiskDirEntry<'a> { + | ^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-56445-3.rs b/src/test/ui/const-generics/issues/issue-56445-3.rs new file mode 100644 index 000000000..c29df1458 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-56445-3.rs @@ -0,0 +1,12 @@ +// Regression test for https://github.com/rust-lang/rust/issues/56445#issuecomment-524494170 +pub struct Memory<'rom> { + rom: &'rom [u8], + ram: [u8; Self::SIZE], + //~^ ERROR: generic `Self` types are currently not permitted in anonymous constants +} + +impl<'rom> Memory<'rom> { + pub const SIZE: usize = 0x8000; +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-56445-3.stderr b/src/test/ui/const-generics/issues/issue-56445-3.stderr new file mode 100644 index 000000000..f1c49eecf --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-56445-3.stderr @@ -0,0 +1,8 @@ +error: generic `Self` types are currently not permitted in anonymous constants + --> $DIR/issue-56445-3.rs:4:15 + | +LL | ram: [u8; Self::SIZE], + | ^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-60818-struct-constructors.rs b/src/test/ui/const-generics/issues/issue-60818-struct-constructors.rs new file mode 100644 index 000000000..0066490df --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-60818-struct-constructors.rs @@ -0,0 +1,7 @@ +// check-pass + +struct Generic; + +fn main() { + let _ = Generic::<0>; +} diff --git a/src/test/ui/const-generics/issues/issue-61336-1.rs b/src/test/ui/const-generics/issues/issue-61336-1.rs new file mode 100644 index 000000000..beb37e63b --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-61336-1.rs @@ -0,0 +1,9 @@ +// build-pass +fn f(x: T) -> [T; N] { + [x; N] +} + +fn main() { + let x: [u32; 5] = f::(3); + assert_eq!(x, [3u32; 5]); +} diff --git a/src/test/ui/const-generics/issues/issue-61336-2.rs b/src/test/ui/const-generics/issues/issue-61336-2.rs new file mode 100644 index 000000000..b7cd29f89 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-61336-2.rs @@ -0,0 +1,13 @@ +fn f(x: T) -> [T; N] { + [x; { N }] +} + +fn g(x: T) -> [T; N] { + [x; { N }] + //~^ ERROR the trait bound `T: Copy` is not satisfied +} + +fn main() { + let x: [u32; 5] = f::(3); + assert_eq!(x, [3u32; 5]); +} diff --git a/src/test/ui/const-generics/issues/issue-61336-2.stderr b/src/test/ui/const-generics/issues/issue-61336-2.stderr new file mode 100644 index 000000000..5bb356696 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-61336-2.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `T: Copy` is not satisfied + --> $DIR/issue-61336-2.rs:6:6 + | +LL | [x; { N }] + | ^ the trait `Copy` is not implemented for `T` + | + = note: the `Copy` trait is required because this value will be copied for each element of the array +help: consider restricting type parameter `T` + | +LL | fn g(x: T) -> [T; N] { + | +++++++++++++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/const-generics/issues/issue-61336.rs b/src/test/ui/const-generics/issues/issue-61336.rs new file mode 100644 index 000000000..80be1d8e5 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-61336.rs @@ -0,0 +1,13 @@ +fn f(x: T) -> [T; N] { + [x; N] +} + +fn g(x: T) -> [T; N] { + [x; N] + //~^ ERROR the trait bound `T: Copy` is not satisfied +} + +fn main() { + let x: [u32; 5] = f::(3); + assert_eq!(x, [3u32; 5]); +} diff --git a/src/test/ui/const-generics/issues/issue-61336.stderr b/src/test/ui/const-generics/issues/issue-61336.stderr new file mode 100644 index 000000000..8d9e545b4 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-61336.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `T: Copy` is not satisfied + --> $DIR/issue-61336.rs:6:6 + | +LL | [x; N] + | ^ the trait `Copy` is not implemented for `T` + | + = note: the `Copy` trait is required because this value will be copied for each element of the array +help: consider restricting type parameter `T` + | +LL | fn g(x: T) -> [T; N] { + | +++++++++++++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/const-generics/issues/issue-61422.rs b/src/test/ui/const-generics/issues/issue-61422.rs new file mode 100644 index 000000000..0b9cf40d8 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-61422.rs @@ -0,0 +1,24 @@ +// check-pass +use std::mem; + +// Neither of the uninits below are currently accepted as not UB, however, +// this code does not run and is merely checking that we do not ICE on this pattern, +// so this is fine. + +fn foo() { + let arr: [u8; SIZE] = unsafe { + #[allow(deprecated)] + let array: [u8; SIZE] = mem::uninitialized(); + array + }; +} + +fn bar() { + let arr: [u8; SIZE] = unsafe { + let array: [u8; SIZE] = mem::MaybeUninit::uninit().assume_init(); + array + }; +} + + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-61432.rs b/src/test/ui/const-generics/issues/issue-61432.rs new file mode 100644 index 000000000..6192af82a --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-61432.rs @@ -0,0 +1,9 @@ +// run-pass + +fn promote() { + let _ = &N; +} + +fn main() { + promote::<0>(); +} diff --git a/src/test/ui/const-generics/issues/issue-62187-encountered-polymorphic-const.rs b/src/test/ui/const-generics/issues/issue-62187-encountered-polymorphic-const.rs new file mode 100644 index 000000000..fa76aeae9 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-62187-encountered-polymorphic-const.rs @@ -0,0 +1,12 @@ +// run-pass +pub trait BitLen: Sized { + const BIT_LEN: usize; +} + +impl BitLen for [u8; L] { + const BIT_LEN: usize = 8 * L; +} + +fn main() { + let _foo = <[u8; 2]>::BIT_LEN; +} diff --git a/src/test/ui/const-generics/issues/issue-62878.full.stderr b/src/test/ui/const-generics/issues/issue-62878.full.stderr new file mode 100644 index 000000000..3a2b291d7 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-62878.full.stderr @@ -0,0 +1,9 @@ +error[E0770]: the type of const parameters must not depend on other generic parameters + --> $DIR/issue-62878.rs:5:38 + | +LL | fn foo() {} + | ^ the type must not depend on the parameter `N` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0770`. diff --git a/src/test/ui/const-generics/issues/issue-62878.min.stderr b/src/test/ui/const-generics/issues/issue-62878.min.stderr new file mode 100644 index 000000000..af029a651 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-62878.min.stderr @@ -0,0 +1,18 @@ +error[E0770]: the type of const parameters must not depend on other generic parameters + --> $DIR/issue-62878.rs:5:38 + | +LL | fn foo() {} + | ^ the type must not depend on the parameter `N` + +error: `[u8; _]` is forbidden as the type of a const generic parameter + --> $DIR/issue-62878.rs:5:33 + | +LL | fn foo() {} + | ^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = help: more complex types are supported with `#![feature(adt_const_params)]` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0770`. diff --git a/src/test/ui/const-generics/issues/issue-62878.rs b/src/test/ui/const-generics/issues/issue-62878.rs new file mode 100644 index 000000000..578ce765b --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-62878.rs @@ -0,0 +1,11 @@ +// revisions: full min +#![cfg_attr(full, feature(adt_const_params, generic_arg_infer))] +#![cfg_attr(full, allow(incomplete_features))] + +fn foo() {} +//~^ ERROR the type of const parameters must not +//[min]~| ERROR `[u8; _]` is forbidden as the type of a const generic parameter + +fn main() { + foo::<_, { [1] }>(); +} diff --git a/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.full.stderr b/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.full.stderr new file mode 100644 index 000000000..16fabd1e8 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.full.stderr @@ -0,0 +1,9 @@ +error[E0741]: `(dyn A + 'static)` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter + --> $DIR/issue-63322-forbid-dyn.rs:9:18 + | +LL | fn test() { + | ^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0741`. diff --git a/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.min.stderr b/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.min.stderr new file mode 100644 index 000000000..9f6c7ccf3 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.min.stderr @@ -0,0 +1,11 @@ +error: `&'static (dyn A + 'static)` is forbidden as the type of a const generic parameter + --> $DIR/issue-63322-forbid-dyn.rs:9:18 + | +LL | fn test() { + | ^^^^^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = help: more complex types are supported with `#![feature(adt_const_params)]` + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs b/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs new file mode 100644 index 000000000..116c3fcfb --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs @@ -0,0 +1,17 @@ +// revisions: full min +#![cfg_attr(full, feature(adt_const_params))] +#![cfg_attr(full, allow(incomplete_features))] + +trait A {} +struct B; +impl A for B {} + +fn test() { + //[full]~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` to be used + //[min]~^^ ERROR `&'static (dyn A + 'static)` is forbidden + unimplemented!() +} + +fn main() { + test::<{ &B }>(); +} diff --git a/src/test/ui/const-generics/issues/issue-64519.rs b/src/test/ui/const-generics/issues/issue-64519.rs new file mode 100644 index 000000000..969289b26 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-64519.rs @@ -0,0 +1,17 @@ +// check-pass +struct Foo { + state: Option<[u8; D]>, +} + +impl Iterator for Foo<{D}> { + type Item = [u8; D]; + fn next(&mut self) -> Option { + if true { + return Some(self.state.unwrap().clone()); + } else { + return Some(self.state.unwrap().clone()); + } + } +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-66596-impl-trait-for-str-const-arg.rs b/src/test/ui/const-generics/issues/issue-66596-impl-trait-for-str-const-arg.rs new file mode 100644 index 000000000..091419f0c --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-66596-impl-trait-for-str-const-arg.rs @@ -0,0 +1,16 @@ +// check-pass +#![feature(adt_const_params)] +#![allow(incomplete_features)] + + +trait Trait { + type Assoc; +} + +impl Trait<"0"> for () { + type Assoc = (); +} + +fn main() { + let _: <() as Trait<"0">>::Assoc = (); +} diff --git a/src/test/ui/const-generics/issues/issue-66906.rs b/src/test/ui/const-generics/issues/issue-66906.rs new file mode 100644 index 000000000..a0b3f9122 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-66906.rs @@ -0,0 +1,9 @@ +// check-pass + +pub struct Tuple; + +pub trait Trait { + type Input: From<>::Input>; +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-67185-1.rs b/src/test/ui/const-generics/issues/issue-67185-1.rs new file mode 100644 index 000000000..69425b25e --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-67185-1.rs @@ -0,0 +1,29 @@ +// check-pass + +trait Baz { + type Quaks; +} +impl Baz for u8 { + type Quaks = [u16; 3]; +} + +trait Bar {} +impl Bar for [u16; 3] {} +impl Bar for [[u16; 3]; 2] {} + +trait Foo + where + [::Quaks; 2]: Bar, + ::Quaks: Bar, +{ +} + +struct FooImpl; + +impl Foo for FooImpl {} + +fn f(_: impl Foo) {} + +fn main() { + f(FooImpl) +} diff --git a/src/test/ui/const-generics/issues/issue-67185-2.rs b/src/test/ui/const-generics/issues/issue-67185-2.rs new file mode 100644 index 000000000..18bb6f6bc --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-67185-2.rs @@ -0,0 +1,31 @@ +trait Baz { + type Quaks; +} +impl Baz for u8 { + type Quaks = [u16; 3]; +} + +trait Bar {} +impl Bar for [u16; 4] {} +impl Bar for [[u16; 3]; 3] {} + +trait Foo +where + [::Quaks; 2]: Bar, //~ ERROR the trait bound `[[u16; 3]; 2]: Bar` is not satisfied [E0277] + ::Quaks: Bar, //~ ERROR the trait bound `[u16; 3]: Bar` is not satisfied [E0277] +{ +} + +struct FooImpl; + +impl Foo for FooImpl {} +//~^ ERROR the trait bound `[u16; 3]: Bar` is not satisfied [E0277] +//~^^ ERROR the trait bound `[[u16; 3]; 2]: Bar` is not satisfied [E0277] + +fn f(_: impl Foo) {} +//~^ ERROR the trait bound `[u16; 3]: Bar` is not satisfied [E0277] +//~^^ ERROR the trait bound `[[u16; 3]; 2]: Bar` is not satisfied [E0277] + +fn main() { + f(FooImpl) +} diff --git a/src/test/ui/const-generics/issues/issue-67185-2.stderr b/src/test/ui/const-generics/issues/issue-67185-2.stderr new file mode 100644 index 000000000..c7be8e14a --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-67185-2.stderr @@ -0,0 +1,99 @@ +error[E0277]: the trait bound `[u16; 3]: Bar` is not satisfied + --> $DIR/issue-67185-2.rs:15:5 + | +LL | ::Quaks: Bar, + | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `[u16; 3]` + | + = help: the following other types implement trait `Bar`: + [[u16; 3]; 3] + [u16; 4] + = help: see issue #48214 + = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + +error[E0277]: the trait bound `[[u16; 3]; 2]: Bar` is not satisfied + --> $DIR/issue-67185-2.rs:14:5 + | +LL | [::Quaks; 2]: Bar, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `[[u16; 3]; 2]` + | + = help: the following other types implement trait `Bar`: + [[u16; 3]; 3] + [u16; 4] + = help: see issue #48214 + = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + +error[E0277]: the trait bound `[u16; 3]: Bar` is not satisfied + --> $DIR/issue-67185-2.rs:21:6 + | +LL | impl Foo for FooImpl {} + | ^^^ the trait `Bar` is not implemented for `[u16; 3]` + | + = help: the following other types implement trait `Bar`: + [[u16; 3]; 3] + [u16; 4] +note: required by a bound in `Foo` + --> $DIR/issue-67185-2.rs:15:25 + | +LL | trait Foo + | --- required by a bound in this +... +LL | ::Quaks: Bar, + | ^^^ required by this bound in `Foo` + +error[E0277]: the trait bound `[[u16; 3]; 2]: Bar` is not satisfied + --> $DIR/issue-67185-2.rs:21:6 + | +LL | impl Foo for FooImpl {} + | ^^^ the trait `Bar` is not implemented for `[[u16; 3]; 2]` + | + = help: the following other types implement trait `Bar`: + [[u16; 3]; 3] + [u16; 4] +note: required by a bound in `Foo` + --> $DIR/issue-67185-2.rs:14:30 + | +LL | trait Foo + | --- required by a bound in this +LL | where +LL | [::Quaks; 2]: Bar, + | ^^^ required by this bound in `Foo` + +error[E0277]: the trait bound `[[u16; 3]; 2]: Bar` is not satisfied + --> $DIR/issue-67185-2.rs:25:14 + | +LL | fn f(_: impl Foo) {} + | ^^^ the trait `Bar` is not implemented for `[[u16; 3]; 2]` + | + = help: the following other types implement trait `Bar`: + [[u16; 3]; 3] + [u16; 4] +note: required by a bound in `Foo` + --> $DIR/issue-67185-2.rs:14:30 + | +LL | trait Foo + | --- required by a bound in this +LL | where +LL | [::Quaks; 2]: Bar, + | ^^^ required by this bound in `Foo` + +error[E0277]: the trait bound `[u16; 3]: Bar` is not satisfied + --> $DIR/issue-67185-2.rs:25:14 + | +LL | fn f(_: impl Foo) {} + | ^^^ the trait `Bar` is not implemented for `[u16; 3]` + | + = help: the following other types implement trait `Bar`: + [[u16; 3]; 3] + [u16; 4] +note: required by a bound in `Foo` + --> $DIR/issue-67185-2.rs:15:25 + | +LL | trait Foo + | --- required by a bound in this +... +LL | ::Quaks: Bar, + | ^^^ required by this bound in `Foo` + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/const-generics/issues/issue-67375.full.stderr b/src/test/ui/const-generics/issues/issue-67375.full.stderr new file mode 100644 index 000000000..0cf69879a --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-67375.full.stderr @@ -0,0 +1,12 @@ +error: overly complex generic constant + --> $DIR/issue-67375.rs:7:17 + | +LL | inner: [(); { [|_: &T| {}; 0].len() }], + | ^^---------------------^^ + | | + | pointer casts are not allowed in generic constants + | + = help: consider moving this anonymous constant into a `const` function + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-67375.min.stderr b/src/test/ui/const-generics/issues/issue-67375.min.stderr new file mode 100644 index 000000000..5256d96c8 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-67375.min.stderr @@ -0,0 +1,21 @@ +error: generic parameters may not be used in const operations + --> $DIR/issue-67375.rs:7:25 + | +LL | inner: [(); { [|_: &T| {}; 0].len() }], + | ^ cannot perform const operation using `T` + | + = note: type parameters may not be used in const expressions + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions + +error[E0392]: parameter `T` is never used + --> $DIR/issue-67375.rs:5:12 + | +LL | struct Bug { + | ^ unused parameter + | + = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` + = help: if you intended `T` to be a const parameter, use `const T: usize` instead + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0392`. diff --git a/src/test/ui/const-generics/issues/issue-67375.rs b/src/test/ui/const-generics/issues/issue-67375.rs new file mode 100644 index 000000000..8b4b276ba --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-67375.rs @@ -0,0 +1,12 @@ +// revisions: full min +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(full, feature(generic_const_exprs))] + +struct Bug { + //[min]~^ ERROR parameter `T` is never used + inner: [(); { [|_: &T| {}; 0].len() }], + //[min]~^ ERROR generic parameters may not be used in const operations + //[full]~^^ ERROR overly complex generic constant +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-67739.full.stderr b/src/test/ui/const-generics/issues/issue-67739.full.stderr new file mode 100644 index 000000000..f1a426c3c --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-67739.full.stderr @@ -0,0 +1,10 @@ +error: unconstrained generic constant + --> $DIR/issue-67739.rs:11:15 + | +LL | [0u8; mem::size_of::()]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: try adding a `where` bound using this expression: `where [(); mem::size_of::()]:` + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-67739.min.stderr b/src/test/ui/const-generics/issues/issue-67739.min.stderr new file mode 100644 index 000000000..dcbe5b94a --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-67739.min.stderr @@ -0,0 +1,10 @@ +error: constant expression depends on a generic parameter + --> $DIR/issue-67739.rs:11:15 + | +LL | [0u8; mem::size_of::()]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this may fail depending on what value the parameter takes + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-67739.rs b/src/test/ui/const-generics/issues/issue-67739.rs new file mode 100644 index 000000000..de0eb7f50 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-67739.rs @@ -0,0 +1,18 @@ +// revisions: full min +#![cfg_attr(full, feature(generic_const_exprs))] +#![cfg_attr(full, allow(incomplete_features))] + +use std::mem; + +pub trait Trait { + type Associated: Sized; + + fn associated_size(&self) -> usize { + [0u8; mem::size_of::()]; + //[min]~^ ERROR constant expression depends on a generic parameter + //[full]~^^ ERROR unconstrained generic constant + 0 + } +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-67945-1.full.stderr b/src/test/ui/const-generics/issues/issue-67945-1.full.stderr new file mode 100644 index 000000000..8e18fcdff --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-67945-1.full.stderr @@ -0,0 +1,17 @@ +error[E0308]: mismatched types + --> $DIR/issue-67945-1.rs:10:20 + | +LL | struct Bug { + | - this type parameter +... +LL | let x: S = MaybeUninit::uninit(); + | - ^^^^^^^^^^^^^^^^^^^^^ expected type parameter `S`, found union `MaybeUninit` + | | + | expected due to this + | + = note: expected type parameter `S` + found union `MaybeUninit<_>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/const-generics/issues/issue-67945-1.min.stderr b/src/test/ui/const-generics/issues/issue-67945-1.min.stderr new file mode 100644 index 000000000..eee04eb75 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-67945-1.min.stderr @@ -0,0 +1,30 @@ +error: generic parameters may not be used in const operations + --> $DIR/issue-67945-1.rs:10:16 + | +LL | let x: S = MaybeUninit::uninit(); + | ^ cannot perform const operation using `S` + | + = note: type parameters may not be used in const expressions + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions + +error: generic parameters may not be used in const operations + --> $DIR/issue-67945-1.rs:13:45 + | +LL | let b = &*(&x as *const _ as *const S); + | ^ cannot perform const operation using `S` + | + = note: type parameters may not be used in const expressions + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions + +error[E0392]: parameter `S` is never used + --> $DIR/issue-67945-1.rs:7:12 + | +LL | struct Bug { + | ^ unused parameter + | + = help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData` + = help: if you intended `S` to be a const parameter, use `const S: usize` instead + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0392`. diff --git a/src/test/ui/const-generics/issues/issue-67945-1.rs b/src/test/ui/const-generics/issues/issue-67945-1.rs new file mode 100644 index 000000000..99f88bc8e --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-67945-1.rs @@ -0,0 +1,19 @@ +// revisions: full min +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(full, feature(generic_const_exprs))] + +use std::mem::MaybeUninit; + +struct Bug { + //[min]~^ ERROR parameter `S` is never used + A: [(); { + let x: S = MaybeUninit::uninit(); + //[min]~^ ERROR generic parameters may not be used in const operations + //[full]~^^ ERROR mismatched types + let b = &*(&x as *const _ as *const S); + //[min]~^ ERROR generic parameters may not be used in const operations + 0 + }], +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-67945-2.full.stderr b/src/test/ui/const-generics/issues/issue-67945-2.full.stderr new file mode 100644 index 000000000..cce85772a --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-67945-2.full.stderr @@ -0,0 +1,17 @@ +error: overly complex generic constant + --> $DIR/issue-67945-2.rs:7:13 + | +LL | A: [(); { + | _____________^ +LL | | +LL | | let x: Option> = None; +LL | | +LL | | 0 +LL | | }], + | |_____^ blocks are not supported in generic constant + | + = help: consider moving this anonymous constant into a `const` function + = note: this operation may be supported in the future + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-67945-2.min.stderr b/src/test/ui/const-generics/issues/issue-67945-2.min.stderr new file mode 100644 index 000000000..6e07af1e6 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-67945-2.min.stderr @@ -0,0 +1,8 @@ +error: generic `Self` types are currently not permitted in anonymous constants + --> $DIR/issue-67945-2.rs:9:27 + | +LL | let x: Option> = None; + | ^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-67945-2.rs b/src/test/ui/const-generics/issues/issue-67945-2.rs new file mode 100644 index 000000000..cbb4e14ec --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-67945-2.rs @@ -0,0 +1,16 @@ +// revisions: full min + +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(full, feature(generic_const_exprs))] + +struct Bug { + A: [(); { + //[full]~^ ERROR overly complex generic constant + let x: Option> = None; + //[min]~^ ERROR generic `Self` types are currently not permitted in anonymous constants + 0 + }], + B: S +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-67945-3.full.stderr b/src/test/ui/const-generics/issues/issue-67945-3.full.stderr new file mode 100644 index 000000000..d3d9452d3 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-67945-3.full.stderr @@ -0,0 +1,16 @@ +error: overly complex generic constant + --> $DIR/issue-67945-3.rs:10:13 + | +LL | A: [(); { + | _____________^ +LL | | let x: Option = None; +LL | | +LL | | 0 +LL | | }], + | |_____^ blocks are not supported in generic constant + | + = help: consider moving this anonymous constant into a `const` function + = note: this operation may be supported in the future + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-67945-3.min.stderr b/src/test/ui/const-generics/issues/issue-67945-3.min.stderr new file mode 100644 index 000000000..8e6b4b204 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-67945-3.min.stderr @@ -0,0 +1,21 @@ +error: generic parameters may not be used in const operations + --> $DIR/issue-67945-3.rs:11:23 + | +LL | let x: Option = None; + | ^ cannot perform const operation using `S` + | + = note: type parameters may not be used in const expressions + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions + +error[E0392]: parameter `S` is never used + --> $DIR/issue-67945-3.rs:9:12 + | +LL | struct Bug { + | ^ unused parameter + | + = help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData` + = help: if you intended `S` to be a const parameter, use `const S: usize` instead + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0392`. diff --git a/src/test/ui/const-generics/issues/issue-67945-3.rs b/src/test/ui/const-generics/issues/issue-67945-3.rs new file mode 100644 index 000000000..fd8a393ef --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-67945-3.rs @@ -0,0 +1,17 @@ +// Regression test for +// https://github.com/rust-lang/rust/issues/67945#issuecomment-572617285 +// Make sure we don't emit an E0277 error. + +// revisions: full min +#![cfg_attr(full, feature(generic_const_exprs))] +#![cfg_attr(full, allow(incomplete_features))] + +struct Bug { //[min]~ ERROR: parameter `S` is never used + A: [(); { //[full]~ ERROR: overly complex generic constant + let x: Option = None; + //[min]~^ ERROR: generic parameters may not be used in const operations + 0 + }], +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-67945-4.full.stderr b/src/test/ui/const-generics/issues/issue-67945-4.full.stderr new file mode 100644 index 000000000..9604eb35d --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-67945-4.full.stderr @@ -0,0 +1,16 @@ +error: overly complex generic constant + --> $DIR/issue-67945-4.rs:9:13 + | +LL | A: [(); { + | _____________^ +LL | | let x: Option> = None; +LL | | +LL | | 0 +LL | | }], + | |_____^ blocks are not supported in generic constant + | + = help: consider moving this anonymous constant into a `const` function + = note: this operation may be supported in the future + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-67945-4.min.stderr b/src/test/ui/const-generics/issues/issue-67945-4.min.stderr new file mode 100644 index 000000000..f9520872d --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-67945-4.min.stderr @@ -0,0 +1,21 @@ +error: generic parameters may not be used in const operations + --> $DIR/issue-67945-4.rs:10:27 + | +LL | let x: Option> = None; + | ^ cannot perform const operation using `S` + | + = note: type parameters may not be used in const expressions + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions + +error[E0392]: parameter `S` is never used + --> $DIR/issue-67945-4.rs:8:12 + | +LL | struct Bug { + | ^ unused parameter + | + = help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData` + = help: if you intended `S` to be a const parameter, use `const S: usize` instead + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0392`. diff --git a/src/test/ui/const-generics/issues/issue-67945-4.rs b/src/test/ui/const-generics/issues/issue-67945-4.rs new file mode 100644 index 000000000..9a27bf09f --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-67945-4.rs @@ -0,0 +1,16 @@ +// Regression test for +// https://github.com/rust-lang/rust/issues/67945#issuecomment-572617285 + +// revisions: full min +#![cfg_attr(full, feature(generic_const_exprs))] +#![cfg_attr(full, allow(incomplete_features))] + +struct Bug { //[min]~ ERROR: parameter `S` is never used + A: [(); { //[full]~ ERROR: overly complex generic constant + let x: Option> = None; + //[min]~^ ERROR: generic parameters may not be used in const operations + 0 + }], +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-68104-print-stack-overflow.rs b/src/test/ui/const-generics/issues/issue-68104-print-stack-overflow.rs new file mode 100644 index 000000000..ad5710baa --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-68104-print-stack-overflow.rs @@ -0,0 +1,13 @@ +// aux-build:impl-const.rs +// run-pass +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +extern crate impl_const; + +use impl_const::*; + +pub fn main() { + let n = Num::<5>; + n.five(); +} diff --git a/src/test/ui/const-generics/issues/issue-68366.full.stderr b/src/test/ui/const-generics/issues/issue-68366.full.stderr new file mode 100644 index 000000000..ca9eb801d --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-68366.full.stderr @@ -0,0 +1,21 @@ +error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates + --> $DIR/issue-68366.rs:11:7 + | +LL | impl Collatz<{Some(N)}> {} + | ^^^^^^^^^^^^^^ unconstrained const parameter + | + = note: expressions using a const parameter must map each value to a distinct output value + = note: proving the result of expressions other than the parameter are unique is not supported + +error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates + --> $DIR/issue-68366.rs:17:6 + | +LL | impl Foo {} + | ^^^^^^^^^^^^^^ unconstrained const parameter + | + = note: expressions using a const parameter must map each value to a distinct output value + = note: proving the result of expressions other than the parameter are unique is not supported + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0207`. diff --git a/src/test/ui/const-generics/issues/issue-68366.min.stderr b/src/test/ui/const-generics/issues/issue-68366.min.stderr new file mode 100644 index 000000000..3740ced90 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-68366.min.stderr @@ -0,0 +1,30 @@ +error: generic parameters may not be used in const operations + --> $DIR/issue-68366.rs:11:37 + | +LL | impl Collatz<{Some(N)}> {} + | ^ cannot perform const operation using `N` + | + = help: const parameters may only be used as standalone arguments, i.e. `N` + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions + +error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates + --> $DIR/issue-68366.rs:11:7 + | +LL | impl Collatz<{Some(N)}> {} + | ^^^^^^^^^^^^^^ unconstrained const parameter + | + = note: expressions using a const parameter must map each value to a distinct output value + = note: proving the result of expressions other than the parameter are unique is not supported + +error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates + --> $DIR/issue-68366.rs:17:6 + | +LL | impl Foo {} + | ^^^^^^^^^^^^^^ unconstrained const parameter + | + = note: expressions using a const parameter must map each value to a distinct output value + = note: proving the result of expressions other than the parameter are unique is not supported + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0207`. diff --git a/src/test/ui/const-generics/issues/issue-68366.rs b/src/test/ui/const-generics/issues/issue-68366.rs new file mode 100644 index 000000000..4c2741ab4 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-68366.rs @@ -0,0 +1,20 @@ +// Checks that const expressions have a useful note explaining why they can't be evaluated. +// The note should relate to the fact that it cannot be shown forall N that it maps 1-1 to a new +// type. + +// revisions: full min +#![cfg_attr(full, feature(generic_const_exprs))] +#![cfg_attr(full, allow(incomplete_features))] + +struct Collatz>; + +impl Collatz<{Some(N)}> {} +//~^ ERROR the const parameter +//[min]~^^ generic parameters may not be used in const operations + +struct Foo; + +impl Foo {} +//~^ ERROR the const parameter + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-68596.rs b/src/test/ui/const-generics/issues/issue-68596.rs new file mode 100644 index 000000000..c3c9141e4 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-68596.rs @@ -0,0 +1,15 @@ +// check-pass +pub struct S(u8); + +impl S { + pub fn get(&self) -> &u8 { + &self.0 + } +} + +fn main() { + const A: u8 = 5; + let s = S(0); + + s.get::(); +} diff --git a/src/test/ui/const-generics/issues/issue-68615-adt.min.stderr b/src/test/ui/const-generics/issues/issue-68615-adt.min.stderr new file mode 100644 index 000000000..df04c4896 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-68615-adt.min.stderr @@ -0,0 +1,11 @@ +error: `[usize; 0]` is forbidden as the type of a const generic parameter + --> $DIR/issue-68615-adt.rs:6:23 + | +LL | struct Const {} + | ^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = help: more complex types are supported with `#![feature(adt_const_params)]` + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-68615-adt.rs b/src/test/ui/const-generics/issues/issue-68615-adt.rs new file mode 100644 index 000000000..3ef1ad45e --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-68615-adt.rs @@ -0,0 +1,13 @@ +// [full] check-pass +// revisions: full min +#![cfg_attr(full, feature(adt_const_params))] +#![cfg_attr(full, allow(incomplete_features))] + +struct Const {} +//[min]~^ ERROR `[usize; 0]` is forbidden as the type of a const generic parameter +type MyConst = Const<{ [] }>; + +fn main() { + let _x = Const::<{ [] }> {}; + let _y = MyConst {}; +} diff --git a/src/test/ui/const-generics/issues/issue-68615-array.min.stderr b/src/test/ui/const-generics/issues/issue-68615-array.min.stderr new file mode 100644 index 000000000..1b4517087 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-68615-array.min.stderr @@ -0,0 +1,11 @@ +error: `[usize; 0]` is forbidden as the type of a const generic parameter + --> $DIR/issue-68615-array.rs:6:21 + | +LL | struct Foo {} + | ^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = help: more complex types are supported with `#![feature(adt_const_params)]` + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-68615-array.rs b/src/test/ui/const-generics/issues/issue-68615-array.rs new file mode 100644 index 000000000..93477be41 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-68615-array.rs @@ -0,0 +1,13 @@ +// [full] check-pass +// revisions: full min +#![cfg_attr(full, feature(adt_const_params))] +#![cfg_attr(full, allow(incomplete_features))] + +struct Foo {} +//[min]~^ ERROR `[usize; 0]` is forbidden as the type of a const generic parameter + +type MyFoo = Foo<{ [] }>; + +fn main() { + let _ = Foo::<{ [] }> {}; +} diff --git a/src/test/ui/const-generics/issues/issue-69654-run-pass.rs b/src/test/ui/const-generics/issues/issue-69654-run-pass.rs new file mode 100644 index 000000000..63d7fde78 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-69654-run-pass.rs @@ -0,0 +1,15 @@ +// run-pass +trait Bar {} +impl Bar for [u8; 7] {} + +struct Foo {} +impl Foo +where + [u8; N]: Bar<[(); N]>, +{ + fn foo() {} +} + +fn main() { + Foo::foo(); +} diff --git a/src/test/ui/const-generics/issues/issue-70125-1.rs b/src/test/ui/const-generics/issues/issue-70125-1.rs new file mode 100644 index 000000000..0027cd46a --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-70125-1.rs @@ -0,0 +1,17 @@ +// run-pass + +const L: usize = 4; + +pub trait Print { + fn print(&self) -> usize { + N + } +} + +pub struct Printer; +impl Print for Printer {} + +fn main() { + let p = Printer; + assert_eq!(p.print(), 4); +} diff --git a/src/test/ui/const-generics/issues/issue-70125-2.rs b/src/test/ui/const-generics/issues/issue-70125-2.rs new file mode 100644 index 000000000..cfd5e784e --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-70125-2.rs @@ -0,0 +1,12 @@ +// run-pass +fn main() { + <()>::foo(); +} + +trait Foo { + fn foo() -> usize { + X + } +} + +impl Foo<3> for () {} diff --git a/src/test/ui/const-generics/issues/issue-70167.rs b/src/test/ui/const-generics/issues/issue-70167.rs new file mode 100644 index 000000000..3961941f8 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-70167.rs @@ -0,0 +1,6 @@ +// check-pass +pub trait Trait: From<>::Item> { + type Item; +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-70180-1-stalled_on.rs b/src/test/ui/const-generics/issues/issue-70180-1-stalled_on.rs new file mode 100644 index 000000000..2ec37cc3a --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-70180-1-stalled_on.rs @@ -0,0 +1,33 @@ +// build-pass + +pub fn works() { + let array/*: [_; _]*/ = default_array(); + let _: [_; 4] = array; + Foo::foo(&array); +} + +pub fn didnt_work() { + let array/*: [_; _]*/ = default_array(); + Foo::foo(&array); + let _: [_; 4] = array; +} + +trait Foo { + fn foo(&self) {} +} + +impl Foo for [i32; 4] {} +impl Foo for [i64; 8] {} + +// Only needed because `[_; _]` is not valid type syntax. +fn default_array() -> [T; N] +where + [T; N]: Default, +{ + Default::default() +} + +fn main() { + works(); + didnt_work(); +} diff --git a/src/test/ui/const-generics/issues/issue-70180-2-stalled_on.rs b/src/test/ui/const-generics/issues/issue-70180-2-stalled_on.rs new file mode 100644 index 000000000..95e548428 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-70180-2-stalled_on.rs @@ -0,0 +1,33 @@ +// build-pass + +fn works() { + let array/*: [u8; _]*/ = default_byte_array(); + let _: [_; 4] = array; + Foo::foo(&array); +} + +fn didnt_work() { + let array/*: [u8; _]*/ = default_byte_array(); + Foo::foo(&array); + let _: [_; 4] = array; +} + +trait Foo { + fn foo(&self) {} +} + +impl Foo for [u8; 4] {} +impl Foo for [u8; 8] {} + +// Only needed because `[u8; _]` is not valid type syntax. +fn default_byte_array() -> [u8; N] +where + [u8; N]: Default, +{ + Default::default() +} + +fn main() { + works(); + didnt_work(); +} diff --git a/src/test/ui/const-generics/issues/issue-70225.rs b/src/test/ui/const-generics/issues/issue-70225.rs new file mode 100644 index 000000000..d458d7b2e --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-70225.rs @@ -0,0 +1,19 @@ +// check-pass +#![deny(dead_code)] + +// We previously incorrectly linted `L` as unused here. +const L: usize = 3; + +fn main() { + let p = Printer {}; + p.print(); +} + +trait Print { + fn print(&self) -> usize { + 3 + } +} + +struct Printer {} +impl Print for Printer {} diff --git a/src/test/ui/const-generics/issues/issue-70273-assoc-fn.rs b/src/test/ui/const-generics/issues/issue-70273-assoc-fn.rs new file mode 100644 index 000000000..a76488249 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-70273-assoc-fn.rs @@ -0,0 +1,14 @@ +// check-pass + +trait T { + fn f(); +} +struct S; + +impl T<0usize> for S { + fn f() {} +} + +fn main() { + let _err = >::f(); +} diff --git a/src/test/ui/const-generics/issues/issue-71169.full.stderr b/src/test/ui/const-generics/issues/issue-71169.full.stderr new file mode 100644 index 000000000..1f5880f36 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-71169.full.stderr @@ -0,0 +1,9 @@ +error[E0770]: the type of const parameters must not depend on other generic parameters + --> $DIR/issue-71169.rs:5:43 + | +LL | fn foo() {} + | ^^^ the type must not depend on the parameter `LEN` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0770`. diff --git a/src/test/ui/const-generics/issues/issue-71169.min.stderr b/src/test/ui/const-generics/issues/issue-71169.min.stderr new file mode 100644 index 000000000..87ed2d4f8 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-71169.min.stderr @@ -0,0 +1,18 @@ +error[E0770]: the type of const parameters must not depend on other generic parameters + --> $DIR/issue-71169.rs:5:43 + | +LL | fn foo() {} + | ^^^ the type must not depend on the parameter `LEN` + +error: `[u8; _]` is forbidden as the type of a const generic parameter + --> $DIR/issue-71169.rs:5:38 + | +LL | fn foo() {} + | ^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = help: more complex types are supported with `#![feature(adt_const_params)]` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0770`. diff --git a/src/test/ui/const-generics/issues/issue-71169.rs b/src/test/ui/const-generics/issues/issue-71169.rs new file mode 100644 index 000000000..617149a84 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-71169.rs @@ -0,0 +1,11 @@ +// revisions: full min +#![cfg_attr(full, feature(adt_const_params))] +#![cfg_attr(full, allow(incomplete_features))] + +fn foo() {} +//~^ ERROR the type of const parameters must not +//[min]~^^ ERROR `[u8; _]` is forbidden as the type of a const generic parameter +fn main() { + const DATA: [u8; 4] = *b"ABCD"; + foo::<4, DATA>(); +} diff --git a/src/test/ui/const-generics/issues/issue-71202.rs b/src/test/ui/const-generics/issues/issue-71202.rs new file mode 100644 index 000000000..57fd72b12 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-71202.rs @@ -0,0 +1,31 @@ +#![feature(generic_const_exprs)] +#![allow(incomplete_features, const_evaluatable_unchecked)] + +use std::marker::PhantomData; + +struct DataHolder { + item: T, +} + +impl DataHolder { + const ITEM_IS_COPY: [(); 1 - { //~ ERROR unconstrained generic constant + trait NotCopy { + const VALUE: bool = false; + } + + impl<__Type: ?Sized> NotCopy for __Type {} + + struct IsCopy<__Type: ?Sized>(PhantomData<__Type>); + + impl<__Type> IsCopy<__Type> + where + __Type: Sized + Copy, + { + const VALUE: bool = true; + } + + >::VALUE + } as usize] = []; +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-71202.stderr b/src/test/ui/const-generics/issues/issue-71202.stderr new file mode 100644 index 000000000..277540610 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-71202.stderr @@ -0,0 +1,33 @@ +error: unconstrained generic constant + --> $DIR/issue-71202.rs:11:5 + | +LL | / const ITEM_IS_COPY: [(); 1 - { +LL | | trait NotCopy { +LL | | const VALUE: bool = false; +LL | | } +... | +LL | | >::VALUE +LL | | } as usize] = []; + | |_____________________^ + | + = help: try adding a `where` bound using this expression: `where [(); 1 - { + trait NotCopy { + const VALUE: bool = false; + } + + impl<__Type: ?Sized> NotCopy for __Type {} + + struct IsCopy<__Type: ?Sized>(PhantomData<__Type>); + + impl<__Type> IsCopy<__Type> + where + __Type: Sized + Copy, + { + const VALUE: bool = true; + } + + >::VALUE + } as usize]:` + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-71381.full.stderr b/src/test/ui/const-generics/issues/issue-71381.full.stderr new file mode 100644 index 000000000..e17cf96aa --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-71381.full.stderr @@ -0,0 +1,28 @@ +error[E0770]: the type of const parameters must not depend on other generic parameters + --> $DIR/issue-71381.rs:14:82 + | +LL | pub fn call_me(&self) { + | ^^^^ the type must not depend on the parameter `Args` + +error[E0770]: the type of const parameters must not depend on other generic parameters + --> $DIR/issue-71381.rs:23:40 + | +LL | const FN: unsafe extern "C" fn(Args), + | ^^^^ the type must not depend on the parameter `Args` + +error[E0741]: using function pointers as const generic parameters is forbidden + --> $DIR/issue-71381.rs:14:61 + | +LL | pub fn call_me(&self) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0741]: using function pointers as const generic parameters is forbidden + --> $DIR/issue-71381.rs:23:19 + | +LL | const FN: unsafe extern "C" fn(Args), + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0741, E0770. +For more information about an error, try `rustc --explain E0741`. diff --git a/src/test/ui/const-generics/issues/issue-71381.min.stderr b/src/test/ui/const-generics/issues/issue-71381.min.stderr new file mode 100644 index 000000000..3950317b3 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-71381.min.stderr @@ -0,0 +1,27 @@ +error[E0770]: the type of const parameters must not depend on other generic parameters + --> $DIR/issue-71381.rs:14:82 + | +LL | pub fn call_me(&self) { + | ^^^^ the type must not depend on the parameter `Args` + +error[E0770]: the type of const parameters must not depend on other generic parameters + --> $DIR/issue-71381.rs:23:40 + | +LL | const FN: unsafe extern "C" fn(Args), + | ^^^^ the type must not depend on the parameter `Args` + +error: using function pointers as const generic parameters is forbidden + --> $DIR/issue-71381.rs:14:61 + | +LL | pub fn call_me(&self) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: using function pointers as const generic parameters is forbidden + --> $DIR/issue-71381.rs:23:19 + | +LL | const FN: unsafe extern "C" fn(Args), + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0770`. diff --git a/src/test/ui/const-generics/issues/issue-71381.rs b/src/test/ui/const-generics/issues/issue-71381.rs new file mode 100644 index 000000000..66f819dbe --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-71381.rs @@ -0,0 +1,36 @@ +// revisions: full min +#![cfg_attr(full, feature(adt_const_params))] +#![cfg_attr(full, allow(incomplete_features))] + +struct Test(*const usize); + +type PassArg = (); + +unsafe extern "C" fn pass(args: PassArg) { + println!("Hello, world!"); +} + +impl Test { + pub fn call_me(&self) { + //~^ ERROR: using function pointers as const generic parameters is forbidden + //~| ERROR: the type of const parameters must not depend on other generic parameters + self.0 = Self::trampiline:: as _ + } + + unsafe extern "C" fn trampiline< + Args: Sized, + const IDX: usize, + const FN: unsafe extern "C" fn(Args), + //~^ ERROR: using function pointers as const generic parameters is forbidden + //~| ERROR: the type of const parameters must not depend on other generic parameters + >( + args: Args, + ) { + FN(args) + } +} + +fn main() { + let x = Test(); + x.call_me::() +} diff --git a/src/test/ui/const-generics/issues/issue-71382.full.stderr b/src/test/ui/const-generics/issues/issue-71382.full.stderr new file mode 100644 index 000000000..ab2a4e64a --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-71382.full.stderr @@ -0,0 +1,9 @@ +error[E0741]: using function pointers as const generic parameters is forbidden + --> $DIR/issue-71382.rs:16:23 + | +LL | fn test(&self) { + | ^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0741`. diff --git a/src/test/ui/const-generics/issues/issue-71382.min.stderr b/src/test/ui/const-generics/issues/issue-71382.min.stderr new file mode 100644 index 000000000..715037bd5 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-71382.min.stderr @@ -0,0 +1,8 @@ +error: using function pointers as const generic parameters is forbidden + --> $DIR/issue-71382.rs:16:23 + | +LL | fn test(&self) { + | ^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-71382.rs b/src/test/ui/const-generics/issues/issue-71382.rs new file mode 100644 index 000000000..4392d72e5 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-71382.rs @@ -0,0 +1,25 @@ +// revisions: full min +#![cfg_attr(full, feature(adt_const_params))] +#![cfg_attr(full, allow(incomplete_features))] + +struct Test(); + +fn pass() { + println!("Hello, world!"); +} + +impl Test { + pub fn call_me(&self) { + self.test::(); + } + + fn test(&self) { + //~^ ERROR: using function pointers as const generic parameters is forbidden + FN(); + } +} + +fn main() { + let x = Test(); + x.call_me() +} diff --git a/src/test/ui/const-generics/issues/issue-71547.rs b/src/test/ui/const-generics/issues/issue-71547.rs new file mode 100644 index 000000000..60776a1a9 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-71547.rs @@ -0,0 +1,18 @@ +// check-pass + +#![feature(adt_const_params)] +#![allow(incomplete_features)] + +pub trait GetType { + type Ty; + fn get(&self) -> &Self::Ty; +} + +pub fn get_val(value: &T) -> &T::Ty +where + T: GetType<"hello">, +{ + value.get() +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-71611.full.stderr b/src/test/ui/const-generics/issues/issue-71611.full.stderr new file mode 100644 index 000000000..656aa29e1 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-71611.full.stderr @@ -0,0 +1,16 @@ +error[E0770]: the type of const parameters must not depend on other generic parameters + --> $DIR/issue-71611.rs:5:31 + | +LL | fn func(outer: A) { + | ^ the type must not depend on the parameter `A` + +error[E0741]: using function pointers as const generic parameters is forbidden + --> $DIR/issue-71611.rs:5:21 + | +LL | fn func(outer: A) { + | ^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0741, E0770. +For more information about an error, try `rustc --explain E0741`. diff --git a/src/test/ui/const-generics/issues/issue-71611.min.stderr b/src/test/ui/const-generics/issues/issue-71611.min.stderr new file mode 100644 index 000000000..01a85b745 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-71611.min.stderr @@ -0,0 +1,15 @@ +error[E0770]: the type of const parameters must not depend on other generic parameters + --> $DIR/issue-71611.rs:5:31 + | +LL | fn func(outer: A) { + | ^ the type must not depend on the parameter `A` + +error: using function pointers as const generic parameters is forbidden + --> $DIR/issue-71611.rs:5:21 + | +LL | fn func(outer: A) { + | ^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0770`. diff --git a/src/test/ui/const-generics/issues/issue-71611.rs b/src/test/ui/const-generics/issues/issue-71611.rs new file mode 100644 index 000000000..fbb91ca18 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-71611.rs @@ -0,0 +1,11 @@ +// revisions: full min +#![cfg_attr(full, feature(adt_const_params))] +#![cfg_attr(full, allow(incomplete_features))] + +fn func(outer: A) { + //~^ ERROR: using function pointers as const generic parameters is forbidden + //~| ERROR: the type of const parameters must not depend on other generic parameters + F(outer); +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-71986.rs b/src/test/ui/const-generics/issues/issue-71986.rs new file mode 100644 index 000000000..6f0a98ead --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-71986.rs @@ -0,0 +1,6 @@ +// check-pass + +pub trait Foo {} +pub fn bar>() {} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-72352.full.stderr b/src/test/ui/const-generics/issues/issue-72352.full.stderr new file mode 100644 index 000000000..92580b336 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-72352.full.stderr @@ -0,0 +1,9 @@ +error[E0741]: using function pointers as const generic parameters is forbidden + --> $DIR/issue-72352.rs:7:42 + | +LL | unsafe fn unsafely_do_the_thing usize>(ptr: *const i8) -> usize { + | ^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0741`. diff --git a/src/test/ui/const-generics/issues/issue-72352.min.stderr b/src/test/ui/const-generics/issues/issue-72352.min.stderr new file mode 100644 index 000000000..eedd73c4d --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-72352.min.stderr @@ -0,0 +1,8 @@ +error: using function pointers as const generic parameters is forbidden + --> $DIR/issue-72352.rs:7:42 + | +LL | unsafe fn unsafely_do_the_thing usize>(ptr: *const i8) -> usize { + | ^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-72352.rs b/src/test/ui/const-generics/issues/issue-72352.rs new file mode 100644 index 000000000..2fa1d7a53 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-72352.rs @@ -0,0 +1,22 @@ +// revisions: full min +#![cfg_attr(full, feature(adt_const_params))] +#![cfg_attr(full, allow(incomplete_features))] + +use std::ffi::{CStr, CString}; + +unsafe fn unsafely_do_the_thing usize>(ptr: *const i8) -> usize { + //~^ ERROR: using function pointers as const generic parameters is forbidden + F(CStr::from_ptr(ptr)) +} + +fn safely_do_the_thing(s: &CStr) -> usize { + s.to_bytes().len() +} + +fn main() { + let baguette = CString::new("baguette").unwrap(); + let ptr = baguette.as_ptr(); + println!("{}", unsafe { + unsafely_do_the_thing::(ptr) + }); +} diff --git a/src/test/ui/const-generics/issues/issue-72845.rs b/src/test/ui/const-generics/issues/issue-72845.rs new file mode 100644 index 000000000..bea5dc8ba --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-72845.rs @@ -0,0 +1,49 @@ +#![feature(generic_const_exprs)] +#![feature(specialization)] +#![allow(incomplete_features)] + +//-------------------------------------------------- + +trait Depth { + const C: usize; +} + +trait Type { + type AT: Depth; +} + +//-------------------------------------------------- + +enum Predicate {} + +trait Satisfied {} + +impl Satisfied for Predicate {} + +//-------------------------------------------------- + +trait Spec1 {} + +impl Spec1 for T where Predicate<{T::AT::C > 0}>: Satisfied {} + +trait Spec2 {} + +//impl Spec2 for T where Predicate<{T::AT::C > 1}>: Satisfied {} +impl Spec2 for T where Predicate: Satisfied {} + +//-------------------------------------------------- + +trait Foo { + fn Bar(); +} + +impl Foo for T { + default fn Bar() {} +} + +impl Foo for T { +//~^ ERROR conflicting implementations of trait + fn Bar() {} +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-72845.stderr b/src/test/ui/const-generics/issues/issue-72845.stderr new file mode 100644 index 000000000..631c8605f --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-72845.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `Foo` + --> $DIR/issue-72845.rs:44:1 + | +LL | impl Foo for T { + | ------------------------ first implementation here +... +LL | impl Foo for T { + | ^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/const-generics/issues/issue-73120.rs b/src/test/ui/const-generics/issues/issue-73120.rs new file mode 100644 index 000000000..050dc9bde --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-73120.rs @@ -0,0 +1,10 @@ +// check-pass +// aux-build:const_generic_issues_lib.rs +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] +extern crate const_generic_issues_lib as lib2; +fn unused_function( + _: as lib2::TypeFn>::Output +) {} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-73260.rs b/src/test/ui/const-generics/issues/issue-73260.rs new file mode 100644 index 000000000..d762f9c8b --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-73260.rs @@ -0,0 +1,19 @@ +// compile-flags: -Zsave-analysis +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] +struct Arr +where + Assert::<{N < usize::MAX / 2}>: IsTrue, +{} + +enum Assert {} + +trait IsTrue {} + +impl IsTrue for Assert {} + +fn main() { + let x: Arr<{usize::MAX}> = Arr {}; + //~^ ERROR mismatched types + //~| ERROR mismatched types +} diff --git a/src/test/ui/const-generics/issues/issue-73260.stderr b/src/test/ui/const-generics/issues/issue-73260.stderr new file mode 100644 index 000000000..f1fc50e6e --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-73260.stderr @@ -0,0 +1,21 @@ +error[E0308]: mismatched types + --> $DIR/issue-73260.rs:16:12 + | +LL | let x: Arr<{usize::MAX}> = Arr {}; + | ^^^^^^^^^^^^^^^^^ expected `false`, found `true` + | + = note: expected type `false` + found type `true` + +error[E0308]: mismatched types + --> $DIR/issue-73260.rs:16:32 + | +LL | let x: Arr<{usize::MAX}> = Arr {}; + | ^^^ expected `false`, found `true` + | + = note: expected type `false` + found type `true` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/const-generics/issues/issue-73491.min.stderr b/src/test/ui/const-generics/issues/issue-73491.min.stderr new file mode 100644 index 000000000..f2b58e59f --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-73491.min.stderr @@ -0,0 +1,11 @@ +error: `[u32; _]` is forbidden as the type of a const generic parameter + --> $DIR/issue-73491.rs:8:19 + | +LL | fn hoge() {} + | ^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = help: more complex types are supported with `#![feature(adt_const_params)]` + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-73491.rs b/src/test/ui/const-generics/issues/issue-73491.rs new file mode 100644 index 000000000..f15c1f2d4 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-73491.rs @@ -0,0 +1,11 @@ +// [full] check-pass +// revisions: full min +#![cfg_attr(full, feature(adt_const_params))] +#![cfg_attr(full, allow(incomplete_features))] + +const LEN: usize = 1024; + +fn hoge() {} +//[min]~^ ERROR `[u32; _]` is forbidden as the type of a const generic parameter + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-73727-static-reference-array-const-param.min.stderr b/src/test/ui/const-generics/issues/issue-73727-static-reference-array-const-param.min.stderr new file mode 100644 index 000000000..0a7db6247 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-73727-static-reference-array-const-param.min.stderr @@ -0,0 +1,11 @@ +error: `&'static [u32]` is forbidden as the type of a const generic parameter + --> $DIR/issue-73727-static-reference-array-const-param.rs:9:15 + | +LL | fn a() {} + | ^^^^^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = help: more complex types are supported with `#![feature(adt_const_params)]` + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-73727-static-reference-array-const-param.rs b/src/test/ui/const-generics/issues/issue-73727-static-reference-array-const-param.rs new file mode 100644 index 000000000..f0d604835 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-73727-static-reference-array-const-param.rs @@ -0,0 +1,14 @@ +// Regression test for #73727 + +// revisions: full min +//[full]check-pass + +#![cfg_attr(full, feature(adt_const_params))] +#![cfg_attr(full, allow(incomplete_features))] + +fn a() {} +//[min]~^ ERROR `&'static [u32]` is forbidden as the type of a const generic parameter + +fn main() { + a::<{&[]}>(); +} diff --git a/src/test/ui/const-generics/issues/issue-74101.min.stderr b/src/test/ui/const-generics/issues/issue-74101.min.stderr new file mode 100644 index 000000000..82ffb2332 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-74101.min.stderr @@ -0,0 +1,20 @@ +error: `[u8; _]` is forbidden as the type of a const generic parameter + --> $DIR/issue-74101.rs:6:18 + | +LL | fn test() {} + | ^^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = help: more complex types are supported with `#![feature(adt_const_params)]` + +error: `[u8; _]` is forbidden as the type of a const generic parameter + --> $DIR/issue-74101.rs:9:21 + | +LL | struct Foo; + | ^^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = help: more complex types are supported with `#![feature(adt_const_params)]` + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/const-generics/issues/issue-74101.rs b/src/test/ui/const-generics/issues/issue-74101.rs new file mode 100644 index 000000000..6b606b946 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-74101.rs @@ -0,0 +1,12 @@ +// [full] check-pass +// revisions: full min +#![cfg_attr(full, feature(adt_const_params))] +#![cfg_attr(full, allow(incomplete_features))] + +fn test() {} +//[min]~^ ERROR `[u8; _]` is forbidden as the type of a const generic parameter + +struct Foo; +//[min]~^ ERROR `[u8; _]` is forbidden as the type of a const generic parameter + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-74255.min.stderr b/src/test/ui/const-generics/issues/issue-74255.min.stderr new file mode 100644 index 000000000..b462d8448 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-74255.min.stderr @@ -0,0 +1,11 @@ +error: `IceEnum` is forbidden as the type of a const generic parameter + --> $DIR/issue-74255.rs:14:31 + | +LL | fn ice_struct_fn() {} + | ^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = help: more complex types are supported with `#![feature(adt_const_params)]` + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-74255.rs b/src/test/ui/const-generics/issues/issue-74255.rs new file mode 100644 index 000000000..0e523926f --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-74255.rs @@ -0,0 +1,20 @@ +// [full] check-pass +// revisions: full min +#![cfg_attr(full, feature(adt_const_params))] +#![cfg_attr(full, allow(incomplete_features))] + +#[derive(PartialEq, Eq)] +enum IceEnum { + Variant +} + +struct IceStruct; + +impl IceStruct { + fn ice_struct_fn() {} + //[min]~^ ERROR `IceEnum` is forbidden as the type of a const generic parameter +} + +fn main() { + IceStruct::ice_struct_fn::<{IceEnum::Variant}>(); +} diff --git a/src/test/ui/const-generics/issues/issue-74906.rs b/src/test/ui/const-generics/issues/issue-74906.rs new file mode 100644 index 000000000..cc1f2853f --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-74906.rs @@ -0,0 +1,22 @@ +// edition:2018 +// check-pass + + +const SIZE: usize = 16; + +struct Bar {} + +struct Foo {} + +impl Foo { + async fn biz(_: &[[u8; SIZE]]) -> Vec<()> { + vec![] + } + + pub async fn baz(&self) -> Bar { + Self::biz(&vec![]).await; + Bar {} + } +} + +fn main() { } diff --git a/src/test/ui/const-generics/issues/issue-74950.min.stderr b/src/test/ui/const-generics/issues/issue-74950.min.stderr new file mode 100644 index 000000000..729ecc202 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-74950.min.stderr @@ -0,0 +1,47 @@ +error: `Inner` is forbidden as the type of a const generic parameter + --> $DIR/issue-74950.rs:17:23 + | +LL | struct Outer; + | ^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = help: more complex types are supported with `#![feature(adt_const_params)]` + +error: `Inner` is forbidden as the type of a const generic parameter + --> $DIR/issue-74950.rs:17:23 + | +LL | struct Outer; + | ^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = help: more complex types are supported with `#![feature(adt_const_params)]` + +error: `Inner` is forbidden as the type of a const generic parameter + --> $DIR/issue-74950.rs:17:23 + | +LL | struct Outer; + | ^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = help: more complex types are supported with `#![feature(adt_const_params)]` + +error: `Inner` is forbidden as the type of a const generic parameter + --> $DIR/issue-74950.rs:17:23 + | +LL | struct Outer; + | ^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = help: more complex types are supported with `#![feature(adt_const_params)]` + +error: `Inner` is forbidden as the type of a const generic parameter + --> $DIR/issue-74950.rs:17:23 + | +LL | struct Outer; + | ^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = help: more complex types are supported with `#![feature(adt_const_params)]` + +error: aborting due to 5 previous errors + diff --git a/src/test/ui/const-generics/issues/issue-74950.rs b/src/test/ui/const-generics/issues/issue-74950.rs new file mode 100644 index 000000000..3e1ca4735 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-74950.rs @@ -0,0 +1,24 @@ +// [full] build-pass +// revisions: full min +#![cfg_attr(full, feature(adt_const_params))] +#![cfg_attr(full, allow(incomplete_features))] + + +#[derive(PartialEq, Eq)] +struct Inner; + +// Note: We emit the error 5 times if we don't deduplicate: +// - struct definition +// - impl PartialEq +// - impl Eq +// - impl StructuralPartialEq +// - impl StructuralEq +#[derive(PartialEq, Eq)] +struct Outer; +//[min]~^ `Inner` is forbidden +//[min]~| `Inner` is forbidden +//[min]~| `Inner` is forbidden +//[min]~| `Inner` is forbidden +//[min]~| `Inner` is forbidden + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-75047.min.stderr b/src/test/ui/const-generics/issues/issue-75047.min.stderr new file mode 100644 index 000000000..7798ae796 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-75047.min.stderr @@ -0,0 +1,11 @@ +error: `[u8; _]` is forbidden as the type of a const generic parameter + --> $DIR/issue-75047.rs:14:21 + | +LL | struct Foo::value()]>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = help: more complex types are supported with `#![feature(adt_const_params)]` + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-75047.rs b/src/test/ui/const-generics/issues/issue-75047.rs new file mode 100644 index 000000000..ee3dcf9ec --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-75047.rs @@ -0,0 +1,17 @@ +// [full] check-pass +// revisions: full min +#![cfg_attr(full, feature(adt_const_params))] +#![cfg_attr(full, allow(incomplete_features))] + +struct Bar(T); + +impl Bar { + const fn value() -> usize { + 42 + } +} + +struct Foo::value()]>; +//[min]~^ ERROR `[u8; _]` is forbidden as the type of a const generic parameter + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-75299.rs b/src/test/ui/const-generics/issues/issue-75299.rs new file mode 100644 index 000000000..83ef09af8 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-75299.rs @@ -0,0 +1,8 @@ +// compile-flags: -Zmir-opt-level=4 +// run-pass +fn main() { + fn foo() -> [u8; N] { + [0; N] + } + let _x = foo::<1>(); +} diff --git a/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.rs b/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.rs new file mode 100644 index 000000000..2e6b02236 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.rs @@ -0,0 +1,11 @@ +fn ty_param() -> [u8; std::mem::size_of::()] { + //~^ ERROR generic parameters may not be used in const operations + todo!() +} + +fn const_param() -> [u8; N + 1] { + //~^ ERROR generic parameters may not be used in const operations + todo!() +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.stderr b/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.stderr new file mode 100644 index 000000000..3b53e18e6 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.stderr @@ -0,0 +1,20 @@ +error: generic parameters may not be used in const operations + --> $DIR/issue-76701-ty-param-in-const.rs:1:46 + | +LL | fn ty_param() -> [u8; std::mem::size_of::()] { + | ^ cannot perform const operation using `T` + | + = note: type parameters may not be used in const expressions + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions + +error: generic parameters may not be used in const operations + --> $DIR/issue-76701-ty-param-in-const.rs:6:42 + | +LL | fn const_param() -> [u8; N + 1] { + | ^ cannot perform const operation using `N` + | + = help: const parameters may only be used as standalone arguments, i.e. `N` + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/const-generics/issues/issue-77357.rs b/src/test/ui/const-generics/issues/issue-77357.rs new file mode 100644 index 000000000..3cb8d3846 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-77357.rs @@ -0,0 +1,11 @@ +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +trait MyTrait {} + +fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> { + //~^ ERROR overly complex generic constant + todo!() +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-77357.stderr b/src/test/ui/const-generics/issues/issue-77357.stderr new file mode 100644 index 000000000..804c0ae51 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-77357.stderr @@ -0,0 +1,11 @@ +error: overly complex generic constant + --> $DIR/issue-77357.rs:6:46 + | +LL | fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ blocks are not supported in generic constant + | + = help: consider moving this anonymous constant into a `const` function + = note: this operation may be supported in the future + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-79674.rs b/src/test/ui/const-generics/issues/issue-79674.rs new file mode 100644 index 000000000..ff141d328 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-79674.rs @@ -0,0 +1,28 @@ +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +trait MiniTypeId { + const TYPE_ID: u64; +} + +impl MiniTypeId for T { + const TYPE_ID: u64 = 0; +} + +enum Lift {} + +trait IsFalse {} +impl IsFalse for Lift {} + +const fn is_same_type() -> bool { + T::TYPE_ID == U::TYPE_ID +} + +fn requires_distinct(_a: A, _b: B) where + A: MiniTypeId, B: MiniTypeId, + Lift<{is_same_type::()}>: IsFalse {} + +fn main() { + requires_distinct("str", 12); + //~^ ERROR mismatched types +} diff --git a/src/test/ui/const-generics/issues/issue-79674.stderr b/src/test/ui/const-generics/issues/issue-79674.stderr new file mode 100644 index 000000000..8c029289c --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-79674.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/issue-79674.rs:26:5 + | +LL | requires_distinct("str", 12); + | ^^^^^^^^^^^^^^^^^ expected `true`, found `false` + | + = note: expected type `true` + found type `false` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/const-generics/issues/issue-80062.rs b/src/test/ui/const-generics/issues/issue-80062.rs new file mode 100644 index 000000000..56dc53298 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-80062.rs @@ -0,0 +1,10 @@ +// Regression test for issue #80062 (fixed by `min_const_generics`) + +fn sof() -> T { unimplemented!() } + +fn test() { + let _: [u8; sof::()]; + //~^ ERROR generic parameters may not be used in const operations +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-80062.stderr b/src/test/ui/const-generics/issues/issue-80062.stderr new file mode 100644 index 000000000..754f18d5c --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-80062.stderr @@ -0,0 +1,11 @@ +error: generic parameters may not be used in const operations + --> $DIR/issue-80062.rs:6:23 + | +LL | let _: [u8; sof::()]; + | ^ cannot perform const operation using `T` + | + = note: type parameters may not be used in const expressions + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-80375.rs b/src/test/ui/const-generics/issues/issue-80375.rs new file mode 100644 index 000000000..c906bb2c4 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-80375.rs @@ -0,0 +1,4 @@ +struct MyArray([u8; COUNT + 1]); +//~^ ERROR generic parameters may not be used in const operations + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-80375.stderr b/src/test/ui/const-generics/issues/issue-80375.stderr new file mode 100644 index 000000000..5409002a9 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-80375.stderr @@ -0,0 +1,11 @@ +error: generic parameters may not be used in const operations + --> $DIR/issue-80375.rs:1:41 + | +LL | struct MyArray([u8; COUNT + 1]); + | ^^^^^ cannot perform const operation using `COUNT` + | + = help: const parameters may only be used as standalone arguments, i.e. `COUNT` + = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-82956.rs b/src/test/ui/const-generics/issues/issue-82956.rs new file mode 100644 index 000000000..3539e9b96 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-82956.rs @@ -0,0 +1,33 @@ +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +pub struct ConstCheck; + +pub trait True {} +impl True for ConstCheck {} + +pub trait OrdesDec { + type Newlen; + type Output; + + fn pop(self) -> (Self::Newlen, Self::Output); +} + +impl OrdesDec for [T; N] +where + ConstCheck<{N > 1}>: True, + [T; N - 1]: Sized, +{ + type Newlen = [T; N - 1]; + type Output = T; + + fn pop(self) -> (Self::Newlen, Self::Output) { + let mut iter = IntoIter::new(self); + //~^ ERROR: failed to resolve: use of undeclared type `IntoIter` + let end = iter.next_back().unwrap(); + let new = [(); N - 1].map(move |()| iter.next().unwrap()); + (new, end) + } +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-82956.stderr b/src/test/ui/const-generics/issues/issue-82956.stderr new file mode 100644 index 000000000..c8b999da9 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-82956.stderr @@ -0,0 +1,21 @@ +error[E0433]: failed to resolve: use of undeclared type `IntoIter` + --> $DIR/issue-82956.rs:25:24 + | +LL | let mut iter = IntoIter::new(self); + | ^^^^^^^^ not found in this scope + | +help: consider importing one of these items + | +LL | use std::array::IntoIter; + | +LL | use std::collections::binary_heap::IntoIter; + | +LL | use std::collections::btree_map::IntoIter; + | +LL | use std::collections::btree_set::IntoIter; + | + and 8 other candidates + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0433`. diff --git a/src/test/ui/const-generics/issues/issue-83249.rs b/src/test/ui/const-generics/issues/issue-83249.rs new file mode 100644 index 000000000..65148c55e --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-83249.rs @@ -0,0 +1,23 @@ +#![allow(incomplete_features)] +#![feature(generic_const_exprs)] + +trait Foo { + const N: usize; +} + +impl Foo for u8 { + const N: usize = 1; +} + +fn foo(_: [u8; T::N]) -> T { + todo!() +} + +pub fn bar() { + let _: u8 = foo([0; 1]); + + let _ = foo([0; 1]); + //~^ ERROR type annotations needed +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-83249.stderr b/src/test/ui/const-generics/issues/issue-83249.stderr new file mode 100644 index 000000000..362b8554b --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-83249.stderr @@ -0,0 +1,14 @@ +error[E0282]: type annotations needed + --> $DIR/issue-83249.rs:19:9 + | +LL | let _ = foo([0; 1]); + | ^ + | +help: consider giving this pattern a type + | +LL | let _: _ = foo([0; 1]); + | +++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/src/test/ui/const-generics/issues/issue-83288.rs b/src/test/ui/const-generics/issues/issue-83288.rs new file mode 100644 index 000000000..a24596d24 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-83288.rs @@ -0,0 +1,69 @@ +// build-pass + +#![allow(incomplete_features)] +#![feature(generic_const_exprs)] + +use std::{marker::PhantomData, ops::Mul}; + +pub enum Nil {} +pub struct Cons { + _phantom: PhantomData<(T, L)>, +} + +pub trait Indices { + const RANK: usize; + const NUM_ELEMS: usize; +} + +impl Indices for Nil { + const RANK: usize = 0; + const NUM_ELEMS: usize = 1; +} + +impl, const N: usize> Indices for Cons { + const RANK: usize = I::RANK + 1; + const NUM_ELEMS: usize = I::NUM_ELEMS * N; +} + +pub trait Concat { + type Output; +} + +impl Concat for Nil { + type Output = J; +} + +impl Concat for Cons +where + I: Concat, +{ + type Output = Cons>::Output>; +} + +pub struct Tensor, const N: usize> +where + [u8; I::NUM_ELEMS]: Sized, +{ + pub data: [u8; I::NUM_ELEMS], + _phantom: PhantomData, +} + +impl, J: Indices, const N: usize> Mul> for Tensor +where + I: Concat, + >::Output: Indices, + [u8; I::NUM_ELEMS]: Sized, + [u8; J::NUM_ELEMS]: Sized, + [u8; >::Output::NUM_ELEMS]: Sized, +{ + type Output = Tensor<>::Output, N>; + + fn mul(self, _rhs: Tensor) -> Self::Output { + Tensor { + data: [0u8; >::Output::NUM_ELEMS], + _phantom: PhantomData, + } + } +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-83466.rs b/src/test/ui/const-generics/issues/issue-83466.rs new file mode 100644 index 000000000..c488a663f --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-83466.rs @@ -0,0 +1,17 @@ +// regression test for #83466- tests that generic arg mismatch errors between +// consts and types are not supressed when there are explicit late bound lifetimes + +struct S; +impl S { + fn func<'a, U>(self) -> U { + todo!() + } +} +fn dont_crash<'a, U>() { + S.func::<'a, 10_u32>() + //~^ WARNING cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + //~^^ WARNING this was previously accepted by + //~^^^ ERROR constant provided when a type was expected [E0747] +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-83466.stderr b/src/test/ui/const-generics/issues/issue-83466.stderr new file mode 100644 index 000000000..a60f71ea6 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-83466.stderr @@ -0,0 +1,22 @@ +warning: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/issue-83466.rs:11:14 + | +LL | fn func<'a, U>(self) -> U { + | -- the late bound lifetime parameter is introduced here +... +LL | S.func::<'a, 10_u32>() + | ^^ + | + = note: `#[warn(late_bound_lifetime_arguments)]` on by default + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #42868 + +error[E0747]: constant provided when a type was expected + --> $DIR/issue-83466.rs:11:18 + | +LL | S.func::<'a, 10_u32>() + | ^^^^^^ + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0747`. diff --git a/src/test/ui/const-generics/issues/issue-83765.rs b/src/test/ui/const-generics/issues/issue-83765.rs new file mode 100644 index 000000000..71c164ab0 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-83765.rs @@ -0,0 +1,116 @@ +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +trait TensorDimension { + const DIM: usize; + //~^ ERROR cycle detected when resolving instance + // FIXME Given the current state of the compiler its expected that we cycle here, + // but the cycle is still wrong. + const ISSCALAR: bool = Self::DIM == 0; + fn is_scalar(&self) -> bool { + Self::ISSCALAR + } +} + +trait TensorSize: TensorDimension { + fn size(&self) -> [usize; Self::DIM]; + fn inbounds(&self, index: [usize; Self::DIM]) -> bool { + index.iter().zip(self.size().iter()).all(|(i, s)| i < s) + } +} + +trait Broadcastable: TensorSize + Sized { + type Element; + fn bget(&self, index: [usize; Self::DIM]) -> Option; + fn lazy_updim( + &self, + size: [usize; NEWDIM], + ) -> LazyUpdim { + assert!( + NEWDIM >= Self::DIM, + "Updimmed tensor cannot have fewer indices than the initial one." + ); + LazyUpdim { size, reference: &self } + } + fn bmap T>(&self, foo: F) -> BMap { + BMap { reference: self, closure: foo } + } +} + +struct LazyUpdim<'a, T: Broadcastable, const OLDDIM: usize, const DIM: usize> { + size: [usize; DIM], + reference: &'a T, +} + +impl<'a, T: Broadcastable, const DIM: usize> TensorDimension for LazyUpdim<'a, T, { T::DIM }, DIM> { + const DIM: usize = DIM; +} + +impl<'a, T: Broadcastable, const DIM: usize> TensorSize for LazyUpdim<'a, T, { T::DIM }, DIM> { + fn size(&self) -> [usize; DIM] { + self.size + } +} + +impl<'a, T: Broadcastable, const DIM: usize> Broadcastable for LazyUpdim<'a, T, { T::DIM }, DIM> { + type Element = T::Element; + fn bget(&self, index: [usize; DIM]) -> Option { + assert!(DIM >= T::DIM); + if !self.inbounds(index) { + return None; + } + let size = self.size(); + let newindex: [usize; T::DIM] = Default::default(); + self.reference.bget(newindex) + } +} + +struct BMap<'a, R, T: Broadcastable, F: Fn(T::Element) -> R, const DIM: usize> { + reference: &'a T, + closure: F, +} + +impl<'a, R, T: Broadcastable, F: Fn(T::Element) -> R, const DIM: usize> TensorDimension + for BMap<'a, R, T, F, DIM> +{ + const DIM: usize = DIM; +} +impl<'a, R, T: Broadcastable, F: Fn(T::Element) -> R, const DIM: usize> TensorSize + for BMap<'a, R, T, F, DIM> +{ + fn size(&self) -> [usize; DIM] { + self.reference.size() + } +} + +impl<'a, R, T: Broadcastable, F: Fn(T::Element) -> R, const DIM: usize> Broadcastable + for BMap<'a, R, T, F, DIM> +{ + type Element = R; + fn bget(&self, index: [usize; DIM]) -> Option { + self.reference.bget(index).map(&self.closure) + } +} + +impl TensorDimension for Vec { + const DIM: usize = 1; +} +impl TensorSize for Vec { + fn size(&self) -> [usize; 1] { + [self.len()] + } +} +impl Broadcastable for Vec { + type Element = T; + fn bget(&self, index: [usize; 1]) -> Option { + self.get(index[0]).cloned() + } +} + +fn main() { + let v = vec![1, 2, 3]; + let bv = v.lazy_updim([3, 4]); + let bbv = bv.bmap(|x| x * x); + + println!("The size of v is {:?}", bbv.bget([0, 2]).expect("Out of bounds.")); +} diff --git a/src/test/ui/const-generics/issues/issue-83765.stderr b/src/test/ui/const-generics/issues/issue-83765.stderr new file mode 100644 index 000000000..28ddddf1b --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-83765.stderr @@ -0,0 +1,21 @@ +error[E0391]: cycle detected when resolving instance ` as TensorDimension>::DIM` + --> $DIR/issue-83765.rs:5:5 + | +LL | const DIM: usize; + | ^^^^^^^^^^^^^^^^ + | +note: ...which requires checking if `TensorDimension` fulfills its obligations... + --> $DIR/issue-83765.rs:4:1 + | +LL | trait TensorDimension { + | ^^^^^^^^^^^^^^^^^^^^^ + = note: ...which again requires resolving instance ` as TensorDimension>::DIM`, completing the cycle +note: cycle used when checking if `TensorDimension` fulfills its obligations + --> $DIR/issue-83765.rs:4:1 + | +LL | trait TensorDimension { + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/src/test/ui/const-generics/issues/issue-83993.rs b/src/test/ui/const-generics/issues/issue-83993.rs new file mode 100644 index 000000000..f2f05d952 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-83993.rs @@ -0,0 +1,14 @@ +// check-pass + +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +fn bug<'a>() +where + for<'b> [(); { + let x: &'b (); + 0 + }]: +{} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-84659.rs b/src/test/ui/const-generics/issues/issue-84659.rs new file mode 100644 index 000000000..440ca740a --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-84659.rs @@ -0,0 +1,12 @@ +#![allow(incomplete_features)] +#![feature(generic_const_exprs)] + +trait Bar {} + +trait Foo<'a> { + const N: usize; + type Baz: Bar<{ Self::N }>; + //~^ ERROR: unconstrained generic constant +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-84659.stderr b/src/test/ui/const-generics/issues/issue-84659.stderr new file mode 100644 index 000000000..2dfc48a34 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-84659.stderr @@ -0,0 +1,10 @@ +error: unconstrained generic constant + --> $DIR/issue-84659.rs:8:15 + | +LL | type Baz: Bar<{ Self::N }>; + | ^^^^^^^^^^^^^^^^ + | + = help: try adding a `where` bound using this expression: `where [(); { Self::N }]:` + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-86033.rs b/src/test/ui/const-generics/issues/issue-86033.rs new file mode 100644 index 000000000..cf08f722f --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-86033.rs @@ -0,0 +1,20 @@ +// check-pass + +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +pub trait IsTrue {} +impl IsTrue for () {} + +pub trait IsZST {} + +impl IsZST for T +where + (): IsTrue<{ std::mem::size_of::() == 0 }> +{} + +fn _func() -> impl IsZST { + || {} +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-86530.rs b/src/test/ui/const-generics/issues/issue-86530.rs new file mode 100644 index 000000000..b024decd4 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-86530.rs @@ -0,0 +1,20 @@ +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +pub trait X { + const Y: usize; +} + +fn z(t: T) +where + T: X, + [(); T::Y]: , +{ +} + +fn unit_literals() { + z(" "); + //~^ ERROR: the trait bound `&str: X` is not satisfied +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-86530.stderr b/src/test/ui/const-generics/issues/issue-86530.stderr new file mode 100644 index 000000000..c63857b23 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-86530.stderr @@ -0,0 +1,20 @@ +error[E0277]: the trait bound `&str: X` is not satisfied + --> $DIR/issue-86530.rs:16:7 + | +LL | z(" "); + | - ^^^ the trait `X` is not implemented for `&str` + | | + | required by a bound introduced by this call + | +note: required by a bound in `z` + --> $DIR/issue-86530.rs:10:8 + | +LL | fn z(t: T) + | - required by a bound in this +LL | where +LL | T: X, + | ^ required by this bound in `z` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/const-generics/issues/issue-86535-2.rs b/src/test/ui/const-generics/issues/issue-86535-2.rs new file mode 100644 index 000000000..0b535fd66 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-86535-2.rs @@ -0,0 +1,19 @@ +// run-pass +#![feature(adt_const_params, generic_const_exprs)] +#![allow(incomplete_features)] + +pub trait Foo { + const ASSOC_C: usize; + fn foo() where [(); Self::ASSOC_C]:; +} + +struct Bar; +impl Foo for Bar { + const ASSOC_C: usize = 3; + + fn foo() where [u8; Self::ASSOC_C]: { + let _: [u8; Self::ASSOC_C] = loop {}; + } +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-86535.rs b/src/test/ui/const-generics/issues/issue-86535.rs new file mode 100644 index 000000000..5289c4e99 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-86535.rs @@ -0,0 +1,20 @@ +// run-pass +#![feature(adt_const_params, generic_const_exprs)] +#![allow(incomplete_features, unused_variables)] + +struct F; +impl X for F<{ S }> { + const W: usize = 3; + + fn d(r: &[u8; Self::W]) -> F<{ S }> { + let x: [u8; Self::W] = [0; Self::W]; + F + } +} + +pub trait X { + const W: usize; + fn d(r: &[u8; Self::W]) -> Self; +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-86820.rs b/src/test/ui/const-generics/issues/issue-86820.rs new file mode 100644 index 000000000..ae4bd943f --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-86820.rs @@ -0,0 +1,24 @@ +// Regression test for the ICE described in #86820. + +#![allow(unused, dead_code)] +use std::ops::BitAnd; + +const C: fn() = || is_set(); +fn is_set() { + 0xffu8.bit::<0>(); +} + +trait Bits { + fn bit(self) -> bool; +} + +impl Bits for u8 { + fn bit(self) -> bool { + //~^ ERROR: method `bit` has an incompatible generic parameter for trait `Bits` [E0053] + let i = 1 << I; + let mask = u8::from(i); + mask & self == mask + } +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-86820.stderr b/src/test/ui/const-generics/issues/issue-86820.stderr new file mode 100644 index 000000000..3a9cd957f --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-86820.stderr @@ -0,0 +1,16 @@ +error[E0053]: method `bit` has an incompatible generic parameter for trait `Bits` + --> $DIR/issue-86820.rs:16:12 + | +LL | trait Bits { + | ---- +LL | fn bit(self) -> bool; + | ----------- expected const parameter of type `u8` +... +LL | impl Bits for u8 { + | ---------------- +LL | fn bit(self) -> bool { + | ^^^^^^^^^^^^^^ found const parameter of type `usize` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0053`. diff --git a/src/test/ui/const-generics/issues/issue-87076.rs b/src/test/ui/const-generics/issues/issue-87076.rs new file mode 100644 index 000000000..8a567678b --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-87076.rs @@ -0,0 +1,20 @@ +// build-pass + +#![feature(adt_const_params)] +#![allow(incomplete_features)] + +#[derive(PartialEq, Eq)] +pub struct UnitDims { + pub time: u8, + pub length: u8, +} + +pub struct UnitValue; + +impl UnitValue { + fn crash() {} +} + +fn main() { + UnitValue::<{ UnitDims { time: 1, length: 2 } }>::crash(); +} diff --git a/src/test/ui/const-generics/issues/issue-87470.rs b/src/test/ui/const-generics/issues/issue-87470.rs new file mode 100644 index 000000000..d60181a41 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-87470.rs @@ -0,0 +1,24 @@ +// build-pass + +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +pub trait TraitWithConst { + const SOME_CONST: usize; +} + +pub trait OtherTrait: TraitWithConst { + fn some_fn(self) -> [u8 ; ::SOME_CONST]; +} + +impl TraitWithConst for f32 { + const SOME_CONST: usize = 32; +} + +impl OtherTrait for f32 { + fn some_fn(self) -> [u8 ; ::SOME_CONST] { + [0; 32] + } +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-87493.rs b/src/test/ui/const-generics/issues/issue-87493.rs new file mode 100644 index 000000000..d8599ab22 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-87493.rs @@ -0,0 +1,14 @@ +pub trait MyTrait { + type Assoc; +} + +pub fn foo(_s: S, _t: T) +where + S: MyTrait, + T: MyTrait, + //~^ ERROR: expected one of `,` or `>`, found `==` + //~| ERROR: this trait takes 0 generic arguments but 1 generic argument was supplied +{ +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-87493.stderr b/src/test/ui/const-generics/issues/issue-87493.stderr new file mode 100644 index 000000000..f998c1187 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-87493.stderr @@ -0,0 +1,28 @@ +error: expected one of `,` or `>`, found `==` + --> $DIR/issue-87493.rs:8:22 + | +LL | T: MyTrait, + | ^^ expected one of `,` or `>` + | +help: if you meant to use an associated type binding, replace `==` with `=` + | +LL | T: MyTrait, + | ~ + +error[E0107]: this trait takes 0 generic arguments but 1 generic argument was supplied + --> $DIR/issue-87493.rs:8:8 + | +LL | T: MyTrait, + | ^^^^^^^ ----------------- help: replace the generic bound with the associated type: `Assoc = Assoc == S::Assoc` + | | + | expected 0 generic arguments + | +note: trait defined here, with 0 generic parameters + --> $DIR/issue-87493.rs:1:11 + | +LL | pub trait MyTrait { + | ^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0107`. diff --git a/src/test/ui/const-generics/issues/issue-87964.rs b/src/test/ui/const-generics/issues/issue-87964.rs new file mode 100644 index 000000000..116686abb --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-87964.rs @@ -0,0 +1,29 @@ +// build-pass + +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +pub trait Target { + const LENGTH: usize; +} + + +pub struct Container +where + [(); T::LENGTH]: Sized, +{ + _target: T, +} + +impl Container +where + [(); T::LENGTH]: Sized, +{ + pub fn start( + _target: T, + ) -> Container { + Container { _target } + } +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-88119.rs b/src/test/ui/const-generics/issues/issue-88119.rs new file mode 100644 index 000000000..70dfa7f70 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-88119.rs @@ -0,0 +1,35 @@ +// check-pass + +#![allow(incomplete_features)] +#![feature(const_trait_impl, generic_const_exprs)] + +trait ConstName { + const NAME_BYTES: &'static [u8]; +} + +impl const ConstName for u8 { + const NAME_BYTES: &'static [u8] = b"u8"; +} + +const fn name_len() -> usize { + T::NAME_BYTES.len() +} + +impl const ConstName for &T +where + [(); name_len::()]:, +{ + const NAME_BYTES: &'static [u8] = b"&T"; +} + +impl const ConstName for &mut T +where + [(); name_len::()]:, +{ + const NAME_BYTES: &'static [u8] = b"&mut T"; +} + +pub const ICE_1: &'static [u8] = <&&mut u8 as ConstName>::NAME_BYTES; +pub const ICE_2: &'static [u8] = <&mut &u8 as ConstName>::NAME_BYTES; + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-88468.rs b/src/test/ui/const-generics/issues/issue-88468.rs new file mode 100644 index 000000000..914047236 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-88468.rs @@ -0,0 +1,13 @@ +// check-pass + +#![allow(incomplete_features)] +#![feature(generic_const_exprs)] + +pub struct Assert(); +pub trait IsTrue {} +impl IsTrue for Assert {} + +pub trait IsNotZST {} +impl IsNotZST for T where Assert<{ std::mem::size_of::() > 0 }>: IsTrue {} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-88997.rs b/src/test/ui/const-generics/issues/issue-88997.rs new file mode 100644 index 000000000..7666a5141 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-88997.rs @@ -0,0 +1,14 @@ +#![allow(incomplete_features)] +#![feature(generic_const_exprs)] + +struct ConstAssert; +trait True {} +impl True for ConstAssert {} + +struct Range(T) +//~^ ERROR the type of const parameters must not depend on other generic parameters +//~| ERROR the type of const parameters must not depend on other generic parameters +where + ConstAssert<{ MIN <= MAX }>: True; + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-88997.stderr b/src/test/ui/const-generics/issues/issue-88997.stderr new file mode 100644 index 000000000..505ba0da2 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-88997.stderr @@ -0,0 +1,15 @@ +error[E0770]: the type of const parameters must not depend on other generic parameters + --> $DIR/issue-88997.rs:8:40 + | +LL | struct Range(T) + | ^ the type must not depend on the parameter `T` + +error[E0770]: the type of const parameters must not depend on other generic parameters + --> $DIR/issue-88997.rs:8:54 + | +LL | struct Range(T) + | ^ the type must not depend on the parameter `T` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0770`. diff --git a/src/test/ui/const-generics/issues/issue-89146.rs b/src/test/ui/const-generics/issues/issue-89146.rs new file mode 100644 index 000000000..e3540f46f --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-89146.rs @@ -0,0 +1,26 @@ +// build-pass + +#![allow(incomplete_features)] +#![feature(generic_const_exprs)] + +pub trait Foo { + const SIZE: usize; + + fn to_bytes(&self) -> [u8; Self::SIZE]; +} + +pub fn bar(a: &G) -> u8 +where + [(); G::SIZE]: Sized, +{ + deeper_bar(a) +} + +fn deeper_bar(a: &G) -> u8 +where + [(); G::SIZE]: Sized, +{ + a.to_bytes()[0] +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-89304.rs b/src/test/ui/const-generics/issues/issue-89304.rs new file mode 100644 index 000000000..d544d637c --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-89304.rs @@ -0,0 +1,20 @@ +// check-pass + +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +struct GenericStruct { val: i64 } + +impl From> for GenericStruct<{T + 1}> { + fn from(other: GenericStruct) -> Self { + Self { val: other.val } + } +} + +impl From> for GenericStruct { + fn from(other: GenericStruct<{T + 1}>) -> Self { + Self { val: other.val } + } +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-89320.rs b/src/test/ui/const-generics/issues/issue-89320.rs new file mode 100644 index 000000000..afa5c8fab --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-89320.rs @@ -0,0 +1,19 @@ +// build-pass + +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +pub trait Enumerable { + const N: usize; +} + +#[derive(Clone)] +pub struct SymmetricGroup +where + S: Enumerable, + [(); S::N]: Sized, +{ + _phantom: std::marker::PhantomData, +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-89334.rs b/src/test/ui/const-generics/issues/issue-89334.rs new file mode 100644 index 000000000..b15b7428c --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-89334.rs @@ -0,0 +1,16 @@ +// build-pass + +#![feature(generic_const_exprs)] +#![allow(unused_braces, incomplete_features)] + +pub trait AnotherTrait{ + const ARRAY_SIZE: usize; +} +pub trait Shard: + AsMut<[[u8; T::ARRAY_SIZE]]> +where + [(); T::ARRAY_SIZE]: Sized +{ +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-90318.rs b/src/test/ui/const-generics/issues/issue-90318.rs new file mode 100644 index 000000000..d6c48e63b --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-90318.rs @@ -0,0 +1,30 @@ +#![feature(const_type_id)] +#![feature(generic_const_exprs)] +#![feature(core_intrinsics)] +#![allow(incomplete_features)] + +use std::any::TypeId; + +struct If; +pub trait True {} +impl True for If {} + +fn consume(_val: T) +where + If<{ TypeId::of::() != TypeId::of::<()>() }>: True, + //~^ ERROR: can't compare +{ +} + +fn test() +where + If<{ TypeId::of::() != TypeId::of::<()>() }>: True, + //~^ ERROR: can't compare +{ +} + +fn main() { + let a = (); + consume(0i32); + consume(a); +} diff --git a/src/test/ui/const-generics/issues/issue-90318.stderr b/src/test/ui/const-generics/issues/issue-90318.stderr new file mode 100644 index 000000000..aba4b5c1a --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-90318.stderr @@ -0,0 +1,29 @@ +error[E0277]: can't compare `TypeId` with `_` in const contexts + --> $DIR/issue-90318.rs:14:28 + | +LL | If<{ TypeId::of::() != TypeId::of::<()>() }>: True, + | ^^ no implementation for `TypeId == _` + | + = help: the trait `~const PartialEq<_>` is not implemented for `TypeId` +note: the trait `PartialEq<_>` is implemented for `TypeId`, but that implementation is not `const` + --> $DIR/issue-90318.rs:14:28 + | +LL | If<{ TypeId::of::() != TypeId::of::<()>() }>: True, + | ^^ + +error[E0277]: can't compare `TypeId` with `_` in const contexts + --> $DIR/issue-90318.rs:21:28 + | +LL | If<{ TypeId::of::() != TypeId::of::<()>() }>: True, + | ^^ no implementation for `TypeId == _` + | + = help: the trait `~const PartialEq<_>` is not implemented for `TypeId` +note: the trait `PartialEq<_>` is implemented for `TypeId`, but that implementation is not `const` + --> $DIR/issue-90318.rs:21:28 + | +LL | If<{ TypeId::of::() != TypeId::of::<()>() }>: True, + | ^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/const-generics/issues/issue-90364.rs b/src/test/ui/const-generics/issues/issue-90364.rs new file mode 100644 index 000000000..b11b07b50 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-90364.rs @@ -0,0 +1,9 @@ +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +pub struct Foo(T) +//~^ ERROR the type of const parameters must not depend on other generic parameters +where + [(); 1]:; + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-90364.stderr b/src/test/ui/const-generics/issues/issue-90364.stderr new file mode 100644 index 000000000..e85bd136e --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-90364.stderr @@ -0,0 +1,9 @@ +error[E0770]: the type of const parameters must not depend on other generic parameters + --> $DIR/issue-90364.rs:4:28 + | +LL | pub struct Foo(T) + | ^ the type must not depend on the parameter `T` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0770`. diff --git a/src/test/ui/const-generics/issues/issue-90455.rs b/src/test/ui/const-generics/issues/issue-90455.rs new file mode 100644 index 000000000..a580410cf --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-90455.rs @@ -0,0 +1,12 @@ +#![feature(generic_const_exprs, adt_const_params)] +#![allow(incomplete_features)] + +struct FieldElement { + n: [u64; num_limbs(N)], + //~^ ERROR unconstrained generic constant +} +const fn num_limbs(_: &str) -> usize { + 0 +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-90455.stderr b/src/test/ui/const-generics/issues/issue-90455.stderr new file mode 100644 index 000000000..724d7f42e --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-90455.stderr @@ -0,0 +1,10 @@ +error: unconstrained generic constant + --> $DIR/issue-90455.rs:5:8 + | +LL | n: [u64; num_limbs(N)], + | ^^^^^^^^^^^^^^^^^^^ + | + = help: try adding a `where` bound using this expression: `where [(); num_limbs(N)]:` + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-92186.rs b/src/test/ui/const-generics/issues/issue-92186.rs new file mode 100644 index 000000000..9ced4667d --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-92186.rs @@ -0,0 +1,12 @@ +// check-pass + +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +pub struct Foo; +pub trait Bar {} + +impl Bar for Foo<{ 1 }> {} +impl Bar for Foo<{ 2 }> {} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-96654.rs b/src/test/ui/const-generics/issues/issue-96654.rs new file mode 100644 index 000000000..8cf786dbe --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-96654.rs @@ -0,0 +1,15 @@ +// check-pass + +struct A {} + +struct B {} + +impl B { + const M: u32 = M; +} + +struct C { + a: A<{ B::<1>::M }>, +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-97278.rs b/src/test/ui/const-generics/issues/issue-97278.rs new file mode 100644 index 000000000..da0a9776f --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-97278.rs @@ -0,0 +1,14 @@ +#![feature(adt_const_params)] +#![allow(incomplete_features)] + +use std::sync::Arc; + +#[derive(PartialEq, Eq)] +enum Bar { + Bar(Arc) +} + +fn test() {} +//~^ ERROR `Arc` must be annotated with `#[derive(PartialEq, Eq)]` + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-97278.stderr b/src/test/ui/const-generics/issues/issue-97278.stderr new file mode 100644 index 000000000..ff13cb505 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-97278.stderr @@ -0,0 +1,9 @@ +error[E0741]: `Arc` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter + --> $DIR/issue-97278.rs:11:20 + | +LL | fn test() {} + | ^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0741`. diff --git a/src/test/ui/const-generics/issues/issue-97634.rs b/src/test/ui/const-generics/issues/issue-97634.rs new file mode 100644 index 000000000..422e8de68 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-97634.rs @@ -0,0 +1,10 @@ +// build-pass + +pub enum Register { + Field0 = 40, + Field1, +} + +fn main() { + let _b = Register::<0>::Field1 as u16; +} diff --git a/src/test/ui/const-generics/issues/issue-98629.rs b/src/test/ui/const-generics/issues/issue-98629.rs new file mode 100644 index 000000000..fc8666bbc --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-98629.rs @@ -0,0 +1,15 @@ +#![feature(const_trait_impl)] + +trait Trait { + const N: usize; +} + +impl const Trait for i32 {} +//~^ ERROR not all trait items implemented, missing: `N` + +fn f() +where + [(); ::N]:, +{} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-98629.stderr b/src/test/ui/const-generics/issues/issue-98629.stderr new file mode 100644 index 000000000..535702208 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-98629.stderr @@ -0,0 +1,12 @@ +error[E0046]: not all trait items implemented, missing: `N` + --> $DIR/issue-98629.rs:7:1 + | +LL | const N: usize; + | -------------- `N` from trait +... +LL | impl const Trait for i32 {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ missing `N` in implementation + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0046`. diff --git a/src/test/ui/const-generics/issues/issue-99641.rs b/src/test/ui/const-generics/issues/issue-99641.rs new file mode 100644 index 000000000..fae6d3fc4 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-99641.rs @@ -0,0 +1,18 @@ +#![feature(adt_const_params)] +#![allow(incomplete_features)] + +fn main() { + pub struct Color; + //~^ ERROR using function pointers + + impl Color { + //~^ ERROR using function pointers + pub fn new() -> Self { + Color:: + } + } + + pub const D65: (fn(),) = (|| {},); + + Color::::new(); +} diff --git a/src/test/ui/const-generics/issues/issue-99641.stderr b/src/test/ui/const-generics/issues/issue-99641.stderr new file mode 100644 index 000000000..349ebba08 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-99641.stderr @@ -0,0 +1,15 @@ +error[E0741]: using function pointers as const generic parameters is forbidden + --> $DIR/issue-99641.rs:5:35 + | +LL | pub struct Color; + | ^^^^^^^ + +error[E0741]: using function pointers as const generic parameters is forbidden + --> $DIR/issue-99641.rs:8:23 + | +LL | impl Color { + | ^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0741`. -- cgit v1.2.3