mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 22:41:50 +00:00
Don't ICE on bound types in sized conditions
This commit is contained in:
parent
3eb5c4581a
commit
f4a4a31479
@ -2148,12 +2148,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
}))
|
||||
}
|
||||
|
||||
ty::Alias(..) | ty::Param(_) => None,
|
||||
ty::Alias(..) | ty::Param(_) | ty::Placeholder(..) => None,
|
||||
ty::Infer(ty::TyVar(_)) => Ambiguous,
|
||||
|
||||
ty::Placeholder(..)
|
||||
| ty::Bound(..)
|
||||
| ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
|
||||
// We can make this an ICE if/once we actually instantiate the trait obligation.
|
||||
ty::Bound(..) => None,
|
||||
|
||||
ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
|
||||
bug!("asked to assemble builtin bounds of unexpected type: {:?}", self_ty);
|
||||
}
|
||||
}
|
||||
|
13
tests/ui/traits/non_lifetime_binders/bad-sized-cond.rs
Normal file
13
tests/ui/traits/non_lifetime_binders/bad-sized-cond.rs
Normal file
@ -0,0 +1,13 @@
|
||||
#![feature(non_lifetime_binders)]
|
||||
//~^ WARN is incomplete and may not be safe
|
||||
|
||||
pub fn foo()
|
||||
where
|
||||
for<V> V: Sized,
|
||||
{
|
||||
}
|
||||
|
||||
fn main() {
|
||||
foo();
|
||||
//~^ ERROR the size for values of type `V` cannot be known at compilation time
|
||||
}
|
28
tests/ui/traits/non_lifetime_binders/bad-sized-cond.stderr
Normal file
28
tests/ui/traits/non_lifetime_binders/bad-sized-cond.stderr
Normal file
@ -0,0 +1,28 @@
|
||||
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/bad-sized-cond.rs:1:12
|
||||
|
|
||||
LL | #![feature(non_lifetime_binders)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
error[E0277]: the size for values of type `V` cannot be known at compilation time
|
||||
--> $DIR/bad-sized-cond.rs:11:5
|
||||
|
|
||||
LL | foo();
|
||||
| ^^^ doesn't have a size known at compile-time
|
||||
|
|
||||
= help: the trait `Sized` is not implemented for `V`
|
||||
note: required by a bound in `foo`
|
||||
--> $DIR/bad-sized-cond.rs:6:15
|
||||
|
|
||||
LL | pub fn foo()
|
||||
| --- required by a bound in this
|
||||
LL | where
|
||||
LL | for<V> V: Sized,
|
||||
| ^^^^^ required by this bound in `foo`
|
||||
|
||||
error: aborting due to previous error; 1 warning emitted
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
Loading…
Reference in New Issue
Block a user