mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 08:44:35 +00:00
Check explicitly that tuple initializer is Sized.
This commit is contained in:
parent
7acce3724d
commit
17fca8b460
@ -1097,6 +1097,9 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||
ObligationCauseCode::AssignmentLhsSized => {
|
||||
err.note("the left-hand-side of an assignment must have a statically known size");
|
||||
}
|
||||
ObligationCauseCode::TupleInitializerSized => {
|
||||
err.note("tuples must have a statically known size to be initialized");
|
||||
}
|
||||
ObligationCauseCode::StructInitializerSized => {
|
||||
err.note("structs must have a statically known size to be initialized");
|
||||
}
|
||||
|
@ -121,6 +121,8 @@ pub enum ObligationCauseCode<'tcx> {
|
||||
// Various cases where expressions must be sized/copy/etc:
|
||||
/// L = X implies that L is Sized
|
||||
AssignmentLhsSized,
|
||||
/// (x1, .., xn) must be Sized
|
||||
TupleInitializerSized,
|
||||
/// S { ... } must be Sized
|
||||
StructInitializerSized,
|
||||
/// Type of each variable must be Sized
|
||||
|
@ -189,6 +189,7 @@ impl<'a, 'tcx> Lift<'tcx> for traits::ObligationCauseCode<'a> {
|
||||
tcx.lift(&ty).map(super::ObjectCastObligation)
|
||||
}
|
||||
super::AssignmentLhsSized => Some(super::AssignmentLhsSized),
|
||||
super::TupleInitializerSized => Some(super::TupleInitializerSized),
|
||||
super::StructInitializerSized => Some(super::StructInitializerSized),
|
||||
super::VariableType(id) => Some(super::VariableType(id)),
|
||||
super::ReturnType(id) => Some(super::ReturnType(id)),
|
||||
@ -476,6 +477,7 @@ impl<'tcx> TypeFoldable<'tcx> for traits::ObligationCauseCode<'tcx> {
|
||||
super::TupleElem |
|
||||
super::ItemObligation(_) |
|
||||
super::AssignmentLhsSized |
|
||||
super::TupleInitializerSized |
|
||||
super::StructInitializerSized |
|
||||
super::VariableType(_) |
|
||||
super::ReturnType(_) |
|
||||
@ -523,6 +525,7 @@ impl<'tcx> TypeFoldable<'tcx> for traits::ObligationCauseCode<'tcx> {
|
||||
super::TupleElem |
|
||||
super::ItemObligation(_) |
|
||||
super::AssignmentLhsSized |
|
||||
super::TupleInitializerSized |
|
||||
super::StructInitializerSized |
|
||||
super::VariableType(_) |
|
||||
super::ReturnType(_) |
|
||||
|
@ -3854,6 +3854,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
if tuple.references_error() {
|
||||
tcx.types.err
|
||||
} else {
|
||||
self.require_type_is_sized(tuple, expr.span, traits::TupleInitializerSized);
|
||||
tuple
|
||||
}
|
||||
}
|
||||
|
@ -54,6 +54,7 @@ fn f9<X: ?Sized>(x1: Box<S<X>>) {
|
||||
fn f10<X: ?Sized>(x1: Box<S<X>>) {
|
||||
f5(&(32, *x1));
|
||||
//~^ ERROR `X: std::marker::Sized` is not satisfied
|
||||
//~| ERROR `X: std::marker::Sized` is not satisfied
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
|
Loading…
Reference in New Issue
Block a user