Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit df2f45c

Browse files
committedDec 19, 2021
Auto merge of #92090 - matthiaskrgr:rollup-pbyqddi, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #91834 (Update browser-ui-test version and improve rustdoc-gui tests readability) - #91894 (Remove `in_band_lifetimes` from `rustc_incremental`) - #91932 (Add user seed to `-Z randomize-layout`) - #91956 (fix(rustc_lint): better detect when parens are necessary) - #92020 (Remove P: Unpin bound on impl Stream for Pin) - #92063 (docs: fix typo) - #92082 (rustdoc: Write doc-comments directly instead of using FromIterator) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents daf2204 + d486e68 commit df2f45c

27 files changed

+374
-99
lines changed
 

‎compiler/rustc_incremental/src/assert_dep_graph.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ struct IfThisChanged<'tcx> {
103103
then_this_would_need: Targets,
104104
}
105105

106-
impl IfThisChanged<'tcx> {
106+
impl<'tcx> IfThisChanged<'tcx> {
107107
fn argument(&self, attr: &ast::Attribute) -> Option<Symbol> {
108108
let mut value = None;
109109
for list_item in attr.meta_item_list().unwrap_or_default() {
@@ -172,7 +172,7 @@ impl IfThisChanged<'tcx> {
172172
}
173173
}
174174

175-
impl Visitor<'tcx> for IfThisChanged<'tcx> {
175+
impl<'tcx> Visitor<'tcx> for IfThisChanged<'tcx> {
176176
type Map = Map<'tcx>;
177177

178178
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {

‎compiler/rustc_incremental/src/assert_module_sources.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ struct AssertModuleSource<'tcx> {
5656
available_cgus: BTreeSet<String>,
5757
}
5858

59-
impl AssertModuleSource<'tcx> {
59+
impl<'tcx> AssertModuleSource<'tcx> {
6060
fn check_attr(&self, attr: &ast::Attribute) {
6161
let (expected_reuse, comp_kind) = if attr.has_name(sym::rustc_partition_reused) {
6262
(CguReuse::PreLto, ComparisonKind::AtLeast)

‎compiler/rustc_incremental/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
33
#![deny(missing_docs)]
44
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
5-
#![feature(in_band_lifetimes)]
65
#![feature(let_else)]
76
#![feature(nll)]
87
#![recursion_limit = "256"]

‎compiler/rustc_incremental/src/persist/dirty_clean.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ pub struct DirtyCleanVisitor<'tcx> {
155155
checked_attrs: FxHashSet<ast::AttrId>,
156156
}
157157

158-
impl DirtyCleanVisitor<'tcx> {
158+
impl<'tcx> DirtyCleanVisitor<'tcx> {
159159
/// Possibly "deserialize" the attribute into a clean/dirty assertion
160160
fn assertion_maybe(&mut self, item_id: LocalDefId, attr: &Attribute) -> Option<Assertion> {
161161
if !attr.has_name(sym::rustc_clean) {
@@ -352,7 +352,7 @@ impl DirtyCleanVisitor<'tcx> {
352352
}
353353
}
354354

355-
impl ItemLikeVisitor<'tcx> for DirtyCleanVisitor<'tcx> {
355+
impl<'tcx> ItemLikeVisitor<'tcx> for DirtyCleanVisitor<'tcx> {
356356
fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
357357
self.check_item(item.def_id, item.span);
358358
}
@@ -415,7 +415,7 @@ pub struct FindAllAttrs<'tcx> {
415415
found_attrs: Vec<&'tcx Attribute>,
416416
}
417417

418-
impl FindAllAttrs<'tcx> {
418+
impl<'tcx> FindAllAttrs<'tcx> {
419419
fn is_active_attr(&mut self, attr: &Attribute) -> bool {
420420
if attr.has_name(sym::rustc_clean) && check_config(self.tcx, attr) {
421421
return true;
@@ -434,7 +434,7 @@ impl FindAllAttrs<'tcx> {
434434
}
435435
}
436436

437-
impl intravisit::Visitor<'tcx> for FindAllAttrs<'tcx> {
437+
impl<'tcx> intravisit::Visitor<'tcx> for FindAllAttrs<'tcx> {
438438
type Map = Map<'tcx>;
439439

440440
fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<Self::Map> {

‎compiler/rustc_lint/src/unused.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,11 @@ trait UnusedDelimLint {
478478

479479
lhs_needs_parens
480480
|| (followed_by_block
481-
&& match inner.kind {
481+
&& match &inner.kind {
482482
ExprKind::Ret(_) | ExprKind::Break(..) | ExprKind::Yield(..) => true,
483+
ExprKind::Range(_lhs, Some(rhs), _limits) => {
484+
matches!(rhs.kind, ExprKind::Block(..))
485+
}
483486
_ => parser::contains_exterior_struct_lit(&inner),
484487
})
485488
}

‎compiler/rustc_middle/src/ty/layout.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,10 +347,6 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
347347

348348
let mut inverse_memory_index: Vec<u32> = (0..fields.len() as u32).collect();
349349

350-
// `ReprOptions.layout_seed` is a deterministic seed that we can use to
351-
// randomize field ordering with
352-
let mut rng = Xoshiro128StarStar::seed_from_u64(repr.field_shuffle_seed);
353-
354350
let optimize = !repr.inhibit_struct_field_reordering_opt();
355351
if optimize {
356352
let end =
@@ -364,6 +360,10 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
364360
// the field ordering to try and catch some code making assumptions about layouts
365361
// we don't guarantee
366362
if repr.can_randomize_type_layout() {
363+
// `ReprOptions.layout_seed` is a deterministic seed that we can use to
364+
// randomize field ordering with
365+
let mut rng = Xoshiro128StarStar::seed_from_u64(repr.field_shuffle_seed);
366+
367367
// Shuffle the ordering of the fields
368368
optimizing.shuffle(&mut rng);
369369

‎compiler/rustc_middle/src/ty/mod.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,9 +1608,9 @@ bitflags! {
16081608
// the seed stored in `ReprOptions.layout_seed`
16091609
const RANDOMIZE_LAYOUT = 1 << 5;
16101610
// Any of these flags being set prevent field reordering optimisation.
1611-
const IS_UNOPTIMISABLE = ReprFlags::IS_C.bits |
1612-
ReprFlags::IS_SIMD.bits |
1613-
ReprFlags::IS_LINEAR.bits;
1611+
const IS_UNOPTIMISABLE = ReprFlags::IS_C.bits
1612+
| ReprFlags::IS_SIMD.bits
1613+
| ReprFlags::IS_LINEAR.bits;
16141614
}
16151615
}
16161616

@@ -1640,7 +1640,14 @@ impl ReprOptions {
16401640

16411641
// Generate a deterministically-derived seed from the item's path hash
16421642
// to allow for cross-crate compilation to actually work
1643-
let field_shuffle_seed = tcx.def_path_hash(did).0.to_smaller_hash();
1643+
let mut field_shuffle_seed = tcx.def_path_hash(did).0.to_smaller_hash();
1644+
1645+
// If the user defined a custom seed for layout randomization, xor the item's
1646+
// path hash with the user defined seed, this will allowing determinism while
1647+
// still allowing users to further randomize layout generation for e.g. fuzzing
1648+
if let Some(user_seed) = tcx.sess.opts.debugging_opts.layout_seed {
1649+
field_shuffle_seed ^= user_seed;
1650+
}
16441651

16451652
for attr in tcx.get_attrs(did).iter() {
16461653
for r in attr::find_repr_attrs(&tcx.sess, attr) {

‎compiler/rustc_session/src/options.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,6 +1321,8 @@ options! {
13211321
"print some statistics about the query system (default: no)"),
13221322
randomize_layout: bool = (false, parse_bool, [TRACKED],
13231323
"randomize the layout of types (default: no)"),
1324+
layout_seed: Option<u64> = (None, parse_opt_number, [TRACKED],
1325+
"seed layout randomization"),
13241326
relax_elf_relocations: Option<bool> = (None, parse_opt_bool, [TRACKED],
13251327
"whether ELF relocations can be relaxed"),
13261328
relro_level: Option<RelroLevel> = (None, parse_relro_level, [TRACKED],

‎library/alloc/src/borrow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ where
170170
/// clone_on_write.values.to_mut().push(3);
171171
/// println!("clone_on_write = {:?}", clone_on_write.values);
172172
///
173-
/// // The data was mutated. Let check it out.
173+
/// // The data was mutated. Let's check it out.
174174
/// match clone_on_write {
175175
/// Items { values: Cow::Owned(_) } => println!("clone_on_write contains owned data"),
176176
/// _ => panic!("expect owned data"),

‎library/core/src/stream/stream.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,13 @@ impl<S: ?Sized + Stream + Unpin> Stream for &mut S {
9595
#[unstable(feature = "async_stream", issue = "79024")]
9696
impl<P> Stream for Pin<P>
9797
where
98-
P: DerefMut + Unpin,
98+
P: DerefMut,
9999
P::Target: Stream,
100100
{
101101
type Item = <P::Target as Stream>::Item;
102102

103103
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
104-
self.get_mut().as_mut().poll_next(cx)
104+
<P::Target as Stream>::poll_next(self.as_deref_mut(), cx)
105105
}
106106

107107
fn size_hint(&self) -> (usize, Option<usize>) {

‎src/ci/docker/host-x86_64/x86_64-gnu-tools/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ ENV PATH="/node-v14.4.0-linux-x64/bin:${PATH}"
7272
# https://github.com/puppeteer/puppeteer/issues/375
7373
#
7474
# We also specify the version in case we need to update it to go around cache limitations.
75-
RUN npm install -g browser-ui-test@0.5.0 --unsafe-perm=true
75+
RUN npm install -g browser-ui-test@0.5.1 --unsafe-perm=true
7676

7777
ENV RUST_CONFIGURE_ARGS \
7878
--build=x86_64-unknown-linux-gnu \

‎src/librustdoc/clean/types.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::cell::RefCell;
22
use std::default::Default;
33
use std::hash::{Hash, Hasher};
4-
use std::iter::FromIterator;
54
use std::lazy::SyncOnceCell as OnceCell;
65
use std::path::PathBuf;
76
use std::rc::Rc;
@@ -958,16 +957,14 @@ fn add_doc_fragment(out: &mut String, frag: &DocFragment) {
958957
}
959958
}
960959

961-
impl<'a> FromIterator<&'a DocFragment> for String {
962-
fn from_iter<T>(iter: T) -> Self
963-
where
964-
T: IntoIterator<Item = &'a DocFragment>,
965-
{
966-
iter.into_iter().fold(String::new(), |mut acc, frag| {
967-
add_doc_fragment(&mut acc, frag);
968-
acc
969-
})
960+
/// Collapse a collection of [`DocFragment`]s into one string,
961+
/// handling indentation and newlines as needed.
962+
crate fn collapse_doc_fragments(doc_strings: &[DocFragment]) -> String {
963+
let mut acc = String::new();
964+
for frag in doc_strings {
965+
add_doc_fragment(&mut acc, frag);
970966
}
967+
acc
971968
}
972969

973970
/// A link that has not yet been rendered.
@@ -1113,7 +1110,11 @@ impl Attributes {
11131110
/// Finds all `doc` attributes as NameValues and returns their corresponding values, joined
11141111
/// with newlines.
11151112
crate fn collapsed_doc_value(&self) -> Option<String> {
1116-
if self.doc_strings.is_empty() { None } else { Some(self.doc_strings.iter().collect()) }
1113+
if self.doc_strings.is_empty() {
1114+
None
1115+
} else {
1116+
Some(collapse_doc_fragments(&self.doc_strings))
1117+
}
11171118
}
11181119

11191120
crate fn get_doc_aliases(&self) -> Box<[Symbol]> {

‎src/librustdoc/passes/unindent_comments/tests.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
use super::*;
2+
3+
use crate::clean::collapse_doc_fragments;
4+
25
use rustc_span::create_default_session_globals_then;
36
use rustc_span::source_map::DUMMY_SP;
47
use rustc_span::symbol::Symbol;
@@ -19,7 +22,7 @@ fn run_test(input: &str, expected: &str) {
1922
create_default_session_globals_then(|| {
2023
let mut s = create_doc_fragment(input);
2124
unindent_fragments(&mut s);
22-
assert_eq!(&s.iter().collect::<String>(), expected);
25+
assert_eq!(collapse_doc_fragments(&s), expected);
2326
});
2427
}
2528

‎src/test/rustdoc-gui/anchors.goml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ assert-css: ("#impl a.anchor", {"color": "rgb(0, 0, 0)"})
3434
move-cursor-to: ".top-doc .docblock .section-header:first-child"
3535
assert-css: (
3636
".top-doc .docblock .section-header:first-child > a::before",
37-
{"left": "-10px", "padding-right": "10px"}
37+
{"left": "-10px", "padding-right": "10px"},
3838
)
3939
// We also check that the heading itself has a different indent.
4040
assert-css: (".top-doc .docblock .section-header:first-child", {"margin-left": "15px"})
4141

4242
move-cursor-to: ".top-doc .docblock .section-header:not(:first-child)"
4343
assert-css: (
4444
".top-doc .docblock .section-header:not(:first-child) > a::before",
45-
{"left": "-25px", "padding-right": "10px"}
45+
{"left": "-25px", "padding-right": "10px"},
4646
)
4747
assert-css: (".top-doc .docblock .section-header:not(:first-child)", {"margin-left": "0px"})
4848

@@ -51,14 +51,14 @@ assert-css: (".top-doc .docblock .section-header:not(:first-child)", {"margin-le
5151
move-cursor-to: "#title-for-struct-impl-doc"
5252
assert-css: (
5353
"#title-for-struct-impl-doc > a::before",
54-
{"left": "-25px", "padding-right": "10px"}
54+
{"left": "-25px", "padding-right": "10px"},
5555
)
5656
assert-css: ("#title-for-struct-impl-doc", {"margin-left": "0px"})
5757
// Now a method docs.
5858
move-cursor-to: "#title-for-struct-impl-item-doc"
5959
assert-css: (
6060
"#title-for-struct-impl-item-doc > a::before",
61-
{"left": "-25px", "padding-right": "10px"}
61+
{"left": "-25px", "padding-right": "10px"},
6262
)
6363
assert-css: ("#title-for-struct-impl-item-doc", {"margin-left": "0px"})
6464

@@ -69,6 +69,6 @@ goto: file://|DOC_PATH|/test_docs/enum.WhoLetTheDogOut.html
6969
move-cursor-to: ".top-doc .docblock .section-header"
7070
assert-css: (
7171
".top-doc .docblock .section-header > a::before",
72-
{"left": "-25px", "padding-right": "10px"}
72+
{"left": "-25px", "padding-right": "10px"},
7373
)
7474
assert-css: (".top-doc .docblock .section-header", {"margin-left": "0px"})

‎src/test/rustdoc-gui/docblock-code-block-line-number.goml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ wait-for: "pre.line-number"
1616
assert-css: ("pre.line-number", {
1717
"margin": "0px",
1818
"padding": "13px 8px",
19-
"text-align": "right"
19+
"text-align": "right",
2020
})
2121
// The first code block has two lines so let's check its `<pre>` elements lists both of them.
2222
assert-text: ("pre.line-number", "1\n2")

‎src/test/rustdoc-gui/docblock-table-overflow.goml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ assert-property: (".top-doc .docblock table", {"scrollWidth": "1573"})
1111
// Checking it works on other doc blocks as well...
1212

1313
// Logically, the ".docblock" and the "<p>" should have the same scroll width.
14-
compare-elements-property: ("#implementations + details .docblock", "#implementations + details .docblock > p", ["scrollWidth"])
14+
compare-elements-property: (
15+
"#implementations + details .docblock",
16+
"#implementations + details .docblock > p",
17+
["scrollWidth"],
18+
)
1519
assert-property: ("#implementations + details .docblock", {"scrollWidth": "816"})
1620
// However, since there is overflow in the <table>, its scroll width is bigger.
1721
assert-property: ("#implementations + details .docblock table", {"scrollWidth": "1573"})

‎src/test/rustdoc-gui/font-weight.goml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
goto: file://|DOC_PATH|/lib2/struct.Foo.html
22
// This test checks that the font weight is correctly applied.
33
assert-css: ("//*[@class='docblock item-decl']//a[text()='Alias']", {"font-weight": "400"})
4-
assert-css: ("//*[@class='structfield small-section-header']//a[text()='Alias']", {"font-weight": "400"})
4+
assert-css: (
5+
"//*[@class='structfield small-section-header']//a[text()='Alias']",
6+
{"font-weight": "400"},
7+
)
58
assert-css: ("#method\.a_method > .code-header", {"font-weight": "600"})
69
assert-css: ("#associatedtype\.X > .code-header", {"font-weight": "600"})
710
assert-css: ("#associatedconstant\.Y > .code-header", {"font-weight": "600"})
@@ -25,8 +28,14 @@ goto: file://|DOC_PATH|/lib2/trait.Trait.html
2528
//
2629
// This uses '/parent::*' as a proxy for the style of the text node.
2730
// We can't just select the '<a>' because intermediate tags could be added.
28-
assert-count: ("//*[@class='docblock item-decl']/pre[@class='rust trait']/code/a[@class='constant']//text()/parent::*", 1)
29-
assert-css: ("//*[@class='docblock item-decl']/pre[@class='rust trait']/code/a[@class='constant']//text()/parent::*", {"font-weight": "400"})
31+
assert-count: (
32+
"//*[@class='docblock item-decl']/pre[@class='rust trait']/code/a[@class='constant']//text()/parent::*",
33+
1,
34+
)
35+
assert-css: (
36+
"//*[@class='docblock item-decl']/pre[@class='rust trait']/code/a[@class='constant']//text()/parent::*",
37+
{"font-weight": "400"},
38+
)
3039

3140
assert-count: (".methods .type", 1)
3241
assert-css: (".methods .type", {"font-weight": "600"})

‎src/test/rustdoc-gui/headers-color.goml

Lines changed: 63 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,36 @@ goto: file://|DOC_PATH|/test_docs/struct.Foo.html
55
show-text: true
66

77
// Ayu theme
8-
local-storage: {"rustdoc-theme": "ayu", "rustdoc-preferred-dark-theme": "ayu", "rustdoc-use-system-theme": "false"}
8+
local-storage: {
9+
"rustdoc-theme": "ayu",
10+
"rustdoc-preferred-dark-theme": "ayu",
11+
"rustdoc-use-system-theme": "false",
12+
}
913
reload:
1014

11-
assert-css: (".impl", {"color": "rgb(197, 197, 197)", "background-color": "rgba(0, 0, 0, 0)"}, ALL)
12-
assert-css: (".impl .code-header", {"color": "rgb(230, 225, 207)", "background-color": "rgb(15, 20, 25)"}, ALL)
15+
assert-css: (
16+
".impl",
17+
{"color": "rgb(197, 197, 197)", "background-color": "rgba(0, 0, 0, 0)"},
18+
ALL,
19+
)
20+
assert-css: (
21+
".impl .code-header",
22+
{"color": "rgb(230, 225, 207)", "background-color": "rgb(15, 20, 25)"},
23+
ALL,
24+
)
1325

1426
goto: file://|DOC_PATH|/test_docs/struct.Foo.html#impl
15-
assert-css: ("#impl", {"color": "rgb(197, 197, 197)", "background-color": "rgba(255, 236, 164, 0.06)"})
27+
assert-css: (
28+
"#impl",
29+
{"color": "rgb(197, 197, 197)", "background-color": "rgba(255, 236, 164, 0.06)"},
30+
)
1631

1732
goto: file://|DOC_PATH|/test_docs/struct.Foo.html#method.must_use
18-
assert-css: ("#method\.must_use", {"color": "rgb(197, 197, 197)", "background-color": "rgba(255, 236, 164, 0.06)"}, ALL)
33+
assert-css: (
34+
"#method\.must_use",
35+
{"color": "rgb(197, 197, 197)", "background-color": "rgba(255, 236, 164, 0.06)"},
36+
ALL,
37+
)
1938

2039
goto: file://|DOC_PATH|/test_docs/index.html
2140
assert-css: (".small-section-header a", {"color": "rgb(197, 197, 197)"}, ALL)
@@ -24,17 +43,36 @@ goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html
2443
assert-css: (".section-header a", {"color": "rgb(57, 175, 215)"}, ALL)
2544

2645
// Dark theme
27-
local-storage: {"rustdoc-theme": "dark", "rustdoc-preferred-dark-theme": "dark", "rustdoc-use-system-theme": "false"}
46+
local-storage: {
47+
"rustdoc-theme": "dark",
48+
"rustdoc-preferred-dark-theme": "dark",
49+
"rustdoc-use-system-theme": "false",
50+
}
2851
goto: file://|DOC_PATH|/test_docs/struct.Foo.html
2952

30-
assert-css: (".impl", {"color": "rgb(221, 221, 221)", "background-color": "rgba(0, 0, 0, 0)"}, ALL)
31-
assert-css: (".impl .code-header", {"color": "rgb(221, 221, 221)", "background-color": "rgb(53, 53, 53)"}, ALL)
53+
assert-css: (
54+
".impl",
55+
{"color": "rgb(221, 221, 221)", "background-color": "rgba(0, 0, 0, 0)"},
56+
ALL,
57+
)
58+
assert-css: (
59+
".impl .code-header",
60+
{"color": "rgb(221, 221, 221)", "background-color": "rgb(53, 53, 53)"},
61+
ALL,
62+
)
3263

3364
goto: file://|DOC_PATH|/test_docs/struct.Foo.html#impl
34-
assert-css: ("#impl", {"color": "rgb(221, 221, 221)", "background-color": "rgb(73, 74, 61)"})
65+
assert-css: (
66+
"#impl",
67+
{"color": "rgb(221, 221, 221)", "background-color": "rgb(73, 74, 61)"},
68+
)
3569

3670
goto: file://|DOC_PATH|/test_docs/struct.Foo.html#method.must_use
37-
assert-css: ("#method\.must_use", {"color": "rgb(221, 221, 221)", "background-color": "rgb(73, 74, 61)"}, ALL)
71+
assert-css: (
72+
"#method\.must_use",
73+
{"color": "rgb(221, 221, 221)", "background-color": "rgb(73, 74, 61)"},
74+
ALL,
75+
)
3876

3977
goto: file://|DOC_PATH|/test_docs/index.html
4078
assert-css: (".small-section-header a", {"color": "rgb(221, 221, 221)"}, ALL)
@@ -48,14 +86,26 @@ reload:
4886

4987
goto: file://|DOC_PATH|/test_docs/struct.Foo.html
5088

51-
assert-css: (".impl", {"color": "rgb(0, 0, 0)", "background-color": "rgba(0, 0, 0, 0)"}, ALL)
52-
assert-css: (".impl .code-header", {"color": "rgb(0, 0, 0)", "background-color": "rgb(255, 255, 255)"}, ALL)
89+
assert-css: (
90+
".impl",
91+
{"color": "rgb(0, 0, 0)", "background-color": "rgba(0, 0, 0, 0)"},
92+
ALL,
93+
)
94+
assert-css: (
95+
".impl .code-header",
96+
{"color": "rgb(0, 0, 0)", "background-color": "rgb(255, 255, 255)"},
97+
ALL,
98+
)
5399

54100
goto: file://|DOC_PATH|/test_docs/struct.Foo.html#impl
55101
assert-css: ("#impl", {"color": "rgb(0, 0, 0)", "background-color": "rgb(253, 255, 211)"})
56102

57103
goto: file://|DOC_PATH|/test_docs/struct.Foo.html#method.must_use
58-
assert-css: ("#method\.must_use", {"color": "rgb(0, 0, 0)", "background-color": "rgb(253, 255, 211)"}, ALL)
104+
assert-css: (
105+
"#method\.must_use",
106+
{"color": "rgb(0, 0, 0)", "background-color": "rgb(253, 255, 211)"},
107+
ALL,
108+
)
59109

60110
goto: file://|DOC_PATH|/test_docs/index.html
61111
assert-css: (".small-section-header a", {"color": "rgb(0, 0, 0)"}, ALL)

‎src/test/rustdoc-gui/huge-collection-of-constants.goml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@ goto: file://|DOC_PATH|/test_docs/huge_amount_of_consts/index.html
22

33
// Make sure that the last two entries are more than 12 pixels apart and not stacked on each other.
44

5-
compare-elements-position-near-false: ("//*[@class='item-table']//div[last()-1]", "//*[@class='item-table']//div[last()-3]", {"y": 12})
5+
compare-elements-position-near-false: (
6+
"//*[@class='item-table']//div[last()-1]",
7+
"//*[@class='item-table']//div[last()-3]",
8+
{"y": 12},
9+
)

‎src/test/rustdoc-gui/jump-to-def-background.goml

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,42 @@
22
goto: file://|DOC_PATH|/src/link_to_definition/lib.rs.html
33

44
// Set the theme to dark.
5-
local-storage: {"rustdoc-theme": "dark", "rustdoc-preferred-dark-theme": "dark", "rustdoc-use-system-theme": "false"}
5+
local-storage: {
6+
"rustdoc-theme": "dark",
7+
"rustdoc-preferred-dark-theme": "dark",
8+
"rustdoc-use-system-theme": "false",
9+
}
610
// We reload the page so the local storage settings are being used.
711
reload:
812

9-
assert-css: ("body.source .example-wrap pre.rust a", {"background-color": "rgb(51, 51, 51)"}, ALL)
13+
assert-css: (
14+
"body.source .example-wrap pre.rust a",
15+
{"background-color": "rgb(51, 51, 51)"},
16+
ALL,
17+
)
1018

1119
// Set the theme to ayu.
12-
local-storage: {"rustdoc-theme": "ayu", "rustdoc-preferred-dark-theme": "ayu", "rustdoc-use-system-theme": "false"}
20+
local-storage: {
21+
"rustdoc-theme": "ayu",
22+
"rustdoc-preferred-dark-theme": "ayu",
23+
"rustdoc-use-system-theme": "false",
24+
}
1325
// We reload the page so the local storage settings are being used.
1426
reload:
1527

16-
assert-css: ("body.source .example-wrap pre.rust a", {"background-color": "rgb(51, 51, 51)"}, ALL)
28+
assert-css: (
29+
"body.source .example-wrap pre.rust a",
30+
{"background-color": "rgb(51, 51, 51)"},
31+
ALL,
32+
)
1733

1834
// Set the theme to light.
1935
local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"}
2036
// We reload the page so the local storage settings are being used.
2137
reload:
2238

23-
assert-css: ("body.source .example-wrap pre.rust a", {"background-color": "rgb(238, 238, 238)"}, ALL)
39+
assert-css: (
40+
"body.source .example-wrap pre.rust a",
41+
{"background-color": "rgb(238, 238, 238)"},
42+
ALL,
43+
)

‎src/test/rustdoc-gui/label-next-to-symbol.goml

Lines changed: 53 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,71 @@ assert: (".stab.deprecated")
88
assert: (".stab.portability")
99

1010
// make sure that deprecated and portability are different colours
11-
assert-css: (".item-table .item-left .stab.deprecated", { "background-color": "rgb(255, 196, 196)" })
12-
assert-css: (".item-table .item-left .stab.portability", { "background-color": "rgb(243, 223, 255)" })
11+
assert-css: (
12+
".item-table .item-left .stab.deprecated",
13+
{ "background-color": "rgb(255, 196, 196)" },
14+
)
15+
assert-css: (
16+
".item-table .item-left .stab.portability",
17+
{ "background-color": "rgb(243, 223, 255)" },
18+
)
1319

1420
// table like view
1521
assert-css: (".item-right.docblock-short", { "padding-left": "0px" })
16-
compare-elements-position-near: ("//*[@class='item-left module-item']//a[text()='replaced_function']", ".item-left .stab.deprecated", {"y": 2})
17-
compare-elements-position: (".item-left .stab.deprecated", ".item-left .stab.portability", ("y"))
22+
compare-elements-position-near: (
23+
"//*[@class='item-left module-item']//a[text()='replaced_function']",
24+
".item-left .stab.deprecated",
25+
{"y": 2},
26+
)
27+
compare-elements-position: (
28+
".item-left .stab.deprecated",
29+
".item-left .stab.portability",
30+
("y"),
31+
)
1832

1933
// Ensure no wrap
20-
compare-elements-position-near: ("//*[@class='item-left module-item']//a[text()='replaced_function']", "//*[@class='item-right docblock-short']//p[text()='a thing with a label']", {"y": 2})
34+
compare-elements-position-near: (
35+
"//*[@class='item-left module-item']//a[text()='replaced_function']",
36+
"//*[@class='item-right docblock-short']//p[text()='a thing with a label']",
37+
{"y": 2},
38+
)
2139
// compare parent elements
22-
compare-elements-position: ("//*[@class='item-left module-item']//a[text()='replaced_function']/..", "//*[@class='item-right docblock-short']//p[text()='a thing with a label']/..", ("y"))
40+
compare-elements-position: (
41+
"//*[@class='item-left module-item']//a[text()='replaced_function']/..",
42+
"//*[@class='item-right docblock-short']//p[text()='a thing with a label']/..",
43+
("y"),
44+
)
2345

2446

2547
// Mobile view
2648
size: (600, 600)
2749
// staggered layout with 2em spacing
2850
assert-css: (".item-right.docblock-short", { "padding-left": "32px" })
29-
compare-elements-position-near: ("//*[@class='item-left module-item']//a[text()='replaced_function']", ".item-left .stab.deprecated", {"y": 1})
30-
compare-elements-position: (".item-left .stab.deprecated", ".item-left .stab.portability", ("y"))
51+
compare-elements-position-near: (
52+
"//*[@class='item-left module-item']//a[text()='replaced_function']",
53+
".item-left .stab.deprecated",
54+
{"y": 1},
55+
)
56+
compare-elements-position: (
57+
".item-left .stab.deprecated",
58+
".item-left .stab.portability",
59+
("y"),
60+
)
3161

3262
// Ensure wrap
33-
compare-elements-position-near-false: ("//*[@class='item-left module-item']//a[text()='replaced_function']", "//*[@class='item-right docblock-short']//p[text()='a thing with a label']", {"y": 12})
63+
compare-elements-position-near-false: (
64+
"//*[@class='item-left module-item']//a[text()='replaced_function']",
65+
"//*[@class='item-right docblock-short']//p[text()='a thing with a label']",
66+
{"y": 12},
67+
)
3468
// compare parent elements
35-
compare-elements-position-false: ("//*[@class='item-left module-item']//a[text()='replaced_function']/..", "//*[@class='item-right docblock-short']//p[text()='a thing with a label']/..", ("y"))
36-
compare-elements-position-false: (".item-left .stab.deprecated", "//*[@class='item-right docblock-short']//p[text()='a thing with a label']", ("y"))
69+
compare-elements-position-false: (
70+
"//*[@class='item-left module-item']//a[text()='replaced_function']/..",
71+
"//*[@class='item-right docblock-short']//p[text()='a thing with a label']/..",
72+
("y"),
73+
)
74+
compare-elements-position-false: (
75+
".item-left .stab.deprecated",
76+
"//*[@class='item-right docblock-short']//p[text()='a thing with a label']",
77+
("y"),
78+
)
Lines changed: 58 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,67 @@
11
// This test checks that the correct font is used on module items (in index.html pages).
22
goto: file://|DOC_PATH|/test_docs/index.html
3-
assert-css: (".item-table .module-item a", {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'}, ALL)
4-
assert-css: (".item-table .docblock-short", {"font-family": '"Source Serif 4", NanumBarunGothic, serif'}, ALL)
3+
assert-css: (
4+
".item-table .module-item a",
5+
{"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'},
6+
ALL,
7+
)
8+
assert-css: (
9+
".item-table .docblock-short",
10+
{"font-family": '"Source Serif 4", NanumBarunGothic, serif'},
11+
ALL,
12+
)
513

614
// modules
7-
assert-css: ("#modules + .item-table .item-left a", {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'})
8-
assert-css: ("#modules + .item-table .item-right.docblock-short", {"font-family": '"Source Serif 4", NanumBarunGothic, serif'})
15+
assert-css: (
16+
"#modules + .item-table .item-left a",
17+
{"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'},
18+
)
19+
assert-css: (
20+
"#modules + .item-table .item-right.docblock-short",
21+
{"font-family": '"Source Serif 4", NanumBarunGothic, serif'},
22+
)
923
// structs
10-
assert-css: ("#structs + .item-table .item-left a", {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'})
11-
assert-css: ("#structs + .item-table .item-right.docblock-short", {"font-family": '"Source Serif 4", NanumBarunGothic, serif'})
24+
assert-css: (
25+
"#structs + .item-table .item-left a",
26+
{"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'},
27+
)
28+
assert-css: (
29+
"#structs + .item-table .item-right.docblock-short",
30+
{"font-family": '"Source Serif 4", NanumBarunGothic, serif'},
31+
)
1232
// enums
13-
assert-css: ("#enums + .item-table .item-left a", {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'})
14-
assert-css: ("#enums + .item-table .item-right.docblock-short", {"font-family": '"Source Serif 4", NanumBarunGothic, serif'})
33+
assert-css: (
34+
"#enums + .item-table .item-left a",
35+
{"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'},
36+
)
37+
assert-css: (
38+
"#enums + .item-table .item-right.docblock-short",
39+
{"font-family": '"Source Serif 4", NanumBarunGothic, serif'},
40+
)
1541
// traits
16-
assert-css: ("#traits + .item-table .item-left a", {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'})
17-
assert-css: ("#traits + .item-table .item-right.docblock-short", {"font-family": '"Source Serif 4", NanumBarunGothic, serif'})
42+
assert-css: (
43+
"#traits + .item-table .item-left a",
44+
{"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'},
45+
)
46+
assert-css: (
47+
"#traits + .item-table .item-right.docblock-short",
48+
{"font-family": '"Source Serif 4", NanumBarunGothic, serif'},
49+
)
1850
// functions
19-
assert-css: ("#functions + .item-table .item-left a", {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'})
20-
assert-css: ("#functions + .item-table .item-right.docblock-short", {"font-family": '"Source Serif 4", NanumBarunGothic, serif'})
51+
assert-css: (
52+
"#functions + .item-table .item-left a",
53+
{"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'},
54+
)
55+
assert-css: (
56+
"#functions + .item-table .item-right.docblock-short",
57+
{"font-family": '"Source Serif 4", NanumBarunGothic, serif'},
58+
)
2159
// keywords
22-
assert-css: ("#keywords + .item-table .item-left a", {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'})
23-
assert-css: ("#keywords + .item-table .item-right.docblock-short", {"font-family": '"Source Serif 4", NanumBarunGothic, serif'})
60+
assert-css: (
61+
"#keywords + .item-table .item-left a",
62+
{"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'},
63+
)
64+
assert-css: (
65+
"#keywords + .item-table .item-right.docblock-short",
66+
{"font-family": '"Source Serif 4", NanumBarunGothic, serif'},
67+
)

‎src/test/rustdoc-gui/search-result-color.goml

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,72 @@ goto: file://|DOC_PATH|/test_docs/index.html?search=coo
55
show-text: true
66

77
// Ayu theme
8-
local-storage: {"rustdoc-theme": "ayu", "rustdoc-preferred-dark-theme": "ayu", "rustdoc-use-system-theme": "false"}
8+
local-storage: {
9+
"rustdoc-theme": "ayu",
10+
"rustdoc-preferred-dark-theme": "ayu",
11+
"rustdoc-use-system-theme": "false",
12+
}
913
reload:
1014

1115
// Waiting for the search results to appear...
1216
wait-for: "#titles"
13-
assert-css: ("//*[@class='desc']//*[text()='Just a normal struct.']", {"color": "rgb(197, 197, 197)"})
14-
assert-css: ("//*[@class='result-name']/*[text()='test_docs::']", {"color": "rgb(0, 150, 207)"})
17+
assert-css: (
18+
"//*[@class='desc']//*[text()='Just a normal struct.']",
19+
{"color": "rgb(197, 197, 197)"},
20+
)
21+
assert-css: (
22+
"//*[@class='result-name']/*[text()='test_docs::']",
23+
{"color": "rgb(0, 150, 207)"},
24+
)
1525

1626
// Checking the color for "keyword".
17-
assert-css: ("//*[@class='result-name']//*[text()='(keyword)']", {"color": "rgb(120, 135, 151)"})
27+
assert-css: (
28+
"//*[@class='result-name']//*[text()='(keyword)']",
29+
{"color": "rgb(120, 135, 151)"},
30+
)
1831

1932
// Dark theme
20-
local-storage: {"rustdoc-theme": "dark", "rustdoc-preferred-dark-theme": "dark", "rustdoc-use-system-theme": "false"}
33+
local-storage: {
34+
"rustdoc-theme": "dark",
35+
"rustdoc-preferred-dark-theme": "dark",
36+
"rustdoc-use-system-theme": "false",
37+
}
2138
reload:
2239

2340
// Waiting for the search results to appear...
2441
wait-for: "#titles"
25-
assert-css: ("//*[@class='desc']//*[text()='Just a normal struct.']", {"color": "rgb(221, 221, 221)"})
26-
assert-css: ("//*[@class='result-name']/*[text()='test_docs::']", {"color": "rgb(221, 221, 221)"})
42+
assert-css: (
43+
"//*[@class='desc']//*[text()='Just a normal struct.']",
44+
{"color": "rgb(221, 221, 221)"},
45+
)
46+
assert-css: (
47+
"//*[@class='result-name']/*[text()='test_docs::']",
48+
{"color": "rgb(221, 221, 221)"},
49+
)
2750

2851
// Checking the color for "keyword".
29-
assert-css: ("//*[@class='result-name']//*[text()='(keyword)']", {"color": "rgb(221, 221, 221)"})
52+
assert-css: (
53+
"//*[@class='result-name']//*[text()='(keyword)']",
54+
{"color": "rgb(221, 221, 221)"},
55+
)
3056

3157
// Light theme
3258
local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"}
3359
reload:
3460

3561
// Waiting for the search results to appear...
3662
wait-for: "#titles"
37-
assert-css: ("//*[@class='desc']//*[text()='Just a normal struct.']", {"color": "rgb(0, 0, 0)"})
38-
assert-css: ("//*[@class='result-name']/*[text()='test_docs::']", {"color": "rgb(0, 0, 0)"})
63+
assert-css: (
64+
"//*[@class='desc']//*[text()='Just a normal struct.']",
65+
{"color": "rgb(0, 0, 0)"},
66+
)
67+
assert-css: (
68+
"//*[@class='result-name']/*[text()='test_docs::']",
69+
{"color": "rgb(0, 0, 0)"},
70+
)
3971

4072
// Checking the color for "keyword".
41-
assert-css: ("//*[@class='result-name']//*[text()='(keyword)']", {"color": "rgb(0, 0, 0)"})
73+
assert-css: (
74+
"//*[@class='result-name']//*[text()='(keyword)']",
75+
{"color": "rgb(0, 0, 0)"},
76+
)

‎src/test/rustdoc-gui/search-result-colors.goml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
goto: file://|DOC_PATH|/test_docs/index.html
22
// We set the theme so we're sure that the correct values will be used, whatever the computer
33
// this test is running on.
4-
local-storage: {"rustdoc-theme": "dark", "rustdoc-preferred-dark-theme": "dark", "rustdoc-use-system-theme": "false"}
4+
local-storage: {
5+
"rustdoc-theme": "dark",
6+
"rustdoc-preferred-dark-theme": "dark",
7+
"rustdoc-use-system-theme": "false",
8+
}
59
// If the text isn't displayed, the browser doesn't compute color style correctly...
610
show-text: true
711
// We reload the page so the local storage settings are being used.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Make sure unused parens lint emit is emitted for loop and match.
2+
// See https://github.com/rust-lang/rust/issues/90807
3+
// and https://github.com/rust-lang/rust/pull/91956#discussion_r771647953
4+
#![deny(unused_parens)]
5+
6+
fn main() {
7+
for _ in (1..loop { break 2 }) {} //~ERROR
8+
for _ in (1..match () { () => 2 }) {} //~ERROR
9+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
error: unnecessary parentheses around `for` iterator expression
2+
--> $DIR/issue-90807-unused-paren-error.rs:7:14
3+
|
4+
LL | for _ in (1..loop { break 2 }) {}
5+
| ^ ^
6+
|
7+
note: the lint level is defined here
8+
--> $DIR/issue-90807-unused-paren-error.rs:4:9
9+
|
10+
LL | #![deny(unused_parens)]
11+
| ^^^^^^^^^^^^^
12+
help: remove these parentheses
13+
|
14+
LL - for _ in (1..loop { break 2 }) {}
15+
LL + for _ in 1..loop { break 2 } {}
16+
|
17+
18+
error: unnecessary parentheses around `for` iterator expression
19+
--> $DIR/issue-90807-unused-paren-error.rs:8:14
20+
|
21+
LL | for _ in (1..match () { () => 2 }) {}
22+
| ^ ^
23+
|
24+
help: remove these parentheses
25+
|
26+
LL - for _ in (1..match () { () => 2 }) {}
27+
LL + for _ in 1..match () { () => 2 } {}
28+
|
29+
30+
error: aborting due to 2 previous errors
31+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// check-pass
2+
// Make sure unused parens lint doesn't emit a false positive.
3+
// See https://github.com/rust-lang/rust/issues/90807
4+
#![deny(unused_parens)]
5+
6+
fn main() {
7+
for _ in (1..{ 2 }) {}
8+
}

0 commit comments

Comments
 (0)
Please sign in to comment.