From eecb097ae6b6b7c515835d99b08c13cd813181bf Mon Sep 17 00:00:00 2001 From: Noah <33094578+coolreader18@users.noreply.github.com> Date: Fri, 13 Mar 2020 20:57:44 -0500 Subject: [PATCH] Make bytecode::Location Copy --- bytecode/src/bytecode.rs | 2 +- compiler/src/peephole.rs | 2 +- vm/src/frame.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bytecode/src/bytecode.rs b/bytecode/src/bytecode.rs index 0a4676288..18ae446d9 100644 --- a/bytecode/src/bytecode.rs +++ b/bytecode/src/bytecode.rs @@ -9,7 +9,7 @@ use std::collections::{HashMap, HashSet}; use std::fmt; /// Sourcode location. -#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize)] pub struct Location { row: usize, column: usize, diff --git a/compiler/src/peephole.rs b/compiler/src/peephole.rs index 3a64380bd..b85266867 100644 --- a/compiler/src/peephole.rs +++ b/compiler/src/peephole.rs @@ -15,7 +15,7 @@ impl From> for InstructionMetadata { fn from(metas: Vec) -> Self { debug_assert!(!metas.is_empty(), "`metas` must not be empty"); InstructionMetadata { - loc: metas[0].loc.clone(), + loc: metas[0].loc, labels: metas .into_iter() .flat_map(|meta| meta.labels.into_iter()) diff --git a/vm/src/frame.rs b/vm/src/frame.rs index 681d5b2d4..21c54277a 100644 --- a/vm/src/frame.rs +++ b/vm/src/frame.rs @@ -1348,7 +1348,7 @@ impl Frame { } pub fn get_lineno(&self) -> bytecode::Location { - self.code.locations[self.lasti.get()].clone() + self.code.locations[self.lasti.get()] } fn push_block(&self, typ: BlockType) {