mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Switch to TryFrom
This commit is contained in:
parent
dc2151085e
commit
63a462f37c
13 changed files with 63 additions and 53 deletions
|
@ -2,6 +2,8 @@
|
|||
|
||||
mod block;
|
||||
|
||||
use std::convert::TryFrom;
|
||||
|
||||
use rustc_lexer::unescape;
|
||||
|
||||
use crate::{
|
||||
|
@ -112,7 +114,7 @@ fn validate_literal(literal: ast::Literal, acc: &mut Vec<SyntaxError>) {
|
|||
|
||||
// FIXME: lift this lambda refactor to `fn` (https://github.com/rust-analyzer/rust-analyzer/pull/2834#discussion_r366199205)
|
||||
let mut push_err = |prefix_len, (off, err): (usize, unescape::EscapeError)| {
|
||||
let off = token.text_range().start() + TextSize::from_usize(off + prefix_len);
|
||||
let off = token.text_range().start() + TextSize::try_from(off + prefix_len).unwrap();
|
||||
acc.push(SyntaxError::new_at_offset(rustc_unescape_error_to_string(err), off));
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue