Rollup merge of #81647 - m-ou-se:assert-2021-fix, r=petrochenkov
Fix bug with assert!() calling the wrong edition of panic!(). The span of `panic!` produced by the `assert` macro did not carry the right edition. This changes `assert` to call the right version. Also adds tests for the 2021 edition of panic and assert, that would've caught this.
This commit is contained in:
commit
7f2eeb10c7
4 changed files with 54 additions and 3 deletions
|
@ -29,11 +29,11 @@ pub fn expand_assert<'cx>(
|
|||
|
||||
let panic_call = if let Some(tokens) = custom_message {
|
||||
let path = if span.rust_2021() {
|
||||
// On edition 2021, we always call `$crate::panic!()`.
|
||||
// On edition 2021, we always call `$crate::panic::panic_2021!()`.
|
||||
Path {
|
||||
span: sp,
|
||||
segments: cx
|
||||
.std_path(&[sym::panic])
|
||||
.std_path(&[sym::panic, sym::panic_2021])
|
||||
.into_iter()
|
||||
.map(|ident| PathSegment::from_ident(ident))
|
||||
.collect(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue