Skip to content

Duplication / confusion between KeyInit::new and digest::Mac::new #1027

@tarcieri

Description

@tarcieri

The Mac::new trait is defined as:

    fn new(key: &Key<Self>) -> Self
    where
        Self: KeyInit;

...but it provides no default definition, requires Self impl KeyInit, and causes ambiguity:

error[E0034]: multiple applicable items in scope
   --> aes-siv/src/siv.rs:81:22
    |
81  |         let mac = M::new(GenericArray::from_slice(&key[..M::KeySize::to_usize()]));
    |                      ^^^ multiple `new` found
    |
note: candidate #1 is defined in the trait `KeyInit`
   --> /Users/tony/.cargo/registry/src/github.com-1ecc6299db9ec823/crypto-common-0.1.3/src/lib.rs:115:5
    |
115 |     fn new(key: &Key<Self>) -> Self;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: candidate #2 is defined in the trait `Mac`
   --> /Users/tony/.cargo/registry/src/github.com-1ecc6299db9ec823/digest-0.10.3/src/mac.rs:21:5
    |
21  | /     fn new(key: &Key<Self>) -> Self
22  | |     where
23  | |         Self: KeyInit;
    | |______________________^
help: disambiguate the associated function for candidate #1

Metadata

Metadata

Assignees

No one assigned

    Labels

    digestHash function crate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions