mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
Future-proof against a next edition by using >=
and not ==
So that we won't have a strange bug when edition 2024 will land.
rustc [also does that](427cf81206/compiler/rustc_builtin_macros/src/edition_panic.rs (L84)
).
This commit is contained in:
parent
4e72700e38
commit
e6a35c28cb
1 changed files with 2 additions and 2 deletions
|
@ -344,7 +344,7 @@ fn panic_expand(
|
||||||
let loc: MacroCallLoc = db.lookup_intern_macro_call(id);
|
let loc: MacroCallLoc = db.lookup_intern_macro_call(id);
|
||||||
// Expand to a macro call `$crate::panic::panic_{edition}`
|
// Expand to a macro call `$crate::panic::panic_{edition}`
|
||||||
let krate = tt::Ident { text: "$crate".into(), id: tt::TokenId::unspecified() };
|
let krate = tt::Ident { text: "$crate".into(), id: tt::TokenId::unspecified() };
|
||||||
let mut call = if db.crate_graph()[loc.krate].edition == Edition::Edition2021 {
|
let mut call = if db.crate_graph()[loc.krate].edition >= Edition::Edition2021 {
|
||||||
quote!(#krate::panic::panic_2021!)
|
quote!(#krate::panic::panic_2021!)
|
||||||
} else {
|
} else {
|
||||||
quote!(#krate::panic::panic_2015!)
|
quote!(#krate::panic::panic_2015!)
|
||||||
|
@ -363,7 +363,7 @@ fn unreachable_expand(
|
||||||
let loc: MacroCallLoc = db.lookup_intern_macro_call(id);
|
let loc: MacroCallLoc = db.lookup_intern_macro_call(id);
|
||||||
// Expand to a macro call `$crate::panic::unreachable_{edition}`
|
// Expand to a macro call `$crate::panic::unreachable_{edition}`
|
||||||
let krate = tt::Ident { text: "$crate".into(), id: tt::TokenId::unspecified() };
|
let krate = tt::Ident { text: "$crate".into(), id: tt::TokenId::unspecified() };
|
||||||
let mut call = if db.crate_graph()[loc.krate].edition == Edition::Edition2021 {
|
let mut call = if db.crate_graph()[loc.krate].edition >= Edition::Edition2021 {
|
||||||
quote!(#krate::panic::unreachable_2021!)
|
quote!(#krate::panic::unreachable_2021!)
|
||||||
} else {
|
} else {
|
||||||
quote!(#krate::panic::unreachable_2015!)
|
quote!(#krate::panic::unreachable_2015!)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue