Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: clippy lints #553

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -113,9 +113,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 @@ -132,9 +132,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
10 changes: 3 additions & 7 deletions crates/mun_hir/src/code_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,13 @@ pub use self::{
function::Function,
module::{Module, ModuleDef},
package::Package,
r#impl::{Impl, ImplData},
r#struct::{Field, LocalFieldId, Struct, StructKind, StructMemoryKind},
r#impl::ImplData,
r#struct::{Field, Struct, StructKind, StructMemoryKind},
src::HasSource,
type_alias::TypeAlias,
};

pub use self::{
function::FunctionData,
r#struct::{FieldData, StructData},
type_alias::TypeAliasData,
};
pub use self::{function::FunctionData, r#struct::StructData, type_alias::TypeAliasData};

/// The definitions that have a body.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
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 @@ -80,12 +80,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
1 change: 0 additions & 1 deletion crates/mun_hir/src/ty/infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use crate::ids::DefWithBodyId;
use crate::resolve::{resolver_for_expr, HasResolver};
use crate::ty::primitives::{FloatTy, IntTy};
use crate::ty::TyKind;
pub use type_variable::TypeVarId;

mod coerce;

Expand Down
2 changes: 1 addition & 1 deletion crates/mun_hir/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
if let Some(file_id) = module.file_id(&db) {
let source_file = db.parse(file_id);
for err in source_file.errors() {
diags.push(format!("{:?}: {}", err.location(), err.to_string()));
diags.push(format!("{:?}: {}", err.location(), err));

Check warning on line 28 in crates/mun_hir/src/utils.rs

View check run for this annotation

Codecov / codecov/patch

crates/mun_hir/src/utils.rs#L28

Added line #L28 was not covered by tests
}
}
}
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 @@ -13,7 +13,7 @@ pub struct DispatchTable {
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
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 @@ -402,7 +402,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 @@ -428,7 +428,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 @@ -453,7 +453,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 @@ -479,7 +479,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 @@ -506,7 +506,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
Loading