Don't allow vectors of pinned kinds
Vectors of pinned kinds can't be safe because most interesting uses of vector perform copies
This commit is contained in:
parent
14bac217b0
commit
cb4e99b688
2 changed files with 21 additions and 0 deletions
|
|
@ -189,6 +189,9 @@ fn need_shared_or_pinned_ctor(tcx: ty::ctxt, a: @ast::expr, descr: str) {
|
|||
ast::expr_tup(_) {
|
||||
true
|
||||
}
|
||||
ast::expr_vec(exprs, _) {
|
||||
true
|
||||
}
|
||||
_ { false }
|
||||
}
|
||||
}
|
||||
|
|
@ -262,6 +265,13 @@ fn check_expr(tcx: ty::ctxt, e: @ast::expr) {
|
|||
need_shared_or_pinned_ctor(tcx, expr, "tuple parameter");
|
||||
}
|
||||
}
|
||||
ast::expr_vec(exprs, _) {
|
||||
// Putting pinned things into vectors is pretty useless since vector
|
||||
// addition can't work (it's a copy)
|
||||
for expr in exprs {
|
||||
need_expr_kind(tcx, expr, ast::kind_shared, "vector element");
|
||||
}
|
||||
}
|
||||
_ { }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue