Skip to content

Feature unification conflict because of encoding feature #861

@maxence-cornaton

Description

@maxence-cornaton

I'm building an app which is split into multiple crates. To simplify the setup, let's assume the following:

  • Crate A depends on quick-xml with the encoding feature enabled
  • Crate B depends on quick-xml with the encoding feature not enabled and uses the Attribute::unescape_value function
  • Crate C depends on crates A & B

When trying to build crate C, I get the following error message:

error[E0599]: no method named `unescape_value` found for struct `Attribute` in the current scope
  --> B\src\lib.rs:9:7
   |
6  | /     Attribute {
7  | |         key: QName(b"key"),
8  | |         value: Cow::Borrowed(b"value"),
9  | |     }.unescape_value()
   | |______-^^^^^^^^^^^^^^
   |
help: there is a method `decode_and_unescape_value` with a similar name, but with different arguments
  --> C:\Users\Maxence\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\quick-xml-0.37.5\src\events\attributes.rs:79:5
   |
79 |     pub fn decode_and_unescape_value(&self, decoder: Decoder) -> XmlResult<Cow<'a, str>> {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

It is clear that B expects quick-xml to not have the encoding feature enabled.

Is there a way to solve this feature unification conflict?
Here's a repo to reproduce the issue: https://github.com/maxence-cornaton/quick-xml-feature-unification


For a real world scenario, imagine having crate A depending on calamine and crate B depending on mail_auth. Crate will fail to compile because calamine enables the encoding feature while mail_auth expects it to be disabled.

error[E0599]: no method named `unescape_value` found for struct `Attribute` in the current scope
   --> C:\Users\Maxence\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\mail-auth-0.6.1\src\report\dmarc\parse.rs:312:48
    |
312 |                         if let Ok(attr) = attr.unescape_value() {
    |                                                ^^^^^^^^^^^^^^
    |
help: there is a method `decode_and_unescape_value` with a similar name, but with different arguments
   --> C:\Users\Maxence\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\quick-xml-0.37.5\src\events\attributes.rs:79:5
    |
79  |     pub fn decode_and_unescape_value(&self, decoder: Decoder) -> XmlResult<Cow<'a, str>> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationIssues about improvements or bugs in documentationencodingIssues related to support of various encodings of the XML documentsquestion

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions