Skip to content

Commit ae85bbb

Browse files
committed
do not ICE on ty::Bound in Layout::compute
1 parent 80ce7fa commit ae85bbb

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

compiler/rustc_middle/src/ty/layout.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1259,11 +1259,11 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
12591259
tcx.layout_raw(param_env.and(normalized))?
12601260
}
12611261

1262-
ty::Bound(..) | ty::Placeholder(..) | ty::GeneratorWitness(..) | ty::Infer(_) => {
1262+
ty::Placeholder(..) | ty::GeneratorWitness(..) | ty::Infer(_) => {
12631263
bug!("Layout::compute: unexpected type `{}`", ty)
12641264
}
12651265

1266-
ty::Param(_) | ty::Error(_) => {
1266+
ty::Bound(..) | ty::Param(_) | ty::Error(_) => {
12671267
return Err(LayoutError::Unknown(ty));
12681268
}
12691269
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#![feature(const_generics, const_evaluatable_checked)]
2+
#![allow(incomplete_features)]
3+
4+
struct Bool<const B: bool>;
5+
6+
trait True {}
7+
8+
impl True for Bool<true> {}
9+
10+
fn test<T, const P: usize>() where Bool<{core::mem::size_of::<T>() > 4}>: True {
11+
todo!()
12+
}
13+
14+
fn main() {
15+
test::<2>();
16+
//~^ ERROR wrong number of type
17+
//~| ERROR constant expression depends
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0107]: wrong number of type arguments: expected 1, found 0
2+
--> $DIR/issue-76595.rs:15:5
3+
|
4+
LL | test::<2>();
5+
| ^^^^^^^^^ expected 1 type argument
6+
7+
error: constant expression depends on a generic parameter
8+
--> $DIR/issue-76595.rs:15:5
9+
|
10+
LL | fn test<T, const P: usize>() where Bool<{core::mem::size_of::<T>() > 4}>: True {
11+
| ---- required by a bound in this
12+
...
13+
LL | test::<2>();
14+
| ^^^^^^^^^
15+
|
16+
= note: this may fail depending on what value the parameter takes
17+
= note: required by this bound in `test`
18+
19+
error: aborting due to 2 previous errors
20+
21+
For more information about this error, try `rustc --explain E0107`.

0 commit comments

Comments
 (0)