Remove `unused_imports` in docs

Examples in documentation are not linted in the same way as other code,
but should still contain correctly written code.

unused_imports in docs have been removed in bitcoin, and a warn
attribute added to lib.rs.
This commit is contained in:
Jamil Lambert, PhD 2024-09-16 09:58:15 +01:00
parent d9d12dafdd
commit e58cda6f92
No known key found for this signature in database
GPG Key ID: 54DC29234AB5D2C0
6 changed files with 5 additions and 10 deletions

View File

@ -307,7 +307,6 @@ pub enum AddressData {
/// 1. `Display` is implemented only for `Address<NetworkChecked>`: /// 1. `Display` is implemented only for `Address<NetworkChecked>`:
/// ///
/// ``` /// ```
/// # use std::str::FromStr;
/// # use bitcoin::address::{Address, NetworkChecked}; /// # use bitcoin::address::{Address, NetworkChecked};
/// let address: Address<NetworkChecked> = "132F25rTsvBdp9JzLLBHP5mvGY66i1xdiM".parse::<Address<_>>() /// let address: Address<NetworkChecked> = "132F25rTsvBdp9JzLLBHP5mvGY66i1xdiM".parse::<Address<_>>()
/// .unwrap().assume_checked(); /// .unwrap().assume_checked();
@ -315,7 +314,6 @@ pub enum AddressData {
/// ``` /// ```
/// ///
/// ```ignore /// ```ignore
/// # use std::str::FromStr;
/// # use bitcoin::address::{Address, NetworkChecked}; /// # use bitcoin::address::{Address, NetworkChecked};
/// let address: Address<NetworkUnchecked> = "132F25rTsvBdp9JzLLBHP5mvGY66i1xdiM".parse::<Address<_>>() /// let address: Address<NetworkUnchecked> = "132F25rTsvBdp9JzLLBHP5mvGY66i1xdiM".parse::<Address<_>>()
/// .unwrap(); /// .unwrap();
@ -327,7 +325,6 @@ pub enum AddressData {
/// check the network and use `Display` in user-facing context. /// check the network and use `Display` in user-facing context.
/// ///
/// ``` /// ```
/// # use std::str::FromStr;
/// # use bitcoin::address::{Address, NetworkUnchecked}; /// # use bitcoin::address::{Address, NetworkUnchecked};
/// let address: Address<NetworkUnchecked> = "132F25rTsvBdp9JzLLBHP5mvGY66i1xdiM".parse::<Address<_>>() /// let address: Address<NetworkUnchecked> = "132F25rTsvBdp9JzLLBHP5mvGY66i1xdiM".parse::<Address<_>>()
/// .unwrap(); /// .unwrap();
@ -335,7 +332,6 @@ pub enum AddressData {
/// ``` /// ```
/// ///
/// ``` /// ```
/// # use std::str::FromStr;
/// # use bitcoin::address::{Address, NetworkChecked}; /// # use bitcoin::address::{Address, NetworkChecked};
/// let address: Address<NetworkChecked> = "132F25rTsvBdp9JzLLBHP5mvGY66i1xdiM".parse::<Address<_>>() /// let address: Address<NetworkChecked> = "132F25rTsvBdp9JzLLBHP5mvGY66i1xdiM".parse::<Address<_>>()
/// .unwrap().assume_checked(); /// .unwrap().assume_checked();

View File

@ -444,7 +444,6 @@ impl DerivationPath {
/// ///
/// ``` /// ```
/// use bitcoin::bip32::DerivationPath; /// use bitcoin::bip32::DerivationPath;
/// use std::str::FromStr;
/// ///
/// let path = "m/84'/0'/0'/0/1".parse::<DerivationPath>().unwrap(); /// let path = "m/84'/0'/0'/0/1".parse::<DerivationPath>().unwrap();
/// const HARDENED: u32 = 0x80000000; /// const HARDENED: u32 = 0x80000000;

View File

@ -114,7 +114,7 @@ impl OutPoint {
/// ///
/// ```rust /// ```rust
/// use bitcoin::constants::genesis_block; /// use bitcoin::constants::genesis_block;
/// use bitcoin::{params, Network}; /// use bitcoin::params;
/// ///
/// let block = genesis_block(&params::MAINNET); /// let block = genesis_block(&params::MAINNET);
/// let tx = &block.txdata[0]; /// let tx = &block.txdata[0];

View File

@ -1370,8 +1370,8 @@ impl<E> EncodeSigningDataResult<E> {
/// ///
/// ```rust /// ```rust
/// # use bitcoin::consensus::deserialize; /// # use bitcoin::consensus::deserialize;
/// # use bitcoin::hashes::{sha256d, Hash, hex::FromHex}; /// # use bitcoin::hashes::{sha256d, hex::FromHex};
/// # use bitcoin::sighash::{LegacySighash, SighashCache}; /// # use bitcoin::sighash::SighashCache;
/// # use bitcoin::Transaction; /// # use bitcoin::Transaction;
/// # let mut writer = sha256d::Hash::engine(); /// # let mut writer = sha256d::Hash::engine();
/// # let input_index = 0; /// # let input_index = 0;

View File

@ -30,6 +30,7 @@
#![cfg_attr(bench, feature(test))] #![cfg_attr(bench, feature(test))]
// Coding conventions. // Coding conventions.
#![warn(missing_docs)] #![warn(missing_docs)]
#![doc(test(attr(warn(unused))))]
// Instead of littering the codebase for non-fuzzing and bench code just globally allow. // Instead of littering the codebase for non-fuzzing and bench code just globally allow.
#![cfg_attr(fuzzing, allow(dead_code, unused_imports))] #![cfg_attr(fuzzing, allow(dead_code, unused_imports))]
#![cfg_attr(bench, allow(dead_code, unused_imports))] #![cfg_attr(bench, allow(dead_code, unused_imports))]

View File

@ -197,8 +197,7 @@ impl PartialMerkleTree {
/// ///
/// ```rust /// ```rust
/// use bitcoin::hash_types::Txid; /// use bitcoin::hash_types::Txid;
/// use bitcoin::hex::FromHex; /// use bitcoin::merkle_tree::PartialMerkleTree;
/// use bitcoin::merkle_tree::{MerkleBlock, PartialMerkleTree};
/// ///
/// // Block 80000 /// // Block 80000
/// let txids: Vec<Txid> = [ /// let txids: Vec<Txid> = [