Skip to content

Commit 09cf5c1

Browse files
committed
Work around #3215/#3217 use-after-free in typeck::check::alt
1 parent 5026ea0 commit 09cf5c1

File tree

1 file changed

+4
-1
lines changed
  • src/rustc/middle/typeck/check

1 file changed

+4
-1
lines changed

src/rustc/middle/typeck/check/alt.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,10 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
235235
ast::pat_struct(path, fields, etc) => {
236236
// Grab the class data that we care about.
237237
let class_fields, class_id, substitutions;
238-
match structure_of(fcx, pat.span, expected) {
238+
// FIXME(#3217) If this were "match structure_of...", this bug causes
239+
// it to not live long enough for 'substitutions'.
240+
let structure = structure_of(fcx, pat.span, expected);
241+
match structure {
239242
ty::ty_class(cid, ref substs) => {
240243
class_id = cid;
241244
substitutions = substs;

0 commit comments

Comments
 (0)