Skip to content

Commit 3fb0f32

Browse files
Merge pull request RustPython#335 from ZapAnton/fix_ptr_arg
Fixed the 'ptr_arg' clippy warnings
2 parents 9d5a953 + 1a68402 commit 3fb0f32

File tree

6 files changed

+23
-23
lines changed

6 files changed

+23
-23
lines changed

vm/src/compile.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -674,14 +674,14 @@ impl Compiler {
674674
Ok(flags)
675675
}
676676

677-
fn prepare_decorators(&mut self, decorator_list: &Vec<ast::Expression>) -> Result<(), String> {
677+
fn prepare_decorators(&mut self, decorator_list: &[ast::Expression]) -> Result<(), String> {
678678
for decorator in decorator_list {
679679
self.compile_expression(decorator)?;
680680
}
681681
Ok(())
682682
}
683683

684-
fn apply_decorators(&mut self, decorator_list: &Vec<ast::Expression>) {
684+
fn apply_decorators(&mut self, decorator_list: &[ast::Expression]) {
685685
// Apply decorators:
686686
for _ in decorator_list {
687687
self.emit(Instruction::CallFunction {
@@ -1036,8 +1036,8 @@ impl Compiler {
10361036
fn compile_call(
10371037
&mut self,
10381038
function: &ast::Expression,
1039-
args: &Vec<ast::Expression>,
1040-
keywords: &Vec<ast::Keyword>,
1039+
args: &[ast::Expression],
1040+
keywords: &[ast::Keyword],
10411041
) -> Result<(), String> {
10421042
self.compile_expression(function)?;
10431043
let count = args.len() + keywords.len();
@@ -1123,7 +1123,7 @@ impl Compiler {
11231123

11241124
// Given a vector of expr / star expr generate code which gives either
11251125
// a list of expressions on the stack, or a list of tuples.
1126-
fn gather_elements(&mut self, elements: &Vec<ast::Expression>) -> Result<bool, String> {
1126+
fn gather_elements(&mut self, elements: &[ast::Expression]) -> Result<bool, String> {
11271127
// First determine if we have starred elements:
11281128
let has_stars = elements.iter().any(|e| {
11291129
if let ast::Expression::Starred { .. } = e {
@@ -1153,7 +1153,7 @@ impl Compiler {
11531153
fn compile_comprehension(
11541154
&mut self,
11551155
kind: &ast::ComprehensionKind,
1156-
generators: &Vec<ast::Comprehension>,
1156+
generators: &[ast::Comprehension],
11571157
) -> Result<(), String> {
11581158
// We must have at least one generator:
11591159
assert!(!generators.is_empty());

vm/src/obj/objsequence.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ pub fn get_item(
109109

110110
pub fn seq_equal(
111111
vm: &mut VirtualMachine,
112-
zelf: &Vec<PyObjectRef>,
113-
other: &Vec<PyObjectRef>,
112+
zelf: &[PyObjectRef],
113+
other: &[PyObjectRef],
114114
) -> Result<bool, PyObjectRef> {
115115
if zelf.len() == other.len() {
116116
for (a, b) in Iterator::zip(zelf.iter(), other.iter()) {
@@ -128,8 +128,8 @@ pub fn seq_equal(
128128

129129
pub fn seq_lt(
130130
vm: &mut VirtualMachine,
131-
zelf: &Vec<PyObjectRef>,
132-
other: &Vec<PyObjectRef>,
131+
zelf: &[PyObjectRef],
132+
other: &[PyObjectRef],
133133
) -> Result<bool, PyObjectRef> {
134134
if zelf.len() == other.len() {
135135
for (a, b) in Iterator::zip(zelf.iter(), other.iter()) {
@@ -168,8 +168,8 @@ pub fn seq_lt(
168168

169169
pub fn seq_gt(
170170
vm: &mut VirtualMachine,
171-
zelf: &Vec<PyObjectRef>,
172-
other: &Vec<PyObjectRef>,
171+
zelf: &[PyObjectRef],
172+
other: &[PyObjectRef],
173173
) -> Result<bool, PyObjectRef> {
174174
if zelf.len() == other.len() {
175175
for (a, b) in Iterator::zip(zelf.iter(), other.iter()) {
@@ -207,29 +207,29 @@ pub fn seq_gt(
207207

208208
pub fn seq_ge(
209209
vm: &mut VirtualMachine,
210-
zelf: &Vec<PyObjectRef>,
211-
other: &Vec<PyObjectRef>,
210+
zelf: &[PyObjectRef],
211+
other: &[PyObjectRef],
212212
) -> Result<bool, PyObjectRef> {
213213
Ok(seq_gt(vm, zelf, other)? || seq_equal(vm, zelf, other)?)
214214
}
215215

216216
pub fn seq_le(
217217
vm: &mut VirtualMachine,
218-
zelf: &Vec<PyObjectRef>,
219-
other: &Vec<PyObjectRef>,
218+
zelf: &[PyObjectRef],
219+
other: &[PyObjectRef],
220220
) -> Result<bool, PyObjectRef> {
221221
Ok(seq_lt(vm, zelf, other)? || seq_equal(vm, zelf, other)?)
222222
}
223223

224-
pub fn seq_mul(elements: &Vec<PyObjectRef>, product: &PyObjectRef) -> Vec<PyObjectRef> {
224+
pub fn seq_mul(elements: &[PyObjectRef], product: &PyObjectRef) -> Vec<PyObjectRef> {
225225
let counter = objint::get_value(&product).to_isize().unwrap();
226226

227227
let current_len = elements.len();
228228
let new_len = counter.max(0) as usize * current_len;
229229
let mut new_elements = Vec::with_capacity(new_len);
230230

231231
for _ in 0..counter {
232-
new_elements.extend(elements.clone());
232+
new_elements.extend(elements.clone().to_owned());
233233
}
234234

235235
new_elements

vm/src/obj/objset.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub fn get_elements(obj: &PyObjectRef) -> HashMap<usize, PyObjectRef> {
2222
}
2323
}
2424

25-
pub fn sequence_to_hashmap(iterable: &Vec<PyObjectRef>) -> HashMap<usize, PyObjectRef> {
25+
pub fn sequence_to_hashmap(iterable: &[PyObjectRef]) -> HashMap<usize, PyObjectRef> {
2626
let mut elements = HashMap::new();
2727
for item in iterable {
2828
let key = item.get_id();

vm/src/obj/objstr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,9 @@ fn str_format(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
238238
fn call_object_format(
239239
vm: &mut VirtualMachine,
240240
argument: PyObjectRef,
241-
format_spec: &String,
241+
format_spec: &str,
242242
) -> PyResult {
243-
let returned_type = vm.ctx.new_str(format_spec.clone());
243+
let returned_type = vm.ctx.new_str(format_spec.to_string());
244244
let result = vm.call_method(&argument, "__format__", vec![returned_type])?;
245245
if !objtype::isinstance(&result, &vm.ctx.str_type()) {
246246
let result_type = result.typ();

vm/src/stdlib/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ fn statement_to_ast(ctx: &PyContext, statement: &ast::LocatedStatement) -> PyObj
238238
node
239239
}
240240

241-
fn expressions_to_ast(ctx: &PyContext, expressions: &Vec<ast::Expression>) -> PyObjectRef {
241+
fn expressions_to_ast(ctx: &PyContext, expressions: &[ast::Expression]) -> PyObjectRef {
242242
let mut py_expression_nodes = vec![];
243243
for expression in expressions {
244244
py_expression_nodes.push(expression_to_ast(ctx, expression));

vm/src/stdlib/io.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use super::super::pyobject::{
2626

2727
use super::super::vm::VirtualMachine;
2828

29-
fn compute_c_flag(mode: &String) -> u16 {
29+
fn compute_c_flag(mode: &str) -> u16 {
3030
match mode.as_ref() {
3131
"w" => 512,
3232
"x" => 512,

0 commit comments

Comments
 (0)