-
Notifications
You must be signed in to change notification settings - Fork 889
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
Confusing error message on syntax error in code in doc comments #6109
Comments
Thanks for the report. Just want to understand how you're calling rustfmt. Are you running rustfmt directly on a file or is it your editor that's invoking rustfmt? |
Linking the tracking issue |
Calling through |
@feds01 by the way, what version of rustfmt are you using? |
@davidtwco I'm assuming this might have been caused by sharing the Do you think it's possible to modify rustc's |
|
…diagnostic, r=davidtwco conditionally ignore fatal diagnostic in the SilentEmitter This change is primarily meant to allow rustfmt to ignore all diagnostics when using the `SilentEmitter`. Back in rust-lang#121301 the `SilentEmitter` was shared between rustc and rustfmt. This changed rustfmt's behavior from ignoring all diagnostic to emitting fatal diagnostics, which lead to rust-lang/rustfmt#6109. These changes allow rustfmt to maintain its previous behaviour when using the `SilentEmitter`, while allowing rustc code to still emit fatal diagnostics.
…diagnostic, r=davidtwco conditionally ignore fatal diagnostic in the SilentEmitter This change is primarily meant to allow rustfmt to ignore all diagnostics when using the `SilentEmitter`. Back in rust-lang#121301 the `SilentEmitter` was shared between rustc and rustfmt. This changed rustfmt's behavior from ignoring all diagnostic to emitting fatal diagnostics, which lead to rust-lang/rustfmt#6109. These changes allow rustfmt to maintain its previous behaviour when using the `SilentEmitter`, while allowing rustc code to still emit fatal diagnostics.
Rollup merge of rust-lang#122737 - ytmimi:conditionally_ignore_fatal_diagnostic, r=davidtwco conditionally ignore fatal diagnostic in the SilentEmitter This change is primarily meant to allow rustfmt to ignore all diagnostics when using the `SilentEmitter`. Back in rust-lang#121301 the `SilentEmitter` was shared between rustc and rustfmt. This changed rustfmt's behavior from ignoring all diagnostic to emitting fatal diagnostics, which lead to rust-lang/rustfmt#6109. These changes allow rustfmt to maintain its previous behaviour when using the `SilentEmitter`, while allowing rustc code to still emit fatal diagnostics.
…diagnostic, r=davidtwco conditionally ignore fatal diagnostic in the SilentEmitter This change is primarily meant to allow rustfmt to ignore all diagnostics when using the `SilentEmitter`. Back in rust-lang#121301 the `SilentEmitter` was shared between rustc and rustfmt. This changed rustfmt's behavior from ignoring all diagnostic to emitting fatal diagnostics, which lead to rust-lang/rustfmt#6109. These changes allow rustfmt to maintain its previous behaviour when using the `SilentEmitter`, while allowing rustc code to still emit fatal diagnostics.
I just tested with the @feds01 when you have a moment could you also confirm this: Steps to confirm:
|
Before closing this issue I think it would be great if we could add a test case to prevent a regression |
It is now not reporting any issues with the file, is the desired behaviour? |
@feds01 In this case yes. The previous behavior was for rustfmt to ignore the diagnostic message produced by the rustc parser, however there were some internal changes made in |
…c, r=davidtwco conditionally ignore fatal diagnostic in the SilentEmitter This change is primarily meant to allow rustfmt to ignore all diagnostics when using the `SilentEmitter`. Back in #121301 the `SilentEmitter` was shared between rustc and rustfmt. This changed rustfmt's behavior from ignoring all diagnostic to emitting fatal diagnostics, which lead to rust-lang#6109. These changes allow rustfmt to maintain its previous behaviour when using the `SilentEmitter`, while allowing rustc code to still emit fatal diagnostics.
Hi, I'm planning to help with this as my first contribution. From looking at the contributing.md doc I understand that I would need to create single target file with the code mentioned at the top of this issue? |
@giordan12 that's great. I appreciate you wanting to take this one one. Yes, you can add a test case in the |
@ytmimi appreciate the guidance, just created the PR. Let me know if there is something to add (I'm expecting there will be :) ) |
closing now that #6232 is merged |
Thanks for this guys |
@ytmimi I was wondering if it's worth making it clear in Contributing.md that besides creating source and target files an actual test is needed? The current text makes it look like it's enough to make the test files IMO |
I don't think it's necessary. It's mostly this specific case since I wanted to add a test to ensure nothing was being output to stdout and stderr. Typically a source and target file are all that's required |
When enabling
format_code_in_doc_comments
, the formatter reports that there is a syntax issue in a code block. However the syntax issue source location seems to be confusing/ambigious:Running
rustfmt
on the following code snippet produces a confusing error message:The error that is produced:
This is not explicitly a bug, but nonetheless is confusing as it does not indicate the true origin of the issue.
The text was updated successfully, but these errors were encountered: