Skip to content

Commit

Permalink
Fix linter warnings in recent Rust versions (#181)
Browse files Browse the repository at this point in the history
## Description

This PR fixes warnings generated by the following lints that were
upgraded in recent Rust versions:

-
[`static_mut_refs`](https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html)
-
[`clippy::needless_lifetimes`](https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes)
  • Loading branch information
sgoll authored Dec 4, 2024
1 parent 63fb28d commit 7ed239c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/data_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,13 @@ macro_rules! data_type {
// PANIC: Value must fit into `usize` to allow indexing.
let index = usize::try_from(open62541_sys::$index).unwrap();
// SAFETY: We use this static variable only read-only.
// This was unsafe only before Rust 1.82.
// <https://blog.rust-lang.org/2024/10/17/Rust-1.82.0.html#safely-addressing-unsafe-statics>
#[allow(unused_unsafe)]
let ua_types = unsafe { std::ptr::addr_of!(open62541_sys::UA_TYPES) };
// SAFETY: Pointer is non-zero, aligned, correct type.
// PANIC: The given index is valid within `UA_TYPES`.
unsafe { open62541_sys::UA_TYPES.get(index) }.unwrap()
unsafe { (*ua_types).get(index) }.unwrap()
}

#[must_use]
Expand Down
2 changes: 1 addition & 1 deletion src/server/access_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl<'a> DefaultAccessControl<'a> {
}

// SAFETY: `UA_AccessControl_default()` replaces previously set config.
unsafe impl<'a> AccessControl for DefaultAccessControl<'a> {
unsafe impl AccessControl for DefaultAccessControl<'_> {
type Sentinel = ();

unsafe fn apply(self, config: &mut UA_ServerConfig) -> Result<Self::Sentinel> {
Expand Down
2 changes: 1 addition & 1 deletion src/ua/data_types/node_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ mod serde {

struct NodeIdVisitor;

impl<'de> serde::de::Visitor<'de> for NodeIdVisitor {
impl serde::de::Visitor<'_> for NodeIdVisitor {
type Value = NodeId;

fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand Down

0 comments on commit 7ed239c

Please sign in to comment.