Remove terrible awful no-good evil hack

The breakage is being addressed in rust itself.
This commit is contained in:
kyren 2018-02-19 18:05:55 -05:00
parent e19a5b6481
commit a49ea51b79
6 changed files with 5 additions and 34 deletions

View file

@ -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"

View file

@ -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()) {

View file

@ -122,7 +122,6 @@ impl<'lua> Function<'lua> {
/// # }
/// ```
pub fn bind<A: ToLuaMulti<'lua>>(&self, args: A) -> Result<Function<'lua>> {
#[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;

View file

@ -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].

View file

@ -759,7 +759,6 @@ impl Lua {
pub(crate) unsafe fn userdata_metatable<T: UserData>(&self) -> Result<c_int> {
// 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<Function<'lua>> {
#[cfg_attr(unwind, unwind)]
unsafe extern "C" fn callback_call_impl(state: *mut ffi::lua_State) -> c_int {
callback_error(state, || {
let lua = Lua {

View file

@ -119,7 +119,6 @@ where
nresults: c_int,
}
#[cfg_attr(unwind, unwind)]
unsafe extern "C" fn do_call<F, R>(state: *mut ffi::lua_State) -> c_int
where
F: FnOnce(*mut ffi::lua_State) -> R,
@ -270,7 +269,6 @@ pub unsafe fn take_userdata<T>(state: *mut ffi::lua_State) -> T {
ptr::read(ud)
}
#[cfg_attr(unwind, unwind)]
pub unsafe extern "C" fn userdata_destructor<T>(state: *mut ffi::lua_State) -> c_int {
callback_error(state, || {
take_userdata::<T>(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);