Also resolve the type of constants, even if we already turned it into an error constant

This commit is contained in:
Oli Scherer 2024-05-31 08:56:38 +00:00
parent 366da30d55
commit 06c4cc44b6
3 changed files with 30 additions and 0 deletions

View File

@ -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> {

View File

@ -0,0 +1,10 @@
//@edition: 2021
#![feature(type_alias_impl_trait)]
type Bar = impl std::fmt::Display;
async fn test<const N: crate::Bar>() {}
//~^ ERROR: type annotations needed
//~| ERROR: `Bar` is forbidden as the type of a const generic parameter
fn main() {}

View File

@ -0,0 +1,19 @@
error[E0283]: type annotations needed
--> $DIR/const_generic_type.rs:6: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:6: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`.