Skip to content

Commit 873bc5c

Browse files
committed
Remove eh_unwind_resume lang item
1 parent 708a246 commit 873bc5c

File tree

18 files changed

+30
-109
lines changed

18 files changed

+30
-109
lines changed

src/doc/unstable-book/src/language-features/lang-items.md

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ fn main(_argc: isize, _argv: *const *const u8) -> isize {
5252
5353
#[lang = "eh_personality"] extern fn rust_eh_personality() {}
5454
#[lang = "panic_impl"] extern fn rust_begin_panic(info: &PanicInfo) -> ! { unsafe { intrinsics::abort() } }
55-
#[lang = "eh_unwind_resume"] extern fn rust_eh_unwind_resume() {}
5655
#[no_mangle] pub extern fn rust_eh_register_frames () {}
5756
#[no_mangle] pub extern fn rust_eh_unregister_frames () {}
5857
```
@@ -67,7 +66,7 @@ Other features provided by lang items include:
6766
marked with lang items; those specific four are `eq`, `ord`,
6867
`deref`, and `add` respectively.
6968
- stack unwinding and general failure; the `eh_personality`,
70-
`eh_unwind_resume`, `fail` and `fail_bounds_checks` lang items.
69+
`fail` and `fail_bounds_checks` lang items.
7170
- the traits in `std::marker` used to indicate types of
7271
various kinds; lang items `send`, `sync` and `copy`.
7372
- the marker types and variance indicators found in
@@ -130,12 +129,6 @@ fn start(_argc: isize, _argv: *const *const u8) -> isize {
130129
pub extern fn rust_eh_personality() {
131130
}
132131
133-
// This function may be needed based on the compilation target.
134-
#[lang = "eh_unwind_resume"]
135-
#[no_mangle]
136-
pub extern fn rust_eh_unwind_resume() {
137-
}
138-
139132
#[lang = "panic_impl"]
140133
#[no_mangle]
141134
pub extern fn rust_begin_panic(info: &PanicInfo) -> ! {
@@ -173,12 +166,6 @@ pub extern fn main(_argc: i32, _argv: *const *const u8) -> i32 {
173166
pub extern fn rust_eh_personality() {
174167
}
175168
176-
// This function may be needed based on the compilation target.
177-
#[lang = "eh_unwind_resume"]
178-
#[no_mangle]
179-
pub extern fn rust_eh_unwind_resume() {
180-
}
181-
182169
#[lang = "panic_impl"]
183170
#[no_mangle]
184171
pub extern fn rust_begin_panic(info: &PanicInfo) -> ! {
@@ -213,8 +200,8 @@ the screen. While the language item's name is `panic_impl`, the symbol name is
213200

214201
A third function, `rust_eh_unwind_resume`, is also needed if the `custom_unwind_resume`
215202
flag is set in the options of the compilation target. It allows customizing the
216-
process of resuming unwind at the end of the landing pads. The language item's name
217-
is `eh_unwind_resume`.
203+
process of resuming unwind at the end of the landing pads. Since this function
204+
must be defined in assembly code it does not have an associated language item.
218205

219206
## List of all language items
220207

@@ -247,8 +234,8 @@ the source code.
247234
- `eh_personality`: `libpanic_unwind/emcc.rs` (EMCC)
248235
- `eh_personality`: `libpanic_unwind/gcc.rs` (GNU)
249236
- `eh_personality`: `libpanic_unwind/seh.rs` (SEH)
250-
- `eh_unwind_resume`: `libpanic_unwind/gcc.rs` (GCC)
251237
- `eh_catch_typeinfo`: `libpanic_unwind/emcc.rs` (EMCC)
238+
- `rust_eh_unwind_resume`: `libpanic_unwind/gcc.rs` (GCC)
252239
- `panic`: `libcore/panicking.rs`
253240
- `panic_bounds_check`: `libcore/panicking.rs`
254241
- `panic_impl`: `libcore/panicking.rs`

src/librustc/middle/lang_items.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ pub fn whitelisted(tcx: TyCtxt<'_>, lang_item: LangItem) -> bool {
5757
// symbols. Other panic runtimes ensure that the relevant symbols are
5858
// available to link things together, but they're never exercised.
5959
if tcx.sess.panic_strategy() != PanicStrategy::Unwind {
60-
return lang_item == LangItem::EhPersonalityLangItem
61-
|| lang_item == LangItem::EhUnwindResumeLangItem;
60+
return lang_item == LangItem::EhPersonalityLangItem;
6261
}
6362

6463
false

src/librustc_codegen_llvm/context.rs

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use crate::abi::FnAbi;
21
use crate::attributes;
32
use crate::debuginfo;
43
use crate::llvm;
@@ -15,23 +14,20 @@ use rustc::mir::mono::CodegenUnit;
1514
use rustc::session::config::{self, CFGuard, DebugInfo};
1615
use rustc::session::Session;
1716
use rustc::ty::layout::{
18-
FnAbiExt, HasParamEnv, LayoutError, LayoutOf, PointeeInfo, Size, TyLayout, VariantIdx,
17+
HasParamEnv, LayoutError, LayoutOf, PointeeInfo, Size, TyLayout, VariantIdx,
1918
};
2019
use rustc::ty::{self, Instance, Ty, TyCtxt};
2120
use rustc_codegen_ssa::base::wants_msvc_seh;
2221
use rustc_data_structures::base_n;
2322
use rustc_data_structures::const_cstr;
2423
use rustc_data_structures::fx::FxHashMap;
2524
use rustc_data_structures::small_c_str::SmallCStr;
26-
use rustc_hir::Unsafety;
2725
use rustc_target::spec::{HasTargetSpec, Target};
2826

29-
use crate::abi::Abi;
3027
use rustc_span::source_map::{Span, DUMMY_SP};
3128
use rustc_span::symbol::Symbol;
3229
use std::cell::{Cell, RefCell};
3330
use std::ffi::CStr;
34-
use std::iter;
3531
use std::str;
3632
use std::sync::Arc;
3733

@@ -87,7 +83,6 @@ pub struct CodegenCx<'ll, 'tcx> {
8783
pub dbg_cx: Option<debuginfo::CrateDebugContext<'ll, 'tcx>>,
8884

8985
eh_personality: Cell<Option<&'ll Value>>,
90-
eh_unwind_resume: Cell<Option<&'ll Value>>,
9186
pub rust_try_fn: Cell<Option<&'ll Value>>,
9287

9388
intrinsics: RefCell<FxHashMap<&'static str, &'ll Value>>,
@@ -328,7 +323,6 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
328323
isize_ty,
329324
dbg_cx,
330325
eh_personality: Cell::new(None),
331-
eh_unwind_resume: Cell::new(None),
332326
rust_try_fn: Cell::new(None),
333327
intrinsics: Default::default(),
334328
local_gen_sym_counter: Cell::new(0),
@@ -406,45 +400,6 @@ impl MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> {
406400
llfn
407401
}
408402

409-
// Returns a Value of the "eh_unwind_resume" lang item if one is defined,
410-
// otherwise declares it as an external function.
411-
fn eh_unwind_resume(&self) -> &'ll Value {
412-
let unwresume = &self.eh_unwind_resume;
413-
if let Some(llfn) = unwresume.get() {
414-
return llfn;
415-
}
416-
417-
let tcx = self.tcx;
418-
assert!(self.sess().target.target.options.custom_unwind_resume);
419-
if let Some(def_id) = tcx.lang_items().eh_unwind_resume() {
420-
let llfn = self.get_fn_addr(
421-
ty::Instance::resolve(
422-
tcx,
423-
ty::ParamEnv::reveal_all(),
424-
def_id,
425-
tcx.intern_substs(&[]),
426-
)
427-
.unwrap(),
428-
);
429-
unwresume.set(Some(llfn));
430-
return llfn;
431-
}
432-
433-
let sig = ty::Binder::bind(tcx.mk_fn_sig(
434-
iter::once(tcx.mk_mut_ptr(tcx.types.u8)),
435-
tcx.types.never,
436-
false,
437-
Unsafety::Unsafe,
438-
Abi::C,
439-
));
440-
441-
let fn_abi = FnAbi::of_fn_ptr(self, sig, &[]);
442-
let llfn = self.declare_fn("rust_eh_unwind_resume", &fn_abi);
443-
attributes::apply_target_cpu_attr(self, llfn);
444-
unwresume.set(Some(llfn));
445-
llfn
446-
}
447-
448403
fn sess(&self) -> &Session {
449404
&self.tcx.sess
450405
}

src/librustc_codegen_ssa/traits/misc.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ pub trait MiscMethods<'tcx>: BackendTypes {
1414
fn get_fn(&self, instance: Instance<'tcx>) -> Self::Function;
1515
fn get_fn_addr(&self, instance: Instance<'tcx>) -> Self::Value;
1616
fn eh_personality(&self) -> Self::Value;
17-
fn eh_unwind_resume(&self) -> Self::Value;
1817
fn sess(&self) -> &Session;
1918
fn codegen_unit(&self) -> &Arc<CodegenUnit<'tcx>>;
2019
fn used_statics(&self) -> &RefCell<Vec<Self::Value>>;

src/librustc_hir/lang_items.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ language_item_table! {
240240
StartFnLangItem, "start", start_fn, Target::Fn;
241241

242242
EhPersonalityLangItem, "eh_personality", eh_personality, Target::Fn;
243-
EhUnwindResumeLangItem, "eh_unwind_resume", eh_unwind_resume, Target::Fn;
244243
EhCatchTypeinfoLangItem, "eh_catch_typeinfo", eh_catch_typeinfo, Target::Static;
245244

246245
OwnedBoxLangItem, "owned_box", owned_box, Target::Struct;

src/librustc_hir/weak_lang_items.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,5 @@ impl LanguageItems {
4343
weak_lang_items! {
4444
panic_impl, PanicImplLangItem, rust_begin_unwind;
4545
eh_personality, EhPersonalityLangItem, rust_eh_personality;
46-
eh_unwind_resume, EhUnwindResumeLangItem, rust_eh_unwind_resume;
4746
oom, OomLangItem, rust_oom;
4847
}

src/librustc_passes/weak_lang_items.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ pub fn check_crate<'tcx>(tcx: TyCtxt<'tcx>, items: &mut lang_items::LanguageItem
2828
if items.eh_personality().is_none() {
2929
items.missing.push(lang_items::EhPersonalityLangItem);
3030
}
31-
if tcx.sess.target.target.options.custom_unwind_resume & items.eh_unwind_resume().is_none() {
32-
items.missing.push(lang_items::EhUnwindResumeLangItem);
33-
}
3431

3532
{
3633
let mut cx = Context { tcx, items };

src/librustc_span/symbol.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@ symbols! {
287287
dylib,
288288
dyn_trait,
289289
eh_personality,
290-
eh_unwind_resume,
291290
enable,
292291
Encodable,
293292
env,
@@ -663,7 +662,6 @@ symbols! {
663662
rustc_variance,
664663
rustfmt,
665664
rust_eh_personality,
666-
rust_eh_unwind_resume,
667665
rust_oom,
668666
rvalue_static_promotion,
669667
sanitize,

src/librustc_target/spec/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ pub struct TargetOptions {
695695
/// Whether the target uses a custom unwind resumption routine.
696696
/// By default LLVM lowers `resume` instructions into calls to `_Unwind_Resume`
697697
/// defined in libgcc. If this option is enabled, the target must provide
698-
/// `eh_unwind_resume` lang item.
698+
/// a `rust_eh_unwind_resume` symbol.
699699
pub custom_unwind_resume: bool,
700700
/// Whether the runtime startup code requires the `main` function be passed
701701
/// `argc` and `argv` values.

src/test/compile-fail/auxiliary/panic-runtime-lang-items.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,3 @@ use core::panic::PanicInfo;
1111
fn panic_impl(info: &PanicInfo) -> ! { loop {} }
1212
#[lang = "eh_personality"]
1313
fn eh_personality() {}
14-
#[lang = "eh_unwind_resume"]
15-
fn eh_unwind_resume() {}

src/test/ui/consts/const-eval/const_panic_libcore_main.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ const X: () = unimplemented!();
1717

1818
#[lang = "eh_personality"]
1919
fn eh() {}
20-
#[lang = "eh_unwind_resume"]
21-
fn eh_unwind_resume() {}
2220

2321
#[panic_handler]
2422
fn panic(_info: &PanicInfo) -> ! {

src/test/ui/macros/macro-comma-behavior.core.stderr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
error: 1 positional argument in format string, but no arguments were given
2-
--> $DIR/macro-comma-behavior.rs:21:23
2+
--> $DIR/macro-comma-behavior.rs:20:23
33
|
44
LL | assert_eq!(1, 1, "{}",);
55
| ^^
66

77
error: 1 positional argument in format string, but no arguments were given
8-
--> $DIR/macro-comma-behavior.rs:24:23
8+
--> $DIR/macro-comma-behavior.rs:23:23
99
|
1010
LL | assert_ne!(1, 2, "{}",);
1111
| ^^
1212

1313
error: 1 positional argument in format string, but no arguments were given
14-
--> $DIR/macro-comma-behavior.rs:30:29
14+
--> $DIR/macro-comma-behavior.rs:29:29
1515
|
1616
LL | debug_assert_eq!(1, 1, "{}",);
1717
| ^^
1818

1919
error: 1 positional argument in format string, but no arguments were given
20-
--> $DIR/macro-comma-behavior.rs:33:29
20+
--> $DIR/macro-comma-behavior.rs:32:29
2121
|
2222
LL | debug_assert_ne!(1, 2, "{}",);
2323
| ^^
2424

2525
error: 1 positional argument in format string, but no arguments were given
26-
--> $DIR/macro-comma-behavior.rs:54:19
26+
--> $DIR/macro-comma-behavior.rs:53:19
2727
|
2828
LL | format_args!("{}",);
2929
| ^^
3030

3131
error: 1 positional argument in format string, but no arguments were given
32-
--> $DIR/macro-comma-behavior.rs:72:21
32+
--> $DIR/macro-comma-behavior.rs:71:21
3333
|
3434
LL | unimplemented!("{}",);
3535
| ^^
3636

3737
error: 1 positional argument in format string, but no arguments were given
38-
--> $DIR/macro-comma-behavior.rs:81:24
38+
--> $DIR/macro-comma-behavior.rs:80:24
3939
|
4040
LL | write!(f, "{}",)?;
4141
| ^^

src/test/ui/macros/macro-comma-behavior.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#[cfg(std)] use std::fmt;
1010
#[cfg(core)] use core::fmt;
1111
#[cfg(core)] #[lang = "eh_personality"] fn eh_personality() {}
12-
#[cfg(core)] #[lang = "eh_unwind_resume"] fn eh_unwind_resume() {}
1312
#[cfg(core)] #[lang = "panic_impl"] fn panic_impl(panic: &core::panic::PanicInfo) -> ! { loop {} }
1413

1514
// (see documentation of the similarly-named test in run-pass)

src/test/ui/macros/macro-comma-behavior.std.stderr

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,59 @@
11
error: 1 positional argument in format string, but no arguments were given
2-
--> $DIR/macro-comma-behavior.rs:21:23
2+
--> $DIR/macro-comma-behavior.rs:20:23
33
|
44
LL | assert_eq!(1, 1, "{}",);
55
| ^^
66

77
error: 1 positional argument in format string, but no arguments were given
8-
--> $DIR/macro-comma-behavior.rs:24:23
8+
--> $DIR/macro-comma-behavior.rs:23:23
99
|
1010
LL | assert_ne!(1, 2, "{}",);
1111
| ^^
1212

1313
error: 1 positional argument in format string, but no arguments were given
14-
--> $DIR/macro-comma-behavior.rs:30:29
14+
--> $DIR/macro-comma-behavior.rs:29:29
1515
|
1616
LL | debug_assert_eq!(1, 1, "{}",);
1717
| ^^
1818

1919
error: 1 positional argument in format string, but no arguments were given
20-
--> $DIR/macro-comma-behavior.rs:33:29
20+
--> $DIR/macro-comma-behavior.rs:32:29
2121
|
2222
LL | debug_assert_ne!(1, 2, "{}",);
2323
| ^^
2424

2525
error: 1 positional argument in format string, but no arguments were given
26-
--> $DIR/macro-comma-behavior.rs:38:18
26+
--> $DIR/macro-comma-behavior.rs:37:18
2727
|
2828
LL | eprint!("{}",);
2929
| ^^
3030

3131
error: 1 positional argument in format string, but no arguments were given
32-
--> $DIR/macro-comma-behavior.rs:50:18
32+
--> $DIR/macro-comma-behavior.rs:49:18
3333
|
3434
LL | format!("{}",);
3535
| ^^
3636

3737
error: 1 positional argument in format string, but no arguments were given
38-
--> $DIR/macro-comma-behavior.rs:54:19
38+
--> $DIR/macro-comma-behavior.rs:53:19
3939
|
4040
LL | format_args!("{}",);
4141
| ^^
4242

4343
error: 1 positional argument in format string, but no arguments were given
44-
--> $DIR/macro-comma-behavior.rs:61:17
44+
--> $DIR/macro-comma-behavior.rs:60:17
4545
|
4646
LL | print!("{}",);
4747
| ^^
4848

4949
error: 1 positional argument in format string, but no arguments were given
50-
--> $DIR/macro-comma-behavior.rs:72:21
50+
--> $DIR/macro-comma-behavior.rs:71:21
5151
|
5252
LL | unimplemented!("{}",);
5353
| ^^
5454

5555
error: 1 positional argument in format string, but no arguments were given
56-
--> $DIR/macro-comma-behavior.rs:81:24
56+
--> $DIR/macro-comma-behavior.rs:80:24
5757
|
5858
LL | write!(f, "{}",)?;
5959
| ^^

src/test/ui/no_owned_box_lang_item.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@ fn main() {
1212
}
1313

1414
#[lang = "eh_personality"] extern fn eh_personality() {}
15-
#[lang = "eh_unwind_resume"] extern fn eh_unwind_resume() {}
1615
#[lang = "panic_impl"] fn panic_impl(panic: &PanicInfo) -> ! { loop {} }

src/test/ui/panic-runtime/auxiliary/panic-runtime-lang-items.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,3 @@ use core::panic::PanicInfo;
1111
fn panic_impl(info: &PanicInfo) -> ! { loop {} }
1212
#[lang = "eh_personality"]
1313
fn eh_personality() {}
14-
#[lang = "eh_unwind_resume"]
15-
fn eh_unwind_resume() {}

src/test/ui/range/issue-54505-no-std.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ use core::ops::RangeBounds;
1515
#[lang = "eh_personality"]
1616
extern fn eh_personality() {}
1717

18-
#[cfg(target_os = "windows")]
19-
#[lang = "eh_unwind_resume"]
20-
extern fn eh_unwind_resume() {}
21-
2218

2319
// take a reference to any built-in range
2420
fn take_range(_r: &impl RangeBounds<i8>) {}

0 commit comments

Comments
 (0)