Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit bb083b8

Browse files
committed
remove useless casts
1 parent aa90d02 commit bb083b8

File tree

4 files changed

+10
-13
lines changed

4 files changed

+10
-13
lines changed

crates/hir-ty/src/consteval.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,15 @@ fn scalar_max(scalar: &Scalar) -> i128 {
131131
IntTy::I16 => i16::MAX as i128,
132132
IntTy::I32 => i32::MAX as i128,
133133
IntTy::I64 => i64::MAX as i128,
134-
IntTy::I128 => i128::MAX as i128,
134+
IntTy::I128 => i128::MAX,
135135
},
136136
Scalar::Uint(x) => match x {
137137
chalk_ir::UintTy::Usize => usize::MAX as i128,
138138
chalk_ir::UintTy::U8 => u8::MAX as i128,
139139
chalk_ir::UintTy::U16 => u16::MAX as i128,
140140
chalk_ir::UintTy::U32 => u32::MAX as i128,
141141
chalk_ir::UintTy::U64 => u64::MAX as i128,
142-
chalk_ir::UintTy::U128 => i128::MAX as i128, // ignore too big u128 for now
142+
chalk_ir::UintTy::U128 => i128::MAX, // ignore too big u128 for now
143143
},
144144
Scalar::Float(_) => 0,
145145
}

crates/rust-analyzer/src/from_proto.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,9 @@ pub(crate) fn vfs_path(url: &lsp_types::Url) -> Result<vfs::VfsPath> {
2525

2626
pub(crate) fn offset(line_index: &LineIndex, position: lsp_types::Position) -> Result<TextSize> {
2727
let line_col = match line_index.encoding {
28-
PositionEncoding::Utf8 => {
29-
LineCol { line: position.line as u32, col: position.character as u32 }
30-
}
28+
PositionEncoding::Utf8 => LineCol { line: position.line, col: position.character },
3129
PositionEncoding::Utf16 => {
32-
let line_col =
33-
LineColUtf16 { line: position.line as u32, col: position.character as u32 };
30+
let line_col = LineColUtf16 { line: position.line, col: position.character };
3431
line_index.index.to_utf8(line_col)
3532
}
3633
};

crates/rust-analyzer/src/semantic_tokens.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ impl SemanticTokensBuilder {
161161

162162
/// Push a new token onto the builder
163163
pub(crate) fn push(&mut self, range: Range, token_index: u32, modifier_bitset: u32) {
164-
let mut push_line = range.start.line as u32;
165-
let mut push_char = range.start.character as u32;
164+
let mut push_line = range.start.line;
165+
let mut push_char = range.start.character;
166166

167167
if !self.data.is_empty() {
168168
push_line -= self.prev_line;
@@ -177,15 +177,15 @@ impl SemanticTokensBuilder {
177177
let token = SemanticToken {
178178
delta_line: push_line,
179179
delta_start: push_char,
180-
length: token_len as u32,
180+
length: token_len,
181181
token_type: token_index,
182182
token_modifiers_bitset: modifier_bitset,
183183
};
184184

185185
self.data.push(token);
186186

187-
self.prev_line = range.start.line as u32;
188-
self.prev_char = range.start.character as u32;
187+
self.prev_line = range.start.line;
188+
self.prev_char = range.start.character;
189189
}
190190

191191
pub(crate) fn build(self) -> SemanticTokens {

crates/stdx/src/hash.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl Hasher for NoHashHasher {
5151
}
5252

5353
fn write_u64(&mut self, i: u64) {
54-
self.0 = i as u64;
54+
self.0 = i;
5555
}
5656

5757
fn write_usize(&mut self, i: usize) {

0 commit comments

Comments
 (0)