Skip to content

Commit 6030212

Browse files
committed
Update toolchain
1 parent f810b4f commit 6030212

File tree

9 files changed

+33
-30
lines changed

9 files changed

+33
-30
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ members = ["jdk-tools"]
44
[package]
55
name = "rusty-java"
66
version = "0.1.0"
7-
edition = "2021"
7+
edition = "2024"
88

99
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1010

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2024-07-25"
2+
channel = "nightly-2025-12-12"
33
components = ["rustfmt", "clippy"]

src/call_frame.rs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ use std::mem;
44
use std::ptr::NonNull;
55
use std::time::SystemTime;
66

7-
use color_eyre::eyre::{self, bail, eyre, ContextCompat};
7+
use color_eyre::eyre::{self, ContextCompat, bail, eyre};
88
use strum::EnumTryAs;
99

1010
use crate::class::{Class, Method};
11-
use crate::class_file::constant_pool::{self, ConstantInfo};
1211
use crate::class_file::MethodAccessFlags;
12+
use crate::class_file::constant_pool::{self, ConstantInfo};
1313
use crate::descriptor::{BaseType, FieldType};
1414
use crate::instructions::{
1515
ArrayLoadStoreType, ArrayType, Condition, Instruction, InvokeKind, LoadStoreType, NumberType,
@@ -79,23 +79,26 @@ impl RefTypeHeader {
7979
Ok(unsafe { std::slice::from_raw_parts_mut(data_ptr, length) })
8080
}
8181

82-
unsafe fn object_data<'a>(&mut self) -> eyre::Result<&'a mut [JvmValue]> {
83-
let target_class = match self {
84-
Self::Object(object) => object.class,
85-
Self::Array(_) => bail!("expected an object"),
86-
};
82+
unsafe fn object_data<'a>(&mut self) -> eyre::Result<&'a mut [JvmValue<'_>]> {
83+
unsafe {
84+
let target_class = match self {
85+
Self::Object(object) => object.class,
86+
Self::Array(_) => bail!("expected an object"),
87+
};
8788

88-
let fields_layout = Layout::array::<JvmValue>((*target_class.as_ptr()).fields().len())?;
89-
let (object_layout, _) = Layout::new::<RefTypeHeader>().extend(fields_layout)?;
89+
let fields_layout = Layout::array::<JvmValue>((*target_class.as_ptr()).fields().len())?;
90+
let (object_layout, _) = Layout::new::<RefTypeHeader>().extend(fields_layout)?;
9091

91-
let offset = object_layout.size() - fields_layout.size();
92+
let offset = object_layout.size() - fields_layout.size();
9293

93-
let header_ptr = self as *mut RefTypeHeader;
94-
let data_ptr = (header_ptr as usize + offset) as *mut JvmValue;
94+
let header_ptr = self as *mut RefTypeHeader;
95+
let data_ptr = (header_ptr as usize + offset) as *mut JvmValue;
9596

96-
Ok(unsafe {
97-
std::slice::from_raw_parts_mut(data_ptr, (*target_class.as_ptr()).fields().len())
98-
})
97+
Ok(std::slice::from_raw_parts_mut(
98+
data_ptr,
99+
(*target_class.as_ptr()).fields().len(),
100+
))
101+
}
99102
}
100103
}
101104

@@ -162,7 +165,7 @@ impl<'a, 'b> CallFrame<'a, 'b> {
162165
ReturnType::Int => {
163166
return Ok(Some(
164167
self.operand_stack.pop().wrap_err("missing return value")?,
165-
))
168+
));
166169
}
167170
ReturnType::Long => todo!(),
168171
ReturnType::Float => todo!(),

src/class.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ use std::io::{self, Cursor};
44
use std::num::NonZeroU8;
55

