]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Add clippy ignore rules for all errors and warnings
authorMirebella <166803555+Mirebella@users.noreply.github.com>
Tue, 13 Aug 2024 11:41:16 +0000 (13:41 +0200)
committerMirebella <166803555+Mirebella@users.noreply.github.com>
Wed, 28 Aug 2024 07:47:40 +0000 (09:47 +0200)
21 files changed:
.github/workflows/build.yml
lightning-rapid-gossip-sync/src/processing.rs
lightning/src/chain/onchaintx.rs
lightning/src/chain/package.rs
lightning/src/crypto/chacha20.rs
lightning/src/crypto/chacha20poly1305rfc.rs
lightning/src/crypto/poly1305.rs
lightning/src/events/mod.rs
lightning/src/ln/chan_utils.rs
lightning/src/ln/channel.rs
lightning/src/ln/channelmanager.rs
lightning/src/ln/peer_handler.rs
lightning/src/offers/invoice.rs
lightning/src/offers/offer.rs
lightning/src/offers/signer.rs
lightning/src/routing/gossip.rs
lightning/src/routing/router.rs
lightning/src/routing/scoring.rs
lightning/src/routing/utxo.rs
lightning/src/util/indexed_map.rs
lightning/src/util/logger.rs

index 9ed1b5eee290a6922e5799a3d0893fdd0e60147e..989e51e83095a7a7c95fca49f5df092c6b40fae4 100644 (file)
@@ -251,7 +251,94 @@ jobs:
           rustup component add clippy
       - name: Run default clippy linting
         run: |
-          cargo clippy -- -Aclippy::erasing_op -Aclippy::never_loop -Aclippy::if_same_then_else -Dclippy::try_err
+          RUSTFLAGS='-D warnings' cargo clippy -- \
+                `# Errors` \
+                -A clippy::erasing_op \
+                -A clippy::never_loop \
+                `# Warnings` \
+                -A renamed_and_removed_lints \
+                -A clippy::blocks_in_conditions \
+                -A clippy::borrow_deref_ref \
+                -A clippy::clone_on_copy \
+                -A clippy::collapsible_else_if \
+                -A clippy::collapsible_if \
+                -A clippy::collapsible_match \
+                -A clippy::comparison_chain \
+                -A clippy::drain_collect \
+                -A clippy::drop_non_drop \
+                -A clippy::enum_variant_names \
+                -A clippy::explicit_auto_deref \
+                -A clippy::extra_unused_lifetimes \
+                -A clippy::for_kv_map \
+                -A clippy::from_over_into \
+                -A clippy::get_first \
+                -A clippy::identity_op \
+                -A clippy::if_same_then_else \
+                -A clippy::inconsistent_digit_grouping \
+                -A clippy::iter_kv_map \
+                -A clippy::iter_skip_next \
+                -A clippy::large_enum_variant \
+                -A clippy::legacy_numeric_constants \
+                -A clippy::len_without_is_empty \
+                -A clippy::len_zero \
+                -A clippy::let_and_return \
+                -A clippy::manual_filter \
+                -A clippy::manual_map \
+                -A clippy::manual_memcpy \
+                -A clippy::manual_range_contains \
+                -A clippy::manual_range_patterns \
+                -A clippy::manual_saturating_arithmetic \
+                -A clippy::manual_strip \
+                -A clippy::map_clone \
+                -A clippy::map_flatten \
+                -A clippy::match_like_matches_macro \
+                -A clippy::match_ref_pats \
+                -A clippy::multiple_bound_locations \
+                -A clippy::mut_mutex_lock \
+                -A clippy::needless_bool \
+                -A clippy::needless_borrow \
+                -A clippy::needless_borrowed_reference \
+                -A clippy::needless_borrows_for_generic_args \
+                -A clippy::needless_lifetimes \
+                -A clippy::needless_question_mark \
+                -A clippy::needless_range_loop \
+                -A clippy::needless_return \
+                -A clippy::new_without_default \
+                -A clippy::non_minimal_cfg \
+                -A clippy::op_ref \
+                -A clippy::option_as_ref_deref \
+                -A clippy::option_map_or_none \
+                -A clippy::option_map_unit_fn \
+                -A clippy::precedence \
+                -A clippy::ptr_arg \
+                -A clippy::question_mark \
+                -A clippy::readonly_write_lock \
+                -A clippy::redundant_closure \
+                -A clippy::redundant_field_names \
+                -A clippy::redundant_guards \
+                -A clippy::redundant_pattern_matching \
+                -A clippy::redundant_slicing \
+                -A clippy::redundant_static_lifetimes \
+                -A clippy::result_large_err \
+                -A clippy::result_unit_err \
+                -A clippy::search_is_some \
+                -A clippy::single_char_pattern \
+                -A clippy::single_match \
+                -A clippy::slow_vector_initialization \
+                -A clippy::tabs_in_doc_comments \
+                -A clippy::to_string_in_format_args \
+                -A clippy::too_many_arguments \
+                -A clippy::toplevel_ref_arg \
+                -A clippy::type_complexity \
+                -A clippy::unnecessary_cast \
+                -A clippy::unnecessary_get_then_check \
+                -A clippy::unnecessary_lazy_evaluations \
+                -A clippy::unnecessary_mut_passed \
+                -A clippy::unnecessary_sort_by \
+                -A clippy::unnecessary_to_owned \
+                -A clippy::unnecessary_unwrap \
+                -A clippy::unused_unit \
+                -A clippy::useless_conversion
 
   rustfmt:
     runs-on: ubuntu-latest
