Skip to content

Commit

Permalink
Rollup merge of rust-lang#102633 - Nilstrieb:rustdoc-lint-🏳️‍⚧️late, …
Browse files Browse the repository at this point in the history
…r=davidtwco

Fix rustdoc ICE in invalid_rust_codeblocks lint

The diagnostic message extraction code didn't handle translations yet.
Fixes rust-lang#102603
Fixes rust-lang#102631

r? `@davidtwco`
  • Loading branch information
Dylan-DPC authored Oct 4, 2022
2 parents 35f92ed + 1456f73 commit f7ca465
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/librustdoc/passes/check_code_block_syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,11 @@ impl Translate for BufferEmitter {
impl Emitter for BufferEmitter {
fn emit_diagnostic(&mut self, diag: &Diagnostic) {
let mut buffer = self.buffer.borrow_mut();
// FIXME(davidtwco): need to support translation here eventually
buffer.messages.push(format!("error from rustc: {}", diag.message[0].0.expect_str()));

let fluent_args = self.to_fluent_args(diag.args());
let translated_main_message = self.translate_message(&diag.message[0].0, &fluent_args);

buffer.messages.push(format!("error from rustc: {}", translated_main_message));
if diag.is_error() {
buffer.has_errors = true;
}
Expand Down
6 changes: 6 additions & 0 deletions src/test/rustdoc-ui/invalid-syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,9 @@ pub fn indent_after_fenced() {}
/// ```
pub fn invalid() {}
//~^^^^ WARNING could not parse code block as Rust code

/// ```
/// fn wook_at_my_beautifuw_bwaces_plz() {);
/// ```
pub fn uwu() {}
//~^^^^ WARNING could not parse code block as Rust code
17 changes: 16 additions & 1 deletion src/test/rustdoc-ui/invalid-syntax.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,20 @@ help: mark blocks that do not contain Rust code as text
LL | /// ```text
| ++++

warning: 12 warnings emitted
warning: could not parse code block as Rust code
--> $DIR/invalid-syntax.rs:103:5
|
LL | /// ```
| _____^
LL | | /// fn wook_at_my_beautifuw_bwaces_plz() {);
LL | | /// ```
| |_______^
|
= note: error from rustc: mismatched closing delimiter: `)`
help: mark blocks that do not contain Rust code as text
|
LL | /// ```text
| ++++

warning: 13 warnings emitted

0 comments on commit f7ca465

Please sign in to comment.