[vlc-commits] [Git][videolan/vlc][master] 6 commits: vlcrs-macros: tests: fix dangerous_implicit_autorefs lint

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Wed Mar 25 13:56:38 UTC 2026



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
6ae10417 by Alexandre Janniaux at 2026-03-25T14:17:15+01:00
vlcrs-macros: tests: fix dangerous_implicit_autorefs lint

Add explicit reference around raw pointer dereference used for
indexing since implicit autoref from a raw pointer dereference,
is now denied by newer Rust nightly.

Error from rustc:

      error: implicit autoref creates a reference to the dereference of a raw pointer
      --> src/rust/vlcrs-macros/tests/common/mod.rs:43:20
         |
      43 |         assert_eq!((*context).commands[(*context).command_cursor], opcode);
         |                    ^^-------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         |                      |
         |                      this raw pointer has type `*mut TestContext<T>`
         |
         = note: creating a reference requires the pointer target to be valid and imposes aliasing requirements
      note: autoref is being applied to this expression, resulting in: `&Vec<ModuleProperties>`
      --> src/rust/vlcrs-macros/tests/common/mod.rs:43:20
         |
      43 |         assert_eq!((*context).commands[(*context).command_cursor], opcode);
         |                    ^^^^^^^^^^^^^^^^^^^
         = note: `#[deny(dangerous_implicit_autorefs)]` on by default
      help: try using a raw pointer method instead; or if this reference is intentional, make it explicit
         |
      43 |         assert_eq!((&(*context).commands)[(*context).command_cursor], opcode);
         |                    ++                   +

- - - - -
ecd4ec68 by Alexandre Janniaux at 2026-03-25T14:17:15+01:00
vlcrs-macros: tests: fix unpredictable_function_pointer_comparisons warning

Replace assert_ne!/assert_eq! comparisons of Option<fn_ptr> with None by
assert!(xx.is_some()) / assert!(xx.is_none()), since comparing function
pointers with == / != is now warned against by Rust nightly.

Fix multiple rustc warning looking like this:

    warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique
      --> src/rust/vlcrs-macros/tests/module.rs:89:5
       |
    89 |     assert_ne!(context.open_cb, None);
       |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       |
       = note: the address of the same function can vary between different codegen units
       = note: furthermore, different functions could have the same address after being merged together
       = note: for more information visit <https://doc.rust-lang.org/nightly/core/ptr/fn.fn_addr_eq.html>
       = note: `#[warn(unpredictable_function_pointer_comparisons)]` on by default
       = note: this warning originates in the macro `assert_ne` (in Nightly builds, run with -Z macro-backtrace for more info)

- - - - -
9705a9ee by Alexandre Janniaux at 2026-03-25T14:17:15+01:00
vlcrs-macros: fix unpredictable_function_pointer_comparisons in module! macro

Replace `!= None` with `.is_some()` in the generated deactivate
function check so that code expanded from the module! macro no
longer triggers the unpredictable_function_pointer_comparisons
warning on newer Rust nightly.

Fixes multiple rustc warning looking like this:

      warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique
      --> src/rust/vlcrs-macros/tests/module.rs:56:1
         |
      56 | / module! {
      57 | |     type: TestModule (ModuleLoader),
      58 | |     capability: "video_filter" @ 0,
      59 | |     category: VIDEO_VFILTER,
      ...  |
      62 | |     shortcuts: ["mynewmodule_filter"],
      63 | | }
         | |_^
         |
         = note: the address of the same function can vary between different codegen units
         = note: furthermore, different functions could have the same address after being merged together
         = note: for more information visit <https://doc.rust-lang.org/nightly/core/ptr/fn.fn_addr_eq.html>
         = note: `#[warn(unpredictable_function_pointer_comparisons)]` on by default
         = note: this warning originates in the macro `module` (in Nightly builds, run with -Z macro-backtrace for more info)

- - - - -
d0ffc760 by Alexandre Janniaux at 2026-03-25T14:17:15+01:00
vlcrs-core: convert: fix internal doctest

Doctests somehow actually requires what it references to be public now,
and pub(crate) elements are not accessible anymore, so the doctest is
failing to compile with the following error:

      error[E0599]: no method named `assume_valid` found for reference `&CStr` in the current scope
      --> src/rust/vlcrs-core/src/convert.rs:40:64
         |
      40 |     let trace: &str = unsafe { std::ffi::CStr::from_ptr(trace).assume_valid() };
         |                                                                ^^^^^^^^^^^^ method not found in `&CStr`

