From 10b65c821fec2a37aa30e4ac7e2190981a8a49ef Mon Sep 17 00:00:00 2001 From: Stein Somers Date: Wed, 18 Nov 2020 18:19:38 +0100 Subject: [PATCH 1/9] Make BTreeSet::split_off name elements like other set methods do --- library/alloc/src/collections/btree/set.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/alloc/src/collections/btree/set.rs b/library/alloc/src/collections/btree/set.rs index 45ea30b538691..be740b05fb8ee 100644 --- a/library/alloc/src/collections/btree/set.rs +++ b/library/alloc/src/collections/btree/set.rs @@ -903,8 +903,8 @@ impl BTreeSet { self.map.append(&mut other.map); } - /// Splits the collection into two at the given key. Returns everything after the given key, - /// including the key. + /// Splits the collection into two at the given value. Returns everything after the given value, + /// including the value. /// /// # Examples /// @@ -933,11 +933,11 @@ impl BTreeSet { /// assert!(b.contains(&41)); /// ``` #[stable(feature = "btree_split_off", since = "1.11.0")] - pub fn split_off(&mut self, key: &Q) -> Self + pub fn split_off(&mut self, value: &Q) -> Self where T: Borrow + Ord, { - BTreeSet { map: self.map.split_off(key) } + BTreeSet { map: self.map.split_off(value) } } /// Creates an iterator that visits all values in ascending order and uses a closure From 28a50b376a2117c0ed23a70b64ee2b7505dcaf10 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Tue, 13 Jul 2021 16:55:40 +0900 Subject: [PATCH 2/9] Unignore some pretty printing tests --- src/test/ui/issues/issue-20427.rs | 1 - src/test/ui/issues/issue-22992.rs | 1 - src/test/ui/issues/issue-23338-ensure-param-drop-order.rs | 2 -- src/test/ui/issues/issue-27401-dropflag-reinit.rs | 1 - 4 files changed, 5 deletions(-) diff --git a/src/test/ui/issues/issue-20427.rs b/src/test/ui/issues/issue-20427.rs index 41922c6229351..cfd8b2191ac38 100644 --- a/src/test/ui/issues/issue-20427.rs +++ b/src/test/ui/issues/issue-20427.rs @@ -7,7 +7,6 @@ #![allow(deprecated, deprecated_in_future)] // aux-build:i8.rs -// ignore-pretty issue #37201 extern crate i8; use std::string as i16; diff --git a/src/test/ui/issues/issue-22992.rs b/src/test/ui/issues/issue-22992.rs index e2ae1f96ee533..292a0ae298dcf 100644 --- a/src/test/ui/issues/issue-22992.rs +++ b/src/test/ui/issues/issue-22992.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-pretty issue #37201 struct X { val: i32 } impl std::ops::Deref for X { diff --git a/src/test/ui/issues/issue-23338-ensure-param-drop-order.rs b/src/test/ui/issues/issue-23338-ensure-param-drop-order.rs index 823be8c832d09..a99f260dde3b2 100644 --- a/src/test/ui/issues/issue-23338-ensure-param-drop-order.rs +++ b/src/test/ui/issues/issue-23338-ensure-param-drop-order.rs @@ -1,8 +1,6 @@ // run-pass #![allow(non_upper_case_globals)] -// ignore-pretty issue #37201 - // This test is ensuring that parameters are indeed dropped after // temporaries in a fn body. diff --git a/src/test/ui/issues/issue-27401-dropflag-reinit.rs b/src/test/ui/issues/issue-27401-dropflag-reinit.rs index e137575c2f825..ab54af29bd6b9 100644 --- a/src/test/ui/issues/issue-27401-dropflag-reinit.rs +++ b/src/test/ui/issues/issue-27401-dropflag-reinit.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-pretty issue #37201 // Check that when a `let`-binding occurs in a loop, its associated // drop-flag is reinitialized (to indicate "needs-drop" at the end of From b09084cbb6f391c2efe7da26c70983d810c23c33 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 12 Jul 2021 16:32:26 +0200 Subject: [PATCH 3/9] Fix search result description text color for ayu theme --- src/librustdoc/html/static/css/themes/ayu.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/html/static/css/themes/ayu.css b/src/librustdoc/html/static/css/themes/ayu.css index 171d06c0a3667..1ef9ae3321f9f 100644 --- a/src/librustdoc/html/static/css/themes/ayu.css +++ b/src/librustdoc/html/static/css/themes/ayu.css @@ -161,7 +161,7 @@ pre, .rustdoc.source .example-wrap { .search-results a { color: #0096cf; } -.search-results a span.desc { +.search-results a div.desc { color: #c5c5c5; } From f0169e923b4c47b6fdf263d8e060a9c4e84c94e4 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 12 Jul 2021 16:48:25 +0200 Subject: [PATCH 4/9] Add test for search results colors --- src/test/rustdoc-gui/search-result-color.goml | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/test/rustdoc-gui/search-result-color.goml diff --git a/src/test/rustdoc-gui/search-result-color.goml b/src/test/rustdoc-gui/search-result-color.goml new file mode 100644 index 0000000000000..c138cc8d9c61a --- /dev/null +++ b/src/test/rustdoc-gui/search-result-color.goml @@ -0,0 +1,32 @@ +// The goal of this test is to ensure the color of the text is the one expected. +goto: file://|DOC_PATH|/test_docs/index.html?search=coo + +// This is needed so that the text color is computed. +show-text: true + +// Ayu theme +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)"}) + +// Dark theme +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)"}) + +// Light theme +local-storage: {"rustdoc-theme": "light", "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(0, 0, 0)"}) +assert-css: ("//*[@class='result-name']/*[text()='test_docs::']", {"color": "rgb(0, 0, 0)"}) From 168b4d490bd15c5eb0055cd748e7fbb4a5851456 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 12 Jul 2021 17:42:53 +0200 Subject: [PATCH 5/9] Fix color for keyword/primitive search result --- src/librustdoc/html/static/css/themes/ayu.css | 2 +- src/librustdoc/html/static/css/themes/dark.css | 2 +- src/librustdoc/html/static/css/themes/light.css | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librustdoc/html/static/css/themes/ayu.css b/src/librustdoc/html/static/css/themes/ayu.css index 1ef9ae3321f9f..9da3fe07adea0 100644 --- a/src/librustdoc/html/static/css/themes/ayu.css +++ b/src/librustdoc/html/static/css/themes/ayu.css @@ -286,7 +286,7 @@ details.undocumented > summary::before { color: grey; } -tr.result span.primitive::after, tr.result span.keyword::after { +.result-name .primitive > i, .result-name .keyword > i { color: #788797; } diff --git a/src/librustdoc/html/static/css/themes/dark.css b/src/librustdoc/html/static/css/themes/dark.css index d9ea28058ad99..599fb942dbe2a 100644 --- a/src/librustdoc/html/static/css/themes/dark.css +++ b/src/librustdoc/html/static/css/themes/dark.css @@ -247,7 +247,7 @@ details.undocumented > summary::before { color: grey; } -tr.result span.primitive::after, tr.result span.keyword::after { +.result-name .primitive > i, .result-name .keyword > i { color: #ddd; } diff --git a/src/librustdoc/html/static/css/themes/light.css b/src/librustdoc/html/static/css/themes/light.css index 6785b79ffda96..0c2799727f3e3 100644 --- a/src/librustdoc/html/static/css/themes/light.css +++ b/src/librustdoc/html/static/css/themes/light.css @@ -237,7 +237,7 @@ details.undocumented > summary::before { color: grey; } -tr.result span.primitive::after, tr.result span.keyword::after { +.result-name .primitive > i, .result-name .keyword > i { color: black; } From b8264a862f045de899d79e149d7ba4bd15adb6a3 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 12 Jul 2021 17:42:59 +0200 Subject: [PATCH 6/9] Add test for keyword/primitive text color --- src/test/rustdoc-gui/search-result-color.goml | 9 +++++++++ src/test/rustdoc-gui/src/test_docs/lib.rs | 1 + 2 files changed, 10 insertions(+) diff --git a/src/test/rustdoc-gui/search-result-color.goml b/src/test/rustdoc-gui/search-result-color.goml index c138cc8d9c61a..bb8ecb98fa387 100644 --- a/src/test/rustdoc-gui/search-result-color.goml +++ b/src/test/rustdoc-gui/search-result-color.goml @@ -13,6 +13,9 @@ 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)"}) +// Checking the color for "keyword". +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"} reload: @@ -22,6 +25,9 @@ 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)"}) +// Checking the color for "keyword". +assert-css: ("//*[@class='result-name']//*[text()='(keyword)']", {"color": "rgb(221, 221, 221)"}) + // Light theme local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} reload: @@ -30,3 +36,6 @@ reload: 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)"}) + +// Checking the color for "keyword". +assert-css: ("//*[@class='result-name']//*[text()='(keyword)']", {"color": "rgb(0, 0, 0)"}) diff --git a/src/test/rustdoc-gui/src/test_docs/lib.rs b/src/test/rustdoc-gui/src/test_docs/lib.rs index 3e753cb4de8b1..1b9f652120e94 100644 --- a/src/test/rustdoc-gui/src/test_docs/lib.rs +++ b/src/test/rustdoc-gui/src/test_docs/lib.rs @@ -101,6 +101,7 @@ pub enum AnEnum { } #[doc(keyword = "CookieMonster")] +/// Some keyword. pub mod keyword {} /// Just some type alias. From e457c2739b1c040953df3989a864bcd189255226 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Tue, 13 Jul 2021 17:58:50 +0900 Subject: [PATCH 7/9] Upgrade `cc` crate to 1.0.69 --- Cargo.lock | 4 ++-- compiler/rustc_codegen_ssa/Cargo.toml | 2 +- compiler/rustc_llvm/Cargo.toml | 2 +- library/profiler_builtins/Cargo.toml | 2 +- library/unwind/Cargo.toml | 2 +- src/bootstrap/Cargo.toml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b432f9ae2272a..6885ac65ca919 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -435,9 +435,9 @@ version = "0.1.0" [[package]] name = "cc" -version = "1.0.68" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787" +checksum = "e70cc2f62c6ce1868963827bd677764c62d07c3d9a3e1fb1177ee1a9ab199eb2" dependencies = [ "jobserver", ] diff --git a/compiler/rustc_codegen_ssa/Cargo.toml b/compiler/rustc_codegen_ssa/Cargo.toml index 9bd5764f0730d..6a6f93d50d364 100644 --- a/compiler/rustc_codegen_ssa/Cargo.toml +++ b/compiler/rustc_codegen_ssa/Cargo.toml @@ -9,7 +9,7 @@ test = false [dependencies] bitflags = "1.2.1" -cc = "1.0.68" +cc = "1.0.69" itertools = "0.9" tracing = "0.1" libc = "0.2.50" diff --git a/compiler/rustc_llvm/Cargo.toml b/compiler/rustc_llvm/Cargo.toml index 3fca2e1ccb97b..1bfa489d39eea 100644 --- a/compiler/rustc_llvm/Cargo.toml +++ b/compiler/rustc_llvm/Cargo.toml @@ -13,4 +13,4 @@ libc = "0.2.73" [build-dependencies] build_helper = { path = "../../src/build_helper" } -cc = "1.0.68" +cc = "1.0.69" diff --git a/library/profiler_builtins/Cargo.toml b/library/profiler_builtins/Cargo.toml index 7b7ca8029b49d..b7ab4f19f0ad9 100644 --- a/library/profiler_builtins/Cargo.toml +++ b/library/profiler_builtins/Cargo.toml @@ -14,4 +14,4 @@ core = { path = "../core" } compiler_builtins = { version = "0.1.0", features = ['rustc-dep-of-std'] } [build-dependencies] -cc = "1.0.68" +cc = "1.0.69" diff --git a/library/unwind/Cargo.toml b/library/unwind/Cargo.toml index c76ba7667d4e6..031d2942c51ad 100644 --- a/library/unwind/Cargo.toml +++ b/library/unwind/Cargo.toml @@ -21,7 +21,7 @@ compiler_builtins = "0.1.0" cfg-if = "0.1.8" [build-dependencies] -cc = "1.0.68" +cc = "1.0.69" [features] diff --git a/src/bootstrap/Cargo.toml b/src/bootstrap/Cargo.toml index 6fb7a1c088f33..64f022b4e8dae 100644 --- a/src/bootstrap/Cargo.toml +++ b/src/bootstrap/Cargo.toml @@ -40,7 +40,7 @@ cmake = "0.1.38" filetime = "0.2" num_cpus = "1.0" getopts = "0.2.19" -cc = "1.0.68" +cc = "1.0.69" libc = "0.2" serde = { version = "1.0.8", features = ["derive"] } serde_json = "1.0.2" From da56618ff9ea1295d108c58002b744223898cb2b Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Mon, 12 Jul 2021 15:12:49 +0200 Subject: [PATCH 8/9] Handle non-integer const generic parameters in debuginfo type names. --- .../src/debuginfo/type_names.rs | 81 ++++++++++++++----- src/test/debuginfo/function-names.rs | 28 ++++++- 2 files changed, 90 insertions(+), 19 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs index b3c14d9072cce..25268d9a5552f 100644 --- a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs +++ b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs @@ -12,12 +12,15 @@ // * `"` is treated as the start of a string. use rustc_data_structures::fx::FxHashSet; +use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_hir::definitions::{DefPathData, DefPathDataName, DisambiguatedDefPathData}; +use rustc_middle::ich::NodeIdHashingMode; +use rustc_middle::ty::layout::IntegerExt; use rustc_middle::ty::subst::{GenericArgKind, SubstsRef}; use rustc_middle::ty::{self, AdtDef, Ty, TyCtxt}; -use rustc_target::abi::{TagEncoding, Variants}; +use rustc_target::abi::{Integer, TagEncoding, Variants}; use std::fmt::Write; @@ -47,7 +50,7 @@ pub fn push_debuginfo_type_name<'tcx>( ) { // When targeting MSVC, emit C++ style type names for compatibility with // .natvis visualizers (and perhaps other existing native debuggers?) - let cpp_like_names = tcx.sess.target.is_like_msvc; + let cpp_like_names = cpp_like_names(tcx); match *t.kind() { ty::Bool => output.push_str("bool"), @@ -424,8 +427,6 @@ fn push_unqualified_item_name( disambiguated_data: DisambiguatedDefPathData, output: &mut String, ) { - let cpp_like_names = tcx.sess.target.is_like_msvc; - match disambiguated_data.data { DefPathData::CrateRoot => { output.push_str(&tcx.crate_name(def_id.krate).as_str()); @@ -433,7 +434,7 @@ fn push_unqualified_item_name( DefPathData::ClosureExpr if tcx.generator_kind(def_id).is_some() => { // Generators look like closures, but we want to treat them differently // in the debug info. - if cpp_like_names { + if cpp_like_names(tcx) { write!(output, "generator${}", disambiguated_data.disambiguator).unwrap(); } else { write!(output, "{{generator#{}}}", disambiguated_data.disambiguator).unwrap(); @@ -444,7 +445,7 @@ fn push_unqualified_item_name( output.push_str(&name.as_str()); } DefPathDataName::Anon { namespace } => { - if cpp_like_names { + if cpp_like_names(tcx) { write!(output, "{}${}", namespace, disambiguated_data.disambiguator).unwrap(); } else { write!(output, "{{{}#{}}}", namespace, disambiguated_data.disambiguator) @@ -478,19 +479,14 @@ fn push_generic_params_internal<'tcx>( match type_parameter { GenericArgKind::Type(type_parameter) => { push_debuginfo_type_name(tcx, type_parameter, true, output, visited); - output.push_str(", "); - } - GenericArgKind::Const(const_parameter) => match const_parameter.val { - ty::ConstKind::Param(param) => write!(output, "{}, ", param.name).unwrap(), - _ => write!( - output, - "0x{:x}, ", - const_parameter.eval_bits(tcx, ty::ParamEnv::reveal_all(), const_parameter.ty) - ) - .unwrap(), - }, + } + GenericArgKind::Const(ct) => { + push_const_param(tcx, ct, output); + } other => bug!("Unexpected non-erasable generic: {:?}", other), } + + output.push_str(", "); } output.pop(); @@ -499,6 +495,51 @@ fn push_generic_params_internal<'tcx>( push_close_angle_bracket(tcx, output); } +fn push_const_param<'tcx>(tcx: TyCtxt<'tcx>, ct: &'tcx ty::Const<'tcx>, output: &mut String) { + match ct.val { + ty::ConstKind::Param(param) => { + write!(output, "{}", param.name) + } + _ => match ct.ty.kind() { + ty::Int(ity) => { + let bits = ct.eval_bits(tcx, ty::ParamEnv::reveal_all(), ct.ty); + let val = Integer::from_int_ty(&tcx, *ity).size().sign_extend(bits) as i128; + write!(output, "{}", val) + } + ty::Uint(_) => { + let val = ct.eval_bits(tcx, ty::ParamEnv::reveal_all(), ct.ty); + write!(output, "{}", val) + } + ty::Bool => { + let val = ct.try_eval_bool(tcx, ty::ParamEnv::reveal_all()).unwrap(); + write!(output, "{}", val) + } + _ => { + // If we cannot evaluate the constant to a known type, we fall back + // to emitting a stable hash value of the constant. This isn't very pretty + // but we get a deterministic, virtually unique value for the constant. + let hcx = &mut tcx.create_stable_hashing_context(); + let mut hasher = StableHasher::new(); + hcx.while_hashing_spans(false, |hcx| { + hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| { + ct.val.hash_stable(hcx, &mut hasher); + }); + }); + // Let's only emit 64 bits of the hash value. That should be plenty for + // avoiding collisions and will make the emitted type names shorter. + let hash: u64 = hasher.finish(); + + if cpp_like_names(tcx) { + write!(output, "CONST${:x}", hash) + } else { + write!(output, "{{CONST#{:x}}}", hash) + } + } + }, + } + .unwrap(); +} + pub fn push_generic_params<'tcx>(tcx: TyCtxt<'tcx>, substs: SubstsRef<'tcx>, output: &mut String) { let mut visited = FxHashSet::default(); push_generic_params_internal(tcx, substs, output, &mut visited); @@ -507,9 +548,13 @@ pub fn push_generic_params<'tcx>(tcx: TyCtxt<'tcx>, substs: SubstsRef<'tcx>, out fn push_close_angle_bracket<'tcx>(tcx: TyCtxt<'tcx>, output: &mut String) { // MSVC debugger always treats `>>` as a shift, even when parsing templates, // so add a space to avoid confusion. - if tcx.sess.target.is_like_msvc && output.ends_with('>') { + if cpp_like_names(tcx) && output.ends_with('>') { output.push(' ') }; output.push('>'); } + +fn cpp_like_names(tcx: TyCtxt<'_>) -> bool { + tcx.sess.target.is_like_msvc +} diff --git a/src/test/debuginfo/function-names.rs b/src/test/debuginfo/function-names.rs index 26317f5c3ff32..54e270b24dc6a 100644 --- a/src/test/debuginfo/function-names.rs +++ b/src/test/debuginfo/function-names.rs @@ -33,6 +33,13 @@ // Generator // Generators don't seem to appear in GDB's symbol table. +// Const generic parameter +// gdb-command:info functions -q function_names::const_generic_fn.* +// gdb-check:[...]static fn function_names::const_generic_fn_bool(); +// gdb-check:[...]static fn function_names::const_generic_fn_non_int(); +// gdb-check:[...]static fn function_names::const_generic_fn_signed_int(); +// gdb-check:[...]static fn function_names::const_generic_fn_unsigned_int(); + // === CDB TESTS =================================================================================== // Top-level function @@ -65,10 +72,18 @@ // cdb-command:x a!function_names::*::generator* // cdb-check:[...] a!function_names::main::generator$1 (void) +// Const generic parameter +// cdb-command:x a!function_names::const_generic_fn* +// cdb-check:[...] a!function_names::const_generic_fn_bool (void) +// cdb-check:[...] a!function_names::const_generic_fn_non_int (void) +// cdb-check:[...] a!function_names::const_generic_fn_signed_int<-7> (void) +// cdb-check:[...] a!function_names::const_generic_fn_unsigned_int<14> (void) + #![allow(unused_variables)] #![feature(omit_gdb_pretty_printer_section)] #![omit_gdb_pretty_printer_section] -#![feature(generators, generator_trait)] +#![feature(const_generics, generators, generator_trait)] +#![allow(incomplete_features)] // for const_generics use Mod1::TestTrait2; use std::ops::Generator; @@ -97,6 +112,12 @@ fn main() { // Generator let mut generator = || { yield; return; }; Pin::new(&mut generator).resume(()); + + // Const generic functions + const_generic_fn_bool::(); + const_generic_fn_non_int::<{()}>(); + const_generic_fn_signed_int::<-7>(); + const_generic_fn_unsigned_int::<14>(); } struct TestStruct1; @@ -173,3 +194,8 @@ fn generic_func(value: T) -> T { value } + +fn const_generic_fn_bool() {} +fn const_generic_fn_non_int() {} +fn const_generic_fn_signed_int() {} +fn const_generic_fn_unsigned_int() {} From cac0d71b6aad63955789ad37ce87c4dc9d5b34f9 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 13 Jul 2021 14:41:19 +0200 Subject: [PATCH 9/9] Add test for "go to first" feature --- .../search-result-go-to-first.goml | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/test/rustdoc-gui/search-result-go-to-first.goml diff --git a/src/test/rustdoc-gui/search-result-go-to-first.goml b/src/test/rustdoc-gui/search-result-go-to-first.goml new file mode 100644 index 0000000000000..5d709f6588118 --- /dev/null +++ b/src/test/rustdoc-gui/search-result-go-to-first.goml @@ -0,0 +1,20 @@ +// This test ensures that the "go_to_first" feature is working as expected. + +// First, we check that the first page doesn't have the string we're looking for to ensure +// that the feature is changing page as expected. +goto: file://|DOC_PATH|/test_docs/index.html +assert-text-false: (".fqn .in-band", "Struct test_docs::Foo") + +// We now check that we land on the search result page if "go_to_first" isn't set. +goto: file://|DOC_PATH|/test_docs/index.html?search=struct%3AFoo +// Waiting for the search results to appear... +wait-for: "#titles" +assert-text-false: (".fqn .in-band", "Struct test_docs::Foo") +// Ensure that the search results are displayed, not the "normal" content. +assert-css: ("#main", {"display": "none"}) + +// Now we can check that the feature is working as expected! +goto: file://|DOC_PATH|/test_docs/index.html?search=struct%3AFoo&go_to_first=true +// Waiting for the page to load... +wait-for: 500 +assert-text: (".fqn .in-band", "Struct test_docs::Foo")