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

Use filter_map instead of map().filter_map() #29

Merged
merged 1 commit into from
Jan 14, 2024
Merged
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
5 changes: 1 addition & 4 deletions crates/oq3_source_file/src/source_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,22 +198,19 @@ pub(crate) fn read_source_file(file_path: &Path) -> String {
}

// FIXME: prevent a file from including itself. Then there are two-file cycles, etc.
// FIXME: I want to disable filter_map_identity globally, but there is no option for clippy.toml
#[allow(clippy::filter_map_identity)]
/// Recursively parse any files `include`d in the program `syntax_ast`.
pub(crate) fn parse_included_files(syntax_ast: &ParsedSource) -> Vec<SourceFile> {
syntax_ast
.tree()
.statements()
.map(|parse_item| match parse_item {
.filter_map(|parse_item| match parse_item {
synast::Stmt::Item(synast::Item::Include(include)) => {
let file: synast::FilePath = include.file().unwrap();
let file_path = file.to_string().unwrap();
Some(parse_source_file(&PathBuf::from(file_path)))
}
_ => None,
})
.filter_map(|x| x)
.collect::<Vec<_>>()
}

Expand Down