misc: Replace uses of deprecated ::max_value() with ::MAX (#8365)

This commit is contained in:
Josh Triplett authored and GitHub committed 2026-11-20 07:13:41 +01:00
1 parent 771a4efacc
commit 0d11cabfc4
14 files changed
+34 -44

No files matched your search

+1 -1
View File
@@ -24,7 +24,7 @@ pub use direction::Direction;
pub use level::Level;
/// Placeholder codepoint index that corresponds to NO_LEVEL
const DELETED: usize = usize::max_value();
const DELETED: usize = usize::MAX;
#[derive(Debug, Clone, Copy, PartialEq, Eq, FromDynamic, ToDynamic)]
pub enum ParagraphDirectionHint {
+2 -2
View File
@@ -42,10 +42,10 @@ impl MuxPane {
0..zone.end_x.saturating_add(1)
} else if row == zone.start_y {
// first line of multi-line
zone.start_x..usize::max_value()
zone.start_x..usize::MAX
} else {
// some "middle" line of multi-line
0..usize::max_value()
0..usize::MAX
}
}
+1 -1
View File
@@ -372,7 +372,7 @@ impl<'widget> Ui<'widget> {
abs_coords.x + render_data.coordinates.x,
abs_coords.y + render_data.coordinates.y,
);
surface.flush_changes_older_than(SequenceNo::max_value());
surface.flush_changes_older_than(SequenceNo::MAX);
render_data.coordinates
};
+7 -7
View File
@@ -1311,14 +1311,14 @@ impl Display for Cursor {
Cursor::LinePositionBackward(n) => n.write_csi(f, "k")?,
Cursor::LinePositionForward(n) => n.write_csi(f, "e")?,
Cursor::SetTopAndBottomMargins { top, bottom } => {
if top.as_one_based() == 1 && bottom.as_one_based() == u32::max_value() {
if top.as_one_based() == 1 && bottom.as_one_based() == u32::MAX {
write!(f, "r")?;
} else {
write!(f, "{};{}r", top, bottom)?;
}
}
Cursor::SetLeftAndRightMargins { left, right } => {
if left.as_one_based() == 1 && right.as_one_based() == u32::max_value() {
if left.as_one_based() == 1 && right.as_one_based() == u32::MAX {
write!(f, "s")?;
} else {
write!(f, "{};{}s", left, right)?;
@@ -1733,7 +1733,7 @@ fn to_u8(v: &CsiParam) -> Result<u8, ()> {
match v {
CsiParam::P(_) => Err(()),
CsiParam::Integer(v) => {
if *v <= i64::from(u8::max_value()) {
if *v <= i64::from(u8::MAX) {
Ok(*v as u8)
} else {
Err(())
@@ -1756,7 +1756,7 @@ fn to_u8(v: &CsiParam) -> Result<u8, ()> {
fn to_1b_u32(v: &CsiParam) -> Result<u32, ()> {
match v {
CsiParam::Integer(v) if *v == 0 => Ok(1),
CsiParam::Integer(v) if *v > 0 && *v <= i64::from(u32::max_value()) => Ok(*v as u32),
CsiParam::Integer(v) if *v > 0 && *v <= i64::from(u32::MAX) => Ok(*v as u32),
_ => Err(()),
}
}
@@ -2101,14 +2101,14 @@ impl<'a> CSIParser<'a> {
match params {
[] => Ok(CSI::Cursor(Cursor::SetTopAndBottomMargins {
top: OneBased::new(1),
bottom: OneBased::new(u32::max_value()),
bottom: OneBased::new(u32::MAX),
})),
[p] => Ok(self.advance_by(
1,
params,
CSI::Cursor(Cursor::SetTopAndBottomMargins {
top: OneBased::from_esc_param(p)?,
bottom: OneBased::new(u32::max_value()),
bottom: OneBased::new(u32::MAX),
}),
)),
[a, CsiParam::P(b';'), b] => Ok(self.advance_by(
@@ -2188,7 +2188,7 @@ impl<'a> CSIParser<'a> {
params,
CSI::Cursor(Cursor::SetLeftAndRightMargins {
left: OneBased::from_esc_param(p)?,
right: OneBased::new(u32::max_value()),
right: OneBased::new(u32::MAX),
}),
)),
[a, CsiParam::P(b';'), b] => Ok(self.advance_by(
+1 -1
View File
@@ -142,7 +142,7 @@ impl Display for Esc {
let packed = code
.to_u16()
.expect("num-derive failed to implement ToPrimitive");
if packed > u16::from(u8::max_value()) {
if packed > u16::from(u8::MAX) {
write!(
f,
"{}{}",
+3 -5
View File
@@ -573,7 +573,7 @@ impl OneBased {
CsiParam::Integer(v) if *v == 0 => Ok(Self {
value: num_traits::one(),
}),
CsiParam::Integer(v) if *v > 0 && *v <= i64::from(u32::max_value()) => {
CsiParam::Integer(v) if *v > 0 && *v <= i64::from(u32::MAX) => {
Ok(Self { value: *v as u32 })
}
_ => Err(()),
@@ -584,10 +584,8 @@ impl OneBased {
/// 0 is equivalent to max_value.
pub fn from_esc_param_with_big_default(v: &CsiParam) -> core::result::Result<Self, ()> {
match v {
CsiParam::Integer(v) if *v == 0 => Ok(Self {
value: u32::max_value(),
}),
CsiParam::Integer(v) if *v > 0 && *v <= i64::from(u32::max_value()) => {
CsiParam::Integer(v) if *v == 0 => Ok(Self { value: u32::MAX }),
CsiParam::Integer(v) if *v > 0 && *v <= i64::from(u32::MAX) => {
Ok(Self { value: *v as u32 })
}
_ => Err(()),
+6 -14
View File
@@ -466,19 +466,11 @@ impl CopyRenderable {
let cursor_is_above_start = self.cursor.y < sel_start.y;
let start = SelectionCoordinate::x_y(
if cursor_is_above_start {
usize::max_value()
} else {
0
},
if cursor_is_above_start { usize::MAX } else { 0 },
sel_start.y,
);
let end = SelectionCoordinate::x_y(
if cursor_is_above_start {
0
} else {
usize::max_value()
},
if cursor_is_above_start { 0 } else { usize::MAX },
self.cursor.y,
);
(start, end)
@@ -759,7 +751,7 @@ impl CopyRenderable {
fn move_to_bottom(&mut self) {
// This will get fixed up by clamp_cursor_to_scrollback
self.cursor.y = isize::max_value();
self.cursor.y = isize::MAX;
self.select_to_cursor_pos();
}
@@ -826,7 +818,7 @@ impl CopyRenderable {
fn move_backward_one_word(&mut self) {
let y = if self.cursor.x == 0 && self.cursor.y > 0 {
self.cursor.x = usize::max_value();
self.cursor.x = usize::MAX;
self.cursor.y.saturating_sub(1)
} else {
self.cursor.y
@@ -835,7 +827,7 @@ impl CopyRenderable {
let (top, lines) = self.delegate.get_lines(y..y + 1);
if let Some(line) = lines.get(0) {
self.cursor.y = top;
if self.cursor.x == usize::max_value() {
if self.cursor.x == usize::MAX {
self.cursor.x = line.len().saturating_sub(1);
}
let s = line.columns_as_str(0..self.cursor.x.saturating_add(1));
@@ -871,7 +863,7 @@ impl CopyRenderable {
if last_was_whitespace && self.cursor.y > 0 {
// The line begins with whitespace
self.cursor.x = usize::max_value();
self.cursor.x = usize::MAX;
self.cursor.y -= 1;
return self.move_backward_one_word();
}
+4 -4
View File
@@ -187,7 +187,7 @@ impl SelectionRange {
return Self {
start: SelectionCoordinate::x_y(0, logical.first_row),
end: SelectionCoordinate::x_y(
usize::max_value(),
usize::MAX,
logical.first_row + (logical.physical_lines.len() - 1) as StableRowIndex,
),
};
@@ -315,7 +315,7 @@ impl SelectionRange {
}
/// Yields a range representing the selected columns for the specified row.
/// Not that the range may include usize::max_value() for some rows; this
/// Note that the range may include `usize::MAX` for some rows; this
/// indicates that the selection extends to the end of that row.
/// Since this struct has no knowledge of line length, it cannot be
/// more precise than that.
@@ -348,10 +348,10 @@ impl SelectionRange {
SelectionX::Cell(0).range(norm.end.x.saturating_add(1))
} else if row == norm.start.y {
// first line of multi-line
norm.start.x.range(SelectionX::Cell(usize::max_value()))
norm.start.x.range(SelectionX::Cell(usize::MAX))
} else {
// some "middle" line of multi-line
0..usize::max_value()
0..usize::MAX
}
}
}
+1 -1
View File
@@ -494,7 +494,7 @@ impl TabBarState {
title_width.saturating_sub(number_of_tabs.saturating_sub(1) + new_tab.len());
let tab_width_max = if config.use_fancy_tab_bar || available_cells >= titles_len {
// We can render each title with its full width
usize::max_value()
usize::MAX
} else {
// We need to clamp the length to balance them out
available_cells / number_of_tabs
+2 -2
View File
@@ -254,7 +254,7 @@ impl MatchResult {
// Pump up the score for an exact match, otherwise
// the order may be undesirable if there are a lot
// of candidates with the same score
u32::max_value()
u32::MAX
} else {
score
},
@@ -302,7 +302,7 @@ fn compute_matches(selection: &str, aliases: &[Alias], group: CharSelectGroup) -
glyph,
MatchResult {
row_idx,
score: u32::max_value(),
score: u32::MAX,
},
))
} else {
+1 -1
View File
@@ -183,7 +183,7 @@ impl MatchResult {
// Pump up the score for an exact match, otherwise
// the order may be undesirable if there are a lot
// of candidates with the same score
u32::max_value()
u32::MAX
} else {
score
},
+1 -1
View File
@@ -583,7 +583,7 @@ impl CursorInfo {
let num_pixels = (width as usize) * (height as usize);
ensure!(
num_pixels < u32::max_value() as usize,
num_pixels < u32::MAX as usize,
"cursor image is larger than fits in u32"
);
+3 -3
View File
@@ -588,7 +588,7 @@ impl XWindowInner {
property: conn.atom_xdndtypelist,
r#type: xcb::x::ATOM_ATOM,
long_offset: 0,
long_length: u32::max_value(),
long_length: u32::MAX,
}) {
Ok(prop) => prop.value::<Atom>().to_vec(),
Err(err) => {
@@ -1107,7 +1107,7 @@ impl XWindowInner {
property: selection.property(),
r#type: selection.target(),
long_offset: 0,
long_length: u32::max_value(),
long_length: u32::MAX,
}) {
Ok(prop) => {
if let Some(mut promise) = self.copy_and_paste.request_mut(clipboard).take() {
@@ -1149,7 +1149,7 @@ impl XWindowInner {
property: selection.property(),
r#type: selection.target(),
long_offset: 0,
long_length: u32::max_value(),
long_length: u32::MAX,
}) {
Ok(prop) => {
if selection.target() == conn.atom_utf8_string {
+1 -1
View File
@@ -36,7 +36,7 @@ fn read_xsettings_grabbed(
property: atom_xsettings_settings,
r#type: atom_xsettings_settings,
long_offset: 0,
long_length: u32::max_value(),
long_length: u32::MAX,
}))
.context("get_property")?;