about summary refs log tree commit diff
path: root/src/librustdoc
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2020-09-27 16:15:26 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2020-10-03 14:16:24 +0200
commit30cabfd215f374b855f6d6473b00a55c3511c3e2 (patch)
treea0808301f08cc30635f2db5d733cc5d2aee50b3c /src/librustdoc
parentb2321bb8da18c753fe3b9b71937a368ae42b8c4b (diff)
downloadrust-30cabfd215f374b855f6d6473b00a55c3511c3e2.tar.gz
rust-30cabfd215f374b855f6d6473b00a55c3511c3e2.zip
Don't warn if the tag is nested inside a <script> or inside a <style>
Diffstat (limited to 'src/librustdoc')
-rw-r--r--src/librustdoc/passes/html_tags.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/librustdoc/passes/html_tags.rs b/src/librustdoc/passes/html_tags.rs
index 79035ba79ff..490e913fbde 100644
--- a/src/librustdoc/passes/html_tags.rs
+++ b/src/librustdoc/passes/html_tags.rs
@@ -48,8 +48,11 @@ fn drop_tag(
     if let Some(pos) = tags.iter().rev().position(|(t, _)| *t == tag_name) {
         // Because this is from a `rev` iterator, the position is reversed as well!
         let pos = tags.len() - 1 - pos;
+        // If the tag is nested inside a "<script>", not warning should be emitted.
+        let should_not_warn =
+            tags.iter().take(pos + 1).any(|(at, _)| at == "script" || at == "style");
         for (last_tag_name, last_tag_span) in tags.drain(pos + 1..) {
-            if ALLOWED_UNCLOSED.iter().any(|&at| at == &last_tag_name) {
+            if should_not_warn || ALLOWED_UNCLOSED.iter().any(|&at| at == &last_tag_name) {
                 continue;
             }
             // `tags` is used as a queue, meaning that everything after `pos` is included inside it.