Auto merge of #104351 - JohnTitor:rollup-ikh2dzr, r=JohnTitor

Rollup of 5 pull requests

Successful merges:

 - #103650 (rustdoc: change `.src-line-numbers > span` to `.src-line-numbers > a`)
 - #104177 (rustdoc: use consistent "popover" styling for notable traits)
 - #104318 (Move tests)
 - #104323 (rustdoc: remove no-op CSS `.scrape-help { background: transparent }`)
 - #104345 (Fix up a Fluent message)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2022-11-13 09:13:41 +00:00
commit 928d14bcd1
41 changed files with 239 additions and 179 deletions

View File

@ -126,10 +126,10 @@ infer_data_lifetime_flow = ...but data with one lifetime flows into the other he
infer_declared_multiple = this type is declared with multiple lifetimes... infer_declared_multiple = this type is declared with multiple lifetimes...
infer_types_declared_different = these two types are declared with different lifetimes... infer_types_declared_different = these two types are declared with different lifetimes...
infer_data_flows = ...but data{$label_var1_exists -> infer_data_flows = ...but data{$label_var1_exists ->
[true] -> {" "}from `{$label_var1}` [true] {" "}from `{$label_var1}`
*[false] -> {""} *[false] -> {""}
} flows{$label_var2_exists -> } flows{$label_var2_exists ->
[true] -> {" "}into `{$label_var2}` [true] {" "}into `{$label_var2}`
*[false] -> {""} *[false] -> {""}
} here } here

View File

@ -1312,9 +1312,7 @@ pub(crate) fn notable_traits_button(ty: &clean::Type, cx: &mut Context<'_>) -> O
if has_notable_trait { if has_notable_trait {
cx.types_with_notable_traits.insert(ty.clone()); cx.types_with_notable_traits.insert(ty.clone());
Some(format!( Some(format!(
"<span class=\"notable-traits\" data-ty=\"{ty}\">\ " <a href=\"#\" class=\"notable-traits\" data-ty=\"{ty}\">ⓘ</a>",
<span class=\"notable-traits-tooltip\">ⓘ</span>\
</span>",
ty = Escape(&format!("{:#}", ty.print(cx))), ty = Escape(&format!("{:#}", ty.print(cx))),
)) ))
} else { } else {
@ -1343,7 +1341,7 @@ fn notable_traits_decl(ty: &clean::Type, cx: &Context<'_>) -> (String, String) {
if out.is_empty() { if out.is_empty() {
write!( write!(
&mut out, &mut out,
"<h3 class=\"notable\">Notable traits for <code>{}</code></h3>\ "<h3>Notable traits for <code>{}</code></h3>\
<pre class=\"content\"><code>", <pre class=\"content\"><code>",
impl_.for_.print(cx) impl_.for_.print(cx)
); );
@ -2939,9 +2937,6 @@ fn render_call_locations(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Ite
})() })()
.unwrap_or(rustc_span::DUMMY_SP); .unwrap_or(rustc_span::DUMMY_SP);
// The root path is the inverse of Context::current
let root_path = vec!["../"; cx.current.len() - 1].join("");
let mut decoration_info = FxHashMap::default(); let mut decoration_info = FxHashMap::default();
decoration_info.insert("highlight focus", vec![byte_ranges.remove(0)]); decoration_info.insert("highlight focus", vec![byte_ranges.remove(0)]);
decoration_info.insert("highlight", byte_ranges); decoration_info.insert("highlight", byte_ranges);
@ -2951,7 +2946,7 @@ fn render_call_locations(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Ite
contents_subset, contents_subset,
file_span, file_span,
cx, cx,
&root_path, &cx.root_path(),
highlight::DecorationInfo(decoration_info), highlight::DecorationInfo(decoration_info),
sources::SourceContext::Embedded { offset: line_min, needs_expansion }, sources::SourceContext::Embedded { offset: line_min, needs_expansion },
); );

View File

@ -276,25 +276,26 @@ pub(crate) fn print_src(
let mut line_numbers = Buffer::empty_from(buf); let mut line_numbers = Buffer::empty_from(buf);
let extra; let extra;
line_numbers.write_str("<pre class=\"src-line-numbers\">"); line_numbers.write_str("<pre class=\"src-line-numbers\">");
let current_href = &context
.href_from_span(clean::Span::new(file_span), false)
.expect("only local crates should have sources emitted");
match source_context { match source_context {
SourceContext::Standalone => { SourceContext::Standalone => {
extra = None; extra = None;
for line in 1..=lines { for line in 1..=lines {
writeln!(line_numbers, "<span id=\"{0}\">{0}</span>", line) writeln!(line_numbers, "<a href=\"#{line}\" id=\"{line}\">{line}</a>")
} }
} }
SourceContext::Embedded { offset, needs_expansion } => { SourceContext::Embedded { offset, needs_expansion } => {
extra = extra =
if needs_expansion { Some(r#"<span class="expand">&varr;</span>"#) } else { None }; if needs_expansion { Some(r#"<span class="expand">&varr;</span>"#) } else { None };
for line in 1..=lines { for line_number in 1..=lines {
writeln!(line_numbers, "<span>{0}</span>", line + offset) let line = line_number + offset;
writeln!(line_numbers, "<span>{line}</span>")
} }
} }
} }
line_numbers.write_str("</pre>"); line_numbers.write_str("</pre>");
let current_href = &context
.href_from_span(clean::Span::new(file_span), false)
.expect("only local crates should have sources emitted");
highlight::render_source_with_highlighting( highlight::render_source_with_highlighting(
s, s,
buf, buf,

View File

@ -579,15 +579,16 @@ ul.block, .block li {
border-color: var(--example-line-numbers-border-color); border-color: var(--example-line-numbers-border-color);
} }
.src-line-numbers span { .src-line-numbers a, .src-line-numbers span {
cursor: pointer;
color: var(--src-line-numbers-span-color); color: var(--src-line-numbers-span-color);
} }
.src-line-numbers .line-highlighted {
background-color: var(--src-line-number-highlighted-background-color);
}
.src-line-numbers :target { .src-line-numbers :target {
background-color: transparent; background-color: transparent;
border-right: none;
padding-right: 0;
}
.src-line-numbers .line-highlighted {
background-color: var(--src-line-number-highlighted-background-color);
} }
.search-loading { .search-loading {
@ -928,13 +929,14 @@ so that we can apply CSS-filters to change the arrow color in themes */
border-radius: 3px; border-radius: 3px;
border: 1px solid var(--border-color); border: 1px solid var(--border-color);
font-size: 1rem; font-size: 1rem;
--popover-arrow-offset: 11px;
} }
/* This rule is to draw the little arrow connecting the settings menu to the gear icon. */ /* This rule is to draw the little arrow connecting the settings menu to the gear icon. */
.popover::before { .popover::before {
content: ''; content: '';
position: absolute; position: absolute;
right: 11px; right: var(--popover-arrow-offset);
border: solid var(--border-color); border: solid var(--border-color);
border-width: 1px 1px 0 0; border-width: 1px 1px 0 0;
display: inline-block; display: inline-block;
@ -951,10 +953,7 @@ so that we can apply CSS-filters to change the arrow color in themes */
/* use larger max-width for help popover, but not for help.html */ /* use larger max-width for help popover, but not for help.html */
#help.popover { #help.popover {
max-width: 600px; max-width: 600px;
} --popover-arrow-offset: 48px;
#help.popover::before {
right: 48px;
} }
#help dt { #help dt {
@ -1273,54 +1272,34 @@ h3.variant {
border-right: 3px solid var(--target-border-color); border-right: 3px solid var(--target-border-color);
} }
.notable-traits-tooltip { .notable-traits {
display: inline-block; color: inherit;
cursor: pointer; margin-right: 15px;
position: relative;
} }
.notable-traits .notable-traits-tooltiptext { /* placeholder thunk so that the mouse can easily travel from "(i)" to popover
display: inline-block; the resulting "hover tunnel" is a stepped triangle, approximating
visibility: hidden; https://bjk5.com/post/44698559168/breaking-down-amazons-mega-dropdown */
} .notable-traits:hover::after {
.notable-traits-tooltiptext {
padding: 5px 3px 3px 3px;
border-radius: 6px;
margin-left: 5px;
z-index: 10;
font-size: 1rem;
cursor: default;
position: absolute; position: absolute;
border: 1px solid; top: calc(100% - 10px);
left: -15px;
right: -15px;
height: 20px;
content: "\00a0";
} }
.notable-traits-tooltip::after { .notable .docblock {
/* The margin on the tooltip does not capture hover events, margin: 0.25em 0.5em;
this extends the area of hover enough so that mouse hover is not
lost when moving the mouse to the tooltip */
content: "\00a0\00a0\00a0";
} }
.notable-traits-tooltiptext .docblock { .notable .docblock pre, .notable .docblock code {
margin: 0;
}
.notable-traits-tooltiptext .notable {
font-size: 1.1875rem;
font-weight: 600;
display: block;
}
.notable-traits-tooltiptext pre, .notable-traits-tooltiptext code {
background: transparent; background: transparent;
}
.notable-traits-tooltiptext .docblock pre.content {
margin: 0; margin: 0;
padding: 0; padding: 0;
font-size: 1.25rem; font-size: 1.25rem;
white-space: pre-wrap; white-space: pre-wrap;
overflow: hidden;
} }
.search-failed { .search-failed {
@ -1363,12 +1342,6 @@ h3.variant {
font-size: 1rem; font-size: 1rem;
} }
.notable-traits {
cursor: pointer;
z-index: 2;
margin-left: 5px;
}
#sidebar-toggle { #sidebar-toggle {
position: sticky; position: sticky;
top: 0; top: 0;
@ -1853,11 +1826,6 @@ in storage.js
border-bottom: 1px solid; border-bottom: 1px solid;
} }
.notable-traits .notable-traits-tooltiptext {
left: 0;
top: 100%;
}
/* We don't display the help button on mobile devices. */ /* We don't display the help button on mobile devices. */
#help-button { #help-button {
display: none; display: none;
@ -1982,7 +1950,6 @@ in storage.js
font-size: 12px; font-size: 12px;
position: relative; position: relative;
bottom: 1px; bottom: 1px;
background: transparent;
border-width: 1px; border-width: 1px;
border-style: solid; border-style: solid;
border-radius: 50px; border-radius: 50px;
@ -2044,6 +2011,7 @@ in storage.js
padding: 14px 0; padding: 14px 0;
} }
.scraped-example .code-wrapper .src-line-numbers a,
.scraped-example .code-wrapper .src-line-numbers span { .scraped-example .code-wrapper .src-line-numbers span {
padding: 0 14px; padding: 0 14px;
} }

View File

@ -169,10 +169,6 @@ details.rustdoc-toggle > summary::before {
border-color: transparent #314559 transparent transparent; border-color: transparent #314559 transparent transparent;
} }
.notable-traits-tooltiptext {
background-color: #314559;
}
#titles > button.selected { #titles > button.selected {
background-color: #141920 !important; background-color: #141920 !important;
border-bottom: 1px solid #ffb44c !important; border-bottom: 1px solid #ffb44c !important;

