diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-10-08 23:32:03 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-08 23:32:03 +0200 |
| commit | 6776cac4c1ba658fb9154a27fbe54a49f46b4071 (patch) | |
| tree | 61aa9c05833e9528f945cce237722903a5a9ea07 | |
| parent | e6f6ad0576d6488770c54176de029520caebb88d (diff) | |
| parent | bf510b4deddf99d9321d86754c18d2a143233b11 (diff) | |
| download | rust-6776cac4c1ba658fb9154a27fbe54a49f46b4071.tar.gz rust-6776cac4c1ba658fb9154a27fbe54a49f46b4071.zip | |
Rollup merge of #102524 - notriddle:notriddle/unsafe-function, r=GuillaumeGomez
rustdoc: remove weird `<a href="#">` wrapper around unsafe triangle This DOM cleanup changes the color of the triangle, from blue to black, but since it's still a different color from the link it's next to, it should still be noticeable. # Before  # After 
| -rw-r--r-- | src/librustdoc/html/render/print_item.rs | 2 | ||||
| -rw-r--r-- | src/test/rustdoc-gui/src/test_docs/lib.rs | 4 | ||||
| -rw-r--r-- | src/test/rustdoc-gui/unsafe-fn.goml | 37 |
3 files changed, 42 insertions, 1 deletions
diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 7999373511b..6327817364a 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -400,7 +400,7 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items: if myitem.fn_header(cx.tcx()).unwrap().unsafety == hir::Unsafety::Unsafe => { - "<a title=\"unsafe function\" href=\"#\"><sup>⚠</sup></a>" + "<sup title=\"unsafe function\">⚠</sup>" } _ => "", }; diff --git a/src/test/rustdoc-gui/src/test_docs/lib.rs b/src/test/rustdoc-gui/src/test_docs/lib.rs index 0281973c1ba..33c74e3a331 100644 --- a/src/test/rustdoc-gui/src/test_docs/lib.rs +++ b/src/test/rustdoc-gui/src/test_docs/lib.rs @@ -367,3 +367,7 @@ impl TypeWithNoDocblocks { pub fn first_fn(&self) {} pub fn second_fn(&self) {} } + +pub unsafe fn unsafe_fn() {} + +pub fn safe_fn() {} diff --git a/src/test/rustdoc-gui/unsafe-fn.goml b/src/test/rustdoc-gui/unsafe-fn.goml new file mode 100644 index 00000000000..94f128db72e --- /dev/null +++ b/src/test/rustdoc-gui/unsafe-fn.goml @@ -0,0 +1,37 @@ +goto: "file://" + |DOC_PATH| + "/test_docs/index.html" + +compare-elements-property: ( + "//a[@title='test_docs::safe_fn fn']/..", + "//a[@title='test_docs::unsafe_fn fn']/..", + ["clientHeight"] +) + +// If the text isn't displayed, the browser doesn't compute color style correctly... +show-text: true + +// Set the theme to dark. +local-storage: {"rustdoc-theme": "dark", "rustdoc-preferred-dark-theme": "dark", "rustdoc-use-system-theme": "false"} +// We reload the page so the local storage settings are being used. +reload: + +assert-css: (".item-left sup", { + "color": "rgb(221, 221, 221)" +}) + +// Set the theme to ayu. +local-storage: {"rustdoc-theme": "ayu", "rustdoc-preferred-dark-theme": "ayu", "rustdoc-use-system-theme": "false"} +// We reload the page so the local storage settings are being used. +reload: + +assert-css: (".item-left sup", { + "color": "rgb(197, 197, 197)" +}) + +// Set the theme to light. +local-storage: {"rustdoc-theme": "light", "rustdoc-preferred-dark-theme": "light", "rustdoc-use-system-theme": "false"} +// We reload the page so the local storage settings are being used. +reload: + +assert-css: (".item-left sup", { + "color": "rgb(0, 0, 0)" +}) |
