Skip to content

Consider emitting a diagnostic message when multiple incompatible log level features are used #481

@CattleProdigy

Description

@CattleProdigy

So today I learned the hard way that crate features are additive. If a program directly or indirectly through other dependencies, depends on a crate of the same version multiples times with different features, it will use the union of features. It does not introduce multiple copies of the crate like what happens with a version mismatch. This is pretty logical behavior I suppose, but it's a bit annoying when you have features that are mutually incompatible (like static max output level in logs).

In my specific case, I had some far flung dependency setting release_max_level_info, when I was trying to do trace level logging.

The real problem here was a dependency library setting log level features. I'll sort that out with that library, but when I was trying to figure out what was going on, I hadn't considered that multiple features were active simultaneously until I did a bunch of digging (verbose builds, grepping through .cargo etc.). I could see legitimate use cases for multiple log levels perhaps, so I wouldn't make this an error. A compiler warning or message saying something to the effect of "hey you've got both release_max_level_info and release_max_level_trace, we're going to go with info" (but obviously more generic than that) could be very helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions