mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 01:04:03 +00:00
Rollup merge of #103251 - GuillaumeGomez:item-decl-highlighting, r=notriddle
Fix item declaration highlighting Fixes https://github.com/rust-lang/rust/issues/103050. As mentioned in the issue, https://github.com/rust-lang/rust/pull/102924 introduced this regression. This PR partially reverts it and adds a regression test. r? `@notriddle`
This commit is contained in:
commit
e5514b9377
@ -229,44 +229,44 @@ h1 a,
|
||||
color: var(--main-color);
|
||||
}
|
||||
|
||||
span.enum, a.enum,
|
||||
span.struct, a.struct,
|
||||
span.union, a.union,
|
||||
span.primitive, a.primitive,
|
||||
span.type, a.type,
|
||||
span.foreigntype, a.foreigntype {
|
||||
.content span.enum, .content a.enum,
|
||||
.content span.struct, .content a.struct,
|
||||
.content span.union, .content a.union,
|
||||
.content span.primitive, .content a.primitive,
|
||||
.content span.type, .content a.type,
|
||||
.content span.foreigntype, .content a.foreigntype {
|
||||
color: var(--type-link-color);
|
||||
}
|
||||
|
||||
span.trait, a.trait,
|
||||
span.traitalias, a.traitalias {
|
||||
.content span.trait, .content a.trait,
|
||||
.content span.traitalias, .content a.traitalias {
|
||||
color: var(--trait-link-color);
|
||||
}
|
||||
|
||||
span.associatedtype, a.associatedtype,
|
||||
span.constant, a.constant,
|
||||
span.static, a.static {
|
||||
.content span.associatedtype, .content a.associatedtype,
|
||||
.content span.constant, .content a.constant,
|
||||
.content span.static, .content a.static {
|
||||
color: var(--assoc-item-link-color);
|
||||
}
|
||||
|
||||
span.fn, a.fn,
|
||||
.fnname,
|
||||
span.method, a.method,
|
||||
span.tymethod, a.tymethod {
|
||||
.content span.fn, .content a.fn,
|
||||
.content .fnname,
|
||||
.content span.method, .content a.method,
|
||||
.content span.tymethod, .content a.tymethod {
|
||||
color: var(--function-link-color);
|
||||
}
|
||||
|
||||
span.attr, a.attr,
|
||||
span.derive, a.derive,
|
||||
span.macro, a.macro {
|
||||
.content span.attr, .content a.attr,
|
||||
.content span.derive, .content a.derive,
|
||||
.content span.macro, .content a.macro {
|
||||
color: var(--macro-link-color);
|
||||
}
|
||||
|
||||
span.mod, a.mod {
|
||||
.content span.mod, .content a.mod {
|
||||
color: var(--mod-link-color);
|
||||
}
|
||||
|
||||
span.keyword, a.keyword {
|
||||
.content span.keyword, .content a.keyword {
|
||||
color: var(--keyword-link-color);
|
||||
}
|
||||
|
||||
|
74
src/test/rustdoc-gui/item-decl-colors.goml
Normal file
74
src/test/rustdoc-gui/item-decl-colors.goml
Normal file
@ -0,0 +1,74 @@
|
||||
// This test ensures that the color of the items in the type decl are working as expected.
|
||||
define-function: (
|
||||
"check-colors",
|
||||
(
|
||||
theme,
|
||||
attr_color,
|
||||
trait_color,
|
||||
struct_color,
|
||||
enum_color,
|
||||
primitive_color,
|
||||
constant_color,
|
||||
fn_color,
|
||||
assoc_type_color,
|
||||
),
|
||||
[
|
||||
("goto", "file://" + |DOC_PATH| + "/test_docs/struct.WithGenerics.html"),
|
||||
("show-text", true),
|
||||
("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
|
||||
("reload"),
|
||||
("assert-css", (".item-decl .code-attribute", {"color": |attr_color|}, ALL)),
|
||||
("assert-css", (".item-decl .trait", {"color": |trait_color|}, ALL)),
|
||||
// We need to add `code` here because otherwise it would select the parent too.
|
||||
("assert-css", (".item-decl code .struct", {"color": |struct_color|}, ALL)),
|
||||
("assert-css", (".item-decl .enum", {"color": |enum_color|}, ALL)),
|
||||
("assert-css", (".item-decl .primitive", {"color": |primitive_color|}, ALL)),
|
||||
("goto", "file://" + |DOC_PATH| + "/test_docs/trait.TraitWithoutGenerics.html"),
|
||||
("assert-css", (".item-decl .constant", {"color": |constant_color|}, ALL)),
|
||||
("assert-css", (".item-decl .fnname", {"color": |fn_color|}, ALL)),
|
||||
("assert-css", (".item-decl .associatedtype", {"color": |assoc_type_color|}, ALL)),
|
||||
],
|
||||
)
|
||||
|
||||
call-function: (
|
||||
"check-colors",
|
||||
{
|
||||
"theme": "ayu",
|
||||
"attr_color": "rgb(153, 153, 153)",
|
||||
"trait_color": "rgb(57, 175, 215)",
|
||||
"struct_color": "rgb(255, 160, 165)",
|
||||
"enum_color": "rgb(255, 160, 165)",
|
||||
"primitive_color": "rgb(255, 160, 165)",
|
||||
"constant_color": "rgb(57, 175, 215)",
|
||||
"fn_color": "rgb(253, 214, 135)",
|
||||
"assoc_type_color": "rgb(57, 175, 215)",
|
||||
},
|
||||
)
|
||||
call-function: (
|
||||
"check-colors",
|
||||
{
|
||||
"theme": "dark",
|
||||
"attr_color": "rgb(153, 153, 153)",
|
||||
"trait_color": "rgb(183, 140, 242)",
|
||||
"struct_color": "rgb(45, 191, 184)",
|
||||
"enum_color": "rgb(45, 191, 184)",
|
||||
"primitive_color": "rgb(45, 191, 184)",
|
||||
"constant_color": "rgb(210, 153, 29)",
|
||||
"fn_color": "rgb(43, 171, 99)",
|
||||
"assoc_type_color": "rgb(210, 153, 29)",
|
||||
},
|
||||
)
|
||||
call-function: (
|
||||
"check-colors",
|
||||
{
|
||||
"theme": "light",
|
||||
"attr_color": "rgb(153, 153, 153)",
|
||||
"trait_color": "rgb(110, 79, 201)",
|
||||
"struct_color": "rgb(173, 55, 138)",
|
||||
"enum_color": "rgb(173, 55, 138)",
|
||||
"primitive_color": "rgb(173, 55, 138)",
|
||||
"constant_color": "rgb(56, 115, 173)",
|
||||
"fn_color": "rgb(173, 124, 55)",
|
||||
"assoc_type_color": "rgb(56, 115, 173)",
|
||||
},
|
||||
)
|
@ -20,11 +20,12 @@ assert-text: (".sidebar-elems section ul > li:nth-child(2)", "Modules")
|
||||
assert-text: (".sidebar-elems section ul > li:nth-child(3)", "Macros")
|
||||
assert-text: (".sidebar-elems section ul > li:nth-child(4)", "Structs")
|
||||
assert-text: (".sidebar-elems section ul > li:nth-child(5)", "Enums")
|
||||
assert-text: (".sidebar-elems section ul > li:nth-child(6)", "Traits")
|
||||
assert-text: (".sidebar-elems section ul > li:nth-child(7)", "Functions")
|
||||
assert-text: (".sidebar-elems section ul > li:nth-child(8)", "Type Definitions")
|
||||
assert-text: (".sidebar-elems section ul > li:nth-child(9)", "Unions")
|
||||
assert-text: (".sidebar-elems section ul > li:nth-child(10)", "Keywords")
|
||||
assert-text: (".sidebar-elems section ul > li:nth-child(6)", "Constants")
|
||||
assert-text: (".sidebar-elems section ul > li:nth-child(7)", "Traits")
|
||||
assert-text: (".sidebar-elems section ul > li:nth-child(8)", "Functions")
|
||||
assert-text: (".sidebar-elems section ul > li:nth-child(9)", "Type Definitions")
|
||||
assert-text: (".sidebar-elems section ul > li:nth-child(10)", "Unions")
|
||||
assert-text: (".sidebar-elems section ul > li:nth-child(11)", "Keywords")
|
||||
assert-text: ("#structs + .item-table .item-left > a", "Foo")
|
||||
click: "#structs + .item-table .item-left > a"
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#![crate_name = "test_docs"]
|
||||
#![feature(rustdoc_internals)]
|
||||
#![feature(doc_cfg)]
|
||||
#![feature(associated_type_defaults)]
|
||||
|
||||
/*!
|
||||
Enable the feature <span class="stab portability"><code>some-feature</code></span> to enjoy
|
||||
@ -386,3 +387,20 @@ impl TypeWithNoDocblocks {
|
||||
pub unsafe fn unsafe_fn() {}
|
||||
|
||||
pub fn safe_fn() {}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct WithGenerics<T: TraitWithNoDocblocks, S = String, E = WhoLetTheDogOut, P = i8> {
|
||||
s: S,
|
||||
t: T,
|
||||
e: E,
|
||||
p: P,
|
||||
}
|
||||
|
||||
pub const CONST: u8 = 0;
|
||||
|
||||
pub trait TraitWithoutGenerics {
|
||||
const C: u8 = CONST;
|
||||
type T = SomeType;
|
||||
|
||||
fn foo();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user