Fix feature flags for owned types
This commit is contained in:
parent
aaf0a5e44a
commit
0fccdfed5c
|
@ -18,7 +18,7 @@ use crate::types::{LightUserData, MaybeSend};
|
||||||
use crate::userdata::{AnyUserData, UserData, UserDataRef, UserDataRefMut};
|
use crate::userdata::{AnyUserData, UserData, UserDataRef, UserDataRefMut};
|
||||||
use crate::value::{FromLua, IntoLua, Nil, Value};
|
use crate::value::{FromLua, IntoLua, Nil, Value};
|
||||||
|
|
||||||
#[cfg(feature = "unstable")]
|
#[cfg(all(feature = "unstable", any(not(feature = "send"), doc)))]
|
||||||
use crate::{function::OwnedFunction, table::OwnedTable, userdata::OwnedAnyUserData};
|
use crate::{function::OwnedFunction, table::OwnedTable, userdata::OwnedAnyUserData};
|
||||||
|
|
||||||
#[cfg(feature = "async")]
|
#[cfg(feature = "async")]
|
||||||
|
@ -79,7 +79,8 @@ impl<'lua> FromLua<'lua> for Table<'lua> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "unstable")]
|
#[cfg(all(feature = "unstable", any(not(feature = "send"), doc)))]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(all(feature = "unstable", not(feature = "send")))))]
|
||||||
impl<'lua> IntoLua<'lua> for OwnedTable {
|
impl<'lua> IntoLua<'lua> for OwnedTable {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
|
fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
|
||||||
|
@ -87,7 +88,8 @@ impl<'lua> IntoLua<'lua> for OwnedTable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "unstable")]
|
#[cfg(all(feature = "unstable", any(not(feature = "send"), doc)))]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(all(feature = "unstable", not(feature = "send")))))]
|
||||||
impl<'lua> FromLua<'lua> for OwnedTable {
|
impl<'lua> FromLua<'lua> for OwnedTable {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from_lua(value: Value<'lua>, lua: &'lua Lua) -> Result<OwnedTable> {
|
fn from_lua(value: Value<'lua>, lua: &'lua Lua) -> Result<OwnedTable> {
|
||||||
|
@ -116,7 +118,8 @@ impl<'lua> FromLua<'lua> for Function<'lua> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "unstable")]
|
#[cfg(all(feature = "unstable", any(not(feature = "send"), doc)))]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(all(feature = "unstable", not(feature = "send")))))]
|
||||||
impl<'lua> IntoLua<'lua> for OwnedFunction {
|
impl<'lua> IntoLua<'lua> for OwnedFunction {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
|
fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
|
||||||
|
@ -124,7 +127,8 @@ impl<'lua> IntoLua<'lua> for OwnedFunction {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "unstable")]
|
#[cfg(all(feature = "unstable", any(not(feature = "send"), doc)))]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(all(feature = "unstable", not(feature = "send")))))]
|
||||||
impl<'lua> FromLua<'lua> for OwnedFunction {
|
impl<'lua> FromLua<'lua> for OwnedFunction {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from_lua(value: Value<'lua>, lua: &'lua Lua) -> Result<OwnedFunction> {
|
fn from_lua(value: Value<'lua>, lua: &'lua Lua) -> Result<OwnedFunction> {
|
||||||
|
@ -189,7 +193,8 @@ impl<'lua> FromLua<'lua> for AnyUserData<'lua> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "unstable")]
|
#[cfg(all(feature = "unstable", any(not(feature = "send"), doc)))]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(all(feature = "unstable", not(feature = "send")))))]
|
||||||
impl<'lua> IntoLua<'lua> for OwnedAnyUserData {
|
impl<'lua> IntoLua<'lua> for OwnedAnyUserData {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
|
fn into_lua(self, lua: &'lua Lua) -> Result<Value<'lua>> {
|
||||||
|
@ -197,7 +202,8 @@ impl<'lua> IntoLua<'lua> for OwnedAnyUserData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "unstable")]
|
#[cfg(all(feature = "unstable", any(not(feature = "send"), doc)))]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(all(feature = "unstable", not(feature = "send")))))]
|
||||||
impl<'lua> FromLua<'lua> for OwnedAnyUserData {
|
impl<'lua> FromLua<'lua> for OwnedAnyUserData {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from_lua(value: Value<'lua>, lua: &'lua Lua) -> Result<OwnedAnyUserData> {
|
fn from_lua(value: Value<'lua>, lua: &'lua Lua) -> Result<OwnedAnyUserData> {
|
||||||
|
|
|
@ -33,6 +33,7 @@ pub struct OwnedFunction(pub(crate) crate::types::LuaOwnedRef);
|
||||||
#[cfg(feature = "unstable")]
|
#[cfg(feature = "unstable")]
|
||||||
impl OwnedFunction {
|
impl OwnedFunction {
|
||||||
/// Get borrowed handle to the underlying Lua function.
|
/// Get borrowed handle to the underlying Lua function.
|
||||||
|
#[cfg_attr(feature = "send", allow(unused))]
|
||||||
pub const fn to_ref(&self) -> Function {
|
pub const fn to_ref(&self) -> Function {
|
||||||
Function(self.0.to_ref())
|
Function(self.0.to_ref())
|
||||||
}
|
}
|
||||||
|
@ -400,8 +401,8 @@ impl<'lua> Function<'lua> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert this handle to owned version.
|
/// Convert this handle to owned version.
|
||||||
#[cfg(feature = "unstable")]
|
#[cfg(all(feature = "unstable", any(not(feature = "send"), doc)))]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
|
#[cfg_attr(docsrs, doc(cfg(all(feature = "unstable", not(feature = "send")))))]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn into_owned(self) -> OwnedFunction {
|
pub fn into_owned(self) -> OwnedFunction {
|
||||||
OwnedFunction(self.0.into_owned())
|
OwnedFunction(self.0.into_owned())
|
||||||
|
@ -476,6 +477,6 @@ mod assertions {
|
||||||
|
|
||||||
static_assertions::assert_not_impl_any!(Function: Send);
|
static_assertions::assert_not_impl_any!(Function: Send);
|
||||||
|
|
||||||
#[cfg(feature = "unstable")]
|
#[cfg(all(feature = "unstable", not(feature = "send")))]
|
||||||
static_assertions::assert_not_impl_any!(OwnedFunction: Send);
|
static_assertions::assert_not_impl_any!(OwnedFunction: Send);
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,7 +151,7 @@ pub mod serde;
|
||||||
extern crate mlua_derive;
|
extern crate mlua_derive;
|
||||||
|
|
||||||
// Unstable features
|
// Unstable features
|
||||||
#[cfg(all(feature = "unstable", not(feature = "send")))]
|
#[cfg(feature = "unstable")]
|
||||||
pub use crate::{function::OwnedFunction, table::OwnedTable, userdata::OwnedAnyUserData};
|
pub use crate::{function::OwnedFunction, table::OwnedTable, userdata::OwnedAnyUserData};
|
||||||
|
|
||||||
/// Create a type that implements [`AsChunk`] and can capture Rust variables.
|
/// Create a type that implements [`AsChunk`] and can capture Rust variables.
|
||||||
|
|
|
@ -2472,7 +2472,7 @@ impl Lua {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "unstable")]
|
#[cfg(all(feature = "unstable", not(feature = "send")))]
|
||||||
pub(crate) fn adopt_owned_ref(&self, loref: crate::types::LuaOwnedRef) -> LuaRef {
|
pub(crate) fn adopt_owned_ref(&self, loref: crate::types::LuaOwnedRef) -> LuaRef {
|
||||||
assert!(
|
assert!(
|
||||||
Arc::ptr_eq(&loref.lua.0, &self.0),
|
Arc::ptr_eq(&loref.lua.0, &self.0),
|
||||||
|
|
|
@ -33,6 +33,7 @@ pub struct OwnedTable(pub(crate) crate::types::LuaOwnedRef);
|
||||||
#[cfg(feature = "unstable")]
|
#[cfg(feature = "unstable")]
|
||||||
impl OwnedTable {
|
impl OwnedTable {
|
||||||
/// Get borrowed handle to the underlying Lua table.
|
/// Get borrowed handle to the underlying Lua table.
|
||||||
|
#[cfg_attr(feature = "send", allow(unused))]
|
||||||
pub const fn to_ref(&self) -> Table {
|
pub const fn to_ref(&self) -> Table {
|
||||||
Table(self.0.to_ref())
|
Table(self.0.to_ref())
|
||||||
}
|
}
|
||||||
|
@ -584,8 +585,8 @@ impl<'lua> Table<'lua> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert this handle to owned version.
|
/// Convert this handle to owned version.
|
||||||
#[cfg(feature = "unstable")]
|
#[cfg(all(feature = "unstable", any(not(feature = "send"), doc)))]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
|
#[cfg_attr(docsrs, doc(cfg(all(feature = "unstable", not(feature = "send")))))]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn into_owned(self) -> OwnedTable {
|
pub fn into_owned(self) -> OwnedTable {
|
||||||
OwnedTable(self.0.into_owned())
|
OwnedTable(self.0.into_owned())
|
||||||
|
|
|
@ -746,6 +746,8 @@ pub struct OwnedAnyUserData(pub(crate) crate::types::LuaOwnedRef);
|
||||||
|
|
||||||
#[cfg(feature = "unstable")]
|
#[cfg(feature = "unstable")]
|
||||||
impl OwnedAnyUserData {
|
impl OwnedAnyUserData {
|
||||||
|
/// Get borrowed handle to the underlying Lua userdata.
|
||||||
|
#[cfg_attr(feature = "send", allow(unused))]
|
||||||
pub const fn to_ref(&self) -> AnyUserData {
|
pub const fn to_ref(&self) -> AnyUserData {
|
||||||
AnyUserData(self.0.to_ref())
|
AnyUserData(self.0.to_ref())
|
||||||
}
|
}
|
||||||
|
@ -1029,8 +1031,8 @@ impl<'lua> AnyUserData<'lua> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "unstable")]
|
#[cfg(all(feature = "unstable", any(not(feature = "send"), doc)))]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
|
#[cfg_attr(docsrs, doc(cfg(all(feature = "unstable", not(feature = "send")))))]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn into_owned(self) -> OwnedAnyUserData {
|
pub fn into_owned(self) -> OwnedAnyUserData {
|
||||||
OwnedAnyUserData(self.0.into_owned())
|
OwnedAnyUserData(self.0.into_owned())
|
||||||
|
@ -1285,6 +1287,6 @@ mod assertions {
|
||||||
|
|
||||||
static_assertions::assert_not_impl_any!(AnyUserData: Send);
|
static_assertions::assert_not_impl_any!(AnyUserData: Send);
|
||||||
|
|
||||||
#[cfg(feature = "unstable")]
|
#[cfg(all(feature = "unstable", not(feature = "send")))]
|
||||||
static_assertions::assert_not_impl_any!(OwnedAnyUserData: Send);
|
static_assertions::assert_not_impl_any!(OwnedAnyUserData: Send);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue