Skip to content

Commit a426da0

Browse files
committed
XXX: use from instead of into
1 parent cfd4ca2 commit a426da0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

compiler/rustc_lexer/src/unescape.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ fn scan_escape<T: From<u8> + From<char>>(
222222
mode: Mode,
223223
) -> Result<T, EscapeError> {
224224
// Previous character was '\\', unescape what follows.
225-
let res = match chars.next().ok_or(EscapeError::LoneSlash)? {
225+
let res: u8 = match chars.next().ok_or(EscapeError::LoneSlash)? {
226226
'"' => b'"',
227227
'n' => b'\n',
228228
'r' => b'\r',
@@ -249,10 +249,10 @@ fn scan_escape<T: From<u8> + From<char>>(
249249
value as u8
250250
}
251251

252-
'u' => return scan_unicode(chars, mode.is_unicode_escape_disallowed()).map(Into::into),
252+
'u' => return scan_unicode(chars, mode.is_unicode_escape_disallowed()).map(T::from),
253253
_ => return Err(EscapeError::InvalidEscape),
254254
};
255-
Ok(res.into())
255+
Ok(T::from(res))
256256
}
257257

258258
fn scan_unicode(
@@ -366,7 +366,7 @@ where
366366
}
367367
'"' => Err(EscapeError::EscapeOnlyChar),
368368
'\r' => Err(EscapeError::BareCarriageReturn),
369-
_ => ascii_check(c, chars_should_be_ascii).map(Into::into),
369+
_ => ascii_check(c, chars_should_be_ascii).map(T::from),
370370
};
371371
let end = src.len() - chars.as_str().len();
372372
callback(start..end, res);

0 commit comments

Comments
 (0)