Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fully qualify #cratename::BorshSchema in derive #244

Merged
merged 2 commits into from
Oct 12, 2023

Conversation

dj8yfo
Copy link
Collaborator

@dj8yfo dj8yfo commented Oct 12, 2023

resolves #112 ,
which either was not fully resolved by #140 or reemerged later in the process

this is not a breaking change and can be safely included in 1.0.1 release

Comment on lines +41 to +49

// https://github.com/near/borsh-rs/issues/112
#[allow(unused)]
impl A {
pub fn declaration() -> usize {
42
}
}
assert_eq!("A".to_string(), <A as borsh::BorshSchema>::declaration());
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change on current master results in compilation error

 1  error[E0277]: the trait bound `String: Borrow<usize>` is not satisfied
    --> borsh/tests/test_schema_structs.rs:39:14
     |
 39  |     #[derive(borsh::BorshSchema)]
     |              ^^^^^^^^^^^^^^^^^^ the trait `Borrow<usize>` is not implemented for `String`
     |
     = help: the trait `Borrow<str>` is implemented for `String`
 note: required by a bound in `BTreeMap::<K, V, A>::get`
    --> /home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library
 /alloc/src/collections/btree/map.rs:696:12
     |
 694 |     pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&V>
     |            --- required by a bound in this associated function
 695 |     where
 696 |         K: Borrow<Q> + Ord,
     |            ^^^^^^^^^ required by this bound in `BTreeMap::<K, V, A>::get`
     = note: this error originates in the derive macro `borsh::BorshSchema` (in Nightly builds, run with
 -Z macro-backtrace for more info)

@dj8yfo dj8yfo marked this pull request as ready for review October 12, 2023 13:06
@dj8yfo dj8yfo requested a review from frol as a code owner October 12, 2023 13:06
@frol frol merged commit 4ef9d00 into master Oct 12, 2023
7 checks passed
@frol frol deleted the fully_qualify_schema_in_derives branch October 12, 2023 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BorshSchema should use fully qualified paths when calling trait methods
2 participants