hashes: Use $crate in macro

Depending on types being in scope when calling macros is bad practice
but we have mistakenly done so in `internal_macros` when using the
`FromSliceError`.

Use `$crate::FromSliceError` in the macro and remove import statements.
This commit is contained in:
Tobin C. Harding 2024-07-12 12:53:56 +10:00
parent 6c8f759676
commit 360d1fb1bb
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
9 changed files with 11 additions and 11 deletions

View File

@ -10,7 +10,7 @@
use core::ops::Index;
use core::slice::SliceIndex;
use crate::{ripemd160, sha256, FromSliceError};
use crate::{ripemd160, sha256};
crate::internal_macros::hash_type! {
160,

View File

@ -113,7 +113,7 @@ macro_rules! hash_trait_impls {
const LEN: usize = $bits / 8;
const DISPLAY_BACKWARD: bool = $reverse;
fn from_slice(sl: &[u8]) -> $crate::_export::_core::result::Result<Hash<$($gen),*>, FromSliceError> {
fn from_slice(sl: &[u8]) -> $crate::_export::_core::result::Result<Hash<$($gen),*>, $crate::FromSliceError> {
Self::from_slice(sl)
}
@ -174,9 +174,9 @@ macro_rules! hash_type {
/// Copies a byte slice into a hash object.
pub fn from_slice(
sl: &[u8],
) -> $crate::_export::_core::result::Result<Hash, FromSliceError> {
) -> $crate::_export::_core::result::Result<Hash, $crate::FromSliceError> {
if sl.len() != $bits / 8 {
Err(FromSliceError { expected: $bits / 8, got: sl.len() })
Err($crate::FromSliceError { expected: $bits / 8, got: sl.len() })
} else {
let mut ret = [0; $bits / 8];
ret.copy_from_slice(sl);

View File

@ -6,7 +6,7 @@ use core::cmp;
use core::ops::Index;
use core::slice::SliceIndex;
use crate::{FromSliceError, HashEngine as _};
use crate::HashEngine as _;
crate::internal_macros::hash_type! {
160,

View File

@ -6,7 +6,7 @@ use core::cmp;
use core::ops::Index;
use core::slice::SliceIndex;
use crate::{FromSliceError, HashEngine as _};
use crate::HashEngine as _;
crate::internal_macros::hash_type! {
160,

View File

@ -5,7 +5,7 @@
use core::ops::Index;
use core::slice::SliceIndex;
use crate::{sha256, FromSliceError};
use crate::sha256;
crate::internal_macros::hash_type! {
256,

View File

@ -5,7 +5,7 @@
use core::ops::Index;
use core::slice::SliceIndex;
use crate::{sha512, FromSliceError};
use crate::sha512;
crate::internal_macros::hash_type! {
384,

View File

@ -6,7 +6,7 @@ use core::cmp;
use core::ops::Index;
use core::slice::SliceIndex;
use crate::{FromSliceError, HashEngine as _};
use crate::HashEngine as _;
crate::internal_macros::hash_type! {
512,

View File

@ -10,7 +10,7 @@
use core::ops::Index;
use core::slice::SliceIndex;
use crate::{sha512, FromSliceError};
use crate::sha512;
crate::internal_macros::hash_type! {
256,

View File

@ -6,7 +6,7 @@ use core::ops::Index;
use core::slice::SliceIndex;
use core::{cmp, mem, ptr};
use crate::{FromSliceError, HashEngine as _};
use crate::HashEngine as _;
crate::internal_macros::hash_type! {
64,