diff --git a/src/librustdoc/html/escape.rs b/src/librustdoc/html/escape.rs index f8199cd6e0e..691f86847b5 100644 --- a/src/librustdoc/html/escape.rs +++ b/src/librustdoc/html/escape.rs @@ -108,13 +108,13 @@ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { || pk.map_or(true, |(_, t)| t.chars().any(|c| c.is_uppercase())); let next_is_underscore = || pk.map_or(true, |(_, t)| t.contains('_')); let next_is_colon = || pk.map_or(true, |(_, t)| t.contains(':')); - if (i - last > 3 && is_uppercase() && !next_is_uppercase()) - || (s.contains('_') && !next_is_underscore()) - { + if i - last > 3 && is_uppercase() && !next_is_uppercase() { EscapeBodyText(&text[last..i]).fmt(fmt)?; fmt.write_str("")?; last = i; - } else if s.contains(':') && !next_is_colon() { + } else if (s.contains(':') && !next_is_colon()) + || (s.contains('_') && !next_is_underscore()) + { EscapeBodyText(&text[last..i + 1]).fmt(fmt)?; fmt.write_str("")?; last = i + 1; diff --git a/src/librustdoc/html/escape/tests.rs b/src/librustdoc/html/escape/tests.rs index e2d81cf5c27..a09649e9e18 100644 --- a/src/librustdoc/html/escape/tests.rs +++ b/src/librustdoc/html/escape/tests.rs @@ -14,16 +14,16 @@ fn escape_body_text_with_wbr() { assert_eq!(&E(" ").to_string(), " "); // real(istic) examples assert_eq!(&E("FirstSecond").to_string(), "FirstSecond"); - assert_eq!(&E("First_Second").to_string(), "First_Second"); + assert_eq!(&E("First_Second").to_string(), "First_Second"); assert_eq!(&E("First Second").to_string(), "First Second"); assert_eq!(&E("First HSecond").to_string(), "First HSecond"); assert_eq!(&E("First HTTPSecond").to_string(), "First HTTPSecond"); assert_eq!(&E("First SecondThird").to_string(), "First SecondThird"); - assert_eq!(&E("First_Second").to_string(), "First<T>_Second"); - assert_eq!(&E("first_second").to_string(), "first_second"); + assert_eq!(&E("First_Second").to_string(), "First<T>_Second"); + assert_eq!(&E("first_second").to_string(), "first_second"); assert_eq!(&E("first:second").to_string(), "first:second"); assert_eq!(&E("first::second").to_string(), "first::second"); - assert_eq!(&E("MY_CONSTANT").to_string(), "MY_CONSTANT"); + assert_eq!(&E("MY_CONSTANT").to_string(), "MY_CONSTANT"); // a string won't get wrapped if it's less than 8 bytes assert_eq!(&E("HashSet").to_string(), "HashSet"); // an individual word won't get wrapped if it's less than 4 bytes diff --git a/tests/rustdoc/item-desc-list-at-start.item-table.html b/tests/rustdoc/item-desc-list-at-start.item-table.html index ab8b1508b55..cff4f816529 100644 --- a/tests/rustdoc/item-desc-list-at-start.item-table.html +++ b/tests/rustdoc/item-desc-list-at-start.item-table.html @@ -1 +1 @@ -MY_CONSTANTGroups: SamplePatternSGIS, SamplePatternEXT \ No newline at end of file +MY_CONSTANTGroups: SamplePatternSGIS, SamplePatternEXT \ No newline at end of file
SamplePatternSGIS
SamplePatternEXT