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

VS Code diagnostics #1092

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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
39 changes: 21 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ members = [

[workspace.package]
edition = "2021"
rust-version = "1.78.0"
rust-version = "1.80.0"

[profile.release]
# This adds file and line number information to backtraces while only increasing
Expand Down
2 changes: 2 additions & 0 deletions compiler_v4/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ itertools = "0.12.0"
petgraph = "0.6.5"
replace_with = "0.1.7"
rustc-hash = "2.0.0"
serde = { version = "1.0.216", features = ["derive"] }
serde_json = "1.0.133"
strum = { version = "0.26.1", features = ["derive"] }
tracing = { version = "0.1", features = ["release_max_level_debug"] }
tracing-subscriber = { version = "0.3.16", features = ["registry"] }
Expand Down
1 change: 1 addition & 0 deletions compiler_v4/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ pub struct AstTypeParameter {

// Types

#[allow(clippy::large_enum_variant)]
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub enum AstType {
Named(AstNamedType),
Expand Down
36 changes: 18 additions & 18 deletions compiler_v4/src/ast_to_hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ struct ImplDeclaration<'a> {
trait_: Trait,
functions: FxHashMap<Id, FunctionDeclaration<'a>>,
}
impl<'a> ImplDeclaration<'a> {
impl ImplDeclaration<'_> {
#[must_use]
fn into_impl(self) -> Impl {
Impl {
Expand Down Expand Up @@ -166,7 +166,7 @@ struct FunctionDeclaration<'a> {
signature: Signature,
body: Option<BodyOrBuiltin>,
}
impl<'a> FunctionDeclaration<'a> {
impl FunctionDeclaration<'_> {
fn signature_to_string(&self) -> String {
format!("{}{}", self.name, self.signature)
}
Expand Down Expand Up @@ -1195,7 +1195,7 @@ impl<'a> Context<'a> {
.collect_vec(),
self_base_type,
|builder| {
for parameter in function.signature.parameters.iter() {
for parameter in &function.signature.parameters {
builder.push_parameter(parameter.clone());
}

Expand Down Expand Up @@ -1229,7 +1229,7 @@ impl<'a> Context<'a> {
.unwrap()
}

fn get_all_functions_matching_name(&mut self, name: &str) -> Vec<Id> {
fn get_all_functions_matching_name(&self, name: &str) -> Vec<Id> {
self.functions
.iter()
.chain(self.traits.iter().flat_map(|(_, trait_)| &trait_.functions))
Expand Down Expand Up @@ -1285,7 +1285,9 @@ impl<'c, 'a> BodyBuilder<'c, 'a> {
self.type_parameters,
self.self_base_type,
|builder| {
builder.local_identifiers = self.local_identifiers.clone();
builder
.local_identifiers
.clone_from(&self.local_identifiers);
fun(builder);
self.global_assignment_dependencies
.extend(&builder.global_assignment_dependencies);
Expand Down Expand Up @@ -1433,14 +1435,12 @@ impl<'c, 'a> BodyBuilder<'c, 'a> {
type_: NamedType::text().into(),
}
}
AstExpressionKind::Parenthesized(parenthesized) => {
return parenthesized
.inner
.value()
.map_or(LoweredExpression::Error, |it| {
self.lower_expression_raw(it, context_type)
});
}
AstExpressionKind::Parenthesized(parenthesized) => parenthesized
.inner
.value()
.map_or(LoweredExpression::Error, |it| {
self.lower_expression_raw(it, context_type)
}),
AstExpressionKind::Call(call) => {
let type_arguments = call.type_arguments.as_ref().map(|it| {
it.arguments
Expand Down Expand Up @@ -1527,7 +1527,7 @@ impl<'c, 'a> BodyBuilder<'c, 'a> {
type_arguments.as_deref(),
&type_,
&type_declaration.type_parameters,
fields,
fields.as_deref(),
)
}
TypeDeclarationKind::Enum { .. } => {
Expand Down Expand Up @@ -1670,7 +1670,7 @@ impl<'c, 'a> BodyBuilder<'c, 'a> {
);

let body = self.build_inner(|builder| {
for parameter in parameters.iter() {
for parameter in &parameters {
builder.push_parameter(parameter.clone());
}

Expand Down Expand Up @@ -1861,7 +1861,7 @@ impl<'c, 'a> BodyBuilder<'c, 'a> {
} else if let Some(type_parameter) = self.type_parameters.iter().find(|it| it.name == *name)
{
LoweredExpression::TypeParameterReference(type_parameter.type_())
} else if self.context.hir.type_declarations.get(name).is_some() {
} else if self.context.hir.type_declarations.contains_key(name) {
LoweredExpression::NamedTypeReference(name.clone())
} else {
self.context.add_error(
Expand Down Expand Up @@ -2059,7 +2059,7 @@ impl<'c, 'a> BodyBuilder<'c, 'a> {
type_arguments: Option<&[Type]>,
type_: &str,
type_parameters: &[TypeParameter],
fields: &Option<Box<[StructField]>>,
fields: Option<&[StructField]>,
) -> LoweredExpression {
let Some(fields) = fields else {
self.context.add_error(
Expand Down Expand Up @@ -2213,7 +2213,7 @@ impl<'c, 'a> BodyBuilder<'c, 'a> {
.collect::<Box<_>>()
}
fn match_signature(
&mut self,
&self,
trait_goal_and_subgoals: Option<(&SolverGoal, &[SolverGoal])>,
type_parameters: &[TypeParameter],
parameter_types: &[Type],
Expand Down
2 changes: 1 addition & 1 deletion compiler_v4/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl ToText for Hir {
(name.as_ref(), definition).build_text(builder);
builder.push_newline();
}
for impl_ in self.impls.iter() {
for impl_ in &self.impls {
impl_.build_text(builder);
builder.push_newline();
}
Expand Down
6 changes: 3 additions & 3 deletions compiler_v4/src/hir_to_mono.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ impl<'h> Context<'h> {
result.push_str(&type_.name);
if !type_.type_arguments.is_empty() {
result.push_str("$of$");
for type_ in type_.type_arguments.iter() {
for type_ in &type_.type_arguments {
Self::mangle_type_helper(result, type_);
result.push('$');
}
Expand All @@ -375,7 +375,7 @@ impl<'h> Context<'h> {
result.push_str("$Fun$");
if !type_.parameter_types.is_empty() {
result.push_str("of$");
for type_ in type_.parameter_types.iter() {
for type_ in &type_.parameter_types {
Self::mangle_type_helper(result, type_);
result.push('$');
}
Expand Down Expand Up @@ -427,7 +427,7 @@ impl<'c, 'h> BodyBuilder<'c, 'h> {
id_generator: IdGenerator::default(),
id_mapping: FxHashMap::default(),
};
builder.id_mapping = self.id_mapping.clone();
builder.id_mapping.clone_from(&self.id_mapping);
builder.id_generator = mem::take(&mut self.id_generator);

fun(&mut builder);
Expand Down
Loading
Loading