Improved the compiler code with clippy
This commit is contained in:
parent
c67277301c
commit
3c5e88c7d1
@ -630,7 +630,7 @@ fn number(&mut self, first_digit: char) -> LiteralKind {
|
|||||||
// with a number
|
// with a number
|
||||||
self.bump();
|
self.bump();
|
||||||
let mut empty_exponent = false;
|
let mut empty_exponent = false;
|
||||||
if self.first().is_digit(10) {
|
if self.first().is_ascii_digit() {
|
||||||
self.eat_decimal_digits();
|
self.eat_decimal_digits();
|
||||||
match self.first() {
|
match self.first() {
|
||||||
'e' | 'E' => {
|
'e' | 'E' => {
|
||||||
@ -661,7 +661,7 @@ fn lifetime_or_char(&mut self) -> TokenKind {
|
|||||||
// If the first symbol is valid for identifier, it can be a lifetime.
|
// If the first symbol is valid for identifier, it can be a lifetime.
|
||||||
// Also check if it's a number for a better error reporting (so '0 will
|
// Also check if it's a number for a better error reporting (so '0 will
|
||||||
// be reported as invalid lifetime and not as unterminated char literal).
|
// be reported as invalid lifetime and not as unterminated char literal).
|
||||||
is_id_start(self.first()) || self.first().is_digit(10)
|
is_id_start(self.first()) || self.first().is_ascii_digit()
|
||||||
};
|
};
|
||||||
|
|
||||||
if !can_be_a_lifetime {
|
if !can_be_a_lifetime {
|
||||||
@ -677,7 +677,7 @@ fn lifetime_or_char(&mut self) -> TokenKind {
|
|||||||
// Either a lifetime or a character literal with
|
// Either a lifetime or a character literal with
|
||||||
// length greater than 1.
|
// length greater than 1.
|
||||||
|
|
||||||
let starts_with_number = self.first().is_digit(10);
|
let starts_with_number = self.first().is_ascii_digit();
|
||||||
|
|
||||||
// Skip the literal contents.
|
// Skip the literal contents.
|
||||||
// First symbol can be a number (which isn't a valid identifier start),
|
// First symbol can be a number (which isn't a valid identifier start),
|
||||||
|
@ -259,7 +259,7 @@ fn scan_escape<T: From<char> + From<u8>>(
|
|||||||
} else {
|
} else {
|
||||||
// This may be a high byte, but that will only happen if `T` is
|
// This may be a high byte, but that will only happen if `T` is
|
||||||
// `MixedUnit`, because of the `allow_high_bytes` check above.
|
// `MixedUnit`, because of the `allow_high_bytes` check above.
|
||||||
Ok(T::from(value as u8))
|
Ok(T::from(value))
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
'u' => return scan_unicode(chars, mode.allow_unicode_escapes()).map(T::from),
|
'u' => return scan_unicode(chars, mode.allow_unicode_escapes()).map(T::from),
|
||||||
@ -300,7 +300,7 @@ fn scan_unicode(chars: &mut Chars<'_>, allow_unicode_escapes: bool) -> Result<ch
|
|||||||
return Err(EscapeError::UnicodeEscapeInByte);
|
return Err(EscapeError::UnicodeEscapeInByte);
|
||||||
}
|
}
|
||||||
|
|
||||||
break std::char::from_u32(value).ok_or_else(|| {
|
break std::char::from_u32(value).ok_or({
|
||||||
if value > 0x10FFFF {
|
if value > 0x10FFFF {
|
||||||
EscapeError::OutOfRangeUnicodeEscape
|
EscapeError::OutOfRangeUnicodeEscape
|
||||||
} else {
|
} else {
|
||||||
|
@ -50,7 +50,7 @@ fn detect_llvm_link() -> (&'static str, &'static str) {
|
|||||||
fn restore_library_path() {
|
fn restore_library_path() {
|
||||||
let key = tracked_env_var_os("REAL_LIBRARY_PATH_VAR").expect("REAL_LIBRARY_PATH_VAR");
|
let key = tracked_env_var_os("REAL_LIBRARY_PATH_VAR").expect("REAL_LIBRARY_PATH_VAR");
|
||||||
if let Some(env) = tracked_env_var_os("REAL_LIBRARY_PATH") {
|
if let Some(env) = tracked_env_var_os("REAL_LIBRARY_PATH") {
|
||||||
env::set_var(&key, &env);
|
env::set_var(&key, env);
|
||||||
} else {
|
} else {
|
||||||
env::remove_var(&key);
|
env::remove_var(&key);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
println!("cargo:rerun-if-changed=build.rs");
|
println!("cargo:rerun-if-changed=build.rs");
|
||||||
println!("cargo:rerun-if-env-changed=RUSTC_BOOTSTRAP");
|
println!("cargo:rerun-if-env-changed=RUSTC_BOOTSTRAP");
|
||||||
if !std::env::var("RUSTC_BOOTSTRAP").is_ok() {
|
if std::env::var("RUSTC_BOOTSTRAP").is_err() {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"error: you are attempting to build the compiler without going through bootstrap"
|
"error: you are attempting to build the compiler without going through bootstrap"
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user