View File

@ -92,10 +92,6 @@ details.rustdoc-toggle > summary::before {
border-color: transparent black transparent transparent; border-color: transparent black transparent transparent;
} }
.notable-traits-tooltiptext {
background-color: #111;
}
#titles > button:not(.selected) { #titles > button:not(.selected) {
background-color: #252525; background-color: #252525;
border-top-color: #252525; border-top-color: #252525;

View File

@ -84,10 +84,6 @@ body.source .example-wrap pre.rust a {
border-color: transparent black transparent transparent; border-color: transparent black transparent transparent;
} }
.notable-traits-tooltiptext {
background-color: #eee;
}
#titles > button:not(.selected) { #titles > button:not(.selected) {
background-color: #e6e6e6; background-color: #e6e6e6;
border-top-color: #e6e6e6; border-top-color: #e6e6e6;

View File

@ -850,18 +850,33 @@ function loadCss(cssUrl) {
} }
hideNotable(); hideNotable();
const ty = e.getAttribute("data-ty"); const ty = e.getAttribute("data-ty");
const tooltip = e.getElementsByClassName("notable-traits-tooltip")[0];
const wrapper = document.createElement("div"); const wrapper = document.createElement("div");
wrapper.innerHTML = "<div class=\"docblock\">" + window.NOTABLE_TRAITS[ty] + "</div>"; wrapper.innerHTML = "<div class=\"docblock\">" + window.NOTABLE_TRAITS[ty] + "</div>";
wrapper.className = "notable-traits-tooltiptext"; wrapper.className = "notable popover";
tooltip.appendChild(wrapper); const focusCatcher = document.createElement("div");
const pos = wrapper.getBoundingClientRect(); focusCatcher.setAttribute("tabindex", "0");
tooltip.removeChild(wrapper); focusCatcher.onfocus = hideNotable;
wrapper.style.top = (pos.top + window.scrollY) + "px"; wrapper.appendChild(focusCatcher);
wrapper.style.left = (pos.left + window.scrollX) + "px"; const pos = e.getBoundingClientRect();
wrapper.style.width = pos.width + "px"; // 5px overlap so that the mouse can easily travel from place to place
wrapper.style.top = (pos.top + window.scrollY + pos.height) + "px";
wrapper.style.left = 0;
wrapper.style.right = "auto";
wrapper.style.visibility = "hidden";
const body = document.getElementsByTagName("body")[0]; const body = document.getElementsByTagName("body")[0];
body.appendChild(wrapper); body.appendChild(wrapper);
const wrapperPos = wrapper.getBoundingClientRect();
// offset so that the arrow points at the center of the "(i)"
const finalPos = pos.left + window.scrollX - wrapperPos.width + 24;
if (finalPos > 0) {
wrapper.style.left = finalPos + "px";
} else {
wrapper.style.setProperty(
"--popover-arrow-offset",
(wrapperPos.right - pos.right + 4) + "px"
);
}
wrapper.style.visibility = "";
window.CURRENT_NOTABLE_ELEMENT = wrapper; window.CURRENT_NOTABLE_ELEMENT = wrapper;
window.CURRENT_NOTABLE_ELEMENT.NOTABLE_BASE = e; window.CURRENT_NOTABLE_ELEMENT.NOTABLE_BASE = e;
wrapper.onpointerleave = function(ev) { wrapper.onpointerleave = function(ev) {
@ -875,9 +890,31 @@ function loadCss(cssUrl) {
}; };
} }
function notableBlurHandler(event) {
if (window.CURRENT_NOTABLE_ELEMENT &&
!elemIsInParent(document.activeElement, window.CURRENT_NOTABLE_ELEMENT) &&
!elemIsInParent(event.relatedTarget, window.CURRENT_NOTABLE_ELEMENT) &&
!elemIsInParent(document.activeElement, window.CURRENT_NOTABLE_ELEMENT.NOTABLE_BASE) &&
!elemIsInParent(event.relatedTarget, window.CURRENT_NOTABLE_ELEMENT.NOTABLE_BASE)
) {
// Work around a difference in the focus behaviour between Firefox, Chrome, and Safari.
// When I click the button on an already-opened notable trait popover, Safari
// hides the popover and then immediately shows it again, while everyone else hides it
// and it stays hidden.
//
// To work around this, make sure the click finishes being dispatched before
// hiding the popover. Since `hideNotable()` is idempotent, this makes Safari behave
// consistently with the other two.
setTimeout(hideNotable, 0);
}
}
function hideNotable() { function hideNotable() {
if (window.CURRENT_NOTABLE_ELEMENT) { if (window.CURRENT_NOTABLE_ELEMENT) {
window.CURRENT_NOTABLE_ELEMENT.NOTABLE_BASE.NOTABLE_FORCE_VISIBLE = false; if (window.CURRENT_NOTABLE_ELEMENT.NOTABLE_BASE.NOTABLE_FORCE_VISIBLE) {
window.CURRENT_NOTABLE_ELEMENT.NOTABLE_BASE.focus();
window.CURRENT_NOTABLE_ELEMENT.NOTABLE_BASE.NOTABLE_FORCE_VISIBLE = false;
}
const body = document.getElementsByTagName("body")[0]; const body = document.getElementsByTagName("body")[0];
body.removeChild(window.CURRENT_NOTABLE_ELEMENT); body.removeChild(window.CURRENT_NOTABLE_ELEMENT);
window.CURRENT_NOTABLE_ELEMENT = null; window.CURRENT_NOTABLE_ELEMENT = null;
@ -891,7 +928,11 @@ function loadCss(cssUrl) {
hideNotable(); hideNotable();
} else { } else {
showNotable(this); showNotable(this);
window.CURRENT_NOTABLE_ELEMENT.setAttribute("tabindex", "0");
window.CURRENT_NOTABLE_ELEMENT.focus();
window.CURRENT_NOTABLE_ELEMENT.onblur = notableBlurHandler;
} }
return false;
}; };
e.onpointerenter = function(ev) { e.onpointerenter = function(ev) {
// If this is a synthetic touch event, ignore it. A click event will be along shortly. // If this is a synthetic touch event, ignore it. A click event will be along shortly.
@ -1018,6 +1059,7 @@ function loadCss(cssUrl) {
onEachLazy(document.querySelectorAll(".search-form .popover"), elem => { onEachLazy(document.querySelectorAll(".search-form .popover"), elem => {
elem.style.display = "none"; elem.style.display = "none";
}); });
hideNotable();
}; };
/** /**

View File

@ -157,7 +157,7 @@ function highlightSourceLines(match) {
x.scrollIntoView(); x.scrollIntoView();
} }
onEachLazy(document.getElementsByClassName("src-line-numbers"), e => { onEachLazy(document.getElementsByClassName("src-line-numbers"), e => {
onEachLazy(e.getElementsByTagName("span"), i_e => { onEachLazy(e.getElementsByTagName("a"), i_e => {
removeClass(i_e, "line-highlighted"); removeClass(i_e, "line-highlighted");
}); });
}); });
@ -188,8 +188,13 @@ const handleSourceHighlight = (function() {
return ev => { return ev => {
let cur_line_id = parseInt(ev.target.id, 10); let cur_line_id = parseInt(ev.target.id, 10);
// It can happen when clicking not on a line number span. // This event handler is attached to the entire line number column, but it should only
if (isNaN(cur_line_id)) { // be run if one of the anchors is clicked. It also shouldn't do anything if the anchor
// is clicked with a modifier key (to open a new browser tab).
if (isNaN(cur_line_id) ||
ev.ctrlKey ||
ev.altKey ||
ev.metaKey) {
return; return;
} }
ev.preventDefault(); ev.preventDefault();

View File

@ -22,31 +22,26 @@ assert-position: (
) )
assert-position: ( assert-position: (
"//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
{"x": 951}, {"x": 955},
) )
// The tooltip should be beside the `i` // The tooltip should be below the `i`
// Also, clicking the tooltip should bring its text into the DOM // Also, clicking the tooltip should bring its text into the DOM
assert-count: ("//*[@class='notable-traits-tooltiptext']", 0) assert-count: ("//*[@class='notable popover']", 0)
click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']" click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
assert-count: ("//*[@class='notable-traits-tooltiptext']", 1) assert-count: ("//*[@class='notable popover']", 1)
compare-elements-position-near: ( compare-elements-position-near: (
"//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
"//*[@class='notable-traits-tooltiptext']", "//*[@class='notable popover']",
{"y": 2} {"y": 30}
) )
compare-elements-position-false: ( compare-elements-position-false: (
"//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
"//*[@class='notable-traits-tooltiptext']", "//*[@class='notable popover']",
("x") ("x")
) )
// The docblock should be flush with the border.
assert-css: (
"//*[@class='notable-traits-tooltiptext']/*[@class='docblock']",
{"margin-left": "0px"}
)
click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']" click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
move-cursor-to: "//h1" move-cursor-to: "//h1"
assert-count: ("//*[@class='notable-traits-tooltiptext']", 0) assert-count: ("//*[@class='notable popover']", 0)
// Now only the `i` should be on the next line. // Now only the `i` should be on the next line.
size: (1055, 600) size: (1055, 600)
@ -77,7 +72,7 @@ assert-position: (
) )
assert-position: ( assert-position: (
"//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
{"x": 519}, {"x": 523},
) )
// Checking on mobile now. // Checking on mobile now.
@ -101,42 +96,28 @@ assert-position: (
) )
assert-position: ( assert-position: (
"//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
{"x": 289}, {"x": 293},
) )
// The tooltip should be below `i` // The tooltip should STILL be below `i`
click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']" click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
assert-count: ("//*[@class='notable-traits-tooltiptext']", 1) assert-count: ("//*[@class='notable popover']", 1)
compare-elements-position-near-false: ( compare-elements-position-near: (
"//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
"//*[@class='notable-traits-tooltiptext']", "//*[@class='notable popover']",
{"y": 2} {"y": 30}
) )
compare-elements-position-false: ( compare-elements-position-false: (
"//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']", "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
"//*[@class='notable-traits-tooltiptext']", "//*[@class='notable popover']",
("x") ("x")
) )
compare-elements-position-near: ( assert-position: (
"//*[@id='method.create_an_iterator_from_read']", "//*[@class='notable popover']",
"//*[@class='notable-traits-tooltiptext']", {"x": 0}
{"x": 10}
)
// The docblock should be flush with the border.
assert-css: (
"//*[@class='notable-traits-tooltiptext']/*[@class='docblock']",
{"margin-left": "0px"}
) )
click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']" click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
move-cursor-to: "//h1" move-cursor-to: "//h1"
assert-count: ("//*[@class='notable-traits-tooltiptext']", 0) assert-count: ("//*[@class='notable popover']", 0)
// Checking on very small mobile. The `i` should be on its own line.
size: (365, 600)
compare-elements-position-false: (
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
"//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
("y", "x"),
)
// Now check the colors. // Now check the colors.
define-function: ( define-function: (
@ -153,25 +134,25 @@ define-function: (
("reload"), ("reload"),
("move-cursor-to", "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"), ("move-cursor-to", "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"),
("assert-count", (".notable-traits-tooltiptext", 1)), ("assert-count", (".notable.popover", 1)),
("assert-css", ( ("assert-css", (
".notable-traits-tooltiptext h3.notable", ".notable.popover h3",
{"color": |header_color|}, {"color": |header_color|},
ALL, ALL,
)), )),
("assert-css", ( ("assert-css", (
".notable-traits-tooltiptext pre.content", ".notable.popover pre",
{"color": |content_color|}, {"color": |content_color|},
ALL, ALL,
)), )),
("assert-css", ( ("assert-css", (
".notable-traits-tooltiptext pre.content a.struct", ".notable.popover pre a.struct",
{"color": |type_color|}, {"color": |type_color|},
ALL, ALL,
)), )),
("assert-css", ( ("assert-css", (
".notable-traits-tooltiptext pre.content a.trait", ".notable.popover pre a.trait",
{"color": |trait_color|}, {"color": |trait_color|},
ALL, ALL,
)), )),
@ -210,3 +191,31 @@ call-function: (
"trait_color": "rgb(110, 79, 201)", "trait_color": "rgb(110, 79, 201)",
}, },
) )
reload:
// Check that pressing escape works
click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
move-cursor-to: "//*[@class='notable popover']"
assert-count: ("//*[@class='notable popover']", 1)
press-key: "Escape"
assert-count: ("//*[@class='notable popover']", 0)
// Check that clicking outside works.
click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
assert-count: ("//*[@class='notable popover']", 1)
click: ".search-input"
assert-count: ("//*[@class='notable popover']", 0)
// Check that pressing tab over and over works.
click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
move-cursor-to: "//*[@class='notable popover']"
assert-count: ("//*[@class='notable popover']", 1)
press-key: "Tab"
press-key: "Tab"
press-key: "Tab"
press-key: "Tab"
press-key: "Tab"
press-key: "Tab"
press-key: "Tab"
assert-count: ("//*[@class='notable popover']", 0)

View File

@ -2,17 +2,22 @@
goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
show-text: true show-text: true
// Check that we can click on the line number. // Check that we can click on the line number.
click: ".src-line-numbers > span:nth-child(4)" // This is the span for line 4. click: ".src-line-numbers > a:nth-child(4)" // This is the anchor for line 4.
// Ensure that the page URL was updated. // Ensure that the page URL was updated.
assert-document-property: ({"URL": "lib.rs.html#4"}, ENDS_WITH) assert-document-property: ({"URL": "lib.rs.html#4"}, ENDS_WITH)
assert-attribute: ("//*[@id='4']", {"class": "line-highlighted"}) assert-attribute: ("//*[@id='4']", {"class": "line-highlighted"})
// We now check that the good spans are highlighted // Ensure that the default style, with the right border, isn't used.
assert-css: ("//*[@id='4']", {"border-right-width": "0px"})
reload:
assert-attribute: ("//*[@id='4']", {"class": "line-highlighted"})
assert-css: ("//*[@id='4']", {"border-right-width": "0px"})
// We now check that the good anchors are highlighted
goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#4-6" goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#4-6"
assert-attribute-false: (".src-line-numbers > span:nth-child(3)", {"class": "line-highlighted"}) assert-attribute-false: (".src-line-numbers > a:nth-child(3)", {"class": "line-highlighted"})
assert-attribute: (".src-line-numbers > span:nth-child(4)", {"class": "line-highlighted"}) assert-attribute: (".src-line-numbers > a:nth-child(4)", {"class": "line-highlighted"})
assert-attribute: (".src-line-numbers > span:nth-child(5)", {"class": "line-highlighted"}) assert-attribute: (".src-line-numbers > a:nth-child(5)", {"class": "line-highlighted"})
assert-attribute: (".src-line-numbers > span:nth-child(6)", {"class": "line-highlighted"}) assert-attribute: (".src-line-numbers > a:nth-child(6)", {"class": "line-highlighted"})
assert-attribute-false: (".src-line-numbers > span:nth-child(7)", {"class": "line-highlighted"}) assert-attribute-false: (".src-line-numbers > a:nth-child(7)", {"class": "line-highlighted"})
define-function: ( define-function: (
"check-colors", "check-colors",
@ -21,12 +26,12 @@ define-function: (
("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}), ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
("reload"), ("reload"),
("assert-css", ( ("assert-css", (
".src-line-numbers > span:not(.line-highlighted)", ".src-line-numbers > a:not(.line-highlighted)",
{"color": |color|, "background-color": |background_color|}, {"color": |color|, "background-color": |background_color|},
ALL, ALL,
)), )),
("assert-css", ( ("assert-css", (
".src-line-numbers > span.line-highlighted", ".src-line-numbers > a.line-highlighted",
{"color": |highlight_color|, "background-color": |highlight_background_color|}, {"color": |highlight_color|, "background-color": |highlight_background_color|},
ALL, ALL,
)), )),
@ -57,6 +62,25 @@ call-function: ("check-colors", {
// This is to ensure that the content is correctly align with the line numbers. // This is to ensure that the content is correctly align with the line numbers.
compare-elements-position: ("//*[@id='1']", ".rust > code > span", ("y")) compare-elements-position: ("//*[@id='1']", ".rust > code > span", ("y"))
// Check the `href` property so that users can treat anchors as links.
assert-property: (".src-line-numbers > a:nth-child(1)", {
"href": "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#1"
})
assert-property: (".src-line-numbers > a:nth-child(2)", {
"href": "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#2"
})
assert-property: (".src-line-numbers > a:nth-child(3)", {
"href": "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#3"
})
assert-property: (".src-line-numbers > a:nth-child(4)", {
"href": "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#4"
})
assert-property: (".src-line-numbers > a:nth-child(5)", {
"href": "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#5"
})
assert-property: (".src-line-numbers > a:nth-child(6)", {
"href": "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html#6"
})
// Assert that the line numbers text is aligned to the right. // Assert that the line numbers text is aligned to the right.
assert-css: (".src-line-numbers", {"text-align": "right"}) assert-css: (".src-line-numbers", {"text-align": "right"})
@ -66,7 +90,7 @@ assert-css: (".src-line-numbers", {"text-align": "right"})
goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
// We use this assert-position to know where we will click. // We use this assert-position to know where we will click.
assert-position: ("//*[@id='1']", {"x": 104, "y": 112}) assert-position: ("//*[@id='1']", {"x": 104, "y": 112})
// We click on the left of the "1" span but still in the "src-line-number" `<pre>`. // We click on the left of the "1" anchor but still in the "src-line-number" `<pre>`.
click: (103, 103) click: (103, 103)
assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH) assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH)

View File

@ -10,14 +10,14 @@ extern crate source_code;
// @has 'src/foo/check-source-code-urls-to-def.rs.html' // @has 'src/foo/check-source-code-urls-to-def.rs.html'
// @has - '//a[@href="auxiliary/source-code-bar.rs.html#1-17"]' 'bar' // @has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#1-17"]' 'bar'
#[path = "auxiliary/source-code-bar.rs"] #[path = "auxiliary/source-code-bar.rs"]
pub mod bar; pub mod bar;
// @count - '//a[@href="auxiliary/source-code-bar.rs.html#5"]' 4 // @count - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#5"]' 4
use bar::Bar; use bar::Bar;
// @has - '//a[@href="auxiliary/source-code-bar.rs.html#13"]' 'self' // @has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#13"]' 'self'
// @has - '//a[@href="auxiliary/source-code-bar.rs.html#14"]' 'Trait' // @has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#14"]' 'Trait'
use bar::sub::{self, Trait}; use bar::sub::{self, Trait};
pub struct Foo; pub struct Foo;
@ -28,29 +28,29 @@ impl Foo {
fn babar() {} fn babar() {}
// @has - '//a/@href' '/struct.String.html' // @has - '//pre[@class="rust"]//a/@href' '/struct.String.html'
// @has - '//a/@href' '/primitive.u32.html' // @has - '//pre[@class="rust"]//a/@href' '/primitive.u32.html'
// @has - '//a/@href' '/primitive.str.html' // @has - '//pre[@class="rust"]//a/@href' '/primitive.str.html'
// @count - '//a[@href="#23"]' 5 // @count - '//pre[@class="rust"]//a[@href="#23"]' 5
// @has - '//a[@href="../../source_code/struct.SourceCode.html"]' 'source_code::SourceCode' // @has - '//pre[@class="rust"]//a[@href="../../source_code/struct.SourceCode.html"]' 'source_code::SourceCode'
pub fn foo(a: u32, b: &str, c: String, d: Foo, e: bar::Bar, f: source_code::SourceCode) { pub fn foo(a: u32, b: &str, c: String, d: Foo, e: bar::Bar, f: source_code::SourceCode) {
let x = 12; let x = 12;
let y: Foo = Foo; let y: Foo = Foo;
let z: Bar = bar::Bar { field: Foo }; let z: Bar = bar::Bar { field: Foo };
babar(); babar();
// @has - '//a[@href="#26"]' 'hello' // @has - '//pre[@class="rust"]//a[@href="#26"]' 'hello'
y.hello(); y.hello();
} }
// @has - '//a[@href="auxiliary/source-code-bar.rs.html#14"]' 'bar::sub::Trait' // @has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#14"]' 'bar::sub::Trait'
// @has - '//a[@href="auxiliary/source-code-bar.rs.html#14"]' 'Trait' // @has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#14"]' 'Trait'
pub fn foo2<T: bar::sub::Trait, V: Trait>(t: &T, v: &V, b: bool) {} pub fn foo2<T: bar::sub::Trait, V: Trait>(t: &T, v: &V, b: bool) {}
pub trait AnotherTrait {} pub trait AnotherTrait {}
pub trait WhyNot {} pub trait WhyNot {}
// @has - '//a[@href="#49"]' 'AnotherTrait' // @has - '//pre[@class="rust"]//a[@href="#49"]' 'AnotherTrait'
// @has - '//a[@href="#50"]' 'WhyNot' // @has - '//pre[@class="rust"]//a[@href="#50"]' 'WhyNot'
pub fn foo3<T, V>(t: &T, v: &V) pub fn foo3<T, V>(t: &T, v: &V)
where where
T: AnotherTrait, T: AnotherTrait,
@ -59,11 +59,11 @@ where
pub trait AnotherTrait2 {} pub trait AnotherTrait2 {}
// @has - '//a[@href="#60"]' 'AnotherTrait2' // @has - '//pre[@class="rust"]//a[@href="#60"]' 'AnotherTrait2'
pub fn foo4() { pub fn foo4() {
let x: Vec<AnotherTrait2> = Vec::new(); let x: Vec<AnotherTrait2> = Vec::new();
} }
// @has - '//a[@href="../../foo/primitive.bool.html"]' 'bool' // @has - '//pre[@class="rust"]//a[@href="../../foo/primitive.bool.html"]' 'bool'
#[doc(primitive = "bool")] #[doc(primitive = "bool")]
mod whatever {} mod whatever {}

View File

@ -1 +1 @@
<script type="text/json" id="notable-traits-data">{"&amp;'static [SomeStruct]":"&lt;h3 class=\"notable\"&gt;Notable traits for &lt;code&gt;&amp;amp;[&lt;a class=\"struct\" href=\"struct.SomeStruct.html\" title=\"struct doc_notable_trait_slice::SomeStruct\"&gt;SomeStruct&lt;/a&gt;]&lt;/code&gt;&lt;/h3&gt;&lt;pre class=\"content\"&gt;&lt;code&gt;&lt;span class=\"where fmt-newline\"&gt;impl &lt;a class=\"trait\" href=\"trait.SomeTrait.html\" title=\"trait doc_notable_trait_slice::SomeTrait\"&gt;SomeTrait&lt;/a&gt; for &amp;amp;[&lt;a class=\"struct\" href=\"struct.SomeStruct.html\" title=\"struct doc_notable_trait_slice::SomeStruct\"&gt;SomeStruct&lt;/a&gt;]&lt;/span&gt;"}</script> <script type="text/json" id="notable-traits-data">{"&amp;'static [SomeStruct]":"&lt;h3&gt;Notable traits for &lt;code&gt;&amp;amp;[&lt;a class=\"struct\" href=\"struct.SomeStruct.html\" title=\"struct doc_notable_trait_slice::SomeStruct\"&gt;SomeStruct&lt;/a&gt;]&lt;/code&gt;&lt;/h3&gt;&lt;pre class=\"content\"&gt;&lt;code&gt;&lt;span class=\"where fmt-newline\"&gt;impl &lt;a class=\"trait\" href=\"trait.SomeTrait.html\" title=\"trait doc_notable_trait_slice::SomeTrait\"&gt;SomeTrait&lt;/a&gt; for &amp;amp;[&lt;a class=\"struct\" href=\"struct.SomeStruct.html\" title=\"struct doc_notable_trait_slice::SomeStruct\"&gt;SomeStruct&lt;/a&gt;]&lt;/span&gt;"}</script>

View File

@ -1 +1 @@
<script type="text/json" id="notable-traits-data">{"SomeStruct":"&lt;h3 class=\"notable\"&gt;Notable traits for &lt;code&gt;&lt;a class=\"struct\" href=\"struct.SomeStruct.html\" title=\"struct doc_notable_trait::SomeStruct\"&gt;SomeStruct&lt;/a&gt;&lt;/code&gt;&lt;/h3&gt;&lt;pre class=\"content\"&gt;&lt;code&gt;&lt;span class=\"where fmt-newline\"&gt;impl &lt;a class=\"trait\" href=\"trait.SomeTrait.html\" title=\"trait doc_notable_trait::SomeTrait\"&gt;SomeTrait&lt;/a&gt; for &lt;a class=\"struct\" href=\"struct.SomeStruct.html\" title=\"struct doc_notable_trait::SomeStruct\"&gt;SomeStruct&lt;/a&gt;&lt;/span&gt;"}</script> <script type="text/json" id="notable-traits-data">{"SomeStruct":"&lt;h3&gt;Notable traits for &lt;code&gt;&lt;a class=\"struct\" href=\"struct.SomeStruct.html\" title=\"struct doc_notable_trait::SomeStruct\"&gt;SomeStruct&lt;/a&gt;&lt;/code&gt;&lt;/h3&gt;&lt;pre class=\"content\"&gt;&lt;code&gt;&lt;span class=\"where fmt-newline\"&gt;impl &lt;a class=\"trait\" href=\"trait.SomeTrait.html\" title=\"trait doc_notable_trait::SomeTrait\"&gt;SomeTrait&lt;/a&gt; for &lt;a class=\"struct\" href=\"struct.SomeStruct.html\" title=\"struct doc_notable_trait::SomeStruct\"&gt;SomeStruct&lt;/a&gt;&lt;/span&gt;"}</script>

View File

@ -9,7 +9,7 @@ impl<T: SomeTrait> SomeTrait for Wrapper<T> {}
#[doc(notable_trait)] #[doc(notable_trait)]
pub trait SomeTrait { pub trait SomeTrait {
// @has doc_notable_trait/trait.SomeTrait.html // @has doc_notable_trait/trait.SomeTrait.html
// @has - '//span[@class="notable-traits"]/@data-ty' 'Wrapper<Self>' // @has - '//a[@class="notable-traits"]/@data-ty' 'Wrapper<Self>'
// @snapshot wrap-me - '//script[@id="notable-traits-data"]' // @snapshot wrap-me - '//script[@id="notable-traits-data"]'
fn wrap_me(self) -> Wrapper<Self> where Self: Sized { fn wrap_me(self) -> Wrapper<Self> where Self: Sized {
Wrapper { Wrapper {
@ -23,7 +23,7 @@ impl SomeTrait for SomeStruct {}
impl SomeStruct { impl SomeStruct {
// @has doc_notable_trait/struct.SomeStruct.html // @has doc_notable_trait/struct.SomeStruct.html
// @has - '//span[@class="notable-traits"]/@data-ty' 'SomeStruct' // @has - '//a[@class="notable-traits"]/@data-ty' 'SomeStruct'
// @snapshot some-struct-new - '//script[@id="notable-traits-data"]' // @snapshot some-struct-new - '//script[@id="notable-traits-data"]'
pub fn new() -> SomeStruct { pub fn new() -> SomeStruct {
SomeStruct SomeStruct
@ -31,7 +31,7 @@ impl SomeStruct {
} }
// @has doc_notable_trait/fn.bare_fn.html // @has doc_notable_trait/fn.bare_fn.html
// @has - '//span[@class="notable-traits"]/@data-ty' 'SomeStruct' // @has - '//a[@class="notable-traits"]/@data-ty' 'SomeStruct'
// @snapshot bare-fn - '//script[@id="notable-traits-data"]' // @snapshot bare-fn - '//script[@id="notable-traits-data"]'
pub fn bare_fn() -> SomeStruct { pub fn bare_fn() -> SomeStruct {
SomeStruct SomeStruct

View File

@ -1 +1 @@
<script type="text/json" id="notable-traits-data">{"SomeStruct":"&lt;h3 class=\"notable\"&gt;Notable traits for &lt;code&gt;&lt;a class=\"struct\" href=\"struct.SomeStruct.html\" title=\"struct doc_notable_trait::SomeStruct\"&gt;SomeStruct&lt;/a&gt;&lt;/code&gt;&lt;/h3&gt;&lt;pre class=\"content\"&gt;&lt;code&gt;&lt;span class=\"where fmt-newline\"&gt;impl &lt;a class=\"trait\" href=\"trait.SomeTrait.html\" title=\"trait doc_notable_trait::SomeTrait\"&gt;SomeTrait&lt;/a&gt; for &lt;a class=\"struct\" href=\"struct.SomeStruct.html\" title=\"struct doc_notable_trait::SomeStruct\"&gt;SomeStruct&lt;/a&gt;&lt;/span&gt;","Wrapper&lt;Self&gt;":"&lt;h3 class=\"notable\"&gt;Notable traits for &lt;code&gt;&lt;a class=\"struct\" href=\"struct.Wrapper.html\" title=\"struct doc_notable_trait::Wrapper\"&gt;Wrapper&lt;/a&gt;&amp;lt;T&amp;gt;&lt;/code&gt;&lt;/h3&gt;&lt;pre class=\"content\"&gt;&lt;code&gt;&lt;span class=\"where fmt-newline\"&gt;impl&amp;lt;T:&amp;nbsp;&lt;a class=\"trait\" href=\"trait.SomeTrait.html\" title=\"trait doc_notable_trait::SomeTrait\"&gt;SomeTrait&lt;/a&gt;&amp;gt; &lt;a class=\"trait\" href=\"trait.SomeTrait.html\" title=\"trait doc_notable_trait::SomeTrait\"&gt;SomeTrait&lt;/a&gt; for &lt;a class=\"struct\" href=\"struct.Wrapper.html\" title=\"struct doc_notable_trait::Wrapper\"&gt;Wrapper&lt;/a&gt;&amp;lt;T&amp;gt;&lt;/span&gt;"}</script> <script type="text/json" id="notable-traits-data">{"SomeStruct":"&lt;h3&gt;Notable traits for &lt;code&gt;&lt;a class=\"struct\" href=\"struct.SomeStruct.html\" title=\"struct doc_notable_trait::SomeStruct\"&gt;SomeStruct&lt;/a&gt;&lt;/code&gt;&lt;/h3&gt;&lt;pre class=\"content\"&gt;&lt;code&gt;&lt;span class=\"where fmt-newline\"&gt;impl &lt;a class=\"trait\" href=\"trait.SomeTrait.html\" title=\"trait doc_notable_trait::SomeTrait\"&gt;SomeTrait&lt;/a&gt; for &lt;a class=\"struct\" href=\"struct.SomeStruct.html\" title=\"struct doc_notable_trait::SomeStruct\"&gt;SomeStruct&lt;/a&gt;&lt;/span&gt;","Wrapper&lt;Self&gt;":"&lt;h3&gt;Notable traits for &lt;code&gt;&lt;a class=\"struct\" href=\"struct.Wrapper.html\" title=\"struct doc_notable_trait::Wrapper\"&gt;Wrapper&lt;/a&gt;&amp;lt;T&amp;gt;&lt;/code&gt;&lt;/h3&gt;&lt;pre class=\"content\"&gt;&lt;code&gt;&lt;span class=\"where fmt-newline\"&gt;impl&amp;lt;T:&amp;nbsp;&lt;a class=\"trait\" href=\"trait.SomeTrait.html\" title=\"trait doc_notable_trait::SomeTrait\"&gt;SomeTrait&lt;/a&gt;&amp;gt; &lt;a class=\"trait\" href=\"trait.SomeTrait.html\" title=\"trait doc_notable_trait::SomeTrait\"&gt;SomeTrait&lt;/a&gt; for &lt;a class=\"struct\" href=\"struct.Wrapper.html\" title=\"struct doc_notable_trait::Wrapper\"&gt;Wrapper&lt;/a&gt;&amp;lt;T&amp;gt;&lt;/span&gt;"}</script>

View File

@ -1 +1 @@
<script type="text/json" id="notable-traits-data">{"Wrapper&lt;Self&gt;":"&lt;h3 class=\"notable\"&gt;Notable traits for &lt;code&gt;&lt;a class=\"struct\" href=\"struct.Wrapper.html\" title=\"struct doc_notable_trait::Wrapper\"&gt;Wrapper&lt;/a&gt;&amp;lt;T&amp;gt;&lt;/code&gt;&lt;/h3&gt;&lt;pre class=\"content\"&gt;&lt;code&gt;&lt;span class=\"where fmt-newline\"&gt;impl&amp;lt;T:&amp;nbsp;&lt;a class=\"trait\" href=\"trait.SomeTrait.html\" title=\"trait doc_notable_trait::SomeTrait\"&gt;SomeTrait&lt;/a&gt;&amp;gt; &lt;a class=\"trait\" href=\"trait.SomeTrait.html\" title=\"trait doc_notable_trait::SomeTrait\"&gt;SomeTrait&lt;/a&gt; for &lt;a class=\"struct\" href=\"struct.Wrapper.html\" title=\"struct doc_notable_trait::Wrapper\"&gt;Wrapper&lt;/a&gt;&amp;lt;T&amp;gt;&lt;/span&gt;"}</script> <script type="text/json" id="notable-traits-data">{"Wrapper&lt;Self&gt;":"&lt;h3&gt;Notable traits for &lt;code&gt;&lt;a class=\"struct\" href=\"struct.Wrapper.html\" title=\"struct doc_notable_trait::Wrapper\"&gt;Wrapper&lt;/a&gt;&amp;lt;T&amp;gt;&lt;/code&gt;&lt;/h3&gt;&lt;pre class=\"content\"&gt;&lt;code&gt;&lt;span class=\"where fmt-newline\"&gt;impl&amp;lt;T:&amp;nbsp;&lt;a class=\"trait\" href=\"trait.SomeTrait.html\" title=\"trait doc_notable_trait::SomeTrait\"&gt;SomeTrait&lt;/a&gt;&amp;gt; &lt;a class=\"trait\" href=\"trait.SomeTrait.html\" title=\"trait doc_notable_trait::SomeTrait\"&gt;SomeTrait&lt;/a&gt; for &lt;a class=\"struct\" href=\"struct.Wrapper.html\" title=\"struct doc_notable_trait::Wrapper\"&gt;Wrapper&lt;/a&gt;&amp;lt;T&amp;gt;&lt;/span&gt;"}</script>

View File

@ -1 +1 @@
<script type="text/json" id="notable-traits-data">{"Odd":"&lt;h3 class=\"notable\"&gt;Notable traits for &lt;code&gt;&lt;a class=\"struct\" href=\"struct.Odd.html\" title=\"struct foo::Odd\"&gt;Odd&lt;/a&gt;&lt;/code&gt;&lt;/h3&gt;&lt;pre class=\"content\"&gt;&lt;code&gt;&lt;span class=\"where fmt-newline\"&gt;impl &lt;a class=\"trait\" href=\"{{channel}}/core/iter/traits/iterator/trait.Iterator.html\" title=\"trait core::iter::traits::iterator::Iterator\"&gt;Iterator&lt;/a&gt; for &lt;a class=\"struct\" href=\"struct.Odd.html\" title=\"struct foo::Odd\"&gt;Odd&lt;/a&gt;&lt;/span&gt;&lt;span class=\"where fmt-newline\"&gt; type &lt;a href=\"{{channel}}/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item\" class=\"associatedtype\"&gt;Item&lt;/a&gt; = &lt;a class=\"primitive\" href=\"{{channel}}/std/primitive.usize.html\"&gt;usize&lt;/a&gt;;&lt;/span&gt;"}</script> <script type="text/json" id="notable-traits-data">{"Odd":"&lt;h3&gt;Notable traits for &lt;code&gt;&lt;a class=\"struct\" href=\"struct.Odd.html\" title=\"struct foo::Odd\"&gt;Odd&lt;/a&gt;&lt;/code&gt;&lt;/h3&gt;&lt;pre class=\"content\"&gt;&lt;code&gt;&lt;span class=\"where fmt-newline\"&gt;impl &lt;a class=\"trait\" href=\"{{channel}}/core/iter/traits/iterator/trait.Iterator.html\" title=\"trait core::iter::traits::iterator::Iterator\"&gt;Iterator&lt;/a&gt; for &lt;a class=\"struct\" href=\"struct.Odd.html\" title=\"struct foo::Odd\"&gt;Odd&lt;/a&gt;&lt;/span&gt;&lt;span class=\"where fmt-newline\"&gt; type &lt;a href=\"{{channel}}/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item\" class=\"associatedtype\"&gt;Item&lt;/a&gt; = &lt;a class=\"primitive\" href=\"{{channel}}/std/primitive.usize.html\"&gt;usize&lt;/a&gt;;&lt;/span&gt;"}</script>

View File

@ -3,7 +3,7 @@
use std::iter::Iterator; use std::iter::Iterator;
// @has foo/struct.Odd.html // @has foo/struct.Odd.html
// @has - '//*[@id="method.new"]//span[@class="notable-traits"]/@data-ty' 'Odd' // @has - '//*[@id="method.new"]//a[@class="notable-traits"]/@data-ty' 'Odd'
// @snapshot odd - '//script[@id="notable-traits-data"]' // @snapshot odd - '//script[@id="notable-traits-data"]'
pub struct Odd { pub struct Odd {
current: usize, current: usize,

View File

@ -31,6 +31,16 @@ fn badboi<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ T) -> &'out T {
sadness.cast() sadness.cast()
} }
fn badboi2<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ T) {
//~^ ERROR lifetime mismatch
let _: &'out T = sadness.cast();
}
fn badboi3<'in_, 'out, T>(a: Foo<'in_, 'out, (&'in_ T, &'out T)>, sadness: &'in_ T) {
//~^ ERROR lifetime mismatch
let _: &'out T = sadness.cast();
}
fn bad<'short, T>(value: &'short T) -> &'static T { fn bad<'short, T>(value: &'short T) -> &'static T {
let x: for<'in_, 'out> fn(Foo<'in_, 'out, T>, &'in_ T) -> &'out T = badboi; let x: for<'in_, 'out> fn(Foo<'in_, 'out, T>, &'in_ T) -> &'out T = badboi;
let x: for<'out> fn(Foo<'short, 'out, T>, &'short T) -> &'out T = x; let x: for<'out> fn(Foo<'short, 'out, T>, &'short T) -> &'out T = x;

View File

@ -7,6 +7,24 @@ LL | fn badboi<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ T) -> &'out
| this parameter and the return type are declared with different lifetimes... | this parameter and the return type are declared with different lifetimes...
| ...but data from `x` is returned here | ...but data from `x` is returned here
error: aborting due to previous error error[E0623]: lifetime mismatch
--> $DIR/hrlt-implied-trait-bounds-guard.rs:34:30
|
LL | fn badboi2<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ T) {
| ^^^^^^^^^^^^^^^^^^
| |
| this type is declared with multiple lifetimes...
| ...but data with one lifetime flows into the other here
error[E0623]: lifetime mismatch
--> $DIR/hrlt-implied-trait-bounds-guard.rs:39:30
|
LL | fn badboi3<'in_, 'out, T>(a: Foo<'in_, 'out, (&'in_ T, &'out T)>, sadness: &'in_ T) {
| ^^^^^^^^^^^^^^^^^-------^^-------^^
| | |
| | these two types are declared with different lifetimes...
| ...but data from `a` flows into `a` here
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0623`. For more information about this error, try `rustc --explain E0623`.

View File

@ -10,7 +10,7 @@ use std::path::Path;
const ENTRY_LIMIT: usize = 1000; const ENTRY_LIMIT: usize = 1000;
// FIXME: The following limits should be reduced eventually. // FIXME: The following limits should be reduced eventually.
const ROOT_ENTRY_LIMIT: usize = 939; const ROOT_ENTRY_LIMIT: usize = 939;
const ISSUES_ENTRY_LIMIT: usize = 2105; const ISSUES_ENTRY_LIMIT: usize = 2085;
fn check_entries(path: &Path, bad: &mut bool) { fn check_entries(path: &Path, bad: &mut bool) {
for dir in Walk::new(&path.join("test/ui")) { for dir in Walk::new(&path.join("test/ui")) {