Skip to content

Commit 6776cac

Browse files
authored
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 ![image](https://user-images.githubusercontent.com/1593513/193352428-929b3026-acc3-448e-9bac-44dddf206b1d.png) # After ![image](https://user-images.githubusercontent.com/1593513/193352500-2f7a0112-b478-4cc4-9ddb-32ba11575530.png)
2 parents e6f6ad0 + bf510b4 commit 6776cac

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

src/librustdoc/html/render/print_item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items:
400400
if myitem.fn_header(cx.tcx()).unwrap().unsafety
401401
== hir::Unsafety::Unsafe =>
402402
{
403-
"<a title=\"unsafe function\" href=\"#\"><sup>⚠</sup></a>"
403+
"<sup title=\"unsafe function\">⚠</sup>"
404404
}
405405
_ => "",
406406
};

src/test/rustdoc-gui/src/test_docs/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -367,3 +367,7 @@ impl TypeWithNoDocblocks {
367367
pub fn first_fn(&self) {}
368368
pub fn second_fn(&self) {}
369369
}
370+
371+
pub unsafe fn unsafe_fn() {}
372+
373+
pub fn safe_fn() {}

src/test/rustdoc-gui/unsafe-fn.goml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
2+
3+
compare-elements-property: (
4+
"//a[@title='test_docs::safe_fn fn']/..",
5+
"//a[@title='test_docs::unsafe_fn fn']/..",
6+
["clientHeight"]
7+
)
8+
9+
// If the text isn't displayed, the browser doesn't compute color style correctly...
10+
show-text: true
11+
12+
// Set the theme to dark.
13+
local-storage: {"rustdoc-theme": "dark", "rustdoc-preferred-dark-theme": "dark", "rustdoc-use-system-theme": "false"}
14+
// We reload the page so the local storage settings are being used.
15+
reload:
16+
17+
assert-css: (".item-left sup", {
18+
"color": "rgb(221, 221, 221)"
19+
})
20+
21+
// Set the theme to ayu.
22+
local-storage: {"rustdoc-theme": "ayu", "rustdoc-preferred-dark-theme": "ayu", "rustdoc-use-system-theme": "false"}
23+
// We reload the page so the local storage settings are being used.
24+
reload:
25+
26+
assert-css: (".item-left sup", {
27+
"color": "rgb(197, 197, 197)"
28+
})
29+
30+
// Set the theme to light.
31+
local-storage: {"rustdoc-theme": "light", "rustdoc-preferred-dark-theme": "light", "rustdoc-use-system-theme": "false"}
32+
// We reload the page so the local storage settings are being used.
33+
reload:
34+
35+
assert-css: (".item-left sup", {
36+
"color": "rgb(0, 0, 0)"
37+
})

0 commit comments

Comments
 (0)