about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2018-06-05 14:36:36 +0100
committervarkor <github@varkor.com>2018-06-05 14:36:36 +0100
commitf37557764d0f1ca32d6b0c2525c88e49319e13d3 (patch)
tree9c40d321d518148fd0bbdc599cfb7bfb96fef8d6
parent29f48ccf396be031ee8a54e74a3a4e81866c8872 (diff)
downloadrust-f37557764d0f1ca32d6b0c2525c88e49319e13d3.tar.gz
rust-f37557764d0f1ca32d6b0c2525c88e49319e13d3.zip
Fix the use of closures within #[panic_implementation]
-rw-r--r--src/librustc_typeck/check/mod.rs2
-rw-r--r--src/test/compile-fail/panic_implementation-closures.rs21
2 files changed, 22 insertions, 1 deletions
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index c2c71d90f06..0c1c2ab4817 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -1131,7 +1131,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
 
     // Check that a function marked as `#[panic_implementation]` has signature `fn(&PanicInfo) -> !`
     if let Some(panic_impl_did) = fcx.tcx.lang_items().panic_impl() {
-        if panic_impl_did == fn_hir_id.owner_def_id() {
+        if panic_impl_did == fcx.tcx.hir.local_def_id(fn_id) {
             if let Some(panic_info_did) = fcx.tcx.lang_items().panic_info() {
                 if declared_ret_ty.sty != ty::TyNever {
                     fcx.tcx.sess.span_err(
diff --git a/src/test/compile-fail/panic_implementation-closures.rs b/src/test/compile-fail/panic_implementation-closures.rs
new file mode 100644
index 00000000000..4fa9a639928
--- /dev/null
+++ b/src/test/compile-fail/panic_implementation-closures.rs
@@ -0,0 +1,21 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// compile-pass
+
+#![crate_type = "rlib"]
+#![no_std]
+#![feature(panic_implementation)]
+
+#[panic_implementation]
+pub fn panic_fmt(_: &::core::panic::PanicInfo) -> ! {
+    |x: u8| x;
+    loop {}
+}