Add debug assertions for empty replacements and overlapping spans#13567
Add debug assertions for empty replacements and overlapping spans#13567bors merged 3 commits intorust-lang:masterfrom
Conversation
de84b25 to
4de65a1
Compare
|
Looks like lintcheck with this assertion unconvered another bug. TIL that the span of a macro call semicolon statement |
…outside_block` The expansion of `asm!()` and `line!()` is not marked as from an expansion, in which case `SourceMap::stmt_span` returns the input span unchanged. So instead of using `stmt_span`, use `mac_call_stmt_semi_span` directly
flip1995
left a comment
There was a problem hiding this comment.
Thanks for making my life easier!
| let remove_span = semi_span.with_lo(tail_stmt_expr.span.source_callsite().hi()); | ||
|
|
||
| // For macro call semicolon statements (`mac!();`), the statement's span does not actually | ||
| // include the semicolon itself, so use `mac_call_stmt_semi_span`, which finds the semicolon |
There was a problem hiding this comment.
Interesting that this function exists!
| let from = self_ty.span.get_source_text(cx)?; | ||
| let into = target_ty.span.get_source_text(cx)?; | ||
|
|
||
| let return_type = matches!(sig.decl.output, FnRetTy::Return(_)) |
There was a problem hiding this comment.
I noticed that this didn't get synced (together with a few other things) when doing the Josh setup. With Josh all of that would be synced. The problem with subtree is, that if you mess up a merge once, it will never be synced correctly again. Luckily this didn't happen that often yet and will get fixed, once we move to Josh.
This is a commit fixing everything that wasn't correctly synced with subtree: flip1995@89f1145
|
r? @flip1995 |
|
@bors r+ |
|
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
rustc has debug assertions 1 2 that check that a substitution doesn't have an empty suggestion string and an empty span at the same time, as well as that spans in multipart suggestions don't overlap.
However, since we link to the rustc-dev distributed compiler, these debug assertions are always disabled and so we never actually run them.
This leads to the problem that the debug ICE is not necessarily caught in the PR and only triggered in the rust repo sync, and in one of the last syncs this was a blocker and delayed the sync by several weeks because the fix was not obvious.
So this PR essentially copies the checks over and runs them in clippy debug builds as well, so that we can catch these errors in PRs directly.
As for the second commit, this also did cause an ICE in a sync before and was fixed in the sync PR (see rust-lang/rust#120345 (comment)), but it seems like that commit didn't make it back into the clippy repo (cc @flip1995), so the fixed code is in the rust repo but not in the clippy repo.
changelog: none
Footnotes
https://doc.rust-lang.org/1.82.0/nightly-rustc/src/rustc_errors/diagnostic.rs.html#1019 ↩
https://doc.rust-lang.org/1.82.0/nightly-rustc/src/rustc_errors/diagnostic.rs.html#932 ↩