Skip to content

Commit 9e5a351

Browse files
committed
remove redundant code after MSRV bump
1 parent b2e315f commit 9e5a351

File tree

4 files changed

+21
-58
lines changed

4 files changed

+21
-58
lines changed

secp256k1-sys/src/lib.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,13 @@
1616
//! Direct bindings to the underlying C library functions. These should
1717
//! not be needed for most users.
1818
19-
#![crate_type = "lib"]
20-
#![crate_type = "rlib"]
21-
#![crate_type = "dylib"]
22-
#![crate_name = "secp256k1_sys"]
23-
24-
#![cfg_attr(all(not(test), not(fuzztarget), not(feature = "std")), no_std)]
25-
#![cfg_attr(feature = "dev", allow(unstable_features))]
26-
#![cfg_attr(feature = "dev", feature(plugin))]
27-
#![cfg_attr(feature = "dev", plugin(clippy))]
19+
// Coding conventions
20+
#![deny(non_upper_case_globals)]
21+
#![deny(non_camel_case_types)]
22+
#![deny(non_snake_case)]
23+
#![deny(unused_mut)]
2824

25+
#![cfg_attr(all(not(test), not(feature = "std")), no_std)]
2926
#[cfg(any(test, feature = "std"))]
3027
extern crate core;
3128

