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

Report fatal lexer errors in --cfg command line arguments #89468

Merged
merged 1 commit into from
Oct 23, 2021

Conversation

FabianWolff
Copy link
Contributor

Fixes #89358. The erroneous behavior was apparently introduced by @Mark-Simulacrum in a678e31; the idea is to silence individual parser errors and instead emit one catch-all error message after parsing. However, for the example in #89358, a fatal lexer error is created here:

rustc_lexer::LiteralKind::Str { terminated } => {
if !terminated {
self.sess.span_diagnostic.span_fatal_with_code(
self.mk_sp(start, suffix_start),
"unterminated double quote string",
error_code!(E0765),
)
}
(token::Str, Mode::Str, 1, 1) // " "
}

This fatal error aborts the compilation, and so the call to new_parser_from_source_str() never returns and the catch-all error message is never emitted. I have therefore changed the SilentEmitter to silence only non-fatal errors; with my changes, for the rustc invocation described in #89358:

rustc --cfg "abc\""

I get the following output:

error[E0765]: unterminated double quote string
  |
  = note: this error occurred on the command line: `--cfg=abc"`

@rust-highfive
Copy link
Collaborator

r? @estebank

(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 Oct 2, 2021
@apiraino apiraino added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Oct 14, 2021
@jackh726
Copy link
Member

r? rust-lang/compiler

@rust-highfive rust-highfive assigned jackh726 and unassigned estebank Oct 21, 2021
@jackh726
Copy link
Member

😂

@jackh726
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Oct 22, 2021

📌 Commit 041212f has been approved by jackh726

@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-review Status: Awaiting review from the assignee but also interested parties. labels Oct 22, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 23, 2021
…askrgr

Rollup of 11 pull requests

Successful merges:

 - rust-lang#83233 (Implement split_array and split_array_mut)
 - rust-lang#88300 (Stabilise unix_process_wait_more, extra ExitStatusExt methods)
 - rust-lang#89416 (nice_region_error: Include lifetime placeholders in error output)
 - rust-lang#89468 (Report fatal lexer errors in `--cfg` command line arguments)
 - rust-lang#89730 (add feature flag for `type_changing_struct_update`)
 - rust-lang#89920 (Implement -Z location-detail flag)
 - rust-lang#90070 (Add edition configuration to compiletest)
 - rust-lang#90087 (Sync rustfmt subtree)
 - rust-lang#90117 (Make RSplit<T, P>: Clone not require T: Clone)
 - rust-lang#90122 (CI: make docker cache download and `docker load` time out after 10 minutes)
 - rust-lang#90166 (Add comment documenting why we can't use a simpler solution)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 0f81c7f into rust-lang:master Oct 23, 2021
@rustbot rustbot added this to the 1.58.0 milestone Oct 23, 2021
matthiaskrgr pushed a commit to matthiaskrgr/rust that referenced this pull request Jan 1, 2022
Fixes rust-lang#73026

See also: rust-lang#64467, rust-lang#89468

The issue stems from a `FatalError` being silently raised in
`panictry_buffer`. Normally this is not a problem, because
`panictry_buffer` emits the causes of the error, but they are not
themselves fatal, so they get filtered out by the silent emitter.

To fix this, we use a parser entrypoint which doesn't use
`panictry_buffer`, and we handle the error ourselves.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 1, 2022
Emit an error for `--cfg=)`

Fixes rust-lang#73026

See also: rust-lang#64467, rust-lang#89468

The issue stems from a `FatalError` being silently raised in
`panictry_buffer`. Normally this is not a problem, because
`panictry_buffer` emits the causes of the error, but they are not
themselves fatal, so they get filtered out by the silent emitter.

To fix this, we use a parser entrypoint which doesn't use
`panictry_buffer`, and we handle the error ourselves.
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.

Parse errors not reported sometimes inside --cfg option
8 participants