diff --git a/common/src/borrow.rs b/common/src/borrow.rs index d33c200f0..00a0b4771 100644 --- a/common/src/borrow.rs +++ b/common/src/borrow.rs @@ -37,10 +37,10 @@ impl Deref for BorrowedValue<'_, T> { fn deref(&self) -> &T { match self { Self::Ref(r) => r, - Self::MuLock(m) => &m, - Self::MappedMuLock(m) => &m, - Self::ReadLock(r) => &r, - Self::MappedReadLock(m) => &m, + Self::MuLock(m) => m, + Self::MappedMuLock(m) => m, + Self::ReadLock(r) => r, + Self::MappedReadLock(m) => m, } } } @@ -76,10 +76,10 @@ impl Deref for BorrowedValueMut<'_, T> { fn deref(&self) -> &T { match self { Self::RefMut(r) => r, - Self::MuLock(m) => &m, - Self::MappedMuLock(m) => &m, - Self::WriteLock(w) => &w, - Self::MappedWriteLock(w) => &w, + Self::MuLock(m) => m, + Self::MappedMuLock(m) => m, + Self::WriteLock(w) => w, + Self::MappedWriteLock(w) => w, } } } diff --git a/compiler/src/compile.rs b/compiler/src/compile.rs index 0d65bacf3..db33c5b80 100644 --- a/compiler/src/compile.rs +++ b/compiler/src/compile.rs @@ -348,7 +348,7 @@ impl Compiler { self.emit(Instruction::PrintExpr); } } else { - self.compile_statement(&statement)?; + self.compile_statement(statement)?; } } @@ -470,7 +470,7 @@ impl Compiler { // we do this here because `from __future__` still executes that `from` statement at runtime, // we still need to compile the ImportFrom down below ImportFrom { module, names, .. } if module.as_deref() == Some("__future__") => { - self.compile_future_features(&names)? + self.compile_future_features(names)? } // if we find any other statement, stop accepting future statements _ => self.done_with_future_stmts = true, @@ -1068,7 +1068,7 @@ impl Compiler { self.emit_constant(ConstantData::Str { value: self.mangle(&arg.node.arg).into_owned(), }); - self.compile_expression(&annotation)?; + self.compile_expression(annotation)?; num_annotations += 1; } } @@ -1159,7 +1159,7 @@ impl Compiler { orelse, finalbody, .. - } => self.find_ann(&body) || self.find_ann(orelse) || self.find_ann(finalbody), + } => self.find_ann(body) || self.find_ann(orelse) || self.find_ann(finalbody), _ => false, }; if res { diff --git a/compiler/src/symboltable.rs b/compiler/src/symboltable.rs index 8eaa0958d..10c13ba55 100644 --- a/compiler/src/symboltable.rs +++ b/compiler/src/symboltable.rs @@ -617,7 +617,7 @@ impl SymbolTableBuilder { fn scan_parameter_annotation(&mut self, parameter: &ast::Arg) -> SymbolTableResult { if let Some(annotation) = ¶meter.node.annotation { - self.scan_expression(&annotation, ExpressionContext::Load)?; + self.scan_expression(annotation, ExpressionContext::Load)?; } Ok(()) } @@ -1075,7 +1075,7 @@ impl SymbolTableBuilder { // Evaluate eventual default parameters: self.scan_expressions(&args.defaults, ExpressionContext::Load)?; for expression in args.kw_defaults.iter().flatten() { - self.scan_expression(&expression, ExpressionContext::Load)?; + self.scan_expression(expression, ExpressionContext::Load)?; } // Annotations are scanned in outer scope: diff --git a/derive/src/from_args.rs b/derive/src/from_args.rs index d396c2008..82f1b2dc9 100644 --- a/derive/src/from_args.rs +++ b/derive/src/from_args.rs @@ -81,7 +81,7 @@ impl ArgAttribute { } match arg { NestedMeta::Meta(Meta::Path(path)) => { - if path_eq(&path, "default") || path_eq(&path, "optional") { + if path_eq(path, "default") || path_eq(path, "optional") { if self.default.is_none() { self.default = Some(None); } diff --git a/derive/src/pyclass.rs b/derive/src/pyclass.rs index e5e2556bd..24e106354 100644 --- a/derive/src/pyclass.rs +++ b/derive/src/pyclass.rs @@ -28,7 +28,7 @@ fn extract_items_into_context<'a, Item>( { for item in items { let r = item.try_split_attr_mut(|attrs, item| { - let (pyitems, cfgs) = attrs_to_content_items(&attrs, new_impl_item::)?; + let (pyitems, cfgs) = attrs_to_content_items(attrs, new_impl_item::)?; for pyitem in pyitems.iter().rev() { let r = pyitem.gen_impl_item(ImplItemArgs:: { item, @@ -227,7 +227,7 @@ pub(crate) fn impl_pyclass( let class_name = class_meta.class_name()?; let module_name = class_meta.module()?; let base = class_meta.base()?; - let class_def = generate_class_def(&ident, &class_name, module_name.as_deref(), base, &attrs)?; + let class_def = generate_class_def(ident, &class_name, module_name.as_deref(), base, attrs)?; let ret = quote! { #item @@ -424,7 +424,7 @@ where }; let (py_name, tokens) = if args.item.is_function_or_method() || args.item.is_const() { let ident = args.item.get_ident().unwrap(); - let py_name = get_py_name(&attr, &ident)?; + let py_name = get_py_name(&attr, ident)?; let value = if args.item.is_const() { // TODO: ctx.new_value diff --git a/derive/src/pymodule.rs b/derive/src/pymodule.rs index e3d33fdbb..fc4874f90 100644 --- a/derive/src/pymodule.rs +++ b/derive/src/pymodule.rs @@ -39,7 +39,7 @@ pub fn impl_pymodule( // collect to context for item in items.iter_mut() { let r = item.try_split_attr_mut(|attrs, item| { - let (pyitems, cfgs) = attrs_to_module_items(&attrs, new_module_item)?; + let (pyitems, cfgs) = attrs_to_module_items(attrs, new_module_item)?; for pyitem in pyitems.iter().rev() { let r = pyitem.gen_module_item(ModuleItemArgs { item, @@ -283,7 +283,7 @@ impl ModuleItem for FunctionItem { impl ModuleItem for ClassItem { fn gen_module_item(&self, args: ModuleItemArgs<'_>) -> Result<()> { - let (ident, _) = pyclass_ident_and_attrs(&args.item)?; + let (ident, _) = pyclass_ident_and_attrs(args.item)?; let (module_name, class_name) = { let class_attr = &mut args.attrs[self.inner.index]; if self.pyattrs.is_empty() { @@ -350,7 +350,7 @@ impl ModuleItem for AttributeItem { let (py_name, tokens) = match args.item { Item::Fn(syn::ItemFn { sig, .. }) => { let ident = &sig.ident; - let py_name = get_py_name(&attr, &ident)?; + let py_name = get_py_name(&attr, ident)?; ( py_name.clone(), quote! { @@ -359,7 +359,7 @@ impl ModuleItem for AttributeItem { ) } Item::Const(syn::ItemConst { ident, .. }) => { - let py_name = get_py_name(&attr, &ident)?; + let py_name = get_py_name(&attr, ident)?; ( py_name.clone(), quote! { diff --git a/jit/src/instructions.rs b/jit/src/instructions.rs index d0ad63e94..a947807c3 100644 --- a/jit/src/instructions.rs +++ b/jit/src/instructions.rs @@ -138,7 +138,7 @@ impl<'a, 'b> FunctionCompiler<'a, 'b> { continue; } - self.add_instruction(&instruction, &bytecode.constants)?; + self.add_instruction(instruction, &bytecode.constants)?; } Ok(()) diff --git a/src/lib.rs b/src/lib.rs index abb5c63ac..8e27e633b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -142,7 +142,7 @@ where } } Err(err) => { - print_exception(&vm, err); + print_exception(vm, err); 1 } }; @@ -535,9 +535,9 @@ fn run_rustpython(vm: &VirtualMachine, matches: &ArgMatches) -> PyResult<()> { // Figure out if a -c option was given: if let Some(command) = matches.value_of("c") { - run_command(&vm, scope, command.to_owned())?; + run_command(vm, scope, command.to_owned())?; } else if let Some(module) = matches.value_of("m") { - run_module(&vm, module)?; + run_module(vm, module)?; } else if matches.is_present("install_pip") { let get_getpip = rustpython_vm::py_compile!( source = r#"\ @@ -555,16 +555,16 @@ __import__("io").TextIOWrapper( eprintln!("running get-pip.py..."); _run_string(vm, scope, getpip_code.as_str(), "get-pip.py".to_owned())?; } else if let Some(filename) = matches.value_of("script") { - run_script(&vm, scope.clone(), filename)?; + run_script(vm, scope.clone(), filename)?; if matches.is_present("inspect") { - shell::run_shell(&vm, scope)?; + shell::run_shell(vm, scope)?; } } else { println!( "Welcome to the magnificent Rust Python {} interpreter \u{1f631} \u{1f596}", crate_version!() ); - shell::run_shell(&vm, scope)?; + shell::run_shell(vm, scope)?; } Ok(()) diff --git a/vm/src/anystr.rs b/vm/src/anystr.rs index aabd7de43..055eb7ad3 100644 --- a/vm/src/anystr.rs +++ b/vm/src/anystr.rs @@ -247,7 +247,7 @@ pub trait AnyStr<'s>: 's { { if range.is_normal() { let start = range.start; - let index = find(self.get_chars(range), &needle)?; + let index = find(self.get_chars(range), needle)?; Some(start + index) } else { None @@ -260,7 +260,7 @@ pub trait AnyStr<'s>: 's { F: Fn(&Self, &Self) -> usize, { if range.is_normal() { - count(self.get_chars(range), &needle) + count(self.get_chars(range), needle) } else { 0 } @@ -336,10 +336,10 @@ pub trait AnyStr<'s>: 's { FC: Fn(&Self, &Self) -> bool, { //if self.py_starts_with(prefix) { - if is_prefix(&self, prefix) { + if is_prefix(self, prefix) { self.get_bytes(prefix_len..self.bytes_len()) } else { - &self + self } } @@ -347,10 +347,10 @@ pub trait AnyStr<'s>: 's { where FC: Fn(&Self, &Self) -> bool, { - if is_suffix(&self, suffix) { + if is_suffix(self, suffix) { self.get_bytes(0..self.bytes_len() - suffix_len) } else { - &self + self } } diff --git a/vm/src/builtins/complex.rs b/vm/src/builtins/complex.rs index f86a88e74..e129da34d 100644 --- a/vm/src/builtins/complex.rs +++ b/vm/src/builtins/complex.rs @@ -350,7 +350,7 @@ impl Comparable for PyComplex { let result = if let Some(other) = other.payload_if_subclass::(vm) { zelf.value == other.value } else { - match float::to_op_float(&other, vm) { + match float::to_op_float(other, vm) { Ok(Some(other)) => zelf.value == other.into(), Err(_) => false, Ok(None) => return Ok(PyComparisonValue::NotImplemented), diff --git a/vm/src/builtins/filter.rs b/vm/src/builtins/filter.rs index 0ba1f904b..82aa9d4d3 100644 --- a/vm/src/builtins/filter.rs +++ b/vm/src/builtins/filter.rs @@ -52,7 +52,7 @@ impl PyIter for PyFilter { } else { // the predicate itself can raise StopIteration which does stop the filter // iteration - vm.invoke(&predicate, vec![next_obj.clone()])? + vm.invoke(predicate, vec![next_obj.clone()])? }; if pybool::boolval(vm, predicate_value)? { return Ok(next_obj); diff --git a/vm/src/builtins/int.rs b/vm/src/builtins/int.rs index c98720e80..10d09fb10 100644 --- a/vm/src/builtins/int.rs +++ b/vm/src/builtins/int.rs @@ -177,7 +177,7 @@ fn inner_floordiv(int1: &BigInt, int2: &BigInt, vm: &VirtualMachine) -> PyResult if int2.is_zero() { Err(vm.new_zero_division_error("integer division by zero".to_owned())) } else { - Ok(vm.ctx.new_int(int1.div_floor(&int2))) + Ok(vm.ctx.new_int(int1.div_floor(int2))) } } @@ -364,12 +364,12 @@ impl PyInt { #[pymethod(name = "__floordiv__")] fn floordiv(&self, other: PyObjectRef, vm: &VirtualMachine) -> PyResult { - self.general_op(other, |a, b| inner_floordiv(a, b, &vm), vm) + self.general_op(other, |a, b| inner_floordiv(a, b, vm), vm) } #[pymethod(name = "__rfloordiv__")] fn rfloordiv(&self, other: PyObjectRef, vm: &VirtualMachine) -> PyResult { - self.general_op(other, |a, b| inner_floordiv(b, a, &vm), vm) + self.general_op(other, |a, b| inner_floordiv(b, a, vm), vm) } #[pymethod(name = "__lshift__")] @@ -906,7 +906,7 @@ fn bytes_to_int(lit: &[u8], mut base: u32) -> Option { Some(if lit.is_empty() { BigInt::zero() } else { - let uint = BigUint::parse_bytes(&lit, base)?; + let uint = BigUint::parse_bytes(lit, base)?; BigInt::from_biguint(sign.unwrap_or(Sign::Plus), uint) }) } @@ -950,7 +950,7 @@ pub(crate) fn try_int(obj: &PyObjectRef, vm: &VirtualMachine) -> PyResult() { return try_convert(obj, s.as_str().as_bytes(), vm); } - if let Ok(r) = try_bytes_like(vm, &obj, |x| try_convert(obj, x, vm)) { + if let Ok(r) = try_bytes_like(vm, obj, |x| try_convert(obj, x, vm)) { return r; } // strict `int` check diff --git a/vm/src/builtins/list.rs b/vm/src/builtins/list.rs index 9c54227ad..3f7a15038 100644 --- a/vm/src/builtins/list.rs +++ b/vm/src/builtins/list.rs @@ -240,7 +240,7 @@ impl PyList { #[pymethod(name = "__rmul__")] fn rmul(&self, counter: isize, vm: &VirtualMachine) -> PyObjectRef { - self.mul(counter, &vm) + self.mul(counter, vm) } #[pymethod(name = "__imul__")] diff --git a/vm/src/builtins/make_module.rs b/vm/src/builtins/make_module.rs index 566a66e71..f09fb4703 100644 --- a/vm/src/builtins/make_module.rs +++ b/vm/src/builtins/make_module.rs @@ -174,7 +174,7 @@ mod decl { .parse::() .map_err(|err| vm.new_value_error(err.to_string()))?; - vm.compile(&source, mode, args.filename.as_str().to_owned()) + vm.compile(source, mode, args.filename.as_str().to_owned()) .map(|o| o.into_object()) .map_err(|err| vm.new_syntax_error(&err)) } @@ -182,7 +182,7 @@ mod decl { let mode = mode_str .parse::() .map_err(|err| vm.new_value_error(err.to_string()))?; - ast::parse(&vm, &source, mode) + ast::parse(vm, source, mode) } } } diff --git a/vm/src/builtins/module.rs b/vm/src/builtins/module.rs index 3bc161aaa..e273eb11b 100644 --- a/vm/src/builtins/module.rs +++ b/vm/src/builtins/module.rs @@ -123,5 +123,5 @@ impl SlotGetattro for PyModule { } pub(crate) fn init(context: &PyContext) { - PyModule::extend_class(&context, &context.types.module_type); + PyModule::extend_class(context, &context.types.module_type); } diff --git a/vm/src/builtins/property.rs b/vm/src/builtins/property.rs index 1113ad958..f5548931d 100644 --- a/vm/src/builtins/property.rs +++ b/vm/src/builtins/property.rs @@ -81,7 +81,7 @@ impl SlotDescriptor for PyProperty { if vm.is_none(&obj) { Ok(zelf.into_object()) } else if let Some(getter) = zelf.getter.read().as_ref() { - vm.invoke(&getter, (obj,)) + vm.invoke(getter, (obj,)) } else { Err(vm.new_attribute_error("unreadable attribute".to_string())) } @@ -121,14 +121,14 @@ impl PyProperty { let zelf = PyRef::::try_from_object(vm, zelf)?; match value { Some(value) => { - if let Some(ref setter) = zelf.setter.read().as_ref() { + if let Some(setter) = zelf.setter.read().as_ref() { vm.invoke(setter, vec![obj, value]).map(drop) } else { Err(vm.new_attribute_error("can't set attribute".to_owned())) } } None => { - if let Some(ref deleter) = zelf.deleter.read().as_ref() { + if let Some(deleter) = zelf.deleter.read().as_ref() { vm.invoke(deleter, (obj,)).map(drop) } else { Err(vm.new_attribute_error("can't delete attribute".to_owned())) diff --git a/vm/src/builtins/pybool.rs b/vm/src/builtins/pybool.rs index 16c759f4a..81e8a01f4 100644 --- a/vm/src/builtins/pybool.rs +++ b/vm/src/builtins/pybool.rs @@ -167,7 +167,7 @@ pub(crate) fn get_value(obj: &PyObjectRef) -> bool { } fn get_py_int(obj: &PyObjectRef) -> &PyInt { - &obj.payload::().unwrap() + obj.payload::().unwrap() } #[derive(Debug, Default, Copy, Clone, PartialEq)] diff --git a/vm/src/builtins/pytype.rs b/vm/src/builtins/pytype.rs index 8332ac590..bfaccec32 100644 --- a/vm/src/builtins/pytype.rs +++ b/vm/src/builtins/pytype.rs @@ -94,7 +94,7 @@ impl PyType { if let Some(r) = f(self) { Some(r) } else { - self.mro.iter().find_map(|cls| f(&cls)) + self.mro.iter().find_map(|cls| f(cls)) } } @@ -579,7 +579,7 @@ impl Callable for PyType { vm_trace!("type_call: {:?}", zelf); let obj = call_tp_new(zelf.clone(), zelf.clone(), args.clone(), vm)?; - if (zelf.is(&vm.ctx.types.type_type) && args.kwargs.is_empty()) || !obj.isinstance(&zelf) { + if (zelf.is(&vm.ctx.types.type_type) && args.kwargs.is_empty()) || !obj.isinstance(zelf) { return Ok(obj); } diff --git a/vm/src/builtins/slice.rs b/vm/src/builtins/slice.rs index fbe84c629..b6424253e 100644 --- a/vm/src/builtins/slice.rs +++ b/vm/src/builtins/slice.rs @@ -37,7 +37,7 @@ impl PySlice { fn start_ref<'a>(&'a self, vm: &'a VirtualMachine) -> &'a PyObjectRef { match &self.start { - Some(v) => &v, + Some(v) => v, None => vm.ctx.none.as_object(), } } @@ -54,7 +54,7 @@ impl PySlice { fn step_ref<'a>(&'a self, vm: &'a VirtualMachine) -> &'a PyObjectRef { match &self.step { - Some(v) => &v, + Some(v) => v, None => vm.ctx.none.as_object(), } } diff --git a/vm/src/builtins/weakproxy.rs b/vm/src/builtins/weakproxy.rs index 4aa8612f9..6bb8f433e 100644 --- a/vm/src/builtins/weakproxy.rs +++ b/vm/src/builtins/weakproxy.rs @@ -67,5 +67,5 @@ impl SlotSetattro for PyWeakProxy { } pub fn init(context: &PyContext) { - PyWeakProxy::extend_class(&context, &context.types.weakproxy_type); + PyWeakProxy::extend_class(context, &context.types.weakproxy_type); } diff --git a/vm/src/bytesinner.rs b/vm/src/bytesinner.rs index 13c2f4714..875cd188a 100644 --- a/vm/src/bytesinner.rs +++ b/vm/src/bytesinner.rs @@ -594,7 +594,7 @@ impl PyBytesInner { }; for i in self.elements.iter() { - if !delete.contains(&i) { + if !delete.contains(i) { res.push(table[*i as usize]); } } diff --git a/vm/src/byteslike.rs b/vm/src/byteslike.rs index eae9bae20..be55b8faa 100644 --- a/vm/src/byteslike.rs +++ b/vm/src/byteslike.rs @@ -50,7 +50,7 @@ impl PyRwBytesLike { impl PyBytesLike { pub fn new(vm: &VirtualMachine, obj: &PyObjectRef) -> PyResult { - let buffer = try_buffer_from_object(vm, &obj)?; + let buffer = try_buffer_from_object(vm, obj)?; if buffer.get_options().contiguous { Ok(Self(buffer)) } else { @@ -98,7 +98,7 @@ pub fn try_rw_bytes_like( impl PyRwBytesLike { pub fn new(vm: &VirtualMachine, obj: &PyObjectRef) -> PyResult { - let buffer = try_buffer_from_object(vm, &obj)?; + let buffer = try_buffer_from_object(vm, obj)?; let options = buffer.get_options(); if !options.contiguous { Err(vm.new_type_error("non-contiguous buffer is not a bytes-like object".to_owned())) diff --git a/vm/src/cformat.rs b/vm/src/cformat.rs index 8ff8fb2fc..fc40a3948 100644 --- a/vm/src/cformat.rs +++ b/vm/src/cformat.rs @@ -563,7 +563,7 @@ fn try_update_quantity_from_tuple<'a, I: Iterator>( if !width_obj.isinstance(&vm.ctx.types.int_type) { Err(vm.new_type_error("* wants int".to_owned())) } else { - let i = int::get_value(&width_obj); + let i = int::get_value(width_obj); let i = int::try_to_primitive::(i, vm)? as usize; *q = Some(CFormatQuantity::Amount(i)); Ok(()) @@ -818,7 +818,7 @@ impl CFormatString { { for (_, part) in &self.parts { match part { - CFormatPart::Literal(literal) => result.push_str(&literal), + CFormatPart::Literal(literal) => result.push_str(literal), CFormatPart::Spec(_) => unreachable!(), } } @@ -835,7 +835,7 @@ impl CFormatString { return if is_mapping { for (_, part) in &self.parts { match part { - CFormatPart::Literal(literal) => result.push_str(&literal), + CFormatPart::Literal(literal) => result.push_str(literal), CFormatPart::Spec(spec) => { let value = match &spec.mapping_key { Some(key) => values_obj.get_item(key, vm)?, @@ -862,7 +862,7 @@ impl CFormatString { for (_, part) in &mut self.parts { match part { - CFormatPart::Literal(literal) => result.push_str(&literal), + CFormatPart::Literal(literal) => result.push_str(literal), CFormatPart::Spec(spec) => { try_update_quantity_from_tuple(vm, &mut value_iter, &mut spec.min_field_width)?; try_update_quantity_from_tuple(vm, &mut value_iter, &mut spec.precision)?; diff --git a/vm/src/exceptions.rs b/vm/src/exceptions.rs index e1b27ac15..94c609715 100644 --- a/vm/src/exceptions.rs +++ b/vm/src/exceptions.rs @@ -824,7 +824,7 @@ impl serde::Serialize for SerializeException<'_> { let rendered = { let mut rendered = String::new(); - write_exception(&mut rendered, self.vm, &self.exc).map_err(S::Error::custom)?; + write_exception(&mut rendered, self.vm, self.exc).map_err(S::Error::custom)?; rendered }; struc.serialize_field("rendered", &rendered)?; diff --git a/vm/src/format.rs b/vm/src/format.rs index 3c8de2996..997de903f 100644 --- a/vm/src/format.rs +++ b/vm/src/format.rs @@ -135,7 +135,7 @@ fn parse_align(text: &str) -> (Option, &str) { let mut chars = text.chars(); let maybe_align = chars.next().and_then(FormatAlign::from_char); if maybe_align.is_some() { - (maybe_align, &chars.as_str()) + (maybe_align, chars.as_str()) } else { (None, text) } @@ -202,7 +202,7 @@ fn parse_precision(text: &str) -> Result<(Option, &str), &'static str> { let mut chars = text.chars(); Ok(match chars.next() { Some('.') => { - let (size, remaining) = parse_number(&chars.as_str())?; + let (size, remaining) = parse_number(chars.as_str())?; if size.is_some() { (size, remaining) } else { @@ -823,7 +823,7 @@ impl FormatString { } let nested_format = - FormatString::from_str(&format_spec).map_err(|e| e.into_pyexception(vm))?; + FormatString::from_str(format_spec).map_err(|e| e.into_pyexception(vm))?; let format_spec = nested_format.format_internal(vm, field_func)?; pystr = call_object_format(vm, argument, *preconversion_spec, &format_spec)?; @@ -879,7 +879,7 @@ impl FormatString { FieldType::Auto | FieldType::Index(_) => { Err(vm.new_value_error("Format string contains positional fields".to_owned())) } - FieldType::Keyword(keyword) => dict.get_item(keyword, &vm), + FieldType::Keyword(keyword) => dict.get_item(keyword, vm), }) } } diff --git a/vm/src/frame.rs b/vm/src/frame.rs index ab828d829..abb85d358 100644 --- a/vm/src/frame.rs +++ b/vm/src/frame.rs @@ -218,7 +218,7 @@ impl FrameRef { globals: &self.globals, builtins: &self.builtins, lasti: &self.lasti, - object: &self, + object: self, state: &mut state, }; f(exec) diff --git a/vm/src/py_serde.rs b/vm/src/py_serde.rs index c8416d1da..2db7f9f40 100644 --- a/vm/src/py_serde.rs +++ b/vm/src/py_serde.rs @@ -90,10 +90,10 @@ impl<'s> serde::Serialize for PyObjectSerializer<'s> { let pairs: Vec<_> = dict.into_iter().collect(); let mut map = serializer.serialize_map(Some(pairs.len()))?; for (key, e) in pairs.iter() { - map.serialize_entry(&self.clone_with_object(key), &self.clone_with_object(&e))?; + map.serialize_entry(&self.clone_with_object(key), &self.clone_with_object(e))?; } map.end() - } else if self.vm.is_none(&self.pyobject) { + } else if self.vm.is_none(self.pyobject) { serializer.serialize_none() } else { Err(serde::ser::Error::custom(format!( diff --git a/vm/src/pyobject.rs b/vm/src/pyobject.rs index df823f1be..65c78d11f 100644 --- a/vm/src/pyobject.rs +++ b/vm/src/pyobject.rs @@ -1034,7 +1034,7 @@ pub trait PyClassImpl: PyClassDef { ); } Self::impl_extend_class(ctx, class); - ctx.add_slot_wrappers(&class); + ctx.add_slot_wrappers(class); if let Some(doc) = Self::DOC { class.set_str_attr("__doc__", ctx.new_str(doc)); } diff --git a/vm/src/pyobjectrc.rs b/vm/src/pyobjectrc.rs index 181b09904..d2cd5836c 100644 --- a/vm/src/pyobjectrc.rs +++ b/vm/src/pyobjectrc.rs @@ -554,7 +554,7 @@ pub(crate) fn init_type_hierarchy() -> (PyTypeRef, PyTypeRef) { object_type .subclasses .write() - .push(PyWeak::downgrade(&type_type.as_object())); + .push(PyWeak::downgrade(type_type.as_object())); (type_type, object_type) } diff --git a/vm/src/stdlib/array.rs b/vm/src/stdlib/array.rs index d51106ae5..4a2a084b4 100644 --- a/vm/src/stdlib/array.rs +++ b/vm/src/stdlib/array.rs @@ -760,7 +760,7 @@ impl PyArray { #[pymethod(name = "__rmul__")] fn rmul(&self, counter: isize, vm: &VirtualMachine) -> PyRef { - self.mul(counter, &vm) + self.mul(counter, vm) } #[pymethod(name = "__imul__")] @@ -818,7 +818,7 @@ impl Comparable for PyArray { let other = class_or_notimplemented!(Self, other); if let PyComparisonValue::Implemented(x) = - op.eq_only(|| Ok(zelf.array_eq(&other, vm)?.into()))? + op.eq_only(|| Ok(zelf.array_eq(other, vm)?.into()))? { return Ok(x.into()); } diff --git a/vm/src/stdlib/binascii.rs b/vm/src/stdlib/binascii.rs index efd4eaa09..383e14a8b 100644 --- a/vm/src/stdlib/binascii.rs +++ b/vm/src/stdlib/binascii.rs @@ -107,7 +107,7 @@ mod decl { let crc = value.unwrap_or(0); let mut digest = crc32::Digest::new_with_initial(crc32::IEEE, crc); - data.with_ref(|bytes| digest.write(&bytes)); + data.with_ref(|bytes| digest.write(bytes)); Ok(vm.ctx.new_int(digest.sum32())) } diff --git a/vm/src/stdlib/io.rs b/vm/src/stdlib/io.rs index d18d8be30..6a2e962c0 100644 --- a/vm/src/stdlib/io.rs +++ b/vm/src/stdlib/io.rs @@ -516,7 +516,7 @@ mod _io { } #[pyslot] fn tp_iternext(instance: &PyObjectRef, vm: &VirtualMachine) -> PyResult { - let line = vm.call_method(&instance, "readline", ())?; + let line = vm.call_method(instance, "readline", ())?; if !pybool::boolval(vm, line.clone())? { Err(vm.new_stop_iteration()) } else { @@ -1357,7 +1357,7 @@ mod _io { }; match name { Some(name) => { - if let Some(_guard) = ReprGuard::enter(vm, &obj) { + if let Some(_guard) = ReprGuard::enter(vm, obj) { vm.to_repr(&name).map(Some) } else { Err(vm.new_runtime_error(format!( diff --git a/vm/src/stdlib/itertools.rs b/vm/src/stdlib/itertools.rs index 1fd36cff2..ea5f1fa8d 100644 --- a/vm/src/stdlib/itertools.rs +++ b/vm/src/stdlib/itertools.rs @@ -640,7 +640,7 @@ mod decl { let old_key = { let mut state = zelf.groupby.state.lock(); - if !state.is_current(&zelf) { + if !state.is_current(zelf) { return Err(vm.new_stop_iteration()); } @@ -735,14 +735,14 @@ mod decl { ) = args.bind(vm)?; let step = if !vm.is_none(&step) { - pyobject_to_opt_usize(step, "Step", &vm)? + pyobject_to_opt_usize(step, "Step", vm)? } else { 1usize }; (iter, start, stop, step) }; let start = if !vm.is_none(&start) { - pyobject_to_opt_usize(start, "Start", &vm)? + pyobject_to_opt_usize(start, "Start", vm)? } else { 0usize }; @@ -752,7 +752,7 @@ mod decl { }; let stop = if !vm.is_none(&stop) { - Some(pyobject_to_opt_usize(stop, "Stop", &vm)?) + Some(pyobject_to_opt_usize(stop, "Stop", vm)?) } else { None }; diff --git a/vm/src/stdlib/math.rs b/vm/src/stdlib/math.rs index 94840d037..4f4257c0f 100644 --- a/vm/src/stdlib/math.rs +++ b/vm/src/stdlib/math.rs @@ -311,7 +311,7 @@ fn math_trunc(value: PyObjectRef, vm: &VirtualMachine) -> PyResult { fn math_ceil(value: PyObjectRef, vm: &VirtualMachine) -> PyResult { let result_or_err = try_magic_method("__ceil__", vm, &value); if result_or_err.is_err() { - if let Ok(Some(v)) = float::try_float_opt(&value, &vm) { + if let Ok(Some(v)) = float::try_float_opt(&value, vm) { let v = float::try_bigint(v.ceil(), vm)?; return Ok(vm.ctx.new_int(v)); } @@ -328,7 +328,7 @@ fn math_ceil(value: PyObjectRef, vm: &VirtualMachine) -> PyResult { fn math_floor(value: PyObjectRef, vm: &VirtualMachine) -> PyResult { let result_or_err = try_magic_method("__floor__", vm, &value); if result_or_err.is_err() { - if let Ok(Some(v)) = float::try_float_opt(&value, &vm) { + if let Ok(Some(v)) = float::try_float_opt(&value, vm) { let v = float::try_bigint(v.floor(), vm)?; return Ok(vm.ctx.new_int(v)); } @@ -379,7 +379,7 @@ where let mut res = argvec[0].as_bigint().clone(); for num in argvec[1..].iter() { - res = op(&res, &num) + res = op(&res, num) } res } diff --git a/vm/src/stdlib/os.rs b/vm/src/stdlib/os.rs index 24a883cf1..672b5e256 100644 --- a/vm/src/stdlib/os.rs +++ b/vm/src/stdlib/os.rs @@ -1978,7 +1978,7 @@ impl<'a> SupportFunc { pub fn make_module(vm: &VirtualMachine) -> PyObjectRef { let module = platform::make_module(vm); - _os::extend_module(&vm, &module); + _os::extend_module(vm, &module); let support_funcs = _os::support_funcs(); let supports_fd = PySet::default().into_ref(vm); @@ -2510,8 +2510,8 @@ mod posix { .into_iter() .map(|(k, v)| -> PyResult<_> { let (key, value) = ( - PyPathLike::try_from_object(&vm, k)?.into_bytes(), - PyPathLike::try_from_object(&vm, v)?.into_bytes(), + PyPathLike::try_from_object(vm, k)?.into_bytes(), + PyPathLike::try_from_object(vm, v)?.into_bytes(), ); if memchr::memchr(b'=', &key).is_some() { diff --git a/vm/src/stdlib/pystruct.rs b/vm/src/stdlib/pystruct.rs index 69f3c52e8..d172579a0 100644 --- a/vm/src/stdlib/pystruct.rs +++ b/vm/src/stdlib/pystruct.rs @@ -218,7 +218,7 @@ pub(crate) mod _struct { ) -> PyResult { let decoded_fmt = match fmt { Either::A(string) => string.as_str(), - Either::B(bytes) if bytes.is_ascii() => std::str::from_utf8(&bytes).unwrap(), + Either::B(bytes) if bytes.is_ascii() => std::str::from_utf8(bytes).unwrap(), _ => { return Err(vm.new_unicode_decode_error( "Struct format must be a ascii string".to_owned(), diff --git a/vm/src/stdlib/thread.rs b/vm/src/stdlib/thread.rs index a94ff2e69..212c4d237 100644 --- a/vm/src/stdlib/thread.rs +++ b/vm/src/stdlib/thread.rs @@ -248,7 +248,7 @@ fn _thread_start_new_thread( ) .map(|handle| { vm.state.thread_count.fetch_add(1); - thread_to_id(&handle.thread()) + thread_to_id(handle.thread()) }) .map_err(|err| err.into_pyexception(vm)) } diff --git a/vm/src/stdlib/time_module.rs b/vm/src/stdlib/time_module.rs index a26a53884..04aae24f5 100644 --- a/vm/src/stdlib/time_module.rs +++ b/vm/src/stdlib/time_module.rs @@ -133,13 +133,13 @@ fn time_asctime(t: OptionalArg, vm: &VirtualMachine) -> PyResult { OptionalArg::Present(t) => t.to_date_time(vm)?, OptionalArg::Missing => default, }; - let formatted_time = instant.format(&CFMT).to_string(); + let formatted_time = instant.format(CFMT).to_string(); Ok(vm.ctx.new_str(formatted_time)) } fn time_ctime(secs: OptionalArg>, vm: &VirtualMachine) -> PyResult { let instant = optional_or_localtime(secs, vm)?; - Ok(instant.format(&CFMT).to_string()) + Ok(instant.format(CFMT).to_string()) } fn time_strftime(format: PyStrRef, t: OptionalArg, vm: &VirtualMachine) -> PyResult { diff --git a/vm/src/types.rs b/vm/src/types.rs index 04adad206..264e60373 100644 --- a/vm/src/types.rs +++ b/vm/src/types.rs @@ -202,46 +202,46 @@ impl TypeZoo { /// Fill attributes of builtin types. pub(crate) fn extend(context: &PyContext) { - pytype::init(&context); - object::init(&context); - list::init(&context); - set::init(&context); - tuple::init(&context); - dict::init(&context); - builtinfunc::init(&context); - function::init(&context); - staticmethod::init(&context); - classmethod::init(&context); - generator::init(&context); - coroutine::init(&context); - asyncgenerator::init(&context); - int::init(&context); - float::init(&context); - complex::init(&context); - bytes::init(&context); - bytearray::init(&context); - property::init(&context); - getset::init(&context); - memory::init(&context); - pystr::init(&context); - range::init(&context); - slice::init(&context); - pysuper::init(&context); - iter::init(&context); - enumerate::init(&context); - filter::init(&context); - map::init(&context); - zip::init(&context); - pybool::init(&context); - code::init(&context); - frame::init(&context); - weakref::init(&context); - weakproxy::init(&context); - singletons::init(&context); - module::init(&context); - namespace::init(&context); - mappingproxy::init(&context); - traceback::init(&context); + pytype::init(context); + object::init(context); + list::init(context); + set::init(context); + tuple::init(context); + dict::init(context); + builtinfunc::init(context); + function::init(context); + staticmethod::init(context); + classmethod::init(context); + generator::init(context); + coroutine::init(context); + asyncgenerator::init(context); + int::init(context); + float::init(context); + complex::init(context); + bytes::init(context); + bytearray::init(context); + property::init(context); + getset::init(context); + memory::init(context); + pystr::init(context); + range::init(context); + slice::init(context); + pysuper::init(context); + iter::init(context); + enumerate::init(context); + filter::init(context); + map::init(context); + zip::init(context); + pybool::init(context); + code::init(context); + frame::init(context); + weakref::init(context); + weakproxy::init(context); + singletons::init(context); + module::init(context); + namespace::init(context); + mappingproxy::init(context); + traceback::init(context); } } diff --git a/vm/src/vm.rs b/vm/src/vm.rs index 1fa1e2e46..e4ccf5280 100644 --- a/vm/src/vm.rs +++ b/vm/src/vm.rs @@ -1708,7 +1708,7 @@ impl VirtualMachine { .class() .mro_find_map(|cls| cls.slots.hash.load()) .unwrap(); // hash always exist - hash(&obj, self) + hash(obj, self) } pub fn obj_len_opt(&self, obj: &PyObjectRef) -> Option> {