@@ -467,7 +464,7 @@ mod fuzz_dummy {
467464
use self::std::{ptr, mem};
468465
use self::std::boxed::Box;
469466
use types::*;
470-
use ::{Signature, Context, NonceFn, EcdhHashFn, PublicKey,
467+
use {Signature, Context, NonceFn, EcdhHashFn, PublicKey,
471468
SECP256K1_START_NONE, SECP256K1_START_VERIFY, SECP256K1_START_SIGN,
472469
SECP256K1_SER_COMPRESSED, SECP256K1_SER_UNCOMPRESSED};
473470

secp256k1-sys/src/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ macro_rules! impl_array_newtype {
130130
&dat[..]
131131
}
132132
}
133-
impl ::CPtr for $thing {
133+
impl $crate::CPtr for $thing {
134134
type Target = $ty;
135135
fn as_c_ptr(&self) -> *const Self::Target {
136136
if self.is_empty() {

src/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub use self::std_only::*;
1414
pub mod global {
1515
use std::ops::Deref;
1616
use std::sync::Once;
17-
use ::{Secp256k1, All};
17+
use {Secp256k1, All};
1818

1919
/// Proxy struct for global `SECP256K1` context
2020
pub struct GlobalContext {

src/lib.rs

Lines changed: 12 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,10 @@
3737
//! trigger any assertion failures in the upstream library.
3838
//!
3939
//! ```rust
40-
//! extern crate secp256k1;
41-
//! # #[cfg(feature="bitcoin_hashes")]
42-
//! extern crate bitcoin_hashes;
43-
//! # #[cfg(feature="rand")]
44-
//! extern crate rand;
45-
//!
46-
//! #
47-
//! # fn main() {
4840
//! # #[cfg(all(feature="rand", feature="bitcoin_hashes"))] {
49-
//! use rand::rngs::OsRng;
41+
//! use secp256k1::rand::rngs::OsRng;
5042
//! use secp256k1::{Secp256k1, Message};
51-
//! use bitcoin_hashes::sha256;
43+
//! use secp256k1::bitcoin_hashes::sha256;
5244
//!
5345
//! let secp = Secp256k1::new();
5446
//! let mut rng = OsRng::new().expect("OsRng");
@@ -57,15 +49,14 @@
5749
//!
5850
//! let sig = secp.sign(&message, &secret_key);
5951
//! assert!(secp.verify(&message, &sig, &public_key).is_ok());
60-
//! # } }
52+
//! # }
6153
//! ```
6254
//!
6355
//! The above code requires `rust-secp256k1` to be compiled with the `rand` and `bitcoin_hashes`
6456
//! feature enabled, to get access to [`generate_keypair`](struct.Secp256k1.html#method.generate_keypair)
6557
//! Alternately, keys and messages can be parsed from slices, like
6658
//!
6759
//! ```rust
68-
//! # fn main() {
6960
//! use self::secp256k1::{Secp256k1, Message, SecretKey, PublicKey};
7061
//!
7162
//! let secp = Secp256k1::new();
@@ -77,13 +68,11 @@
7768
//!
7869
//! let sig = secp.sign(&message, &secret_key);
7970
//! assert!(secp.verify(&message, &sig, &public_key).is_ok());
80-
//! # }
8171
//! ```
8272
//!
8373
//! Users who only want to verify signatures can use a cheaper context, like so:
8474
//!
8575
//! ```rust
86-
//! # fn main() {
8776
//! use secp256k1::{Secp256k1, Message, Signature, PublicKey};
8877
//!
8978
//! let secp = Secp256k1::verification_only();
@@ -115,44 +104,28 @@
115104
//! ]).expect("compact signatures are 64 bytes; DER signatures are 68-72 bytes");
116105
//!
117106
//! assert!(secp.verify(&message, &sig, &public_key).is_ok());
118-
//! # }
119107
//! ```
120108
//!
121109
//! Observe that the same code using, say [`signing_only`](struct.Secp256k1.html#method.signing_only)
122110
//! to generate a context would simply not compile.
123111
//!
124112
125-
#![crate_type = "lib"]
126-
#![crate_type = "rlib"]
127-
#![crate_type = "dylib"]
128-
#![crate_name = "secp256k1"]
129-
130113
// Coding conventions
131114
#![deny(non_upper_case_globals)]
132115
#![deny(non_camel_case_types)]
133116
#![deny(non_snake_case)]
134117
#![deny(unused_mut)]
135118
#![warn(missing_docs)]
136119

137-
// In general, rust is absolutely horrid at supporting users doing things like,
138-
// for example, compiling Rust code for real environments. Disable useless lints
139-
// that don't do anything but annoy us and cant actually ever be resolved.
140-
#![allow(bare_trait_objects)]
141-
#![allow(ellipsis_inclusive_range_patterns)]
142120

143-
#![cfg_attr(feature = "dev", allow(unstable_features))]
144-
#![cfg_attr(feature = "dev", feature(plugin))]
145-
#![cfg_attr(feature = "dev", plugin(clippy))]
146-
147-
148-
#![cfg_attr(all(not(test), not(fuzztarget), not(feature = "std")), no_std)]
121+
#![cfg_attr(all(not(test), not(feature = "std")), no_std)]
149122
#![cfg_attr(all(test, feature = "unstable"), feature(test))]
150123

151124
#[macro_use]
152125
pub extern crate secp256k1_sys;
153126
pub use secp256k1_sys as ffi;
154127

155-
#[cfg(feature = "bitcoin_hashes")] extern crate bitcoin_hashes;
128+
#[cfg(feature = "bitcoin_hashes")] pub extern crate bitcoin_hashes;
156129
#[cfg(all(test, feature = "unstable"))] extern crate test;
157130
#[cfg(any(test, feature = "rand"))] pub extern crate rand;
158131
#[cfg(any(test))] extern crate rand_core;
@@ -575,9 +548,7 @@ impl fmt::Display for Error {
575548
}
576549

577550
#[cfg(feature = "std")]
578-
impl std::error::Error for Error {
579-
fn description(&self) -> &str { self.as_str() }
580-
}
551+
impl std::error::Error for Error {}
581552

582553

583554
/// The secp256k1 engine, used to execute all signature operations
@@ -676,7 +647,7 @@ impl<C: Context> Secp256k1<C> {
676647
// However, if this DOES fail, the result is potentially weaker side-channel
677648
// resistance, which is deadly and undetectable, so we take out the entire
678649
// thread to be on the safe side.
679-
assert!(err == 1);
650+
assert_eq!(err, 1);
680651
}
681652
}
682653

@@ -723,13 +694,8 @@ impl<C: Verification> Secp256k1<C> {
723694
/// verify-capable context.
724695
///
725696
/// ```rust
726-
/// # extern crate secp256k1;
727-
/// # #[cfg(feature="rand")]
728-
/// # extern crate rand;
729-
/// #
730-
/// # fn main() {
731697
/// # #[cfg(feature="rand")] {
732-
/// # use rand::OsRng;
698+
/// # use secp256k1::rand::rngs::OsRng;
733699
/// # use secp256k1::{Secp256k1, Message, Error};
734700
/// #
735701
/// # let secp = Secp256k1::new();
@@ -742,7 +708,7 @@ impl<C: Verification> Secp256k1<C> {
742708
///
743709
/// let message = Message::from_slice(&[0xcd; 32]).expect("32 bytes");
744710
/// assert_eq!(secp.verify(&message, &sig, &public_key), Err(Error::IncorrectSignature));
745-
/// # } }
711+
/// # }
746712
/// ```
747713
#[inline]
748714
pub fn verify(&self, msg: &Message, sig: &Signature, pk: &key::PublicKey) -> Result<(), Error> {
@@ -769,9 +735,9 @@ fn from_hex(hex: &str, target: &mut [u8]) -> Result<usize, ()> {
769735
for c in hex.bytes() {
770736
b <<= 4;
771737
match c {
772-
b'A'...b'F' => b |= c - b'A' + 10,
773-
b'a'...b'f' => b |= c - b'a' + 10,
774-
b'0'...b'9' => b |= c - b'0',
738+
b'A'..=b'F' => b |= c - b'A' + 10,
739+
b'a'..=b'f' => b |= c - b'a' + 10,
740+
b'0'..=b'9' => b |= c - b'0',
775741
_ => return Err(()),
776742
}
777743
if (idx & 1) == 1 {

0 commit comments

Comments
 (0)