index c7cda96ff93f583b38007a8a5a7b10a0fa202948..a9757e04dc25c36b8b7edfaa4746db1d20d7b8b3 100644 (file)
@@ -176,7 +176,7 @@ where
                                                .and_then(|node| node.announcement_info.as_ref())
                                                .map(|info| {
                                                        synthetic_node_announcement.features = info.features().clone();
-                                                       synthetic_node_announcement.rgb = info.rgb().clone();
+                                                       synthetic_node_announcement.rgb.clone_from(&info.rgb());
                                                        synthetic_node_announcement.alias = info.alias().clone();
                                                        synthetic_node_announcement.addresses = info.addresses().to_vec();
                                                });
index eff827983ca451232e2a3b055c2d8194a5b850f6..b07297ce214c145155aab5420344b30d129eb9c2 100644 (file)
@@ -761,7 +761,7 @@ impl<ChannelSigner: EcdsaChannelSigner> OnchainTxHandler<ChannelSigner> {
                                        for outpoint in req.outpoints() {
                                                log_info!(logger, "  Outpoint {}", outpoint);
                                        }
-                                       self.locktimed_packages.entry(package_locktime).or_insert(Vec::new()).push(req);
+                                       self.locktimed_packages.entry(package_locktime).or_default().push(req);
                                        continue;
                                }
 
