diff options
| author | Ralf Jung <post@ralfj.de> | 2018-10-08 14:21:41 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2018-10-09 13:08:00 +0200 |
| commit | 976880aa8493cec9e16b38c24f3113f1bbd91b88 (patch) | |
| tree | 80bfb6c095cd73b862cbb01ceca44d986f077900 | |
| parent | 6899af82fd80bd83a5e580c72c1655ac3d7a86d3 (diff) | |
| download | rust-976880aa8493cec9e16b38c24f3113f1bbd91b88.tar.gz rust-976880aa8493cec9e16b38c24f3113f1bbd91b88.zip | |
dont fail when validating non-local closures
| -rw-r--r-- | src/librustc_mir/interpret/validity.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs index 0aa2e708043..3be710ef398 100644 --- a/src/librustc_mir/interpret/validity.rs +++ b/src/librustc_mir/interpret/validity.rs @@ -207,7 +207,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> bug!("Unexpected unsized type tail: {:?}", tail), } } - // for safe ptrs, recursively check + // for safe ptrs, also check the ptr values itself if !ty.is_unsafe_ptr() { // Make sure this is non-NULL and aligned let (size, align) = self.size_and_align_of(place.extra, place.layout)?; @@ -556,9 +556,13 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> match layout.ty.sty { // generators and closures. ty::Closure(def_id, _) | ty::Generator(def_id, _, _) => { - let node_id = self.tcx.hir.as_local_node_id(def_id).unwrap(); - let freevar = self.tcx.with_freevars(node_id, |fv| fv[field]); - PathElem::ClosureVar(self.tcx.hir.name(freevar.var_id())) + if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) { + let freevar = self.tcx.with_freevars(node_id, |fv| fv[field]); + PathElem::ClosureVar(self.tcx.hir.name(freevar.var_id())) + } else { + // The closure is not local, so we cannot get the name + PathElem::ClosureVar(Symbol::intern(&field.to_string())) + } } // tuples |
