Skip to content

Commit 9527d6a

Browse files
committed
Moved non_exhaustive message to fields/variants section and onto type.
1 parent 5ccafa1 commit 9527d6a

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
lines changed

src/librustdoc/html/render.rs

+14-17
Original file line numberDiff line numberDiff line change
@@ -2194,7 +2194,6 @@ fn document(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Re
21942194
info!("Documenting {}", name);
21952195
}
21962196
document_stability(w, cx, item)?;
2197-
document_non_exhaustive(w, item)?;
21982197
let prefix = render_assoc_const_value(item);
21992198
document_full(w, item, cx, &prefix)?;
22002199
Ok(())
@@ -2263,20 +2262,13 @@ fn document_stability(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item)
22632262
Ok(())
22642263
}
22652264

2265+
fn document_non_exhaustive_header(item: &clean::Item) -> &str {
2266+
if item.is_non_exhaustive() { " (Non-exhaustive)" } else { "" }
2267+
}
2268+
22662269
fn document_non_exhaustive(w: &mut fmt::Formatter, item: &clean::Item) -> fmt::Result {
22672270
if item.is_non_exhaustive() {
2268-
write!(w, "<div class='non-exhaustive'><div class='stab non-exhaustive'>")?;
2269-
write!(w, "<details><summary><span class=microscope>🔬</span>")?;
2270-
2271-
if item.is_struct() {
2272-
write!(w, "This struct is marked as non exhaustive.")?;
2273-
} else if item.is_enum() {
2274-
write!(w, "This enum is marked as non exhaustive.")?;
2275-
} else {
2276-
write!(w, "This type is marked as non exhaustive.")?;
2277-
}
2278-
2279-
write!(w, "</summary><p>")?;
2271+
write!(w, "<p class='non-exhaustive'>")?;
22802272

22812273
if item.is_struct() {
22822274
write!(w, "This struct is marked as non-exhaustive as additional fields may be \
@@ -2293,7 +2285,7 @@ fn document_non_exhaustive(w: &mut fmt::Formatter, item: &clean::Item) -> fmt::R
22932285
constructors.")?;
22942286
}
22952287

2296-
write!(w, "</p></details></div></div>")?;
2288+
write!(w, "</p>")?;
22972289
}
22982290

22992291
Ok(())
@@ -3159,7 +3151,9 @@ fn item_struct(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
31593151
if let doctree::Plain = s.struct_type {
31603152
if fields.peek().is_some() {
31613153
write!(w, "<h2 id='fields' class='fields small-section-header'>
3162-
Fields<a href='#fields' class='anchor'></a></h2>")?;
3154+
Fields{}<a href='#fields' class='anchor'></a></h2>",
3155+
document_non_exhaustive_header(it))?;
3156+
document_non_exhaustive(w, it)?;
31633157
for (field, ty) in fields {
31643158
let id = derive_id(format!("{}.{}",
31653159
ItemType::StructField,
@@ -3291,7 +3285,9 @@ fn item_enum(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
32913285
document(w, cx, it)?;
32923286
if !e.variants.is_empty() {
32933287
write!(w, "<h2 id='variants' class='variants small-section-header'>
3294-
Variants<a href='#variants' class='anchor'></a></h2>\n")?;
3288+
Variants{}<a href='#variants' class='anchor'></a></h2>\n",
3289+
document_non_exhaustive_header(it))?;
3290+
document_non_exhaustive(w, it)?;
32953291
for variant in &e.variants {
32963292
let id = derive_id(format!("{}.{}",
32973293
ItemType::Variant,
@@ -3392,7 +3388,8 @@ const ATTRIBUTE_WHITELIST: &'static [&'static str] = &[
33923388
"must_use",
33933389
"no_mangle",
33943390
"repr",
3395-
"unsafe_destructor_blind_to_params"
3391+
"unsafe_destructor_blind_to_params",
3392+
"non_exhaustive"
33963393
];
33973394

33983395
fn render_attributes(w: &mut fmt::Formatter, it: &clean::Item) -> fmt::Result {

src/librustdoc/html/static/themes/dark.css

+2-1
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ pre {
148148
.content .fnname{ color: #2BAB63; }
149149
.content span.keyword, .content a.keyword, .block a.current.keyword { color: #de5249; }
150150

151+
.non-exhaustive { color: #DDD; margin-bottom: 1em; }
152+
151153
pre.rust .comment { color: #8d8d8b; }
152154
pre.rust .doccomment { color: #8ca375; }
153155

@@ -188,7 +190,6 @@ a.test-arrow {
188190
border-color: #008dfd;
189191
}
190192

191-
.stab.non-exhaustive { background: #2a2a2a; border-color: #707070; }
192193
.stab.unstable { background: #FFF5D6; border-color: #FFC600; color: #404040; }
193194
.stab.deprecated { background: #F3DFFF; border-color: #7F0087; color: #404040; }
194195
.stab.portability { background: #C4ECFF; border-color: #7BA5DB; color: #404040; }

src/librustdoc/html/static/themes/light.css

+2-1
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ pre {
148148
.content .fnname { color: #9a6e31; }
149149
.content span.keyword, .content a.keyword, .block a.current.keyword { color: #de5249; }
150150

151+
.non-exhaustive { color: #222; margin-bottom: 1em; }
152+
151153
pre.rust .comment { color: #8E908C; }
152154
pre.rust .doccomment { color: #4D4D4C; }
153155

@@ -188,7 +190,6 @@ a.test-arrow {
188190
border-color: #66afe9;
189191
}
190192

191-
.stab.non-exhaustive { background: #F5F5F5; border-color: #D3D3D3; }
192193
.stab.unstable { background: #FFF5D6; border-color: #FFC600; }
193194
.stab.deprecated { background: #F3DFFF; border-color: #7F0087; }
194195
.stab.portability { background: #C4ECFF; border-color: #7BA5DB; }

0 commit comments

Comments
 (0)