index 361e12fa5634ce3ed38b3018fd122474420a0cef..ce3ac1d9d5aaf49079611e50934cd149f2d62071 100644 (file)
@@ -1033,8 +1033,7 @@ impl PackageTemplate {
 
        pub (crate) fn build_package(txid: Txid, vout: u32, input_solving_data: PackageSolvingData, soonest_conf_deadline: u32, height_original: u32) -> Self {
                let (malleability, aggregable) = PackageSolvingData::map_output_type_flags(&input_solving_data);
-               let mut inputs = Vec::with_capacity(1);
-               inputs.push((BitcoinOutPoint { txid, vout }, input_solving_data));
+               let inputs = vec![(BitcoinOutPoint { txid, vout }, input_solving_data)];
                PackageTemplate {
                        inputs,
                        malleability,
index 0c51d4562febf12168f9971f4f43d7a94cd875c2..d1dcff1474c6b4d00d96be9b6ccec22fd6a5644d 100644 (file)
@@ -176,7 +176,7 @@ mod real_chacha {
                ) {
                        let block = ChaCha20::get_single_block(key, nonce);
                        for i in 0..bytes.len() {
-                               bytes[i] = block[i] ^ bytes[i];
+                               bytes[i] ^= block[i];
                        }
                }
 
index 4ca974421c6810f8291bff65febf394c93637f67..76d6040c224a698604657c704cf4b97024b9c58b 100644 (file)
@@ -59,7 +59,7 @@ mod real_chachapoly {
 
                pub fn encrypt(&mut self, input: &[u8], output: &mut [u8], out_tag: &mut [u8]) {
                        assert!(input.len() == output.len());
-                       assert!(self.finished == false);
+                       assert!(!self.finished);
                        self.cipher.process(input, output);
                        self.data_len += input.len();
                        self.mac.input(output);
@@ -78,7 +78,7 @@ mod real_chachapoly {
                // Encrypt `input_output` in-place. To finish and calculate the tag, use `finish_and_get_tag`
                // below.
                pub(in super::super) fn encrypt_in_place(&mut self, input_output: &mut [u8]) {
-                       debug_assert!(self.finished == false);
+                       debug_assert!(!self.finished);
                        self.cipher.process_in_place(input_output);
                        self.data_len += input_output.len();
                        self.mac.input(input_output);
@@ -87,7 +87,7 @@ mod real_chachapoly {
                // If we were previously encrypting with `encrypt_in_place`, this method can be used to finish
                // encrypting and calculate the tag.
                pub(in super::super) fn finish_and_get_tag(&mut self, out_tag: &mut [u8]) {
-                       debug_assert!(self.finished == false);
+                       debug_assert!(!self.finished);
                        ChaCha20Poly1305RFC::pad_mac_16(&mut self.mac, self.data_len);
                        self.finished = true;
                        self.mac.input(&self.aad_len.to_le_bytes());
@@ -100,7 +100,7 @@ mod real_chachapoly {
                /// this decryption is *variable time*.
                pub fn variable_time_decrypt(&mut self, input: &[u8], output: &mut [u8], tag: &[u8]) -> Result<(), ()> {
                        assert!(input.len() == output.len());
-                       assert!(self.finished == false);
+                       assert!(!self.finished);
 
                        self.finished = true;
 
@@ -131,7 +131,7 @@ mod real_chachapoly {
                ///
                /// Should never be `pub` because the public API should always enforce tag checking.
                pub(in super::super) fn decrypt_in_place(&mut self, input_output: &mut [u8]) {
-                       debug_assert!(self.finished == false);
+                       debug_assert!(!self.finished);
                        self.mac.input(input_output);
                        self.data_len += input_output.len();
                        self.cipher.process_in_place(input_output);
@@ -140,7 +140,7 @@ mod real_chachapoly {
                /// If we were previously decrypting with `just_decrypt_in_place`, this method must be used
                /// to check the tag. Returns whether or not the tag is valid.
                pub(in super::super) fn finish_and_check_tag(&mut self, tag: &[u8]) -> bool {
-                       debug_assert!(self.finished == false);
+                       debug_assert!(!self.finished);
                        self.finished = true;
                        ChaCha20Poly1305RFC::pad_mac_16(&mut self.mac, self.data_len);
                        self.mac.input(&self.aad_len.to_le_bytes());
index 593200210055e32605c9ab4822a9f32fd54a9e44..7b7449125610fd87673b049d4d04a386cc1f2790 100644 (file)
@@ -82,7 +82,7 @@ impl Poly1305 {
                d2 += c as u64; c = (d2 >> 26) as u32; h2 = d2 as u32 & 0x3ffffff;
                d3 += c as u64; c = (d3 >> 26) as u32; h3 = d3 as u32 & 0x3ffffff;
                d4 += c as u64; c = (d4 >> 26) as u32; h4 = d4 as u32 & 0x3ffffff;
-               h0 += c * 5;    c = h0 >> 26; h0 = h0 & 0x3ffffff;
+               h0 += c * 5;    c = h0 >> 26; h0 &= 0x3ffffff;
                h1 += c;
 
                self.h[0] = h0;
@@ -111,11 +111,11 @@ impl Poly1305 {
                let mut h4 = self.h[4];
 
                let mut c : u32;
-                            c = h1 >> 26; h1 = h1 & 0x3ffffff;
-               h2 +=     c; c = h2 >> 26; h2 = h2 & 0x3ffffff;
-               h3 +=     c; c = h3 >> 26; h3 = h3 & 0x3ffffff;
-               h4 +=     c; c = h4 >> 26; h4 = h4 & 0x3ffffff;
-               h0 += c * 5; c = h0 >> 26; h0 = h0 & 0x3ffffff;
+                            c = h1 >> 26; h1 &= 0x3ffffff;
+               h2 +=     c; c = h2 >> 26; h2 &= 0x3ffffff;
+               h3 +=     c; c = h3 >> 26; h3 &= 0x3ffffff;
+               h4 +=     c; c = h4 >> 26; h4 &= 0x3ffffff;
+               h0 += c * 5; c = h0 >> 26; h0 &= 0x3ffffff;
                h1 +=     c;
 
                // compute h + -p
index a823512f10def0ea97fec1876d36a1625980f21e..99ea14b6826375011eaa55ea1420b865f5675f2e 100644 (file)
@@ -1271,6 +1271,7 @@ pub enum Event {
                ///
                /// This field will be `None` for objects serialized prior to LDK 0.0.117.
                channel_capacity_sats: Option<u64>,
+
                /// The original channel funding TXO; this helps checking for the existence and confirmation
                /// status of the closing tx.
                /// Note that for instances serialized in v0.0.119 or prior this will be missing (None).
@@ -2049,7 +2050,7 @@ impl MaybeReadable for Event {
                                                payment_hash,
                                                purpose: _init_tlv_based_struct_field!(purpose, upgradable_required),
                                                amount_msat,
-                                               htlcs: htlcs.unwrap_or(vec![]),
+                                               htlcs: htlcs.unwrap_or_default(),
                                                sender_intended_total_msat,
                                                onion_fields,
                                        }))
index 88b830f16820b87739ebaa068173732d1f860b0f..c40ac3b503121c0df1ef773f44abc3beffbbe389 100644 (file)
@@ -221,13 +221,12 @@ pub fn build_commitment_secret(commitment_seed: &[u8; 32], idx: u64) -> [u8; 32]
 /// Build a closing transaction
 pub fn build_closing_transaction(to_holder_value_sat: Amount, to_counterparty_value_sat: Amount, to_holder_script: ScriptBuf, to_counterparty_script: ScriptBuf, funding_outpoint: OutPoint) -> Transaction {
        let txins = {
-               let mut ins: Vec<TxIn> = Vec::new();
-               ins.push(TxIn {
+               let ins: Vec<TxIn> = vec![TxIn {
                        previous_output: funding_outpoint,
                        script_sig: ScriptBuf::new(),
                        sequence: Sequence::MAX,
                        witness: Witness::new(),
-               });
+               }];
                ins
        };
 
@@ -702,8 +701,7 @@ pub(crate) fn make_funding_redeemscript_from_slices(broadcaster_funding_key: &[u
 /// Panics if htlc.transaction_output_index.is_none() (as such HTLCs do not appear in the
 /// commitment transaction).
 pub fn build_htlc_transaction(commitment_txid: &Txid, feerate_per_kw: u32, contest_delay: u16, htlc: &HTLCOutputInCommitment, channel_type_features: &ChannelTypeFeatures, broadcaster_delayed_payment_key: &DelayedPaymentKey, revocation_key: &RevocationKey) -> Transaction {
-       let mut txins: Vec<TxIn> = Vec::new();
-       txins.push(build_htlc_input(commitment_txid, htlc, channel_type_features));
+       let txins= vec![build_htlc_input(commitment_txid, htlc, channel_type_features)];
 
        let mut txouts: Vec<TxOut> = Vec::new();
        txouts.push(build_htlc_output(
@@ -1590,14 +1588,13 @@ impl CommitmentTransaction {
                        commitment_transaction_number_obscure_factor ^ (INITIAL_COMMITMENT_NUMBER - commitment_number);
 
                let txins = {
-                       let mut ins: Vec<TxIn> = Vec::new();
-                       ins.push(TxIn {
+                       let ins: Vec<TxIn> = vec![TxIn {
                                previous_output: channel_parameters.funding_outpoint(),
                                script_sig: ScriptBuf::new(),
                                sequence: Sequence(((0x80 as u32) << 8 * 3)
                                        | ((obscured_commitment_transaction_number >> 3 * 8) as u32)),
                                witness: Witness::new(),
-                       });
+                       }];
                        ins
                };
                (obscured_commitment_transaction_number, txins)
index 576ae665ade3d89603304bda117d5ee8a0ba8880..ad6981f7c2f1e1cf30ab2c47b680e744e3aaad58 100644 (file)
@@ -610,7 +610,7 @@ impl ChannelState {
                }
        }
 
-       fn to_u32(&self) -> u32 {
+       fn to_u32(self) -> u32 {
                match self {
                        ChannelState::NegotiatingFunding(flags) => flags.0,
                        ChannelState::FundingNegotiated => state_flags::FUNDING_NEGOTIATED,
@@ -9505,7 +9505,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
                                monitor_pending_forwards,
                                monitor_pending_failures,
                                monitor_pending_finalized_fulfills: monitor_pending_finalized_fulfills.unwrap(),
-                               monitor_pending_update_adds: monitor_pending_update_adds.unwrap_or(Vec::new()),
+                               monitor_pending_update_adds: monitor_pending_update_adds.unwrap_or_default(),
 
                                signer_pending_revoke_and_ack: false,
                                signer_pending_commitment_update: false,
index b14369c432a42273e168220c2f6617b339994bee..627aa50de848d7fc0cb2d8ebf8a1ecbc922ac6cf 100644 (file)
@@ -5165,7 +5165,7 @@ where
                                                failure_code: fail_malformed_htlc.failure_code,
                                        },
                                };
-                               self.forward_htlcs.lock().unwrap().entry(incoming_scid).or_insert(vec![]).push(failure);
+                               self.forward_htlcs.lock().unwrap().entry(incoming_scid).or_default().push(failure);
                                self.pending_events.lock().unwrap().push_back((events::Event::HTLCHandlingFailed {
                                        prev_channel_id: incoming_channel_id,
                                        failed_next_destination: htlc_destination,
@@ -6770,7 +6770,7 @@ where
 
                                peer_state.actions_blocking_raa_monitor_updates
                                        .entry(prev_hop.channel_id)
-                                       .or_insert_with(Vec::new)
+                                       .or_default()
                                        .push(raa_blocker);
                        } else {
                                debug_assert!(false,
index dda1ca8b9637e6713505844a50bbad7cea59dd20..51695bba09afc01e62afac9c69c259eba591677c 100644 (file)
@@ -1431,7 +1431,7 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
                                        let peer = &mut *peer_lock;
                                        let mut msg_to_handle = None;
                                        if peer_node_id.is_none() {
-                                               peer_node_id = peer.their_node_id.clone();
+                                               peer_node_id.clone_from(&peer.their_node_id);
                                        }
 
                                        assert!(peer.pending_read_buffer.len() > 0);
index 40ee4009040165cd273d6be4db0a783f3b8053da..865939b078e0d317f7559eb9f0f3182d3cc48ed1 100644 (file)
@@ -1018,7 +1018,7 @@ impl InvoiceContents {
                self.fields().fallbacks
                        .as_ref()
                        .map(|fallbacks| filter_fallbacks(self.chain(), fallbacks))
-                       .unwrap_or_else(Vec::new)
+                       .unwrap_or_default()
        }
 
        fn features(&self) -> &Bolt12InvoiceFeatures {
index 96cd4465c96a34be3a5605dfd6403256b8d5293a..27a79166bc3bfd518b8a85cecabcd0e23361bc43 100644 (file)
@@ -1048,7 +1048,7 @@ pub enum Quantity {
 }
 
 impl Quantity {
-       fn to_tlv_record(&self) -> Option<u64> {
+       fn to_tlv_record(self) -> Option<u64> {
                match self {
                        Quantity::Bounded(n) => Some(n.get()),
                        Quantity::Unbounded => Some(0),
index 2ee54c588119566cda8dc35e88874519a4d18c7c..ebab9b0724301ed8f42cc5567caba6bc18e47c6e 100644 (file)
@@ -240,7 +240,7 @@ impl MetadataMaterial {
                self.hmac.input(DERIVED_METADATA_HMAC_INPUT);
                self.maybe_include_encrypted_payment_id();
 
-               let mut bytes = self.encrypted_payment_id.map(|id| id.to_vec()).unwrap_or(vec![]);
+               let mut bytes = self.encrypted_payment_id.map(|id| id.to_vec()).unwrap_or_default();
                bytes.extend_from_slice(self.nonce.as_slice());
                bytes.extend_from_slice(Hmac::from_engine(self.hmac).as_byte_array());
                bytes
@@ -256,7 +256,7 @@ impl MetadataMaterial {
                self.hmac.input(DERIVED_METADATA_AND_KEYS_HMAC_INPUT);
                self.maybe_include_encrypted_payment_id();
 
-               let bytes = self.encrypted_payment_id.map(|id| id.to_vec()).unwrap_or(vec![]);
+               let bytes = self.encrypted_payment_id.map(|id| id.to_vec()).unwrap_or_default();
 
                let hmac = Hmac::from_engine(self.hmac);
                let privkey = SecretKey::from_slice(hmac.as_byte_array()).unwrap();
index 1acd2ebdc26333a66e6eb2d691570e4ce661c042..f1bc73110bf9d6a24065cb339e0f88141e2d7798 100644 (file)
@@ -509,10 +509,10 @@ where U::Target: UtxoLookup, L::Target: Logger
                                let mut one_to_two_announcement: Option<msgs::ChannelUpdate> = None;
                                let mut two_to_one_announcement: Option<msgs::ChannelUpdate> = None;
                                if let Some(one_to_two) = chan.one_to_two.as_ref() {
-                                       one_to_two_announcement = one_to_two.last_update_message.clone();
+                                       one_to_two_announcement.clone_from(&one_to_two.last_update_message);
                                }
                                if let Some(two_to_one) = chan.two_to_one.as_ref() {
-                                       two_to_one_announcement = two_to_one.last_update_message.clone();
+                                       two_to_one_announcement.clone_from(&two_to_one.last_update_message);
                                }
                                return Some((chan_announcement, one_to_two_announcement, two_to_one_announcement));
                        } else {
index 65ac21ee40592045a4fbb390b5250f650f0505ff..49760aa12fef0adc7ca2204a3c9230322afc1eaf 100644 (file)
@@ -1704,7 +1704,7 @@ where L::Target: Logger {
                                                .filter(|(p, _)| p.blinded_hops().len() == 1)
                                                .any(|(_, iter_info_opt)| iter_info_opt.is_some() && iter_info_opt != info_opt)
                                {
-                                       return Err(LightningError{err: format!("1-hop blinded paths must all have matching introduction node ids"), action: ErrorAction::IgnoreError});
+                                       return Err(LightningError{err: "1-hop blinded paths must all have matching introduction node ids".to_string(), action: ErrorAction::IgnoreError});
                                }
                        }
                }
index 480cbc5b3662cdb93a5740a68db7140602f1213b..d40b1f22c4089c29180b28be99e798c9feb4e9ea 100644 (file)
@@ -1587,7 +1587,7 @@ mod bucketed_history {
        }
 
        impl LegacyHistoricalBucketRangeTracker {
-               pub(crate) fn into_current(&self) -> HistoricalBucketRangeTracker {
+               pub(crate) fn into_current(self) -> HistoricalBucketRangeTracker {
                        let mut buckets = [0; 32];
                        for (idx, legacy_bucket) in self.buckets.iter().enumerate() {
                                let mut new_val = *legacy_bucket;
index f885c47efef1c7729d9b5722d1d9675d6db6e7de..c960846638a40fbeb33835cfe1d41aec087e84ef 100644 (file)
@@ -512,9 +512,9 @@ impl PendingChecks {
                                                                if let Some(msg) = full_msg { ChannelAnnouncement::Full(msg.clone()) }
                                                                else { ChannelAnnouncement::Unsigned(msg.clone()) });
                                                        pending_checks.nodes.entry(msg.node_id_1)
-                                                               .or_insert(Vec::new()).push(Arc::downgrade(&future.state));
+                                                               .or_default().push(Arc::downgrade(&future.state));
                                                        pending_checks.nodes.entry(msg.node_id_2)
-                                                               .or_insert(Vec::new()).push(Arc::downgrade(&future.state));
+                                                               .or_default().push(Arc::downgrade(&future.state));
                                                        Err(LightningError {
                                                                err: "Channel being checked async".to_owned(),
                                                                action: ErrorAction::IgnoreAndLog(Level::Gossip),
index 97788ffe68acbd5f90d67bd501710c3b5942ce51..dd29e4ddcb91541485e5c990fd465f7c524e2e98 100644 (file)
@@ -128,11 +128,11 @@ impl<K: Clone + Hash + Ord, V> IndexedMap<K, V> {
                let start = match range.start_bound() {
                        Bound::Unbounded => 0,
                        Bound::Included(key) => self.keys.binary_search(key).unwrap_or_else(|index| index),
-                       Bound::Excluded(key) => self.keys.binary_search(key).and_then(|index| Ok(index + 1)).unwrap_or_else(|index| index),
+                       Bound::Excluded(key) => self.keys.binary_search(key).map(|index| index +1).unwrap_or_else(|index| index),
                };
                let end = match range.end_bound() {
                        Bound::Unbounded => self.keys.len(),
-                       Bound::Included(key) => self.keys.binary_search(key).and_then(|index| Ok(index + 1)).unwrap_or_else(|index| index),
+                       Bound::Included(key) => self.keys.binary_search(key).map(|index| index +1).unwrap_or_else(|index| index),
                        Bound::Excluded(key) => self.keys.binary_search(key).unwrap_or_else(|index| index),
                };
 
index 33ef9b1f7838694bcc749903a1a39ad7d3fae8f2..cba5dbb771a04178f93026ee2133561546ac1752 100644 (file)
@@ -247,7 +247,7 @@ impl<T: fmt::Display, I: core::iter::Iterator<Item = T> + Clone> fmt::Display fo
                if let Some(item) = iter.next() {
                        write!(f, "{}", item)?;
                }
-               while let Some(item) = iter.next() {
+               for item in iter {
                        write!(f, ", {}", item)?;
                }
                write!(f, "]")?;