From 59103d1a25ce41321a4d7d304123bb019da11612 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 15 Jul 2021 18:19:07 +0200 Subject: [PATCH 1/2] Fix layout overflow in type declaration --- src/librustdoc/html/static/css/rustdoc.css | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 208e8f723f4..017ce0a494e 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -247,6 +247,9 @@ code, pre, a.test-arrow { pre { padding: 14px; } +.type-decl pre { + overflow-x: auto; +} .source .content pre { padding: 20px; From 25e74037e8c1fda12cc83833d6e49feccb665e0f Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 15 Jul 2021 18:19:25 +0200 Subject: [PATCH 2/2] Add regression test for type declaration layout overflow --- src/test/rustdoc-gui/src/lib2/lib.rs | 7 +++++++ src/test/rustdoc-gui/type-declation-overflow.goml | 8 ++++++++ 2 files changed, 15 insertions(+) create mode 100644 src/test/rustdoc-gui/type-declation-overflow.goml diff --git a/src/test/rustdoc-gui/src/lib2/lib.rs b/src/test/rustdoc-gui/src/lib2/lib.rs index ec8ab339e28..0466909479b 100644 --- a/src/test/rustdoc-gui/src/lib2/lib.rs +++ b/src/test/rustdoc-gui/src/lib2/lib.rs @@ -47,3 +47,10 @@ pub mod sub_mod { /// ``` pub struct Foo; } + +pub mod long_trait { + use std::ops::DerefMut; + + pub trait ALongNameBecauseItHelpsTestingTheCurrentProblem: DerefMut + + From + Send + Sync + AsRef + 'static {} +} diff --git a/src/test/rustdoc-gui/type-declation-overflow.goml b/src/test/rustdoc-gui/type-declation-overflow.goml new file mode 100644 index 00000000000..0a316e220a4 --- /dev/null +++ b/src/test/rustdoc-gui/type-declation-overflow.goml @@ -0,0 +1,8 @@ +// This test ensures that the type declaration content overflow is handled inside the
 directly.
+goto: file://|DOC_PATH|/lib2/long_trait/trait.ALongNameBecauseItHelpsTestingTheCurrentProblem.html
+// We set a fixed size so there is no chance of "random" resize.
+size: (1100, 800)
+// Logically, the  scroll width should be the width of the window.
+assert-property: ("body", {"scrollWidth": "1100"})
+// However, since there is overflow in the type declaration, its scroll width is bigger.
+assert-property: (".type-decl pre", {"scrollWidth": "1324"})