66
use bumpalo::collections::Vec;
7-
use bumpalo::{vec, Bump};
7+
use bumpalo::{Bump, vec};
88
use byteorder::{BigEndian, ReadBytesExt};
9-
use color_eyre::eyre::{self, bail, eyre, Context, ContextCompat};
9+
use color_eyre::eyre::{self, Context, ContextCompat, bail, eyre};
1010
use hashbrown::HashMap;
1111

1212
use crate::call_frame::JvmValue;
1313
use crate::class_file::constant_pool::ConstantPool;
1414
use crate::class_file::{ClassFile, FieldAccessFlags, MethodAccessFlags};
1515
use crate::descriptor::{
16-
parse_field_descriptor, parse_method_descriptor, BaseType, FieldDescriptor, FieldType,
17-
MethodDescriptor,
16+
BaseType, FieldDescriptor, FieldType, MethodDescriptor, parse_field_descriptor,
17+
parse_method_descriptor,
1818
};
1919
use crate::instructions::{
2020
ArrayLoadStoreType, ArrayType, Condition, EqCondition, Instruction, IntegerType, InvokeKind,
@@ -217,7 +217,7 @@ impl<'a> Class<'a> {
217217
self.methods.get(&MethodId { name, descriptor })
218218
}
219219

220-
pub fn constant_pool(&self) -> &'a ConstantPool {
220+
pub fn constant_pool(&self) -> &'a ConstantPool<'_> {
221221
&self.class_file.constant_pool
222222
}
223223

src/class_file.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub mod constant_pool {
2727
pub struct ConstantPool<'a>(pub(crate) bumpalo::collections::Vec<'a, ConstantInfo<'a>>);
2828

2929
impl<'a> ConstantPool<'a> {
30-
pub fn get(&self, index: u16) -> Option<&ConstantInfo> {
30+
pub fn get(&self, index: u16) -> Option<&ConstantInfo<'_>> {
3131
self.0.get(index.checked_sub(1)? as usize)
3232
}
3333
}

src/descriptor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub struct MethodDescriptor<'a> {
3333
pub return_type: Option<FieldType<'a>>,
3434
}
3535

36-
pub fn parse_method_descriptor(descriptor: &str) -> eyre::Result<MethodDescriptor> {
36+
pub fn parse_method_descriptor(descriptor: &str) -> eyre::Result<MethodDescriptor<'_>> {
3737
let (params, return_type) = (parse_params_types, parse_return_type)
3838
.parse(descriptor)
3939
.map_err(|e| eyre!("{e}"))?;
@@ -44,7 +44,7 @@ pub fn parse_method_descriptor(descriptor: &str) -> eyre::Result<MethodDescripto
4444
})
4545
}
4646

47-
pub fn parse_field_descriptor(descriptor: &str) -> eyre::Result<FieldDescriptor> {
47+
pub fn parse_field_descriptor(descriptor: &str) -> eyre::Result<FieldDescriptor<'_>> {
4848
let field_type = parse_field_type
4949
.parse(descriptor)
5050
.map_err(|e| eyre!("{e}"))?;

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(cursor_remaining, let_chains, macro_metavar_expr)]
1+
#![feature(macro_metavar_expr)]
22

33
pub mod call_frame;
44
pub mod class;

src/reader.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use std::io;
22

33
use bumpalo::collections::{CollectIn, String, Vec};
4-
use bumpalo::{vec, Bump};
4+
use bumpalo::{Bump, vec};
55
use byteorder::{BigEndian, ReadBytesExt};
6-
use color_eyre::eyre::{self, bail, eyre, Context};
6+
use color_eyre::eyre::{self, Context, bail, eyre};
77

88
use crate::class_file::constant_pool::{self, ConstantInfo, ConstantPool};
99
use crate::class_file::{

src/vm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::path::Path;
66
use std::time::SystemTime;
77

88
use bumpalo::Bump;
9-
use color_eyre::eyre::{self, eyre, Context};
9+
use color_eyre::eyre::{self, Context, eyre};
1010

1111
use crate::call_frame::CallFrame;
1212
use crate::class::{Class, Method};

0 commit comments

Comments
 (0)