mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
remove useless casts
This commit is contained in:
parent
aa90d02079
commit
bb083b8202
4 changed files with 10 additions and 13 deletions
|
@ -131,7 +131,7 @@ fn scalar_max(scalar: &Scalar) -> i128 {
|
||||||
IntTy::I16 => i16::MAX as i128,
|
IntTy::I16 => i16::MAX as i128,
|
||||||
IntTy::I32 => i32::MAX as i128,
|
IntTy::I32 => i32::MAX as i128,
|
||||||
IntTy::I64 => i64::MAX as i128,
|
IntTy::I64 => i64::MAX as i128,
|
||||||
IntTy::I128 => i128::MAX as i128,
|
IntTy::I128 => i128::MAX,
|
||||||
},
|
},
|
||||||
Scalar::Uint(x) => match x {
|
Scalar::Uint(x) => match x {
|
||||||
chalk_ir::UintTy::Usize => usize::MAX as i128,
|
chalk_ir::UintTy::Usize => usize::MAX as i128,
|
||||||
|
@ -139,7 +139,7 @@ fn scalar_max(scalar: &Scalar) -> i128 {
|
||||||
chalk_ir::UintTy::U16 => u16::MAX as i128,
|
chalk_ir::UintTy::U16 => u16::MAX as i128,
|
||||||
chalk_ir::UintTy::U32 => u32::MAX as i128,
|
chalk_ir::UintTy::U32 => u32::MAX as i128,
|
||||||
chalk_ir::UintTy::U64 => u64::MAX as i128,
|
chalk_ir::UintTy::U64 => u64::MAX as i128,
|
||||||
chalk_ir::UintTy::U128 => i128::MAX as i128, // ignore too big u128 for now
|
chalk_ir::UintTy::U128 => i128::MAX, // ignore too big u128 for now
|
||||||
},
|
},
|
||||||
Scalar::Float(_) => 0,
|
Scalar::Float(_) => 0,
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,12 +25,9 @@ pub(crate) fn vfs_path(url: &lsp_types::Url) -> Result<vfs::VfsPath> {
|
||||||
|
|
||||||
pub(crate) fn offset(line_index: &LineIndex, position: lsp_types::Position) -> Result<TextSize> {
|
pub(crate) fn offset(line_index: &LineIndex, position: lsp_types::Position) -> Result<TextSize> {
|
||||||
let line_col = match line_index.encoding {
|
let line_col = match line_index.encoding {
|
||||||
PositionEncoding::Utf8 => {
|
PositionEncoding::Utf8 => LineCol { line: position.line, col: position.character },
|
||||||
LineCol { line: position.line as u32, col: position.character as u32 }
|
|
||||||
}
|
|
||||||
PositionEncoding::Utf16 => {
|
PositionEncoding::Utf16 => {
|
||||||
let line_col =
|
let line_col = LineColUtf16 { line: position.line, col: position.character };
|
||||||
LineColUtf16 { line: position.line as u32, col: position.character as u32 };
|
|
||||||
line_index.index.to_utf8(line_col)
|
line_index.index.to_utf8(line_col)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -161,8 +161,8 @@ impl SemanticTokensBuilder {
|
||||||
|
|
||||||
/// Push a new token onto the builder
|
/// Push a new token onto the builder
|
||||||
pub(crate) fn push(&mut self, range: Range, token_index: u32, modifier_bitset: u32) {
|
pub(crate) fn push(&mut self, range: Range, token_index: u32, modifier_bitset: u32) {
|
||||||
let mut push_line = range.start.line as u32;
|
let mut push_line = range.start.line;
|
||||||
let mut push_char = range.start.character as u32;
|
let mut push_char = range.start.character;
|
||||||
|
|
||||||
if !self.data.is_empty() {
|
if !self.data.is_empty() {
|
||||||
push_line -= self.prev_line;
|
push_line -= self.prev_line;
|
||||||
|
@ -177,15 +177,15 @@ impl SemanticTokensBuilder {
|
||||||
let token = SemanticToken {
|
let token = SemanticToken {
|
||||||
delta_line: push_line,
|
delta_line: push_line,
|
||||||
delta_start: push_char,
|
delta_start: push_char,
|
||||||
length: token_len as u32,
|
length: token_len,
|
||||||
token_type: token_index,
|
token_type: token_index,
|
||||||
token_modifiers_bitset: modifier_bitset,
|
token_modifiers_bitset: modifier_bitset,
|
||||||
};
|
};
|
||||||
|
|
||||||
self.data.push(token);
|
self.data.push(token);
|
||||||
|
|
||||||
self.prev_line = range.start.line as u32;
|
self.prev_line = range.start.line;
|
||||||
self.prev_char = range.start.character as u32;
|
self.prev_char = range.start.character;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn build(self) -> SemanticTokens {
|
pub(crate) fn build(self) -> SemanticTokens {
|
||||||
|
|
|
@ -51,7 +51,7 @@ impl Hasher for NoHashHasher {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_u64(&mut self, i: u64) {
|
fn write_u64(&mut self, i: u64) {
|
||||||
self.0 = i as u64;
|
self.0 = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_usize(&mut self, i: usize) {
|
fn write_usize(&mut self, i: usize) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue