Skip to content

Commit 7ab95fd

Browse files
committed
fix more
1 parent cccd1bd commit 7ab95fd

7 files changed

Lines changed: 11 additions & 11 deletions

File tree

benches/execution.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fn bench_rustpython_code(b: &mut Bencher, name: &str, source: &str) {
3030
// Note: bench_cpython is both compiling and executing the code.
3131
// As such we compile the code in the benchmark loop as well.
3232
b.iter(|| {
33-
let code = vm.compile(source, Mode::Exec, name.to_owned()).unwrap();
33+
let code = vm.compile(source, Mode::Exec, name).unwrap();
3434
let scope = vm.new_scope_with_builtins();
3535
let res: PyResult = vm.run_code_obj(code.clone(), scope);
3636
vm.unwrap_pyresult(res);

benches/microbenchmarks.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ fn bench_rustpython_code(group: &mut BenchmarkGroup<WallTime>, bench: &MicroBenc
118118
let interp = builder.add_native_modules(&defs).build();
119119
interp.enter(|vm| {
120120
let setup_code = vm
121-
.compile(&bench.setup, Mode::Exec, bench.name.to_owned())
121+
.compile(&bench.setup, Mode::Exec, &bench.name)
122122
.expect("Error compiling setup code");
123123
let bench_code = vm
124-
.compile(&bench.code, Mode::Exec, bench.name.to_owned())
124+
.compile(&bench.code, Mode::Exec, &bench.name)
125125
.expect("Error compiling bench code");
126126

127127
let bench_func = |scope| {

crates/stdlib/src/_opcode.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ mod tests {
192192
///
193193
/// Memory addresses in the output are replaced with `0xdeadbeef` for consistency.
194194
fn dis(source: &str) -> String {
195-
let fname = String::from("<?>");
195+
const FNAME: &str = "<?>";
196196

197197
let builder = vm::Interpreter::builder(Default::default());
198198
let stdlib_defs = crate::stdlib_module_defs(&builder.ctx);
@@ -204,7 +204,7 @@ mod tests {
204204
interp.enter(|vm| {
205205
let scope = vm.new_scope_with_builtins();
206206
let code_obj = vm
207-
.compile(source.trim(), Mode::Exec, fname.clone())
207+
.compile(source.trim(), Mode::Exec, FNAME)
208208
.map_err(|err| vm.new_syntax_error(&err, Some(source)))
209209
.unwrap();
210210
scope.globals.set_item("code", code_obj.into(), vm).unwrap();
@@ -227,7 +227,7 @@ output = re.sub(r'(<code object \w+ at )0x[0-9a-fA-F]+', r'\g<1>0xdeadbeef', tmp
227227
"#;
228228

229229
let py_code_obj = vm
230-
.compile(py_source, Mode::Exec, fname)
230+
.compile(py_source, Mode::Exec, FNAME)
231231
.map_err(|err| vm.new_syntax_error(&err, Some(py_source)))
232232
.unwrap();
233233

crates/vm/src/vm/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ impl Context {
699699
where
700700
F: IntoPyGetterFunc<T>,
701701
{
702-
let getset = PyGetSet::new(&name, class).with_get(f);
702+
let getset = PyGetSet::new(name, class).with_get(f);
703703
PyRef::new_ref(getset, self.types.getset_type.to_owned(), None)
704704
}
705705

@@ -714,7 +714,7 @@ impl Context {
714714
G: IntoPyGetterFunc<T>,
715715
S: IntoPySetterFunc<U>,
716716
{
717-
let getset = PyGetSet::new(&name, class).with_get(g).with_set(s);
717+
let getset = PyGetSet::new(name, class).with_get(g).with_set(s);
718718
PyRef::new_ref(getset, self.types.getset_type.to_owned(), None)
719719
}
720720

crates/vm/src/vm/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2285,7 +2285,7 @@ mod tests {
22852285

22862286
let source = "from dir_module.dir_module_inner import value2";
22872287
let code_obj = vm
2288-
.compile(source, vm::compiler::Mode::Exec, "<embedded>".to_owned())
2288+
.compile(source, vm::compiler::Mode::Exec, "<embedded>")
22892289
.map_err(|err| vm.new_syntax_error(&err, Some(source)))
22902290
.unwrap();
22912291

examples/hello_embed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ fn main() -> vm::PyResult<()> {
55
let scope = vm.new_scope_with_builtins();
66
let source = r#"print("Hello World!")"#;
77
let code_obj = vm
8-
.compile(source, vm::compiler::Mode::Exec, "<embedded>".to_owned())
8+
.compile(source, vm::compiler::Mode::Exec, "<embedded>")
99
.map_err(|err| vm.new_syntax_error(&err, Some(source)))?;
1010

1111
vm.run_code_obj(code_obj, scope)?;

examples/mini_repl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def fib(n):
6565
// this line also automatically prints the output
6666
// (note that this is only the case when compiler::Mode::Single is passed to vm.compile)
6767
match vm
68-
.compile(&input, vm::compiler::Mode::Single, "<embedded>".to_owned())
68+
.compile(&input, vm::compiler::Mode::Single, "<embedded>")
6969
.map_err(|err| vm.new_syntax_error(&err, Some(&input)))
7070
.and_then(|code_obj| vm.run_code_obj(code_obj, scope.clone()))
7171
{

0 commit comments

Comments
 (0)