Skip to content

Commit faaf250

Browse files
committed
improve the error message when #[panic_implementation] is missing
closes #51341
1 parent 5fdcd3a commit faaf250

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

src/librustc/middle/weak_lang_items.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,13 @@ fn verify<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
112112
if missing.contains(&lang_items::$item) &&
113113
!whitelisted(tcx, lang_items::$item) &&
114114
items.$name().is_none() {
115-
tcx.sess.err(&format!("language item required, but not found: `{}`",
116-
stringify!($name)));
117-
115+
if lang_items::$item == lang_items::PanicImplLangItem {
116+
tcx.sess.err(&format!("`#[panic_implementation]` function required, \
117+
but not found"));
118+
} else {
119+
tcx.sess.err(&format!("language item required, but not found: `{}`",
120+
stringify!($name)));
121+
}
118122
}
119123
)*
120124
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
// error-pattern: `#[panic_implementation]` function required, but not found
12+
13+
#![feature(lang_items)]
14+
#![no_main]
15+
#![no_std]
16+
17+
#[lang = "eh_personality"]
18+
fn eh() {}

0 commit comments

Comments
 (0)