Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feat/rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Wodann committed Feb 20, 2024
2 parents 5ecedb0 + 8e449e8 commit 7f4c836
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 30 deletions.
4 changes: 1 addition & 3 deletions crates/mun_abi/src/type_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,7 @@ impl<'a> TypeDefinition<'a> {

/// Returns the alignment of the type in bytes
pub fn alignment(&self) -> usize {
self.alignment
.try_into()
.expect("cannot convert alignment to platform size")
self.alignment.into()
}
}

Expand Down
4 changes: 1 addition & 3 deletions crates/mun_hir/src/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,7 @@ impl<T> Arena<T> {
}

/// Iterate over the elements in the arena
pub fn iter(
&self,
) -> impl Iterator<Item = (Idx<T>, &T)> + ExactSizeIterator + DoubleEndedIterator {
pub fn iter(&self) -> impl ExactSizeIterator<Item = (Idx<T>, &T)> + DoubleEndedIterator {
self.data
.iter()
.enumerate()
Expand Down
4 changes: 2 additions & 2 deletions crates/mun_hir/src/code_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ pub use self::{
function::{Function, FunctionData},
module::{Module, ModuleDef},
package::Package,
r#impl::{Impl, ImplData},
r#struct::{Field, FieldData, LocalFieldId, Struct, StructData, StructKind, StructMemoryKind},
r#impl::ImplData,
r#struct::{Field, Struct, StructData, StructKind, StructMemoryKind},
src::HasSource,
type_alias::{TypeAlias, TypeAliasData},
};
Expand Down
4 changes: 2 additions & 2 deletions crates/mun_hir/src/item_scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ impl ItemScope {
}

/// Returns an iterator over all declarations with this scope
pub fn declarations(&self) -> impl Iterator<Item = ItemDefinitionId> + ExactSizeIterator + '_ {
pub fn declarations(&self) -> impl ExactSizeIterator<Item = ItemDefinitionId> + '_ {
self.defs.iter().copied()
}

/// Returns an iterator over all impls in this scope
pub fn impls(&self) -> impl Iterator<Item = ImplId> + ExactSizeIterator + '_ {
pub fn impls(&self) -> impl ExactSizeIterator<Item = ImplId> + '_ {
self.impls.iter().copied()
}

Expand Down
2 changes: 0 additions & 2 deletions crates/mun_hir/src/ty/infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ mod place_expr;
mod type_variable;
mod unify;

pub use type_variable::TypeVarId;

use crate::{
expr::{LiteralFloat, LiteralFloatKind, LiteralInt, LiteralIntKind},
ids::DefWithBodyId,
Expand Down
2 changes: 1 addition & 1 deletion crates/mun_runtime/src/dispatch_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl DispatchTable {
/// Retrieves the [`FunctionDefinition`] corresponding to `fn_path`, if it
/// exists.
pub fn get_fn(&self, fn_path: &str) -> Option<Arc<FunctionDefinition>> {
self.functions.get(fn_path).map(Clone::clone)
self.functions.get(fn_path).cloned()
}

/// Retrieves the name of all available functions.
Expand Down
17 changes: 6 additions & 11 deletions crates/mun_runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,10 +694,6 @@ impl<'name, T: InvokeArgs> InvokeErr<'name, T> {
Output: 'o + ReturnTypeReflection + Marshal<'o>,
'r: 'o,
{
// Safety: The output of `retry_impl` is guaranteed to only contain a shared
// reference.
let runtime = &*runtime;

loop {
self = match unsafe { self.retry_impl(runtime) } {
Ok(output) => return output,
Expand All @@ -712,16 +708,15 @@ impl<'name, T: InvokeArgs> InvokeErr<'name, T> {
///
/// # Safety
///
/// When calling this function, you have to guarantee that `runtime` is
/// mutably borrowed. The `Output` value can only contain a shared
/// borrow of `runtime`.
unsafe fn retry_impl<'r, 'o, Output>(self, runtime: &'r Runtime) -> Result<Output, Self>
/// When calling this function, you have to guarantee that `runtime` can be
/// dereferenced and is valid for `'o`. The `Output` value can only
/// contain a shared borrow of `runtime`.
unsafe fn retry_impl<'o, Output>(self, runtime: *mut Runtime) -> Result<Output, Self>
where
Output: 'o + ReturnTypeReflection + Marshal<'o>,
'r: 'o,
{
#[allow(invalid_reference_casting, invalid_reference_casting)]
let runtime = &mut *(runtime as *const Runtime as *mut Runtime);
// Safety: Guaranteed by the caller to be valid to dereference.
let runtime = &mut *runtime;

eprintln!("{}", self.msg);
while !runtime.update() {
Expand Down
10 changes: 5 additions & 5 deletions crates/mun_runtime_capi/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ mod tests {
let lib_path = CString::new("some/path").expect("Invalid library path");

let type_id = <()>::type_info().clone().into();
let functions = vec![ExternalFunctionDefinition {
let functions = [ExternalFunctionDefinition {
name: ptr::null(),
arg_types: ptr::null(),
return_type: type_id,
Expand All @@ -447,7 +447,7 @@ mod tests {

let invalid_encoding = ['�', '\0'];
let type_id = <()>::type_info().clone().into();
let functions = vec![ExternalFunctionDefinition {
let functions = [ExternalFunctionDefinition {
name: invalid_encoding.as_ptr().cast(),
arg_types: ptr::null(),
return_type: type_id,
Expand All @@ -472,7 +472,7 @@ mod tests {
let lib_path = CString::new("some/path").expect("Invalid library path");
let function_name = CString::new("foobar").unwrap();

let functions = vec![ExternalFunctionDefinition {
let functions = [ExternalFunctionDefinition {
name: function_name.as_ptr(),
arg_types: ptr::null(),
return_type: Type::null(),
Expand All @@ -498,7 +498,7 @@ mod tests {
let function_name = CString::new("foobar").unwrap();

let type_id = <()>::type_info().clone().into();
let functions = vec![ExternalFunctionDefinition {
let functions = [ExternalFunctionDefinition {
name: function_name.as_ptr(),
arg_types: ptr::null(),
return_type: type_id,
Expand All @@ -525,7 +525,7 @@ mod tests {
let arg_types = [Type::null()];

let type_id = <()>::type_info().clone().into();
let functions = vec![ExternalFunctionDefinition {
let functions = [ExternalFunctionDefinition {
name: function_name.as_ptr(),
arg_types: &arg_types as _,
return_type: type_id,
Expand Down
2 changes: 1 addition & 1 deletion crates/mun_syntax/src/syntax_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub type SyntaxElement = rowan::NodeOrToken<SyntaxNode, SyntaxToken>;
pub type SyntaxNodeChildren = rowan::SyntaxNodeChildren<MunLanguage>;
pub type SyntaxElementChildren = rowan::SyntaxElementChildren<MunLanguage>;

pub use rowan::{Direction, NodeOrToken};
pub use rowan::Direction;

pub struct SyntaxTreeBuilder {
errors: Vec<SyntaxError>,
Expand Down

0 comments on commit 7f4c836

Please sign in to comment.