diff --git a/Cargo.toml b/Cargo.toml index d834d5d87..3618fa2c7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -202,6 +202,7 @@ new_without_default = "allow" option_map_unit_fn = "allow" ptr_offset_by_literal = "warn" ref_option = "warn" +unnecessary_semicolon = "warn" # We do not want to use the e?print(ln)?! macros. # These lints flag their use. diff --git a/crates/gettext-maps/build.rs b/crates/gettext-maps/build.rs index 6e326cd80..a6a61bfd3 100644 --- a/crates/gettext-maps/build.rs +++ b/crates/gettext-maps/build.rs @@ -91,7 +91,7 @@ fn embed_localizations(cache_dir: &Path) { if cached_map_mtime > po_mtime { // Cached map file is considered up-to-date. continue; - }; + } } // Generate the map file. @@ -104,7 +104,7 @@ fn embed_localizations(cache_dir: &Path) { cmd = cmd.arg("--check-format"); } else { tmp_mo_file = Some(cache_dir.join("messages.mo")); - }; + } cmd.arg(format!( "--output-file={}", tmp_mo_file diff --git a/crates/printf/src/printf_impl.rs b/crates/printf/src/printf_impl.rs index 9ed003398..58e2f8d79 100644 --- a/crates/printf/src/printf_impl.rs +++ b/crates/printf/src/printf_impl.rs @@ -57,7 +57,7 @@ fn try_set(&mut self, c: char) -> bool { '+' => self.mark_pos = true, '\'' => self.grouped = true, _ => return false, - }; + } true } } diff --git a/src/ast.rs b/src/ast.rs index b599bc9d0..4740b234d 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -657,7 +657,7 @@ fn accept<'a>(&'a self, visitor: &mut dyn NodeVisitor<'a>) { match self { Self::Argument(child) => visitor.visit(child), Self::Redirection(child) => visitor.visit(&**child), - }; + } } } impl AcceptorMut for ArgumentOrRedirection { diff --git a/src/autoload.rs b/src/autoload.rs index 01e61020d..30e614cf9 100644 --- a/src/autoload.rs +++ b/src/autoload.rs @@ -112,7 +112,7 @@ pub fn resolve_command(&mut self, cmd: &wstr, env: &dyn Environment) -> Autoload ); } AutoloadResult::Loaded | AutoloadResult::Pending | AutoloadResult::None => {} - }; + } result } diff --git a/src/bin/fish.rs b/src/bin/fish.rs index cefe4654c..b526beb32 100644 --- a/src/bin/fish.rs +++ b/src/bin/fish.rs @@ -430,7 +430,7 @@ fn throwing_main() -> i32 { eprintf!("%s\n", e); return 1; } - }; + } } // No-exec is prohibited when in interactive mode. diff --git a/src/builtins/abbr.rs b/src/builtins/abbr.rs index b13a775f5..0e117237d 100644 --- a/src/builtins/abbr.rs +++ b/src/builtins/abbr.rs @@ -33,22 +33,22 @@ fn validate(&mut self, streams: &mut IoStreams) -> bool { let mut cmds = vec![]; if self.add { cmds.push(L!("add")) - }; + } if self.rename { cmds.push(L!("rename")) - }; + } if self.show { cmds.push(L!("show")) - }; + } if self.list { cmds.push(L!("list")) - }; + } if self.erase { cmds.push(L!("erase")) - }; + } if self.query { cmds.push(L!("query")) - }; + } if cmds.len() > 1 { streams.err.append(&wgettext_fmt!( @@ -388,7 +388,7 @@ fn abbr_add(opts: &Options, streams: &mut IoStreams) -> BuiltinResult { // The name plays double-duty as the token to replace. key = name; regex = None; - }; + } if opts.function.is_some() && opts.args.len() > 1 { streams @@ -413,7 +413,7 @@ fn abbr_add(opts: &Options, streams: &mut IoStreams) -> BuiltinResult { for iter in opts.args.iter().skip(1) { if !replacement.is_empty() { replacement.push(' ') - }; + } replacement.push_utfstr(iter); } replacement @@ -477,7 +477,7 @@ fn abbr_erase(opts: &Options, parser: &Parser) -> BuiltinResult { if ret == EnvStackSetResult::Ok { result = Ok(SUCCESS) - }; + } } } } @@ -535,7 +535,7 @@ pub fn abbr(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Bui // non-option, and --add is implied. if let Some(arg) = w.woptarg { opts.args.push(arg.to_owned()) - }; + } if opts.args.len() >= 2 && !(opts.rename || opts.show || opts.list || opts.erase || opts.query) { @@ -645,22 +645,22 @@ pub fn abbr(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Bui if opts.add { return abbr_add(&opts, streams); - }; + } if opts.show { return abbr_show(&opts, streams, parser); - }; + } if opts.list { return abbr_list(&opts, streams); - }; + } if opts.rename { return abbr_rename(&opts, streams); - }; + } if opts.erase { return abbr_erase(&opts, parser); - }; + } if opts.query { return abbr_query(&opts); - }; + } // validate() should error or ensure at least one path is set. panic!("unreachable"); diff --git a/src/builtins/argparse.rs b/src/builtins/argparse.rs index 52ff6c2da..367592be3 100644 --- a/src/builtins/argparse.rs +++ b/src/builtins/argparse.rs @@ -540,7 +540,7 @@ fn parse_cmd_opts<'args>( "--move-unknown" )); return Err(STATUS_INVALID_ARGS); - }; + } opts.unknown_handling = if c == 'i' { UnknownHandling::Ignore } else { @@ -674,7 +674,7 @@ fn populate_option_strings<'args>( ArgType::OptionalArgument => short_options.push_str("::"), ArgType::RequiredArgument => short_options.push_str(":"), ArgType::NoArgument => {} - }; + } } if !opt_spec.long_flag.is_empty() { diff --git a/src/builtins/cd.rs b/src/builtins/cd.rs index 9cf92a31f..1bb965f0c 100644 --- a/src/builtins/cd.rs +++ b/src/builtins/cd.rs @@ -55,7 +55,7 @@ pub fn cd(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> Built )); if !parser.is_interactive() { streams.err.append(&parser.current_line()); - }; + } return Err(STATUS_CMD_ERROR); } diff --git a/src/builtins/commandline.rs b/src/builtins/commandline.rs index 733ac1d50..d3e793952 100644 --- a/src/builtins/commandline.rs +++ b/src/builtins/commandline.rs @@ -229,7 +229,7 @@ fn write_part( let token_text = tok.text_of(&token); add_token(token_text); } - }; + } for arg in args { streams.out.appendln(arg.completion); diff --git a/src/builtins/echo.rs b/src/builtins/echo.rs index f05ac8dbb..ae0b4a67f 100644 --- a/src/builtins/echo.rs +++ b/src/builtins/echo.rs @@ -107,7 +107,7 @@ fn parse_numeric_sequence(chars: I) -> Option<(usize, u8)> // Skip the x start = 1; - }; + } if base == 0 { return None; diff --git a/src/builtins/fg.rs b/src/builtins/fg.rs index 803227842..b9545490b 100644 --- a/src/builtins/fg.rs +++ b/src/builtins/fg.rs @@ -53,7 +53,7 @@ pub fn fg(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Built let mut found_job = false; if let Ok(pid) = parse_pid(streams, cmd, argv[optind]) { found_job = parser.job_get_from_pid(pid).is_some(); - }; + } if found_job { streams @@ -101,8 +101,8 @@ pub fn fg(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Built job = None; builtin_print_error_trailer(parser, streams.err, cmd); } - }; - }; + } + } let Some(job) = job else { return Err(STATUS_INVALID_ARGS); diff --git a/src/builtins/functions.rs b/src/builtins/functions.rs index c25a7cb1b..edcb7efd5 100644 --- a/src/builtins/functions.rs +++ b/src/builtins/functions.rs @@ -365,7 +365,7 @@ pub fn functions(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) - } if !first { streams.out.append(L!("\n")); - }; + } let mut comment = WString::new(); if !opts.no_metadata { diff --git a/src/builtins/jobs.rs b/src/builtins/jobs.rs index eba37b746..b9d6edb0c 100644 --- a/src/builtins/jobs.rs +++ b/src/builtins/jobs.rs @@ -111,7 +111,7 @@ fn builtin_jobs_print(j: &Job, mode: JobsPrintMode, header: bool, streams: &mut } streams.out.append(&out); } - }; + } } const SHORT_OPTIONS: &wstr = L!("cghlpq"); diff --git a/src/builtins/path.rs b/src/builtins/path.rs index 549ff4994..3a9f1fc52 100644 --- a/src/builtins/path.rs +++ b/src/builtins/path.rs @@ -424,7 +424,7 @@ fn path_transform( // TODO: Is that correct? if opts.quiet { return Ok(SUCCESS); - }; + } } path_out(streams, &opts, transformed); } @@ -921,7 +921,7 @@ fn path_filter_maybe_is( } if opts.quiet { return Ok(SUCCESS); - }; + } } if opts.all && n_transformed != arguments_vec.len() { diff --git a/src/builtins/read.rs b/src/builtins/read.rs index dc9ab8851..45bda2afc 100644 --- a/src/builtins/read.rs +++ b/src/builtins/read.rs @@ -705,7 +705,7 @@ pub fn read(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Bui text = Cow::Owned(unescaped); } } - }; + } text.into_owned() }; if opts.array { diff --git a/src/builtins/return.rs b/src/builtins/return.rs index 0967a09a7..0565486dd 100644 --- a/src/builtins/return.rs +++ b/src/builtins/return.rs @@ -66,7 +66,7 @@ pub fn r#return(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> // Note in Rust, dividend % divisor has the same sign as the dividend. if retval < 0 { retval = 256 - (retval % 256).abs(); - }; + } let retval = BuiltinResult::from_dynamic(retval); diff --git a/src/builtins/source.rs b/src/builtins/source.rs index 75c19c2c0..d840722aa 100644 --- a/src/builtins/source.rs +++ b/src/builtins/source.rs @@ -68,7 +68,7 @@ pub fn source(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> B builtin_wperror(cmd, streams); return Err(STATUS_CMD_ERROR); } - }; + } fd = opened_file.as_raw_fd(); diff --git a/src/builtins/status.rs b/src/builtins/status.rs index f835b9e46..c7147e998 100644 --- a/src/builtins/status.rs +++ b/src/builtins/status.rs @@ -579,7 +579,7 @@ pub fn status(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> B args[0] )); return Err(STATUS_INVALID_ARGS); - }; + } return if get_scroll_content_up_capability() == Some(true) { Ok(SUCCESS) } else { @@ -776,7 +776,7 @@ pub fn status(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> B } } } - }; + } Ok(SUCCESS) } diff --git a/src/builtins/test.rs b/src/builtins/test.rs index a9c608772..8b3c8b959 100644 --- a/src/builtins/test.rs +++ b/src/builtins/test.rs @@ -1104,7 +1104,7 @@ fn run_one_test_test_mbracket(expected: i32, lst: &[&str], bracket: bool) -> boo } if bracket { argv.push(L!("]").to_owned()) - }; + } // Convert to &[&wstr]. let mut argv = argv.iter().map(|s| s.as_ref()).collect::>(); diff --git a/src/common.rs b/src/common.rs index 3ea4a2ecc..574657c36 100644 --- a/src/common.rs +++ b/src/common.rs @@ -186,7 +186,7 @@ fn escape_string_script(input: &wstr, flags: EscapeFlags) -> WString { need_escape = true; if escape_printables { out.push('\\') - }; + } } out.push(c); } @@ -1245,7 +1245,7 @@ pub fn is_windows_subsystem_for_linux(v: WSL) -> bool { Ok(17763..) => return Some(WSL::V1), Ok(_) => (), // return true, but first warn (see below) _ => return None, // if parsing fails, assume this isn't WSL - }; + } // #5298, #5661: There are acknowledged, published, and (later) fixed issues with // job control under early WSL releases that prevent fish from running correctly, diff --git a/src/env_universal_common.rs b/src/env_universal_common.rs index 384021766..dd96f622c 100644 --- a/src/env_universal_common.rs +++ b/src/env_universal_common.rs @@ -103,7 +103,7 @@ pub fn set(&mut self, key: &wstr, var: EnvVar) { Entry::Vacant(entry) => { entry.insert(var); } - }; + } self.modified.insert(key.to_owned()); if exports { self.export_generation += 1; diff --git a/src/event.rs b/src/event.rs index 4eb8f5b51..9f98597a6 100644 --- a/src/event.rs +++ b/src/event.rs @@ -481,7 +481,7 @@ fn fire_internal(parser: &Parser, event: &Event) { // A previous handler may have erased this one. if handler.removed.load(Ordering::Relaxed) { continue; - }; + } // Construct a buffer to evaluate, starting with the function name and then all the // arguments. @@ -526,12 +526,12 @@ pub fn fire_delayed(parser: &Parser) { // Do not invoke new event handlers from within event handlers. if parser.scope().is_event { return; - }; + } // Do not invoke new event handlers if we are unwinding (#6649). if signal_check_cancel() != 0 { return; - }; + } // We unfortunately can't keep this locked until we're done with it because the SIGWINCH handler // code might call back into here and we would delay processing of the events, leading to a test diff --git a/src/exec.rs b/src/exec.rs index 2688f1c98..4a0f098d8 100644 --- a/src/exec.rs +++ b/src/exec.rs @@ -344,7 +344,7 @@ fn exit_code_from_exec_error(err: libc::c_int) -> libc::c_int { fn is_thompson_shell_payload(p: &[u8]) -> bool { if !p.contains(&b'\0') { return true; - }; + } let mut haslower = false; for c in p { if c.is_ascii_lowercase() || *c == b'$' || *c == b'`' { @@ -970,7 +970,7 @@ fn function_prepare_environment( for (idx, named_arg) in props.named_arguments.iter().enumerate() { if named_arg == L!("argv") { overwrite_argv = true - }; + } if idx < argv.len() { vars.set_one(named_arg, mode, argv[idx].clone()); } else { @@ -981,7 +981,7 @@ fn function_prepare_environment( for (key, value) in &*props.inherit_vars { if key == L!("argv") { overwrite_argv = true - }; + } vars.set(key, mode, value.clone()); } diff --git a/src/expand.rs b/src/expand.rs index a220ce8e2..cb614bfeb 100644 --- a/src/expand.rs +++ b/src/expand.rs @@ -1154,7 +1154,7 @@ fn expand_home_directory(input: &mut WString, vars: &dyn Environment) { home = Some(home_var.as_string()); tail_idx = 1; } - }; + } } else { // Some other user's home directory. let name_cstr = wcs2zstring(username); diff --git a/src/function.rs b/src/function.rs index c26b1e722..d5c7dff9b 100644 --- a/src/function.rs +++ b/src/function.rs @@ -341,7 +341,7 @@ pub fn get_names(get_hidden: bool, vars: &dyn Environment) -> Vec { }; if !get_hidden && (bname.is_empty() || bname.starts_with('_')) { continue; - }; + } let Some(fname) = bname.strip_suffix(".fish") else { continue; }; @@ -466,7 +466,7 @@ pub fn annotated_definition(&self, name: &wstr) -> WString { EventDescription::Any => { panic!("Unexpected event handler type"); } - }; + } } let named = &self.named_arguments; diff --git a/src/highlight/file_tester.rs b/src/highlight/file_tester.rs index e434921bd..2cb103caa 100644 --- a/src/highlight/file_tester.rs +++ b/src/highlight/file_tester.rs @@ -404,7 +404,7 @@ fn fs_is_case_insensitive( ) -> bool { if let Some(cached) = case_sensitivity_cache.get(path) { return *cached; - }; + } // Ask the system. A -1 value means error (so assume case sensitive), a 1 value means case // sensitive, and a 0 value means case insensitive. let ret = unsafe { libc::fpathconf(fd, libc::_PC_CASE_SENSITIVE) }; diff --git a/src/highlight/highlight.rs b/src/highlight/highlight.rs index 0b6e7d847..75ea8d715 100644 --- a/src/highlight/highlight.rs +++ b/src/highlight/highlight.rs @@ -259,22 +259,22 @@ fn command_is_valid( // Builtins if !is_valid && builtin_ok { is_valid = builtin_exists(cmd) - }; + } // Functions if !is_valid && function_ok { is_valid = function::exists_no_autoload(cmd) - }; + } // Abbreviations if !is_valid && abbreviation_ok { is_valid = with_abbrs(|set| set.has_match(cmd, abbrs::Position::Command, L!(""))) - }; + } // Regular commands if !is_valid && command_ok { is_valid = path_get_path(cmd, vars).is_some() - }; + } // Implicit cd if !is_valid && implicit_cd_ok { @@ -895,7 +895,7 @@ fn visit_keyword(&mut self, node: &dyn Keyword) { | ParseKeyword::Exclam | ParseKeyword::Time => role = HighlightRole::operat, ParseKeyword::None => (), - }; + } self.color_node(node.as_node(), HighlightSpec::with_fg(role)); } fn visit_token(&mut self, tok: &dyn Token) { diff --git a/src/history/history.rs b/src/history/history.rs index 957f926bb..8b30f8204 100644 --- a/src/history/history.rs +++ b/src/history/history.rs @@ -1592,7 +1592,7 @@ pub fn go_to_next_match(&mut self, direction: SearchDirection) -> bool { match direction { SearchDirection::Backward => index += 1, SearchDirection::Forward => index -= 1, - }; + } if self.current_index == invalid_index { return false; diff --git a/src/input_common.rs b/src/input_common.rs index c56b8caba..dc6ba80a5 100644 --- a/src/input_common.rs +++ b/src/input_common.rs @@ -250,7 +250,7 @@ fn apply_shift(mut key: Key, do_ascii: bool, shifted_codepoint: char) -> Option< key.codepoint = key.codepoint.to_ascii_uppercase(); } else { return None; - }; + } key.modifiers.shift = false; Some(key) } @@ -1046,7 +1046,7 @@ fn parse_csi(&mut self, buffer: &mut Vec) -> Option { { Some(c) => params[count][subcount] = c, None => return invalid_sequence(buffer), - }; + } } else if c == b':' && subcount < 3 { subcount += 1; } else if c == b';' { @@ -1242,7 +1242,7 @@ fn parse_csi(&mut self, buffer: &mut Vec) -> Option { match params[1] { [1, 0, 0, 0] | [2, 0, 0, 0] => (), _ => return None, - }; + } flog!(reader, "Received color theme change"); self.push_front(CharEvent::Implicit(ImplicitEvent::NewColorTheme)); return None; diff --git a/src/pager.rs b/src/pager.rs index edc15c4e5..4d56c3657 100644 --- a/src/pager.rs +++ b/src/pager.rs @@ -911,7 +911,7 @@ pub fn get_selected_column(&self, rendering: &PageRendering) -> Option { pub fn get_selected_row_given_rows(&self, rows: usize) -> Option { if rows == 0 { return None; - }; + } self.selected_completion_idx.map(|idx| idx % rows) } diff --git a/src/parse_execution.rs b/src/parse_execution.rs index e973cf758..415012363 100644 --- a/src/parse_execution.rs +++ b/src/parse_execution.rs @@ -780,7 +780,7 @@ fn populate_plain_process( std::io::Error::from_raw_os_error(external_cmd.err.unwrap().into()), ); } - }; + } path } else { WString::new() diff --git a/src/parser.rs b/src/parser.rs index c5863a33c..06f98beec 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -1283,7 +1283,7 @@ pub fn set_color_theme(&self, background_color: Option<&xterm_color::Color>) { .is_some_and(|var| var.as_list() == [color_theme]) { return; - }; + } flogf!( reader, "Setting %s to %s", diff --git a/src/reader/reader.rs b/src/reader/reader.rs index ac7139641..24d7607e6 100644 --- a/src/reader/reader.rs +++ b/src/reader/reader.rs @@ -325,7 +325,7 @@ pub fn terminal_init(vars: &dyn Environment, inputfd: RawFd) -> TerminalInitResu } CharEvent::QueryResult(Interrupted) => break, Key(_) | Readline(_) | Command(_) | Implicit(_) => panic!(), - }; + } } stop_query(input_queue.blocking_query()); @@ -1329,7 +1329,7 @@ pub fn reader_test_and_clear_interrupted() -> i32 { let res = INTERRUPTED.load(Ordering::Relaxed); if res != 0 { INTERRUPTED.store(0, Ordering::Relaxed); - }; + } res } @@ -2678,7 +2678,7 @@ fn read_normal_chars(&mut self) -> Option { accumulated_chars.push(c); } else { continue; - }; + } } if !accumulated_chars.is_empty() { @@ -4092,7 +4092,7 @@ fn handle_readline_command(&mut self, c: ReadlineCmd) { replacement.extend(chr.to_uppercase()); } else { replacement.extend(chr.to_lowercase()); - }; + } capitalized_first = capitalized_first || make_uppercase; pos += 1; } @@ -5985,7 +5985,7 @@ fn extract_tokens(s: &wstr) -> Vec { // We are only interested in leaf nodes with source. if node.as_leaf().is_none() { continue; - }; + } let range = node.source_range(); if range.length() == 0 { continue; @@ -7075,7 +7075,7 @@ fn handle_completions(&mut self, token_range: Range, mut comp: Vec bo 0..=7 => write_to_output!(out, "\x1b[{}m", 30 + bg + idx), 8..=15 => write_to_output!(out, "\x1b[{}m", 90 + bg + (idx - 8)), _ => write_to_output!(out, "\x1b[{};5;{}m", 38 + bg, idx), - }; + } true } diff --git a/src/tinyexpr.rs b/src/tinyexpr.rs index 326f42d69..d9b62121e 100644 --- a/src/tinyexpr.rs +++ b/src/tinyexpr.rs @@ -243,7 +243,7 @@ fn ncr(n: f64, r: f64) -> f64 { if ur > un / 2 { ur = un - ur - }; + } let mut result = 1_u64; for i in 1..=ur { diff --git a/src/tty_handoff.rs b/src/tty_handoff.rs index a4f29a487..70ca15052 100644 --- a/src/tty_handoff.rs +++ b/src/tty_handoff.rs @@ -305,7 +305,7 @@ fn set_tty_protocols_active(on_write: fn(), enable: bool) { ProtocolKind::Other => flog!(reader, mode, "other extended keys"), ProtocolKind::WorkAroundWezTerm => flog!(reader, mode, "wezterm; no modifyOtherKeys"), ProtocolKind::None => (), - }; + } (on_write)(); } @@ -391,7 +391,7 @@ pub fn enable_tty_protocols(&mut self) { pub fn disable_tty_protocols(&mut self) { if !self.tty_protocols_applied { return; // Already disabled. - }; + } self.tty_protocols_applied = false; set_tty_protocols_active(self.on_write, false); } diff --git a/src/wildcard.rs b/src/wildcard.rs index 50547d949..9f763ae89 100644 --- a/src/wildcard.rs +++ b/src/wildcard.rs @@ -708,7 +708,7 @@ fn expand_trailing_slash(&mut self, base_dir: &wstr, prefix: &wstr, info: Parent let known_dir = need_dir && entry.is_dir(); if need_dir && !known_dir { continue; - }; + } if !entry.name.is_empty() && !entry.name.starts_with('.') { self.try_add_completion_result( &(base_dir.to_owned() + entry.name.as_utfstr()), diff --git a/src/wutil/wcstod.rs b/src/wutil/wcstod.rs index 44c737e81..2745737c3 100644 --- a/src/wutil/wcstod.rs +++ b/src/wutil/wcstod.rs @@ -184,11 +184,11 @@ pub fn is_hex_float>(mut chars: Chars) -> bool { } Some('0') => (), _ => return false, - }; + } match chars.next() { Some('x') | Some('X') => (), _ => return false, - }; + } match chars.next() { Some(c) => c.is_ascii_hexdigit(), None => false,