summaryrefslogtreecommitdiffstats
path: root/tests/ui/const-generics
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/const-generics')
-rw-r--r--tests/ui/const-generics/adt_const_params/const_param_ty_bad.rs13
-rw-r--r--tests/ui/const-generics/adt_const_params/const_param_ty_bad.stderr87
-rw-r--r--tests/ui/const-generics/adt_const_params/const_param_ty_bad_empty_array.rs12
-rw-r--r--tests/ui/const-generics/adt_const_params/const_param_ty_bad_empty_array.stderr16
-rw-r--r--tests/ui/const-generics/adt_const_params/const_param_ty_generic_bounds_do_not_hold.rs13
-rw-r--r--tests/ui/const-generics/adt_const_params/const_param_ty_generic_bounds_do_not_hold.stderr42
-rw-r--r--tests/ui/const-generics/adt_const_params/const_param_ty_good.rs53
-rw-r--r--tests/ui/const-generics/adt_const_params/const_param_ty_impl_bad_field.rs17
-rw-r--r--tests/ui/const-generics/adt_const_params/const_param_ty_impl_bad_field.stderr23
-rw-r--r--tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.rs21
-rw-r--r--tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.stderr22
-rw-r--r--tests/ui/const-generics/adt_const_params/const_param_ty_impl_union.rs33
-rw-r--r--tests/ui/const-generics/adt_const_params/const_param_ty_impl_union.stderr8
-rw-r--r--tests/ui/const-generics/assoc_const_as_type_argument.rs13
-rw-r--r--tests/ui/const-generics/assoc_const_as_type_argument.stderr21
-rw-r--r--tests/ui/const-generics/assoc_const_eq_diagnostic.rs1
-rw-r--r--tests/ui/const-generics/assoc_const_eq_diagnostic.stderr16
-rw-r--r--tests/ui/const-generics/const-arg-in-const-arg.full.stderr163
-rw-r--r--tests/ui/const-generics/const-arg-in-const-arg.min.stderr206
-rw-r--r--tests/ui/const-generics/const-arg-in-const-arg.rs60
-rw-r--r--tests/ui/const-generics/const-argument-non-static-lifetime.min.stderr9
-rw-r--r--tests/ui/const-generics/const-argument-non-static-lifetime.rs2
-rw-r--r--tests/ui/const-generics/const-param-type-depends-on-const-param.full.stderr4
-rw-r--r--tests/ui/const-generics/const-param-type-depends-on-const-param.min.stderr4
-rw-r--r--tests/ui/const-generics/const-param-type-depends-on-type-param-ungated.stderr2
-rw-r--r--tests/ui/const-generics/const-param-type-depends-on-type-param.full.stderr2
-rw-r--r--tests/ui/const-generics/const-param-type-depends-on-type-param.min.stderr2
-rw-r--r--tests/ui/const-generics/defaults/trait_objects_fail.stderr4
-rw-r--r--tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr6
-rw-r--r--tests/ui/const-generics/generic_const_exprs/issue-74713.rs2
-rw-r--r--tests/ui/const-generics/generic_const_exprs/issue-74713.stderr11
-rw-r--r--tests/ui/const-generics/generic_const_exprs/nested_uneval_unification-2.rs24
-rw-r--r--tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.rs10
-rw-r--r--tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.stderr11
-rw-r--r--tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.rs3
-rw-r--r--tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.stderr11
-rw-r--r--tests/ui/const-generics/generic_const_exprs/unresolved_lifetimes_error.rs12
-rw-r--r--tests/ui/const-generics/generic_const_exprs/unresolved_lifetimes_error.stderr11
-rw-r--r--tests/ui/const-generics/issue-46511.rs2
-rw-r--r--tests/ui/const-generics/issue-46511.stderr11
-rw-r--r--tests/ui/const-generics/issues/issue-105821.rs2
-rw-r--r--tests/ui/const-generics/issues/issue-56445-1.full.stderr8
-rw-r--r--tests/ui/const-generics/issues/issue-56445-1.min.stderr8
-rw-r--r--tests/ui/const-generics/issues/issue-56445-1.rs2
-rw-r--r--tests/ui/const-generics/issues/issue-62878.full.stderr2
-rw-r--r--tests/ui/const-generics/issues/issue-62878.min.stderr2
-rw-r--r--tests/ui/const-generics/issues/issue-71169.full.stderr2
-rw-r--r--tests/ui/const-generics/issues/issue-71169.min.stderr2
-rw-r--r--tests/ui/const-generics/issues/issue-71381.full.stderr4
-rw-r--r--tests/ui/const-generics/issues/issue-71381.min.stderr4
-rw-r--r--tests/ui/const-generics/issues/issue-71611.full.stderr2
-rw-r--r--tests/ui/const-generics/issues/issue-71611.min.stderr2
-rw-r--r--tests/ui/const-generics/issues/issue-77357.rs11
-rw-r--r--tests/ui/const-generics/issues/issue-77357.stderr11
-rw-r--r--tests/ui/const-generics/issues/issue-83993.rs14
-rw-r--r--tests/ui/const-generics/issues/issue-88997.stderr4
-rw-r--r--tests/ui/const-generics/issues/issue-90364.stderr2
-rw-r--r--tests/ui/const-generics/late-bound-vars/in_closure.rs20
-rw-r--r--tests/ui/const-generics/late-bound-vars/in_closure.stderr13
-rw-r--r--tests/ui/const-generics/late-bound-vars/simple.rs19
-rw-r--r--tests/ui/const-generics/late-bound-vars/simple.stderr13
-rw-r--r--tests/ui/const-generics/min_const_generics/forbid-non-static-lifetimes.rs4
-rw-r--r--tests/ui/const-generics/min_const_generics/forbid-non-static-lifetimes.stderr17
-rw-r--r--tests/ui/const-generics/nested-type.rs6
-rw-r--r--tests/ui/const-generics/occurs-check/unused-substs-2.rs8
-rw-r--r--tests/ui/const-generics/occurs-check/unused-substs-3.rs8
-rw-r--r--tests/ui/const-generics/outer-lifetime-in-const-generic-default.rs2
-rw-r--r--tests/ui/const-generics/outer-lifetime-in-const-generic-default.stderr8
-rw-r--r--tests/ui/const-generics/sneaky-array-repeat-expr.rs2
-rw-r--r--tests/ui/const-generics/sneaky-array-repeat-expr.stderr20
-rw-r--r--tests/ui/const-generics/transmute-fail.stderr8
-rw-r--r--tests/ui/const-generics/variant-discrimiant-no-generics.full.stderr34
-rw-r--r--tests/ui/const-generics/variant-discrimiant-no-generics.min.stderr34
-rw-r--r--tests/ui/const-generics/variant-discrimiant-no-generics.rs32
74 files changed, 890 insertions, 423 deletions
diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_bad.rs b/tests/ui/const-generics/adt_const_params/const_param_ty_bad.rs
new file mode 100644
index 000000000..0da68ae75
--- /dev/null
+++ b/tests/ui/const-generics/adt_const_params/const_param_ty_bad.rs
@@ -0,0 +1,13 @@
+#![allow(incomplete_features)]
+#![feature(adt_const_params)]
+
+fn check(_: impl std::marker::ConstParamTy) {}
+
+fn main() {
+ check(main); //~ error: `fn() {main}` can't be used as a const parameter type
+ check(|| {}); //~ error: `[closure@$DIR/const_param_ty_bad.rs:8:11: 8:13]` can't be used as a const parameter type
+ check(main as fn()); //~ error: `fn()` can't be used as a const parameter type
+ check(&mut ()); //~ error: `&mut ()` can't be used as a const parameter type
+ check(&mut () as *mut ()); //~ error: `*mut ()` can't be used as a const parameter type
+ check(&() as *const ()); //~ error: `*const ()` can't be used as a const parameter type
+}
diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_bad.stderr b/tests/ui/const-generics/adt_const_params/const_param_ty_bad.stderr
new file mode 100644
index 000000000..de5704ee4
--- /dev/null
+++ b/tests/ui/const-generics/adt_const_params/const_param_ty_bad.stderr
@@ -0,0 +1,87 @@
+error[E0277]: `fn() {main}` can't be used as a const parameter type
+ --> $DIR/const_param_ty_bad.rs:7:11
+ |
+LL | check(main);
+ | ----- ^^^^ the trait `ConstParamTy` is not implemented for fn item `fn() {main}`
+ | |
+ | required by a bound introduced by this call
+ |
+note: required by a bound in `check`
+ --> $DIR/const_param_ty_bad.rs:4:18
+ |
+LL | fn check(_: impl std::marker::ConstParamTy) {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
+
+error[E0277]: `[closure@$DIR/const_param_ty_bad.rs:8:11: 8:13]` can't be used as a const parameter type
+ --> $DIR/const_param_ty_bad.rs:8:11
+ |
+LL | check(|| {});
+ | ----- ^^^^^ the trait `ConstParamTy` is not implemented for closure `[closure@$DIR/const_param_ty_bad.rs:8:11: 8:13]`
+ | |
+ | required by a bound introduced by this call
+ |
+note: required by a bound in `check`
+ --> $DIR/const_param_ty_bad.rs:4:18
+ |
+LL | fn check(_: impl std::marker::ConstParamTy) {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
+
+error[E0277]: `fn()` can't be used as a const parameter type
+ --> $DIR/const_param_ty_bad.rs:9:11
+ |
+LL | check(main as fn());
+ | ----- ^^^^^^^^^^^^ the trait `ConstParamTy` is not implemented for `fn()`
+ | |
+ | required by a bound introduced by this call
+ |
+note: required by a bound in `check`
+ --> $DIR/const_param_ty_bad.rs:4:18
+ |
+LL | fn check(_: impl std::marker::ConstParamTy) {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
+
+error[E0277]: `&mut ()` can't be used as a const parameter type
+ --> $DIR/const_param_ty_bad.rs:10:11
+ |
+LL | check(&mut ());
+ | ----- ^^^^^^^ the trait `ConstParamTy` is not implemented for `&mut ()`
+ | |
+ | required by a bound introduced by this call
+ |
+note: required by a bound in `check`
+ --> $DIR/const_param_ty_bad.rs:4:18
+ |
+LL | fn check(_: impl std::marker::ConstParamTy) {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
+
+error[E0277]: `*mut ()` can't be used as a const parameter type
+ --> $DIR/const_param_ty_bad.rs:11:11
+ |
+LL | check(&mut () as *mut ());
+ | ----- ^^^^^^^^^^^^^^^^^^ the trait `ConstParamTy` is not implemented for `*mut ()`
+ | |
+ | required by a bound introduced by this call
+ |
+note: required by a bound in `check`
+ --> $DIR/const_param_ty_bad.rs:4:18
+ |
+LL | fn check(_: impl std::marker::ConstParamTy) {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
+
+error[E0277]: `*const ()` can't be used as a const parameter type
+ --> $DIR/const_param_ty_bad.rs:12:11
+ |
+LL | check(&() as *const ());
+ | ----- ^^^^^^^^^^^^^^^^ the trait `ConstParamTy` is not implemented for `*const ()`
+ | |
+ | required by a bound introduced by this call
+ |
+note: required by a bound in `check`
+ --> $DIR/const_param_ty_bad.rs:4:18
+ |
+LL | fn check(_: impl std::marker::ConstParamTy) {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
+
+error: aborting due to 6 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_bad_empty_array.rs b/tests/ui/const-generics/adt_const_params/const_param_ty_bad_empty_array.rs
new file mode 100644
index 000000000..b0e3b13cc
--- /dev/null
+++ b/tests/ui/const-generics/adt_const_params/const_param_ty_bad_empty_array.rs
@@ -0,0 +1,12 @@
+#![allow(incomplete_features)]
+#![feature(adt_const_params)]
+
+#[derive(PartialEq, Eq)]
+struct NotParam;
+
+fn check<T: std::marker::ConstParamTy>() {}
+
+fn main() {
+ check::<[NotParam; 0]>();
+ //~^ error: `NotParam` can't be used as a const parameter type
+}
diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_bad_empty_array.stderr b/tests/ui/const-generics/adt_const_params/const_param_ty_bad_empty_array.stderr
new file mode 100644
index 000000000..ef55242df
--- /dev/null
+++ b/tests/ui/const-generics/adt_const_params/const_param_ty_bad_empty_array.stderr
@@ -0,0 +1,16 @@
+error[E0277]: `NotParam` can't be used as a const parameter type
+ --> $DIR/const_param_ty_bad_empty_array.rs:10:13
+ |
+LL | check::<[NotParam; 0]>();
+ | ^^^^^^^^^^^^^ the trait `ConstParamTy` is not implemented for `NotParam`
+ |
+ = note: required for `[NotParam; 0]` to implement `ConstParamTy`
+note: required by a bound in `check`
+ --> $DIR/const_param_ty_bad_empty_array.rs:7:13
+ |
+LL | fn check<T: std::marker::ConstParamTy>() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_generic_bounds_do_not_hold.rs b/tests/ui/const-generics/adt_const_params/const_param_ty_generic_bounds_do_not_hold.rs
new file mode 100644
index 000000000..e4dc76703
--- /dev/null
+++ b/tests/ui/const-generics/adt_const_params/const_param_ty_generic_bounds_do_not_hold.rs
@@ -0,0 +1,13 @@
+#![allow(incomplete_features)]
+#![feature(adt_const_params)]
+
+#[derive(PartialEq, Eq)]
+struct NotParam;
+
+fn check<T: std::marker::ConstParamTy + ?Sized>() {}
+
+fn main() {
+ check::<&NotParam>(); //~ error: `NotParam` can't be used as a const parameter type
+ check::<[NotParam]>(); //~ error: `NotParam` can't be used as a const parameter type
+ check::<[NotParam; 17]>(); //~ error: `NotParam` can't be used as a const parameter type
+}
diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_generic_bounds_do_not_hold.stderr b/tests/ui/const-generics/adt_const_params/const_param_ty_generic_bounds_do_not_hold.stderr
new file mode 100644
index 000000000..86d1c94e8
--- /dev/null
+++ b/tests/ui/const-generics/adt_const_params/const_param_ty_generic_bounds_do_not_hold.stderr
@@ -0,0 +1,42 @@
+error[E0277]: `NotParam` can't be used as a const parameter type
+ --> $DIR/const_param_ty_generic_bounds_do_not_hold.rs:10:13
+ |
+LL | check::<&NotParam>();
+ | ^^^^^^^^^ the trait `ConstParamTy` is not implemented for `NotParam`
+ |
+ = note: required for `&NotParam` to implement `ConstParamTy`
+note: required by a bound in `check`
+ --> $DIR/const_param_ty_generic_bounds_do_not_hold.rs:7:13
+ |
+LL | fn check<T: std::marker::ConstParamTy + ?Sized>() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
+
+error[E0277]: `NotParam` can't be used as a const parameter type
+ --> $DIR/const_param_ty_generic_bounds_do_not_hold.rs:11:13
+ |
+LL | check::<[NotParam]>();
+ | ^^^^^^^^^^ the trait `ConstParamTy` is not implemented for `NotParam`
+ |
+ = note: required for `[NotParam]` to implement `ConstParamTy`
+note: required by a bound in `check`
+ --> $DIR/const_param_ty_generic_bounds_do_not_hold.rs:7:13
+ |
+LL | fn check<T: std::marker::ConstParamTy + ?Sized>() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
+
+error[E0277]: `NotParam` can't be used as a const parameter type
+ --> $DIR/const_param_ty_generic_bounds_do_not_hold.rs:12:13
+ |
+LL | check::<[NotParam; 17]>();
+ | ^^^^^^^^^^^^^^ the trait `ConstParamTy` is not implemented for `NotParam`
+ |
+ = note: required for `[NotParam; 17]` to implement `ConstParamTy`
+note: required by a bound in `check`
+ --> $DIR/const_param_ty_generic_bounds_do_not_hold.rs:7:13
+ |
+LL | fn check<T: std::marker::ConstParamTy + ?Sized>() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check`
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_good.rs b/tests/ui/const-generics/adt_const_params/const_param_ty_good.rs
new file mode 100644
index 000000000..87ae83dd9
--- /dev/null
+++ b/tests/ui/const-generics/adt_const_params/const_param_ty_good.rs
@@ -0,0 +1,53 @@
+// check-pass
+#![allow(incomplete_features)]
+#![feature(adt_const_params)]
+use std::marker::ConstParamTy;
+
+#[derive(PartialEq, Eq)]
+struct S<T> {
+ field: u8,
+ gen: T,
+}
+
+impl<T: ConstParamTy> ConstParamTy for S<T> {}
+
+#[derive(PartialEq, Eq, ConstParamTy)]
+struct D<T> {
+ field: u8,
+ gen: T,
+}
+
+
+fn check<T: ConstParamTy + ?Sized>() {}
+
+fn main() {
+ check::<u8>();
+ check::<u16>();
+ check::<u32>();
+ check::<u64>();
+ check::<u128>();
+
+ check::<i8>();
+ check::<i16>();
+ check::<i32>();
+ check::<i64>();
+ check::<i128>();
+
+ check::<char>();
+ check::<bool>();
+ check::<str>();
+
+ check::<&u8>();
+ check::<&str>();
+ check::<[usize]>();
+ check::<[u16; 0]>();
+ check::<[u8; 42]>();
+
+ check::<S<u8>>();
+ check::<S<[&[bool]; 8]>>();
+
+ check::<D<u8>>();
+ check::<D<[&[bool]; 8]>>();
+
+ // FIXME: test tuples
+}
diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_bad_field.rs b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_bad_field.rs
new file mode 100644
index 000000000..74283a37a
--- /dev/null
+++ b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_bad_field.rs
@@ -0,0 +1,17 @@
+#![allow(incomplete_features)]
+#![feature(adt_const_params)]
+
+#[derive(PartialEq, Eq)]
+struct NotParam;
+
+#[derive(PartialEq, Eq)]
+struct CantParam(NotParam);
+
+impl std::marker::ConstParamTy for CantParam {}
+//~^ error: the trait `ConstParamTy` cannot be implemented for this type
+
+#[derive(std::marker::ConstParamTy, Eq, PartialEq)]
+//~^ error: the trait `ConstParamTy` cannot be implemented for this type
+struct CantParamDerive(NotParam);
+
+fn main() {}
diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_bad_field.stderr b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_bad_field.stderr
new file mode 100644
index 000000000..52b65d606
--- /dev/null
+++ b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_bad_field.stderr
@@ -0,0 +1,23 @@
+error[E0204]: the trait `ConstParamTy` cannot be implemented for this type
+ --> $DIR/const_param_ty_impl_bad_field.rs:10:36
+ |
+LL | struct CantParam(NotParam);
+ | -------- this field does not implement `ConstParamTy`
+LL |
+LL | impl std::marker::ConstParamTy for CantParam {}
+ | ^^^^^^^^^
+
+error[E0204]: the trait `ConstParamTy` cannot be implemented for this type
+ --> $DIR/const_param_ty_impl_bad_field.rs:13:10
+ |
+LL | #[derive(std::marker::ConstParamTy, Eq, PartialEq)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |
+LL | struct CantParamDerive(NotParam);
+ | -------- this field does not implement `ConstParamTy`
+ |
+ = note: this error originates in the derive macro `std::marker::ConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0204`.
diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.rs b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.rs
new file mode 100644
index 000000000..37986de48
--- /dev/null
+++ b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.rs
@@ -0,0 +1,21 @@
+#![allow(incomplete_features)]
+#![feature(adt_const_params)]
+
+#[derive(PartialEq, Eq)]
+struct ImplementsConstParamTy;
+impl std::marker::ConstParamTy for ImplementsConstParamTy {}
+
+struct CantParam(ImplementsConstParamTy);
+
+impl std::marker::ConstParamTy for CantParam {}
+//~^ error: the type `CantParam` does not `#[derive(Eq)]`
+
+#[derive(std::marker::ConstParamTy)]
+//~^ error: the type `CantParamDerive` does not `#[derive(Eq)]`
+struct CantParamDerive(ImplementsConstParamTy);
+
+fn check<T: std::marker::ConstParamTy>() {}
+
+fn main() {
+ check::<ImplementsConstParamTy>();
+}
diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.stderr b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.stderr
new file mode 100644
index 000000000..52701d559
--- /dev/null
+++ b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.stderr
@@ -0,0 +1,22 @@
+error[E0277]: the type `CantParam` does not `#[derive(Eq)]`
+ --> $DIR/const_param_ty_impl_no_structural_eq.rs:10:36
+ |
+LL | impl std::marker::ConstParamTy for CantParam {}
+ | ^^^^^^^^^ the trait `StructuralEq` is not implemented for `CantParam`
+ |
+note: required by a bound in `ConstParamTy`
+ --> $SRC_DIR/core/src/marker.rs:LL:COL
+
+error[E0277]: the type `CantParamDerive` does not `#[derive(Eq)]`
+ --> $DIR/const_param_ty_impl_no_structural_eq.rs:13:10
+ |
+LL | #[derive(std::marker::ConstParamTy)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `StructuralEq` is not implemented for `CantParamDerive`
+ |
+note: required by a bound in `ConstParamTy`
+ --> $SRC_DIR/core/src/marker.rs:LL:COL
+ = note: this error originates in the derive macro `std::marker::ConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_union.rs b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_union.rs
new file mode 100644
index 000000000..d70377a20
--- /dev/null
+++ b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_union.rs
@@ -0,0 +1,33 @@
+#![allow(incomplete_features)]
+#![feature(adt_const_params, structural_match)]
+
+union Union {
+ a: u8,
+}
+
+impl PartialEq for Union {
+ fn eq(&self, other: &Union) -> bool {
+ true
+ }
+}
+impl Eq for Union {}
+impl std::marker::StructuralEq for Union {}
+
+impl std::marker::ConstParamTy for Union {}
+
+#[derive(std::marker::ConstParamTy)]
+//~^ ERROR this trait cannot be derived for unions
+union UnionDerive {
+ a: u8,
+}
+
+impl PartialEq for UnionDerive {
+ fn eq(&self, other: &UnionDerive) -> bool {
+ true
+ }
+}
+impl Eq for UnionDerive {}
+impl std::marker::StructuralEq for UnionDerive {}
+
+
+fn main() {}
diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_union.stderr b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_union.stderr
new file mode 100644
index 000000000..293703046
--- /dev/null
+++ b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_union.stderr
@@ -0,0 +1,8 @@
+error: this trait cannot be derived for unions
+ --> $DIR/const_param_ty_impl_union.rs:18:10
+ |
+LL | #[derive(std::marker::ConstParamTy)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/const-generics/assoc_const_as_type_argument.rs b/tests/ui/const-generics/assoc_const_as_type_argument.rs
new file mode 100644
index 000000000..ffc7f116a
--- /dev/null
+++ b/tests/ui/const-generics/assoc_const_as_type_argument.rs
@@ -0,0 +1,13 @@
+trait Trait {
+ const ASSOC: usize;
+}
+
+fn bar<const N: usize>() {}
+
+fn foo<T: Trait>() {
+ bar::<<T as Trait>::ASSOC>();
+ //~^ ERROR: expected associated type, found associated constant `Trait::ASSOC`
+ //~| ERROR: unresolved item provided when a constant was expected
+}
+
+fn main() {}
diff --git a/tests/ui/const-generics/assoc_const_as_type_argument.stderr b/tests/ui/const-generics/assoc_const_as_type_argument.stderr
new file mode 100644
index 000000000..ac0095461
--- /dev/null
+++ b/tests/ui/const-generics/assoc_const_as_type_argument.stderr
@@ -0,0 +1,21 @@
+error[E0575]: expected associated type, found associated constant `Trait::ASSOC`
+ --> $DIR/assoc_const_as_type_argument.rs:8:11
+ |
+LL | bar::<<T as Trait>::ASSOC>();
+ | ^^^^^^^^^^^^^^^^^^^ not a associated type
+
+error[E0747]: unresolved item provided when a constant was expected
+ --> $DIR/assoc_const_as_type_argument.rs:8:11
+ |
+LL | bar::<<T as Trait>::ASSOC>();
+ | ^^^^^^^^^^^^^^^^^^^
+ |
+help: if this generic argument was intended as a const parameter, surround it with braces
+ |
+LL | bar::<{ <T as Trait>::ASSOC }>();
+ | + +
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0575, E0747.
+For more information about an error, try `rustc --explain E0575`.
diff --git a/tests/ui/const-generics/assoc_const_eq_diagnostic.rs b/tests/ui/const-generics/assoc_const_eq_diagnostic.rs
index 4d0aaf88e..bf8202ac1 100644
--- a/tests/ui/const-generics/assoc_const_eq_diagnostic.rs
+++ b/tests/ui/const-generics/assoc_const_eq_diagnostic.rs
@@ -10,6 +10,7 @@ pub trait Parse {
pub trait CoolStuff: Parse<MODE = Mode::Cool> {}
//~^ ERROR expected associated constant bound
+//~| ERROR expected associated constant bound
//~| ERROR expected type
fn no_help() -> Mode::Cool {}
diff --git a/tests/ui/const-generics/assoc_const_eq_diagnostic.stderr b/tests/ui/const-generics/assoc_const_eq_diagnostic.stderr
index ba727ee0e..d7e5e50cb 100644
--- a/tests/ui/const-generics/assoc_const_eq_diagnostic.stderr
+++ b/tests/ui/const-generics/assoc_const_eq_diagnostic.stderr
@@ -8,7 +8,7 @@ LL | pub trait CoolStuff: Parse<MODE = Mode::Cool> {}
| help: try using the variant's enum: `Mode`
error[E0573]: expected type, found variant `Mode::Cool`
- --> $DIR/assoc_const_eq_diagnostic.rs:15:17
+ --> $DIR/assoc_const_eq_diagnostic.rs:16:17
|
LL | fn no_help() -> Mode::Cool {}
| ^^^^^^^^^^
@@ -28,6 +28,18 @@ note: associated constant defined here
LL | const MODE: Mode;
| ^^^^^^^^^^^^^^^^
-error: aborting due to 3 previous errors
+error: expected associated constant bound, found type
+ --> $DIR/assoc_const_eq_diagnostic.rs:11:28
+ |
+LL | pub trait CoolStuff: Parse<MODE = Mode::Cool> {}
+ | ^^^^^^^^^^^^^^^^^ help: if equating a const, try wrapping with braces: `MODE = { const }`
+ |
+note: associated constant defined here
+ --> $DIR/assoc_const_eq_diagnostic.rs:8:5
+ |
+LL | const MODE: Mode;
+ | ^^^^^^^^^^^^^^^^
+
+error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0573`.
diff --git a/tests/ui/const-generics/const-arg-in-const-arg.full.stderr b/tests/ui/const-generics/const-arg-in-const-arg.full.stderr
deleted file mode 100644
index 463a37d7e..000000000
--- a/tests/ui/const-generics/const-arg-in-const-arg.full.stderr
+++ /dev/null
@@ -1,163 +0,0 @@
-error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
- --> $DIR/const-arg-in-const-arg.rs:18:23
- |
-LL | let _: [u8; faz::<'a>(&())];
- | ^^
- |
-note: the late bound lifetime parameter is introduced here
- --> $DIR/const-arg-in-const-arg.rs:8:14
- |
-LL | const fn faz<'a>(_: &'a ()) -> usize { 13 }
- | ^^
-
-error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
- --> $DIR/const-arg-in-const-arg.rs:21:23
- |
-LL | let _: [u8; faz::<'b>(&())];
- | ^^
- |
-note: the late bound lifetime parameter is introduced here
- --> $DIR/const-arg-in-const-arg.rs:8:14
- |
-LL | const fn faz<'a>(_: &'a ()) -> usize { 13 }
- | ^^
-
-error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
- --> $DIR/const-arg-in-const-arg.rs:41:24
- |
-LL | let _: Foo<{ faz::<'a>(&()) }>;
- | ^^
- |
-note: the late bound lifetime parameter is introduced here
- --> $DIR/const-arg-in-const-arg.rs:8:14
- |
-LL | const fn faz<'a>(_: &'a ()) -> usize { 13 }
- | ^^
-
-error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
- --> $DIR/const-arg-in-const-arg.rs:44:24
- |
-LL | let _: Foo<{ faz::<'b>(&()) }>;
- | ^^
- |
-note: the late bound lifetime parameter is introduced here
- --> $DIR/const-arg-in-const-arg.rs:8:14
- |
-LL | const fn faz<'a>(_: &'a ()) -> usize { 13 }
- | ^^
-
-error: unconstrained generic constant
- --> $DIR/const-arg-in-const-arg.rs:13:12
- |
-LL | let _: [u8; foo::<T>()];
- | ^^^^^^^^^^^^^^^^
- |
- = help: try adding a `where` bound using this expression: `where [(); foo::<T>()]:`
-
-error: unconstrained generic constant
- --> $DIR/const-arg-in-const-arg.rs:15:12
- |
-LL | let _: [u8; bar::<N>()];
- | ^^^^^^^^^^^^^^^^
- |
- = help: try adding a `where` bound using this expression: `where [(); bar::<N>()]:`
-
-error: unconstrained generic constant
- --> $DIR/const-arg-in-const-arg.rs:36:12
- |
-LL | let _: Foo<{ foo::<T>() }>;
- | ^^^^^^^^^^^^^^^^^^^
- |
- = help: try adding a `where` bound using this expression: `where [(); { foo::<T>() }]:`
-
-error: unconstrained generic constant
- --> $DIR/const-arg-in-const-arg.rs:38:12
- |
-LL | let _: Foo<{ bar::<N>() }>;
- | ^^^^^^^^^^^^^^^^^^^
- |
- = help: try adding a `where` bound using this expression: `where [(); { bar::<N>() }]:`
-
-error: unconstrained generic constant
- --> $DIR/const-arg-in-const-arg.rs:25:17
- |
-LL | let _ = [0; foo::<T>()];
- | ^^^^^^^^^^
- |
- = help: try adding a `where` bound using this expression: `where [(); foo::<T>()]:`
-
-error: unconstrained generic constant
- --> $DIR/const-arg-in-const-arg.rs:27:17
- |
-LL | let _ = [0; bar::<N>()];
- | ^^^^^^^^^^
- |
- = help: try adding a `where` bound using this expression: `where [(); bar::<N>()]:`
-
-error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
- --> $DIR/const-arg-in-const-arg.rs:30:23
- |
-LL | let _ = [0; faz::<'a>(&())];
- | ^^
- |
-note: the late bound lifetime parameter is introduced here
- --> $DIR/const-arg-in-const-arg.rs:8:14
- |
-LL | const fn faz<'a>(_: &'a ()) -> usize { 13 }
- | ^^
-
-error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
- --> $DIR/const-arg-in-const-arg.rs:33:23
- |
-LL | let _ = [0; faz::<'b>(&())];
- | ^^
- |
-note: the late bound lifetime parameter is introduced here
- --> $DIR/const-arg-in-const-arg.rs:8:14
- |
-LL | const fn faz<'a>(_: &'a ()) -> usize { 13 }
- | ^^
-
-error: unconstrained generic constant
- --> $DIR/const-arg-in-const-arg.rs:47:19
- |
-LL | let _ = Foo::<{ foo::<T>() }>;
- | ^^^^^^^^^^^^^^
- |
- = help: try adding a `where` bound using this expression: `where [(); { foo::<T>() }]:`
-
-error: unconstrained generic constant
- --> $DIR/const-arg-in-const-arg.rs:49:19
- |
-LL | let _ = Foo::<{ bar::<N>() }>;
- | ^^^^^^^^^^^^^^
- |
- = help: try adding a `where` bound using this expression: `where [(); { bar::<N>() }]:`
-
-error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
- --> $DIR/const-arg-in-const-arg.rs:52:27
- |
-LL | let _ = Foo::<{ faz::<'a>(&()) }>;
- | ^^
- |
-note: the late bound lifetime parameter is introduced here
- --> $DIR/const-arg-in-const-arg.rs:8:14
- |
-LL | const fn faz<'a>(_: &'a ()) -> usize { 13 }
- | ^^
-
-error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
- --> $DIR/const-arg-in-const-arg.rs:55:27
- |
-LL | let _ = Foo::<{ faz::<'b>(&()) }>;
- | ^^
- |
-note: the late bound lifetime parameter is introduced here
- --> $DIR/const-arg-in-const-arg.rs:8:14
- |
-LL | const fn faz<'a>(_: &'a ()) -> usize { 13 }
- | ^^
-
-error: aborting due to 16 previous errors
-
-For more information about this error, try `rustc --explain E0794`.
diff --git a/tests/ui/const-generics/const-arg-in-const-arg.min.stderr b/tests/ui/const-generics/const-arg-in-const-arg.min.stderr
index a7bd9c62b..f1f22e234 100644
--- a/tests/ui/const-generics/const-arg-in-const-arg.min.stderr
+++ b/tests/ui/const-generics/const-arg-in-const-arg.min.stderr
@@ -1,5 +1,5 @@
error: generic parameters may not be used in const operations
- --> $DIR/const-arg-in-const-arg.rs:13:23
+ --> $DIR/const-arg-in-const-arg.rs:15:23
|
LL | let _: [u8; foo::<T>()];
| ^ cannot perform const operation using `T`
@@ -8,7 +8,7 @@ LL | let _: [u8; foo::<T>()];
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
- --> $DIR/const-arg-in-const-arg.rs:15:23
+ --> $DIR/const-arg-in-const-arg.rs:16:23
|
LL | let _: [u8; bar::<N>()];
| ^ cannot perform const operation using `N`
@@ -16,44 +16,44 @@ LL | let _: [u8; bar::<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[E0658]: a non-static lifetime is not allowed in a `const`
+error: generic parameters may not be used in const operations
--> $DIR/const-arg-in-const-arg.rs:18:23
|
LL | let _: [u8; faz::<'a>(&())];
- | ^^
+ | ^^ cannot perform const operation using `'a`
|
- = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
- = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
+ = note: lifetime parameters may not be used in const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
-error[E0658]: a non-static lifetime is not allowed in a `const`
+error: generic parameters may not be used in const operations
--> $DIR/const-arg-in-const-arg.rs:20:23
|
LL | let _: [u8; baz::<'a>(&())];
- | ^^
+ | ^^ cannot perform const operation using `'a`
|
- = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
- = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
+ = note: lifetime parameters may not be used in const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
-error[E0658]: a non-static lifetime is not allowed in a `const`
+error: generic parameters may not be used in const operations
--> $DIR/const-arg-in-const-arg.rs:21:23
|
LL | let _: [u8; faz::<'b>(&())];
- | ^^
+ | ^^ cannot perform const operation using `'b`
|
- = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
- = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
+ = note: lifetime parameters may not be used in const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
-error[E0658]: a non-static lifetime is not allowed in a `const`
+error: generic parameters may not be used in const operations
--> $DIR/const-arg-in-const-arg.rs:23:23
|
LL | let _: [u8; baz::<'b>(&())];
- | ^^
+ | ^^ cannot perform const operation using `'b`
|
- = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
- = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
+ = note: lifetime 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/const-arg-in-const-arg.rs:27:23
+ --> $DIR/const-arg-in-const-arg.rs:26:23
|
LL | let _ = [0; bar::<N>()];
| ^ cannot perform const operation using `N`
@@ -61,44 +61,44 @@ LL | let _ = [0; bar::<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[E0658]: a non-static lifetime is not allowed in a `const`
- --> $DIR/const-arg-in-const-arg.rs:30:23
+error: generic parameters may not be used in const operations
+ --> $DIR/const-arg-in-const-arg.rs:28:23
|
LL | let _ = [0; faz::<'a>(&())];
- | ^^
+ | ^^ cannot perform const operation using `'a`
|
- = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
- = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
+ = note: lifetime parameters may not be used in const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
-error[E0658]: a non-static lifetime is not allowed in a `const`
- --> $DIR/const-arg-in-const-arg.rs:32:23
+error: generic parameters may not be used in const operations
+ --> $DIR/const-arg-in-const-arg.rs:30:23
|
LL | let _ = [0; baz::<'a>(&())];
- | ^^
+ | ^^ cannot perform const operation using `'a`
|
- = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
- = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
+ = note: lifetime parameters may not be used in const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
-error[E0658]: a non-static lifetime is not allowed in a `const`
- --> $DIR/const-arg-in-const-arg.rs:33:23
+error: generic parameters may not be used in const operations
+ --> $DIR/const-arg-in-const-arg.rs:31:23
|
LL | let _ = [0; faz::<'b>(&())];
- | ^^
+ | ^^ cannot perform const operation using `'b`
|
- = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
- = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
+ = note: lifetime parameters may not be used in const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
-error[E0658]: a non-static lifetime is not allowed in a `const`
- --> $DIR/const-arg-in-const-arg.rs:35:23
+error: generic parameters may not be used in const operations
+ --> $DIR/const-arg-in-const-arg.rs:33:23
|
LL | let _ = [0; baz::<'b>(&())];
- | ^^
+ | ^^ cannot perform const operation using `'b`
|
- = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
- = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
+ = note: lifetime 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/const-arg-in-const-arg.rs:36:24
+ --> $DIR/const-arg-in-const-arg.rs:34:24
|
LL | let _: Foo<{ foo::<T>() }>;
| ^ cannot perform const operation using `T`
@@ -107,7 +107,7 @@ LL | let _: Foo<{ foo::<T>() }>;
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
- --> $DIR/const-arg-in-const-arg.rs:38:24
+ --> $DIR/const-arg-in-const-arg.rs:35:24
|
LL | let _: Foo<{ bar::<N>() }>;
| ^ cannot perform const operation using `N`
@@ -115,44 +115,44 @@ LL | let _: Foo<{ bar::<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[E0658]: a non-static lifetime is not allowed in a `const`
- --> $DIR/const-arg-in-const-arg.rs:41:24
+error: generic parameters may not be used in const operations
+ --> $DIR/const-arg-in-const-arg.rs:37:24
|
LL | let _: Foo<{ faz::<'a>(&()) }>;
- | ^^
+ | ^^ cannot perform const operation using `'a`
|
- = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
- = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
+ = note: lifetime parameters may not be used in const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
-error[E0658]: a non-static lifetime is not allowed in a `const`
- --> $DIR/const-arg-in-const-arg.rs:43:24
+error: generic parameters may not be used in const operations
+ --> $DIR/const-arg-in-const-arg.rs:39:24
|
LL | let _: Foo<{ baz::<'a>(&()) }>;
- | ^^
+ | ^^ cannot perform const operation using `'a`
|
- = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
- = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
+ = note: lifetime parameters may not be used in const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
-error[E0658]: a non-static lifetime is not allowed in a `const`
- --> $DIR/const-arg-in-const-arg.rs:44:24
+error: generic parameters may not be used in const operations
+ --> $DIR/const-arg-in-const-arg.rs:40:24
|
LL | let _: Foo<{ faz::<'b>(&()) }>;
- | ^^
+ | ^^ cannot perform const operation using `'b`
|
- = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
- = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
+ = note: lifetime parameters may not be used in const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
-error[E0658]: a non-static lifetime is not allowed in a `const`
- --> $DIR/const-arg-in-const-arg.rs:46:24
+error: generic parameters may not be used in const operations
+ --> $DIR/const-arg-in-const-arg.rs:42:24
|
LL | let _: Foo<{ baz::<'b>(&()) }>;
- | ^^
+ | ^^ cannot perform const operation using `'b`
|
- = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
- = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
+ = note: lifetime 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/const-arg-in-const-arg.rs:47:27
+ --> $DIR/const-arg-in-const-arg.rs:43:27
|
LL | let _ = Foo::<{ foo::<T>() }>;
| ^ cannot perform const operation using `T`
@@ -161,7 +161,7 @@ LL | let _ = Foo::<{ foo::<T>() }>;
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
- --> $DIR/const-arg-in-const-arg.rs:49:27
+ --> $DIR/const-arg-in-const-arg.rs:44:27
|
LL | let _ = Foo::<{ bar::<N>() }>;
| ^ cannot perform const operation using `N`
@@ -169,44 +169,44 @@ LL | let _ = Foo::<{ bar::<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[E0658]: a non-static lifetime is not allowed in a `const`
- --> $DIR/const-arg-in-const-arg.rs:52:27
+error: generic parameters may not be used in const operations
+ --> $DIR/const-arg-in-const-arg.rs:46:27
|
LL | let _ = Foo::<{ faz::<'a>(&()) }>;
- | ^^
+ | ^^ cannot perform const operation using `'a`
|
- = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
- = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
+ = note: lifetime parameters may not be used in const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
-error[E0658]: a non-static lifetime is not allowed in a `const`
- --> $DIR/const-arg-in-const-arg.rs:54:27
+error: generic parameters may not be used in const operations
+ --> $DIR/const-arg-in-const-arg.rs:48:27
|
LL | let _ = Foo::<{ baz::<'a>(&()) }>;
- | ^^
+ | ^^ cannot perform const operation using `'a`
|
- = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
- = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
+ = note: lifetime parameters may not be used in const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
-error[E0658]: a non-static lifetime is not allowed in a `const`
- --> $DIR/const-arg-in-const-arg.rs:55:27
+error: generic parameters may not be used in const operations
+ --> $DIR/const-arg-in-const-arg.rs:49:27
|
LL | let _ = Foo::<{ faz::<'b>(&()) }>;
- | ^^
+ | ^^ cannot perform const operation using `'b`
|
- = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
- = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
+ = note: lifetime parameters may not be used in const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
-error[E0658]: a non-static lifetime is not allowed in a `const`
- --> $DIR/const-arg-in-const-arg.rs:57:27
+error: generic parameters may not be used in const operations
+ --> $DIR/const-arg-in-const-arg.rs:51:27
|
LL | let _ = Foo::<{ baz::<'b>(&()) }>;
- | ^^
+ | ^^ cannot perform const operation using `'b`
|
- = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
- = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
+ = note: lifetime parameters may not be used in const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error[E0747]: unresolved item provided when a constant was expected
- --> $DIR/const-arg-in-const-arg.rs:15:23
+ --> $DIR/const-arg-in-const-arg.rs:16:23
|
LL | let _: [u8; bar::<N>()];
| ^
@@ -223,7 +223,7 @@ LL | let _: [u8; faz::<'a>(&())];
| ^^
|
note: the late bound lifetime parameter is introduced here
- --> $DIR/const-arg-in-const-arg.rs:8:14
+ --> $DIR/const-arg-in-const-arg.rs:10:14
|
LL | const fn faz<'a>(_: &'a ()) -> usize { 13 }
| ^^
@@ -235,13 +235,13 @@ LL | let _: [u8; faz::<'b>(&())];
| ^^
|
note: the late bound lifetime parameter is introduced here
- --> $DIR/const-arg-in-const-arg.rs:8:14
+ --> $DIR/const-arg-in-const-arg.rs:10:14
|
LL | const fn faz<'a>(_: &'a ()) -> usize { 13 }
| ^^
error[E0747]: unresolved item provided when a constant was expected
- --> $DIR/const-arg-in-const-arg.rs:38:24
+ --> $DIR/const-arg-in-const-arg.rs:35:24
|
LL | let _: Foo<{ bar::<N>() }>;
| ^
@@ -252,25 +252,25 @@ LL | let _: Foo<{ bar::<{ N }>() }>;
| + +
error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
- --> $DIR/const-arg-in-const-arg.rs:41:24
+ --> $DIR/const-arg-in-const-arg.rs:37:24
|
LL | let _: Foo<{ faz::<'a>(&()) }>;
| ^^
|
note: the late bound lifetime parameter is introduced here
- --> $DIR/const-arg-in-const-arg.rs:8:14
+ --> $DIR/const-arg-in-const-arg.rs:10:14
|
LL | const fn faz<'a>(_: &'a ()) -> usize { 13 }
| ^^
error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
- --> $DIR/const-arg-in-const-arg.rs:44:24
+ --> $DIR/const-arg-in-const-arg.rs:40:24
|
LL | let _: Foo<{ faz::<'b>(&()) }>;
| ^^
|
note: the late bound lifetime parameter is introduced here
- --> $DIR/const-arg-in-const-arg.rs:8:14
+ --> $DIR/const-arg-in-const-arg.rs:10:14
|
LL | const fn faz<'a>(_: &'a ()) -> usize { 13 }
| ^^
@@ -284,7 +284,7 @@ LL | let _ = [0; foo::<T>()];
= note: this may fail depending on what value the parameter takes
error[E0747]: unresolved item provided when a constant was expected
- --> $DIR/const-arg-in-const-arg.rs:27:23
+ --> $DIR/const-arg-in-const-arg.rs:26:23
|
LL | let _ = [0; bar::<N>()];
| ^
@@ -295,31 +295,31 @@ LL | let _ = [0; bar::<{ N }>()];
| + +
error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
- --> $DIR/const-arg-in-const-arg.rs:30:23
+ --> $DIR/const-arg-in-const-arg.rs:28:23
|
LL | let _ = [0; faz::<'a>(&())];
| ^^
|
note: the late bound lifetime parameter is introduced here
- --> $DIR/const-arg-in-const-arg.rs:8:14
+ --> $DIR/const-arg-in-const-arg.rs:10:14
|
LL | const fn faz<'a>(_: &'a ()) -> usize { 13 }
| ^^
error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
- --> $DIR/const-arg-in-const-arg.rs:33:23
+ --> $DIR/const-arg-in-const-arg.rs:31:23
|
LL | let _ = [0; faz::<'b>(&())];
| ^^
|
note: the late bound lifetime parameter is introduced here
- --> $DIR/const-arg-in-const-arg.rs:8:14
+ --> $DIR/const-arg-in-const-arg.rs:10:14
|
LL | const fn faz<'a>(_: &'a ()) -> usize { 13 }
| ^^
error[E0747]: unresolved item provided when a constant was expected
- --> $DIR/const-arg-in-const-arg.rs:49:27
+ --> $DIR/const-arg-in-const-arg.rs:44:27
|
LL | let _ = Foo::<{ bar::<N>() }>;
| ^
@@ -330,30 +330,30 @@ LL | let _ = Foo::<{ bar::<{ N }>() }>;
| + +
error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
- --> $DIR/const-arg-in-const-arg.rs:52:27
+ --> $DIR/const-arg-in-const-arg.rs:46:27
|
LL | let _ = Foo::<{ faz::<'a>(&()) }>;
| ^^
|
note: the late bound lifetime parameter is introduced here
- --> $DIR/const-arg-in-const-arg.rs:8:14
+ --> $DIR/const-arg-in-const-arg.rs:10:14
|
LL | const fn faz<'a>(_: &'a ()) -> usize { 13 }
| ^^
error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
- --> $DIR/const-arg-in-const-arg.rs:55:27
+ --> $DIR/const-arg-in-const-arg.rs:49:27
|
LL | let _ = Foo::<{ faz::<'b>(&()) }>;
| ^^
|
note: the late bound lifetime parameter is introduced here
- --> $DIR/const-arg-in-const-arg.rs:8:14
+ --> $DIR/const-arg-in-const-arg.rs:10:14
|
LL | const fn faz<'a>(_: &'a ()) -> usize { 13 }
| ^^
error: aborting due to 36 previous errors
-Some errors have detailed explanations: E0658, E0747, E0794.
-For more information about an error, try `rustc --explain E0658`.
+Some errors have detailed explanations: E0747, E0794.
+For more information about an error, try `rustc --explain E0747`.
diff --git a/tests/ui/const-generics/const-arg-in-const-arg.rs b/tests/ui/const-generics/const-arg-in-const-arg.rs
index 44a4f560a..9eaa54347 100644
--- a/tests/ui/const-generics/const-arg-in-const-arg.rs
+++ b/tests/ui/const-generics/const-arg-in-const-arg.rs
@@ -1,4 +1,6 @@
-// revisions: full min
+// revisions: min
+// we use a single revision because t his shoudl have a `full` revision
+// but right now that ICEs and I(@BoxyUwU) could not get stderr normalization to work
#![cfg_attr(full, feature(generic_const_exprs))]
#![cfg_attr(full, allow(incomplete_features))]
@@ -11,50 +13,42 @@ const fn baz<'a>(_: &'a ()) -> usize where &'a (): Sized { 13 }
struct Foo<const N: usize>;
fn test<'a, 'b, T, const N: usize>() where &'b (): Sized {
let _: [u8; foo::<T>()]; //[min]~ ERROR generic parameters may not
- //[full]~^ ERROR unconstrained generic constant
let _: [u8; bar::<N>()]; //[min]~ ERROR generic parameters may not
//[min]~^ ERROR unresolved item provided when a constant was expected
- //[full]~^^ ERROR unconstrained generic constant
- let _: [u8; faz::<'a>(&())]; //[min]~ ERROR a non-static lifetime
- //~^ ERROR cannot specify lifetime arguments
- let _: [u8; baz::<'a>(&())]; //[min]~ ERROR a non-static lifetime
- let _: [u8; faz::<'b>(&())]; //[min]~ ERROR a non-static lifetime
- //~^ ERROR cannot specify lifetime arguments
- let _: [u8; baz::<'b>(&())]; //[min]~ ERROR a non-static lifetime
+ let _: [u8; faz::<'a>(&())]; //[min]~ ERROR generic parameters may not
+ //[min]~^ ERROR cannot specify lifetime arguments
+ let _: [u8; baz::<'a>(&())]; //[min]~ ERROR generic parameters may not
+ let _: [u8; faz::<'b>(&())]; //[min]~ ERROR generic parameters may not
+ //[min]~^ ERROR cannot specify lifetime arguments
+ let _: [u8; baz::<'b>(&())]; //[min]~ ERROR generic parameters may not
let _ = [0; foo::<T>()]; //[min]~ ERROR constant expression depends on a generic parameter
- //[full]~^ ERROR unconstrained generic constant
let _ = [0; bar::<N>()]; //[min]~ ERROR generic parameters may not
//[min]~^ ERROR unresolved item provided when a constant was expected
- //[full]~^^ ERROR unconstrained generic constant
- let _ = [0; faz::<'a>(&())]; //[min]~ ERROR a non-static lifetime
- //~^ ERROR cannot specify lifetime arguments
- let _ = [0; baz::<'a>(&())]; //[min]~ ERROR a non-static lifetime
- let _ = [0; faz::<'b>(&())]; //[min]~ ERROR a non-static lifetime
- //~^ ERROR cannot specify lifetime arguments
- let _ = [0; baz::<'b>(&())]; //[min]~ ERROR a non-static lifetime
+ let _ = [0; faz::<'a>(&())]; //[min]~ ERROR generic parameters may not
+ //[min]~^ ERROR cannot specify lifetime arguments
+ let _ = [0; baz::<'a>(&())]; //[min]~ ERROR generic parameters may not
+ let _ = [0; faz::<'b>(&())]; //[min]~ ERROR generic parameters may not
+ //[min]~^ ERROR cannot specify lifetime arguments
+ let _ = [0; baz::<'b>(&())]; //[min]~ ERROR generic parameters may not
let _: Foo<{ foo::<T>() }>; //[min]~ ERROR generic parameters may not
- //[full]~^ ERROR unconstrained generic constant
let _: Foo<{ bar::<N>() }>; //[min]~ ERROR generic parameters may not
//[min]~^ ERROR unresolved item provided when a constant was expected
- //[full]~^^ ERROR unconstrained generic constant
- let _: Foo<{ faz::<'a>(&()) }>; //[min]~ ERROR a non-static lifetime
- //~^ ERROR cannot specify lifetime arguments
- let _: Foo<{ baz::<'a>(&()) }>; //[min]~ ERROR a non-static lifetime
- let _: Foo<{ faz::<'b>(&()) }>; //[min]~ ERROR a non-static lifetime
- //~^ ERROR cannot specify lifetime arguments
- let _: Foo<{ baz::<'b>(&()) }>; //[min]~ ERROR a non-static lifetime
+ let _: Foo<{ faz::<'a>(&()) }>; //[min]~ ERROR generic parameters may not
+ //[min]~^ ERROR cannot specify lifetime arguments
+ let _: Foo<{ baz::<'a>(&()) }>; //[min]~ ERROR generic parameters may not
+ let _: Foo<{ faz::<'b>(&()) }>; //[min]~ ERROR generic parameters may not
+ //[min]~^ ERROR cannot specify lifetime arguments
+ let _: Foo<{ baz::<'b>(&()) }>; //[min]~ ERROR generic parameters may not
let _ = Foo::<{ foo::<T>() }>; //[min]~ ERROR generic parameters may not
- //[full]~^ ERROR unconstrained generic constant
let _ = Foo::<{ bar::<N>() }>; //[min]~ ERROR generic parameters may not
//[min]~^ ERROR unresolved item provided when a constant was expected
- //[full]~^^ ERROR unconstrained generic constant
- let _ = Foo::<{ faz::<'a>(&()) }>; //[min]~ ERROR a non-static lifetime
- //~^ ERROR cannot specify lifetime arguments
- let _ = Foo::<{ baz::<'a>(&()) }>; //[min]~ ERROR a non-static lifetime
- let _ = Foo::<{ faz::<'b>(&()) }>; //[min]~ ERROR a non-static lifetime
- //~^ ERROR cannot specify lifetime arguments
- let _ = Foo::<{ baz::<'b>(&()) }>; //[min]~ ERROR a non-static lifetime
+ let _ = Foo::<{ faz::<'a>(&()) }>; //[min]~ ERROR generic parameters may not
+ //[min]~^ ERROR cannot specify lifetime arguments
+ let _ = Foo::<{ baz::<'a>(&()) }>; //[min]~ ERROR generic parameters may not
+ let _ = Foo::<{ faz::<'b>(&()) }>; //[min]~ ERROR generic parameters may not
+ //[min]~^ ERROR cannot specify lifetime arguments
+ let _ = Foo::<{ baz::<'b>(&()) }>; //[min]~ ERROR generic parameters may not
}
fn main() {}
diff --git a/tests/ui/const-generics/const-argument-non-static-lifetime.min.stderr b/tests/ui/const-generics/const-argument-non-static-lifetime.min.stderr
index 82030731c..310ca75fd 100644
--- a/tests/ui/const-generics/const-argument-non-static-lifetime.min.stderr
+++ b/tests/ui/const-generics/const-argument-non-static-lifetime.min.stderr
@@ -1,12 +1,11 @@
-error[E0658]: a non-static lifetime is not allowed in a `const`
+error: generic parameters may not be used in const operations
--> $DIR/const-argument-non-static-lifetime.rs:14:17
|
LL | let _: &'a ();
- | ^^
+ | ^^ cannot perform const operation using `'a`
|
- = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
- = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
+ = note: lifetime 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
-For more information about this error, try `rustc --explain E0658`.
diff --git a/tests/ui/const-generics/const-argument-non-static-lifetime.rs b/tests/ui/const-generics/const-argument-non-static-lifetime.rs
index 0357e4ed5..df2f3b791 100644
--- a/tests/ui/const-generics/const-argument-non-static-lifetime.rs
+++ b/tests/ui/const-generics/const-argument-non-static-lifetime.rs
@@ -11,7 +11,7 @@ fn test<const N: usize>() {}
fn wow<'a>() -> &'a () {
test::<{
- let _: &'a (); //[min]~ ERROR a non-static lifetime
+ let _: &'a (); //[min]~ ERROR generic parameters may not be used in const operations
3
}>();
&()
diff --git a/tests/ui/const-generics/const-param-type-depends-on-const-param.full.stderr b/tests/ui/const-generics/const-param-type-depends-on-const-param.full.stderr
index f639e276f..539d840f0 100644
--- a/tests/ui/const-generics/const-param-type-depends-on-const-param.full.stderr
+++ b/tests/ui/const-generics/const-param-type-depends-on-const-param.full.stderr
@@ -3,12 +3,16 @@ error[E0770]: the type of const parameters must not depend on other generic para
|
LL | pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]);
| ^ the type must not depend on the parameter `N`
+ |
+ = note: const parameters may not be used in the type of const parameters
error[E0770]: the type of const parameters must not depend on other generic parameters
--> $DIR/const-param-type-depends-on-const-param.rs:15:40
|
LL | pub struct SelfDependent<const N: [u8; N]>;
| ^ the type must not depend on the parameter `N`
+ |
+ = note: const parameters may not be used in the type of const parameters
error: aborting due to 2 previous errors
diff --git a/tests/ui/const-generics/const-param-type-depends-on-const-param.min.stderr b/tests/ui/const-generics/const-param-type-depends-on-const-param.min.stderr
index 24aa40521..f829526ca 100644
--- a/tests/ui/const-generics/const-param-type-depends-on-const-param.min.stderr
+++ b/tests/ui/const-generics/const-param-type-depends-on-const-param.min.stderr
@@ -3,12 +3,16 @@ error[E0770]: the type of const parameters must not depend on other generic para
|
LL | pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]);
| ^ the type must not depend on the parameter `N`
+ |
+ = note: const parameters may not be used in the type of const parameters
error[E0770]: the type of const parameters must not depend on other generic parameters
--> $DIR/const-param-type-depends-on-const-param.rs:15:40
|
LL | pub struct SelfDependent<const N: [u8; N]>;
| ^ the type must not depend on the parameter `N`
+ |
+ = note: const parameters may not be used in the type of const parameters
error: `[u8; N]` is forbidden as the type of a const generic parameter
--> $DIR/const-param-type-depends-on-const-param.rs:11:47
diff --git a/tests/ui/const-generics/const-param-type-depends-on-type-param-ungated.stderr b/tests/ui/const-generics/const-param-type-depends-on-type-param-ungated.stderr
index 9c5c97bef..c5160d1c3 100644
--- a/tests/ui/const-generics/const-param-type-depends-on-type-param-ungated.stderr
+++ b/tests/ui/const-generics/const-param-type-depends-on-type-param-ungated.stderr
@@ -3,6 +3,8 @@ error[E0770]: the type of const parameters must not depend on other generic para
|
LL | struct B<T, const N: T>(PhantomData<[T; N]>);
| ^ the type must not depend on the parameter `T`
+ |
+ = note: type parameters may not be used in the type of const parameters
error: aborting due to previous error
diff --git a/tests/ui/const-generics/const-param-type-depends-on-type-param.full.stderr b/tests/ui/const-generics/const-param-type-depends-on-type-param.full.stderr
index 32f7dea82..938fb08b7 100644
--- a/tests/ui/const-generics/const-param-type-depends-on-type-param.full.stderr
+++ b/tests/ui/const-generics/const-param-type-depends-on-type-param.full.stderr
@@ -3,6 +3,8 @@ error[E0770]: the type of const parameters must not depend on other generic para
|
LL | pub struct Dependent<T, const X: T>([(); X]);
| ^ the type must not depend on the parameter `T`
+ |
+ = note: type parameters may not be used in the type of const parameters
error[E0392]: parameter `T` is never used
--> $DIR/const-param-type-depends-on-type-param.rs:11:22
diff --git a/tests/ui/const-generics/const-param-type-depends-on-type-param.min.stderr b/tests/ui/const-generics/const-param-type-depends-on-type-param.min.stderr
index 32f7dea82..938fb08b7 100644
--- a/tests/ui/const-generics/const-param-type-depends-on-type-param.min.stderr
+++ b/tests/ui/const-generics/const-param-type-depends-on-type-param.min.stderr
@@ -3,6 +3,8 @@ error[E0770]: the type of const parameters must not depend on other generic para
|
LL | pub struct Dependent<T, const X: T>([(); X]);
| ^ the type must not depend on the parameter `T`
+ |
+ = note: type parameters may not be used in the type of const parameters
error[E0392]: parameter `T` is never used
--> $DIR/const-param-type-depends-on-type-param.rs:11:22
diff --git a/tests/ui/const-generics/defaults/trait_objects_fail.stderr b/tests/ui/const-generics/defaults/trait_objects_fail.stderr
index 0e8334d03..481d77728 100644
--- a/tests/ui/const-generics/defaults/trait_objects_fail.stderr
+++ b/tests/ui/const-generics/defaults/trait_objects_fail.stderr
@@ -5,7 +5,7 @@ LL | foo(&10_u32);
| ^^^^^^^ the trait `Trait` is not implemented for `u32`
|
= help: the trait `Trait<2>` is implemented for `u32`
- = note: required for the cast from `u32` to the object type `dyn Trait`
+ = note: required for the cast from `&u32` to `&dyn Trait`
error[E0277]: the trait bound `bool: Traitor<_>` is not satisfied
--> $DIR/trait_objects_fail.rs:28:9
@@ -14,7 +14,7 @@ LL | bar(&true);
| ^^^^^ the trait `Traitor<_>` is not implemented for `bool`
|
= help: the trait `Traitor<2, 3>` is implemented for `bool`
- = note: required for the cast from `bool` to the object type `dyn Traitor<_>`
+ = note: required for the cast from `&bool` to `&dyn Traitor<_>`
error: aborting due to 2 previous errors
diff --git a/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr b/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr
index 6b3396a25..3a7f3cd0b 100644
--- a/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr
+++ b/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr
@@ -8,6 +8,9 @@ LL | let _ = const_evaluatable_lib::test1::<T>();
note: required by a bound in `test1`
--> $DIR/auxiliary/const_evaluatable_lib.rs:6:10
|
+LL | pub fn test1<T>() -> [u8; std::mem::size_of::<T>() - 1]
+ | ----- required by a bound in this function
+LL | where
LL | [u8; std::mem::size_of::<T>() - 1]: Sized,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `test1`
@@ -34,6 +37,9 @@ LL | let _ = const_evaluatable_lib::test1::<T>();
note: required by a bound in `test1`
--> $DIR/auxiliary/const_evaluatable_lib.rs:6:10
|
+LL | pub fn test1<T>() -> [u8; std::mem::size_of::<T>() - 1]
+ | ----- required by a bound in this function
+LL | where
LL | [u8; std::mem::size_of::<T>() - 1]: Sized,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `test1`
diff --git a/tests/ui/const-generics/generic_const_exprs/issue-74713.rs b/tests/ui/const-generics/generic_const_exprs/issue-74713.rs
index 0bcb997d9..205d031d4 100644
--- a/tests/ui/const-generics/generic_const_exprs/issue-74713.rs
+++ b/tests/ui/const-generics/generic_const_exprs/issue-74713.rs
@@ -1,7 +1,7 @@
fn bug<'a>()
where
[(); { //~ ERROR mismatched types
- let _: &'a (); //~ ERROR a non-static lifetime is not allowed in a `const`
+ let _: &'a (); //~ ERROR generic parameters may not be used in const operations
}]:
{}
diff --git a/tests/ui/const-generics/generic_const_exprs/issue-74713.stderr b/tests/ui/const-generics/generic_const_exprs/issue-74713.stderr
index e7673df0a..f0e0a4b97 100644
--- a/tests/ui/const-generics/generic_const_exprs/issue-74713.stderr
+++ b/tests/ui/const-generics/generic_const_exprs/issue-74713.stderr
@@ -1,11 +1,11 @@
-error[E0658]: a non-static lifetime is not allowed in a `const`
+error: generic parameters may not be used in const operations
--> $DIR/issue-74713.rs:4:17
|
LL | let _: &'a ();
- | ^^
+ | ^^ cannot perform const operation using `'a`
|
- = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
- = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
+ = note: lifetime parameters may not be used in const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error[E0308]: mismatched types
--> $DIR/issue-74713.rs:3:10
@@ -18,5 +18,4 @@ LL | | }]:
error: aborting due to 2 previous errors
-Some errors have detailed explanations: E0308, E0658.
-For more information about an error, try `rustc --explain E0308`.
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/const-generics/generic_const_exprs/nested_uneval_unification-2.rs b/tests/ui/const-generics/generic_const_exprs/nested_uneval_unification-2.rs
index d45a6465b..18a993986 100644
--- a/tests/ui/const-generics/generic_const_exprs/nested_uneval_unification-2.rs
+++ b/tests/ui/const-generics/generic_const_exprs/nested_uneval_unification-2.rs
@@ -2,28 +2,30 @@
#![feature(generic_const_exprs)]
#![allow(incomplete_features, unused_parens, unused_braces)]
-fn zero_init<const N: usize>() -> Substs1<{ (N) }>
+fn zero_init<const N: usize>() -> Substs1<{{ N }}>
where
- [u8; { (N) }]: ,
+ [u8; {{ N }}]: ,
{
- Substs1([0; { (N) }])
+ Substs1([0; {{ N }}])
}
-struct Substs1<const N: usize>([u8; { (N) }])
+struct Substs1<const N: usize>([u8; {{ N }}])
where
- [(); { (N) }]: ;
+ [(); {{ N }}]: ;
-fn substs2<const M: usize>() -> Substs1<{ (M) }> {
- zero_init::<{ (M) }>()
+fn substs2<const M: usize>() -> Substs1<{{ M }}> {
+ zero_init::<{{ M }}>()
}
-fn substs3<const L: usize>() -> Substs1<{ (L) }> {
- substs2::<{ (L) }>()
+fn substs3<const L: usize>() -> Substs1<{{ L }}> {
+ substs2::<{{ L }}>()
}
fn main() {
assert_eq!(substs3::<2>().0, [0; 2]);
}
-// Test that the implicit ``{ (L) }`` bound on ``substs3`` satisfies the
-// ``{ (N) }`` bound on ``Substs1``
+// Test that the implicit ``{{ L }}`` bound on ``substs3`` satisfies the
+// ``{{ N }}`` bound on ``Substs1``
+// FIXME(generic_const_exprs): come up with a less brittle test for this using assoc consts
+// once normalization is implemented for them.
diff --git a/tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.rs b/tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.rs
index 85345d65c..b22cab7c7 100644
--- a/tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.rs
+++ b/tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.rs
@@ -1,7 +1,7 @@
-// check-pass
+// known-bug: #110395
// known-bug: #97156
-#![feature(const_type_id, generic_const_exprs)]
+#![feature(const_type_id, const_trait_impl, generic_const_exprs)]
#![allow(incomplete_features)]
use std::any::TypeId;
@@ -26,7 +26,10 @@ impl<T: 'static> AssocCt for T {
trait WithAssoc<U> {
type Assoc;
}
-impl<T: 'static> WithAssoc<()> for T where [(); <T as AssocCt>::ASSOC]: {
+impl<T: 'static> WithAssoc<()> for T
+where
+ [(); <T as AssocCt>::ASSOC]:,
+{
type Assoc = [u8; <T as AssocCt>::ASSOC];
}
@@ -38,7 +41,6 @@ where
x
}
-
fn unsound<T>(x: <One as WithAssoc<T>>::Assoc) -> <Two as WithAssoc<T>>::Assoc
where
One: WithAssoc<T>,
diff --git a/tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.stderr b/tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.stderr
new file mode 100644
index 000000000..8cbd12654
--- /dev/null
+++ b/tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.stderr
@@ -0,0 +1,11 @@
+error: to use a constant of type `TypeId` in a pattern, `TypeId` must be annotated with `#[derive(PartialEq, Eq)]`
+ --> $DIR/typeid-equality-by-subtyping.rs:18:9
+ |
+LL | WHAT_A_TYPE => 0,
+ | ^^^^^^^^^^^
+ |
+ = note: the traits must be derived, manual `impl`s are not sufficient
+ = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
+
+error: aborting due to previous error
+
diff --git a/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.rs b/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.rs
index c0404d35b..ae9207cf8 100644
--- a/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.rs
+++ b/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.rs
@@ -1,3 +1,5 @@
+// known-bug: #110395
+
#![feature(generic_const_exprs, adt_const_params, const_trait_impl)]
#![allow(incomplete_features)]
@@ -26,7 +28,6 @@ struct Evaluatable2<const N: usize>;
fn foo2<const N: usize>(a: Evaluatable2<{ N + N }>) {
bar2::<{ std::ops::Add::add(N, N) }>();
- //~^ error: unconstrained generic constant
// FIXME(generic_const_exprs) make this not an error
}
diff --git a/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.stderr b/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.stderr
index d18c7916f..7f28771ce 100644
--- a/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.stderr
+++ b/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.stderr
@@ -1,10 +1,11 @@
-error: unconstrained generic constant
- --> $DIR/unify-op-with-fn-call.rs:28:12
+error: const `impl` for trait `Add` which is not marked with `#[const_trait]`
+ --> $DIR/unify-op-with-fn-call.rs:10:12
|
-LL | bar2::<{ std::ops::Add::add(N, N) }>();
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | impl const std::ops::Add for Foo {
+ | ^^^^^^^^^^^^^
|
- = help: try adding a `where` bound using this expression: `where [(); { std::ops::Add::add(N, N) }]:`
+ = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
+ = note: adding a non-const method body in the future would be a breaking change
error: aborting due to previous error
diff --git a/tests/ui/const-generics/generic_const_exprs/unresolved_lifetimes_error.rs b/tests/ui/const-generics/generic_const_exprs/unresolved_lifetimes_error.rs
new file mode 100644
index 000000000..96aeec77c
--- /dev/null
+++ b/tests/ui/const-generics/generic_const_exprs/unresolved_lifetimes_error.rs
@@ -0,0 +1,12 @@
+#![feature(generic_const_exprs)]
+#![allow(incomplete_features)]
+
+fn foo() -> [(); {
+ let a: &'a ();
+ //~^ ERROR: use of undeclared lifetime name `'a`
+ 10_usize
+}] {
+ loop {}
+}
+
+fn main() {}
diff --git a/tests/ui/const-generics/generic_const_exprs/unresolved_lifetimes_error.stderr b/tests/ui/const-generics/generic_const_exprs/unresolved_lifetimes_error.stderr
new file mode 100644
index 000000000..976f03706
--- /dev/null
+++ b/tests/ui/const-generics/generic_const_exprs/unresolved_lifetimes_error.stderr
@@ -0,0 +1,11 @@
+error[E0261]: use of undeclared lifetime name `'a`
+ --> $DIR/unresolved_lifetimes_error.rs:5:13
+ |
+LL | fn foo() -> [(); {
+ | - help: consider introducing lifetime `'a` here: `<'a>`
+LL | let a: &'a ();
+ | ^^ undeclared lifetime
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0261`.
diff --git a/tests/ui/const-generics/issue-46511.rs b/tests/ui/const-generics/issue-46511.rs
index 71c50e2f3..78baba818 100644
--- a/tests/ui/const-generics/issue-46511.rs
+++ b/tests/ui/const-generics/issue-46511.rs
@@ -2,7 +2,7 @@
struct Foo<'a> //~ ERROR parameter `'a` is never used [E0392]
{
- _a: [u8; std::mem::size_of::<&'a mut u8>()] //~ ERROR a non-static lifetime is not allowed in a `const`
+ _a: [u8; std::mem::size_of::<&'a mut u8>()] //~ ERROR generic parameters may not be used in const operations
}
pub fn main() {}
diff --git a/tests/ui/const-generics/issue-46511.stderr b/tests/ui/const-generics/issue-46511.stderr
index b21afa56d..58c93a1fa 100644
--- a/tests/ui/const-generics/issue-46511.stderr
+++ b/tests/ui/const-generics/issue-46511.stderr
@@ -1,11 +1,11 @@
-error[E0658]: a non-static lifetime is not allowed in a `const`
+error: generic parameters may not be used in const operations
--> $DIR/issue-46511.rs:5:35
|
LL | _a: [u8; std::mem::size_of::<&'a mut u8>()]
- | ^^
+ | ^^ cannot perform const operation using `'a`
|
- = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
- = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
+ = note: lifetime parameters may not be used in const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error[E0392]: parameter `'a` is never used
--> $DIR/issue-46511.rs:3:12
@@ -17,5 +17,4 @@ LL | struct Foo<'a>
error: aborting due to 2 previous errors
-Some errors have detailed explanations: E0392, E0658.
-For more information about an error, try `rustc --explain E0392`.
+For more information about this error, try `rustc --explain E0392`.
diff --git a/tests/ui/const-generics/issues/issue-105821.rs b/tests/ui/const-generics/issues/issue-105821.rs
index cba2e22c4..6cfabb65e 100644
--- a/tests/ui/const-generics/issues/issue-105821.rs
+++ b/tests/ui/const-generics/issues/issue-105821.rs
@@ -1,7 +1,7 @@
// check-pass
#![allow(incomplete_features)]
-#![feature(adt_const_params, const_ptr_read, generic_const_exprs)]
+#![feature(adt_const_params, generic_const_exprs)]
#![allow(dead_code)]
const fn catone<const M: usize>(_a: &[u8; M]) -> [u8; M + 1]
diff --git a/tests/ui/const-generics/issues/issue-56445-1.full.stderr b/tests/ui/const-generics/issues/issue-56445-1.full.stderr
index 179643a75..5fc0ec260 100644
--- a/tests/ui/const-generics/issues/issue-56445-1.full.stderr
+++ b/tests/ui/const-generics/issues/issue-56445-1.full.stderr
@@ -1,11 +1,11 @@
-error[E0771]: use of non-static lifetime `'a` in const generic
+error[E0770]: the type of const parameters must not depend on other generic parameters
--> $DIR/issue-56445-1.rs:9:26
|
LL | struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>);
- | ^^
+ | ^^ the type must not depend on the parameter `'a`
|
- = note: for more information, see issue #74052 <https://github.com/rust-lang/rust/issues/74052>
+ = note: lifetime parameters may not be used in the type of const parameters
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0771`.
+For more information about this error, try `rustc --explain E0770`.
diff --git a/tests/ui/const-generics/issues/issue-56445-1.min.stderr b/tests/ui/const-generics/issues/issue-56445-1.min.stderr
index 9f8801341..71a7051f2 100644
--- a/tests/ui/const-generics/issues/issue-56445-1.min.stderr
+++ b/tests/ui/const-generics/issues/issue-56445-1.min.stderr
@@ -1,10 +1,10 @@
-error[E0771]: use of non-static lifetime `'a` in const generic
+error[E0770]: the type of const parameters must not depend on other generic parameters
--> $DIR/issue-56445-1.rs:9:26
|
LL | struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>);
- | ^^
+ | ^^ the type must not depend on the parameter `'a`
|
- = note: for more information, see issue #74052 <https://github.com/rust-lang/rust/issues/74052>
+ = note: lifetime parameters may not be used in the type of const parameters
error: `&str` is forbidden as the type of a const generic parameter
--> $DIR/issue-56445-1.rs:9:25
@@ -17,4 +17,4 @@ LL | struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>);
error: aborting due to 2 previous errors
-For more information about this error, try `rustc --explain E0771`.
+For more information about this error, try `rustc --explain E0770`.
diff --git a/tests/ui/const-generics/issues/issue-56445-1.rs b/tests/ui/const-generics/issues/issue-56445-1.rs
index 0741c3796..d862bf24a 100644
--- a/tests/ui/const-generics/issues/issue-56445-1.rs
+++ b/tests/ui/const-generics/issues/issue-56445-1.rs
@@ -7,7 +7,7 @@
use std::marker::PhantomData;
struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>);
-//~^ ERROR: use of non-static lifetime `'a` in const generic
+//~^ ERROR: the type of const parameters must not depend on other generic parameters
//[min]~| ERROR: `&str` is forbidden as the type of a const generic parameter
impl Bug<'_, ""> {}
diff --git a/tests/ui/const-generics/issues/issue-62878.full.stderr b/tests/ui/const-generics/issues/issue-62878.full.stderr
index 3a2b291d7..c658b5a6e 100644
--- a/tests/ui/const-generics/issues/issue-62878.full.stderr
+++ b/tests/ui/const-generics/issues/issue-62878.full.stderr
@@ -3,6 +3,8 @@ error[E0770]: the type of const parameters must not depend on other generic para
|
LL | fn foo<const N: usize, const A: [u8; N]>() {}
| ^ the type must not depend on the parameter `N`
+ |
+ = note: const parameters may not be used in the type of const parameters
error: aborting due to previous error
diff --git a/tests/ui/const-generics/issues/issue-62878.min.stderr b/tests/ui/const-generics/issues/issue-62878.min.stderr
index 5a721720d..9c0e5179c 100644
--- a/tests/ui/const-generics/issues/issue-62878.min.stderr
+++ b/tests/ui/const-generics/issues/issue-62878.min.stderr
@@ -3,6 +3,8 @@ error[E0770]: the type of const parameters must not depend on other generic para
|
LL | fn foo<const N: usize, const A: [u8; N]>() {}
| ^ the type must not depend on the parameter `N`
+ |
+ = note: const parameters may not be used in the type of const parameters
error: `[u8; N]` is forbidden as the type of a const generic parameter
--> $DIR/issue-62878.rs:5:33
diff --git a/tests/ui/const-generics/issues/issue-71169.full.stderr b/tests/ui/const-generics/issues/issue-71169.full.stderr
index 1f5880f36..ccdfbbd54 100644
--- a/tests/ui/const-generics/issues/issue-71169.full.stderr
+++ b/tests/ui/const-generics/issues/issue-71169.full.stderr
@@ -3,6 +3,8 @@ error[E0770]: the type of const parameters must not depend on other generic para
|
LL | fn foo<const LEN: usize, const DATA: [u8; LEN]>() {}
| ^^^ the type must not depend on the parameter `LEN`
+ |
+ = note: const parameters may not be used in the type of const parameters
error: aborting due to previous error
diff --git a/tests/ui/const-generics/issues/issue-71169.min.stderr b/tests/ui/const-generics/issues/issue-71169.min.stderr
index 998b16a79..ebfb24bec 100644
--- a/tests/ui/const-generics/issues/issue-71169.min.stderr
+++ b/tests/ui/const-generics/issues/issue-71169.min.stderr
@@ -3,6 +3,8 @@ error[E0770]: the type of const parameters must not depend on other generic para
|
LL | fn foo<const LEN: usize, const DATA: [u8; LEN]>() {}
| ^^^ the type must not depend on the parameter `LEN`
+ |
+ = note: const parameters may not be used in the type of const parameters
error: `[u8; LEN]` is forbidden as the type of a const generic parameter
--> $DIR/issue-71169.rs:5:38
diff --git a/tests/ui/const-generics/issues/issue-71381.full.stderr b/tests/ui/const-generics/issues/issue-71381.full.stderr
index e17cf96aa..962eaf75b 100644
--- a/tests/ui/const-generics/issues/issue-71381.full.stderr
+++ b/tests/ui/const-generics/issues/issue-71381.full.stderr
@@ -3,12 +3,16 @@ error[E0770]: the type of const parameters must not depend on other generic para
|
LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&self) {
| ^^^^ the type must not depend on the parameter `Args`
+ |
+ = note: type parameters may not be used in the type of const parameters
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`
+ |
+ = note: type parameters may not be used in the type of const parameters
error[E0741]: using function pointers as const generic parameters is forbidden
--> $DIR/issue-71381.rs:14:61
diff --git a/tests/ui/const-generics/issues/issue-71381.min.stderr b/tests/ui/const-generics/issues/issue-71381.min.stderr
index 3950317b3..e1e140071 100644
--- a/tests/ui/const-generics/issues/issue-71381.min.stderr
+++ b/tests/ui/const-generics/issues/issue-71381.min.stderr
@@ -3,12 +3,16 @@ error[E0770]: the type of const parameters must not depend on other generic para
|
LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&self) {
| ^^^^ the type must not depend on the parameter `Args`
+ |
+ = note: type parameters may not be used in the type of const parameters
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`
+ |
+ = note: type parameters may not be used in the type of const parameters
error: using function pointers as const generic parameters is forbidden
--> $DIR/issue-71381.rs:14:61
diff --git a/tests/ui/const-generics/issues/issue-71611.full.stderr b/tests/ui/const-generics/issues/issue-71611.full.stderr
index 656aa29e1..e109459f2 100644
--- a/tests/ui/const-generics/issues/issue-71611.full.stderr
+++ b/tests/ui/const-generics/issues/issue-71611.full.stderr
@@ -3,6 +3,8 @@ error[E0770]: the type of const parameters must not depend on other generic para
|
LL | fn func<A, const F: fn(inner: A)>(outer: A) {
| ^ the type must not depend on the parameter `A`
+ |
+ = note: type parameters may not be used in the type of const parameters
error[E0741]: using function pointers as const generic parameters is forbidden
--> $DIR/issue-71611.rs:5:21
diff --git a/tests/ui/const-generics/issues/issue-71611.min.stderr b/tests/ui/const-generics/issues/issue-71611.min.stderr
index 01a85b745..b33d7cf98 100644
--- a/tests/ui/const-generics/issues/issue-71611.min.stderr
+++ b/tests/ui/const-generics/issues/issue-71611.min.stderr
@@ -3,6 +3,8 @@ error[E0770]: the type of const parameters must not depend on other generic para
|
LL | fn func<A, const F: fn(inner: A)>(outer: A) {
| ^ the type must not depend on the parameter `A`
+ |
+ = note: type parameters may not be used in the type of const parameters
error: using function pointers as const generic parameters is forbidden
--> $DIR/issue-71611.rs:5:21
diff --git a/tests/ui/const-generics/issues/issue-77357.rs b/tests/ui/const-generics/issues/issue-77357.rs
deleted file mode 100644
index 3cb8d3846..000000000
--- a/tests/ui/const-generics/issues/issue-77357.rs
+++ /dev/null
@@ -1,11 +0,0 @@
-#![feature(generic_const_exprs)]
-#![allow(incomplete_features)]
-
-trait MyTrait<T> {}
-
-fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> {
- //~^ ERROR overly complex generic constant
- todo!()
-}
-
-fn main() {}
diff --git a/tests/ui/const-generics/issues/issue-77357.stderr b/tests/ui/const-generics/issues/issue-77357.stderr
deleted file mode 100644
index 68b35a38b..000000000
--- a/tests/ui/const-generics/issues/issue-77357.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-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 constants
- |
- = 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/tests/ui/const-generics/issues/issue-83993.rs b/tests/ui/const-generics/issues/issue-83993.rs
deleted file mode 100644
index f2f05d952..000000000
--- a/tests/ui/const-generics/issues/issue-83993.rs
+++ /dev/null
@@ -1,14 +0,0 @@
-// check-pass
-
-#![feature(generic_const_exprs)]
-#![allow(incomplete_features)]
-
-fn bug<'a>()
-where
- for<'b> [(); {
- let x: &'b ();
- 0
- }]:
-{}
-
-fn main() {}
diff --git a/tests/ui/const-generics/issues/issue-88997.stderr b/tests/ui/const-generics/issues/issue-88997.stderr
index 505ba0da2..b49d52dd0 100644
--- a/tests/ui/const-generics/issues/issue-88997.stderr
+++ b/tests/ui/const-generics/issues/issue-88997.stderr
@@ -3,12 +3,16 @@ error[E0770]: the type of const parameters must not depend on other generic para
|
LL | struct Range<T: PartialOrd, const MIN: T, const MAX: T>(T)
| ^ the type must not depend on the parameter `T`
+ |
+ = note: type parameters may not be used in the type of const parameters
error[E0770]: the type of const parameters must not depend on other generic parameters
--> $DIR/issue-88997.rs:8:54
|
LL | struct Range<T: PartialOrd, const MIN: T, const MAX: T>(T)
| ^ the type must not depend on the parameter `T`
+ |
+ = note: type parameters may not be used in the type of const parameters
error: aborting due to 2 previous errors
diff --git a/tests/ui/const-generics/issues/issue-90364.stderr b/tests/ui/const-generics/issues/issue-90364.stderr
index e85bd136e..23424d7b9 100644
--- a/tests/ui/const-generics/issues/issue-90364.stderr
+++ b/tests/ui/const-generics/issues/issue-90364.stderr
@@ -3,6 +3,8 @@ error[E0770]: the type of const parameters must not depend on other generic para
|
LL | pub struct Foo<T, const H: T>(T)
| ^ the type must not depend on the parameter `T`
+ |
+ = note: type parameters may not be used in the type of const parameters
error: aborting due to previous error
diff --git a/tests/ui/const-generics/late-bound-vars/in_closure.rs b/tests/ui/const-generics/late-bound-vars/in_closure.rs
index 5294cc3b5..00fb535f0 100644
--- a/tests/ui/const-generics/late-bound-vars/in_closure.rs
+++ b/tests/ui/const-generics/late-bound-vars/in_closure.rs
@@ -1,4 +1,22 @@
-// run-pass
+// failure-status: 101
+// known-bug: unknown
+// error-pattern:internal compiler error
+// normalize-stderr-test "internal compiler error.*" -> ""
+// normalize-stderr-test "DefId\([^)]*\)" -> "..."
+// normalize-stderr-test "\nerror: internal compiler error.*\n\n" -> ""
+// normalize-stderr-test "note:.*unexpectedly panicked.*\n\n" -> ""
+// normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> ""
+// normalize-stderr-test "note: compiler flags.*\n\n" -> ""
+// normalize-stderr-test "note: rustc.*running on.*\n\n" -> ""
+// normalize-stderr-test "thread.*panicked.*\n" -> ""
+// normalize-stderr-test "stack backtrace:\n" -> ""
+// normalize-stderr-test "\s\d{1,}: .*\n" -> ""
+// normalize-stderr-test "\s at .*\n" -> ""
+// normalize-stderr-test ".*note: Some details.*\n" -> ""
+// normalize-stderr-test "\n\n[ ]*\n" -> ""
+// normalize-stderr-test "compiler/.*: projection" -> "projection"
+// this should run-pass
+
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
diff --git a/tests/ui/const-generics/late-bound-vars/in_closure.stderr b/tests/ui/const-generics/late-bound-vars/in_closure.stderr
new file mode 100644
index 000000000..557fbea2e
--- /dev/null
+++ b/tests/ui/const-generics/late-bound-vars/in_closure.stderr
@@ -0,0 +1,13 @@
+error: query stack during panic:
+#0 [mir_borrowck] borrow-checking `test::{closure#0}::{constant#1}`
+#1 [mir_drops_elaborated_and_const_checked] elaborating drops for `test::{closure#0}::{constant#1}`
+#2 [mir_for_ctfe] caching mir of `test::{closure#0}::{constant#1}` for CTFE
+#3 [eval_to_allocation_raw] const-evaluating + checking `test::{closure#0}::{constant#1}`
+#4 [eval_to_allocation_raw] const-evaluating + checking `test::{closure#0}::{constant#1}`
+#5 [eval_to_valtree] evaluating type-level constant
+#6 [typeck] type-checking `test`
+#7 [used_trait_imports] finding used_trait_imports `test`
+#8 [analysis] running analysis passes on this crate
+end of query stack
+error: aborting due to previous error
+
diff --git a/tests/ui/const-generics/late-bound-vars/simple.rs b/tests/ui/const-generics/late-bound-vars/simple.rs
index 6da5395ef..5d19aaf0b 100644
--- a/tests/ui/const-generics/late-bound-vars/simple.rs
+++ b/tests/ui/const-generics/late-bound-vars/simple.rs
@@ -1,4 +1,21 @@
-// run-pass
+// failure-status: 101
+// known-bug: unknown
+// error-pattern:internal compiler error
+// normalize-stderr-test "internal compiler error.*" -> ""
+// normalize-stderr-test "DefId\([^)]*\)" -> "..."
+// normalize-stderr-test "\nerror: internal compiler error.*\n\n" -> ""
+// normalize-stderr-test "note:.*unexpectedly panicked.*\n\n" -> ""
+// normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> ""
+// normalize-stderr-test "note: compiler flags.*\n\n" -> ""
+// normalize-stderr-test "note: rustc.*running on.*\n\n" -> ""
+// normalize-stderr-test "thread.*panicked.*\n" -> ""
+// normalize-stderr-test "stack backtrace:\n" -> ""
+// normalize-stderr-test "\s\d{1,}: .*\n" -> ""
+// normalize-stderr-test "\s at .*\n" -> ""
+// normalize-stderr-test ".*note: Some details.*\n" -> ""
+// normalize-stderr-test "\n\n[ ]*\n" -> ""
+// normalize-stderr-test "compiler/.*: projection" -> "projection"
+
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
diff --git a/tests/ui/const-generics/late-bound-vars/simple.stderr b/tests/ui/const-generics/late-bound-vars/simple.stderr
new file mode 100644
index 000000000..c0568f5a5
--- /dev/null
+++ b/tests/ui/const-generics/late-bound-vars/simple.stderr
@@ -0,0 +1,13 @@
+error: query stack during panic:
+#0 [mir_borrowck] borrow-checking `test::{constant#1}`
+#1 [mir_drops_elaborated_and_const_checked] elaborating drops for `test::{constant#1}`
+#2 [mir_for_ctfe] caching mir of `test::{constant#1}` for CTFE
+#3 [eval_to_allocation_raw] const-evaluating + checking `test::{constant#1}`
+#4 [eval_to_allocation_raw] const-evaluating + checking `test::{constant#1}`
+#5 [eval_to_valtree] evaluating type-level constant
+#6 [typeck] type-checking `test`
+#7 [used_trait_imports] finding used_trait_imports `test`
+#8 [analysis] running analysis passes on this crate
+end of query stack
+error: aborting due to previous error
+
diff --git a/tests/ui/const-generics/min_const_generics/forbid-non-static-lifetimes.rs b/tests/ui/const-generics/min_const_generics/forbid-non-static-lifetimes.rs
index 6215b7d93..86f2bc9c7 100644
--- a/tests/ui/const-generics/min_const_generics/forbid-non-static-lifetimes.rs
+++ b/tests/ui/const-generics/min_const_generics/forbid-non-static-lifetimes.rs
@@ -5,7 +5,7 @@ fn test<const N: usize>() {}
fn issue_75323_and_74447_1<'a>() -> &'a () {
test::<{ let _: &'a (); 3 },>();
- //~^ ERROR a non-static lifetime is not allowed in a `const`
+ //~^ ERROR generic parameters may not be used in const operations
&()
}
@@ -19,7 +19,7 @@ fn issue_75323_and_74447_3() {
fn issue_73375<'a>() {
[(); (|_: &'a u8| (), 0).1];
- //~^ ERROR a non-static lifetime is not allowed in a `const`
+ //~^ ERROR generic parameters may not be used in const operations
}
fn main() {}
diff --git a/tests/ui/const-generics/min_const_generics/forbid-non-static-lifetimes.stderr b/tests/ui/const-generics/min_const_generics/forbid-non-static-lifetimes.stderr
index 5f641b070..7726016eb 100644
--- a/tests/ui/const-generics/min_const_generics/forbid-non-static-lifetimes.stderr
+++ b/tests/ui/const-generics/min_const_generics/forbid-non-static-lifetimes.stderr
@@ -1,21 +1,20 @@
-error[E0658]: a non-static lifetime is not allowed in a `const`
+error: generic parameters may not be used in const operations
--> $DIR/forbid-non-static-lifetimes.rs:7:22
|
LL | test::<{ let _: &'a (); 3 },>();
- | ^^
+ | ^^ cannot perform const operation using `'a`
|
- = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
- = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
+ = note: lifetime parameters may not be used in const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
-error[E0658]: a non-static lifetime is not allowed in a `const`
+error: generic parameters may not be used in const operations
--> $DIR/forbid-non-static-lifetimes.rs:21:16
|
LL | [(); (|_: &'a u8| (), 0).1];
- | ^^
+ | ^^ cannot perform const operation using `'a`
|
- = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
- = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
+ = note: lifetime parameters may not be used in const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: aborting due to 2 previous errors
-For more information about this error, try `rustc --explain E0658`.
diff --git a/tests/ui/const-generics/nested-type.rs b/tests/ui/const-generics/nested-type.rs
index 5240f5c3b..ff9501806 100644
--- a/tests/ui/const-generics/nested-type.rs
+++ b/tests/ui/const-generics/nested-type.rs
@@ -3,7 +3,7 @@
#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
-struct Foo<const N: [u8; { //[min]~ ERROR `[u8; _]` is forbidden
+struct Foo<const N: [u8; {
struct Foo<const N: usize>;
impl<const N: usize> Foo<N> {
@@ -15,5 +15,9 @@ struct Foo<const N: [u8; { //[min]~ ERROR `[u8; _]` is forbidden
Foo::<17>::value()
//~^ ERROR cannot call non-const fn
}]>;
+//[min]~^^^^^^^^^^^^ ERROR `[u8; {
+
+// N.B. it is important that the comment above is not inside the array length,
+// otherwise it may check for itself, instead of the actual error
fn main() {}
diff --git a/tests/ui/const-generics/occurs-check/unused-substs-2.rs b/tests/ui/const-generics/occurs-check/unused-substs-2.rs
index 9b1212694..84e24d1a3 100644
--- a/tests/ui/const-generics/occurs-check/unused-substs-2.rs
+++ b/tests/ui/const-generics/occurs-check/unused-substs-2.rs
@@ -1,9 +1,9 @@
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
-// The goal is to get an unevaluated const `ct` with a `Ty::Infer(TyVar(_#1t)` subst.
+// The goal is to get an unevaluated const `ct` with a `Ty::Infer(TyVar(?1t)` subst.
//
-// If we are then able to infer `ty::Infer(TyVar(_#1t) := Ty<ct>` we introduced an
+// If we are then able to infer `ty::Infer(TyVar(?1t) := Ty<ct>` we introduced an
// artificial inference cycle.
struct Foo<const N: usize>;
@@ -20,8 +20,8 @@ impl<T> Bind<T> for Foo<{ 6 + 1 }> {
fn main() {
let (mut t, foo) = Foo::bind();
- // `t` is `ty::Infer(TyVar(_#1t))`
- // `foo` contains `ty::Infer(TyVar(_#1t))` in its substs
+ // `t` is `ty::Infer(TyVar(?1t))`
+ // `foo` contains `ty::Infer(TyVar(?1t))` in its substs
t = foo;
//~^ ERROR mismatched types
//~| NOTE cyclic type
diff --git a/tests/ui/const-generics/occurs-check/unused-substs-3.rs b/tests/ui/const-generics/occurs-check/unused-substs-3.rs
index d5aeab47e..6db18d587 100644
--- a/tests/ui/const-generics/occurs-check/unused-substs-3.rs
+++ b/tests/ui/const-generics/occurs-check/unused-substs-3.rs
@@ -1,9 +1,9 @@
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
-// The goal is to get an unevaluated const `ct` with a `Ty::Infer(TyVar(_#1t)` subst.
+// The goal is to get an unevaluated const `ct` with a `Ty::Infer(TyVar(?1t)` subst.
//
-// If we are then able to infer `ty::Infer(TyVar(_#1t) := Ty<ct>` we introduced an
+// If we are then able to infer `ty::Infer(TyVar(?1t) := Ty<ct>` we introduced an
// artificial inference cycle.
fn bind<T>() -> (T, [u8; 6 + 1]) {
todo!()
@@ -11,8 +11,8 @@ fn bind<T>() -> (T, [u8; 6 + 1]) {
fn main() {
let (mut t, foo) = bind();
- // `t` is `ty::Infer(TyVar(_#1t))`
- // `foo` contains `ty::Infer(TyVar(_#1t))` in its substs
+ // `t` is `ty::Infer(TyVar(?1t))`
+ // `foo` contains `ty::Infer(TyVar(?1t))` in its substs
t = foo;
//~^ ERROR mismatched types
//~| NOTE cyclic type
diff --git a/tests/ui/const-generics/outer-lifetime-in-const-generic-default.rs b/tests/ui/const-generics/outer-lifetime-in-const-generic-default.rs
index 3018439af..de710b0e3 100644
--- a/tests/ui/const-generics/outer-lifetime-in-const-generic-default.rs
+++ b/tests/ui/const-generics/outer-lifetime-in-const-generic-default.rs
@@ -2,7 +2,7 @@ struct Foo<
'a,
const N: usize = {
let x: &'a ();
- //~^ ERROR use of non-static lifetime `'a` in const generic
+ //~^ ERROR generic parameters may not be used in const operations
3
},
>(&'a ());
diff --git a/tests/ui/const-generics/outer-lifetime-in-const-generic-default.stderr b/tests/ui/const-generics/outer-lifetime-in-const-generic-default.stderr
index 9d9555d3f..6b0d18f19 100644
--- a/tests/ui/const-generics/outer-lifetime-in-const-generic-default.stderr
+++ b/tests/ui/const-generics/outer-lifetime-in-const-generic-default.stderr
@@ -1,11 +1,11 @@
-error[E0771]: use of non-static lifetime `'a` in const generic
+error: generic parameters may not be used in const operations
--> $DIR/outer-lifetime-in-const-generic-default.rs:4:17
|
LL | let x: &'a ();
- | ^^
+ | ^^ cannot perform const operation using `'a`
|
- = note: for more information, see issue #74052 <https://github.com/rust-lang/rust/issues/74052>
+ = note: lifetime 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
-For more information about this error, try `rustc --explain E0771`.
diff --git a/tests/ui/const-generics/sneaky-array-repeat-expr.rs b/tests/ui/const-generics/sneaky-array-repeat-expr.rs
index b147c246b..cd1607608 100644
--- a/tests/ui/const-generics/sneaky-array-repeat-expr.rs
+++ b/tests/ui/const-generics/sneaky-array-repeat-expr.rs
@@ -10,6 +10,7 @@ impl<const N: usize> Trait<N> for () {
pub const fn foo<const N: usize>() where (): Trait<N> {
let bar = [(); <()>::Assoc];
//~^ error: constant expression depends on a generic parameter
+ //~| error: constant expression depends on a generic parameter
}
trait Trait2<const N: usize> {
@@ -24,6 +25,7 @@ impl<const N: usize> Trait2<N> for () {
pub const fn foo2<const N: usize>() where (): Trait2<N> {
let bar2 = [(); <()>::Assoc2];
//~^ error: constant expression depends on a generic parameter
+ //~| error: constant expression depends on a generic parameter
}
fn main() {
diff --git a/tests/ui/const-generics/sneaky-array-repeat-expr.stderr b/tests/ui/const-generics/sneaky-array-repeat-expr.stderr
index 5c77375d3..e532f27a1 100644
--- a/tests/ui/const-generics/sneaky-array-repeat-expr.stderr
+++ b/tests/ui/const-generics/sneaky-array-repeat-expr.stderr
@@ -7,12 +7,28 @@ LL | let bar = [(); <()>::Assoc];
= note: this may fail depending on what value the parameter takes
error: constant expression depends on a generic parameter
- --> $DIR/sneaky-array-repeat-expr.rs:25:21
+ --> $DIR/sneaky-array-repeat-expr.rs:11:15
+ |
+LL | let bar = [(); <()>::Assoc];
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: this may fail depending on what value the parameter takes
+
+error: constant expression depends on a generic parameter
+ --> $DIR/sneaky-array-repeat-expr.rs:26:21
|
LL | let bar2 = [(); <()>::Assoc2];
| ^^^^^^^^^^^^
|
= note: this may fail depending on what value the parameter takes
-error: aborting due to 2 previous errors
+error: constant expression depends on a generic parameter
+ --> $DIR/sneaky-array-repeat-expr.rs:26:16
+ |
+LL | let bar2 = [(); <()>::Assoc2];
+ | ^^^^^^^^^^^^^^^^^^
+ |
+ = note: this may fail depending on what value the parameter takes
+
+error: aborting due to 4 previous errors
diff --git a/tests/ui/const-generics/transmute-fail.stderr b/tests/ui/const-generics/transmute-fail.stderr
index 41b098135..3d1197afd 100644
--- a/tests/ui/const-generics/transmute-fail.stderr
+++ b/tests/ui/const-generics/transmute-fail.stderr
@@ -4,8 +4,8 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-
LL | std::mem::transmute(v)
| ^^^^^^^^^^^^^^^^^^^
|
- = note: source type: `[[u32; H+1]; W]` (generic size [const expr])
- = note: target type: `[[u32; W+1]; H]` (generic size [const expr])
+ = note: source type: `[[u32; H+1]; W]` (generic size {const expr})
+ = note: target type: `[[u32; W+1]; H]` (generic size {const expr})
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/transmute-fail.rs:16:5
@@ -34,8 +34,8 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-
LL | std::mem::transmute(v)
| ^^^^^^^^^^^^^^^^^^^
|
- = note: source type: `[[u32; H]; W]` (generic size [const expr])
- = note: target type: `[u32; W * H * H]` (generic size [const expr])
+ = note: source type: `[[u32; H]; W]` (generic size {const expr})
+ = note: target type: `[u32; W * H * H]` (generic size {const expr})
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/transmute-fail.rs:30:5
diff --git a/tests/ui/const-generics/variant-discrimiant-no-generics.full.stderr b/tests/ui/const-generics/variant-discrimiant-no-generics.full.stderr
new file mode 100644
index 000000000..2f03b8e1f
--- /dev/null
+++ b/tests/ui/const-generics/variant-discrimiant-no-generics.full.stderr
@@ -0,0 +1,34 @@
+error: generic parameters may not be used in enum discriminant values
+ --> $DIR/variant-discrimiant-no-generics.rs:7:15
+ |
+LL | Variant = N,
+ | ^ cannot perform const operation using `N`
+ |
+ = note: const parameters may not be used in enum discriminant values
+
+error: generic parameters may not be used in enum discriminant values
+ --> $DIR/variant-discrimiant-no-generics.rs:12:17
+ |
+LL | Variant = { N + 1 },
+ | ^ cannot perform const operation using `N`
+ |
+ = note: const parameters may not be used in enum discriminant values
+
+error: generic parameters may not be used in enum discriminant values
+ --> $DIR/variant-discrimiant-no-generics.rs:18:37
+ |
+LL | Variant = { std::mem::size_of::<T>() as isize },
+ | ^ cannot perform const operation using `T`
+ |
+ = note: type parameters may not be used in enum discriminant values
+
+error: generic parameters may not be used in enum discriminant values
+ --> $DIR/variant-discrimiant-no-generics.rs:25:17
+ |
+LL | let a: &'a ();
+ | ^^ cannot perform const operation using `'a`
+ |
+ = note: lifetime parameters may not be used in enum discriminant values
+
+error: aborting due to 4 previous errors
+
diff --git a/tests/ui/const-generics/variant-discrimiant-no-generics.min.stderr b/tests/ui/const-generics/variant-discrimiant-no-generics.min.stderr
new file mode 100644
index 000000000..2f03b8e1f
--- /dev/null
+++ b/tests/ui/const-generics/variant-discrimiant-no-generics.min.stderr
@@ -0,0 +1,34 @@
+error: generic parameters may not be used in enum discriminant values
+ --> $DIR/variant-discrimiant-no-generics.rs:7:15
+ |
+LL | Variant = N,
+ | ^ cannot perform const operation using `N`
+ |
+ = note: const parameters may not be used in enum discriminant values
+
+error: generic parameters may not be used in enum discriminant values
+ --> $DIR/variant-discrimiant-no-generics.rs:12:17
+ |
+LL | Variant = { N + 1 },
+ | ^ cannot perform const operation using `N`
+ |
+ = note: const parameters may not be used in enum discriminant values
+
+error: generic parameters may not be used in enum discriminant values
+ --> $DIR/variant-discrimiant-no-generics.rs:18:37
+ |
+LL | Variant = { std::mem::size_of::<T>() as isize },
+ | ^ cannot perform const operation using `T`
+ |
+ = note: type parameters may not be used in enum discriminant values
+
+error: generic parameters may not be used in enum discriminant values
+ --> $DIR/variant-discrimiant-no-generics.rs:25:17
+ |
+LL | let a: &'a ();
+ | ^^ cannot perform const operation using `'a`
+ |
+ = note: lifetime parameters may not be used in enum discriminant values
+
+error: aborting due to 4 previous errors
+
diff --git a/tests/ui/const-generics/variant-discrimiant-no-generics.rs b/tests/ui/const-generics/variant-discrimiant-no-generics.rs
new file mode 100644
index 000000000..e286aa9a6
--- /dev/null
+++ b/tests/ui/const-generics/variant-discrimiant-no-generics.rs
@@ -0,0 +1,32 @@
+// revisions: full min
+
+#![cfg_attr(full, feature(generic_const_exprs))]
+#![cfg_attr(full, allow(incomplete_features))]
+
+enum Foo<const N: isize> {
+ Variant = N,
+ //~^ ERROR: generic parameters may not be used in enum discriminant values
+}
+
+enum Owo<const N: isize> {
+ Variant = { N + 1 },
+ //~^ ERROR: generic parameters may not be used in enum discriminant values
+}
+
+#[repr(isize)]
+enum Bar<T> {
+ Variant = { std::mem::size_of::<T>() as isize },
+ Other(T), //~^ ERROR: generic parameters may not be used in enum discriminant values
+}
+
+#[repr(isize)]
+enum UwU<'a> {
+ Variant = {
+ let a: &'a ();
+ //~^ ERROR: generic parameters may not be used in enum discriminant values
+ 10_isize
+ },
+ Other(&'a ()),
+}
+
+fn main() {}