Skip to content
/ rust Public
forked from rust-lang/rust

Commit 06c4cc4

Browse files
committed
Also resolve the type of constants, even if we already turned it into an error constant
1 parent 366da30 commit 06c4cc4

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

compiler/rustc_hir_typeck/src/writeback.rs

+1
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,7 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Resolver<'cx, 'tcx> {
865865
self.handle_term(ct, ty::Const::outer_exclusive_binder, |tcx, guar| {
866866
ty::Const::new_error(tcx, guar, ct.ty())
867867
})
868+
.super_fold_with(self)
868869
}
869870

870871
fn fold_predicate(&mut self, predicate: ty::Predicate<'tcx>) -> ty::Predicate<'tcx> {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//@edition: 2021
2+
3+
#![feature(type_alias_impl_trait)]
4+
type Bar = impl std::fmt::Display;
5+
6+
async fn test<const N: crate::Bar>() {}
7+
//~^ ERROR: type annotations needed
8+
//~| ERROR: `Bar` is forbidden as the type of a const generic parameter
9+
10+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0283]: type annotations needed
2+
--> $DIR/const_generic_type.rs:6:1
3+
|
4+
LL | async fn test<const N: crate::Bar>() {}
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
6+
|
7+
= note: cannot satisfy `_: std::fmt::Display`
8+
9+
error: `Bar` is forbidden as the type of a const generic parameter
10+
--> $DIR/const_generic_type.rs:6:24
11+
|
12+
LL | async fn test<const N: crate::Bar>() {}
13+
| ^^^^^^^^^^
14+
|
15+
= note: the only supported types are integers, `bool` and `char`
16+
17+
error: aborting due to 2 previous errors
18+
19+
For more information about this error, try `rustc --explain E0283`.

0 commit comments

Comments
 (0)