diff --git a/bytecode/src/lib.rs b/bytecode/src/lib.rs index c72cd57f7..4c7723b11 100644 --- a/bytecode/src/lib.rs +++ b/bytecode/src/lib.rs @@ -1251,7 +1251,6 @@ pub struct FrozenModule { pub mod frozen_lib { use super::*; use bincode::{options, Options}; - use std::convert::TryInto; use std::io; /// Decode a library to a iterable of frozen modules diff --git a/common/src/hash.rs b/common/src/hash.rs index 119622a9a..20dabf127 100644 --- a/common/src/hash.rs +++ b/common/src/hash.rs @@ -2,7 +2,6 @@ use num_bigint::BigInt; use num_complex::Complex64; use num_traits::ToPrimitive; use siphasher::sip::SipHasher24; -use std::convert::TryInto; use std::hash::{BuildHasher, Hash, Hasher}; use std::num::Wrapping; diff --git a/jit/src/lib.rs b/jit/src/lib.rs index 01a860b33..a338c6fa6 100644 --- a/jit/src/lib.rs +++ b/jit/src/lib.rs @@ -10,7 +10,6 @@ use rustpython_bytecode as bytecode; mod instructions; use instructions::FunctionCompiler; -use std::convert::TryFrom; #[derive(Debug, thiserror::Error)] pub enum JitCompileError { diff --git a/jit/tests/common.rs b/jit/tests/common.rs index b1213224b..074386308 100644 --- a/jit/tests/common.rs +++ b/jit/tests/common.rs @@ -176,8 +176,6 @@ macro_rules! jit_function { }; ($func_name:ident($($arg_name:ident:$arg_type:ty),*) -> $ret_type:ty => $($t:tt)*) => { { - use std::convert::TryInto; - let jit_code = jit_function!($func_name => $($t)*); move |$($arg_name:$arg_type),*| -> Result<$ret_type, rustpython_jit::JitArgumentError> { diff --git a/parser/src/python.lalrpop b/parser/src/python.lalrpop index f6167fb48..0d2ca3316 100644 --- a/parser/src/python.lalrpop +++ b/parser/src/python.lalrpop @@ -3,8 +3,6 @@ // See also: file:///usr/share/doc/python/html/reference/compound_stmts.html#function-definitions // See also: https://greentreesnakes.readthedocs.io/en/latest/nodes.html#keyword -use std::iter::FromIterator; - use crate::ast; use crate::fstring::parse_located_fstring; use crate::function::{ArgumentList, parse_args, parse_params}; diff --git a/src/lib.rs b/src/lib.rs index fb0199ccd..5bb6d7b1e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -50,7 +50,6 @@ use rustpython_vm::{ TypeProtocol, VirtualMachine, }; -use std::convert::TryInto; use std::env; use std::path::Path; use std::process; diff --git a/stdlib/src/array.rs b/stdlib/src/array.rs index ef019b142..4cae57d86 100644 --- a/stdlib/src/array.rs +++ b/stdlib/src/array.rs @@ -35,7 +35,6 @@ mod array { use itertools::Itertools; use lexical_core::Integer; use std::cmp::Ordering; - use std::convert::{TryFrom, TryInto}; use std::{fmt, os::raw}; macro_rules! def_array_enum { diff --git a/stdlib/src/bisect.rs b/stdlib/src/bisect.rs index 7c391921f..61dac0eae 100644 --- a/stdlib/src/bisect.rs +++ b/stdlib/src/bisect.rs @@ -6,7 +6,6 @@ mod _bisect { function::OptionalArg, types::PyComparisonOp::Lt, ItemProtocol, PyObjectRef, PyResult, VirtualMachine, }; - use std::convert::TryFrom; #[derive(FromArgs)] struct BisectArgs { diff --git a/stdlib/src/socket.rs b/stdlib/src/socket.rs index 5348a2fb8..59222d223 100644 --- a/stdlib/src/socket.rs +++ b/stdlib/src/socket.rs @@ -24,7 +24,6 @@ mod _socket { use crossbeam_utils::atomic::AtomicCell; use num_traits::ToPrimitive; use socket2::{Domain, Protocol, Socket, Type as SocketType}; - use std::convert::TryFrom; use std::mem::MaybeUninit; use std::net::{self, Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr, ToSocketAddrs}; use std::time::{Duration, Instant}; diff --git a/stdlib/src/ssl.rs b/stdlib/src/ssl.rs index 5b2b841d6..618765bf9 100644 --- a/stdlib/src/ssl.rs +++ b/stdlib/src/ssl.rs @@ -53,7 +53,6 @@ mod _ssl { }; use openssl_sys as sys; use std::{ - convert::TryFrom, ffi::CStr, fmt, io::{Read, Write}, diff --git a/stdlib/src/termios.rs b/stdlib/src/termios.rs index 66f639c88..14bd56388 100644 --- a/stdlib/src/termios.rs +++ b/stdlib/src/termios.rs @@ -7,7 +7,6 @@ mod termios { function::IntoPyObject, PyObjectRef, PyResult, TryFromObject, VirtualMachine, }; - use std::convert::TryFrom; use termios::Termios; // TODO: more ioctl numbers diff --git a/vm/src/builtins/int.rs b/vm/src/builtins/int.rs index 738011eb8..ee248e5ff 100644 --- a/vm/src/builtins/int.rs +++ b/vm/src/builtins/int.rs @@ -13,7 +13,6 @@ use bstr::ByteSlice; use num_bigint::{BigInt, BigUint, Sign}; use num_integer::Integer; use num_traits::{One, Pow, PrimInt, Signed, ToPrimitive, Zero}; -use std::convert::TryFrom; use std::fmt; use std::mem::size_of; diff --git a/vm/src/builtins/list.rs b/vm/src/builtins/list.rs index 18d2a35e1..142346b2b 100644 --- a/vm/src/builtins/list.rs +++ b/vm/src/builtins/list.rs @@ -18,7 +18,6 @@ use crate::{ PyRef, PyResult, PyValue, TryFromObject, TypeProtocol, }; use std::fmt; -use std::iter::FromIterator; use std::mem::size_of; use std::ops::{DerefMut, Range}; diff --git a/vm/src/function.rs b/vm/src/function.rs index 0a9ba166c..b9e52792c 100644 --- a/vm/src/function.rs +++ b/vm/src/function.rs @@ -357,7 +357,7 @@ impl KwArgs { self.0.remove(name) } } -impl std::iter::FromIterator<(String, T)> for KwArgs { +impl FromIterator<(String, T)> for KwArgs { fn from_iter>(iter: I) -> Self { KwArgs(iter.into_iter().collect()) } diff --git a/vm/src/stdlib/io.rs b/vm/src/stdlib/io.rs index 0a14441b3..313eba06f 100644 --- a/vm/src/stdlib/io.rs +++ b/vm/src/stdlib/io.rs @@ -1343,7 +1343,6 @@ mod _io { } pub fn get_offset(obj: PyObjectRef, vm: &VirtualMachine) -> PyResult { - use std::convert::TryInto; let int = vm.to_index(&obj)?; int.as_bigint().try_into().map_err(|_| { vm.new_value_error(format!( @@ -2120,7 +2119,6 @@ mod _io { const BYTES_TO_SKIP_OFF: usize = Self::NEED_EOF_OFF + 1; const BYTE_LEN: usize = Self::BYTES_TO_SKIP_OFF + 4; fn parse(cookie: &num_bigint::BigInt) -> Option { - use std::convert::TryInto; let (_, mut buf) = cookie.to_bytes_le(); if buf.len() > Self::BYTE_LEN { return None; diff --git a/vm/src/stdlib/os.rs b/vm/src/stdlib/os.rs index 037e474cb..e55b3425d 100644 --- a/vm/src/stdlib/os.rs +++ b/vm/src/stdlib/os.rs @@ -1584,7 +1584,6 @@ pub(super) mod _os { #[cfg(target_os = "linux")] #[pyfunction] fn copy_file_range(args: CopyFileRangeArgs, vm: &VirtualMachine) -> PyResult { - use std::convert::{TryFrom, TryInto}; let p_offset_src = args.offset_src.as_ref().map_or_else(std::ptr::null, |x| x); let p_offset_dst = args.offset_dst.as_ref().map_or_else(std::ptr::null, |x| x); let count: usize = args diff --git a/vm/src/stdlib/posix.rs b/vm/src/stdlib/posix.rs index 3491ee2a5..be28774fe 100644 --- a/vm/src/stdlib/posix.rs +++ b/vm/src/stdlib/posix.rs @@ -43,9 +43,6 @@ pub mod module { use bitflags::bitflags; use nix::fcntl; use nix::unistd::{self, Gid, Pid, Uid}; - #[allow(unused_imports)] // TODO: use will be unnecessary in edition 2021 - use std::convert::TryFrom; - use std::convert::TryInto; use std::ffi::{CStr, CString}; use std::os::unix::ffi as ffi_ext; use std::os::unix::io::RawFd; diff --git a/vm/src/stdlib/pwd.rs b/vm/src/stdlib/pwd.rs index 5c316f99d..79c7d00a9 100644 --- a/vm/src/stdlib/pwd.rs +++ b/vm/src/stdlib/pwd.rs @@ -8,7 +8,6 @@ mod pwd { PyObjectRef, PyResult, PyStructSequence, VirtualMachine, }; use nix::unistd::{self, User}; - use std::convert::TryFrom; use std::ptr::NonNull; #[pyattr] diff --git a/vm/src/stdlib/pystruct.rs b/vm/src/stdlib/pystruct.rs index 99ecc5f89..8d1157e42 100644 --- a/vm/src/stdlib/pystruct.rs +++ b/vm/src/stdlib/pystruct.rs @@ -27,7 +27,6 @@ pub(crate) mod _struct { use itertools::Itertools; use num_bigint::BigInt; use num_traits::{PrimInt, ToPrimitive}; - use std::convert::TryFrom; use std::iter::Peekable; use std::{fmt, mem, os::raw}; @@ -473,7 +472,7 @@ pub(crate) mod _struct { fn get_int_or_index(vm: &VirtualMachine, arg: PyObjectRef) -> PyResult where - T: PrimInt + for<'a> std::convert::TryFrom<&'a BigInt>, + T: PrimInt + for<'a> TryFrom<&'a BigInt>, { match vm.to_index_opt(arg) { Some(index) => index? diff --git a/vm/src/stdlib/winreg.rs b/vm/src/stdlib/winreg.rs index c3f4dcc41..3c6124958 100644 --- a/vm/src/stdlib/winreg.rs +++ b/vm/src/stdlib/winreg.rs @@ -33,7 +33,6 @@ mod winreg { TryFromObject, VirtualMachine, }; use ::winreg::{enums::RegType, RegKey, RegValue}; - use std::convert::TryInto; use std::ffi::OsStr; use std::io; use winapi::shared::winerror;