Skip to content

Commit f4a4a31

Browse files
Don't ICE on bound types in sized conditions
1 parent 3eb5c45 commit f4a4a31

File tree

3 files changed

+46
-4
lines changed

3 files changed

+46
-4
lines changed

compiler/rustc_trait_selection/src/traits/select/mod.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -2148,12 +2148,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
21482148
}))
21492149
}
21502150

2151-
ty::Alias(..) | ty::Param(_) => None,
2151+
ty::Alias(..) | ty::Param(_) | ty::Placeholder(..) => None,
21522152
ty::Infer(ty::TyVar(_)) => Ambiguous,
21532153

2154-
ty::Placeholder(..)
2155-
| ty::Bound(..)
2156-
| ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
2154+
// We can make this an ICE if/once we actually instantiate the trait obligation.
2155+
ty::Bound(..) => None,
2156+
2157+
ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
21572158
bug!("asked to assemble builtin bounds of unexpected type: {:?}", self_ty);
21582159
}
21592160
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#![feature(non_lifetime_binders)]
2+
//~^ WARN is incomplete and may not be safe
3+
4+
pub fn foo()
5+
where
6+
for<V> V: Sized,
7+
{
8+
}
9+
10+
fn main() {
11+
foo();
12+
//~^ ERROR the size for values of type `V` cannot be known at compilation time
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/bad-sized-cond.rs:1:12
3+
|
4+
LL | #![feature(non_lifetime_binders)]
5+
| ^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
8+
= note: `#[warn(incomplete_features)]` on by default
9+
10+
error[E0277]: the size for values of type `V` cannot be known at compilation time
11+
--> $DIR/bad-sized-cond.rs:11:5
12+
|
13+
LL | foo();
14+
| ^^^ doesn't have a size known at compile-time
15+
|
16+
= help: the trait `Sized` is not implemented for `V`
17+
note: required by a bound in `foo`
18+
--> $DIR/bad-sized-cond.rs:6:15
19+
|
20+
LL | pub fn foo()
21+
| --- required by a bound in this
22+
LL | where
23+
LL | for<V> V: Sized,
24+
| ^^^^^ required by this bound in `foo`
25+
26+
error: aborting due to previous error; 1 warning emitted
27+
28+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)