Skip to content

Commit 110d314

Browse files
authored
Unrolled build for #125807
Rollup merge of #125807 - oli-obk:resolve_const_types, r=compiler-errors Also resolve the type of constants, even if we already turned it into an error constant error constants can still have arbitrary types, and in this case it was turned into an error constant because there was an infer var in the *type* not the *const*. fixes #125760
2 parents 2a2c29a + befcdec commit 110d314

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-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+
error: `Bar` is forbidden as the type of a const generic parameter
2+
--> $DIR/const_generic_type.rs:7:24
3+
|
4+
LL | async fn test<const N: crate::Bar>() {
5+
| ^^^^^^^^^^
6+
|
7+
= note: the only supported types are integers, `bool` and `char`
8+
9+
error: aborting due to 1 previous error
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0283]: type annotations needed
2+
--> $DIR/const_generic_type.rs:7: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:7: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`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//@edition: 2021
2+
//@revisions: infer no_infer
3+
4+
#![feature(type_alias_impl_trait)]
5+
type Bar = impl std::fmt::Display;
6+
7+
async fn test<const N: crate::Bar>() {
8+
//[no_infer]~^ ERROR: type annotations needed
9+
//~^^ ERROR: `Bar` is forbidden as the type of a const generic parameter
10+
#[cfg(infer)]
11+
let x: u32 = N;
12+
}
13+
14+
fn main() {}

0 commit comments

Comments
 (0)