8000 False positive for circularity · Issue #307 · regexident/cargo-modules · GitHub
[go: up one dir, main page]

Skip to content

False positive for circularity #307

@pdh11

Description

@pdh11

In this example:

pub mod foo {
    pub struct Foo {}
}

pub mod bar {
    use crate::foo::Foo;
    pub struct Fnord;

    pub trait Bar {
        fn send(&self, n: Fnord);
    }

    impl Bar for Foo {
        fn send(&self, _: Fnord) {}
    }
}

it seems pretty clear that the reasonable assessment is that module "bar" depends on module "foo", but not vice versa. Yet cargo modules dependencies --no-traits --no-types --no-fns --layout circo shows a cyclic "uses"-dependency:
deps

Without the --no-traits --no-types --no-fns it's clear what happened: the trait in mod bar has a function which uses type bar::Fnord -- and that function is depicted as "owned by" foo just because it's implemented on a struct which is owned by foo:
deps2

This is unhelpful, IMO: the example (distilled from a much larger one, of course) has in fact been written with all due principles of levelisability and non-circularity in mind, but cargo-modules (v0.16.6) produces a "false positive" for circularity.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0