Skip to content

Commit df2f45c

Browse files
committed
Auto merge of rust-lang#92090 - matthiaskrgr:rollup-pbyqddi, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#91834 (Update browser-ui-test version and improve rustdoc-gui tests readability) - rust-lang#91894 (Remove `in_band_lifetimes` from `rustc_incremental`) - rust-lang#91932 (Add user seed to `-Z randomize-layout`) - rust-lang#91956 (fix(rustc_lint): better detect when parens are necessary) - rust-lang#92020 (Remove P: Unpin bound on impl Stream for Pin) - rust-lang#92063 (docs: fix typo) - rust-lang#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

+2-2
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

+1-1
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

-1
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

+4-4
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

+4-1
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

+4-4
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

+11-4
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

+2
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

+1-1
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

+2-2
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

+1-1
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 [email protected].0 --unsafe-perm=true
75+
RUN npm install -g [email protected].1 --unsafe-perm=true
7676

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

src/librustdoc/clean/types.rs

+12-11
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

+4-1
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

+5-5
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

+1-1
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

+5-1
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

+12-3
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"})

0 commit comments

Comments
 (0)