Skip to content

Commit dfe2cd4

Browse files
Merge pull request #540 from theseus-rs/correct-lints
chore: correct lint errors
2 parents 8dd4276 + 10bd72c commit dfe2cd4

File tree

10 files changed

+33
-27
lines changed

10 files changed

+33
-27
lines changed

ristretto_vm/src/build/intrinsics.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ fn write_intrinsic_method_map(
273273
map_builder.entry(signature, function);
274274
}
275275
writeln!(file)?;
276+
writeln!(file, "#[deny(clippy::large_stack_arrays)]")?;
276277
writeln!(file, "#[expect(clippy::unreadable_literal)]")?;
277278
let intrinsic_method_signature = "IntrinsicMethod";
278279
writeln!(

ristretto_vm/src/call_site_cache.rs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -127,23 +127,22 @@ impl CallSiteCache {
127127
);
128128

129129
// Update cache based on result
130-
match &result {
131-
Ok(value) => {
132-
// Store successful resolution
133-
let mut map = self.states.write().map_err(|error| {
134-
PoisonedLock(format!("Failed to acquire cache lock: {error}"))
135-
})?;
136-
debug!("CallSiteCache: Caching successful result for key: {key:?}",);
137-
map.insert(key, CallSiteState::Resolved(value.clone()));
138-
}
139-
Err(_) => {
140-
// Remove in-progress marker on failure to allow retry
141-
let mut map = self.states.write().map_err(|error| {
142-
PoisonedLock(format!("Failed to acquire cache lock: {error}"))
143-
})?;
144-
debug!("CallSiteCache: Removing failed resolution from cache for key: {key:?}");
145-
map.remove(&key);
146-
}
130+
if let Ok(value) = &result {
131+
// Store successful resolution
132+
let mut map = self
133+
.states
134+
.write()
135+
.map_err(|error| PoisonedLock(format!("Failed to acquire cache lock: {error}")))?;
136+
debug!("CallSiteCache: Caching successful result for key: {key:?}",);
137+
map.insert(key, CallSiteState::Resolved(value.clone()));
138+
} else {
139+
// Remove in-progress marker on failure to allow retry
140+
let mut map = self
141+
.states
142+
.write()
143+
.map_err(|error| PoisonedLock(format!("Failed to acquire cache lock: {error}")))?;
144+
debug!("CallSiteCache: Removing failed resolution from cache for key: {key:?}");
145+
map.remove(&key);
147146
}
148147

149148
result

ristretto_vm/src/instruction/invokeinterface.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pub(crate) async fn invokeinterface(
6868

6969
// Find the method implementation
7070
let (resolved_class, resolved_method) =
71-
resolve_method(object_class, method_name, method_descriptor)?;
71+
resolve_method(&object_class, method_name, method_descriptor)?;
7272

7373
// Check resolved method accessibility
7474
if !resolved_method.is_public() {

ristretto_vm/src/instruction/invokespecial.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ pub(crate) async fn invokespecial(
3232
constant_pool.try_get_name_and_type(*name_and_type_index)?;
3333
let method_name = constant_pool.try_get_utf8(*name_index)?;
3434
let method_descriptor = constant_pool.try_get_utf8(*descriptor_index)?;
35-
let (resolved_class, resolved_method) =
36-
resolve_method(class.clone(), method_name, method_descriptor)?;
35+
let (resolved_class, resolved_method) = resolve_method(&class, method_name, method_descriptor)?;
3736

3837
let parameters = stack.drain_last(resolved_method.parameters().len() + 1);
3938
let result = thread

ristretto_vm/src/instruction/invokevirtual.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub(crate) async fn invokevirtual(
2323
constant_pool.try_get_name_and_type(*name_and_type_index)?;
2424
let method_name = constant_pool.try_get_utf8(*name_index)?;
2525
let method_descriptor = constant_pool.try_get_utf8(*descriptor_index)?;
26-
let (resolved_class, resolved_method) = resolve_method(class, method_name, method_descriptor)?;
26+
let (resolved_class, resolved_method) = resolve_method(&class, method_name, method_descriptor)?;
2727

2828
let parameters = stack.drain_last(resolved_method.parameters().len() + 1);
2929
let reference = match parameters.first() {
@@ -39,7 +39,7 @@ pub(crate) async fn invokevirtual(
3939
} else {
4040
let class_name = reference.class_name()?;
4141
let object_class = thread.class(class_name).await?;
42-
resolve_method(object_class, method_name, method_descriptor)?
42+
resolve_method(&object_class, method_name, method_descriptor)?
4343
};
4444

4545
let result = thread.execute(&class, &method, &parameters).await?;
@@ -55,7 +55,7 @@ pub(crate) async fn invokevirtual(
5555
///
5656
/// if the method is not found.
5757
pub(crate) fn resolve_method(
58-
class: Arc<Class>,
58+
class: &Arc<Class>,
5959
name: &str,
6060
descriptor: &str,
6161
) -> Result<(Arc<Class>, Arc<Method>)> {

ristretto_vm/src/intrinsic_methods/intrinsics.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! This file is automatically generated by build.rs. Do not edit manually.
22
use crate::intrinsic_methods::IntrinsicMethod;
33

4+
#[deny(clippy::large_stack_arrays)]
45
#[expect(clippy::unreadable_literal)]
56
pub(crate) static JAVA_8: phf::Map<&'static str, IntrinsicMethod> = ::phf::Map {
67
key: 16287231350648472473,
@@ -1983,6 +1984,7 @@ pub(crate) static JAVA_8: phf::Map<&'static str, IntrinsicMethod> = ::phf::Map {
19831984
],
19841985
};
19851986

1987+
#[deny(clippy::large_stack_arrays)]
19861988
#[expect(clippy::unreadable_literal)]
19871989
pub(crate) static JAVA_11: phf::Map<&'static str, IntrinsicMethod> = ::phf::Map {
19881990
key: 16287231350648472473,
@@ -3983,6 +3985,7 @@ pub(crate) static JAVA_11: phf::Map<&'static str, IntrinsicMethod> = ::phf::Map
39833985
],
39843986
};
39853987

3988+
#[deny(clippy::large_stack_arrays)]
39863989
#[expect(clippy::unreadable_literal)]
39873990
pub(crate) static JAVA_17: phf::Map<&'static str, IntrinsicMethod> = ::phf::Map {
39883991
key: 16287231350648472473,
@@ -6072,6 +6075,7 @@ pub(crate) static JAVA_17: phf::Map<&'static str, IntrinsicMethod> = ::phf::Map
60726075
],
60736076
};
60746077

6078+
#[deny(clippy::large_stack_arrays)]
60756079
#[expect(clippy::unreadable_literal)]
60766080
pub(crate) static JAVA_21: phf::Map<&'static str, IntrinsicMethod> = ::phf::Map {
60776081
key: 16287231350648472473,
@@ -8150,6 +8154,7 @@ pub(crate) static JAVA_21: phf::Map<&'static str, IntrinsicMethod> = ::phf::Map
81508154
],
81518155
};
81528156

8157+
#[deny(clippy::large_stack_arrays)]
81538158
#[expect(clippy::unreadable_literal)]
81548159
pub(crate) static JAVA_24: phf::Map<&'static str, IntrinsicMethod> = ::phf::Map {
81558160
key: 16287231350648472473,

ristretto_vm/src/intrinsic_methods/java/io/randomaccessfile.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ pub(crate) async fn length_0(
141141

142142
#[intrinsic_method("java/io/RandomAccessFile.open0(Ljava/lang/String;I)V", Any)]
143143
#[async_recursion(?Send)]
144+
#[expect(clippy::too_many_lines)]
144145
pub(crate) async fn open_0(
145146
thread: Arc<Thread>,
146147
mut parameters: Parameters,

ristretto_vm/src/intrinsic_methods/java/lang/class.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,7 @@ mod tests {
12821282
};
12831283
assert_eq!(class.name(), "[Ljava/lang/reflect/Field;");
12841284
let mut signatures = Vec::new();
1285-
for reference in references.into_iter() {
1285+
for reference in references {
12861286
let value = Value::from(reference);
12871287
let result = vm
12881288
.invoke(
@@ -1333,7 +1333,7 @@ mod tests {
13331333
};
13341334
assert_eq!(class.name(), "[Ljava/lang/reflect/Method;");
13351335
let mut method_names = Vec::new();
1336-
for reference in references.into_iter() {
1336+
for reference in references {
13371337
let value = Value::from(reference);
13381338
let result = vm
13391339
.invoke(

ristretto_vm/src/intrinsic_methods/java/lang/invoke/methodhandlenatives.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ pub(crate) async fn register_natives(
200200
Ok(None)
201201
}
202202

203+
#[expect(clippy::too_many_lines)]
203204
pub(crate) async fn resolve(
204205
thread: Arc<Thread>,
205206
member_self: Value,

ristretto_vm/src/intrinsic_methods/java/lang/reflect/array.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use ristretto_classloader::{Reference, Value};
1010
use ristretto_macros::intrinsic_method;
1111
use std::sync::Arc;
1212

13-
fn get_class_name(value: Value) -> Result<String> {
13+
fn get_class_name(value: &Value) -> Result<String> {
1414
let component_type = value.as_object_ref()?;
1515
let class_name = component_type.value("name")?.as_string()?;
1616
Ok(class_name)
@@ -457,7 +457,7 @@ pub(crate) async fn new_array(
457457
mut parameters: Parameters,
458458
) -> Result<Option<Value>> {
459459
let length = usize::try_from(parameters.pop_int()?)?;
460-
let class_name = get_class_name(parameters.pop()?)?;
460+
let class_name = get_class_name(&parameters.pop()?)?;
461461

462462
let array = match class_name.as_str() {
463463
"boolean" | "byte" => Value::from(vec![0i8; length]),

0 commit comments

Comments
 (0)