Backport LexError's Display to rust <1.44

This commit is contained in:
David Tolnay 2020-09-30 21:01:17 -07:00
parent 7221690e7e
commit 0093bbb16d
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 7 additions and 0 deletions

View File

@ -69,6 +69,10 @@ fn main() {
println!("cargo:rustc-cfg=no_bind_by_move_pattern_guard");
}
if version.minor >= 44 {
println!("cargo:rustc-cfg=lexerror_display");
}
if version.minor >= 45 {
println!("cargo:rustc-cfg=hygiene");
}

View File

@ -267,7 +267,10 @@ impl Debug for LexError {
impl Display for LexError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
#[cfg(lexerror_display)]
LexError::Compiler(e) => Display::fmt(e, f),
#[cfg(not(lexerror_display))]
LexError::Compiler(_e) => Display::fmt(&fallback::LexError, f),
LexError::Fallback(e) => Display::fmt(e, f),
}
}