diff --git a/src/builtins/abbr.rs b/src/builtins/abbr.rs index f4e52a1b4..7f1e3ab1b 100644 --- a/src/builtins/abbr.rs +++ b/src/builtins/abbr.rs @@ -180,7 +180,7 @@ fn abbr_show(streams: &mut IoStreams) -> BuiltinResult { // Print the list of abbreviation names. fn abbr_list(opts: &Options, streams: &mut IoStreams) -> BuiltinResult { - const subcmd: &wstr = L!("--list"); + let subcmd = L!("--list"); if !opts.args.is_empty() { streams.err.append(wgettext_fmt!( "%s %s: Unexpected argument -- '%s'\n", @@ -203,7 +203,7 @@ fn abbr_list(opts: &Options, streams: &mut IoStreams) -> BuiltinResult { // Rename an abbreviation, deleting any existing one with the given name. fn abbr_rename(opts: &Options, streams: &mut IoStreams) -> BuiltinResult { - const subcmd: &wstr = L!("--rename"); + let subcmd = L!("--rename"); if opts.args.len() != 2 { streams.err.append(wgettext_fmt!( @@ -305,7 +305,7 @@ fn abbr_query(opts: &Options) -> BuiltinResult { // Add a named abbreviation. fn abbr_add(opts: &Options, streams: &mut IoStreams) -> BuiltinResult { - const subcmd: &wstr = L!("--add"); + let subcmd = L!("--add"); if opts.args.len() < 2 && opts.function.is_none() { streams.err.append(wgettext_fmt!( @@ -484,9 +484,9 @@ pub fn abbr(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Bui // Note the leading '-' causes wgetopter to return arguments in order, instead of permuting // them. We need this behavior for compatibility with pre-builtin abbreviations where options // could be given literally, for example `abbr e emacs -nw`. - const short_options: &wstr = L!("-ac:f:r:seqgUh"); + let short_options: &wstr = L!("-ac:f:r:seqgUh"); - const longopts: &[WOption] = &[ + let longopts: &[WOption] = &[ wopt(L!("add"), ArgType::NoArgument, 'a'), wopt(L!("command"), ArgType::RequiredArgument, 'c'), wopt(L!("position"), ArgType::RequiredArgument, 'p'), diff --git a/src/builtins/builtin.rs b/src/builtins/builtin.rs index bdcb513b0..eb540f201 100644 --- a/src/builtins/builtin.rs +++ b/src/builtins/builtin.rs @@ -12,8 +12,8 @@ pub fn r#builtin(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) - let print_hints = false; let mut opts: builtin_cmd_opts_t = Default::default(); - const shortopts: &wstr = L!("hnq"); - const longopts: &[WOption] = &[ + let shortopts: &wstr = L!("hnq"); + let longopts: &[WOption] = &[ wopt(L!("help"), ArgType::NoArgument, 'h'), wopt(L!("names"), ArgType::NoArgument, 'n'), wopt(L!("query"), ArgType::NoArgument, 'q'), diff --git a/src/builtins/command.rs b/src/builtins/command.rs index 955aae6ad..9b3693de7 100644 --- a/src/builtins/command.rs +++ b/src/builtins/command.rs @@ -14,8 +14,8 @@ pub fn r#command(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) - let print_hints = false; let mut opts: command_cmd_opts_t = Default::default(); - const shortopts: &wstr = L!("hasqv"); - const longopts: &[WOption] = &[ + let shortopts: &wstr = L!("hasqv"); + let longopts: &[WOption] = &[ wopt(L!("help"), ArgType::NoArgument, 'h'), wopt(L!("all"), ArgType::NoArgument, 'a'), wopt(L!("query"), ArgType::NoArgument, 'q'), diff --git a/src/builtins/history.rs b/src/builtins/history.rs index 725dd1109..3d3307617 100644 --- a/src/builtins/history.rs +++ b/src/builtins/history.rs @@ -66,8 +66,8 @@ struct HistoryCmdOpts { /// the non-flag subcommand form. While many of these flags are deprecated they must be /// supported at least until fish 3.0 and possibly longer to avoid breaking everyones /// config.fish and other scripts. -const short_options: &wstr = L!("CRcehmn:pt::z"); -const longopts: &[WOption] = &[ +const SHORT_OPTIONS: &wstr = L!("CRcehmn:pt::z"); +const LONG_OPTIONS: &[WOption] = &[ wopt(L!("prefix"), ArgType::NoArgument, 'p'), wopt(L!("contains"), ArgType::NoArgument, 'c'), wopt(L!("help"), ArgType::NoArgument, 'h'), @@ -144,7 +144,7 @@ fn parse_cmd_opts( return Err(STATUS_INVALID_ARGS); }; - let mut w = WGetopter::new(short_options, longopts, argv); + let mut w = WGetopter::new(SHORT_OPTIONS, LONG_OPTIONS, argv); while let Some(opt) = w.next_opt() { match opt { '\x01' => { diff --git a/src/builtins/math.rs b/src/builtins/math.rs index 98a633259..4a8982119 100644 --- a/src/builtins/math.rs +++ b/src/builtins/math.rs @@ -33,7 +33,7 @@ fn parse_cmd_opts( parser: &Parser, streams: &mut IoStreams, ) -> Result<(Options, usize), ErrorCode> { - const cmd: &wstr = L!("math"); + let cmd = L!("math"); let print_hints = true; // This command is atypical in using the "+" (REQUIRE_ORDER) option for flag parsing. diff --git a/src/builtins/random.rs b/src/builtins/random.rs index dc3d0d24d..2afdf87d9 100644 --- a/src/builtins/random.rs +++ b/src/builtins/random.rs @@ -15,8 +15,8 @@ pub fn random(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> B let argc = argv.len(); let print_hints = false; - const shortopts: &wstr = L!("+h"); - const longopts: &[WOption] = &[wopt(L!("help"), ArgType::NoArgument, 'h')]; + let shortopts: &wstr = L!("+h"); + let longopts: &[WOption] = &[wopt(L!("help"), ArgType::NoArgument, 'h')]; let mut w = WGetopter::new(shortopts, longopts, argv); #[allow(clippy::never_loop)] diff --git a/src/builtins/shared.rs b/src/builtins/shared.rs index bd403a816..8c6c268b1 100644 --- a/src/builtins/shared.rs +++ b/src/builtins/shared.rs @@ -737,8 +737,8 @@ pub fn parse( let cmd = args[0]; let print_hints = true; - const shortopts: &wstr = L!("+h"); - const longopts: &[WOption] = &[wopt(L!("help"), ArgType::NoArgument, 'h')]; + let shortopts: &wstr = L!("+h"); + let longopts: &[WOption] = &[wopt(L!("help"), ArgType::NoArgument, 'h')]; let mut print_help = false; let mut w = WGetopter::new(shortopts, longopts, args); diff --git a/src/builtins/type.rs b/src/builtins/type.rs index e9677c63e..c68dcad42 100644 --- a/src/builtins/type.rs +++ b/src/builtins/type.rs @@ -23,8 +23,8 @@ pub fn r#type(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> B let print_hints = false; let mut opts: type_cmd_opts_t = Default::default(); - const shortopts: &wstr = L!("hasftpPq"); - const longopts: &[WOption] = &[ + let shortopts: &wstr = L!("hasftpPq"); + let longopts: &[WOption] = &[ wopt(L!("help"), ArgType::NoArgument, 'h'), wopt(L!("all"), ArgType::NoArgument, 'a'), wopt(L!("short"), ArgType::NoArgument, 's'), diff --git a/src/builtins/wait.rs b/src/builtins/wait.rs index efadf241e..9b096ac1d 100644 --- a/src/builtins/wait.rs +++ b/src/builtins/wait.rs @@ -140,8 +140,8 @@ pub fn wait(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Bui let mut print_help = false; let print_hints = false; - const shortopts: &wstr = L!("nh"); - const longopts: &[WOption] = &[ + let shortopts: &wstr = L!("nh"); + let longopts: &[WOption] = &[ wopt(L!("any"), ArgType::NoArgument, 'n'), wopt(L!("help"), ArgType::NoArgument, 'h'), ]; diff --git a/src/parse_util.rs b/src/parse_util.rs index 88e5da55a..38a5b7d92 100644 --- a/src/parse_util.rs +++ b/src/parse_util.rs @@ -37,8 +37,8 @@ /// Return the length of the slice starting at `in`, or 0 if there is no slice, or None on error. /// This never accepts incomplete slices. pub fn parse_util_slice_length(input: &wstr) -> Option { - const openc: char = '['; - const closec: char = ']'; + let openc = '['; + let closec = ']'; let mut escaped = false; // Check for initial opening [ @@ -2082,7 +2082,7 @@ macro_rules! validate { #[serial] fn test_parse_util_cmdsubst_extent() { let _cleanup = test_init(); - const a: &wstr = L!("echo (echo (echo hi"); + let a = L!("echo (echo (echo hi"); assert_eq!(parse_util_cmdsubst_extent(a, 0), 0..a.len()); assert_eq!(parse_util_cmdsubst_extent(a, 1), 0..a.len()); assert_eq!(parse_util_cmdsubst_extent(a, 2), 0..a.len()); diff --git a/src/topic_monitor.rs b/src/topic_monitor.rs index 3aca297a2..2bb776fe4 100644 --- a/src/topic_monitor.rs +++ b/src/topic_monitor.rs @@ -362,7 +362,7 @@ pub fn post(&self, topic: Topic) { // Beware, we may be in a signal handler! // Atomically update the pending topics. let topicbit = topic_to_bit(topic); - const relaxed: Ordering = Ordering::Relaxed; + let relaxed = Ordering::Relaxed; // CAS in our bit, capturing the old status value. let mut oldstatus: StatusBits = 0; @@ -405,7 +405,7 @@ fn updated_gens_in_data(&self, data: &mut MutexGuard) -> GenerationsList // Atomically acquire the pending updates, swapping in 0. // If there are no pending updates (likely) or a thread is waiting, just return. // Otherwise CAS in 0 and update our topics. - const relaxed: Ordering = Ordering::Relaxed; + let relaxed = Ordering::Relaxed; let mut changed_topic_bits: TopicBitmask = 0; let mut cas_success = false; while !cas_success { diff --git a/src/wutil/mod.rs b/src/wutil/mod.rs index c37d01a21..9b00236dd 100644 --- a/src/wutil/mod.rs +++ b/src/wutil/mod.rs @@ -607,7 +607,7 @@ fn norm_path(path: &wstr) -> WString { fn test_wdirname_wbasename() { // path, dir, base struct Test(&'static wstr, &'static wstr, &'static wstr); - const testcases: &[Test] = &[ + let testcases: &[Test] = &[ Test(L!(""), L!("."), L!(".")), Test(L!("foo//"), L!("."), L!("foo")), Test(L!("foo//////"), L!("."), L!("foo")),