From a49ea51b79ff129f807b17b1510086377dac557f Mon Sep 17 00:00:00 2001 From: kyren Date: Mon, 19 Feb 2018 18:05:55 -0500 Subject: [PATCH] Remove terrible awful no-good evil hack The breakage is being addressed in rust itself. --- Cargo.toml | 1 - build.rs | 25 +++++-------------------- src/function.rs | 1 - src/lib.rs | 2 -- src/lua.rs | 2 -- src/util.rs | 8 -------- 6 files changed, 5 insertions(+), 34 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 754b0ac..d61c140 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,7 +31,6 @@ compiletest_rs = { version = "0.3", optional = true } [build-dependencies] gcc = { version = "0.3.52", optional = true } -rustc_version = { version = "0.2" } [dev-dependencies] rustyline = "1.0.0" \ No newline at end of file diff --git a/build.rs b/build.rs index 070d1b9..98b5cf0 100644 --- a/build.rs +++ b/build.rs @@ -1,29 +1,14 @@ #[cfg(feature = "builtin-lua")] extern crate gcc; -extern crate rustc_version; - -use std::env; fn main() { - let target_os = env::var("CARGO_CFG_TARGET_OS"); - let target_family = env::var("CARGO_CFG_TARGET_FAMILY"); - if target_family == Ok("windows".to_string()) - && rustc_version::version().unwrap() == rustc_version::Version::parse("1.24.0").unwrap() - { - // Error handling is completely broken on windows with - // https://github.com/rust-lang/rust/pull/46833 merged, and this includes stable rustc - // 1.24.0+. `#[unwind]` fixes error handling on windows, but requires nightly! This - // HORRIBLE HACK enables `#[unwind]` on stable rust by setting RUSTC_BOOTSTRAP=1 during - // build. This is very evil, don't do this kids. - // - // See https://github.com/rust-lang/rust/issues/48251 and - // https://github.com/chucklefish/rlua/issues/71 for more details. - println!("cargo:rustc-env=RUSTC_BOOTSTRAP=1"); - println!("cargo:rustc-cfg=unwind"); - } - #[cfg(feature = "builtin-lua")] { + use std::env; + + let target_os = env::var("CARGO_CFG_TARGET_OS"); + let target_family = env::var("CARGO_CFG_TARGET_FAMILY"); + let mut config = gcc::Build::new(); if target_os == Ok("linux".to_string()) { diff --git a/src/function.rs b/src/function.rs index f41a76c..3cc9e1d 100644 --- a/src/function.rs +++ b/src/function.rs @@ -122,7 +122,6 @@ impl<'lua> Function<'lua> { /// # } /// ``` pub fn bind>(&self, args: A) -> Result> { - #[cfg_attr(unwind, unwind)] unsafe extern "C" fn bind_call_impl(state: *mut ffi::lua_State) -> c_int { let nargs = ffi::lua_gettop(state); let nbinds = ffi::lua_tointeger(state, ffi::lua_upvalueindex(2)) as c_int; diff --git a/src/lib.rs b/src/lib.rs index e7e29bc..2ae4f5a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,3 @@ -#![cfg_attr(unwind, feature(unwind_attributes))] - //! # High-level bindings to Lua //! //! The `rlua` crate provides safe high-level bindings to the [Lua programming language]. diff --git a/src/lua.rs b/src/lua.rs index e2c3e60..0b5ade3 100644 --- a/src/lua.rs +++ b/src/lua.rs @@ -759,7 +759,6 @@ impl Lua { pub(crate) unsafe fn userdata_metatable(&self) -> Result { // Used if both an __index metamethod is set and regular methods, checks methods table // first, then __index metamethod. - #[cfg_attr(unwind, unwind)] unsafe extern "C" fn meta_index_impl(state: *mut ffi::lua_State) -> c_int { ffi::luaL_checkstack(state, 2, ptr::null()); @@ -997,7 +996,6 @@ impl Lua { &'lua self, func: Callback<'callback, 'static>, ) -> Result> { - #[cfg_attr(unwind, unwind)] unsafe extern "C" fn callback_call_impl(state: *mut ffi::lua_State) -> c_int { callback_error(state, || { let lua = Lua { diff --git a/src/util.rs b/src/util.rs index 0ba3565..647efeb 100644 --- a/src/util.rs +++ b/src/util.rs @@ -119,7 +119,6 @@ where nresults: c_int, } - #[cfg_attr(unwind, unwind)] unsafe extern "C" fn do_call(state: *mut ffi::lua_State) -> c_int where F: FnOnce(*mut ffi::lua_State) -> R, @@ -270,7 +269,6 @@ pub unsafe fn take_userdata(state: *mut ffi::lua_State) -> T { ptr::read(ud) } -#[cfg_attr(unwind, unwind)] pub unsafe extern "C" fn userdata_destructor(state: *mut ffi::lua_State) -> c_int { callback_error(state, || { take_userdata::(state); @@ -308,7 +306,6 @@ where // Takes an error at the top of the stack, and if it is a WrappedError, converts it to an // Error::CallbackError with a traceback, if it is some lua type, prints the error along with a // traceback, and if it is a WrappedPanic, does not modify it. -#[cfg_attr(unwind, unwind)] pub unsafe extern "C" fn error_traceback(state: *mut ffi::lua_State) -> c_int { // I believe luaL_traceback requires this much free stack to not error. 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 { } // A variant of pcall that does not allow lua to catch panic errors from callback_error -#[cfg_attr(unwind, unwind)] pub unsafe extern "C" fn safe_pcall(state: *mut ffi::lua_State) -> c_int { ffi::luaL_checkstack(state, 2, ptr::null()); @@ -378,9 +374,7 @@ pub unsafe extern "C" fn safe_pcall(state: *mut ffi::lua_State) -> c_int { } // A variant of xpcall that does not allow lua to catch panic errors from callback_error -#[cfg_attr(unwind, unwind)] pub unsafe extern "C" fn safe_xpcall(state: *mut ffi::lua_State) -> c_int { - #[cfg_attr(unwind, unwind)] unsafe extern "C" fn xpcall_msgh(state: *mut ffi::lua_State) -> c_int { ffi::luaL_checkstack(state, 2, ptr::null()); @@ -480,7 +474,6 @@ pub unsafe fn init_error_metatables(state: *mut ffi::lua_State) { // Create error metatable - #[cfg_attr(unwind, unwind)] unsafe extern "C" fn error_tostring(state: *mut ffi::lua_State) -> c_int { ffi::luaL_checkstack(state, 2, ptr::null()); @@ -544,7 +537,6 @@ pub unsafe fn init_error_metatables(state: *mut ffi::lua_State) { // Create destructed userdata metatable - #[cfg_attr(unwind, unwind)] unsafe extern "C" fn destructed_error(state: *mut ffi::lua_State) -> c_int { ffi::luaL_checkstack(state, 2, ptr::null()); push_wrapped_error(state, Error::CallbackDestructed);