Disallow deconstructing destructing structs (fixes #3147)
This commit is contained in:
parent
849d5649ef
commit
c321cdbac6
2 changed files with 23 additions and 0 deletions
|
|
@ -270,6 +270,12 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
|
|||
}
|
||||
}
|
||||
|
||||
// Forbid pattern-matching structs with destructors.
|
||||
if ty::has_dtor(tcx, class_id) {
|
||||
tcx.sess.span_err(pat.span, ~"deconstructing struct not allowed \
|
||||
in pattern (it has a destructor)");
|
||||
}
|
||||
|
||||
// Index the class fields.
|
||||
let field_map = std::map::box_str_hash();
|
||||
for class_fields.eachi |i, class_field| {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue