Skip to content

Commit a49ea51

Browse files
committed
Remove terrible awful no-good evil hack
The breakage is being addressed in rust itself.
1 parent e19a5b6 commit a49ea51

File tree

6 files changed

+5
-34
lines changed

6 files changed

+5
-34
lines changed

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ compiletest_rs = { version = "0.3", optional = true }
3131

3232
[build-dependencies]
3333
gcc = { version = "0.3.52", optional = true }
34-
rustc_version = { version = "0.2" }
3534

3635
[dev-dependencies]
3736
rustyline = "1.0.0"

build.rs

+5-20
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,14 @@
11
#[cfg(feature = "builtin-lua")]
22
extern crate gcc;
3-
extern crate rustc_version;
4-
5-
use std::env;
63

74
fn main() {
8-
let target_os = env::var("CARGO_CFG_TARGET_OS");
9-
let target_family = env::var("CARGO_CFG_TARGET_FAMILY");
10-
if target_family == Ok("windows".to_string())
11-
&& rustc_version::version().unwrap() == rustc_version::Version::parse("1.24.0").unwrap()
12-
{
13-
// Error handling is completely broken on windows with
14-
// https://github.com/rust-lang/rust/pull/46833 merged, and this includes stable rustc
15-
// 1.24.0+. `#[unwind]` fixes error handling on windows, but requires nightly! This
16-
// HORRIBLE HACK enables `#[unwind]` on stable rust by setting RUSTC_BOOTSTRAP=1 during
17-
// build. This is very evil, don't do this kids.
18-
//
19-
// See https://github.com/rust-lang/rust/issues/48251 and
20-
// https://github.com/chucklefish/rlua/issues/71 for more details.
21-
println!("cargo:rustc-env=RUSTC_BOOTSTRAP=1");
22-
println!("cargo:rustc-cfg=unwind");
23-
}
24-
255
#[cfg(feature = "builtin-lua")]
266
{
7+
use std::env;
8+
9+
let target_os = env::var("CARGO_CFG_TARGET_OS");
10+
let target_family = env::var("CARGO_CFG_TARGET_FAMILY");
11+
2712
let mut config = gcc::Build::new();
2813

2914
if target_os == Ok("linux".to_string()) {

src/function.rs

-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ impl<'lua> Function<'lua> {
122122
/// # }
123123
/// ```
124124
pub fn bind<A: ToLuaMulti<'lua>>(&self, args: A) -> Result<Function<'lua>> {
125-
#[cfg_attr(unwind, unwind)]
126125
unsafe extern "C" fn bind_call_impl(state: *mut ffi::lua_State) -> c_int {
127126
let nargs = ffi::lua_gettop(state);
128127
let nbinds = ffi::lua_tointeger(state, ffi::lua_upvalueindex(2)) as c_int;

src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg_attr(unwind, feature(unwind_attributes))]
2-
31
//! # High-level bindings to Lua
42
//!
53
//! The `rlua` crate provides safe high-level bindings to the [Lua programming language].

src/lua.rs

-2
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,6 @@ impl Lua {
759759
pub(crate) unsafe fn userdata_metatable<T: UserData>(&self) -> Result<c_int> {
760760
// Used if both an __index metamethod is set and regular methods, checks methods table
761761
// first, then __index metamethod.
762-
#[cfg_attr(unwind, unwind)]
763762
unsafe extern "C" fn meta_index_impl(state: *mut ffi::lua_State) -> c_int {
764763
ffi::luaL_checkstack(state, 2, ptr::null());
765764

@@ -997,7 +996,6 @@ impl Lua {
997996
&'lua self,
998997
func: Callback<'callback, 'static>,
999998
) -> Result<Function<'lua>> {
1000-
#[cfg_attr(unwind, unwind)]
1001999
unsafe extern "C" fn callback_call_impl(state: *mut ffi::lua_State) -> c_int {
10021000
callback_error(state, || {
10031001
let lua = Lua {

src/util.rs

-8
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ where
119119
nresults: c_int,
120120
}
121121

122-
#[cfg_attr(unwind, unwind)]
123122
unsafe extern "C" fn do_call<F, R>(state: *mut ffi::lua_State) -> c_int
124123
where
125124
F: FnOnce(*mut ffi::lua_State) -> R,
@@ -270,7 +269,6 @@ pub unsafe fn take_userdata<T>(state: *mut ffi::lua_State) -> T {
270269
ptr::read(ud)
271270
}
272271

273-
#[cfg_attr(unwind, unwind)]
274272
pub unsafe extern "C" fn userdata_destructor<T>(state: *mut ffi::lua_State) -> c_int {
275273
callback_error(state, || {
276274
take_userdata::<T>(state);
@@ -308,7 +306,6 @@ where
308306
// Takes an error at the top of the stack, and if it is a WrappedError, converts it to an
309307
// Error::CallbackError with a traceback, if it is some lua type, prints the error along with a
310308
// traceback, and if it is a WrappedPanic, does not modify it.
311-
#[cfg_attr(unwind, unwind)]
312309
pub unsafe extern "C" fn error_traceback(state: *mut ffi::lua_State) -> c_int {
313310
// I believe luaL_traceback requires this much free stack to not error.
314311
const LUA_TRACEBACK_STACK: c_int = 11;
@@ -355,7 +352,6 @@ pub unsafe extern "C" fn error_traceback(state: *mut ffi::lua_State) -> c_int {
355352
}
356353

357354
// A variant of pcall that does not allow lua to catch panic errors from callback_error
358-
#[cfg_attr(unwind, unwind)]
359355
pub unsafe extern "C" fn safe_pcall(state: *mut ffi::lua_State) -> c_int {
360356
ffi::luaL_checkstack(state, 2, ptr::null());
361357

@@ -378,9 +374,7 @@ pub unsafe extern "C" fn safe_pcall(state: *mut ffi::lua_State) -> c_int {
378374
}
379375

380376
// A variant of xpcall that does not allow lua to catch panic errors from callback_error
381-
#[cfg_attr(unwind, unwind)]
382377
pub unsafe extern "C" fn safe_xpcall(state: *mut ffi::lua_State) -> c_int {
383-
#[cfg_attr(unwind, unwind)]
384378
unsafe extern "C" fn xpcall_msgh(state: *mut ffi::lua_State) -> c_int {
385379
ffi::luaL_checkstack(state, 2, ptr::null());
386380

@@ -480,7 +474,6 @@ pub unsafe fn init_error_metatables(state: *mut ffi::lua_State) {
480474

481475
// Create error metatable
482476

483-
#[cfg_attr(unwind, unwind)]
484477
unsafe extern "C" fn error_tostring(state: *mut ffi::lua_State) -> c_int {
485478
ffi::luaL_checkstack(state, 2, ptr::null());
486479

@@ -544,7 +537,6 @@ pub unsafe fn init_error_metatables(state: *mut ffi::lua_State) {
544537

545538
// Create destructed userdata metatable
546539

547-
#[cfg_attr(unwind, unwind)]
548540
unsafe extern "C" fn destructed_error(state: *mut ffi::lua_State) -> c_int {
549541
ffi::luaL_checkstack(state, 2, ptr::null());
550542
push_wrapped_error(state, Error::CallbackDestructed);

0 commit comments

Comments
 (0)