Skip to content

Commit 415be8b

Browse files
Merge #11579
11579: minor: Future-proof against a next edition by using `>=` and not `==` r=lnicola a=ChayimFriedman2 So that we won't have a strange bug when edition 2024 will land. rustc [also does that](https://github.com/rust-lang/rust/blob/427cf81206d3b6cf41c86c1b9ce113a33f1ce860/compiler/rustc_builtin_macros/src/edition_panic.rs#L84). Co-authored-by: Chayim Refael Friedman <[email protected]>
2 parents 4e72700 + e6a35c2 commit 415be8b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

crates/hir_expand/src/builtin_fn_macro.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ fn panic_expand(
344344
let loc: MacroCallLoc = db.lookup_intern_macro_call(id);
345345
// Expand to a macro call `$crate::panic::panic_{edition}`
346346
let krate = tt::Ident { text: "$crate".into(), id: tt::TokenId::unspecified() };
347-
let mut call = if db.crate_graph()[loc.krate].edition == Edition::Edition2021 {
347+
let mut call = if db.crate_graph()[loc.krate].edition >= Edition::Edition2021 {
348348
quote!(#krate::panic::panic_2021!)
349349
} else {
350350
quote!(#krate::panic::panic_2015!)
@@ -363,7 +363,7 @@ fn unreachable_expand(
363363
let loc: MacroCallLoc = db.lookup_intern_macro_call(id);
364364
// Expand to a macro call `$crate::panic::unreachable_{edition}`
365365
let krate = tt::Ident { text: "$crate".into(), id: tt::TokenId::unspecified() };
366-
let mut call = if db.crate_graph()[loc.krate].edition == Edition::Edition2021 {
366+
let mut call = if db.crate_graph()[loc.krate].edition >= Edition::Edition2021 {
367367
quote!(#krate::panic::unreachable_2021!)
368368
} else {
369369
quote!(#krate::panic::unreachable_2015!)

0 commit comments

Comments
 (0)