Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Make the structure name inclusion in module optional #23

Open
gagbo opened this issue Jun 20, 2023 · 1 comment
Open

Make the structure name inclusion in module optional #23

gagbo opened this issue Jun 20, 2023 · 1 comment
Labels
good first issue Good for newcomers
Milestone

Comments

@gagbo
Copy link
Member

gagbo commented Jun 20, 2023

I've always thought that the class/struct would just be part of the module, as in the end the name of a class acts as an additional scope for the name of the function.

I didn't even think of asking what other points of view were, I thought Rust was always doing that, so I actually had that implemented in the helper that lists all the the functions that have autometrics annotations:

#[test]
fn detect_trait_impl_block() {
    let source = r#"
        struct Foo{};

        #[autometrics]
        impl A for Foo {
            fn m_a() {}
        }
        "#;

    let list = list_function_names(String::new(), source, true).unwrap();

    assert_eq!(list.len(), 1);
    assert_eq!(
        list[0],
        ExpectedAmLabel {
            module: "Foo".into(),
            function: "m_a".into()
        }
    );
}

Originally posted by @gagbo in autometrics-dev/autometrics-shared#33 (comment)

@gagbo
Copy link
Member Author

gagbo commented Jun 20, 2023

Turns out module_path! is used in autometrics-rs, so the information is not available.

It could be useful later though (at least to have a better list in diff-metrics related output), so instead of removing the code, we should make the struct inclusion a flag

@gagbo gagbo added this to the Version 1.0.0 milestone Jun 26, 2023
@gagbo gagbo added the good first issue Good for newcomers label Jun 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant