mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 03:04:38 +08:00
TryFrom, TryInto, FromIterator are in prelude now
This commit is contained in:
20 files changed
+2
-26
No files matched your search
@@ -1251,7 +1251,6 @@ pub struct FrozenModule<C: Constant = ConstantData> {
|
||||
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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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> {
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -50,7 +50,6 @@ use rustpython_vm::{
|
||||
TypeProtocol, VirtualMachine,
|
||||
};
|
||||
|
||||
use std::convert::TryInto;
|
||||
use std::env;
|
||||
use std::path::Path;
|
||||
use std::process;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -6,7 +6,6 @@ mod _bisect {
|
||||
function::OptionalArg, types::PyComparisonOp::Lt, ItemProtocol, PyObjectRef, PyResult,
|
||||
VirtualMachine,
|
||||
};
|
||||
use std::convert::TryFrom;
|
||||
|
||||
#[derive(FromArgs)]
|
||||
struct BisectArgs {
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -53,7 +53,6 @@ mod _ssl {
|
||||
};
|
||||
use openssl_sys as sys;
|
||||
use std::{
|
||||
convert::TryFrom,
|
||||
ffi::CStr,
|
||||
fmt,
|
||||
io::{Read, Write},
|
||||
|
||||
@@ -7,7 +7,6 @@ mod termios {
|
||||
function::IntoPyObject,
|
||||
PyObjectRef, PyResult, TryFromObject, VirtualMachine,
|
||||
};
|
||||
use std::convert::TryFrom;
|
||||
use termios::Termios;
|
||||
|
||||
// TODO: more ioctl numbers
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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};
|
||||
|
||||
|
||||
+1
-1
@@ -357,7 +357,7 @@ impl<T> KwArgs<T> {
|
||||
self.0.remove(name)
|
||||
}
|
||||
}
|
||||
impl<T> std::iter::FromIterator<(String, T)> for KwArgs<T> {
|
||||
impl<T> FromIterator<(String, T)> for KwArgs<T> {
|
||||
fn from_iter<I: IntoIterator<Item = (String, T)>>(iter: I) -> Self {
|
||||
KwArgs(iter.into_iter().collect())
|
||||
}
|
||||
|
||||
@@ -1343,7 +1343,6 @@ mod _io {
|
||||
}
|
||||
|
||||
pub fn get_offset(obj: PyObjectRef, vm: &VirtualMachine) -> PyResult<Offset> {
|
||||
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<Self> {
|
||||
use std::convert::TryInto;
|
||||
let (_, mut buf) = cookie.to_bytes_le();
|
||||
if buf.len() > Self::BYTE_LEN {
|
||||
return None;
|
||||
|
||||
@@ -1584,7 +1584,6 @@ pub(super) mod _os {
|
||||
#[cfg(target_os = "linux")]
|
||||
#[pyfunction]
|
||||
fn copy_file_range(args: CopyFileRangeArgs, vm: &VirtualMachine) -> PyResult<usize> {
|
||||
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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -8,7 +8,6 @@ mod pwd {
|
||||
PyObjectRef, PyResult, PyStructSequence, VirtualMachine,
|
||||
};
|
||||
use nix::unistd::{self, User};
|
||||
use std::convert::TryFrom;
|
||||
use std::ptr::NonNull;
|
||||
|
||||
#[pyattr]
|
||||
|
||||
@@ -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<T>(vm: &VirtualMachine, arg: PyObjectRef) -> PyResult<T>
|
||||
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?
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user