Skip to content

Commit f375577

Browse files
committed
Fix the use of closures within #[panic_implementation]
1 parent 29f48cc commit f375577

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/librustc_typeck/check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
11311131

11321132
// Check that a function marked as `#[panic_implementation]` has signature `fn(&PanicInfo) -> !`
11331133
if let Some(panic_impl_did) = fcx.tcx.lang_items().panic_impl() {
1134-
if panic_impl_did == fn_hir_id.owner_def_id() {
1134+
if panic_impl_did == fcx.tcx.hir.local_def_id(fn_id) {
11351135
if let Some(panic_info_did) = fcx.tcx.lang_items().panic_info() {
11361136
if declared_ret_ty.sty != ty::TyNever {
11371137
fcx.tcx.sess.span_err(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// compile-pass
12+
13+
#![crate_type = "rlib"]
14+
#![no_std]
15+
#![feature(panic_implementation)]
16+
17+
#[panic_implementation]
18+
pub fn panic_fmt(_: &::core::panic::PanicInfo) -> ! {
19+
|x: u8| x;
20+
loop {}
21+
}

0 commit comments

Comments
 (0)