Rollup merge of #118928 - EliseZeroTwo:EliseZeroTwo/fix-issue-118786, r=cjgillot
fix: Overlapping spans in delimited meta-vars Closes #118786 Delimited meta-vars inside of MBE's spans were set to have the same opening and closing position resulting in an ICE when debug assertions were enabled and an error was present in the templated code. This ensures that the spans do not overlap, whilst still having the spans point at the usage of the meta-var inside the macro definition. It includes a regression test. 🖤
This commit is contained in:
commit
93d3a4231e
3 changed files with 70 additions and 0 deletions
|
@ -236,6 +236,13 @@ fn expand_macro<'cx>(
|
|||
target_sp.open = source_sp.open.with_ctxt(ctxt);
|
||||
target_sp.close = source_sp.close.with_ctxt(ctxt);
|
||||
}
|
||||
(
|
||||
TokenTree::Delimited(target_sp, ..),
|
||||
mbe::TokenTree::MetaVar(source_sp, ..),
|
||||
) => {
|
||||
target_sp.open = source_sp.with_ctxt(ctxt);
|
||||
target_sp.close = source_sp.with_ctxt(ctxt).shrink_to_hi();
|
||||
}
|
||||
_ => {
|
||||
let sp = rhs_tt.span().with_ctxt(ctxt);
|
||||
tt.set_span(sp);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue