fix: clippy lints

This commit is contained in:
Amaan Qureshi 2024-11-16 03:20:59 -05:00
parent 78e5144f3f
commit 274e60a523
No known key found for this signature in database
GPG key ID: E67890ADC4227273
10 changed files with 17 additions and 22 deletions

View file

@ -65,10 +65,7 @@ fn web_playground_files_present() -> bool {
fn read_git_sha() -> Option<String> {
let crate_path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
if !crate_path
.parent()
.map_or(false, |p| p.join(".git").exists())
{
if !crate_path.parent().is_some_and(|p| p.join(".git").exists()) {
return None;
}

View file

@ -208,7 +208,7 @@ fn populate_used_symbols(
// ensure that a subtree's symbol can be successfully reassigned to the word token
// without having to move the subtree to the heap.
// See https://github.com/tree-sitter/tree-sitter/issues/258
if syntax_grammar.word_token.map_or(false, |t| t.index == i) {
if syntax_grammar.word_token.is_some_and(|t| t.index == i) {
parse_table.symbols.insert(1, Symbol::terminal(i));
} else {
parse_table.symbols.push(Symbol::terminal(i));

View file

@ -363,9 +363,9 @@ impl CharacterSet {
}) {
Ok(ix) | Err(ix) => ix,
};
self.ranges.get(ix).map_or(false, |range| {
range.start <= seek_range.start && range.end >= seek_range.end
})
self.ranges
.get(ix)
.is_some_and(|range| range.start <= seek_range.start && range.end >= seek_range.end)
}
pub fn contains(&self, c: char) -> bool {

View file

@ -574,7 +574,7 @@ pub fn generate_node_types_json(
if node_type_json
.children
.as_ref()
.map_or(false, |c| c.types.is_empty())
.is_some_and(|c| c.types.is_empty())
{
node_type_json.children = None;
}

View file

@ -202,7 +202,7 @@ pub(crate) fn parse_grammar(input: &str) -> Result<InputGrammar> {
(&extra_symbols, &external_tokens),
name,
&mut in_progress,
) && grammar_json.word.as_ref().map_or(true, |w| w != name)
) && grammar_json.word.as_ref().is_some_and(|w| w != name)
{
grammar_json.conflicts.retain(|r| !r.contains(name));
grammar_json.supertypes.retain(|r| r != name);

View file

@ -481,7 +481,7 @@ impl Loader {
scope: &str,
) -> Result<Option<(Language, &LanguageConfiguration)>> {
for configuration in &self.language_configurations {
if configuration.scope.as_ref().map_or(false, |s| s == scope) {
if configuration.scope.as_ref().is_some_and(|s| s == scope) {
let language = self.language_for_id(configuration.language_id)?;
return Ok(Some((language, configuration)));
}
@ -977,13 +977,13 @@ impl Loader {
} else if Command::new("docker")
.arg("info")
.output()
.map_or(false, |out| out.status.success())
.is_ok_and(|out| out.status.success())
{
EmccSource::Docker
} else if Command::new("podman")
.arg("--version")
.output()
.map_or(false, |out| out.status.success())
.is_ok_and(|out| out.status.success())
{
EmccSource::Podman
} else {

View file

@ -307,9 +307,8 @@ fn write_color(buffer: &mut String, color: Color) {
}
fn terminal_supports_truecolor() -> bool {
std::env::var("COLORTERM").map_or(false, |truecolor| {
truecolor == "truecolor" || truecolor == "24bit"
})
std::env::var("COLORTERM")
.is_ok_and(|truecolor| truecolor == "truecolor" || truecolor == "24bit")
}
fn closest_xterm_color(red: u8, green: u8, blue: u8) -> Color {

View file

@ -84,7 +84,7 @@ pub fn get_test_language(name: &str, parser_code: &str, path: Option<&Path>) ->
fs::create_dir_all(&src_dir).unwrap();
let parser_path = src_dir.join("parser.c");
if !fs::read_to_string(&parser_path).map_or(false, |content| content == parser_code) {
if !fs::read_to_string(&parser_path).is_ok_and(|content| content == parser_code) {
fs::write(&parser_path, parser_code).unwrap();
}
@ -93,8 +93,7 @@ pub fn get_test_language(name: &str, parser_code: &str, path: Option<&Path>) ->
if scanner_path.exists() {
let scanner_code = fs::read_to_string(&scanner_path).unwrap();
let scanner_copy_path = src_dir.join("scanner.c");
if !fs::read_to_string(&scanner_copy_path)
.map_or(false, |content| content == scanner_code)
if !fs::read_to_string(&scanner_copy_path).is_ok_and(|content| content == scanner_code)
{
fs::write(&scanner_copy_path, scanner_code).unwrap();
}

View file

@ -199,7 +199,7 @@ impl TagsConfiguration {
&& property
.value
.as_ref()
.map_or(false, |v| v.as_ref() == "false")
.is_some_and(|v| v.as_ref() == "false")
{
info.local_scope_inherits = false;
}

View file

@ -35,13 +35,13 @@ pub fn run_wasm(args: &BuildWasm) -> Result<()> {
} else if Command::new("docker")
.arg("info")
.output()
.map_or(false, |out| out.status.success())
.is_ok_and(|out| out.status.success())
{
EmccSource::Docker
} else if Command::new("podman")
.arg("--version")
.output()
.map_or(false, |out| out.status.success())
.is_ok_and(|out| out.status.success())
{
EmccSource::Podman
} else {