about summary refs log tree commit diff
path: root/src/doc
diff options
context:
space:
mode:
authorLukas Markeffsky <@>2022-12-17 23:22:48 +0100
committerLukas Markeffsky <@>2023-04-29 13:13:25 +0200
commit4f15a772b3ac7b56f177bcad4d59ad399844e588 (patch)
tree1b562298649d69bb33451365bca5fb109313b53d /src/doc
parentaf2c7e0f9b5730b9598ca70fc67360fa69b469c8 (diff)
downloadrust-4f15a772b3ac7b56f177bcad4d59ad399844e588.tar.gz
rust-4f15a772b3ac7b56f177bcad4d59ad399844e588.zip
Add `rustdoc::unescaped_backtick` lint
Diffstat (limited to 'src/doc')
-rw-r--r--src/doc/rustdoc/src/lints.md38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/doc/rustdoc/src/lints.md b/src/doc/rustdoc/src/lints.md
index 45db3bb9b00..fd57b079644 100644
--- a/src/doc/rustdoc/src/lints.md
+++ b/src/doc/rustdoc/src/lints.md
@@ -374,3 +374,41 @@ warning: this URL is not a hyperlink
 
 warning: 2 warnings emitted
 ```
+
+## `unescaped_backticks`
+
+This lint is **allowed by default**. It detects backticks (\`) that are not escaped.
+This usually means broken inline code. For example:
+
+```rust
+#![warn(rustdoc::unescaped_backticks)]
+
+/// `add(a, b) is the same as `add(b, a)`.
+pub fn add(a: i32, b: i32) -> i32 { a + b }
+```
+
+Which will give:
+
+```text
+warning: unescaped backtick
+ --> src/lib.rs:3:41
+  |
+3 | /// `add(a, b) is the same as `add(b, a)`.
+  |                                         ^
+  |
+note: the lint level is defined here
+ --> src/lib.rs:1:9
+  |
+1 | #![warn(rustdoc::unescaped_backticks)]
+  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+help: a previous inline code might be longer than expected
+  |
+3 | /// `add(a, b)` is the same as `add(b, a)`.
+  |               +
+help: if you meant to use a literal backtick, escape it
+  |
+3 | /// `add(a, b) is the same as `add(b, a)\`.
+  |                                         +
+
+warning: 1 warning emitted
+```