Skip to content

Commit ce0ce18

Browse files
committed
chore: new compilation warnings dropped
1 parent 588e3df commit ce0ce18

File tree

12 files changed

+27
-13
lines changed

12 files changed

+27
-13
lines changed

tarantool/src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ unsafe fn error_get_file_line(ptr: *const ffi::BoxError) -> Option<(String, u32)
441441
struct Failure;
442442
static mut FIELD_OFFSETS: Option<std::result::Result<(u32, u32), Failure>> = None;
443443

444-
if FIELD_OFFSETS.is_none() {
444+
if (*std::ptr::addr_of!(FIELD_OFFSETS)).is_none() {
445445
let lua = crate::lua_state();
446446
let res = lua.eval::<(u32, u32)>(
447447
"ffi = require 'ffi'

tarantool/src/ffi/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub fn has_datetime() -> bool {
7878
#[inline]
7979
pub unsafe fn has_fiber_set_ctx() -> bool {
8080
static mut RESULT: Option<bool> = None;
81-
if RESULT.is_none() {
81+
if (*std::ptr::addr_of!(RESULT)).is_none() {
8282
RESULT = Some(helper::has_dyn_symbol(crate::c_str!("fiber_set_ctx")));
8383
}
8484
RESULT.unwrap()
@@ -114,7 +114,7 @@ pub fn has_fully_temporary_spaces() -> bool {
114114
#[inline]
115115
pub unsafe fn has_fiber_id() -> bool {
116116
static mut RESULT: Option<bool> = None;
117-
if RESULT.is_none() {
117+
if (*std::ptr::addr_of!(RESULT)).is_none() {
118118
RESULT = Some(helper::has_dyn_symbol(crate::c_str!("fiber_id")));
119119
}
120120
RESULT.unwrap()

tarantool/src/network/client/tcp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use std::pin::Pin;
2828
use std::rc::Rc;
2929
use std::task::{Context, Poll};
3030
use std::time::Duration;
31-
use std::{io, marker, vec};
31+
use std::{io, marker};
3232

3333
#[cfg(feature = "async-std")]
3434
use async_std::io::{Read as AsyncRead, Write as AsyncWrite};

tarantool/src/space.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1370,7 +1370,7 @@ pub fn space_id_temporary_min() -> Option<SpaceId> {
13701370
static mut VALUE: Option<Option<SpaceId>> = None;
13711371
// SAFETY: this is safe as we only call this from tx thread.
13721372
unsafe {
1373-
if VALUE.is_none() {
1373+
if (*std::ptr::addr_of!(VALUE)).is_none() {
13741374
VALUE = Some(
13751375
crate::lua_state()
13761376
.eval("return box.schema.SPACE_ID_TEMPORARY_MIN")

tarantool/src/uuid.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,9 @@ impl<'de> serde::Deserialize<'de> for Uuid {
257257
static mut CTID_UUID: Option<u32> = None;
258258

259259
fn ctid_uuid() -> u32 {
260+
// SAFETY: only safe to call this from tx thread
260261
unsafe {
261-
if CTID_UUID.is_none() {
262+
if (*std::ptr::addr_of!(CTID_UUID)).is_none() {
262263
let lua = crate::global_lua();
263264
let ctid_uuid =
264265
tlua::ffi::luaL_ctypeid(tlua::AsLua::as_lua(&lua), crate::c_ptr!("struct tt_uuid"));

tests/src/define_str_enum.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ pub fn basic() {
9595

9696
// other claimed traits
9797
impl<'de, L: tlua::AsLua> AssertImpl<'de, L> for Color {}
98+
#[allow(unused)]
9899
trait AssertImpl<'de, L: tlua::AsLua>:
99100
AsRef<str>
100101
+ Into<String>

tests/src/fiber/channel.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ pub fn into_clones() {
303303
struct NonClonable();
304304

305305
#[derive(Clone)]
306+
#[allow(unused)]
306307
struct MyChannel(fiber::Channel<NonClonable>);
307308

308309
let (_, _) = MyChannel(fiber::Channel::new(1)).into_clones();

tests/src/proc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ pub fn inject() {
256256
fn global() -> &'static GlobalData {
257257
static mut GLOBAL: Option<GlobalData> = None;
258258
unsafe {
259-
GLOBAL.get_or_insert_with(|| GlobalData {
259+
(*std::ptr::addr_of_mut!(GLOBAL)).get_or_insert_with(|| GlobalData {
260260
data: vec!["some".into(), "global".into(), "data".into()],
261261
})
262262
}

tests/src/tlua/functions_write.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,10 @@ pub fn closures_must_be_static() {
246246
}
247247
let f: LuaFunction<_> = lua.get("a").unwrap();
248248
let () = f.call().unwrap();
249-
assert_eq!(unsafe { &GLOBAL }, &Some(vec![1, 2, 3]));
249+
assert_eq!(
250+
unsafe { &*std::ptr::addr_of!(GLOBAL) },
251+
&Some(vec![1, 2, 3])
252+
);
250253
}
251254

252255
pub fn pcall() {
@@ -263,20 +266,20 @@ pub fn pcall() {
263266
pub fn error() {
264267
let lua = tarantool::lua_state();
265268
lua.set("error_callback",
266-
tlua::function1(|lua: tlua::LuaState| tlua::error!(lua, "but it compiled :("))
269+
tlua::function1(|lua: tlua::LuaState| -> () { tlua::error!(lua, "but it compiled :(") })
267270
);
268271
let msg = lua.exec("return error_callback()").unwrap_err().to_string();
269272
assert_eq!(msg, "but it compiled :(");
270273

271274
lua.set("error_callback_2",
272-
tlua::function2(|msg: String, lua: tlua::LuaState| tlua::error!(lua, "your message: {}", msg))
275+
tlua::function2(|msg: String, lua: tlua::LuaState| -> () { tlua::error!(lua, "your message: {}", msg) })
273276
);
274277
let msg = lua.exec("return error_callback_2('my message')").unwrap_err().to_string();
275278
assert_eq!(msg, "your message: my message");
276279

277280
lua.set("error_callback_3",
278281
tlua::Function::new(
279-
|qualifier: String, lua: tlua::StaticLua| {
282+
|qualifier: String, lua: tlua::StaticLua| -> () {
280283
tlua::error!(lua, "this way is {qualifier}")
281284
}
282285
)

tests/src/tlua/lua_tables.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ pub fn get_or_create_metatable() {
9494
{
9595
let table = lua.get::<LuaTable<_>, _>("a").unwrap();
9696

97+
#[allow(deprecated)]
9798
let metatable = table.get_or_create_metatable();
9899
fn handler() -> i32 {
99100
5
@@ -180,6 +181,7 @@ pub fn registry_metatable() {
180181
let lua = Lua::new();
181182

182183
let registry = LuaTable::registry(&lua);
184+
#[allow(deprecated)]
183185
let metatable = registry.get_or_create_metatable();
184186
metatable.set(3, "hello");
185187
}

0 commit comments

Comments
 (0)