mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-31 20:31:19 -03:00
committed by
Johannes Altmanninger
parent
8718d62b11
commit
d35edcf5fa
@@ -266,7 +266,7 @@ fn should_round_up(&self, digit_idx: i32, remainder: u32, mod_base: u32) -> bool
|
||||
if rounding_digit & 1 != 0 {
|
||||
round += 2.0;
|
||||
// round now has an odd lsb (though round itself is even).
|
||||
debug_assert!(round.to_bits() & 1 != 0);
|
||||
debug_assert_ne!(round.to_bits() & 1, 0);
|
||||
}
|
||||
|
||||
// Set 'small' to a value which is less than halfway, exactly halfway, or more than halfway
|
||||
|
||||
15
src/ast.rs
15
src/ast.rs
@@ -2131,12 +2131,10 @@ fn peek_type(&mut self, idx: usize) -> ParseTokenType {
|
||||
/// Return the token.
|
||||
fn consume_any_token(&mut self) -> ParseToken {
|
||||
let tok = self.tokens.pop();
|
||||
assert!(
|
||||
tok.typ != ParseTokenType::Comment,
|
||||
"Should not be a comment"
|
||||
);
|
||||
assert!(
|
||||
tok.typ != ParseTokenType::Terminate,
|
||||
assert_ne!(tok.typ, ParseTokenType::Comment, "Should not be a comment");
|
||||
assert_ne!(
|
||||
tok.typ,
|
||||
ParseTokenType::Terminate,
|
||||
"Cannot consume terminate token, caller should check status first"
|
||||
);
|
||||
tok
|
||||
@@ -2144,8 +2142,9 @@ fn consume_any_token(&mut self) -> ParseToken {
|
||||
|
||||
/// Consume the next token which is expected to be of the given type.
|
||||
fn consume_token_type(&mut self, typ: ParseTokenType) -> SourceRange {
|
||||
assert!(
|
||||
typ != ParseTokenType::Terminate,
|
||||
assert_ne!(
|
||||
typ,
|
||||
ParseTokenType::Terminate,
|
||||
"Should not attempt to consume terminate token"
|
||||
);
|
||||
let tok = self.consume_any_token();
|
||||
|
||||
@@ -116,7 +116,7 @@ pub fn ok() -> Self {
|
||||
}
|
||||
/// Make an error value with the given status.
|
||||
pub fn make_error(status: libc::c_int) -> Self {
|
||||
assert!(status != 0, "status cannot be 0 for an error result");
|
||||
assert_ne!(status, 0, "status cannot be 0 for an error result");
|
||||
Self {
|
||||
result: ExpandResultCode::error,
|
||||
status,
|
||||
|
||||
@@ -340,7 +340,7 @@ fn test_pipes() {
|
||||
assert!(fd >= FIRST_HIGH_FD);
|
||||
let flags = unsafe { libc::fcntl(fd, F_GETFD, 0) };
|
||||
assert!(flags >= 0);
|
||||
assert!(flags & FD_CLOEXEC != 0);
|
||||
assert_ne!(flags & FD_CLOEXEC, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ pub fn execute_setpgid(pid: libc::pid_t, pgroup: libc::pid_t, is_parent: bool) -
|
||||
return 0;
|
||||
}
|
||||
let err = errno::errno().0;
|
||||
assert!(err != libc::EINTR);
|
||||
assert_ne!(err, libc::EINTR);
|
||||
if err == libc::EACCES && is_parent {
|
||||
// We are the parent process and our child has called exec().
|
||||
// This is an unavoidable benign race.
|
||||
|
||||
@@ -41,7 +41,7 @@ impl MmapRegion {
|
||||
///
|
||||
/// `ptr` must be the result of a successful `mmap()` call with length `len`.
|
||||
unsafe fn new(ptr: *mut u8, len: usize) -> Self {
|
||||
assert!(ptr.cast() != MAP_FAILED);
|
||||
assert_ne!(ptr.cast(), MAP_FAILED);
|
||||
assert!(len > 0);
|
||||
Self { ptr, len }
|
||||
}
|
||||
|
||||
@@ -819,7 +819,7 @@ fn resolve_pending(&mut self) {
|
||||
/// Enable / disable automatic saving. Main thread only!
|
||||
fn disable_automatic_saving(&mut self) {
|
||||
self.disable_automatic_save_counter += 1;
|
||||
assert!(self.disable_automatic_save_counter != 0); // overflow!
|
||||
assert_ne!(self.disable_automatic_save_counter, 0); // overflow!
|
||||
}
|
||||
|
||||
fn enable_automatic_saving(&mut self) {
|
||||
@@ -1570,7 +1570,7 @@ pub fn original_term(&self) -> &wstr {
|
||||
}
|
||||
|
||||
pub fn prepare_to_search_after_deletion(&mut self) {
|
||||
assert!(self.current_index != 0);
|
||||
assert_ne!(self.current_index, 0);
|
||||
self.current_index -= 1;
|
||||
self.current_item = None;
|
||||
}
|
||||
|
||||
@@ -720,18 +720,18 @@ pub fn function_set_status(&mut self, status: bool) {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Default, Eq, PartialEq)]
|
||||
#[derive(Clone, Debug, Default, Eq, PartialEq)]
|
||||
pub struct BackgroundColorQuery {
|
||||
pub result: Option<xterm_color::Color>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Eq, PartialEq)]
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub enum CursorPositionQueryReason {
|
||||
NewPrompt,
|
||||
WindowHeightChange,
|
||||
}
|
||||
|
||||
#[derive(Clone, Eq, PartialEq)]
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct CursorPositionQuery {
|
||||
pub reason: CursorPositionQueryReason,
|
||||
pub result: Option<ViewportPosition>,
|
||||
@@ -746,7 +746,7 @@ pub fn new(reason: CursorPositionQueryReason) -> Self {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Default, Eq, PartialEq)]
|
||||
#[derive(Clone, Debug, Default, Eq, PartialEq)]
|
||||
pub struct RecurrentQuery {
|
||||
pub background_color: Option<BackgroundColorQuery>,
|
||||
pub cursor_position: Option<CursorPositionQuery>,
|
||||
|
||||
@@ -1102,7 +1102,7 @@ fn divide_round_up(numer: usize, denom: usize) -> usize {
|
||||
if numer == 0 {
|
||||
return 0;
|
||||
}
|
||||
assert!(denom != 0);
|
||||
assert_ne!(denom, 0);
|
||||
let has_rem = (numer % denom) != 0;
|
||||
numer / denom + if has_rem { 1 } else { 0 }
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ fn new(text: WString, offset: usize) -> Self {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Eq, Default, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
|
||||
pub enum SearchMode {
|
||||
#[default]
|
||||
/// no search
|
||||
@@ -162,8 +162,9 @@ pub fn reset_to_mode(
|
||||
mode: SearchMode,
|
||||
token_offset: usize,
|
||||
) {
|
||||
assert!(
|
||||
mode != SearchMode::Inactive,
|
||||
assert_ne!(
|
||||
mode,
|
||||
SearchMode::Inactive,
|
||||
"mode cannot be inactive in this setter"
|
||||
);
|
||||
self.skips = HashSet::from([text.clone()]);
|
||||
|
||||
@@ -1683,7 +1683,7 @@ fn combine_command_and_autosuggestion(
|
||||
|
||||
impl<'a> Reader<'a> {
|
||||
fn query(&mut self, query_state: RecurrentQuery) {
|
||||
assert!(query_state != RecurrentQuery::default());
|
||||
assert_ne!(query_state, RecurrentQuery::default());
|
||||
if self
|
||||
.vars()
|
||||
.get_unless_empty(L!("FISH_TEST_NO_RECURRENT_QUERIES"))
|
||||
|
||||
@@ -590,8 +590,9 @@ fn call_error(
|
||||
token_length: Option<usize>,
|
||||
error_len: usize,
|
||||
) -> Tok {
|
||||
assert!(
|
||||
error_type != TokenizerError::None,
|
||||
assert_ne!(
|
||||
error_type,
|
||||
TokenizerError::None,
|
||||
"TokenizerError::none passed to call_error"
|
||||
);
|
||||
assert!(error_loc >= token_start, "Invalid error location");
|
||||
@@ -1016,8 +1017,9 @@ fn try_from(buff: &wstr) -> Result<PipeOrRedir, ()> {
|
||||
return Err(());
|
||||
}
|
||||
consume(&mut cursor, '|');
|
||||
assert!(
|
||||
buff.char_at(cursor) != '|',
|
||||
assert_ne!(
|
||||
buff.char_at(cursor),
|
||||
'|',
|
||||
"|| passed as redirection, this should have been handled as 'or' by the caller"
|
||||
);
|
||||
result.fd = STDOUT_FILENO;
|
||||
|
||||
@@ -428,8 +428,9 @@ fn try_transfer(jg: &JobGroup) -> bool {
|
||||
|
||||
// It should never be fish's pgroup.
|
||||
let fish_pgrp = crate::nix::getpgrp();
|
||||
assert!(
|
||||
pgid.as_pid_t() != fish_pgrp,
|
||||
assert_ne!(
|
||||
pgid.as_pid_t(),
|
||||
fish_pgrp,
|
||||
"Job should not have fish's pgroup"
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user