about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_hir_typeck/src/writeback.rs1
-rw-r--r--tests/ui/type-alias-impl-trait/const_generic_type.infer.stderr10
-rw-r--r--tests/ui/type-alias-impl-trait/const_generic_type.no_infer.stderr19
-rw-r--r--tests/ui/type-alias-impl-trait/const_generic_type.rs14
4 files changed, 44 insertions, 0 deletions
diff --git a/compiler/rustc_hir_typeck/src/writeback.rs b/compiler/rustc_hir_typeck/src/writeback.rs
index 31caa52d267..e337105f011 100644
--- a/compiler/rustc_hir_typeck/src/writeback.rs
+++ b/compiler/rustc_hir_typeck/src/writeback.rs
@@ -865,6 +865,7 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Resolver<'cx, 'tcx> {
         self.handle_term(ct, ty::Const::outer_exclusive_binder, |tcx, guar| {
             ty::Const::new_error(tcx, guar, ct.ty())
         })
+        .super_fold_with(self)
     }
 
     fn fold_predicate(&mut self, predicate: ty::Predicate<'tcx>) -> ty::Predicate<'tcx> {
diff --git a/tests/ui/type-alias-impl-trait/const_generic_type.infer.stderr b/tests/ui/type-alias-impl-trait/const_generic_type.infer.stderr
new file mode 100644
index 00000000000..6a1a770228d
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/const_generic_type.infer.stderr
@@ -0,0 +1,10 @@
+error: `Bar` is forbidden as the type of a const generic parameter
+  --> $DIR/const_generic_type.rs:7:24
+   |
+LL | async fn test<const N: crate::Bar>() {
+   |                        ^^^^^^^^^^
+   |
+   = note: the only supported types are integers, `bool` and `char`
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/type-alias-impl-trait/const_generic_type.no_infer.stderr b/tests/ui/type-alias-impl-trait/const_generic_type.no_infer.stderr
new file mode 100644
index 00000000000..a1a69bfaca3
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/const_generic_type.no_infer.stderr
@@ -0,0 +1,19 @@
+error[E0283]: type annotations needed
+  --> $DIR/const_generic_type.rs:7:1
+   |
+LL | async fn test<const N: crate::Bar>() {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
+   |
+   = note: cannot satisfy `_: std::fmt::Display`
+
+error: `Bar` is forbidden as the type of a const generic parameter
+  --> $DIR/const_generic_type.rs:7:24
+   |
+LL | async fn test<const N: crate::Bar>() {
+   |                        ^^^^^^^^^^
+   |
+   = note: the only supported types are integers, `bool` and `char`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0283`.
diff --git a/tests/ui/type-alias-impl-trait/const_generic_type.rs b/tests/ui/type-alias-impl-trait/const_generic_type.rs
new file mode 100644
index 00000000000..95a5e1c6286
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/const_generic_type.rs
@@ -0,0 +1,14 @@
+//@edition: 2021
+//@revisions: infer no_infer
+
+#![feature(type_alias_impl_trait)]
+type Bar = impl std::fmt::Display;
+
+async fn test<const N: crate::Bar>() {
+    //[no_infer]~^ ERROR: type annotations needed
+    //~^^ ERROR: `Bar` is forbidden as the type of a const generic parameter
+    #[cfg(infer)]
+    let x: u32 = N;
+}
+
+fn main() {}