Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ICE on format string of macro with secondary-label #91575

Merged
merged 1 commit into from
Dec 11, 2021

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Dec 6, 2021

This generalizes the fix #86104 to also correctly skip Span::from_inner for the secondary_label of a format macro parsing error as well.

We can alternatively skip the span_label diagnostic call for the secondary label as well, since that label probably only makes sense when the proper span is computed.

Fixes #91556

@rust-highfive
Copy link
Collaborator

r? @cjgillot

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 6, 2021
Comment on lines 999 to 1000
let sp2 = if efmt_kind_is_lit { fmt_span.from_inner(span) } else { fmt_span };
e.span_label(sp2, label);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sp2 looks like a leftover temporary change. If so:

Suggested change
let sp2 = if efmt_kind_is_lit { fmt_span.from_inner(span) } else { fmt_span };
e.span_label(sp2, label);
let sp = if efmt_kind_is_lit { fmt_span.from_inner(span) } else { fmt_span };
e.span_label(sp, label);

@apiraino apiraino added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Dec 9, 2021
@@ -995,8 +995,9 @@ pub fn expand_preparsed_format_args(
e.note(&note);
}
if let Some((label, span)) = err.secondary_label {
let sp = fmt_span.from_inner(span);
e.span_label(sp, label);
// FIXME(compiler-errors): Should we just suppress this secondary_label?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree we should just suppress the secondary label. Its purpose is to point to the opening brace, which can't happen if we have to replace the span with fmt_span.

@cjgillot cjgillot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 9, 2021
@compiler-errors
Copy link
Member Author

r? @cjgillot

@cjgillot
Copy link
Contributor

cjgillot commented Dec 9, 2021

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Dec 9, 2021

📌 Commit 99bd24e has been approved by cjgillot

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 9, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Dec 9, 2021
…llot

Fix ICE on format string of macro with secondary-label

This generalizes the fix rust-lang#86104 to also correctly skip `Span::from_inner` for the `secondary_label` of a format macro parsing error as well.

We can alternatively skip the `span_label` diagnostic call for the secondary label as well, since that label probably only makes sense when the _proper_ span is computed.

Fixes rust-lang#91556
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Dec 10, 2021
…llot

Fix ICE on format string of macro with secondary-label

This generalizes the fix rust-lang#86104 to also correctly skip `Span::from_inner` for the `secondary_label` of a format macro parsing error as well.

We can alternatively skip the `span_label` diagnostic call for the secondary label as well, since that label probably only makes sense when the _proper_ span is computed.

Fixes rust-lang#91556
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Dec 10, 2021
…llot

Fix ICE on format string of macro with secondary-label

This generalizes the fix rust-lang#86104 to also correctly skip `Span::from_inner` for the `secondary_label` of a format macro parsing error as well.

We can alternatively skip the `span_label` diagnostic call for the secondary label as well, since that label probably only makes sense when the _proper_ span is computed.

Fixes rust-lang#91556
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 10, 2021
…askrgr

Rollup of 10 pull requests

Successful merges:

 - rust-lang#90407 (Document all public items in `rustc_incremental`)
 - rust-lang#90897 (Fix incorrect stability attributes)
 - rust-lang#91105 (Fix method name reference in stream documentation)
 - rust-lang#91325 (adjust const_eval_select documentation)
 - rust-lang#91470 (code-cov: generate dead functions with private/default linkage)
 - rust-lang#91482 (Update documentation to use `from()` to initialize `HashMap`s and `BTreeMap`s)
 - rust-lang#91524 (Fix Vec::extend_from_slice docs)
 - rust-lang#91575 (Fix ICE on format string of macro with secondary-label)
 - rust-lang#91625 (Remove redundant [..]s)
 - rust-lang#91646 (Fix documentation for `core::ready::Ready`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 6cfe9af into rust-lang:master Dec 11, 2021
@rustbot rustbot added this to the 1.59.0 milestone Dec 11, 2021
@compiler-errors compiler-errors deleted the issue-91556 branch April 7, 2022 04:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unmatched brace in a format string crashes the compiler
7 participants