TryFrom, TryInto, FromIterator are in prelude now

This commit is contained in:
Noa committed 2021-10-21 17:04:19 -05:00
1 parent 33b5827c4d
commit 09e9ea91e7
20 files changed
+2 -26

No files matched your search

-1
View File
@@ -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
-1
View File
@@ -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;
-1
View File
@@ -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 {
-2
View File
@@ -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> {
-2
View File
@@ -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};
-1
View File
@@ -50,7 +50,6 @@ use rustpython_vm::{
TypeProtocol, VirtualMachine,
};
use std::convert::TryInto;
use std::env;
use std::path::Path;
use std::process;
-1
View File
@@ -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 {
-1
View File
@@ -6,7 +6,6 @@ mod _bisect {
function::OptionalArg, types::PyComparisonOp::Lt, ItemProtocol, PyObjectRef, PyResult,
VirtualMachine,
};
use std::convert::TryFrom;
#[derive(FromArgs)]
struct BisectArgs {
-1
View File
@@ -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};
-1
View File
@@ -53,7 +53,6 @@ mod _ssl {
};
use openssl_sys as sys;
use std::{
convert::TryFrom,
ffi::CStr,
fmt,
io::{Read, Write},
-1
View File
@@ -7,7 +7,6 @@ mod termios {
function::IntoPyObject,
PyObjectRef, PyResult, TryFromObject, VirtualMachine,
};
use std::convert::TryFrom;
use termios::Termios;
// TODO: more ioctl numbers
-1
View File
@@ -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;
-1
View File
@@ -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
View File
@@ -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())
}
-2
View File
@@ -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;
-1
View File
@@ -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
-3
View File
@@ -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;
-1
View File
@@ -8,7 +8,6 @@ mod pwd {
PyObjectRef, PyResult, PyStructSequence, VirtualMachine,
};
use nix::unistd::{self, User};
use std::convert::TryFrom;
use std::ptr::NonNull;
#[pyattr]
+1 -2
View File
@@ -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?
-1
View File
@@ -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;