- - - - -
47162af4 by Alexandre Janniaux at 2026-03-25T14:17:15+01:00
vlcrs-core: tracer: fix doctest

Doctests now requires the types from the current module to be imported
explicitely, which results in compilation errors currently:

    error[E0405]: cannot find trait `TracerCapability` in this scope
      --> src/rust/vlcrs-core/src/tracer/mod.rs:229:6
        |
    229 | impl TracerCapability for T {
        |      ^^^^^^^^^^^^^^^^ not found in this scope
        |
    help: consider importing this trait
        |
    228 + use vlcrs_core::tracer::TracerCapability;
        |

    error[E0425]: cannot find type `T` in this scope
      --> src/rust/vlcrs-core/src/tracer/mod.rs:229:27
        |
    229 | impl TracerCapability for T {
        |                           ^ not found in this scope

    error[E0425]: cannot find type `Trace` in this scope
      --> src/rust/vlcrs-core/src/tracer/mod.rs:230:29
        |
    230 |     fn trace(&self, trace: &Trace) {
        |                             ^^^^^ not found in this scope
        |
    help: consider importing this struct
        |
    228 + use vlcrs_core::tracer::Trace;
        |

- - - - -
1b68a8be by Alexandre Janniaux at 2026-03-25T14:17:15+01:00
vlcrs-core: tracer: fix rustdoc warnings

Note that it removes the non-working reference to vlcrs_macros since the
macros crate is not re-exported from vlcrs-core and cannot be
referenced by it.

    warning: unresolved link to `vlcrs_macros::module`
      --> src/rust/vlcrs-core/src/tracer/mod.rs:35:8
      |
    35 | /// a [vlcrs_macros::module!] manifest using the
      |        ^^^^^^^^^^^^^^^^^^^^^ no item named `vlcrs_macros` in scope
      |
      = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default

    warning: unresolved link to `vlcrs_macros::module`
      --> src/rust/vlcrs-core/src/tracer/mod.rs:138:8
        |
    138 | /// ([`vlcrs_macros::module!`]) of the manifest as a "tracer"
        |        ^^^^^^^^^^^^^^^^^^^^^ no item named `vlcrs_macros` in scope

    warning: unresolved link to `tick`
      --> src/rust/vlcrs-core/src/tracer/mod.rs:203:41
        |
    203 |     /// Register the new point at time [tick] with the metadata [entries].
        |                                         ^^^^ no item named `tick` in scope
        |
        = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

    warning: unresolved link to `entries`
      --> src/rust/vlcrs-core/src/tracer/mod.rs:203:66
        |
    203 |     /// Register the new point at time [tick] with the metadata [entries].
        |                                                                  ^^^^^^^ no item named `entries` in scope
        |
        = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

- - - - -


8 changed files:

- src/rust/vlcrs-core/src/convert.rs
- src/rust/vlcrs-core/src/tracer/mod.rs
- src/rust/vlcrs-macros/src/module.rs
- src/rust/vlcrs-macros/tests/common/mod.rs
- src/rust/vlcrs-macros/tests/module.rs
- src/rust/vlcrs-macros/tests/module_default.rs
- src/rust/vlcrs-macros/tests/module_multiple.rs
- src/rust/vlcrs-macros/tests/module_specific.rs


Changes:

=====================================
src/rust/vlcrs-core/src/convert.rs
=====================================
@@ -34,7 +34,7 @@
 /// VLC manipulate already checked UTF8 strings. This lift the bindings from the obligation to
 /// perform UTF8 validity verifications:
 ///
-/// ```
+/// ```ignore
 /// extern "C" fn tracer_trace(trace: *const std::ffi::c_char) {
 ///     // `trace` is from VLC and is assumed to be valid UTF8.
 ///     let trace: &str = unsafe { std::ffi::CStr::from_ptr(trace).assume_valid() };


=====================================
src/rust/vlcrs-core/src/tracer/mod.rs
=====================================
@@ -32,7 +32,7 @@ pub struct Tick(pub i64);
 /// Trait representing the module capability for implementing tracers.
 ///
 /// A type implementing the [TracerCapability] trait can be exposed to
-/// a [vlcrs_macros::module!] manifest using the
+/// a `vlcrs_macros::module!` manifest using the
 /// [TracerModuleLoader] type loader, which will expose it as a "tracer"
 /// capability for VLC core.
 ///
@@ -135,7 +135,7 @@ extern "C" fn activate_tracer<T: TracerCapability>(
 ///
 /// This is an implementation of the [ModuleProtocol] type for the
 /// [TracerCapability] trait, exposing modules from the declaration
-/// ([`vlcrs_macros::module!`]) of the manifest as a "tracer"
+/// (`vlcrs_macros::module!`) of the manifest as a "tracer"
 /// capability for VLC core.
 ///
 /// ```
@@ -200,7 +200,7 @@ impl Tracer {
     }
 
     ///
-    /// Register the new point at time [tick] with the metadata [entries].
+    /// Register the new point at time `tick` with the metadata `entries:.
     ///
     pub fn trace(&self, tick: Tick, trace: Trace) {
         unsafe {
@@ -226,8 +226,12 @@ macro_rules! trace {
 /// # Examples
 ///
 /// ```
-/// impl TracerCapability for T {
-///     fn trace(&self, trace: &Trace) {
+/// # use vlcrs_core::tracer::*;
+/// # use vlcrs_core::object::Object;
+/// # struct MyTracer {}
+/// impl TracerCapability for MyTracer {
+///     # fn open(_: &mut Object) -> Option<impl TracerCapability> { Some(MyTracer{}) }
+///     fn trace(&self, _: Tick, trace: &Trace) {
 ///         for entry in trace.entries() {
 ///             println!("{}", entry.key);
 ///         }


=====================================
src/rust/vlcrs-macros/src/module.rs
=====================================
@@ -948,7 +948,7 @@ fn generate_module_code(module_info: &ModuleInfo) -> TokenStream2 {
             return -1;
         }
 
-        if <#loader as ModuleProtocol<#type_>>::deactivate_function() != None {
+        if <#loader as ModuleProtocol<#type_>>::deactivate_function().is_some() {
             if unsafe {
                 vlc_set(
                     opaque,


=====================================
src/rust/vlcrs-macros/tests/common/mod.rs
=====================================
@@ -40,7 +40,7 @@ pub fn load_manifest<Activate, Deactivate>(
         let opcode = opcode.unwrap();
         assert!((*context).command_cursor < (*context).commands.len());
 
-        assert_eq!((*context).commands[(*context).command_cursor], opcode);
+        assert_eq!((&(*context).commands)[(*context).command_cursor], opcode);
         (*context).command_cursor += 1;
 
         if opcode == ModuleProperties::MODULE_CB_OPEN {


=====================================
src/rust/vlcrs-macros/tests/module.rs
=====================================
@@ -86,8 +86,8 @@ fn test_module_load_common_activate() {
     };
     let ret = common::load_manifest(&mut context, vlc_entry);
     assert_eq!(ret, 0);
-    assert_ne!(context.open_cb, None);
-    assert_ne!(context.close_cb, None);
+    assert!(context.open_cb.is_some());
+    assert!(context.close_cb.is_some());
 
     unsafe {
         context.open_cb.unwrap()(std::ptr::null_mut());


=====================================
src/rust/vlcrs-macros/tests/module_default.rs
=====================================
@@ -92,6 +92,6 @@ fn test_module_load_default_deactivate() {
     };
     let ret = common::load_manifest(&mut context, vlc_entry);
     assert_eq!(ret, 0);
-    assert_ne!(context.open_cb, None);
-    assert_eq!(context.close_cb, None);
+    assert!(context.open_cb.is_some());
+    assert!(context.close_cb.is_none());
 }


=====================================
src/rust/vlcrs-macros/tests/module_multiple.rs
=====================================
@@ -154,7 +154,7 @@ fn test_module_manifest_multiple_capabilities() {
     };
     let ret = common::load_manifest(&mut context, vlc_entry);
     assert_eq!(ret, 0);
-    assert_ne!(context.open_cb, None);
+    assert!(context.open_cb.is_some());
 
     let mut valid = false;
     unsafe {


=====================================
src/rust/vlcrs-macros/tests/module_specific.rs
=====================================
@@ -128,8 +128,8 @@ fn test_module_load_specific_open() {
     };
     let ret = common::load_manifest(&mut context, vlc_entry);
     assert_eq!(ret, 0);
-    assert_ne!(context.open_cb, None);
-    assert_ne!(context.close_cb, None);
+    assert!(context.open_cb.is_some());
+    assert!(context.close_cb.is_some());
 
     let mut valid = false;
     unsafe {



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6e53bd3ec5fb52f05a9c37d2aa6470a3506ee596...1b68a8be79051e41c964627a1e71140d49fa392a

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6e53bd3ec5fb52f05a9c37d2aa6470a3506ee596...1b68a8be79051e41c964627a1e71140d49fa392a
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list