Skip to content

Commit f7ca465

Browse files
authored
Rollup merge of #102633 - Nilstrieb:rustdoc-lint-🏳️‍⚧️late, r=davidtwco
Fix rustdoc ICE in invalid_rust_codeblocks lint The diagnostic message extraction code didn't handle translations yet. Fixes #102603 Fixes #102631 r? `@davidtwco`
2 parents 35f92ed + 1456f73 commit f7ca465

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

src/librustdoc/passes/check_code_block_syntax.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,11 @@ impl Translate for BufferEmitter {
192192
impl Emitter for BufferEmitter {
193193
fn emit_diagnostic(&mut self, diag: &Diagnostic) {
194194
let mut buffer = self.buffer.borrow_mut();
195-
// FIXME(davidtwco): need to support translation here eventually
196-
buffer.messages.push(format!("error from rustc: {}", diag.message[0].0.expect_str()));
195+
196+
let fluent_args = self.to_fluent_args(diag.args());
197+
let translated_main_message = self.translate_message(&diag.message[0].0, &fluent_args);
198+
199+
buffer.messages.push(format!("error from rustc: {}", translated_main_message));
197200
if diag.is_error() {
198201
buffer.has_errors = true;
199202
}

src/test/rustdoc-ui/invalid-syntax.rs

+6
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,9 @@ pub fn indent_after_fenced() {}
9999
/// ```
100100
pub fn invalid() {}
101101
//~^^^^ WARNING could not parse code block as Rust code
102+
103+
/// ```
104+
/// fn wook_at_my_beautifuw_bwaces_plz() {);
105+
/// ```
106+
pub fn uwu() {}
107+
//~^^^^ WARNING could not parse code block as Rust code

src/test/rustdoc-ui/invalid-syntax.stderr

+16-1
Original file line numberDiff line numberDiff line change
@@ -150,5 +150,20 @@ help: mark blocks that do not contain Rust code as text
150150
LL | /// ```text
151151
| ++++
152152

153-
warning: 12 warnings emitted
153+
warning: could not parse code block as Rust code
154+
--> $DIR/invalid-syntax.rs:103:5
155+
|
156+
LL | /// ```
157+
| _____^
158+
LL | | /// fn wook_at_my_beautifuw_bwaces_plz() {);
159+
LL | | /// ```
160+
| |_______^
161+
|
162+
= note: error from rustc: mismatched closing delimiter: `)`
163+
help: mark blocks that do not contain Rust code as text
164+
|
165+
LL | /// ```text
166+
| ++++
167+
168+
warning: 13 warnings emitted
154169

0 commit comments

Comments
 (0)