about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2021-07-16 10:08:09 +0200
committerGitHub <noreply@github.com>2021-07-16 10:08:09 +0200
commita547abe929b750971f5b909149a0be2a3ec7c366 (patch)
treeebf6fa9cd9be4dbfc734adbcb3f777112f39b8da
parent41433795e75fa96e4ad880802879da7892d12fad (diff)
parent25e74037e8c1fda12cc83833d6e49feccb665e0f (diff)
downloadrust-a547abe929b750971f5b909149a0be2a3ec7c366.tar.gz
rust-a547abe929b750971f5b909149a0be2a3ec7c366.zip
Rollup merge of #87162 - GuillaumeGomez:type-decl-overflow, r=notriddle
Fix type decl layout "overflow"

Before:

![Screenshot from 2021-07-15 17-56-12](https://user-images.githubusercontent.com/3050060/125822644-c4595211-d75e-4dd7-ba44-183197ee836c.png)

After:

![Screenshot from 2021-07-15 17-56-17](https://user-images.githubusercontent.com/3050060/125822648-7b363847-e153-4ff3-9fba-59478e32eced.png)

cc ```@SergioBenitez```

r? ```@notriddle```
-rw-r--r--src/librustdoc/html/static/css/rustdoc.css3
-rw-r--r--src/test/rustdoc-gui/src/lib2/lib.rs7
-rw-r--r--src/test/rustdoc-gui/type-declation-overflow.goml8
3 files changed, 18 insertions, 0 deletions
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;
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<Target = u32>
+        + From<u128> + Send + Sync + AsRef<str> + '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 <pre> 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 <body> 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"})