Clippy compliance for the last batch of commits.

This commit is contained in:
David Wendt 2020-07-02 21:11:10 -04:00
parent 041cb0b5c3
commit 12fc13da7f
6 changed files with 19 additions and 18 deletions

View File

@ -98,7 +98,7 @@ impl<'gc> Activation<'gc> {
script: GcCell<'gc, Script<'gc>>,
global: Object<'gc>,
) -> Result<Self, Error> {
let method = script.read().init().as_entry()?;
let method = script.read().init().into_entry()?;
let scope = Some(Scope::push_scope(None, global, context.gc_context));
let num_locals = method.body().num_locals;
let local_registers =

View File

@ -164,13 +164,13 @@ impl<'gc> Class<'gc> {
let abc_class: Result<&AbcClass, Error> = abc
.classes
.get(class_index as usize)
.ok_or("LoadError: Class index not valid".into());
.ok_or_else(|| "LoadError: Class index not valid".into());
let abc_class = abc_class?;
let abc_instance: Result<&AbcInstance, Error> = abc
.instances
.get(class_index as usize)
.ok_or("LoadError: Instance index not valid".into());
.ok_or_else(|| "LoadError: Instance index not valid".into());
let abc_instance = abc_instance?;
let name = QName::from_abc_multiname(&unit.abc(), abc_instance.name.clone())?;

View File

@ -89,7 +89,7 @@ impl<'gc> Avm2MethodEntry<'gc> {
/// Get the underlying ABC file.
#[allow(dead_code)]
pub fn abc(&self) -> Rc<AbcFile> {
self.txunit.abc().clone()
self.txunit.abc()
}
/// Get the underlying translation unit this method was defined in.
@ -158,7 +158,7 @@ impl<'gc> From<Avm2MethodEntry<'gc>> for Method<'gc> {
}
impl<'gc> Method<'gc> {
pub fn as_entry(self) -> Result<Avm2MethodEntry<'gc>, Error> {
pub fn into_entry(self) -> Result<Avm2MethodEntry<'gc>, Error> {
match self {
Method::Native(_) => {
Err("Attempted to unwrap a native method as a user-defined one".into())
@ -273,7 +273,7 @@ impl<'gc> Executable<'gc> {
Activation::from_action(
context,
method.clone(),
scope.clone(),
*scope,
reciever,
arguments,
base_proto,
@ -368,9 +368,9 @@ impl<'gc> FunctionObject<'gc> {
FunctionObjectData {
base: ScriptObjectData::base_new(
Some(fn_proto),
ScriptObjectClass::ClassConstructor(class.clone(), scope),
ScriptObjectClass::ClassConstructor(class, scope),
),
exec: Some(Executable::from_method(initializer, scope, None).into()),
exec: Some(Executable::from_method(initializer, scope, None)),
},
))
.into();

View File

@ -198,7 +198,7 @@ impl Multiname {
) -> Result<Self, Error> {
let actual_index: Result<usize, Error> = (multiname_index.0 as usize)
.checked_sub(1)
.ok_or("Attempted to resolve a multiname at index zero. This is a bug.".into());
.ok_or_else(|| "Attempted to resolve a multiname at index zero. This is a bug.".into());
let actual_index = actual_index?;
let abc_multiname: Result<&AbcMultiname, Error> = file
.constant_pool
@ -258,9 +258,10 @@ impl Multiname {
file: &AbcFile,
multiname_index: Index<AbcMultiname>,
) -> Result<Self, Error> {
let actual_index: Result<usize, Error> = (multiname_index.0 as usize).checked_sub(1).ok_or(
"Attempted to resolve a (static) multiname at index zero. This is a bug.".into(),
);
let actual_index: Result<usize, Error> =
(multiname_index.0 as usize).checked_sub(1).ok_or_else(|| {
"Attempted to resolve a (static) multiname at index zero. This is a bug.".into()
});
let actual_index = actual_index?;
let abc_multiname: Result<&AbcMultiname, Error> = file
.constant_pool

View File

@ -485,7 +485,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
//then?
let super_name = if let Some(sc_name) = class_read.super_class_name() {
self.resolve_multiname(sc_name)?
.unwrap_or(QName::dynamic_name("Object"))
.unwrap_or_else(|| QName::dynamic_name("Object"))
} else {
QName::dynamic_name("Object")
};

View File

@ -87,7 +87,7 @@ impl<'gc> TranslationUnit<'gc> {
.methods
.insert(method_index, method.clone());
return Ok(method);
Ok(method)
}
/// Load a class from the ABC file and return it's class definition.
@ -98,7 +98,7 @@ impl<'gc> TranslationUnit<'gc> {
) -> Result<GcCell<'gc, Class<'gc>>, Error> {
let write = self.0.write(mc);
if let Some(class) = write.classes.get(&class_index) {
return Ok(class.clone());
return Ok(*class);
}
drop(write);
@ -108,7 +108,7 @@ impl<'gc> TranslationUnit<'gc> {
class.write(mc).load_traits(self, class_index, mc)?;
return Ok(class);
Ok(class)
}
/// Load a script from the ABC file and return it's script definition.
@ -119,7 +119,7 @@ impl<'gc> TranslationUnit<'gc> {
) -> Result<GcCell<'gc, Script<'gc>>, Error> {
let write = self.0.write(mc);
if let Some(scripts) = write.scripts.get(&script_index) {
return Ok(scripts.clone());
return Ok(*scripts);
}
drop(write);
@ -129,7 +129,7 @@ impl<'gc> TranslationUnit<'gc> {
script.write(mc).load_traits(self, script_index, mc)?;
return Ok(script);
Ok(script)
}
}