Skip to content

Commit a730970

Browse files
committed
Only call span.rust_2021() when necessary.
1 parent 8098ac1 commit a730970

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

compiler/rustc_builtin_macros/src/assert.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,23 @@ use rustc_span::{Span, DUMMY_SP};
1212

1313
pub fn expand_assert<'cx>(
1414
cx: &'cx mut ExtCtxt<'_>,
15-
sp: Span,
15+
span: Span,
1616
tts: TokenStream,
1717
) -> Box<dyn MacResult + 'cx> {
18-
let Assert { cond_expr, custom_message } = match parse_assert(cx, sp, tts) {
18+
let Assert { cond_expr, custom_message } = match parse_assert(cx, span, tts) {
1919
Ok(assert) => assert,
2020
Err(mut err) => {
2121
err.emit();
22-
return DummyResult::any(sp);
22+
return DummyResult::any(span);
2323
}
2424
};
2525

26-
let is_2021 = sp.rust_2021();
27-
2826
// `core::panic` and `std::panic` are different macros, so we use call-site
2927
// context to pick up whichever is currently in scope.
30-
let sp = cx.with_call_site_ctxt(sp);
28+
let sp = cx.with_call_site_ctxt(span);
3129

3230
let panic_call = if let Some(tokens) = custom_message {
33-
let path = if is_2021 {
31+
let path = if span.rust_2021() {
3432
// On edition 2021, we always call `$crate::panic!()`.
3533
Path {
3634
span: sp,

0 commit comments

Comments
 (0)