1
Fork 0

Work around #3215/#3217 use-after-free in typeck::check::alt

This commit is contained in:
Ben Blum 2012-08-17 15:06:46 -04:00
parent 5026ea0446
commit 09cf5c1de4

View file

@ -235,7 +235,10 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
ast::pat_struct(path, fields, etc) => {
// Grab the class data that we care about.
let class_fields, class_id, substitutions;
match structure_of(fcx, pat.span, expected) {
// FIXME(#3217) If this were "match structure_of...", this bug causes
// it to not live long enough for 'substitutions'.
let structure = structure_of(fcx, pat.span, expected);
match structure {
ty::ty_class(cid, ref substs) => {
class_id = cid;
substitutions = substs;