mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-28 15:34:22 +00:00
79518eafce
Consider this code: ``` struct NoContentHash {} #[derive(ContentHash)] enum Hashable { NoCanHash(NoContentHash), Empty, } ``` Before this commit, it generates an error like this: ``` error[E0277]: the trait bound `NoContentHash: ContentHash` is not satisfied --> lib/src/content_hash.rs:150:10 | 150 | #[derive(ContentHash)] | ^^^^^^^^^^^ the trait `ContentHash` is not implemented for `NoContentHash` 151 | enum Hashable { 152 | NoCanHash(NoContentHash), | --------- required by a bound introduced by this call | = help: the following other types implement trait `ContentHash`: bool i32 i64 u8 u32 u64 std::collections::HashMap<K, V> BTreeMap<K, V> and 35 others For more information about this error, try `rustc --explain E0277`. ``` After this commit, it generates a better error message: ``` error[E0277]: the trait bound `NoContentHash: ContentHash` is not satisfied --> lib/src/content_hash.rs:152:15 | 152 | NoCanHash(NoContentHash), | ^^^^^^^^^^^^^ the trait `ContentHash` is not implemented for `NoContentHash` | = help: the following other types implement trait `ContentHash`: bool i32 i64 u8 u32 u64 std::collections::HashMap<K, V> BTreeMap<K, V> and 35 others For more information about this error, try `rustc --explain E0277`. error: could not compile `jj-lib` (lib) due to 1 previous error ``` It also works for enum variants with named fields: ``` error[E0277]: the trait bound `NoContentHash: ContentHash` is not satisfied --> lib/src/content_hash.rs:152:23 | 152 | NoCanHash { named: NoContentHash }, | ^^^^^^^^^^^^^ the trait `ContentHash` is not implemented for `NoContentHash` | = help: the following other types implement trait `ContentHash`: bool i32 i64 u8 u32 u64 std::collections::HashMap<K, V> BTreeMap<K, V> and 35 others For more information about this error, try `rustc --explain E0277`. ``` |
||
---|---|---|
.. | ||
content_hash.rs | ||
lib.rs |