From 7d802542d895a49125ef6caa685c33fe966fe009 Mon Sep 17 00:00:00 2001 From: molpopgen Date: Mon, 13 Dec 2021 12:50:48 -0800 Subject: [PATCH] Bump editions to 2021. * Bump tskit-derive version to 0.2.0 to match edition change. * Update to new 2021 prelude Closes #193 --- Cargo.toml | 4 ++-- src/_macros.rs | 5 +---- src/edge_table.rs | 1 - src/individual_table.rs | 1 - src/lib.rs | 4 ++-- src/metadata.rs | 1 - src/migration_table.rs | 1 - src/mutation_table.rs | 1 - src/node_table.rs | 1 - src/population_table.rs | 1 - src/provenance.rs | 1 - src/site_table.rs | 1 - src/table_collection.rs | 6 +----- tskit-derive/Cargo.toml | 4 ++-- 14 files changed, 8 insertions(+), 24 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5fb7970c7..54e0d5f3c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "tskit" version = "0.6.1" authors = ["tskit developers "] build = "build.rs" -edition = "2018" +edition = "2021" description = "rust interface to tskit" license = "MIT" homepage = "https://github.com/tskit-dev/tskit-rust" @@ -24,7 +24,7 @@ humantime = {version = "2.1.0", optional = true} serde = {version = "1.0.118", features = ["derive"], optional = true} serde_json = {version = "1.0.67", optional = true} bincode = {version = "1.3.1", optional = true} -tskit-derive = {version = "0.1.0", path = "tskit-derive", optional = true} +tskit-derive = {version = "0.2.0", path = "tskit-derive", optional = true} [dev-dependencies] clap = "~2.34.0" diff --git a/src/_macros.rs b/src/_macros.rs index aa4f06632..026426560 100644 --- a/src/_macros.rs +++ b/src/_macros.rs @@ -46,7 +46,6 @@ macro_rules! unsafe_tsk_column_access { macro_rules! unsafe_tsk_ragged_column_access { ($i: expr, $lo: expr, $hi: expr, $array: expr, $offset_array: expr, $offset_array_len: expr) => {{ - use std::convert::TryFrom; let i = crate::SizeType::try_from($i)?; if $i < $lo || i >= $hi { Err(TskitError::IndexError {}) @@ -72,7 +71,6 @@ macro_rules! unsafe_tsk_ragged_column_access { }}; ($i: expr, $lo: expr, $hi: expr, $array: expr, $offset_array: expr, $offset_array_len: expr, $output_id_type: expr) => {{ - use std::convert::TryFrom; let i = crate::SizeType::try_from($i)?; if $i < $lo || i >= $hi { Err(TskitError::IndexError {}) @@ -103,7 +101,6 @@ macro_rules! unsafe_tsk_ragged_column_access { #[allow(unused_macros)] macro_rules! unsafe_tsk_ragged_char_column_access { ($i: expr, $lo: expr, $hi: expr, $array: expr, $offset_array: expr, $offset_array_len: expr) => {{ - use std::convert::TryFrom; let i = crate::SizeType::try_from($i)?; if $i < $lo || i >= $hi { Err(TskitError::IndexError {}) @@ -305,7 +302,7 @@ macro_rules! impl_id_traits { } } - impl std::convert::TryFrom<$idtype> for crate::SizeType { + impl TryFrom<$idtype> for crate::SizeType { type Error = crate::TskitError; fn try_from(value: $idtype) -> Result { diff --git a/src/edge_table.rs b/src/edge_table.rs index bea314d04..e0e214a7e 100644 --- a/src/edge_table.rs +++ b/src/edge_table.rs @@ -25,7 +25,6 @@ impl PartialEq for EdgeTableRow { } fn make_edge_table_row(table: &EdgeTable, pos: tsk_id_t) -> Option { - use std::convert::TryFrom; // panic is okay here, as we are handling a bad // input value before we first call this to // set up the iterator diff --git a/src/individual_table.rs b/src/individual_table.rs index ba8895bac..487e5b734 100644 --- a/src/individual_table.rs +++ b/src/individual_table.rs @@ -49,7 +49,6 @@ pub struct IndividualTable<'a> { } fn make_individual_table_row(table: &IndividualTable, pos: tsk_id_t) -> Option { - use std::convert::TryFrom; // panic is okay here, as we are handling a bad // input value before we first call this to // set up the iterator diff --git a/src/lib.rs b/src/lib.rs index ab8d23635..af00b36f5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -286,7 +286,7 @@ impl From for SizeType { } } -impl std::convert::TryFrom for SizeType { +impl TryFrom for SizeType { type Error = crate::TskitError; fn try_from(value: tsk_id_t) -> Result { @@ -297,7 +297,7 @@ impl std::convert::TryFrom for SizeType { } } -impl std::convert::TryFrom for tsk_id_t { +impl TryFrom for tsk_id_t { type Error = crate::TskitError; fn try_from(value: SizeType) -> Result { diff --git a/src/metadata.rs b/src/metadata.rs index e0a435787..d33c2e328 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -313,7 +313,6 @@ mod tests { Ok(rv) } fn decode(md: &[u8]) -> Result { - use std::convert::TryInto; let (x_int_bytes, rest) = md.split_at(std::mem::size_of::()); let (y_int_bytes, _) = rest.split_at(std::mem::size_of::()); Ok(Self { diff --git a/src/migration_table.rs b/src/migration_table.rs index 4de58b7a1..66bdd2fa4 100644 --- a/src/migration_table.rs +++ b/src/migration_table.rs @@ -30,7 +30,6 @@ impl PartialEq for MigrationTableRow { } fn make_migration_table_row(table: &MigrationTable, pos: tsk_id_t) -> Option { - use std::convert::TryFrom; // panic is okay here, as we are handling a bad // input value before we first call this to // set up the iterator diff --git a/src/mutation_table.rs b/src/mutation_table.rs index 1c30ee4f8..230ee9310 100644 --- a/src/mutation_table.rs +++ b/src/mutation_table.rs @@ -28,7 +28,6 @@ impl PartialEq for MutationTableRow { } fn make_mutation_table_row(table: &MutationTable, pos: tsk_id_t) -> Option { - use std::convert::TryFrom; // panic is okay here, as we are handling a bad // input value before we first call this to // set up the iterator diff --git a/src/node_table.rs b/src/node_table.rs index 0dd46b473..f4cb03f62 100644 --- a/src/node_table.rs +++ b/src/node_table.rs @@ -26,7 +26,6 @@ impl PartialEq for NodeTableRow { } fn make_node_table_row(table: &NodeTable, pos: tsk_id_t) -> Option { - use std::convert::TryFrom; // panic is okay here, as we are handling a bad // input value before we first call this to // set up the iterator diff --git a/src/population_table.rs b/src/population_table.rs index 43908b78c..e82ad1e98 100644 --- a/src/population_table.rs +++ b/src/population_table.rs @@ -19,7 +19,6 @@ impl PartialEq for PopulationTableRow { } fn make_population_table_row(table: &PopulationTable, pos: tsk_id_t) -> Option { - use std::convert::TryFrom; // panic is okay here, as we are handling a bad // input value before we first call this to // set up the iterator diff --git a/src/provenance.rs b/src/provenance.rs index bd8327e4b..253c42afb 100644 --- a/src/provenance.rs +++ b/src/provenance.rs @@ -131,7 +131,6 @@ impl std::fmt::Display for ProvenanceTableRow { } fn make_provenance_table_row(table: &ProvenanceTable, pos: tsk_id_t) -> Option { - use std::convert::TryFrom; // panic is okay here, as we are handling a bad // input value before we first call this to // set up the iterator diff --git a/src/site_table.rs b/src/site_table.rs index 82402db06..aa1e9bf2a 100644 --- a/src/site_table.rs +++ b/src/site_table.rs @@ -23,7 +23,6 @@ impl PartialEq for SiteTableRow { } fn make_site_table_row(table: &SiteTable, pos: tsk_id_t) -> Option { - use std::convert::TryFrom; // panic is okay here, as we are handling a bad // input value before we first call this to // set up the iterator diff --git a/src/table_collection.rs b/src/table_collection.rs index 750702716..9ffdafee8 100644 --- a/src/table_collection.rs +++ b/src/table_collection.rs @@ -78,7 +78,7 @@ use ll_bindings::tsk_table_collection_free; /// Ok(rv) /// } /// fn decode(md: &[u8]) -> Result { -/// use std::convert::TryInto; +/// /// let (x_int_bytes, rest) = md.split_at(std::mem::size_of::()); /// Ok(Self { /// x: i32::from_le_bytes(x_int_bytes.try_into().unwrap()), @@ -1048,8 +1048,6 @@ mod test { #[test] fn test_add_mutation() { - use std::convert::TryFrom; - let mut tables = TableCollection::new(1000.).unwrap(); tables @@ -1141,7 +1139,6 @@ mod test { Ok(rv) } fn decode(md: &[u8]) -> Result { - use std::convert::TryInto; let (x_int_bytes, rest) = md.split_at(std::mem::size_of::()); let (y_int_bytes, _) = rest.split_at(std::mem::size_of::()); Ok(Self { @@ -1757,7 +1754,6 @@ mod test_adding_migrations { #[test] fn test_add_migration_with_metadata() { use crate::metadata::MetadataRoundtrip; - use std::convert::TryInto; let metadata = vec![GenericMetadata::default(), GenericMetadata { data: 84 }]; diff --git a/tskit-derive/Cargo.toml b/tskit-derive/Cargo.toml index 90f285e16..040bfd7b0 100644 --- a/tskit-derive/Cargo.toml +++ b/tskit-derive/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "tskit-derive" -version = "0.1.0" -edition = "2018" +version = "0.2.0" +edition = "2021" authors = ["tskit developers "] description = "procedural macros for tskit-rust" license = "MIT"