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 parsing bug after refactor: Don't borrow parse state #106

Merged
merged 3 commits into from
Apr 16, 2024
Merged
Changes from 2 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
108 changes: 38 additions & 70 deletions src/build/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,90 +103,58 @@ pub fn generate_asts(
.packages
.get(&module.package_name)
.expect("Package not found");
if is_dirty {
rolandpeelen marked this conversation as resolved.
Show resolved Hide resolved
module.compile_dirty = true
}
match ast_path {
Ok((_path, err)) => {
match module.source_type {
SourceType::SourceFile(ref mut source_file) => {
source_file.implementation.parse_dirty = false;
source_file
.interface
.as_mut()
.map(|interface| interface.parse_dirty = false);
}
_ => (),
}
if let SourceType::SourceFile(ref mut source_file) = module.source_type {
match ast_path {
// supress warnings in non-pinned deps
match module.source_type {
SourceType::SourceFile(ref mut source_file) => {
source_file.implementation.parse_state = ParseState::Success;
Ok((_path, Some(err))) if package.is_pinned_dep => {
source_file.implementation.parse_state = ParseState::Warning;
source_file.implementation.parse_dirty = true;
if let Some(interface) = source_file.interface.as_mut() {
interface.parse_dirty = false;
}
_ => (),
logs::append(package, &err);
stderr.push_str(&err);
}

if package.is_pinned_dep {
if let Some(err) = err {
match module.source_type {
SourceType::SourceFile(ref mut source_file) => {
source_file.implementation.parse_state = ParseState::Warning;
source_file.implementation.parse_dirty = true;
}
_ => (),
}
logs::append(package, &err);
stderr.push_str(&err);
Ok((_path, None)) => {
source_file.implementation.parse_state = ParseState::Success;
source_file.implementation.parse_dirty = false;
if let Some(interface) = source_file.interface.as_mut() {
interface.parse_dirty = false;
}
}
}
Err(err) => {
match module.source_type {
SourceType::SourceFile(ref mut source_file) => {
source_file.implementation.parse_state = ParseState::ParseError;
source_file.implementation.parse_dirty = true;
}
_ => (),
Err(err) => {
source_file.implementation.parse_state = ParseState::ParseError;
source_file.implementation.parse_dirty = true;
logs::append(package, &err);
has_failure = true;
stderr.push_str(&err);
}
logs::append(package, &err);
has_failure = true;
stderr.push_str(&err);
}
};
match iast_path {
Ok(Some((_path, err))) => {
_ => (),
};
}

match (iast_path, module.source_type.to_owned()) {
rolandpeelen marked this conversation as resolved.
Show resolved Hide resolved
(Ok(Some((_path, Some(err)))), SourceType::SourceFile(ref mut source_file))
if package.is_pinned_dep =>
{
// supress warnings in non-pinned deps
if package.is_pinned_dep {
if let Some(err) = err {
match module.source_type {
SourceType::SourceFile(ref mut source_file) => {
source_file.interface.as_mut().map(|interface| {
interface.parse_state = ParseState::ParseError;
interface.parse_dirty = true;
});
}
_ => (),
}
logs::append(package, &err);
stderr.push_str(&err);
}
if let Some(interface) = source_file.interface.as_mut() {
interface.parse_state = ParseState::Warning;
interface.parse_dirty = true;
}
logs::append(package, &err);
stderr.push_str(&err);
}
Ok(None) => (),
Err(err) => {
match module.source_type {
SourceType::SourceFile(ref mut source_file) => {
source_file.interface.as_mut().map(|interface| {
interface.parse_state = ParseState::ParseError;
interface.parse_dirty = true;
});
}
_ => (),
(Err(err), SourceType::SourceFile(ref mut source_file)) => {
if let Some(interface) = source_file.interface.as_mut() {
interface.parse_state = ParseState::ParseError;
interface.parse_dirty = true;
}
logs::append(package, &err);
has_failure = true;
stderr.push_str(&err);
}
_ => (),
rolandpeelen marked this conversation as resolved.
Show resolved Hide resolved
};
}
});
Expand Down
Loading