diff --git a/lib/build.rs b/lib/build.rs deleted file mode 100644 index c7a3e25e0..000000000 --- a/lib/build.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2020 The Jujutsu Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -fn main() -> std::io::Result<()> { - println!("cargo:rerun-if-changed=build.rs"); - - if let Some(true) = version_check::supports_feature("map_first_last") { - println!("cargo:rustc-cfg=feature=\"map_first_last\""); - } - - Ok(()) -} diff --git a/lib/src/default_index_store.rs b/lib/src/default_index_store.rs index 57960e824..c434ca20d 100644 --- a/lib/src/default_index_store.rs +++ b/lib/src/default_index_store.rs @@ -40,11 +40,6 @@ use crate::file_util::persist_content_addressed_temp_file; use crate::index::{ HexPrefix, Index, IndexStore, IndexWriteError, MutableIndex, PrefixResolution, ReadonlyIndex, }; -#[cfg(not(feature = "map_first_last"))] -// This import is used on Rust 1.61, but not on recent version. -// TODO: Remove it when our MSRV becomes recent enough. -#[allow(unused_imports)] -use crate::nightly_shims::BTreeSetExt; use crate::op_store::OperationId; use crate::operation::Operation; use crate::revset::{ResolvedExpression, Revset, RevsetEvaluationError}; diff --git a/lib/src/default_revset_graph_iterator.rs b/lib/src/default_revset_graph_iterator.rs index 5fad16d76..fe483a53d 100644 --- a/lib/src/default_revset_graph_iterator.rs +++ b/lib/src/default_revset_graph_iterator.rs @@ -19,7 +19,6 @@ use std::collections::{BTreeMap, HashSet}; use crate::backend::CommitId; use crate::default_index_store::{IndexEntry, IndexPosition}; -use crate::nightly_shims::BTreeMapExt; use crate::revset::{RevsetGraphEdge, RevsetGraphEdgeType}; /// Given an iterator over some set of revisions, yields the same revisions with @@ -122,7 +121,7 @@ impl<'revset, 'index> RevsetGraphIterator<'revset, 'index> { } fn next_index_entry(&mut self) -> Option> { - if let Some(index_entry) = self.look_ahead.pop_last_value() { + if let Some(index_entry) = self.look_ahead.last_entry().map(|x| x.remove()) { return Some(index_entry); } self.input_set_iter.next() diff --git a/lib/src/diff.rs b/lib/src/diff.rs index 852582983..d67dd535a 100644 --- a/lib/src/diff.rs +++ b/lib/src/diff.rs @@ -22,8 +22,6 @@ use std::slice; use itertools::Itertools; -use crate::nightly_shims::BTreeMapExt; - pub fn find_line_ranges(text: &[u8]) -> Vec> { let mut ranges = vec![]; let mut start = 0; @@ -185,7 +183,7 @@ pub(crate) fn unchanged_ranges( let max_occurrences = 100; let mut left_histogram = Histogram::calculate(left, left_ranges, max_occurrences); - if *left_histogram.count_to_words.first_key().unwrap() > max_occurrences { + if *left_histogram.count_to_words.keys().next().unwrap() > max_occurrences { // If there are very many occurrences of all words, then we just give up. return vec![]; } @@ -195,7 +193,11 @@ pub(crate) fn unchanged_ranges( // the LCS. let mut uncommon_shared_words = vec![]; while !left_histogram.count_to_words.is_empty() && uncommon_shared_words.is_empty() { - let left_words = left_histogram.count_to_words.pop_first_value().unwrap(); + let left_words = left_histogram + .count_to_words + .first_entry() + .map(|x| x.remove()) + .unwrap(); for left_word in left_words { if right_histogram.word_to_positions.contains_key(left_word) { uncommon_shared_words.push(left_word); diff --git a/lib/src/lib.rs b/lib/src/lib.rs index 482437142..a69a03f06 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -43,7 +43,6 @@ pub mod local_backend; pub mod lock; pub mod matchers; pub mod merge; -pub mod nightly_shims; pub mod op_heads_store; pub mod op_store; pub mod operation; diff --git a/lib/src/nightly_shims.rs b/lib/src/nightly_shims.rs deleted file mode 100644 index 0b2d62a9f..000000000 --- a/lib/src/nightly_shims.rs +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright 2023 The Jujutsu Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#![allow(missing_docs)] - -#[cfg(feature = "map_first_last")] -pub trait BTreeMapExt { - fn first_key(&self) -> Option<&K>; - fn last_key(&self) -> Option<&K>; - fn pop_first_value(&mut self) -> Option; - fn pop_last_value(&mut self) -> Option; -} - -#[cfg(feature = "map_first_last")] -impl BTreeMapExt for std::collections::BTreeMap { - fn first_key(&self) -> Option<&K> { - self.keys().next() - } - - fn last_key(&self) -> Option<&K> { - self.keys().next_back() - } - fn pop_first_value(&mut self) -> Option { - self.first_entry().map(|x| x.remove()) - } - - fn pop_last_value(&mut self) -> Option { - self.last_entry().map(|x| x.remove()) - } -} - -#[cfg(not(feature = "map_first_last"))] -pub trait BTreeMapExt { - fn first_key(&self) -> Option<&K>; - fn last_key(&self) -> Option<&K>; - fn pop_first_key(&mut self) -> Option; - fn pop_last_key(&mut self) -> Option; - fn pop_first_value(&mut self) -> Option; - fn pop_last_value(&mut self) -> Option; -} - -#[cfg(not(feature = "map_first_last"))] -impl BTreeMapExt for std::collections::BTreeMap { - fn first_key(&self) -> Option<&K> { - self.keys().next() - } - - fn last_key(&self) -> Option<&K> { - self.keys().next_back() - } - - fn pop_first_key(&mut self) -> Option { - let key = self.first_key()?; - let key = key.clone(); // ownership hack - Some(self.remove_entry(&key).unwrap().0) - } - - fn pop_last_key(&mut self) -> Option { - let key = self.last_key()?; - let key = key.clone(); // ownership hack - Some(self.remove_entry(&key).unwrap().0) - } - - fn pop_first_value(&mut self) -> Option { - let key = self.first_key()?; - let key = key.clone(); // ownership hack - Some(self.remove_entry(&key).unwrap().1) - } - - fn pop_last_value(&mut self) -> Option { - let key = self.last_key()?; - let key = key.clone(); // ownership hack - Some(self.remove_entry(&key).unwrap().1) - } -} - -#[cfg(feature = "map_first_last")] -pub trait BTreeSetExt {} - -#[cfg(not(feature = "map_first_last"))] -pub trait BTreeSetExt { - fn last(&self) -> Option<&K>; - fn pop_last(&mut self) -> Option; -} - -#[cfg(not(feature = "map_first_last"))] -impl BTreeSetExt for std::collections::BTreeSet { - fn last(&self) -> Option<&K> { - self.iter().next_back() - } - - fn pop_last(&mut self) -> Option { - #[allow(unstable_name_collisions)] - let key = self.last()?; - let key = key.clone(); // ownership hack - self.take(&key) - } -}