Remove dead code, enable dead_code lint

This commit is contained in:
Johannes Altmanninger 2024-01-13 01:59:06 +01:00
parent 5512f44899
commit 65064ac976
39 changed files with 56 additions and 221 deletions

View file

@ -75,7 +75,6 @@ bsd = []
[lints]
rust.non_camel_case_types = "allow"
rust.dead_code = "allow"
rust.non_upper_case_globals = "allow"
rust.unstable_name_collisions = "allow"
clippy.bool_assert_comparison = "allow"

View file

@ -266,10 +266,6 @@ pub fn abbrs_match(token: &wstr, position: Position) -> Vec<Replacer> {
.collect()
}
pub struct GlobalAbbrs<'a> {
g: MutexGuard<'a, AbbreviationSet>,
}
#[test]
#[serial]
fn rename_abbrs() {

View file

@ -1947,19 +1947,6 @@ impl ArgumentOrRedirectionVariant {
self.embedded_node().try_source_range()
}
fn as_argument(&self) -> Option<&Argument> {
match self {
ArgumentOrRedirectionVariant::Argument(node) => Some(node),
_ => None,
}
}
fn as_redirection(&self) -> Option<&Redirection> {
match self {
ArgumentOrRedirectionVariant::Redirection(redirection) => Some(redirection),
_ => None,
}
}
fn embedded_node(&self) -> &dyn NodeMut {
match self {
ArgumentOrRedirectionVariant::Argument(node) => node,

View file

@ -119,6 +119,7 @@ impl Autoload {
/// Invalidate any underlying cache.
/// This is exposed for testing.
#[cfg(test)]
fn invalidate_cache(&mut self) {
self.cache = Box::new(AutoloadFileCache::with_dirs(self.cache.dirs().to_owned()));
}

View file

@ -23,7 +23,6 @@ use crate::{
// FIXME: (once localization works in Rust) These should separate `%ls: ` and the trailing `\n`, like in builtins/string
const MISMATCHED_ARGS: &str = "%ls: given %d indexes but %d values\n";
const ARRAY_BOUNDS_ERR: &str = "%ls: array index out of bounds\n";
const UVAR_ERR: &str =
"%ls: successfully set universal '%ls'; but a global by that name shadows it\n";
@ -935,8 +934,6 @@ fn set_internal(
// Setting with explicit indexes like `set foo[3] ...` has additional error handling.
if !split.indexes.is_empty() {
// Indexes must be > 0. (Note split_var_and_indexes negates negative values).
// Append and prepend are disallowed.
if opts.append || opts.prepend {
streams.err.append(wgettext_fmt!(

View file

@ -259,7 +259,6 @@ mod test_expressions {
/// Parenthentical expression.
struct ParentheticalExpression {
contents: Box<dyn Expression>,
token: Token,
range: Range,
}
@ -572,7 +571,6 @@ mod test_expressions {
// Success.
ParentheticalExpression {
contents: subexpr,
token: Token::paren_open,
range: start..close_index + 1,
}
.into_some_box()

View file

@ -14,7 +14,6 @@ struct type_cmd_opts_t {
get_type: bool,
path: bool,
force_path: bool,
print_help: bool,
query: bool,
}

View file

@ -316,7 +316,7 @@ fn simple_icase_compare(s1: &wstr, s2: &wstr) -> Ordering {
struct NamedColor {
name: &'static wstr,
idx: u8,
rgb: [u8; 3],
_rgb: [u8; 3],
hidden: bool,
}
@ -324,28 +324,28 @@ struct NamedColor {
#[rustfmt::skip]
const NAMED_COLORS: &[NamedColor] = &[
// Keep this sorted alphabetically
NamedColor {name: "black"L, idx: 0, rgb: [0x00, 0x00, 0x00], hidden: false},
NamedColor {name: "blue"L, idx: 4, rgb: [0x00, 0x00, 0x80], hidden: false},
NamedColor {name: "brblack"L, idx: 8, rgb: [0x80, 0x80, 0x80], hidden: false},
NamedColor {name: "brblue"L, idx: 12, rgb: [0x00, 0x00, 0xFF], hidden: false},
NamedColor {name: "brbrown"L, idx: 11, rgb: [0xFF, 0xFF, 0x00], hidden: true},
NamedColor {name: "brcyan"L, idx: 14, rgb: [0x00, 0xFF, 0xFF], hidden: false},
NamedColor {name: "brgreen"L, idx: 10, rgb: [0x00, 0xFF, 0x00], hidden: false},
NamedColor {name: "brgrey"L, idx: 8, rgb: [0x55, 0x55, 0x55], hidden: true},
NamedColor {name: "brmagenta"L, idx: 13, rgb: [0xFF, 0x00, 0xFF], hidden: false},
NamedColor {name: "brown"L, idx: 3, rgb: [0x72, 0x50, 0x00], hidden: true},
NamedColor {name: "brpurple"L, idx: 13, rgb: [0xFF, 0x00, 0xFF], hidden: true},
NamedColor {name: "brred"L, idx: 9, rgb: [0xFF, 0x00, 0x00], hidden: false},
NamedColor {name: "brwhite"L, idx: 15, rgb: [0xFF, 0xFF, 0xFF], hidden: false},
NamedColor {name: "bryellow"L, idx: 11, rgb: [0xFF, 0xFF, 0x00], hidden: false},
NamedColor {name: "cyan"L, idx: 6, rgb: [0x00, 0x80, 0x80], hidden: false},
NamedColor {name: "green"L, idx: 2, rgb: [0x00, 0x80, 0x00], hidden: false},
NamedColor {name: "grey"L, idx: 7, rgb: [0xE5, 0xE5, 0xE5], hidden: true},
NamedColor {name: "magenta"L, idx: 5, rgb: [0x80, 0x00, 0x80], hidden: false},
NamedColor {name: "purple"L, idx: 5, rgb: [0x80, 0x00, 0x80], hidden: true},
NamedColor {name: "red"L, idx: 1, rgb: [0x80, 0x00, 0x00], hidden: false},
NamedColor {name: "white"L, idx: 7, rgb: [0xC0, 0xC0, 0xC0], hidden: false},
NamedColor {name: "yellow"L, idx: 3, rgb: [0x80, 0x80, 0x00], hidden: false},
NamedColor {name: "black"L, idx: 0, _rgb: [0x00, 0x00, 0x00], hidden: false},
NamedColor {name: "blue"L, idx: 4, _rgb: [0x00, 0x00, 0x80], hidden: false},
NamedColor {name: "brblack"L, idx: 8, _rgb: [0x80, 0x80, 0x80], hidden: false},
NamedColor {name: "brblue"L, idx: 12, _rgb: [0x00, 0x00, 0xFF], hidden: false},
NamedColor {name: "brbrown"L, idx: 11, _rgb: [0xFF, 0xFF, 0x00], hidden: true},
NamedColor {name: "brcyan"L, idx: 14, _rgb: [0x00, 0xFF, 0xFF], hidden: false},
NamedColor {name: "brgreen"L, idx: 10, _rgb: [0x00, 0xFF, 0x00], hidden: false},
NamedColor {name: "brgrey"L, idx: 8, _rgb: [0x55, 0x55, 0x55], hidden: true},
NamedColor {name: "brmagenta"L, idx: 13, _rgb: [0xFF, 0x00, 0xFF], hidden: false},
NamedColor {name: "brown"L, idx: 3, _rgb: [0x72, 0x50, 0x00], hidden: true},
NamedColor {name: "brpurple"L, idx: 13, _rgb: [0xFF, 0x00, 0xFF], hidden: true},
NamedColor {name: "brred"L, idx: 9, _rgb: [0xFF, 0x00, 0x00], hidden: false},
NamedColor {name: "brwhite"L, idx: 15, _rgb: [0xFF, 0xFF, 0xFF], hidden: false},
NamedColor {name: "bryellow"L, idx: 11, _rgb: [0xFF, 0xFF, 0x00], hidden: false},
NamedColor {name: "cyan"L, idx: 6, _rgb: [0x00, 0x80, 0x80], hidden: false},
NamedColor {name: "green"L, idx: 2, _rgb: [0x00, 0x80, 0x00], hidden: false},
NamedColor {name: "grey"L, idx: 7, _rgb: [0xE5, 0xE5, 0xE5], hidden: true},
NamedColor {name: "magenta"L, idx: 5, _rgb: [0x80, 0x00, 0x80], hidden: false},
NamedColor {name: "purple"L, idx: 5, _rgb: [0x80, 0x00, 0x80], hidden: true},
NamedColor {name: "red"L, idx: 1, _rgb: [0x80, 0x00, 0x00], hidden: false},
NamedColor {name: "white"L, idx: 7, _rgb: [0xC0, 0xC0, 0xC0], hidden: false},
NamedColor {name: "yellow"L, idx: 3, _rgb: [0x80, 0x80, 0x00], hidden: false},
];
assert_sorted_by_name!(NAMED_COLORS);

View file

@ -2527,13 +2527,6 @@ pub struct CompletionRequestOptions {
pub fuzzy_match: bool,
}
fn completion_request_options_autosuggest() -> CompletionRequestOptions {
CompletionRequestOptions::autosuggest()
}
fn completion_request_options_normal() -> CompletionRequestOptions {
CompletionRequestOptions::normal()
}
impl Default for CompletionRequestOptions {
fn default() -> Self {
Self {
@ -2543,18 +2536,3 @@ impl Default for CompletionRequestOptions {
}
}
}
impl Completion {
fn flags(&self) -> u8 {
self.flags.bits()
}
fn set_flags(&mut self, value: u8) {
self.flags = CompleteFlags::from_bits(value).unwrap();
}
fn match_is_exact_or_prefix(&self) -> bool {
self.r#match.is_exact_or_prefix()
}
fn completion_erase(&mut self, begin: usize, end: usize) {
self.completion.replace_range(begin..end, L!(""))
}
}

View file

@ -54,7 +54,6 @@ fn try_ptr_to_cstr(ptr: *const libc::c_char) -> Option<CString> {
/// Private module exposing system curses ffi.
mod sys {
pub const OK: i32 = 0;
pub const ERR: i32 = -1;
/// tputs callback argument type and the callback type itself.
/// N.B. The C++ had a check for TPUTS_USES_INT_ARG for the first parameter of tputs
@ -481,7 +480,6 @@ pub fn reset() {
/// Panics if the given code string does not contain exactly two bytes.
fn get_str_cap(code: &str) -> Option<CString> {
let code = to_cstr_code(code);
const NULL: *const i8 = core::ptr::null();
// termcap spec says nul is not allowed in terminal sequences and must be encoded;
// so the terminating NUL is the end of the string.
let tstr = unsafe { sys::tgetstr(code.as_ptr(), core::ptr::null_mut()) };

View file

@ -38,9 +38,6 @@ use std::os::unix::prelude::*;
use std::pin::Pin;
use std::sync::{Arc, Mutex};
/// TODO: migrate to history once ported.
const DFLT_FISH_HISTORY_SESSION_ID: &wstr = L!("fish");
// Universal variables instance.
lazy_static! {
static ref UVARS: Mutex<EnvUniversal> = Mutex::new(EnvUniversal::new());

View file

@ -24,9 +24,6 @@ use std::ops::{Deref, DerefMut};
use std::sync::{atomic::AtomicU64, atomic::Ordering, Arc, Mutex, MutexGuard};
/// TODO: migrate to history once ported.
const DFLT_FISH_HISTORY_SESSION_ID: &wstr = L!("fish");
// Universal variables instance.
lazy_static! {
static ref UVARS: Mutex<EnvUniversal> = Mutex::new(EnvUniversal::new());
@ -529,19 +526,6 @@ impl EnvScopedImpl {
pwd
}
// todo!("these two are clones from the trait")
fn get_unless_empty(&self, name: &wstr) -> Option<EnvVar> {
self.getf_unless_empty(name, EnvMode::default())
}
fn getf_unless_empty(&self, name: &wstr, mode: EnvMode) -> Option<EnvVar> {
let var = self.getf(name, mode)?;
if !var.is_empty() {
return Some(var);
}
None
}
/// Return a copy of self, with copied locals but shared globals.
pub fn snapshot(&self) -> EnvMutex<Self> {
EnvMutex::new(EnvScopedImpl {
@ -1106,7 +1090,7 @@ static ENV_LOCK: Mutex<()> = Mutex::new(());
/// Like MutexGuard but for our global lock.
pub struct EnvMutexGuard<'a, T: 'a> {
guard: MutexGuard<'static, ()>,
_guard: MutexGuard<'static, ()>,
value: *mut T,
_phantom: PhantomData<&'a T>,
}
@ -1143,7 +1127,7 @@ impl<T> EnvMutex<T> {
// Safety: we have the global lock.
let value = unsafe { &mut *self.inner.get() };
EnvMutexGuard {
guard,
_guard: guard,
value,
_phantom: PhantomData,
}

View file

@ -292,11 +292,6 @@ impl ElectricVar {
pub fn exports(&self) -> bool {
self.flags & electric::EXPORTS != 0
}
/// Supports assert_sorted_by_name.
fn as_char_slice(&self) -> &[char] {
self.name.as_char_slice()
}
}
/// Check if a variable may not be set using the set command.

View file

@ -864,12 +864,6 @@ mod fish3_uvars {
pub const PATH: &[u8] = b"--path";
}
/// The different types of messages found in the fishd file.
enum UvarMessageType {
set,
set_export,
}
/// \return the default variable path, or an empty string on failure.
fn default_vars_path_directory() -> Option<WString> {
path_get_config()

View file

@ -199,12 +199,6 @@ impl EventHandler {
}
type EventHandlerList = Vec<Arc<EventHandler>>;
impl EventHandler {
fn set_removed(self: &mut EventHandler) {
self.removed.store(true, Ordering::Relaxed);
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Event {
desc: EventDescription,

View file

@ -420,7 +420,6 @@ fn is_quotable(s: &wstr) -> bool {
}
enum ParseSliceError {
none,
zero_index,
invalid_index,
}
@ -671,9 +670,6 @@ fn expand_variables(
}
Err((bad_pos, error)) => {
match error {
ParseSliceError::none => {
panic!("bad_pos != 0 but parse_slice_error_t::none!");
}
ParseSliceError::zero_index => {
append_syntax_error!(
errors,
@ -1023,9 +1019,6 @@ pub fn expand_cmdsubst(
Ok(offset) => slice_begin + offset,
Err((bad_pos, error)) => {
match error {
ParseSliceError::none => {
panic!("bad_pos != 0 but parse_slice_error_t::none!");
}
ParseSliceError::zero_index => {
append_syntax_error!(
errors,

View file

@ -30,7 +30,9 @@ pub struct fd_readable_set_t {
nfds_: c_int,
}
#[allow(dead_code)]
const kUsecPerMsec: u64 = 1000;
#[allow(dead_code)]
const kUsecPerSec: u64 = 1000 * kUsecPerMsec;
#[cfg(target_os = "macos")]

View file

@ -58,10 +58,6 @@ impl Write for AutoCloseFd {
}
}
fn new_autoclose_fd(fd: i32) -> Box<AutoCloseFd> {
Box::new(AutoCloseFd::new(fd))
}
impl AutoCloseFd {
// Closes the fd if not already closed.
pub fn close(&mut self) {

View file

@ -198,19 +198,17 @@ const INPUT_FUNCTION_METADATA: &[InputFunctionMetadata] = &[
];
assert_sorted_by_name!(INPUT_FUNCTION_METADATA);
const INPUT_FUNCTION_COUNT: usize = R_END_INPUT_FUNCTIONS;
#[allow(dead_code)]
const fn assert_sizes_match() {
const fn _assert_sizes_match() {
let input_function_count = R_END_INPUT_FUNCTIONS;
assert!(
INPUT_FUNCTION_METADATA.len() == INPUT_FUNCTION_COUNT,
INPUT_FUNCTION_METADATA.len() == input_function_count,
concat!(
"input_function_metadata size mismatch with input_common. ",
"Did you forget to update input_function_metadata?"
)
);
}
const _: () = assert_sizes_match();
const _: () = _assert_sizes_match();
// Keep this function for debug purposes
// See 031b265

View file

@ -141,16 +141,6 @@ impl SeparatedBuffer {
!self.elements.is_empty() && !self.elements.last().unwrap().is_explicitly_separated()
}
/// If our last element has an inferred separation, return a pointer to it; else nullptr.
/// This is useful for appending one inferred separation to another.
fn last_if_inferred(&self) -> Option<&BufferElement> {
if self.last_inferred() {
self.elements.last()
} else {
None
}
}
/// Mark that we are about to add the given size \p delta to the buffer. \return true if we
/// succeed, false if we exceed buffer_limit.
fn try_add_size(&mut self, delta: usize) -> bool {

View file

@ -20,6 +20,7 @@ impl KillRing {
}
/// Return whether this killring is empty.
#[cfg(test)]
fn is_empty(&self) -> bool {
self.0.is_empty()
}

View file

@ -1,7 +1,6 @@
// Delete this once we require Rust 1.74.
#![cfg_attr(feature = "benchmark", feature(test))]
#![allow(non_camel_case_types)]
#![allow(dead_code)]
#![allow(non_upper_case_globals)]
#![allow(unstable_name_collisions)]
#![allow(clippy::bool_assert_comparison)]

View file

@ -2,9 +2,6 @@
pub use printf_compat::locale::{Locale, C_LOCALE};
use std::sync::Mutex;
/// Rust libc does not provide LC_GLOBAL_LOCALE, but it appears to be -1 everywhere.
const LC_GLOBAL_LOCALE: libc::locale_t = (-1_isize) as libc::locale_t;
/// It's CHAR_MAX.
const CHAR_MAX: libc::c_char = libc::c_char::max_value();
@ -58,11 +55,6 @@ unsafe fn lconv_to_locale(lconv: &libc::lconv) -> Locale {
}
}
// Declare localeconv_l as an extern C function as libc does not have it.
extern "C" {
fn localeconv_l(loc: libc::locale_t) -> *const libc::lconv;
}
/// Read the numeric locale, or None on any failure.
// TODO: figure out precisely which platforms have localeconv_l, or use a build script.
#[cfg(any(
@ -73,6 +65,12 @@ extern "C" {
target_os = "netbsd",
))]
unsafe fn read_locale() -> Option<Locale> {
extern "C" {
fn localeconv_l(loc: libc::locale_t) -> *const libc::lconv;
}
/// Rust libc does not provide LC_GLOBAL_LOCALE, but it appears to be -1 everywhere.
const LC_GLOBAL_LOCALE: libc::locale_t = (-1_isize) as libc::locale_t;
const empty: [libc::c_char; 1] = [0];
let cur = libc::duplocale(LC_GLOBAL_LOCALE);
if cur.is_null() {

View file

@ -95,7 +95,7 @@ unsafe impl<T: NulTerminatedString + ?Sized + Sync> Sync for NullTerminatedArray
pub struct OwningNullTerminatedArray {
// Note that null_terminated_array holds pointers into our boxed strings.
// The 'static is a lie.
strings: Pin<Box<[CString]>>,
_strings: Pin<Box<[CString]>>,
null_terminated_array: NullTerminatedArray<'static, CStr>,
}
@ -120,7 +120,7 @@ impl OwningNullTerminatedArray {
// Safety: we're pinning the strings, so they won't move.
let string_slice: &'static [CString] = unsafe { std::mem::transmute(&*strings) };
OwningNullTerminatedArray {
strings: Pin::from(strings),
_strings: Pin::from(strings),
null_terminated_array: NullTerminatedArray::new(string_slice),
}
}

View file

@ -402,15 +402,6 @@ impl ParseError {
}
}
impl ParseError {
fn code(&self) -> ParseErrorCode {
self.code
}
fn source_start(&self) -> usize {
self.source_start
}
}
#[widestrs]
pub fn token_type_user_presentable_description(
type_: ParseTokenType,

View file

@ -144,11 +144,6 @@ impl ProcStatus {
self.value.store(value, Ordering::Relaxed);
}
fn set_empty(&self, empty: bool) {
let value = Self::to_u64(self.status(), empty);
self.value.store(value, Ordering::Relaxed);
}
fn to_u64(status: i32, empty: bool) -> u64 {
(u64::from(empty) << 32) | u64::from(status as u32)
}
@ -185,9 +180,9 @@ impl ProcStatus {
);
// Some paranoia.
const zerocode: i32 = ProcStatus::w_exitcode(0, 0);
const _zerocode: i32 = ProcStatus::w_exitcode(0, 0);
const _: () = assert!(
WIFEXITED(zerocode),
WIFEXITED(_zerocode),
"Synthetic exit status not reported as exited"
);

View file

@ -89,14 +89,6 @@ impl RedirectionSpec {
None => panic!("Not a file redirection"),
}
}
fn fd(&self) -> RawFd {
self.fd
}
fn mode(&self) -> RedirectionMode {
self.mode
}
}
pub type RedirectionSpecList = Vec<RedirectionSpec>;

View file

@ -133,10 +133,6 @@ pub struct ScreenData {
}
impl ScreenData {
fn new() -> Self {
Default::default()
}
pub fn add_line(&mut self) -> &mut Line {
self.line_datas.push(Line::new());
self.line_datas.last_mut().unwrap()
@ -852,15 +848,9 @@ impl Screen {
fn o_line(zelf: &Screen, i: usize) -> &Line {
zelf.desired.line(i)
}
fn o_line_mut(zelf: &mut Screen, i: usize) -> &mut Line {
zelf.desired.line_mut(i)
}
fn s_line(zelf: &Screen, i: usize) -> &Line {
zelf.actual.line(i)
}
fn s_line_mut(zelf: &mut Screen, i: usize) -> &mut Line {
zelf.actual.line_mut(i)
}
// Output all lines.
for i in 0..zelf.desired.line_count() {

View file

@ -531,10 +531,6 @@ fn test_signal_name() {
assert_eq!(sig.name(), "SIGINT");
}
fn new_sighupint_checker() -> Box<SigChecker> {
Box::new(SigChecker::new_sighupint())
}
#[rustfmt::skip]
#[test]
fn test_signal_parse() {

View file

@ -67,7 +67,7 @@ fn test_debounce() {
while !ctx.completion_ran.last().unwrap().load() {
iothread_service_main(reader_data);
}
unsafe { iothread_drain_all(reader_data) };
iothread_drain_all(reader_data);
// Each perform() call may displace an existing queued operation.
// Each operation waits until all are queued.

View file

@ -13,6 +13,7 @@ pub struct TestEnvironment {
pub vars: HashMap<WString, WString>,
}
impl TestEnvironment {
#[allow(dead_code)]
pub fn new() -> Self {
Self::default()
}
@ -34,6 +35,7 @@ pub struct PwdEnvironment {
pub parent: TestEnvironment,
}
impl PwdEnvironment {
#[allow(dead_code)]
pub fn new() -> Self {
Self::default()
}

View file

@ -50,7 +50,7 @@ fn test_universal() {
for i in 0..threads {
iothread_perform(move || test_universal_helper(i));
}
unsafe { iothread_drain_all(reader_current_data().unwrap()) };
iothread_drain_all(reader_current_data().unwrap());
let mut uvars = EnvUniversal::new();
let mut callbacks = CallbackDataList::new();

View file

@ -711,9 +711,7 @@ fn test_1_cancellation(src: &wstr) {
src
);
assert!(res.status.signal_exited() && res.status.signal_code() == SIGINT);
unsafe {
iothread_drain_all(reader_current_data().unwrap());
}
iothread_drain_all(reader_current_data().unwrap());
}
#[test]

View file

@ -486,8 +486,9 @@ pub fn iothread_service_main(ctx: &mut ReaderData) {
}
}
/// Does nasty polling via select() and marked as unsafe because it should only be used for testing.
pub(crate) unsafe fn iothread_drain_all(ctx: &mut ReaderData) {
/// Does nasty polling via select(), only used for testing.
#[cfg(test)]
pub(crate) fn iothread_drain_all(ctx: &mut ReaderData) {
while borrow_io_thread_pool()
.shared
.mutex

View file

@ -41,7 +41,6 @@ use crate::{
#[derive(Clone, Copy)]
enum Function {
Constant(f64),
Fn0(fn() -> f64),
Fn1(fn(f64) -> f64),
Fn2(fn(f64, f64) -> f64),
FnN(fn(&[f64]) -> f64),
@ -51,7 +50,6 @@ impl Debug for Function {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let variant = match self {
Function::Constant(n) => return f.debug_tuple("Function::Constant").field(n).finish(),
Function::Fn0(_) => "Fn0",
Function::Fn1(_) => "Fn1",
Function::Fn2(_) => "Fn2",
Function::FnN(_) => "FnN",
@ -65,7 +63,6 @@ impl Function {
pub fn arity(&self) -> Option<usize> {
match self {
Function::Constant(_) => Some(0),
Function::Fn0(_) => Some(0),
Function::Fn1(_) => Some(1),
Function::Fn2(_) => Some(2),
Function::FnN(_) => None,
@ -75,7 +72,6 @@ impl Function {
pub fn call(&self, args: &[f64]) -> f64 {
match (self, args) {
(Function::Constant(n), []) => *n,
(Function::Fn0(f), []) => f(),
(Function::Fn1(f), [a]) => f(*a),
(Function::Fn2(f), [a, b]) => f(*a, *b),
(Function::FnN(f), args) => f(args),
@ -152,7 +148,6 @@ impl Operator {
#[derive(Debug, Clone, Copy)]
enum Token {
Null,
Error,
End,
Sep,
@ -529,7 +524,6 @@ impl<'s> State<'s> {
}
return match f {
Function::Fn0(f) => f(),
Function::Constant(n) => n,
_ => unreachable!("unhandled function type with arity 0"),
};
@ -631,7 +625,7 @@ impl<'s> State<'s> {
NAN
}
Token::Null | Token::Error | Token::Sep | Token::Close | Token::Infix(_) => {
Token::Error | Token::Sep | Token::Close | Token::Infix(_) => {
if self.no_specific_error() {
self.set_error(ErrorKind::UnexpectedToken, None);
}

View file

@ -1072,10 +1072,6 @@ fn parse_fd(s: &wstr) -> RawFd {
s.parse().unwrap_or(-1)
}
fn new_move_word_state_machine(syl: MoveWordStyle) -> Box<MoveWordStateMachine> {
Box::new(MoveWordStateMachine::new(syl))
}
impl MoveWordStateMachine {
pub fn new(style: MoveWordStyle) -> Self {
MoveWordStateMachine { state: 0, style }

View file

@ -4,14 +4,6 @@ use crate::wchar::prelude::*;
use std::cmp::Ordering;
use std::time;
fn ordering_to_int(ord: Ordering) -> i32 {
match ord {
Ordering::Less => -1,
Ordering::Equal => 0,
Ordering::Greater => 1,
}
}
/// Compares two wide character strings with an (arguably) intuitive ordering. This function tries
/// to order strings in a way which is intuitive to humans with regards to sorting strings
/// containing numbers.

View file

@ -24,15 +24,9 @@ use once_cell::sync::Lazy;
static COMPLETE_EXEC_DESC: Lazy<&wstr> = Lazy::new(|| wgettext!("command"));
static COMPLETE_EXEC_LINK_DESC: Lazy<&wstr> = Lazy::new(|| wgettext!("command link"));
static COMPLETE_CHAR_DESC: Lazy<&wstr> = Lazy::new(|| wgettext!("char device"));
static COMPLETE_BLOCK_DESC: Lazy<&wstr> = Lazy::new(|| wgettext!("block device"));
static COMPLETE_FIFO_DESC: Lazy<&wstr> = Lazy::new(|| wgettext!("fifo"));
static COMPLETE_FILE_DESC: Lazy<&wstr> = Lazy::new(|| wgettext!("file"));
static COMPLETE_SYMLINK_DESC: Lazy<&wstr> = Lazy::new(|| wgettext!("symlink"));
static COMPLETE_DIRECTORY_SYMLINK_DESC: Lazy<&wstr> = Lazy::new(|| wgettext!("dir symlink"));
static COMPLETE_BROKEN_SYMLINK_DESC: Lazy<&wstr> = Lazy::new(|| wgettext!("broken symlink"));
static COMPLETE_LOOP_SYMLINK_DESC: Lazy<&wstr> = Lazy::new(|| wgettext!("symlink loop"));
static COMPLETE_SOCKET_DESC: Lazy<&wstr> = Lazy::new(|| wgettext!("socket"));
static COMPLETE_DIRECTORY_DESC: Lazy<&wstr> = Lazy::new(|| wgettext!("directory"));
/// Character representing any character except '/' (slash).

View file

@ -478,10 +478,10 @@ pub fn wwrite_to_fd(input: &wstr, fd: RawFd) -> Option<usize> {
const PUA1_START: char = '\u{E000}';
const PUA1_END: char = '\u{F900}';
const PUA2_START: char = '\u{F0000}';
const PUA2_END: char = '\u{FFFFE}';
const PUA3_START: char = '\u{100000}';
const PUA3_END: char = '\u{10FFFE}';
// const PUA2_START: char = '\u{F0000}';
// const PUA2_END: char = '\u{FFFFE}';
// const PUA3_START: char = '\u{100000}';
// const PUA3_END: char = '\u{10FFFE}';
/// Return one if the code point is in a Unicode private use area.
fn fish_is_pua(c: char) -> bool {