Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive when two macros with the same name exists and one of them is exported #1042

Closed
1 task
CBenoit opened this issue Dec 13, 2024 · 1 comment · Fixed by #1043
Closed
1 task
Labels
A-lint Area: new or existing lint C-bug Category: doesn't meet expectations

Comments

@CBenoit
Copy link

CBenoit commented Dec 13, 2024

Which lint or lints are the issue

macro_no_longer_exported

Known issues that might be causing this

  • Is the flagged item defined in another crate, or a re-export of such an item? (#638)

Steps to reproduce the bug with the above code

Publish a crate with this code:

mod foo {
  // Public macro.
  #[macro_export]
  macro_rules! foo { }
}

mod bar {
  // Private macro.
  macro_rules! foo { }
}

Next time cargo semver-checks is called, it will reports that foo is no longer exported.

Actual Behaviour

Check fails.

Expected Behaviour

Check passes.

Verbose Lint Output

     Locking 3 packages to latest compatible versions
    Building ironrdp-core v0.1.1 (current)
 Documenting ironrdp-core v0.1.1 (/home/auroden/git/IronRDP/crates/ironrdp-core)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.14s
       Built [   0.187s] (current)
     Parsing ironrdp-core v0.1.1 (current)
      Parsed [   0.002s] (current)
     Parsing ironrdp-core v0.1.1 (baseline, cached)
      Parsed [   0.007s] (baseline)
    Checking ironrdp-core v0.1.1 -> v0.1.1 (no change)
    Starting 107 checks, 0 unnecessary on 20 threads
        PASS [   0.001s]       major        attribute_proc_macro_missing
        PASS [   0.003s]       major        auto_trait_impl_removed
        PASS [   0.003s]       major        constructible_struct_adds_field
        PASS [   0.002s]       major        constructible_struct_adds_private_field
        PASS [   0.001s]       major        constructible_struct_changed_type
        PASS [   0.002s]       major        declarative_macro_missing
        PASS [   0.001s]       major        derive_helper_attr_removed
        PASS [   0.000s]       major        derive_proc_macro_missing
        PASS [   0.003s]       major        derive_trait_impl_removed
        PASS [   0.001s]       major        enum_discriminants_undefined_non_exhaustive_variant
        PASS [   0.001s]       major        enum_discriminants_undefined_non_unit_variant
        PASS [   0.001s]       major        enum_marked_non_exhaustive
        PASS [   0.001s]       major        enum_missing
        PASS [   0.001s]       minor        enum_must_use_added
        PASS [   0.002s]       major        enum_no_repr_variant_discriminant_changed
        PASS [   0.000s]       major        enum_now_doc_hidden
        PASS [   0.003s]       major        enum_repr_int_changed
        PASS [   0.003s]       major        enum_repr_int_removed
        PASS [   0.001s]       major        enum_repr_transparent_removed
        PASS [   0.003s]       major        enum_repr_variant_discriminant_changed
        PASS [   0.001s]       major        enum_struct_variant_field_added
        PASS [   0.001s]       major        enum_struct_variant_field_missing
        PASS [   0.002s]       major        enum_struct_variant_field_now_doc_hidden
        PASS [   0.001s]       major        enum_tuple_variant_changed_kind
        PASS [   0.001s]       major        enum_tuple_variant_field_added
        PASS [   0.000s]       major        enum_tuple_variant_field_missing
        PASS [   0.001s]       major        enum_tuple_variant_field_now_doc_hidden
        PASS [   0.001s]       major        enum_unit_variant_changed_kind
        PASS [   0.001s]       major        enum_variant_added
        PASS [   0.001s]       major        enum_variant_marked_non_exhaustive
        PASS [   0.001s]       major        enum_variant_missing
        PASS [   0.001s]       major        exported_function_changed_abi
        PASS [   0.001s]       major        feature_missing
        PASS [   0.001s]       major        function_abi_no_longer_unwind
        PASS [   0.001s]       major        function_changed_abi
        PASS [   0.001s]       major        function_const_removed
        PASS [   0.000s]       major        function_export_name_changed
        PASS [   0.001s]       major        function_like_proc_macro_missing
        PASS [   0.001s]       major        function_missing
        PASS [   0.001s]       minor        function_must_use_added
        PASS [   0.001s]       major        function_now_doc_hidden
        PASS [   0.001s]       major        function_parameter_count_changed
        PASS [   0.001s]       major        function_unsafe_added
        PASS [   0.001s]       major        inherent_associated_const_now_doc_hidden
        PASS [   0.002s]       major        inherent_associated_pub_const_missing
        PASS [   0.002s]       major        inherent_method_const_removed
        PASS [   0.005s]       major        inherent_method_missing
        PASS [   0.003s]       minor        inherent_method_must_use_added
        PASS [   0.002s]       major        inherent_method_now_doc_hidden
        PASS [   0.006s]       major        inherent_method_unsafe_added
        FAIL [   0.002s]       major        macro_no_longer_exported
        PASS [   0.003s]       major        macro_now_doc_hidden
        PASS [   0.005s]       major        method_parameter_count_changed
        PASS [   0.001s]       major        module_missing
        PASS [   0.001s]       major        non_exhaustive_struct_changed_type
        PASS [   0.001s]       major        pub_module_level_const_missing
        PASS [   0.000s]       major        pub_module_level_const_now_doc_hidden
        PASS [   0.001s]       major        pub_static_missing
        PASS [   0.001s]       major        pub_static_mut_now_immutable
        PASS [   0.001s]       major        pub_static_now_doc_hidden
        PASS [   0.001s]       major        pub_static_now_mutable
        PASS [   0.001s]       major        repr_c_removed
        PASS [   0.001s]       major        repr_packed_added
        PASS [   0.001s]       major        repr_packed_removed
        PASS [   0.001s]       major        sized_impl_removed
        PASS [   0.002s]       major        struct_marked_non_exhaustive
        PASS [   0.001s]       major        struct_missing
        PASS [   0.001s]       minor        struct_must_use_added
        PASS [   0.001s]       major        struct_now_doc_hidden
        PASS [   0.001s]       major        struct_pub_field_missing
        PASS [   0.001s]       major        struct_pub_field_now_doc_hidden
        PASS [   0.002s]       major        struct_repr_transparent_removed
        PASS [   0.001s]       major        struct_with_no_pub_fields_changed_type
        PASS [   0.001s]       major        struct_with_pub_fields_changed_type
        PASS [   0.000s]       major        trait_added_supertrait
        PASS [   0.000s]       major        trait_associated_const_added
        PASS [   0.000s]       major        trait_associated_const_default_removed
        PASS [   0.000s]       major        trait_associated_const_now_doc_hidden
        PASS [   0.000s]       major        trait_associated_type_added
        PASS [   0.000s]       major        trait_associated_type_default_removed
        PASS [   0.001s]       major        trait_associated_type_now_doc_hidden
        PASS [   0.001s]       major        trait_method_added
        PASS [   0.001s]       major        trait_method_default_impl_removed
        PASS [   0.001s]       major        trait_method_missing
        PASS [   0.001s]       major        trait_method_now_doc_hidden
        PASS [   0.001s]       major        trait_method_unsafe_added
        PASS [   0.001s]       major        trait_method_unsafe_removed
        PASS [   0.001s]       major        trait_mismatched_generic_lifetimes
        PASS [   0.001s]       major        trait_missing
        PASS [   0.001s]       minor        trait_must_use_added
        PASS [   0.001s]       major        trait_newly_sealed
        PASS [   0.001s]       major        trait_no_longer_object_safe
        PASS [   0.001s]       major        trait_now_doc_hidden
        PASS [   0.001s]       major        trait_removed_associated_constant
        PASS [   0.001s]       major        trait_removed_associated_type
        PASS [   0.001s]       major        trait_removed_supertrait
        PASS [   0.001s]       major        trait_unsafe_added
        PASS [   0.001s]       major        trait_unsafe_removed
        PASS [   0.001s]       major        tuple_struct_to_plain_struct
        PASS [   0.001s]       minor        type_marked_deprecated
        PASS [   0.001s]       major        type_mismatched_generic_lifetimes
        PASS [   0.002s]       major        union_field_missing
        PASS [   0.001s]       major        union_missing
        PASS [   0.001s]       minor        union_must_use_added
        PASS [   0.001s]       major        union_now_doc_hidden
        PASS [   0.001s]       major        union_pub_field_now_doc_hidden
        PASS [   0.001s]       major        unit_struct_changed_kind
     Checked [   0.012s] 107 checks: 106 pass, 1 fail, 0 warn, 0 skip

--- failure macro_no_longer_exported: macro is no longer exported ---

Description:
A macro that was previously exported with #[macro_export] is no longer exported. This breaks downstream code that used the macro.
        ref: https://doc.rust-lang.org/reference/macros-by-example.html#path-based-scope
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.38.0/src/lints/macro_no_longer_exported.ron

Failed in:
  macro ensure_size in /home/auroden/git/IronRDP/crates/ironrdp-core/src/cursor.rs:39

     Summary semver requires new major version: 1 major and 0 minor checks failed
    Finished [   0.884s] ironrdp-core

Generated System Information

System information:

Software version

cargo-semver-checks 0.38.0

Operating system

Linux 6.1.119-1-MANJARO

Command-line

/home/auroden/.cargo/bin/cargo-semver-checks semver-checks --bugreport

cargo version

> cargo -V
cargo 1.83.0 (5ffbef321 2024-10-29)

Compile time information

  • Profile: release
  • Target triple: x86_64-unknown-linux-gnu
  • Family: unix
  • OS: linux
  • Architecture: x86_64
  • Pointer width: 64
  • Endian: little
  • CPU features: fxsr,sse,sse2
  • Host: x86_64-unknown-linux-gnu

Build Configuration

No response

Additional Context

The crate where this false-positive is reported can be found here: https://github.com/Devolutions/IronRDP/tree/master/crates/ironrdp-core

The false-positive is reported when checking commit 0c10367ebcd9767085ee5fc07203353e9a982d3c against ironrdp-core v0.1.1.

I ended up modifying the name of the internal macro as it was confusing anyway.

@CBenoit CBenoit added A-lint Area: new or existing lint C-bug Category: doesn't meet expectations labels Dec 13, 2024
CBenoit added a commit to Devolutions/IronRDP that referenced this issue Dec 13, 2024
This was causing a false-positive in cargo-semver-checks:

- obi1kenobi/cargo-semver-checks#1042
CBenoit added a commit to Devolutions/IronRDP that referenced this issue Dec 13, 2024
@obi1kenobi
Copy link
Owner

Ah, I'm so sorry! We should have caught this before release. Thanks for the report and the excellent repro example.

I'll try to fix this ASAP, and I'll make sure none of our other macro-related lints have the same problem.

obi1kenobi added a commit that referenced this issue Dec 13, 2024
The old implementation checked that there's a macro with a matching name that isn't exported in the linted code, but didn't check that there is no *exported* macro by that name in the code. This was the cause of issue #1042.

Fixes #1042.
obi1kenobi added a commit that referenced this issue Dec 13, 2024
The old implementation checked that there's a macro with a matching name that isn't exported in the linted code, but didn't check that there is no *exported* macro by that name in the code. This was the cause of issue #1042.

Fixes #1042.
obi1kenobi added a commit that referenced this issue Dec 14, 2024
The old implementation checked that there's a macro with a matching name that isn't exported in the linted code, but didn't check that there is no *exported* macro by that name in the code. This was the cause of issue #1042.

Fixes #1042.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: new or existing lint C-bug Category: doesn't meet expectations
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants