diff --git a/compiler/rustc_incremental/src/assert_dep_graph.rs b/compiler/rustc_incremental/src/assert_dep_graph.rs index 7b5b015d5a509f35f9b6afc96735619928c6591f..4691cdd64c10deaaed0823df149258c3696a996f 100644 --- a/compiler/rustc_incremental/src/assert_dep_graph.rs +++ b/compiler/rustc_incremental/src/assert_dep_graph.rs @@ -103,7 +103,7 @@ struct IfThisChanged<'tcx> { then_this_would_need: Targets, } -impl IfThisChanged<'tcx> { +impl<'tcx> IfThisChanged<'tcx> { fn argument(&self, attr: &ast::Attribute) -> Option { let mut value = None; for list_item in attr.meta_item_list().unwrap_or_default() { @@ -172,7 +172,7 @@ fn process_attrs(&mut self, hir_id: hir::HirId) { } } -impl Visitor<'tcx> for IfThisChanged<'tcx> { +impl<'tcx> Visitor<'tcx> for IfThisChanged<'tcx> { type Map = Map<'tcx>; fn nested_visit_map(&mut self) -> NestedVisitorMap { diff --git a/compiler/rustc_incremental/src/assert_module_sources.rs b/compiler/rustc_incremental/src/assert_module_sources.rs index 2cf8f9b08e190908fe13990e5c195785031dead7..b5974f8fb768f587a9c9a99cfbb44fe82af86247 100644 --- a/compiler/rustc_incremental/src/assert_module_sources.rs +++ b/compiler/rustc_incremental/src/assert_module_sources.rs @@ -56,7 +56,7 @@ struct AssertModuleSource<'tcx> { available_cgus: BTreeSet, } -impl AssertModuleSource<'tcx> { +impl<'tcx> AssertModuleSource<'tcx> { fn check_attr(&self, attr: &ast::Attribute) { let (expected_reuse, comp_kind) = if attr.has_name(sym::rustc_partition_reused) { (CguReuse::PreLto, ComparisonKind::AtLeast) diff --git a/compiler/rustc_incremental/src/lib.rs b/compiler/rustc_incremental/src/lib.rs index 07e9f8b00ca1bd75184000545deaeb0a0bc2ea37..df64534ce54d924ae0c6bcb427d9e08502f7b100 100644 --- a/compiler/rustc_incremental/src/lib.rs +++ b/compiler/rustc_incremental/src/lib.rs @@ -2,7 +2,6 @@ #![deny(missing_docs)] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] -#![feature(in_band_lifetimes)] #![feature(let_else)] #![feature(nll)] #![recursion_limit = "256"] diff --git a/compiler/rustc_incremental/src/persist/dirty_clean.rs b/compiler/rustc_incremental/src/persist/dirty_clean.rs index b2eaf61b7d14560912011fcea60ed46f8723e739..7ac00b4609aaf92efe2b2aaee926d97bc46a8271 100644 --- a/compiler/rustc_incremental/src/persist/dirty_clean.rs +++ b/compiler/rustc_incremental/src/persist/dirty_clean.rs @@ -155,7 +155,7 @@ pub struct DirtyCleanVisitor<'tcx> { checked_attrs: FxHashSet, } -impl DirtyCleanVisitor<'tcx> { +impl<'tcx> DirtyCleanVisitor<'tcx> { /// Possibly "deserialize" the attribute into a clean/dirty assertion fn assertion_maybe(&mut self, item_id: LocalDefId, attr: &Attribute) -> Option { if !attr.has_name(sym::rustc_clean) { @@ -352,7 +352,7 @@ fn check_item(&mut self, item_id: LocalDefId, item_span: Span) { } } -impl ItemLikeVisitor<'tcx> for DirtyCleanVisitor<'tcx> { +impl<'tcx> ItemLikeVisitor<'tcx> for DirtyCleanVisitor<'tcx> { fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) { self.check_item(item.def_id, item.span); } @@ -415,7 +415,7 @@ pub struct FindAllAttrs<'tcx> { found_attrs: Vec<&'tcx Attribute>, } -impl FindAllAttrs<'tcx> { +impl<'tcx> FindAllAttrs<'tcx> { fn is_active_attr(&mut self, attr: &Attribute) -> bool { if attr.has_name(sym::rustc_clean) && check_config(self.tcx, attr) { return true; @@ -434,7 +434,7 @@ fn report_unchecked_attrs(&self, mut checked_attrs: FxHashSet) { } } -impl intravisit::Visitor<'tcx> for FindAllAttrs<'tcx> { +impl<'tcx> intravisit::Visitor<'tcx> for FindAllAttrs<'tcx> { type Map = Map<'tcx>; fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap { diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index ed24b94e2fd3b24bcadac04dc65584deec6d8406..8e1c9b6394a7404d2e2ac588608146354031749a 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -478,8 +478,11 @@ fn is_expr_delims_necessary( lhs_needs_parens || (followed_by_block - && match inner.kind { + && match &inner.kind { ExprKind::Ret(_) | ExprKind::Break(..) | ExprKind::Yield(..) => true, + ExprKind::Range(_lhs, Some(rhs), _limits) => { + matches!(rhs.kind, ExprKind::Block(..)) + } _ => parser::contains_exterior_struct_lit(&inner), }) } diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 02811b2491c15fd4d579546b4d0a6f1d0c400c92..727c0ba63cbb64b30511df583c8af65656bc43b7 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -347,10 +347,6 @@ fn univariant_uninterned( let mut inverse_memory_index: Vec = (0..fields.len() as u32).collect(); - // `ReprOptions.layout_seed` is a deterministic seed that we can use to - // randomize field ordering with - let mut rng = Xoshiro128StarStar::seed_from_u64(repr.field_shuffle_seed); - let optimize = !repr.inhibit_struct_field_reordering_opt(); if optimize { let end = @@ -364,6 +360,10 @@ fn univariant_uninterned( // the field ordering to try and catch some code making assumptions about layouts // we don't guarantee if repr.can_randomize_type_layout() { + // `ReprOptions.layout_seed` is a deterministic seed that we can use to + // randomize field ordering with + let mut rng = Xoshiro128StarStar::seed_from_u64(repr.field_shuffle_seed); + // Shuffle the ordering of the fields optimizing.shuffle(&mut rng); diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index d0d2a46fc4c1d6131378cb8a9b5091aa5847c351..10232dc9cb60e01e44666b26691b43997ff9267e 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -1608,9 +1608,9 @@ pub struct ReprFlags: u8 { // the seed stored in `ReprOptions.layout_seed` const RANDOMIZE_LAYOUT = 1 << 5; // Any of these flags being set prevent field reordering optimisation. - const IS_UNOPTIMISABLE = ReprFlags::IS_C.bits | - ReprFlags::IS_SIMD.bits | - ReprFlags::IS_LINEAR.bits; + const IS_UNOPTIMISABLE = ReprFlags::IS_C.bits + | ReprFlags::IS_SIMD.bits + | ReprFlags::IS_LINEAR.bits; } } @@ -1640,7 +1640,14 @@ pub fn new(tcx: TyCtxt<'_>, did: DefId) -> ReprOptions { // Generate a deterministically-derived seed from the item's path hash // to allow for cross-crate compilation to actually work - let field_shuffle_seed = tcx.def_path_hash(did).0.to_smaller_hash(); + let mut field_shuffle_seed = tcx.def_path_hash(did).0.to_smaller_hash(); + + // If the user defined a custom seed for layout randomization, xor the item's + // path hash with the user defined seed, this will allowing determinism while + // still allowing users to further randomize layout generation for e.g. fuzzing + if let Some(user_seed) = tcx.sess.opts.debugging_opts.layout_seed { + field_shuffle_seed ^= user_seed; + } for attr in tcx.get_attrs(did).iter() { for r in attr::find_repr_attrs(&tcx.sess, attr) { diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index dc5f4ee0ece0cd0ccad378fd6ec73dad9ddca585..9090524c93396f47f72e17e815a7cfd85ff89149 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -1321,6 +1321,8 @@ mod parse { "print some statistics about the query system (default: no)"), randomize_layout: bool = (false, parse_bool, [TRACKED], "randomize the layout of types (default: no)"), + layout_seed: Option = (None, parse_opt_number, [TRACKED], + "seed layout randomization"), relax_elf_relocations: Option = (None, parse_opt_bool, [TRACKED], "whether ELF relocations can be relaxed"), relro_level: Option = (None, parse_relro_level, [TRACKED], diff --git a/library/alloc/src/borrow.rs b/library/alloc/src/borrow.rs index 9ecbf0582319e845febdf4cca95e4d822c0bd7c6..63234ee91f091096568443b861b55d3d52d4dd50 100644 --- a/library/alloc/src/borrow.rs +++ b/library/alloc/src/borrow.rs @@ -170,7 +170,7 @@ fn clone_into(&self, target: &mut T) { /// clone_on_write.values.to_mut().push(3); /// println!("clone_on_write = {:?}", clone_on_write.values); /// -/// // The data was mutated. Let check it out. +/// // The data was mutated. Let's check it out. /// match clone_on_write { /// Items { values: Cow::Owned(_) } => println!("clone_on_write contains owned data"), /// _ => panic!("expect owned data"), diff --git a/library/core/src/stream/stream.rs b/library/core/src/stream/stream.rs index d102619b8e5ec135f09090ae7b1e08e5413c3a87..2cfddf9ad013d7366f0a098887034ed49ce58def 100644 --- a/library/core/src/stream/stream.rs +++ b/library/core/src/stream/stream.rs @@ -95,13 +95,13 @@ fn size_hint(&self) -> (usize, Option) { #[unstable(feature = "async_stream", issue = "79024")] impl

Stream for Pin

where - P: DerefMut + Unpin, + P: DerefMut, P::Target: Stream, { type Item = ::Item; fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { - self.get_mut().as_mut().poll_next(cx) + ::poll_next(self.as_deref_mut(), cx) } fn size_hint(&self) -> (usize, Option) { diff --git a/src/ci/docker/host-x86_64/x86_64-gnu-tools/Dockerfile b/src/ci/docker/host-x86_64/x86_64-gnu-tools/Dockerfile index f71282a1b52d47bd1411e2331df71f32a8557e9c..6e77bb0a09b9e9a32f894eadabc75d106632ff8e 100644 --- a/src/ci/docker/host-x86_64/x86_64-gnu-tools/Dockerfile +++ b/src/ci/docker/host-x86_64/x86_64-gnu-tools/Dockerfile @@ -72,7 +72,7 @@ ENV PATH="/node-v14.4.0-linux-x64/bin:${PATH}" # https://github.com/puppeteer/puppeteer/issues/375 # # We also specify the version in case we need to update it to go around cache limitations. -RUN npm install -g browser-ui-test@0.5.0 --unsafe-perm=true +RUN npm install -g browser-ui-test@0.5.1 --unsafe-perm=true ENV RUST_CONFIGURE_ARGS \ --build=x86_64-unknown-linux-gnu \ diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 6ce6d889150108e5b543ff222238f9b855f2f4cd..2bd90f67cf4af64f09cf1e5db6d0a4e7eb9fd246 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -1,7 +1,6 @@ use std::cell::RefCell; use std::default::Default; use std::hash::{Hash, Hasher}; -use std::iter::FromIterator; use std::lazy::SyncOnceCell as OnceCell; use std::path::PathBuf; use std::rc::Rc; @@ -958,16 +957,14 @@ fn add_doc_fragment(out: &mut String, frag: &DocFragment) { } } -impl<'a> FromIterator<&'a DocFragment> for String { - fn from_iter(iter: T) -> Self - where - T: IntoIterator, - { - iter.into_iter().fold(String::new(), |mut acc, frag| { - add_doc_fragment(&mut acc, frag); - acc - }) +/// Collapse a collection of [`DocFragment`]s into one string, +/// handling indentation and newlines as needed. +crate fn collapse_doc_fragments(doc_strings: &[DocFragment]) -> String { + let mut acc = String::new(); + for frag in doc_strings { + add_doc_fragment(&mut acc, frag); } + acc } /// A link that has not yet been rendered. @@ -1113,7 +1110,11 @@ fn update_need_backline(doc_strings: &mut Vec) { /// Finds all `doc` attributes as NameValues and returns their corresponding values, joined /// with newlines. crate fn collapsed_doc_value(&self) -> Option { - if self.doc_strings.is_empty() { None } else { Some(self.doc_strings.iter().collect()) } + if self.doc_strings.is_empty() { + None + } else { + Some(collapse_doc_fragments(&self.doc_strings)) + } } crate fn get_doc_aliases(&self) -> Box<[Symbol]> { diff --git a/src/librustdoc/passes/unindent_comments/tests.rs b/src/librustdoc/passes/unindent_comments/tests.rs index daec04e11cd180b409308c9c7325944049c38f2d..3d3d2e50321d9df44d269d211d6ba6fbe9598a4a 100644 --- a/src/librustdoc/passes/unindent_comments/tests.rs +++ b/src/librustdoc/passes/unindent_comments/tests.rs @@ -1,4 +1,7 @@ use super::*; + +use crate::clean::collapse_doc_fragments; + use rustc_span::create_default_session_globals_then; use rustc_span::source_map::DUMMY_SP; use rustc_span::symbol::Symbol; @@ -19,7 +22,7 @@ fn run_test(input: &str, expected: &str) { create_default_session_globals_then(|| { let mut s = create_doc_fragment(input); unindent_fragments(&mut s); - assert_eq!(&s.iter().collect::(), expected); + assert_eq!(collapse_doc_fragments(&s), expected); }); } diff --git a/src/test/rustdoc-gui/anchors.goml b/src/test/rustdoc-gui/anchors.goml index 8910cbbbb256c7c14cccd904c548591919a52576..2216b3f1c972843297857bd5af889e3344b8d731 100644 --- a/src/test/rustdoc-gui/anchors.goml +++ b/src/test/rustdoc-gui/anchors.goml @@ -34,7 +34,7 @@ assert-css: ("#impl a.anchor", {"color": "rgb(0, 0, 0)"}) move-cursor-to: ".top-doc .docblock .section-header:first-child" assert-css: ( ".top-doc .docblock .section-header:first-child > a::before", - {"left": "-10px", "padding-right": "10px"} + {"left": "-10px", "padding-right": "10px"}, ) // We also check that the heading itself has a different indent. assert-css: (".top-doc .docblock .section-header:first-child", {"margin-left": "15px"}) @@ -42,7 +42,7 @@ assert-css: (".top-doc .docblock .section-header:first-child", {"margin-left": " move-cursor-to: ".top-doc .docblock .section-header:not(:first-child)" assert-css: ( ".top-doc .docblock .section-header:not(:first-child) > a::before", - {"left": "-25px", "padding-right": "10px"} + {"left": "-25px", "padding-right": "10px"}, ) assert-css: (".top-doc .docblock .section-header:not(:first-child)", {"margin-left": "0px"}) @@ -51,14 +51,14 @@ assert-css: (".top-doc .docblock .section-header:not(:first-child)", {"margin-le move-cursor-to: "#title-for-struct-impl-doc" assert-css: ( "#title-for-struct-impl-doc > a::before", - {"left": "-25px", "padding-right": "10px"} + {"left": "-25px", "padding-right": "10px"}, ) assert-css: ("#title-for-struct-impl-doc", {"margin-left": "0px"}) // Now a method docs. move-cursor-to: "#title-for-struct-impl-item-doc" assert-css: ( "#title-for-struct-impl-item-doc > a::before", - {"left": "-25px", "padding-right": "10px"} + {"left": "-25px", "padding-right": "10px"}, ) assert-css: ("#title-for-struct-impl-item-doc", {"margin-left": "0px"}) @@ -69,6 +69,6 @@ goto: file://|DOC_PATH|/test_docs/enum.WhoLetTheDogOut.html move-cursor-to: ".top-doc .docblock .section-header" assert-css: ( ".top-doc .docblock .section-header > a::before", - {"left": "-25px", "padding-right": "10px"} + {"left": "-25px", "padding-right": "10px"}, ) assert-css: (".top-doc .docblock .section-header", {"margin-left": "0px"}) diff --git a/src/test/rustdoc-gui/docblock-code-block-line-number.goml b/src/test/rustdoc-gui/docblock-code-block-line-number.goml index 7e6607b55ea8bead372fe82b422233cb431605e8..baf9651c40de39125595daa4de2a2d15f2ec6e00 100644 --- a/src/test/rustdoc-gui/docblock-code-block-line-number.goml +++ b/src/test/rustdoc-gui/docblock-code-block-line-number.goml @@ -16,7 +16,7 @@ wait-for: "pre.line-number" assert-css: ("pre.line-number", { "margin": "0px", "padding": "13px 8px", - "text-align": "right" + "text-align": "right", }) // The first code block has two lines so let's check its `

` elements lists both of them.
 assert-text: ("pre.line-number", "1\n2")
diff --git a/src/test/rustdoc-gui/docblock-table-overflow.goml b/src/test/rustdoc-gui/docblock-table-overflow.goml
index 10f516d2dae06703003c3a1336ad0da560207867..1b3006155d8b632a7c9314667a0011d6378a4fa4 100644
--- a/src/test/rustdoc-gui/docblock-table-overflow.goml
+++ b/src/test/rustdoc-gui/docblock-table-overflow.goml
@@ -11,7 +11,11 @@ assert-property: (".top-doc .docblock table", {"scrollWidth": "1573"})
 // Checking it works on other doc blocks as well...
 
 // Logically, the ".docblock" and the "

" should have the same scroll width. -compare-elements-property: ("#implementations + details .docblock", "#implementations + details .docblock > p", ["scrollWidth"]) +compare-elements-property: ( + "#implementations + details .docblock", + "#implementations + details .docblock > p", + ["scrollWidth"], +) assert-property: ("#implementations + details .docblock", {"scrollWidth": "816"}) // However, since there is overflow in the , its scroll width is bigger. assert-property: ("#implementations + details .docblock table", {"scrollWidth": "1573"}) diff --git a/src/test/rustdoc-gui/font-weight.goml b/src/test/rustdoc-gui/font-weight.goml index 0459fd4b9c353644158378331ed6ab8765b0f090..c9117e2c101d7def38bde591113bac8e0022fff0 100644 --- a/src/test/rustdoc-gui/font-weight.goml +++ b/src/test/rustdoc-gui/font-weight.goml @@ -1,7 +1,10 @@ goto: file://|DOC_PATH|/lib2/struct.Foo.html // This test checks that the font weight is correctly applied. assert-css: ("//*[@class='docblock item-decl']//a[text()='Alias']", {"font-weight": "400"}) -assert-css: ("//*[@class='structfield small-section-header']//a[text()='Alias']", {"font-weight": "400"}) +assert-css: ( + "//*[@class='structfield small-section-header']//a[text()='Alias']", + {"font-weight": "400"}, +) assert-css: ("#method\.a_method > .code-header", {"font-weight": "600"}) assert-css: ("#associatedtype\.X > .code-header", {"font-weight": "600"}) assert-css: ("#associatedconstant\.Y > .code-header", {"font-weight": "600"}) @@ -25,8 +28,14 @@ goto: file://|DOC_PATH|/lib2/trait.Trait.html // // This uses '/parent::*' as a proxy for the style of the text node. // We can't just select the '' because intermediate tags could be added. -assert-count: ("//*[@class='docblock item-decl']/pre[@class='rust trait']/code/a[@class='constant']//text()/parent::*", 1) -assert-css: ("//*[@class='docblock item-decl']/pre[@class='rust trait']/code/a[@class='constant']//text()/parent::*", {"font-weight": "400"}) +assert-count: ( + "//*[@class='docblock item-decl']/pre[@class='rust trait']/code/a[@class='constant']//text()/parent::*", + 1, +) +assert-css: ( + "//*[@class='docblock item-decl']/pre[@class='rust trait']/code/a[@class='constant']//text()/parent::*", + {"font-weight": "400"}, +) assert-count: (".methods .type", 1) assert-css: (".methods .type", {"font-weight": "600"}) diff --git a/src/test/rustdoc-gui/headers-color.goml b/src/test/rustdoc-gui/headers-color.goml index 03b10e3f78d431ffb8630a9d0778a5b5ff53e165..d58ca13a6291fbc855f3e3ae158a27d54485c5de 100644 --- a/src/test/rustdoc-gui/headers-color.goml +++ b/src/test/rustdoc-gui/headers-color.goml @@ -5,17 +5,36 @@ goto: file://|DOC_PATH|/test_docs/struct.Foo.html show-text: true // Ayu theme -local-storage: {"rustdoc-theme": "ayu", "rustdoc-preferred-dark-theme": "ayu", "rustdoc-use-system-theme": "false"} +local-storage: { + "rustdoc-theme": "ayu", + "rustdoc-preferred-dark-theme": "ayu", + "rustdoc-use-system-theme": "false", +} reload: -assert-css: (".impl", {"color": "rgb(197, 197, 197)", "background-color": "rgba(0, 0, 0, 0)"}, ALL) -assert-css: (".impl .code-header", {"color": "rgb(230, 225, 207)", "background-color": "rgb(15, 20, 25)"}, ALL) +assert-css: ( + ".impl", + {"color": "rgb(197, 197, 197)", "background-color": "rgba(0, 0, 0, 0)"}, + ALL, +) +assert-css: ( + ".impl .code-header", + {"color": "rgb(230, 225, 207)", "background-color": "rgb(15, 20, 25)"}, + ALL, +) goto: file://|DOC_PATH|/test_docs/struct.Foo.html#impl -assert-css: ("#impl", {"color": "rgb(197, 197, 197)", "background-color": "rgba(255, 236, 164, 0.06)"}) +assert-css: ( + "#impl", + {"color": "rgb(197, 197, 197)", "background-color": "rgba(255, 236, 164, 0.06)"}, +) goto: file://|DOC_PATH|/test_docs/struct.Foo.html#method.must_use -assert-css: ("#method\.must_use", {"color": "rgb(197, 197, 197)", "background-color": "rgba(255, 236, 164, 0.06)"}, ALL) +assert-css: ( + "#method\.must_use", + {"color": "rgb(197, 197, 197)", "background-color": "rgba(255, 236, 164, 0.06)"}, + ALL, +) goto: file://|DOC_PATH|/test_docs/index.html 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 assert-css: (".section-header a", {"color": "rgb(57, 175, 215)"}, ALL) // Dark theme -local-storage: {"rustdoc-theme": "dark", "rustdoc-preferred-dark-theme": "dark", "rustdoc-use-system-theme": "false"} +local-storage: { + "rustdoc-theme": "dark", + "rustdoc-preferred-dark-theme": "dark", + "rustdoc-use-system-theme": "false", +} goto: file://|DOC_PATH|/test_docs/struct.Foo.html -assert-css: (".impl", {"color": "rgb(221, 221, 221)", "background-color": "rgba(0, 0, 0, 0)"}, ALL) -assert-css: (".impl .code-header", {"color": "rgb(221, 221, 221)", "background-color": "rgb(53, 53, 53)"}, ALL) +assert-css: ( + ".impl", + {"color": "rgb(221, 221, 221)", "background-color": "rgba(0, 0, 0, 0)"}, + ALL, +) +assert-css: ( + ".impl .code-header", + {"color": "rgb(221, 221, 221)", "background-color": "rgb(53, 53, 53)"}, + ALL, +) goto: file://|DOC_PATH|/test_docs/struct.Foo.html#impl -assert-css: ("#impl", {"color": "rgb(221, 221, 221)", "background-color": "rgb(73, 74, 61)"}) +assert-css: ( + "#impl", + {"color": "rgb(221, 221, 221)", "background-color": "rgb(73, 74, 61)"}, +) goto: file://|DOC_PATH|/test_docs/struct.Foo.html#method.must_use -assert-css: ("#method\.must_use", {"color": "rgb(221, 221, 221)", "background-color": "rgb(73, 74, 61)"}, ALL) +assert-css: ( + "#method\.must_use", + {"color": "rgb(221, 221, 221)", "background-color": "rgb(73, 74, 61)"}, + ALL, +) goto: file://|DOC_PATH|/test_docs/index.html assert-css: (".small-section-header a", {"color": "rgb(221, 221, 221)"}, ALL) @@ -48,14 +86,26 @@ reload: goto: file://|DOC_PATH|/test_docs/struct.Foo.html -assert-css: (".impl", {"color": "rgb(0, 0, 0)", "background-color": "rgba(0, 0, 0, 0)"}, ALL) -assert-css: (".impl .code-header", {"color": "rgb(0, 0, 0)", "background-color": "rgb(255, 255, 255)"}, ALL) +assert-css: ( + ".impl", + {"color": "rgb(0, 0, 0)", "background-color": "rgba(0, 0, 0, 0)"}, + ALL, +) +assert-css: ( + ".impl .code-header", + {"color": "rgb(0, 0, 0)", "background-color": "rgb(255, 255, 255)"}, + ALL, +) goto: file://|DOC_PATH|/test_docs/struct.Foo.html#impl assert-css: ("#impl", {"color": "rgb(0, 0, 0)", "background-color": "rgb(253, 255, 211)"}) goto: file://|DOC_PATH|/test_docs/struct.Foo.html#method.must_use -assert-css: ("#method\.must_use", {"color": "rgb(0, 0, 0)", "background-color": "rgb(253, 255, 211)"}, ALL) +assert-css: ( + "#method\.must_use", + {"color": "rgb(0, 0, 0)", "background-color": "rgb(253, 255, 211)"}, + ALL, +) goto: file://|DOC_PATH|/test_docs/index.html assert-css: (".small-section-header a", {"color": "rgb(0, 0, 0)"}, ALL) diff --git a/src/test/rustdoc-gui/huge-collection-of-constants.goml b/src/test/rustdoc-gui/huge-collection-of-constants.goml index 924fab1ea91068817d431d481f26c94218867fdb..4f7fe7a212c923628f60dd76c8aa84b6a1348a98 100644 --- a/src/test/rustdoc-gui/huge-collection-of-constants.goml +++ b/src/test/rustdoc-gui/huge-collection-of-constants.goml @@ -2,4 +2,8 @@ goto: file://|DOC_PATH|/test_docs/huge_amount_of_consts/index.html // Make sure that the last two entries are more than 12 pixels apart and not stacked on each other. -compare-elements-position-near-false: ("//*[@class='item-table']//div[last()-1]", "//*[@class='item-table']//div[last()-3]", {"y": 12}) +compare-elements-position-near-false: ( + "//*[@class='item-table']//div[last()-1]", + "//*[@class='item-table']//div[last()-3]", + {"y": 12}, +) diff --git a/src/test/rustdoc-gui/jump-to-def-background.goml b/src/test/rustdoc-gui/jump-to-def-background.goml index 3df899e0f2618d528dbe8f3b367cf0ad14433aa8..d17400f5bd9e8b7ba281d8cac5d293d99861d811 100644 --- a/src/test/rustdoc-gui/jump-to-def-background.goml +++ b/src/test/rustdoc-gui/jump-to-def-background.goml @@ -2,22 +2,42 @@ goto: file://|DOC_PATH|/src/link_to_definition/lib.rs.html // Set the theme to dark. -local-storage: {"rustdoc-theme": "dark", "rustdoc-preferred-dark-theme": "dark", "rustdoc-use-system-theme": "false"} +local-storage: { + "rustdoc-theme": "dark", + "rustdoc-preferred-dark-theme": "dark", + "rustdoc-use-system-theme": "false", +} // We reload the page so the local storage settings are being used. reload: -assert-css: ("body.source .example-wrap pre.rust a", {"background-color": "rgb(51, 51, 51)"}, ALL) +assert-css: ( + "body.source .example-wrap pre.rust a", + {"background-color": "rgb(51, 51, 51)"}, + ALL, +) // Set the theme to ayu. -local-storage: {"rustdoc-theme": "ayu", "rustdoc-preferred-dark-theme": "ayu", "rustdoc-use-system-theme": "false"} +local-storage: { + "rustdoc-theme": "ayu", + "rustdoc-preferred-dark-theme": "ayu", + "rustdoc-use-system-theme": "false", +} // We reload the page so the local storage settings are being used. reload: -assert-css: ("body.source .example-wrap pre.rust a", {"background-color": "rgb(51, 51, 51)"}, ALL) +assert-css: ( + "body.source .example-wrap pre.rust a", + {"background-color": "rgb(51, 51, 51)"}, + ALL, +) // Set the theme to light. local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} // We reload the page so the local storage settings are being used. reload: -assert-css: ("body.source .example-wrap pre.rust a", {"background-color": "rgb(238, 238, 238)"}, ALL) +assert-css: ( + "body.source .example-wrap pre.rust a", + {"background-color": "rgb(238, 238, 238)"}, + ALL, +) diff --git a/src/test/rustdoc-gui/label-next-to-symbol.goml b/src/test/rustdoc-gui/label-next-to-symbol.goml index 4fef4e655fdfb94e2d20c70217896dcdeefc161e..ca3994a08b269deac3346dfbabf3d410fa521598 100644 --- a/src/test/rustdoc-gui/label-next-to-symbol.goml +++ b/src/test/rustdoc-gui/label-next-to-symbol.goml @@ -8,29 +8,71 @@ assert: (".stab.deprecated") assert: (".stab.portability") // make sure that deprecated and portability are different colours -assert-css: (".item-table .item-left .stab.deprecated", { "background-color": "rgb(255, 196, 196)" }) -assert-css: (".item-table .item-left .stab.portability", { "background-color": "rgb(243, 223, 255)" }) +assert-css: ( + ".item-table .item-left .stab.deprecated", + { "background-color": "rgb(255, 196, 196)" }, +) +assert-css: ( + ".item-table .item-left .stab.portability", + { "background-color": "rgb(243, 223, 255)" }, +) // table like view assert-css: (".item-right.docblock-short", { "padding-left": "0px" }) -compare-elements-position-near: ("//*[@class='item-left module-item']//a[text()='replaced_function']", ".item-left .stab.deprecated", {"y": 2}) -compare-elements-position: (".item-left .stab.deprecated", ".item-left .stab.portability", ("y")) +compare-elements-position-near: ( + "//*[@class='item-left module-item']//a[text()='replaced_function']", + ".item-left .stab.deprecated", + {"y": 2}, +) +compare-elements-position: ( + ".item-left .stab.deprecated", + ".item-left .stab.portability", + ("y"), +) // Ensure no wrap -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}) +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}, +) // compare parent elements -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")) +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"), +) // Mobile view size: (600, 600) // staggered layout with 2em spacing assert-css: (".item-right.docblock-short", { "padding-left": "32px" }) -compare-elements-position-near: ("//*[@class='item-left module-item']//a[text()='replaced_function']", ".item-left .stab.deprecated", {"y": 1}) -compare-elements-position: (".item-left .stab.deprecated", ".item-left .stab.portability", ("y")) +compare-elements-position-near: ( + "//*[@class='item-left module-item']//a[text()='replaced_function']", + ".item-left .stab.deprecated", + {"y": 1}, +) +compare-elements-position: ( + ".item-left .stab.deprecated", + ".item-left .stab.portability", + ("y"), +) // Ensure wrap -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}) +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}, +) // compare parent elements -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")) -compare-elements-position-false: (".item-left .stab.deprecated", "//*[@class='item-right docblock-short']//p[text()='a thing with a label']", ("y")) +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"), +) +compare-elements-position-false: ( + ".item-left .stab.deprecated", + "//*[@class='item-right docblock-short']//p[text()='a thing with a label']", + ("y"), +) diff --git a/src/test/rustdoc-gui/module-items-font.goml b/src/test/rustdoc-gui/module-items-font.goml index 0316172ee1464663e393d4290d63f01f7491b59b..758ee391ae42b3b02224f61ad4c101c880204509 100644 --- a/src/test/rustdoc-gui/module-items-font.goml +++ b/src/test/rustdoc-gui/module-items-font.goml @@ -1,23 +1,67 @@ // This test checks that the correct font is used on module items (in index.html pages). goto: file://|DOC_PATH|/test_docs/index.html -assert-css: (".item-table .module-item a", {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'}, ALL) -assert-css: (".item-table .docblock-short", {"font-family": '"Source Serif 4", NanumBarunGothic, serif'}, ALL) +assert-css: ( + ".item-table .module-item a", + {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'}, + ALL, +) +assert-css: ( + ".item-table .docblock-short", + {"font-family": '"Source Serif 4", NanumBarunGothic, serif'}, + ALL, +) // modules -assert-css: ("#modules + .item-table .item-left a", {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'}) -assert-css: ("#modules + .item-table .item-right.docblock-short", {"font-family": '"Source Serif 4", NanumBarunGothic, serif'}) +assert-css: ( + "#modules + .item-table .item-left a", + {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'}, +) +assert-css: ( + "#modules + .item-table .item-right.docblock-short", + {"font-family": '"Source Serif 4", NanumBarunGothic, serif'}, +) // structs -assert-css: ("#structs + .item-table .item-left a", {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'}) -assert-css: ("#structs + .item-table .item-right.docblock-short", {"font-family": '"Source Serif 4", NanumBarunGothic, serif'}) +assert-css: ( + "#structs + .item-table .item-left a", + {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'}, +) +assert-css: ( + "#structs + .item-table .item-right.docblock-short", + {"font-family": '"Source Serif 4", NanumBarunGothic, serif'}, +) // enums -assert-css: ("#enums + .item-table .item-left a", {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'}) -assert-css: ("#enums + .item-table .item-right.docblock-short", {"font-family": '"Source Serif 4", NanumBarunGothic, serif'}) +assert-css: ( + "#enums + .item-table .item-left a", + {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'}, +) +assert-css: ( + "#enums + .item-table .item-right.docblock-short", + {"font-family": '"Source Serif 4", NanumBarunGothic, serif'}, +) // traits -assert-css: ("#traits + .item-table .item-left a", {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'}) -assert-css: ("#traits + .item-table .item-right.docblock-short", {"font-family": '"Source Serif 4", NanumBarunGothic, serif'}) +assert-css: ( + "#traits + .item-table .item-left a", + {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'}, +) +assert-css: ( + "#traits + .item-table .item-right.docblock-short", + {"font-family": '"Source Serif 4", NanumBarunGothic, serif'}, +) // functions -assert-css: ("#functions + .item-table .item-left a", {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'}) -assert-css: ("#functions + .item-table .item-right.docblock-short", {"font-family": '"Source Serif 4", NanumBarunGothic, serif'}) +assert-css: ( + "#functions + .item-table .item-left a", + {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'}, +) +assert-css: ( + "#functions + .item-table .item-right.docblock-short", + {"font-family": '"Source Serif 4", NanumBarunGothic, serif'}, +) // keywords -assert-css: ("#keywords + .item-table .item-left a", {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'}) -assert-css: ("#keywords + .item-table .item-right.docblock-short", {"font-family": '"Source Serif 4", NanumBarunGothic, serif'}) +assert-css: ( + "#keywords + .item-table .item-left a", + {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'}, +) +assert-css: ( + "#keywords + .item-table .item-right.docblock-short", + {"font-family": '"Source Serif 4", NanumBarunGothic, serif'}, +) diff --git a/src/test/rustdoc-gui/search-result-color.goml b/src/test/rustdoc-gui/search-result-color.goml index bb8ecb98fa3872bbfba2a9d6b99b8a58c4ea7334..ffa9362755dd7345399e2c4d043d03a9db311757 100644 --- a/src/test/rustdoc-gui/search-result-color.goml +++ b/src/test/rustdoc-gui/search-result-color.goml @@ -5,28 +5,54 @@ goto: file://|DOC_PATH|/test_docs/index.html?search=coo show-text: true // Ayu theme -local-storage: {"rustdoc-theme": "ayu", "rustdoc-preferred-dark-theme": "ayu", "rustdoc-use-system-theme": "false"} +local-storage: { + "rustdoc-theme": "ayu", + "rustdoc-preferred-dark-theme": "ayu", + "rustdoc-use-system-theme": "false", +} reload: // Waiting for the search results to appear... wait-for: "#titles" -assert-css: ("//*[@class='desc']//*[text()='Just a normal struct.']", {"color": "rgb(197, 197, 197)"}) -assert-css: ("//*[@class='result-name']/*[text()='test_docs::']", {"color": "rgb(0, 150, 207)"}) +assert-css: ( + "//*[@class='desc']//*[text()='Just a normal struct.']", + {"color": "rgb(197, 197, 197)"}, +) +assert-css: ( + "//*[@class='result-name']/*[text()='test_docs::']", + {"color": "rgb(0, 150, 207)"}, +) // Checking the color for "keyword". -assert-css: ("//*[@class='result-name']//*[text()='(keyword)']", {"color": "rgb(120, 135, 151)"}) +assert-css: ( + "//*[@class='result-name']//*[text()='(keyword)']", + {"color": "rgb(120, 135, 151)"}, +) // Dark theme -local-storage: {"rustdoc-theme": "dark", "rustdoc-preferred-dark-theme": "dark", "rustdoc-use-system-theme": "false"} +local-storage: { + "rustdoc-theme": "dark", + "rustdoc-preferred-dark-theme": "dark", + "rustdoc-use-system-theme": "false", +} reload: // Waiting for the search results to appear... wait-for: "#titles" -assert-css: ("//*[@class='desc']//*[text()='Just a normal struct.']", {"color": "rgb(221, 221, 221)"}) -assert-css: ("//*[@class='result-name']/*[text()='test_docs::']", {"color": "rgb(221, 221, 221)"}) +assert-css: ( + "//*[@class='desc']//*[text()='Just a normal struct.']", + {"color": "rgb(221, 221, 221)"}, +) +assert-css: ( + "//*[@class='result-name']/*[text()='test_docs::']", + {"color": "rgb(221, 221, 221)"}, +) // Checking the color for "keyword". -assert-css: ("//*[@class='result-name']//*[text()='(keyword)']", {"color": "rgb(221, 221, 221)"}) +assert-css: ( + "//*[@class='result-name']//*[text()='(keyword)']", + {"color": "rgb(221, 221, 221)"}, +) // Light theme local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} @@ -34,8 +60,17 @@ reload: // Waiting for the search results to appear... wait-for: "#titles" -assert-css: ("//*[@class='desc']//*[text()='Just a normal struct.']", {"color": "rgb(0, 0, 0)"}) -assert-css: ("//*[@class='result-name']/*[text()='test_docs::']", {"color": "rgb(0, 0, 0)"}) +assert-css: ( + "//*[@class='desc']//*[text()='Just a normal struct.']", + {"color": "rgb(0, 0, 0)"}, +) +assert-css: ( + "//*[@class='result-name']/*[text()='test_docs::']", + {"color": "rgb(0, 0, 0)"}, +) // Checking the color for "keyword". -assert-css: ("//*[@class='result-name']//*[text()='(keyword)']", {"color": "rgb(0, 0, 0)"}) +assert-css: ( + "//*[@class='result-name']//*[text()='(keyword)']", + {"color": "rgb(0, 0, 0)"}, +) diff --git a/src/test/rustdoc-gui/search-result-colors.goml b/src/test/rustdoc-gui/search-result-colors.goml index daf8bc9dea3501d690393056e3cf98a752c5247a..b4eb896af1c7e0d01a59a30237aca2d96534e0dd 100644 --- a/src/test/rustdoc-gui/search-result-colors.goml +++ b/src/test/rustdoc-gui/search-result-colors.goml @@ -1,7 +1,11 @@ goto: file://|DOC_PATH|/test_docs/index.html // We set the theme so we're sure that the correct values will be used, whatever the computer // this test is running on. -local-storage: {"rustdoc-theme": "dark", "rustdoc-preferred-dark-theme": "dark", "rustdoc-use-system-theme": "false"} +local-storage: { + "rustdoc-theme": "dark", + "rustdoc-preferred-dark-theme": "dark", + "rustdoc-use-system-theme": "false", +} // If the text isn't displayed, the browser doesn't compute color style correctly... show-text: true // We reload the page so the local storage settings are being used. diff --git a/src/test/ui/lint/unused/issue-90807-unused-paren-error.rs b/src/test/ui/lint/unused/issue-90807-unused-paren-error.rs new file mode 100644 index 0000000000000000000000000000000000000000..2fca2e262657eadd0241bfa02e300e1b27cd8234 --- /dev/null +++ b/src/test/ui/lint/unused/issue-90807-unused-paren-error.rs @@ -0,0 +1,9 @@ +// Make sure unused parens lint emit is emitted for loop and match. +// See https://github.com/rust-lang/rust/issues/90807 +// and https://github.com/rust-lang/rust/pull/91956#discussion_r771647953 +#![deny(unused_parens)] + +fn main() { + for _ in (1..loop { break 2 }) {} //~ERROR + for _ in (1..match () { () => 2 }) {} //~ERROR +} diff --git a/src/test/ui/lint/unused/issue-90807-unused-paren-error.stderr b/src/test/ui/lint/unused/issue-90807-unused-paren-error.stderr new file mode 100644 index 0000000000000000000000000000000000000000..4e158e126ac1f52d94b4dbbfc03bc215c3cf9d24 --- /dev/null +++ b/src/test/ui/lint/unused/issue-90807-unused-paren-error.stderr @@ -0,0 +1,31 @@ +error: unnecessary parentheses around `for` iterator expression + --> $DIR/issue-90807-unused-paren-error.rs:7:14 + | +LL | for _ in (1..loop { break 2 }) {} + | ^ ^ + | +note: the lint level is defined here + --> $DIR/issue-90807-unused-paren-error.rs:4:9 + | +LL | #![deny(unused_parens)] + | ^^^^^^^^^^^^^ +help: remove these parentheses + | +LL - for _ in (1..loop { break 2 }) {} +LL + for _ in 1..loop { break 2 } {} + | + +error: unnecessary parentheses around `for` iterator expression + --> $DIR/issue-90807-unused-paren-error.rs:8:14 + | +LL | for _ in (1..match () { () => 2 }) {} + | ^ ^ + | +help: remove these parentheses + | +LL - for _ in (1..match () { () => 2 }) {} +LL + for _ in 1..match () { () => 2 } {} + | + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/lint/unused/issue-90807-unused-paren.rs b/src/test/ui/lint/unused/issue-90807-unused-paren.rs new file mode 100644 index 0000000000000000000000000000000000000000..4c0930f967d89ab5a3e018b643dd6a8e7d031776 --- /dev/null +++ b/src/test/ui/lint/unused/issue-90807-unused-paren.rs @@ -0,0 +1,8 @@ +// check-pass +// Make sure unused parens lint doesn't emit a false positive. +// See https://github.com/rust-lang/rust/issues/90807 +#![deny(unused_parens)] + +fn main() { + for _ in (1..{ 2 }) {} +}