From 0a1cd5baa4d0ad4994f4038988a76770a6e2150c Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 2 Jun 2023 11:07:38 +1000 Subject: [PATCH 01/13] Remove some unnecessary `&mut`s. --- compiler/rustc_monomorphize/src/partitioning.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_monomorphize/src/partitioning.rs b/compiler/rustc_monomorphize/src/partitioning.rs index 79fcd62bc6206..e99551410e022 100644 --- a/compiler/rustc_monomorphize/src/partitioning.rs +++ b/compiler/rustc_monomorphize/src/partitioning.rs @@ -136,7 +136,7 @@ struct PlacedRootMonoItems<'tcx> { // The output CGUs are sorted by name. fn partition<'tcx, I>( tcx: TyCtxt<'tcx>, - mono_items: &mut I, + mono_items: I, max_cgu_count: usize, usage_map: &UsageMap<'tcx>, ) -> Vec> @@ -239,7 +239,7 @@ where fn place_root_mono_items<'tcx, I>( cx: &PartitioningCx<'_, 'tcx>, - mono_items: &mut I, + mono_items: I, ) -> PlacedRootMonoItems<'tcx> where I: Iterator>, @@ -951,12 +951,8 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> (&DefIdSet, &[Co let (codegen_units, _) = tcx.sess.time("partition_and_assert_distinct_symbols", || { sync::join( || { - let mut codegen_units = partition( - tcx, - &mut items.iter().copied(), - tcx.sess.codegen_units(), - &usage_map, - ); + let mut codegen_units = + partition(tcx, items.iter().copied(), tcx.sess.codegen_units(), &usage_map); codegen_units[0].make_primary(); &*tcx.arena.alloc_from_iter(codegen_units) }, From 9fd6d979152db51271b12ad66ab7e8352e2bbd4f Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 2 Jun 2023 14:12:05 +1000 Subject: [PATCH 02/13] Improve sorting in `debug_dump`. Currently it sorts by symbol name, which is a mangled name like `_ZN1a4main17hb29587cdb6db5f42E`, which leads to non-obvious orderings. This commit changes it to use the existing `items_in_deterministic_order`, which iterates in source code order. --- compiler/rustc_monomorphize/src/partitioning.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/compiler/rustc_monomorphize/src/partitioning.rs b/compiler/rustc_monomorphize/src/partitioning.rs index e99551410e022..2909042a931d1 100644 --- a/compiler/rustc_monomorphize/src/partitioning.rs +++ b/compiler/rustc_monomorphize/src/partitioning.rs @@ -864,15 +864,10 @@ fn debug_dump<'a, 'tcx: 'a>(tcx: TyCtxt<'tcx>, label: &str, cgus: &[CodegenUnit< cgu.size_estimate() ); - // The order of `cgu.items()` is non-deterministic; sort it by name - // to give deterministic output. - let mut items: Vec<_> = cgu.items().iter().collect(); - items.sort_by_key(|(item, _)| item.symbol_name(tcx).name); - for (item, linkage) in items { + for (item, linkage) in cgu.items_in_deterministic_order(tcx) { let symbol_name = item.symbol_name(tcx).name; let symbol_hash_start = symbol_name.rfind('h'); let symbol_hash = symbol_hash_start.map_or("", |i| &symbol_name[i..]); - let size = item.size_estimate(tcx); let _ = with_no_trimmed_paths!(writeln!( s, From 392045b7e70cc68290851451994d4ea135ec3f0a Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 5 Jun 2023 12:01:53 +1000 Subject: [PATCH 03/13] Make the two loops in `internalize_symbols` have the same form. Because the next commit will merge them. --- compiler/rustc_monomorphize/src/partitioning.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_monomorphize/src/partitioning.rs b/compiler/rustc_monomorphize/src/partitioning.rs index 2909042a931d1..fb8c21c59f22b 100644 --- a/compiler/rustc_monomorphize/src/partitioning.rs +++ b/compiler/rustc_monomorphize/src/partitioning.rs @@ -491,11 +491,14 @@ fn internalize_symbols<'tcx>( // can internalize all candidates, since there is nowhere else they // could be used from. for cgu in codegen_units { - for candidate in &internalization_candidates { - cgu.items_mut().insert(*candidate, (Linkage::Internal, Visibility::Default)); + for (item, linkage_and_visibility) in cgu.items_mut() { + if !internalization_candidates.contains(item) { + // This item is no candidate for internalizing, so skip it. + continue; + } + *linkage_and_visibility = (Linkage::Internal, Visibility::Default); } } - return; } From fe3b6465654d8d73f9ddd45faf02971614f5780b Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 5 Jun 2023 16:05:48 +1000 Subject: [PATCH 04/13] Merge the two loops in `internalize_symbols`. Because they have a lot of overlap. --- .../rustc_monomorphize/src/partitioning.rs | 49 +++++++------------ 1 file changed, 19 insertions(+), 30 deletions(-) diff --git a/compiler/rustc_monomorphize/src/partitioning.rs b/compiler/rustc_monomorphize/src/partitioning.rs index fb8c21c59f22b..c88df1b0b60f3 100644 --- a/compiler/rustc_monomorphize/src/partitioning.rs +++ b/compiler/rustc_monomorphize/src/partitioning.rs @@ -486,21 +486,7 @@ fn internalize_symbols<'tcx>( mono_item_placements: FxHashMap, MonoItemPlacement>, internalization_candidates: FxHashSet>, ) { - if codegen_units.len() == 1 { - // Fast path for when there is only one codegen unit. In this case we - // can internalize all candidates, since there is nowhere else they - // could be used from. - for cgu in codegen_units { - for (item, linkage_and_visibility) in cgu.items_mut() { - if !internalization_candidates.contains(item) { - // This item is no candidate for internalizing, so skip it. - continue; - } - *linkage_and_visibility = (Linkage::Internal, Visibility::Default); - } - } - return; - } + let single_codegen_unit = codegen_units.len() == 1; // For each internalization candidates in each codegen unit, check if it is // used from outside its defining codegen unit. @@ -512,21 +498,24 @@ fn internalize_symbols<'tcx>( // This item is no candidate for internalizing, so skip it. continue; } - debug_assert_eq!(mono_item_placements[item], home_cgu); - - if let Some(user_items) = cx.usage_map.get_user_items(*item) { - if user_items - .iter() - .filter_map(|user_item| { - // Some user mono items might not have been - // instantiated. We can safely ignore those. - mono_item_placements.get(user_item) - }) - .any(|placement| *placement != home_cgu) - { - // Found a user from another CGU, so skip to the next item - // without marking this one as internal. - continue; + + if !single_codegen_unit { + debug_assert_eq!(mono_item_placements[item], home_cgu); + + if let Some(user_items) = cx.usage_map.get_user_items(*item) { + if user_items + .iter() + .filter_map(|user_item| { + // Some user mono items might not have been + // instantiated. We can safely ignore those. + mono_item_placements.get(user_item) + }) + .any(|placement| *placement != home_cgu) + { + // Found a user from another CGU, so skip to the next item + // without marking this one as internal. + continue; + } } } From 8dbb3475b93a15cbd64e9b726a775ee2b31328a6 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 7 Jun 2023 09:24:37 +1000 Subject: [PATCH 05/13] Split loop in `place_inlined_mono_item`. This loop is doing two different things. For inlined items, it's adding them to the CGU. For all items, it's recording them in `mono_item_placements`. This commit splits it into two separate loops. This avoids putting root mono items into `reachable`, and removes the low-value check that `roots` doesn't contain inlined mono items. --- .../rustc_monomorphize/src/partitioning.rs | 38 +++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/compiler/rustc_monomorphize/src/partitioning.rs b/compiler/rustc_monomorphize/src/partitioning.rs index c88df1b0b60f3..737c0b035e7ab 100644 --- a/compiler/rustc_monomorphize/src/partitioning.rs +++ b/compiler/rustc_monomorphize/src/partitioning.rs @@ -416,37 +416,35 @@ enum MonoItemPlacement { fn place_inlined_mono_items<'tcx>( cx: &PartitioningCx<'_, 'tcx>, codegen_units: &mut [CodegenUnit<'tcx>], - roots: FxHashSet>, + _roots: FxHashSet>, ) -> FxHashMap, MonoItemPlacement> { - let mut mono_item_placements = FxHashMap::default(); - - let single_codegen_unit = codegen_units.len() == 1; - for cgu in codegen_units.iter_mut() { - // Collect all items that need to be available in this codegen unit. - let mut reachable = FxHashSet::default(); + // Collect all inlined items that need to be available in this codegen unit. + let mut reachable_inlined_items = FxHashSet::default(); for root in cgu.items().keys() { - // Insert the root item itself, plus all inlined items that are - // reachable from it without going via another root item. - reachable.insert(*root); - get_reachable_inlined_items(cx.tcx, *root, cx.usage_map, &mut reachable); + // Get all inlined items that are reachable from it without going + // via another root item. + get_reachable_inlined_items(cx.tcx, *root, cx.usage_map, &mut reachable_inlined_items); } // Add all monomorphizations that are not already there. - for mono_item in reachable { - if !cgu.items().contains_key(&mono_item) { - if roots.contains(&mono_item) { - bug!("GloballyShared mono-item inlined into other CGU: {:?}", mono_item); - } + for inlined_item in reachable_inlined_items { + assert!(!cgu.items().contains_key(&inlined_item)); - // This is a CGU-private copy. - cgu.items_mut().insert(mono_item, (Linkage::Internal, Visibility::Default)); - } + // This is a CGU-private copy. + cgu.items_mut().insert(inlined_item, (Linkage::Internal, Visibility::Default)); + } + } + + let mut mono_item_placements = FxHashMap::default(); + let single_codegen_unit = codegen_units.len() == 1; + for cgu in codegen_units.iter_mut() { + for item in cgu.items().keys() { if !single_codegen_unit { // If there is more than one codegen unit, we need to keep track // in which codegen units each monomorphization is placed. - match mono_item_placements.entry(mono_item) { + match mono_item_placements.entry(*item) { Entry::Occupied(e) => { let placement = e.into_mut(); debug_assert!(match *placement { From 1defd3076473699332e1b4c424d35f0dfb28c63b Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 7 Jun 2023 09:24:51 +1000 Subject: [PATCH 06/13] Remove `PlacedRootMonoItems::roots`. It's no longer used. --- compiler/rustc_monomorphize/src/partitioning.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_monomorphize/src/partitioning.rs b/compiler/rustc_monomorphize/src/partitioning.rs index 737c0b035e7ab..e3a226fd427fa 100644 --- a/compiler/rustc_monomorphize/src/partitioning.rs +++ b/compiler/rustc_monomorphize/src/partitioning.rs @@ -129,7 +129,6 @@ struct PlacedRootMonoItems<'tcx> { /// The codegen units, sorted by name to make things deterministic. codegen_units: Vec>, - roots: FxHashSet>, internalization_candidates: FxHashSet>, } @@ -150,7 +149,7 @@ where // In the first step, we place all regular monomorphizations into their // respective 'home' codegen unit. Regular monomorphizations are all // functions and statics defined in the local crate. - let PlacedRootMonoItems { mut codegen_units, roots, internalization_candidates } = { + let PlacedRootMonoItems { mut codegen_units, internalization_candidates } = { let _prof_timer = tcx.prof.generic_activity("cgu_partitioning_place_roots"); place_root_mono_items(cx, mono_items) }; @@ -176,7 +175,7 @@ where // local functions the definition of which is marked with `#[inline]`. let mono_item_placements = { let _prof_timer = tcx.prof.generic_activity("cgu_partitioning_place_inline_items"); - place_inlined_mono_items(cx, &mut codegen_units, roots) + place_inlined_mono_items(cx, &mut codegen_units) }; for cgu in &mut codegen_units { @@ -244,7 +243,6 @@ fn place_root_mono_items<'tcx, I>( where I: Iterator>, { - let mut roots = FxHashSet::default(); let mut codegen_units = FxHashMap::default(); let is_incremental_build = cx.tcx.sess.opts.incremental.is_some(); let mut internalization_candidates = FxHashSet::default(); @@ -295,7 +293,6 @@ where } codegen_unit.items_mut().insert(mono_item, (linkage, visibility)); - roots.insert(mono_item); } // Always ensure we have at least one CGU; otherwise, if we have a @@ -308,7 +305,7 @@ where let mut codegen_units: Vec<_> = codegen_units.into_values().collect(); codegen_units.sort_by(|a, b| a.name().as_str().cmp(b.name().as_str())); - PlacedRootMonoItems { codegen_units, roots, internalization_candidates } + PlacedRootMonoItems { codegen_units, internalization_candidates } } // This function requires the CGUs to be sorted by name on input, and ensures @@ -416,7 +413,6 @@ enum MonoItemPlacement { fn place_inlined_mono_items<'tcx>( cx: &PartitioningCx<'_, 'tcx>, codegen_units: &mut [CodegenUnit<'tcx>], - _roots: FxHashSet>, ) -> FxHashMap, MonoItemPlacement> { for cgu in codegen_units.iter_mut() { // Collect all inlined items that need to be available in this codegen unit. From 853345635be1c51f180174d0ed66bb85aacc2570 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 7 Jun 2023 10:59:00 +1000 Subject: [PATCH 07/13] Move `mono_item_placement` construction. It's currently created in `place_inlined_mono_items` and then used in `internalize_symbols`. This commit moves the creation to `internalize_symbols`. --- .../rustc_monomorphize/src/partitioning.rs | 80 ++++++++----------- 1 file changed, 35 insertions(+), 45 deletions(-) diff --git a/compiler/rustc_monomorphize/src/partitioning.rs b/compiler/rustc_monomorphize/src/partitioning.rs index e3a226fd427fa..1d9c8ded349c0 100644 --- a/compiler/rustc_monomorphize/src/partitioning.rs +++ b/compiler/rustc_monomorphize/src/partitioning.rs @@ -173,7 +173,7 @@ where // monomorphizations have to go into each codegen unit. These additional // monomorphizations can be drop-glue, functions from external crates, and // local functions the definition of which is marked with `#[inline]`. - let mono_item_placements = { + { let _prof_timer = tcx.prof.generic_activity("cgu_partitioning_place_inline_items"); place_inlined_mono_items(cx, &mut codegen_units) }; @@ -188,12 +188,7 @@ where // more freedom to optimize. if !tcx.sess.link_dead_code() { let _prof_timer = tcx.prof.generic_activity("cgu_partitioning_internalize_symbols"); - internalize_symbols( - cx, - &mut codegen_units, - mono_item_placements, - internalization_candidates, - ); + internalize_symbols(cx, &mut codegen_units, internalization_candidates); } let instrument_dead_code = @@ -401,19 +396,10 @@ fn merge_codegen_units<'tcx>( codegen_units.sort_by(|a, b| a.name().as_str().cmp(b.name().as_str())); } -/// For symbol internalization, we need to know whether a symbol/mono-item is -/// used from outside the codegen unit it is defined in. This type is used -/// to keep track of that. -#[derive(Clone, PartialEq, Eq, Debug)] -enum MonoItemPlacement { - SingleCgu { cgu_name: Symbol }, - MultipleCgus, -} - fn place_inlined_mono_items<'tcx>( cx: &PartitioningCx<'_, 'tcx>, codegen_units: &mut [CodegenUnit<'tcx>], -) -> FxHashMap, MonoItemPlacement> { +) { for cgu in codegen_units.iter_mut() { // Collect all inlined items that need to be available in this codegen unit. let mut reachable_inlined_items = FxHashSet::default(); @@ -432,33 +418,6 @@ fn place_inlined_mono_items<'tcx>( } } - let mut mono_item_placements = FxHashMap::default(); - let single_codegen_unit = codegen_units.len() == 1; - - for cgu in codegen_units.iter_mut() { - for item in cgu.items().keys() { - if !single_codegen_unit { - // If there is more than one codegen unit, we need to keep track - // in which codegen units each monomorphization is placed. - match mono_item_placements.entry(*item) { - Entry::Occupied(e) => { - let placement = e.into_mut(); - debug_assert!(match *placement { - MonoItemPlacement::SingleCgu { cgu_name } => cgu_name != cgu.name(), - MonoItemPlacement::MultipleCgus => true, - }); - *placement = MonoItemPlacement::MultipleCgus; - } - Entry::Vacant(e) => { - e.insert(MonoItemPlacement::SingleCgu { cgu_name: cgu.name() }); - } - } - } - } - } - - return mono_item_placements; - fn get_reachable_inlined_items<'tcx>( tcx: TyCtxt<'tcx>, item: MonoItem<'tcx>, @@ -477,11 +436,42 @@ fn place_inlined_mono_items<'tcx>( fn internalize_symbols<'tcx>( cx: &PartitioningCx<'_, 'tcx>, codegen_units: &mut [CodegenUnit<'tcx>], - mono_item_placements: FxHashMap, MonoItemPlacement>, internalization_candidates: FxHashSet>, ) { + /// For symbol internalization, we need to know whether a symbol/mono-item + /// is used from outside the codegen unit it is defined in. This type is + /// used to keep track of that. + #[derive(Clone, PartialEq, Eq, Debug)] + enum MonoItemPlacement { + SingleCgu { cgu_name: Symbol }, + MultipleCgus, + } + + let mut mono_item_placements = FxHashMap::default(); let single_codegen_unit = codegen_units.len() == 1; + if !single_codegen_unit { + for cgu in codegen_units.iter_mut() { + for item in cgu.items().keys() { + // If there is more than one codegen unit, we need to keep track + // in which codegen units each monomorphization is placed. + match mono_item_placements.entry(*item) { + Entry::Occupied(e) => { + let placement = e.into_mut(); + debug_assert!(match *placement { + MonoItemPlacement::SingleCgu { cgu_name } => cgu_name != cgu.name(), + MonoItemPlacement::MultipleCgus => true, + }); + *placement = MonoItemPlacement::MultipleCgus; + } + Entry::Vacant(e) => { + e.insert(MonoItemPlacement::SingleCgu { cgu_name: cgu.name() }); + } + } + } + } + } + // For each internalization candidates in each codegen unit, check if it is // used from outside its defining codegen unit. for cgu in codegen_units { From 7f79ceb438321810a8199fb099067cd648c638da Mon Sep 17 00:00:00 2001 From: Matthew Esposito Date: Fri, 9 Jun 2023 10:47:41 -0400 Subject: [PATCH 08/13] Compile rustc_driver by default --- src/bootstrap/doc.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index d6210ed59c4d1..fef7e4db9ab85 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -667,7 +667,7 @@ impl Step for Rustc { /// Compiler documentation is distributed separately, so we make sure /// we do not merge it with the other documentation from std, test and /// proc_macros. This is largely just a wrapper around `cargo doc`. - fn run(self, builder: &Builder<'_>) { + fn run(mut self, builder: &Builder<'_>) { let stage = self.stage; let target = self.target; @@ -725,6 +725,11 @@ impl Step for Rustc { cargo.rustdocflag("ena=https://docs.rs/ena/latest/"); let mut to_open = None; + + if self.crates.is_empty() { + self.crates = INTERNER.intern_list(vec!["rustc_driver".to_owned()]); + }; + for krate in &*self.crates { // Create all crate output directories first to make sure rustdoc uses // relative links. From 6b0c7c4f01d3e6c90d10847471c7a2256346dd3e Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 9 Jun 2023 16:49:19 +0200 Subject: [PATCH 09/13] Change format of rustdoc-js tests by putting `query` and `correction` directly alongside the expected values --- src/tools/rustdoc-js/tester.js | 90 ++++++++++++++++++---------------- 1 file changed, 49 insertions(+), 41 deletions(-) diff --git a/src/tools/rustdoc-js/tester.js b/src/tools/rustdoc-js/tester.js index 270704ebffde6..416517d15f5db 100644 --- a/src/tools/rustdoc-js/tester.js +++ b/src/tools/rustdoc-js/tester.js @@ -22,6 +22,10 @@ function contentToDiffLine(key, value) { return `"${key}": "${value}",`; } +function shouldIgnoreField(fieldName) { + return fieldName === "query" || fieldName === "correction"; +} + // This function is only called when no matching result was found and therefore will only display // the diff between the two items. function betterLookingDiff(entry, data) { @@ -135,6 +139,9 @@ function valueCheck(fullPath, expected, result, error_text, queryName) { } else if (expected !== null && typeof expected !== "undefined" && expected.constructor == Object) { // eslint-disable-line eqeqeq for (const key in expected) { + if (shouldIgnoreField(key)) { + continue; + } if (!Object.prototype.hasOwnProperty.call(expected, key)) { continue; } @@ -184,6 +191,9 @@ function runSearch(query, expected, doSearch, loadedFile, queryName) { const error_text = []; for (const key in expected) { + if (shouldIgnoreField(key)) { + continue; + } if (!Object.prototype.hasOwnProperty.call(expected, key)) { continue; } @@ -260,41 +270,49 @@ function checkResult(error_text, loadedFile, displaySuccess) { return 1; } -function runCheck(loadedFile, key, callback) { - const expected = loadedFile[key]; - const query = loadedFile.QUERY; - - if (Array.isArray(query)) { - if (!Array.isArray(expected)) { - console.log("FAILED"); - console.log(`==> If QUERY variable is an array, ${key} should be an array too`); - return 1; - } else if (query.length !== expected.length) { - console.log("FAILED"); - console.log(`==> QUERY variable should have the same length as ${key}`); - return 1; +function runCheckInner(callback, loadedFile, entry, getCorrections, extra) { + if (typeof entry.query !== "string") { + console.log("FAILED"); + console.log("==> Missing `query` field"); + return false; + } + let error_text = callback(entry.query, entry, extra ? "[ query `" + entry.query + "`]" : ""); + if (checkResult(error_text, loadedFile, false) !== 0) { + return false; + } + if (entry.correction !== undefined) { + error_text = runCorrections(entry.query, entry.correction, getCorrections, loadedFile); + if (checkResult(error_text, loadedFile, false) !== 0) { + return false; } - for (let i = 0; i < query.length; ++i) { - const error_text = callback(query[i], expected[i], "[ query `" + query[i] + "`]"); - if (checkResult(error_text, loadedFile, false) !== 0) { + } + return true; +} + +function runCheck(loadedFile, key, getCorrections, callback) { + const expected = loadedFile[key]; + + if (Array.isArray(expected)) { + for (const entry of expected) { + if (!runCheckInner(callback, loadedFile, entry, getCorrections, true)) { return 1; } } - console.log("OK"); - } else { - const error_text = callback(query, expected, ""); - if (checkResult(error_text, loadedFile, true) !== 0) { - return 1; - } + } else if (!runCheckInner(callback, loadedFile, expected, getCorrections, false)) { + return 1; } + console.log("OK"); return 0; } +function hasCheck(content, checkName) { + return content.startsWith(`const ${checkName}`) || content.includes(`\nconst ${checkName}`); +} + function runChecks(testFile, doSearch, parseQuery, getCorrections) { let checkExpected = false; let checkParsed = false; - let checkCorrections = false; - let testFileContent = readFile(testFile) + "exports.QUERY = QUERY;"; + let testFileContent = readFile(testFile); if (testFileContent.indexOf("FILTER_CRATE") !== -1) { testFileContent += "exports.FILTER_CRATE = FILTER_CRATE;"; @@ -302,21 +320,17 @@ function runChecks(testFile, doSearch, parseQuery, getCorrections) { testFileContent += "exports.FILTER_CRATE = null;"; } - if (testFileContent.indexOf("\nconst EXPECTED") !== -1) { + if (hasCheck(testFileContent, "EXPECTED")) { testFileContent += "exports.EXPECTED = EXPECTED;"; checkExpected = true; } - if (testFileContent.indexOf("\nconst PARSED") !== -1) { + if (hasCheck(testFileContent, "PARSED")) { testFileContent += "exports.PARSED = PARSED;"; checkParsed = true; } - if (testFileContent.indexOf("\nconst CORRECTIONS") !== -1) { - testFileContent += "exports.CORRECTIONS = CORRECTIONS;"; - checkCorrections = true; - } - if (!checkParsed && !checkExpected && !checkCorrections) { + if (!checkParsed && !checkExpected) { console.log("FAILED"); - console.log("==> At least `PARSED`, `EXPECTED`, or `CORRECTIONS` is needed!"); + console.log("==> At least `PARSED` or `EXPECTED` is needed!"); return 1; } @@ -324,20 +338,15 @@ function runChecks(testFile, doSearch, parseQuery, getCorrections) { let res = 0; if (checkExpected) { - res += runCheck(loadedFile, "EXPECTED", (query, expected, text) => { + res += runCheck(loadedFile, "EXPECTED", getCorrections, (query, expected, text) => { return runSearch(query, expected, doSearch, loadedFile, text); }); } if (checkParsed) { - res += runCheck(loadedFile, "PARSED", (query, expected, text) => { + res += runCheck(loadedFile, "PARSED", getCorrections, (query, expected, text) => { return runParser(query, expected, parseQuery, text); }); } - if (checkCorrections) { - res += runCheck(loadedFile, "CORRECTIONS", (query, expected) => { - return runCorrections(query, expected, getCorrections, loadedFile); - }); - } return res; } @@ -367,8 +376,7 @@ function loadSearchJS(doc_folder, resource_suffix) { }, getCorrections: function(queryStr, filterCrate, currentCrate) { const parsedQuery = searchModule.parseQuery(queryStr); - searchModule.execQuery(parsedQuery, searchWords, - filterCrate, currentCrate); + searchModule.execQuery(parsedQuery, searchWords, filterCrate, currentCrate); return parsedQuery.correction; }, parseQuery: searchModule.parseQuery, From 9803651ee84545f8913b6fe9e76c8bd13603bb6e Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 9 Jun 2023 16:49:38 +0200 Subject: [PATCH 10/13] Update rustdoc-js* format --- tests/rustdoc-js-std/alias-1.js | 3 +- tests/rustdoc-js-std/alias-2.js | 3 +- tests/rustdoc-js-std/alias-3.js | 3 +- tests/rustdoc-js-std/alias-4.js | 3 +- tests/rustdoc-js-std/alias.js | 3 +- tests/rustdoc-js-std/asrawfd.js | 3 +- tests/rustdoc-js-std/basic.js | 3 +- tests/rustdoc-js-std/deduplication.js | 3 +- tests/rustdoc-js-std/enum-option.js | 3 +- tests/rustdoc-js-std/filter-crate.js | 2 +- tests/rustdoc-js-std/fn-forget.js | 3 +- tests/rustdoc-js-std/from_u.js | 3 +- tests/rustdoc-js-std/keyword.js | 3 +- tests/rustdoc-js-std/macro-check.js | 3 +- tests/rustdoc-js-std/macro-print.js | 3 +- tests/rustdoc-js-std/never.js | 3 +- .../rustdoc-js-std/option-type-signatures.js | 7 +- tests/rustdoc-js-std/parser-errors.js | 87 +++++++++---------- tests/rustdoc-js-std/parser-filter.js | 21 ++--- tests/rustdoc-js-std/parser-generics.js | 15 ++-- tests/rustdoc-js-std/parser-ident.js | 15 ++-- tests/rustdoc-js-std/parser-literal.js | 3 +- tests/rustdoc-js-std/parser-paths.js | 6 +- tests/rustdoc-js-std/parser-quote.js | 17 ++-- tests/rustdoc-js-std/parser-returned.js | 13 ++- tests/rustdoc-js-std/parser-separators.js | 17 ++-- tests/rustdoc-js-std/parser-weird-queries.js | 16 ++-- tests/rustdoc-js-std/path-ordering.js | 5 +- tests/rustdoc-js-std/primitive.js | 17 ++-- tests/rustdoc-js-std/println-typo.js | 2 +- tests/rustdoc-js-std/quoted.js | 2 +- tests/rustdoc-js-std/reference-shrink.js | 3 +- tests/rustdoc-js-std/regex.js | 3 +- .../rustdoc-js-std/return-specific-literal.js | 3 +- tests/rustdoc-js-std/return-specific.js | 3 +- tests/rustdoc-js-std/should-fail.js | 3 +- tests/rustdoc-js-std/string-from_ut.js | 3 +- tests/rustdoc-js-std/struct-vec.js | 3 +- tests/rustdoc-js-std/typed-query.js | 2 +- tests/rustdoc-js-std/vec-new.js | 3 +- tests/rustdoc-js/basic.js | 3 +- tests/rustdoc-js/doc-alias-filter-out.js | 3 +- tests/rustdoc-js/doc-alias-filter.js | 3 +- tests/rustdoc-js/doc-alias-whitespace.js | 5 +- tests/rustdoc-js/doc-alias.js | 69 +++++---------- tests/rustdoc-js/exact-match.js | 3 +- tests/rustdoc-js/foreign-type-path.js | 3 +- tests/rustdoc-js/generics-impl.js | 30 ++----- tests/rustdoc-js/generics-multi-trait.js | 9 +- tests/rustdoc-js/generics-nested.js | 15 +--- tests/rustdoc-js/generics-trait.js | 26 ++---- tests/rustdoc-js/generics.js | 30 ++----- tests/rustdoc-js/impl-trait.js | 18 ++-- tests/rustdoc-js/macro-search.js | 3 +- tests/rustdoc-js/module-substring.js | 3 +- tests/rustdoc-js/path-ordering.js | 3 +- tests/rustdoc-js/primitive.js | 13 ++- tests/rustdoc-js/prototype.js | 4 +- tests/rustdoc-js/raw-pointer.js | 18 ++-- tests/rustdoc-js/reexport.js | 4 +- tests/rustdoc-js/search-bag-semantics.js | 7 +- tests/rustdoc-js/search-short-types.js | 3 +- tests/rustdoc-js/slice-array.js | 27 ++---- tests/rustdoc-js/struct-like-variant.js | 3 +- tests/rustdoc-js/substring.js | 3 +- tests/rustdoc-js/summaries.js | 5 +- tests/rustdoc-js/where-clause.js | 7 +- 67 files changed, 236 insertions(+), 400 deletions(-) diff --git a/tests/rustdoc-js-std/alias-1.js b/tests/rustdoc-js-std/alias-1.js index 7c6327fcdd7ca..b27b3da217966 100644 --- a/tests/rustdoc-js-std/alias-1.js +++ b/tests/rustdoc-js-std/alias-1.js @@ -1,6 +1,5 @@ -const QUERY = '&'; - const EXPECTED = { + 'query': '&', 'others': [ { 'path': 'std', 'name': 'reference' }, ], diff --git a/tests/rustdoc-js-std/alias-2.js b/tests/rustdoc-js-std/alias-2.js index 798fa29efbd2d..5735b573bcbda 100644 --- a/tests/rustdoc-js-std/alias-2.js +++ b/tests/rustdoc-js-std/alias-2.js @@ -1,6 +1,5 @@ -const QUERY = '+'; - const EXPECTED = { + 'query': '+', 'others': [ { 'path': 'std::ops', 'name': 'AddAssign' }, { 'path': 'std::ops', 'name': 'Add' }, diff --git a/tests/rustdoc-js-std/alias-3.js b/tests/rustdoc-js-std/alias-3.js index 392b1e8183786..ed3776b3c2ae0 100644 --- a/tests/rustdoc-js-std/alias-3.js +++ b/tests/rustdoc-js-std/alias-3.js @@ -1,6 +1,5 @@ -const QUERY = '!'; - const EXPECTED = { + 'query': '!', 'others': [ { 'path': 'std', 'name': 'never' }, ], diff --git a/tests/rustdoc-js-std/alias-4.js b/tests/rustdoc-js-std/alias-4.js index bf2bb4d2981fc..35840a472c10b 100644 --- a/tests/rustdoc-js-std/alias-4.js +++ b/tests/rustdoc-js-std/alias-4.js @@ -1,6 +1,5 @@ -const QUERY = '<'; - const EXPECTED = { + 'query': '<', 'others': [ { 'name': 'Ord' }, ], diff --git a/tests/rustdoc-js-std/alias.js b/tests/rustdoc-js-std/alias.js index 2b709c99119ae..bf707fa03dc2a 100644 --- a/tests/rustdoc-js-std/alias.js +++ b/tests/rustdoc-js-std/alias.js @@ -1,8 +1,7 @@ // ignore-order -const QUERY = '['; - const EXPECTED = { + 'query': '[', 'others': [ { 'path': 'std', 'name': 'slice' }, { 'path': 'std::ops', 'name': 'IndexMut' }, diff --git a/tests/rustdoc-js-std/asrawfd.js b/tests/rustdoc-js-std/asrawfd.js index 369a34f9c6eb7..5b3cfeabbcdd2 100644 --- a/tests/rustdoc-js-std/asrawfd.js +++ b/tests/rustdoc-js-std/asrawfd.js @@ -1,8 +1,7 @@ // ignore-order -const QUERY = 'RawFd::as_raw_fd'; - const EXPECTED = { + 'query': 'RawFd::as_raw_fd', 'others': [ // Reproduction test for https://github.com/rust-lang/rust/issues/78724 // Validate that type alias methods get the correct path. diff --git a/tests/rustdoc-js-std/basic.js b/tests/rustdoc-js-std/basic.js index 824cac7108332..baff24b0af699 100644 --- a/tests/rustdoc-js-std/basic.js +++ b/tests/rustdoc-js-std/basic.js @@ -1,6 +1,5 @@ -const QUERY = 'String'; - const EXPECTED = { + 'query': 'String', 'others': [ { 'path': 'std::string', 'name': 'String' }, { 'path': 'std::ffi', 'name': 'CString' }, diff --git a/tests/rustdoc-js-std/deduplication.js b/tests/rustdoc-js-std/deduplication.js index f02f6cf55ed21..51279dd5ed467 100644 --- a/tests/rustdoc-js-std/deduplication.js +++ b/tests/rustdoc-js-std/deduplication.js @@ -1,8 +1,7 @@ // ignore-order -const QUERY = 'is_nan'; - const EXPECTED = { + 'query': 'is_nan', 'others': [ { 'path': 'std::f32', 'name': 'is_nan' }, { 'path': 'std::f64', 'name': 'is_nan' }, diff --git a/tests/rustdoc-js-std/enum-option.js b/tests/rustdoc-js-std/enum-option.js index 902e09069108d..216dafe3b129e 100644 --- a/tests/rustdoc-js-std/enum-option.js +++ b/tests/rustdoc-js-std/enum-option.js @@ -1,6 +1,5 @@ -const QUERY = 'enum:Option'; - const EXPECTED = { + 'query': 'enum:Option', 'others': [ { 'path': 'std::option', 'name': 'Option' }, ], diff --git a/tests/rustdoc-js-std/filter-crate.js b/tests/rustdoc-js-std/filter-crate.js index b47a1fefa41d0..95f2969d29924 100644 --- a/tests/rustdoc-js-std/filter-crate.js +++ b/tests/rustdoc-js-std/filter-crate.js @@ -1,9 +1,9 @@ // exact-check -const QUERY = '"hashmap"'; const FILTER_CRATE = 'core'; const EXPECTED = { + 'query': 'hashmap', 'others': [ ], }; diff --git a/tests/rustdoc-js-std/fn-forget.js b/tests/rustdoc-js-std/fn-forget.js index 66a5fcaa7813d..addecf4e44fe4 100644 --- a/tests/rustdoc-js-std/fn-forget.js +++ b/tests/rustdoc-js-std/fn-forget.js @@ -1,6 +1,5 @@ -const QUERY = 'fn:forget'; - const EXPECTED = { + 'query': 'fn:forget', 'others': [ { 'path': 'std::mem', 'name': 'forget' }, { 'path': 'std::fmt', 'name': 'format' }, diff --git a/tests/rustdoc-js-std/from_u.js b/tests/rustdoc-js-std/from_u.js index e3f3cd436aa6a..7c9375ba529a8 100644 --- a/tests/rustdoc-js-std/from_u.js +++ b/tests/rustdoc-js-std/from_u.js @@ -1,6 +1,5 @@ -const QUERY = 'from_u'; - const EXPECTED = { + 'query': 'from_u', 'others': [ { 'path': 'std::char', 'name': 'from_u32' }, { 'path': 'std::str', 'name': 'from_utf8' }, diff --git a/tests/rustdoc-js-std/keyword.js b/tests/rustdoc-js-std/keyword.js index 868ddd7b6dceb..b85ba34138bae 100644 --- a/tests/rustdoc-js-std/keyword.js +++ b/tests/rustdoc-js-std/keyword.js @@ -1,8 +1,7 @@ // ignore-order -const QUERY = 'fn'; - const EXPECTED = { + 'query': 'fn', 'others': [ { 'path': 'std', 'name': 'fn', ty: 15 }, // 15 is for primitive types { 'path': 'std', 'name': 'fn', ty: 21 }, // 21 is for keywords diff --git a/tests/rustdoc-js-std/macro-check.js b/tests/rustdoc-js-std/macro-check.js index 242e0cbf5f4de..c22b1753fd71b 100644 --- a/tests/rustdoc-js-std/macro-check.js +++ b/tests/rustdoc-js-std/macro-check.js @@ -1,8 +1,7 @@ // ignore-order -const QUERY = 'panic'; - const EXPECTED = { + 'query': 'panic', 'others': [ { 'path': 'std', 'name': 'panic', ty: 14 }, // 15 is for macros { 'path': 'std', 'name': 'panic', ty: 0 }, // 0 is for modules diff --git a/tests/rustdoc-js-std/macro-print.js b/tests/rustdoc-js-std/macro-print.js index 1b4c7b4057020..2ef1c89e49b0f 100644 --- a/tests/rustdoc-js-std/macro-print.js +++ b/tests/rustdoc-js-std/macro-print.js @@ -1,6 +1,5 @@ -const QUERY = 'macro:print'; - const EXPECTED = { + 'query': 'macro:print', 'others': [ { 'path': 'std', 'name': 'print' }, { 'path': 'std', 'name': 'println' }, diff --git a/tests/rustdoc-js-std/never.js b/tests/rustdoc-js-std/never.js index 392b1e8183786..ed3776b3c2ae0 100644 --- a/tests/rustdoc-js-std/never.js +++ b/tests/rustdoc-js-std/never.js @@ -1,6 +1,5 @@ -const QUERY = '!'; - const EXPECTED = { + 'query': '!', 'others': [ { 'path': 'std', 'name': 'never' }, ], diff --git a/tests/rustdoc-js-std/option-type-signatures.js b/tests/rustdoc-js-std/option-type-signatures.js index 6bf421a213560..8f6b0450dd319 100644 --- a/tests/rustdoc-js-std/option-type-signatures.js +++ b/tests/rustdoc-js-std/option-type-signatures.js @@ -1,15 +1,12 @@ -const QUERY = [ - 'option, fnonce -> option', - 'option -> default', -]; - const EXPECTED = [ { + 'query': 'option, fnonce -> option', 'others': [ { 'path': 'std::option::Option', 'name': 'map' }, ], }, { + 'query': 'option -> default', 'others': [ { 'path': 'std::option::Option', 'name': 'unwrap_or_default' }, { 'path': 'std::option::Option', 'name': 'get_or_insert_default' }, diff --git a/tests/rustdoc-js-std/parser-errors.js b/tests/rustdoc-js-std/parser-errors.js index d1aa840ab08a2..aa8ee86d67247 100644 --- a/tests/rustdoc-js-std/parser-errors.js +++ b/tests/rustdoc-js-std/parser-errors.js @@ -1,50 +1,6 @@ -const QUERY = [ - '

', - '->

', - 'a<"P">', - '"P" "P"', - 'P "P"', - '"p" p', - '"const": p', - "a<:a>", - "a<::a>", - "((a))", - "(p -> p", - "::a::b", - "a::::b", - "a::b::", - ":a", - "a b:", - "a (b:", - "_:", - "_:a", - "a-bb", - "a>bb", - "ab'", - "a->", - '"p" ', - '"p" a', - "a,<", - "aaaaa<>b", - "fn:aaaaa<>b", - "->a<>b", - "a<->", - "a:: a", - "a ::a", - "a:", - "a<>:", - "a,:", - " a<> :", - "mod : :", - "a!a", - "a!!", - "mod:a!", - "a!::a", - "a<", -]; - const PARSED = [ { + query: '

', elems: [], foundElems: 0, original: "

", @@ -53,6 +9,7 @@ const PARSED = [ error: "Found generics without a path", }, { + query: '->

', elems: [], foundElems: 0, original: "->

", @@ -61,6 +18,7 @@ const PARSED = [ error: "Found generics without a path", }, { + query: 'a<"P">', elems: [], foundElems: 0, original: "a<\"P\">", @@ -69,6 +27,7 @@ const PARSED = [ error: "Unexpected `\"` in generics", }, { + query: '"P" "P"', elems: [], foundElems: 0, original: "\"P\" \"P\"", @@ -77,6 +36,7 @@ const PARSED = [ error: "Cannot have more than one literal search element", }, { + query: 'P "P"', elems: [], foundElems: 0, original: "P \"P\"", @@ -85,6 +45,7 @@ const PARSED = [ error: "Cannot use literal search when there is more than one element", }, { + query: '"p" p', elems: [], foundElems: 0, original: "\"p\" p", @@ -93,6 +54,7 @@ const PARSED = [ error: "You cannot have more than one element if you use quotes", }, { + query: '"const": p', elems: [], foundElems: 0, original: "\"const\": p", @@ -101,6 +63,7 @@ const PARSED = [ error: "You cannot use quotes on type filter", }, { + query: "a<:a>", elems: [], foundElems: 0, original: "a<:a>", @@ -109,6 +72,7 @@ const PARSED = [ error: "Expected type filter before `:`", }, { + query: "a<::a>", elems: [], foundElems: 0, original: "a<::a>", @@ -117,6 +81,7 @@ const PARSED = [ error: "Unexpected `::`: paths cannot start with `::`", }, { + query: "((a))", elems: [], foundElems: 0, original: "((a))", @@ -125,6 +90,7 @@ const PARSED = [ error: "Unexpected `(`", }, { + query: "(p -> p", elems: [], foundElems: 0, original: "(p -> p", @@ -133,6 +99,7 @@ const PARSED = [ error: "Unexpected `(`", }, { + query: "::a::b", elems: [], foundElems: 0, original: "::a::b", @@ -141,6 +108,7 @@ const PARSED = [ error: "Paths cannot start with `::`", }, { + query: "a::::b", elems: [], foundElems: 0, original: "a::::b", @@ -149,6 +117,7 @@ const PARSED = [ error: "Unexpected `::::`", }, { + query: "a::b::", elems: [], foundElems: 0, original: "a::b::", @@ -157,6 +126,7 @@ const PARSED = [ error: "Paths cannot end with `::`", }, { + query: ":a", elems: [], foundElems: 0, original: ":a", @@ -165,6 +135,7 @@ const PARSED = [ error: "Expected type filter before `:`", }, { + query: "a b:", elems: [], foundElems: 0, original: "a b:", @@ -173,6 +144,7 @@ const PARSED = [ error: "Unexpected `:` (expected path after type filter)", }, { + query: "a (b:", elems: [], foundElems: 0, original: "a (b:", @@ -181,6 +153,7 @@ const PARSED = [ error: "Unexpected `(`", }, { + query: "_:", elems: [], foundElems: 0, original: "_:", @@ -189,6 +162,7 @@ const PARSED = [ error: "Unexpected `:` (expected path after type filter)", }, { + query: "_:a", elems: [], foundElems: 0, original: "_:a", @@ -197,6 +171,7 @@ const PARSED = [ error: "Unknown type filter `_`", }, { + query: "a-bb", elems: [], foundElems: 0, original: "a-bb", @@ -205,6 +180,7 @@ const PARSED = [ error: "Unexpected `-` (did you mean `->`?)", }, { + query: "a>bb", elems: [], foundElems: 0, original: "a>bb", @@ -213,6 +189,7 @@ const PARSED = [ error: "Unexpected `>` (did you mean `->`?)", }, { + query: "ab'", elems: [], foundElems: 0, original: "ab'", @@ -221,6 +198,7 @@ const PARSED = [ error: "Unexpected `'`", }, { + query: "a->", elems: [], foundElems: 0, original: "a->", @@ -229,6 +207,7 @@ const PARSED = [ error: "Expected at least one item after `->`", }, { + query: '"p" ', elems: [], foundElems: 0, original: '"p" ', @@ -237,6 +216,7 @@ const PARSED = [ error: "Found generics without a path", }, { + query: '"p" a', elems: [], foundElems: 0, original: '"p" a', @@ -245,6 +225,7 @@ const PARSED = [ error: "You cannot have more than one element if you use quotes", }, { + query: "a,<", elems: [], foundElems: 0, original: 'a,<', @@ -253,6 +234,7 @@ const PARSED = [ error: 'Found generics without a path', }, { + query: "aaaaa<>b", elems: [], foundElems: 0, original: 'aaaaa<>b', @@ -261,6 +243,7 @@ const PARSED = [ error: 'Expected `,`, ` `, `:` or `->`, found `b`', }, { + query: "fn:aaaaa<>b", elems: [], foundElems: 0, original: 'fn:aaaaa<>b', @@ -269,6 +252,7 @@ const PARSED = [ error: 'Expected `,`, ` `, `:` or `->`, found `b`', }, { + query: "->a<>b", elems: [], foundElems: 0, original: '->a<>b', @@ -277,6 +261,7 @@ const PARSED = [ error: 'Expected `,` or ` `, found `b`', }, { + query: "a<->", elems: [], foundElems: 0, original: 'a<->', @@ -285,6 +270,7 @@ const PARSED = [ error: 'Unexpected `-` after `<`', }, { + query: "a:: a", elems: [], foundElems: 0, original: 'a:: a', @@ -293,6 +279,7 @@ const PARSED = [ error: 'Paths cannot end with `::`', }, { + query: "a ::a", elems: [], foundElems: 0, original: 'a ::a', @@ -301,6 +288,7 @@ const PARSED = [ error: 'Paths cannot start with `::`', }, { + query: "a:", elems: [], foundElems: 0, original: "a:", @@ -309,6 +297,7 @@ const PARSED = [ error: 'Unexpected `<` in type filter', }, { + query: "a<>:", elems: [], foundElems: 0, original: "a<>:", @@ -317,6 +306,7 @@ const PARSED = [ error: 'Unexpected `<` in type filter', }, { + query: "a,:", elems: [], foundElems: 0, original: "a,:", @@ -325,6 +315,7 @@ const PARSED = [ error: 'Unexpected `,` in type filter', }, { + query: " a<> :", elems: [], foundElems: 0, original: "a<> :", @@ -333,6 +324,7 @@ const PARSED = [ error: 'Unexpected `<` in type filter', }, { + query: "mod : :", elems: [], foundElems: 0, original: "mod : :", @@ -341,6 +333,7 @@ const PARSED = [ error: 'Unexpected `:`', }, { + query: "a!a", elems: [], foundElems: 0, original: "a!a", @@ -349,6 +342,7 @@ const PARSED = [ error: 'Unexpected `!`: it can only be at the end of an ident', }, { + query: "a!!", elems: [], foundElems: 0, original: "a!!", @@ -357,6 +351,7 @@ const PARSED = [ error: 'Cannot have more than one `!` in an ident', }, { + query: "mod:a!", elems: [], foundElems: 0, original: "mod:a!", @@ -365,6 +360,7 @@ const PARSED = [ error: 'Invalid search type: macro `!` and `mod` both specified', }, { + query: "a!::a", elems: [], foundElems: 0, original: "a!::a", @@ -373,6 +369,7 @@ const PARSED = [ error: 'Cannot have associated items in macros', }, { + query: "a<", elems: [], foundElems: 0, original: "a<", diff --git a/tests/rustdoc-js-std/parser-filter.js b/tests/rustdoc-js-std/parser-filter.js index e23447ab75dc4..6f5d66e57ba0c 100644 --- a/tests/rustdoc-js-std/parser-filter.js +++ b/tests/rustdoc-js-std/parser-filter.js @@ -1,17 +1,6 @@ -const QUERY = [ - 'fn:foo', - 'enum : foo', - 'macro:foo', - 'macro!', - 'macro:mac!', - 'a::mac!', - '-> fn:foo', - '-> fn:foo', - '-> fn:foo', -]; - const PARSED = [ { + query: 'fn:foo', elems: [{ name: "foo", fullPath: ["foo"], @@ -27,6 +16,7 @@ const PARSED = [ error: null, }, { + query: 'enum : foo', elems: [{ name: "foo", fullPath: ["foo"], @@ -42,6 +32,7 @@ const PARSED = [ error: null, }, { + query: 'macro:foo', elems: [], foundElems: 0, original: "macro:foo", @@ -50,6 +41,7 @@ const PARSED = [ error: "Unexpected `<` in type filter", }, { + query: 'macro!', elems: [{ name: "macro", fullPath: ["macro"], @@ -65,6 +57,7 @@ const PARSED = [ error: null, }, { + query: 'macro:mac!', elems: [{ name: "mac", fullPath: ["mac"], @@ -80,6 +73,7 @@ const PARSED = [ error: null, }, { + query: 'a::mac!', elems: [{ name: "a::mac", fullPath: ["a", "mac"], @@ -95,6 +89,7 @@ const PARSED = [ error: null, }, { + query: '-> fn:foo', elems: [], foundElems: 1, original: "-> fn:foo", @@ -110,6 +105,7 @@ const PARSED = [ error: null, }, { + query: '-> fn:foo', elems: [], foundElems: 1, original: "-> fn:foo", @@ -134,6 +130,7 @@ const PARSED = [ error: null, }, { + query: '-> fn:foo', elems: [], foundElems: 1, original: "-> fn:foo", diff --git a/tests/rustdoc-js-std/parser-generics.js b/tests/rustdoc-js-std/parser-generics.js index 5a2266dbe3697..eb3cf45515576 100644 --- a/tests/rustdoc-js-std/parser-generics.js +++ b/tests/rustdoc-js-std/parser-generics.js @@ -1,14 +1,6 @@ -const QUERY = [ - 'A, E>', - 'p<> u8', - '"p"', - 'p>', - 'p, r>', - 'p>', -]; - const PARSED = [ { + query: 'A, E>', elems: [], foundElems: 0, original: 'A, E>', @@ -17,6 +9,7 @@ const PARSED = [ error: 'Unclosed `<`', }, { + query: 'p<> u8', elems: [ { name: "p", @@ -42,6 +35,7 @@ const PARSED = [ error: null, }, { + query: '"p"', elems: [ { name: "p", @@ -67,6 +61,7 @@ const PARSED = [ error: null, }, { + query: 'p>', elems: [ { name: "p", @@ -100,6 +95,7 @@ const PARSED = [ error: null, }, { + query: 'p, r>', elems: [ { name: "p", @@ -140,6 +136,7 @@ const PARSED = [ error: null, }, { + query: 'p>', elems: [ { name: "p", diff --git a/tests/rustdoc-js-std/parser-ident.js b/tests/rustdoc-js-std/parser-ident.js index be42b7aa46307..d9ee5fb564b68 100644 --- a/tests/rustdoc-js-std/parser-ident.js +++ b/tests/rustdoc-js-std/parser-ident.js @@ -1,14 +1,6 @@ -const QUERY = [ - "R", - "!", - "a!", - "a!::b", - "!::b", - "a!::b!", -]; - const PARSED = [ { + query: "R", elems: [{ name: "r", fullPath: ["r"], @@ -32,6 +24,7 @@ const PARSED = [ error: null, }, { + query: "!", elems: [{ name: "!", fullPath: ["!"], @@ -47,6 +40,7 @@ const PARSED = [ error: null, }, { + query: "a!", elems: [{ name: "a", fullPath: ["a"], @@ -62,6 +56,7 @@ const PARSED = [ error: null, }, { + query: "a!::b", elems: [], foundElems: 0, original: "a!::b", @@ -70,6 +65,7 @@ const PARSED = [ error: "Cannot have associated items in macros", }, { + query: "!::b", elems: [{ name: "!::b", fullPath: ["!", "b"], @@ -85,6 +81,7 @@ const PARSED = [ error: null, }, { + query: "a!::b!", elems: [], foundElems: 0, original: "a!::b!", diff --git a/tests/rustdoc-js-std/parser-literal.js b/tests/rustdoc-js-std/parser-literal.js index 3a31d1bddfff5..87c06224dbf2d 100644 --- a/tests/rustdoc-js-std/parser-literal.js +++ b/tests/rustdoc-js-std/parser-literal.js @@ -1,7 +1,6 @@ -const QUERY = ['R

']; - const PARSED = [ { + query: 'R

', elems: [{ name: "r", fullPath: ["r"], diff --git a/tests/rustdoc-js-std/parser-paths.js b/tests/rustdoc-js-std/parser-paths.js index f3e421f5ffa50..8d4dedf3f46c8 100644 --- a/tests/rustdoc-js-std/parser-paths.js +++ b/tests/rustdoc-js-std/parser-paths.js @@ -1,7 +1,6 @@ -const QUERY = ['A::B', 'A::B,C', 'A::B,C', 'mod::a']; - const PARSED = [ { + query: 'A::B', elems: [{ name: "a::b", fullPath: ["a", "b"], @@ -17,6 +16,7 @@ const PARSED = [ error: null, }, { + query: 'A::B,C', elems: [ { name: "a::b", @@ -42,6 +42,7 @@ const PARSED = [ error: null, }, { + query: 'A::B,C', elems: [ { name: "a::b", @@ -75,6 +76,7 @@ const PARSED = [ error: null, }, { + query: 'mod::a', elems: [{ name: "mod::a", fullPath: ["mod", "a"], diff --git a/tests/rustdoc-js-std/parser-quote.js b/tests/rustdoc-js-std/parser-quote.js index d5d67cac892f5..9d2a3620ed7a3 100644 --- a/tests/rustdoc-js-std/parser-quote.js +++ b/tests/rustdoc-js-std/parser-quote.js @@ -1,15 +1,6 @@ -const QUERY = [ - '-> "p"', - '"p",', - '"p" -> a', - '"a" -> "p"', - '->"-"', - '"a', - '""', -]; - const PARSED = [ { + query: '-> "p"', elems: [], foundElems: 1, original: '-> "p"', @@ -25,6 +16,7 @@ const PARSED = [ error: null, }, { + query: '"p",', elems: [{ name: "p", fullPath: ["p"], @@ -40,6 +32,7 @@ const PARSED = [ error: null, }, { + query: '"p" -> a', elems: [], foundElems: 0, original: '"p" -> a', @@ -48,6 +41,7 @@ const PARSED = [ error: "You cannot have more than one element if you use quotes", }, { + query: '"a" -> "p"', elems: [], foundElems: 0, original: '"a" -> "p"', @@ -56,6 +50,7 @@ const PARSED = [ error: "Cannot have more than one literal search element", }, { + query: '->"-"', elems: [], foundElems: 0, original: '->"-"', @@ -64,6 +59,7 @@ const PARSED = [ error: 'Unexpected `-` in a string element', }, { + query: '"a', elems: [], foundElems: 0, original: '"a', @@ -72,6 +68,7 @@ const PARSED = [ error: 'Unclosed `"`', }, { + query: '""', elems: [], foundElems: 0, original: '""', diff --git a/tests/rustdoc-js-std/parser-returned.js b/tests/rustdoc-js-std/parser-returned.js index c2981319055db..665e2a9b2e3d7 100644 --- a/tests/rustdoc-js-std/parser-returned.js +++ b/tests/rustdoc-js-std/parser-returned.js @@ -1,13 +1,6 @@ -const QUERY = [ - "-> F

", - "-> P", - "->,a", - "aaaaa->a", - "-> !", -]; - const PARSED = [ { + query: "-> F

", elems: [], foundElems: 1, original: "-> F

", @@ -31,6 +24,7 @@ const PARSED = [ error: null, }, { + query: "-> P", elems: [], foundElems: 1, original: "-> P", @@ -46,6 +40,7 @@ const PARSED = [ error: null, }, { + query: "->,a", elems: [], foundElems: 1, original: "->,a", @@ -61,6 +56,7 @@ const PARSED = [ error: null, }, { + query: "aaaaa->a", elems: [{ name: "aaaaa", fullPath: ["aaaaa"], @@ -83,6 +79,7 @@ const PARSED = [ error: null, }, { + query: "-> !", elems: [], foundElems: 1, original: "-> !", diff --git a/tests/rustdoc-js-std/parser-separators.js b/tests/rustdoc-js-std/parser-separators.js index fc8c5114c4e96..69f9ac29ad3ce 100644 --- a/tests/rustdoc-js-std/parser-separators.js +++ b/tests/rustdoc-js-std/parser-separators.js @@ -1,17 +1,8 @@ // ignore-tidy-tab -const QUERY = [ - 'aaaaaa b', - 'a b', - 'a,b', - 'a\tb', - 'a', - 'a', - 'a', -]; - const PARSED = [ { + query: 'aaaaaa b', elems: [ { name: 'aaaaaa', @@ -37,6 +28,7 @@ const PARSED = [ error: null, }, { + query: 'a b', elems: [ { name: 'a', @@ -62,6 +54,7 @@ const PARSED = [ error: null, }, { + query: 'a,b', elems: [ { name: 'a', @@ -87,6 +80,7 @@ const PARSED = [ error: null, }, { + query: 'a\tb', elems: [ { name: 'a', @@ -112,6 +106,7 @@ const PARSED = [ error: null, }, { + query: 'a', elems: [ { name: 'a', @@ -144,6 +139,7 @@ const PARSED = [ error: null, }, { + query: 'a', elems: [ { name: 'a', @@ -176,6 +172,7 @@ const PARSED = [ error: null, }, { + query: 'a', elems: [ { name: 'a', diff --git a/tests/rustdoc-js-std/parser-weird-queries.js b/tests/rustdoc-js-std/parser-weird-queries.js index dc1049a70bc38..0e08eaf73c876 100644 --- a/tests/rustdoc-js-std/parser-weird-queries.js +++ b/tests/rustdoc-js-std/parser-weird-queries.js @@ -1,18 +1,10 @@ // This test is mostly to check that the parser still kinda outputs something // (and doesn't enter an infinite loop!) even though the query is completely // invalid. -const QUERY = [ - 'a b', - 'a b', - 'a,b(c)', - 'aaa,a', - ',,,,', - 'mod :', - 'mod\t:', -]; const PARSED = [ { + query: 'a b', elems: [ { name: "a", @@ -38,6 +30,7 @@ const PARSED = [ error: null, }, { + query: 'a b', elems: [ { name: "a", @@ -63,6 +56,7 @@ const PARSED = [ error: null, }, { + query: 'a,b(c)', elems: [], foundElems: 0, original: "a,b(c)", @@ -71,6 +65,7 @@ const PARSED = [ error: "Unexpected `(`", }, { + query: 'aaa,a', elems: [ { name: "aaa", @@ -96,6 +91,7 @@ const PARSED = [ error: null, }, { + query: ',,,,', elems: [], foundElems: 0, original: ",,,,", @@ -104,6 +100,7 @@ const PARSED = [ error: null, }, { + query: 'mod :', elems: [], foundElems: 0, original: 'mod :', @@ -112,6 +109,7 @@ const PARSED = [ error: "Unexpected `:` (expected path after type filter)", }, { + query: 'mod\t:', elems: [], foundElems: 0, original: 'mod\t:', diff --git a/tests/rustdoc-js-std/path-ordering.js b/tests/rustdoc-js-std/path-ordering.js index 7dcdd40231248..c3d61d238cc35 100644 --- a/tests/rustdoc-js-std/path-ordering.js +++ b/tests/rustdoc-js-std/path-ordering.js @@ -1,7 +1,6 @@ -const QUERY = 'hashset::insert'; - const EXPECTED = { - 'others': [ + query: 'hashset::insert', + others: [ // ensure hashset::insert comes first { 'path': 'std::collections::hash_set::HashSet', 'name': 'insert' }, { 'path': 'std::collections::hash_set::HashSet', 'name': 'get_or_insert' }, diff --git a/tests/rustdoc-js-std/primitive.js b/tests/rustdoc-js-std/primitive.js index e5690383e4f0b..737e429bf5514 100644 --- a/tests/rustdoc-js-std/primitive.js +++ b/tests/rustdoc-js-std/primitive.js @@ -1,15 +1,6 @@ -const QUERY = [ - 'i8', - 'u32', - 'str', - 'char', - 'unit', - 'tuple', - 'fn', -]; - const EXPECTED = [ { + 'query': 'i8', 'others': [ { 'path': 'std', @@ -19,6 +10,7 @@ const EXPECTED = [ ] }, { + 'query': 'u32', 'others': [ { 'path': 'std', @@ -28,6 +20,7 @@ const EXPECTED = [ ] }, { + 'query': 'str', 'others': [ { 'path': 'std', @@ -37,6 +30,7 @@ const EXPECTED = [ ] }, { + 'query': 'char', 'others': [ { 'path': 'std', @@ -46,6 +40,7 @@ const EXPECTED = [ ] }, { + 'query': 'unit', 'others': [ { 'path': 'std', @@ -55,6 +50,7 @@ const EXPECTED = [ ] }, { + 'query': 'tuple', 'others': [ { 'path': 'std', @@ -64,6 +60,7 @@ const EXPECTED = [ ] }, { + 'query': 'fn', 'others': [ { 'path': 'std', diff --git a/tests/rustdoc-js-std/println-typo.js b/tests/rustdoc-js-std/println-typo.js index 7ca3ab8e56333..a4dd90a44d5ba 100644 --- a/tests/rustdoc-js-std/println-typo.js +++ b/tests/rustdoc-js-std/println-typo.js @@ -1,9 +1,9 @@ // exact-check -const QUERY = 'prinltn'; const FILTER_CRATE = 'std'; const EXPECTED = { + 'query': 'prinltn', 'others': [ { 'path': 'std', 'name': 'println' }, { 'path': 'std', 'name': 'print' }, diff --git a/tests/rustdoc-js-std/quoted.js b/tests/rustdoc-js-std/quoted.js index aec8484a41f6d..8a9275019255c 100644 --- a/tests/rustdoc-js-std/quoted.js +++ b/tests/rustdoc-js-std/quoted.js @@ -1,9 +1,9 @@ // ignore-order -const QUERY = '"error"'; const FILTER_CRATE = 'std'; const EXPECTED = { + 'query': '"error"', 'others': [ { 'path': 'std', 'name': 'error' }, { 'path': 'std::fmt', 'name': 'Error' }, diff --git a/tests/rustdoc-js-std/reference-shrink.js b/tests/rustdoc-js-std/reference-shrink.js index f90be6d1bfd35..b602bbdca188d 100644 --- a/tests/rustdoc-js-std/reference-shrink.js +++ b/tests/rustdoc-js-std/reference-shrink.js @@ -1,8 +1,7 @@ // exact-check -const QUERY = 'reference::shrink'; - const EXPECTED = { + 'query': 'reference::shrink', // avoid including the method that's not going to be in the HTML 'others': [], }; diff --git a/tests/rustdoc-js-std/regex.js b/tests/rustdoc-js-std/regex.js index a6843c595f7ad..7dc38939a17d4 100644 --- a/tests/rustdoc-js-std/regex.js +++ b/tests/rustdoc-js-std/regex.js @@ -1,9 +1,8 @@ // exact-check // https://github.com/rust-lang/rust/issues/103357 -const QUERY = 'regex'; - const EXPECTED = { + 'query': 'regex', 'others': [], 'in_args': [], 'returned': [], diff --git a/tests/rustdoc-js-std/return-specific-literal.js b/tests/rustdoc-js-std/return-specific-literal.js index c7c347240b751..86ed3aceb4e84 100644 --- a/tests/rustdoc-js-std/return-specific-literal.js +++ b/tests/rustdoc-js-std/return-specific-literal.js @@ -1,6 +1,5 @@ -const QUERY = 'struct:"string"'; - const EXPECTED = { + 'query': 'struct:"string"', 'in_args': [ { 'path': 'std::string::String', 'name': 'ne' }, ], diff --git a/tests/rustdoc-js-std/return-specific.js b/tests/rustdoc-js-std/return-specific.js index d9a910553b8de..be54a1c977254 100644 --- a/tests/rustdoc-js-std/return-specific.js +++ b/tests/rustdoc-js-std/return-specific.js @@ -1,6 +1,5 @@ -const QUERY = 'struct:string'; - const EXPECTED = { + 'query': 'struct:string', 'in_args': [ { 'path': 'std::string::String', 'name': 'ne' }, ], diff --git a/tests/rustdoc-js-std/should-fail.js b/tests/rustdoc-js-std/should-fail.js index b85a47dc08a88..94f82efd9b497 100644 --- a/tests/rustdoc-js-std/should-fail.js +++ b/tests/rustdoc-js-std/should-fail.js @@ -1,8 +1,7 @@ // should-fail -const QUERY = 'fn'; - const EXPECTED = { + 'query': 'fn', 'others': [ { 'path': 'std', 'name': 'fn', ty: 14 }, ], diff --git a/tests/rustdoc-js-std/string-from_ut.js b/tests/rustdoc-js-std/string-from_ut.js index f9edf4408db85..1fff6ee28bb42 100644 --- a/tests/rustdoc-js-std/string-from_ut.js +++ b/tests/rustdoc-js-std/string-from_ut.js @@ -1,6 +1,5 @@ -const QUERY = 'String::from_ut'; - const EXPECTED = { + 'query': 'String::from_ut', 'others': [ { 'path': 'std::string::String', 'name': 'from_utf8' }, { 'path': 'std::string::String', 'name': 'from_utf8' }, diff --git a/tests/rustdoc-js-std/struct-vec.js b/tests/rustdoc-js-std/struct-vec.js index 29609904b1957..dd72aaa1ab86c 100644 --- a/tests/rustdoc-js-std/struct-vec.js +++ b/tests/rustdoc-js-std/struct-vec.js @@ -1,6 +1,5 @@ -const QUERY = 'struct:VecD'; - const EXPECTED = { + 'query': 'struct:VecD', 'others': [ { 'path': 'std::collections', 'name': 'VecDeque' }, { 'path': 'std::vec', 'name': 'Vec' }, diff --git a/tests/rustdoc-js-std/typed-query.js b/tests/rustdoc-js-std/typed-query.js index eeb3e18886959..8e84645889adf 100644 --- a/tests/rustdoc-js-std/typed-query.js +++ b/tests/rustdoc-js-std/typed-query.js @@ -1,9 +1,9 @@ // exact-check -const QUERY = 'macro:print'; const FILTER_CRATE = 'std'; const EXPECTED = { + 'query': 'macro:print', 'others': [ { 'path': 'std', 'name': 'print' }, { 'path': 'std', 'name': 'println' }, diff --git a/tests/rustdoc-js-std/vec-new.js b/tests/rustdoc-js-std/vec-new.js index fc44a566af21f..309f3543faffe 100644 --- a/tests/rustdoc-js-std/vec-new.js +++ b/tests/rustdoc-js-std/vec-new.js @@ -1,6 +1,5 @@ -const QUERY = 'Vec::new'; - const EXPECTED = { + 'query': 'Vec::new', 'others': [ { 'path': 'std::vec::Vec', 'name': 'new' }, { 'path': 'alloc::vec::Vec', 'name': 'new' }, diff --git a/tests/rustdoc-js/basic.js b/tests/rustdoc-js/basic.js index d99b23468b60c..e186d510887cb 100644 --- a/tests/rustdoc-js/basic.js +++ b/tests/rustdoc-js/basic.js @@ -1,6 +1,5 @@ -const QUERY = 'Fo'; - const EXPECTED = { + 'query': 'Fo', 'others': [ { 'path': 'basic', 'name': 'Foo' }, ], diff --git a/tests/rustdoc-js/doc-alias-filter-out.js b/tests/rustdoc-js/doc-alias-filter-out.js index 46a089d06ebef..fd25370dff3c1 100644 --- a/tests/rustdoc-js/doc-alias-filter-out.js +++ b/tests/rustdoc-js/doc-alias-filter-out.js @@ -1,9 +1,8 @@ // exact-check -const QUERY = 'true'; - const FILTER_CRATE = 'some_other_crate'; const EXPECTED = { + 'query': 'true', 'others': [], }; diff --git a/tests/rustdoc-js/doc-alias-filter.js b/tests/rustdoc-js/doc-alias-filter.js index e06047ba7606e..1d2dd8b9a8cde 100644 --- a/tests/rustdoc-js/doc-alias-filter.js +++ b/tests/rustdoc-js/doc-alias-filter.js @@ -1,10 +1,9 @@ // exact-check -const QUERY = '"true"'; - const FILTER_CRATE = 'doc_alias_filter'; const EXPECTED = { + 'query': '"true"', 'others': [ { 'path': 'doc_alias_filter', diff --git a/tests/rustdoc-js/doc-alias-whitespace.js b/tests/rustdoc-js/doc-alias-whitespace.js index c9fc0c4311f19..64784b5698be9 100644 --- a/tests/rustdoc-js/doc-alias-whitespace.js +++ b/tests/rustdoc-js/doc-alias-whitespace.js @@ -1,11 +1,8 @@ // exact-check -const QUERY = [ - 'Demon Lord', -]; - const EXPECTED = [ { + 'query': 'Demon Lord', 'others': [ { 'path': 'doc_alias_whitespace', diff --git a/tests/rustdoc-js/doc-alias.js b/tests/rustdoc-js/doc-alias.js index 62c8e7a74b940..7e4e8a776d899 100644 --- a/tests/rustdoc-js/doc-alias.js +++ b/tests/rustdoc-js/doc-alias.js @@ -1,31 +1,6 @@ -const QUERY = [ - 'StructItem', - 'StructFieldItem', - 'StructMethodItem', - 'ImplTraitItem', - 'StructImplConstItem', - 'ImplTraitFunction', - 'EnumItem', - 'VariantItem', - 'EnumMethodItem', - 'TypedefItem', - 'TraitItem', - 'TraitTypeItem', - 'AssociatedConstItem', - 'TraitFunctionItem', - 'FunctionItem', - 'ModuleItem', - 'ConstItem', - 'StaticItem', - 'UnionItem', - 'UnionFieldItem', - 'UnionMethodItem', - 'MacroItem', -]; - const EXPECTED = [ { - // StructItem + 'query': 'StructItem', 'others': [ { 'path': 'doc_alias', @@ -37,7 +12,7 @@ const EXPECTED = [ ], }, { - // StructFieldItem + 'query': 'StructFieldItem', 'others': [ { 'path': 'doc_alias::Struct', @@ -49,7 +24,7 @@ const EXPECTED = [ ], }, { - // StructMethodItem + 'query': 'StructMethodItem', 'others': [ { 'path': 'doc_alias::Struct', @@ -61,11 +36,11 @@ const EXPECTED = [ ], }, { - // ImplTraitItem + 'query': 'ImplTraitItem', 'others': [], }, { - // StructImplConstItem + 'query': 'StructImplConstItem', 'others': [ { 'path': 'doc_alias::Struct', @@ -77,7 +52,7 @@ const EXPECTED = [ ], }, { - // ImplTraitFunction + 'query': 'ImplTraitFunction', 'others': [ { 'path': 'doc_alias::Struct', @@ -89,7 +64,7 @@ const EXPECTED = [ ], }, { - // EnumItem + 'query': 'EnumItem', 'others': [ { 'path': 'doc_alias', @@ -101,7 +76,7 @@ const EXPECTED = [ ], }, { - // VariantItem + 'query': 'VariantItem', 'others': [ { 'path': 'doc_alias::Enum', @@ -113,7 +88,7 @@ const EXPECTED = [ ], }, { - // EnumMethodItem + 'query': 'EnumMethodItem', 'others': [ { 'path': 'doc_alias::Enum', @@ -125,7 +100,7 @@ const EXPECTED = [ ], }, { - // TypedefItem + 'query': 'TypedefItem', 'others': [ { 'path': 'doc_alias', @@ -137,7 +112,7 @@ const EXPECTED = [ ], }, { - // TraitItem + 'query': 'TraitItem', 'others': [ { 'path': 'doc_alias', @@ -149,7 +124,7 @@ const EXPECTED = [ ], }, { - // TraitTypeItem + 'query': 'TraitTypeItem', 'others': [ { 'path': 'doc_alias::Trait', @@ -161,7 +136,7 @@ const EXPECTED = [ ], }, { - // AssociatedConstItem + 'query': 'AssociatedConstItem', 'others': [ { 'path': 'doc_alias::Trait', @@ -173,7 +148,7 @@ const EXPECTED = [ ], }, { - // TraitFunctionItem + 'query': 'TraitFunctionItem', 'others': [ { 'path': 'doc_alias::Trait', @@ -185,7 +160,7 @@ const EXPECTED = [ ], }, { - // FunctionItem + 'query': 'FunctionItem', 'others': [ { 'path': 'doc_alias', @@ -197,7 +172,7 @@ const EXPECTED = [ ], }, { - // ModuleItem + 'query': 'ModuleItem', 'others': [ { 'path': 'doc_alias', @@ -209,7 +184,7 @@ const EXPECTED = [ ], }, { - // ConstItem + 'query': 'ConstItem', 'others': [ { 'path': 'doc_alias', @@ -225,7 +200,7 @@ const EXPECTED = [ ], }, { - // StaticItem + 'query': 'StaticItem', 'others': [ { 'path': 'doc_alias', @@ -237,7 +212,7 @@ const EXPECTED = [ ], }, { - // UnionItem + 'query': 'UnionItem', 'others': [ { 'path': 'doc_alias', @@ -255,7 +230,7 @@ const EXPECTED = [ ], }, { - // UnionFieldItem + 'query': 'UnionFieldItem', 'others': [ { 'path': 'doc_alias::Union', @@ -267,7 +242,7 @@ const EXPECTED = [ ], }, { - // UnionMethodItem + 'query': 'UnionMethodItem', 'others': [ { 'path': 'doc_alias::Union', @@ -279,7 +254,7 @@ const EXPECTED = [ ], }, { - // MacroItem + 'query': 'MacroItem', 'others': [ { 'path': 'doc_alias', diff --git a/tests/rustdoc-js/exact-match.js b/tests/rustdoc-js/exact-match.js index b0a411bee5829..ce3a76f9b7dd3 100644 --- a/tests/rustdoc-js/exact-match.js +++ b/tests/rustdoc-js/exact-match.js @@ -1,6 +1,5 @@ -const QUERY = 'si::pc'; - const EXPECTED = { + 'query': 'si::pc', 'others': [ { 'path': 'exact_match::Si', 'name': 'pc' }, { 'path': 'exact_match::Psi', 'name': 'pc' }, diff --git a/tests/rustdoc-js/foreign-type-path.js b/tests/rustdoc-js/foreign-type-path.js index 334761badcab1..b11123d3ed9b1 100644 --- a/tests/rustdoc-js/foreign-type-path.js +++ b/tests/rustdoc-js/foreign-type-path.js @@ -1,6 +1,5 @@ -const QUERY = 'MyForeignType::my_method'; - const EXPECTED = { + 'query': 'MyForeignType::my_method', 'others': [ // Test case for https://github.com/rust-lang/rust/pull/96887#pullrequestreview-967154358 // Validates that the parent path for a foreign type method is correct. diff --git a/tests/rustdoc-js/generics-impl.js b/tests/rustdoc-js/generics-impl.js index 5051743bda2d1..5e33e224876fe 100644 --- a/tests/rustdoc-js/generics-impl.js +++ b/tests/rustdoc-js/generics-impl.js @@ -1,68 +1,56 @@ // exact-check -const QUERY = [ - 'Aaaaaaa -> u32', - 'Aaaaaaa -> bool', - 'Aaaaaaa -> usize', - 'Read -> u64', - 'trait:Read -> u64', - 'struct:Read -> u64', - 'bool -> u64', - 'Ddddddd -> u64', - '-> Ddddddd' -]; - const EXPECTED = [ { - // Aaaaaaa -> u32 + 'query': 'Aaaaaaa -> u32', 'others': [ { 'path': 'generics_impl::Aaaaaaa', 'name': 'bbbbbbb' }, ], }, { - // Aaaaaaa -> bool + 'query': 'Aaaaaaa -> bool', 'others': [ { 'path': 'generics_impl::Aaaaaaa', 'name': 'ccccccc' }, ], }, { - // Aaaaaaa -> usize + 'query': 'Aaaaaaa -> usize', 'others': [ { 'path': 'generics_impl::Aaaaaaa', 'name': 'read' }, ], }, { - // Read -> u64 + 'query': 'Read -> u64', 'others': [ { 'path': 'generics_impl::Ddddddd', 'name': 'eeeeeee' }, { 'path': 'generics_impl::Ddddddd', 'name': 'ggggggg' }, ], }, { - // trait:Read -> u64 + 'query': 'trait:Read -> u64', 'others': [ { 'path': 'generics_impl::Ddddddd', 'name': 'eeeeeee' }, { 'path': 'generics_impl::Ddddddd', 'name': 'ggggggg' }, ], }, { - // struct:Read -> u64 + 'query': 'struct:Read -> u64', 'others': [], }, { - // bool -> u64 + 'query': 'bool -> u64', 'others': [ { 'path': 'generics_impl::Ddddddd', 'name': 'fffffff' }, ], }, { - // Ddddddd -> u64 + 'query': 'Ddddddd -> u64', 'others': [ { 'path': 'generics_impl::Ddddddd', 'name': 'ggggggg' }, ], }, { - // -> Ddddddd + 'query': '-> Ddddddd', 'others': [ { 'path': 'generics_impl::Ddddddd', 'name': 'hhhhhhh' }, ], diff --git a/tests/rustdoc-js/generics-multi-trait.js b/tests/rustdoc-js/generics-multi-trait.js index e7fcea876c85c..7097cabe7a21f 100644 --- a/tests/rustdoc-js/generics-multi-trait.js +++ b/tests/rustdoc-js/generics-multi-trait.js @@ -1,14 +1,9 @@ // exact-check -const QUERY = [ - 'Result', - 'Zzzzzzzzzzzzzzzzzz', - 'Nonononononononono', -]; - const EXPECTED = [ // check one of the generic items { + 'query': 'Result', 'in_args': [ { 'path': 'generics_multi_trait', 'name': 'beta' }, ], @@ -17,6 +12,7 @@ const EXPECTED = [ ], }, { + 'query': 'Zzzzzzzzzzzzzzzzzz', 'in_args': [ { 'path': 'generics_multi_trait', 'name': 'beta' }, ], @@ -26,6 +22,7 @@ const EXPECTED = [ }, // ignore the name of the generic itself { + 'query': 'Nonononononononono', 'in_args': [], 'returned': [], }, diff --git a/tests/rustdoc-js/generics-nested.js b/tests/rustdoc-js/generics-nested.js index 8701f2d49861a..294c194907489 100644 --- a/tests/rustdoc-js/generics-nested.js +++ b/tests/rustdoc-js/generics-nested.js @@ -1,31 +1,24 @@ // exact-check -const QUERY = [ - '-> Out>', - '-> Out>', - '-> Out', - '-> Out', -]; - const EXPECTED = [ { - // -> Out> + 'query': '-> Out>', 'others': [ { 'path': 'generics_nested', 'name': 'alef' }, ], }, { - // -> Out> + 'query': '-> Out>', 'others': [], }, { - // -> Out + 'query': '-> Out', 'others': [ { 'path': 'generics_nested', 'name': 'bet' }, ], }, { - // -> Out + 'query': '-> Out', 'others': [ { 'path': 'generics_nested', 'name': 'bet' }, ], diff --git a/tests/rustdoc-js/generics-trait.js b/tests/rustdoc-js/generics-trait.js index 0e84751603ed6..4ccfb8f4e4d02 100644 --- a/tests/rustdoc-js/generics-trait.js +++ b/tests/rustdoc-js/generics-trait.js @@ -1,22 +1,9 @@ // exact-check -const QUERY = [ - 'Result', - 'Result', - 'OtherThingxxxxxxxx', - 'OtherThingxxxxxxxy', -]; - -const CORRECTIONS = [ - null, - null, - null, - 'OtherThingxxxxxxxx', -]; - const EXPECTED = [ - // Result { + 'query': 'Result', + 'correction': null, 'in_args': [ { 'path': 'generics_trait', 'name': 'beta' }, ], @@ -24,13 +11,15 @@ const EXPECTED = [ { 'path': 'generics_trait', 'name': 'bet' }, ], }, - // Result { + 'query': 'Result', + 'correction': null, 'in_args': [], 'returned': [], }, - // OtherThingxxxxxxxx { + 'query': 'OtherThingxxxxxxxx', + 'correction': null, 'in_args': [ { 'path': 'generics_trait', 'name': 'alpha' }, ], @@ -38,8 +27,9 @@ const EXPECTED = [ { 'path': 'generics_trait', 'name': 'alef' }, ], }, - // OtherThingxxxxxxxy { + 'query': 'OtherThingxxxxxxxy', + 'correction': 'OtherThingxxxxxxxx', 'in_args': [ { 'path': 'generics_trait', 'name': 'alpha' }, ], diff --git a/tests/rustdoc-js/generics.js b/tests/rustdoc-js/generics.js index f79c709ad6cf0..ebc92ccfc0575 100644 --- a/tests/rustdoc-js/generics.js +++ b/tests/rustdoc-js/generics.js @@ -1,20 +1,8 @@ // exact-check -const QUERY = [ - 'R

', - 'R', - 'R', - '"P"', - 'P', - 'ExtraCreditStructMulti', - 'TraitCat', - 'TraitDog', - 'Result', -]; - const EXPECTED = [ { - // R

+ 'query': 'R

', 'returned': [ { 'path': 'generics', 'name': 'alef' }, ], @@ -23,7 +11,7 @@ const EXPECTED = [ ], }, { - // R + 'query': 'R', 'returned': [ { 'path': 'generics', 'name': 'alef' }, ], @@ -32,12 +20,12 @@ const EXPECTED = [ ], }, { - // R + 'query': 'R', 'returned': [], 'in_args': [], }, { - // "P" + 'query': '"P"', 'others': [ { 'path': 'generics', 'name': 'P' }, ], @@ -49,7 +37,7 @@ const EXPECTED = [ ], }, { - // P + 'query': 'P', 'returned': [ { 'path': 'generics', 'name': 'alef' }, ], @@ -58,26 +46,26 @@ const EXPECTED = [ ], }, { - // "ExtraCreditStructMulti" + 'query': '"ExtraCreditStructMulti"', 'in_args': [ { 'path': 'generics', 'name': 'extracreditlabhomework' }, ], 'returned': [], }, { - // TraitCat + 'query': 'TraitCat', 'in_args': [ { 'path': 'generics', 'name': 'gamma' }, ], }, { - // TraitDog + 'query': 'TraitDog', 'in_args': [ { 'path': 'generics', 'name': 'gamma' }, ], }, { - // Result + 'query': 'Result', 'others': [], 'returned': [ { 'path': 'generics', 'name': 'super_soup' }, diff --git a/tests/rustdoc-js/impl-trait.js b/tests/rustdoc-js/impl-trait.js index 8d594bf8aea75..710e594b54774 100644 --- a/tests/rustdoc-js/impl-trait.js +++ b/tests/rustdoc-js/impl-trait.js @@ -1,32 +1,24 @@ // ignore-order -const QUERY = [ - 'Aaaaaaa -> i32', - 'Aaaaaaa -> Aaaaaaa', - 'Aaaaaaa -> usize', - '-> Aaaaaaa', - 'Aaaaaaa', -]; - const EXPECTED = [ { - // Aaaaaaa -> i32 + 'query': 'Aaaaaaa -> i32', 'others': [ { 'path': 'impl_trait::Ccccccc', 'name': 'eeeeeee' }, ], }, { - // Aaaaaaa -> Aaaaaaa + 'query': 'Aaaaaaa -> Aaaaaaa', 'others': [ { 'path': 'impl_trait::Ccccccc', 'name': 'fffffff' }, ], }, { - // Aaaaaaa -> usize + 'query': 'Aaaaaaa -> usize', 'others': [], }, { - // -> Aaaaaaa + 'query': '-> Aaaaaaa', 'others': [ { 'path': 'impl_trait::Ccccccc', 'name': 'fffffff' }, { 'path': 'impl_trait::Ccccccc', 'name': 'ddddddd' }, @@ -34,7 +26,7 @@ const EXPECTED = [ ], }, { - // Aaaaaaa + 'query': 'Aaaaaaa', 'others': [ { 'path': 'impl_trait', 'name': 'Aaaaaaa' }, ], diff --git a/tests/rustdoc-js/macro-search.js b/tests/rustdoc-js/macro-search.js index 2b179ce146bf0..241f7f1728859 100644 --- a/tests/rustdoc-js/macro-search.js +++ b/tests/rustdoc-js/macro-search.js @@ -1,8 +1,7 @@ // exact-check -const QUERY = 'abracadabra!'; - const EXPECTED = { + 'query': 'abracadabra!', 'others': [ { 'path': 'macro_search', 'name': 'abracadabra' }, { 'path': 'macro_search', 'name': 'abracadabra_b' }, diff --git a/tests/rustdoc-js/module-substring.js b/tests/rustdoc-js/module-substring.js index f17a97f13dc7e..7a10397ebc620 100644 --- a/tests/rustdoc-js/module-substring.js +++ b/tests/rustdoc-js/module-substring.js @@ -1,6 +1,5 @@ -const QUERY = 'ig::pc'; - const EXPECTED = { + 'query': 'ig::pc', 'others': [ { 'path': 'module_substring::Sig', 'name': 'pc' }, { 'path': 'module_substring::Si', 'name': 'pc' }, diff --git a/tests/rustdoc-js/path-ordering.js b/tests/rustdoc-js/path-ordering.js index 4aee569b0f481..f2e6fe2fa61c4 100644 --- a/tests/rustdoc-js/path-ordering.js +++ b/tests/rustdoc-js/path-ordering.js @@ -1,8 +1,7 @@ // exact-check -const QUERY = 'b::ccccccc'; - const EXPECTED = { + 'query': 'b::ccccccc', 'others': [ // `ccccccc` is an exact match for all three of these. // However `b` is a closer match for `bb` than for any diff --git a/tests/rustdoc-js/primitive.js b/tests/rustdoc-js/primitive.js index 4aec98c340379..ad8f6663aad12 100644 --- a/tests/rustdoc-js/primitive.js +++ b/tests/rustdoc-js/primitive.js @@ -1,33 +1,30 @@ // exact-check -const QUERY = [ - "i32", - "str", - "primitive:str", - "struct:str", - "TotoIsSomewhere", -]; - const EXPECTED = [ { + 'query': 'i32', 'in_args': [ { 'path': 'primitive', 'name': 'foo' }, ], }, { + 'query': 'str', 'returned': [ { 'path': 'primitive', 'name': 'foo' }, ], }, { + 'query': 'primitive:str', 'returned': [ { 'path': 'primitive', 'name': 'foo' }, ], }, { + 'query': 'struct:str', 'returned': [], }, { + 'query': 'TotoIsSomewhere', 'others': [], 'in_args': [], 'returned': [], diff --git a/tests/rustdoc-js/prototype.js b/tests/rustdoc-js/prototype.js index 2f1d841c3be19..da72fdce3db93 100644 --- a/tests/rustdoc-js/prototype.js +++ b/tests/rustdoc-js/prototype.js @@ -1,14 +1,14 @@ // exact-check -const QUERY = ['constructor', '__proto__']; - const EXPECTED = [ { + 'query': 'constructor', 'others': [], 'returned': [], 'in_args': [], }, { + 'query': '__proto__', 'others': [], 'returned': [], 'in_args': [], diff --git a/tests/rustdoc-js/raw-pointer.js b/tests/rustdoc-js/raw-pointer.js index 140b955ea713a..f2b1294ee3c86 100644 --- a/tests/rustdoc-js/raw-pointer.js +++ b/tests/rustdoc-js/raw-pointer.js @@ -1,33 +1,25 @@ // ignore-order -const QUERY = [ - 'Aaaaaaa -> i32', - 'Aaaaaaa -> Aaaaaaa', - 'Aaaaaaa -> usize', - '-> Aaaaaaa', - 'Aaaaaaa', -]; - const EXPECTED = [ { - // Aaaaaaa -> i32 + 'query': 'Aaaaaaa -> i32', 'others': [ { 'path': 'raw_pointer::Ccccccc', 'name': 'eeeeeee' }, ], }, { - // Aaaaaaa -> Aaaaaaa + 'query': 'Aaaaaaa -> Aaaaaaa', 'others': [ { 'path': 'raw_pointer::Ccccccc', 'name': 'fffffff' }, { 'path': 'raw_pointer::Ccccccc', 'name': 'ggggggg' }, ], }, { - // Aaaaaaa -> usize + 'query': 'Aaaaaaa -> usize', 'others': [], }, { - // -> Aaaaaaa + 'query': '-> Aaaaaaa', 'others': [ { 'path': 'raw_pointer::Ccccccc', 'name': 'fffffff' }, { 'path': 'raw_pointer::Ccccccc', 'name': 'ggggggg' }, @@ -36,7 +28,7 @@ const EXPECTED = [ ], }, { - // Aaaaaaa + 'query': 'Aaaaaaa', 'others': [ { 'path': 'raw_pointer', 'name': 'Aaaaaaa' }, ], diff --git a/tests/rustdoc-js/reexport.js b/tests/rustdoc-js/reexport.js index 871e75d9b2b31..9021cc2e90fe0 100644 --- a/tests/rustdoc-js/reexport.js +++ b/tests/rustdoc-js/reexport.js @@ -1,15 +1,15 @@ // exact-check -const QUERY = ['Subscriber', 'AnotherOne']; - const EXPECTED = [ { + 'query': 'Subscriber', 'others': [ { 'path': 'reexport::fmt', 'name': 'Subscriber' }, { 'path': 'reexport', 'name': 'FmtSubscriber' }, ], }, { + 'query': 'AnotherOne', 'others': [ { 'path': 'reexport', 'name': 'AnotherOne' }, ], diff --git a/tests/rustdoc-js/search-bag-semantics.js b/tests/rustdoc-js/search-bag-semantics.js index c56a3df5f904c..4b598cd80cc07 100644 --- a/tests/rustdoc-js/search-bag-semantics.js +++ b/tests/rustdoc-js/search-bag-semantics.js @@ -1,18 +1,15 @@ // exact-check -const QUERY = [ - 'P', - 'P, P', -]; - const EXPECTED = [ { + 'query': 'P', 'in_args': [ { 'path': 'search_bag_semantics', 'name': 'alacazam' }, { 'path': 'search_bag_semantics', 'name': 'abracadabra' }, ], }, { + 'query': 'P, P', 'others': [ { 'path': 'search_bag_semantics', 'name': 'abracadabra' }, ], diff --git a/tests/rustdoc-js/search-short-types.js b/tests/rustdoc-js/search-short-types.js index 3b2f15a40bf87..5048e0443c1c2 100644 --- a/tests/rustdoc-js/search-short-types.js +++ b/tests/rustdoc-js/search-short-types.js @@ -1,6 +1,5 @@ -const QUERY = 'P'; - const EXPECTED = { + 'query': 'P', 'others': [ { 'path': 'search_short_types', 'name': 'P' }, { 'path': 'search_short_types::VeryLongTypeName', 'name': 'p' }, diff --git a/tests/rustdoc-js/slice-array.js b/tests/rustdoc-js/slice-array.js index 8c21e06dc4e4f..1c06566920c2b 100644 --- a/tests/rustdoc-js/slice-array.js +++ b/tests/rustdoc-js/slice-array.js @@ -1,63 +1,52 @@ // exact-check -const QUERY = [ - 'R>', - 'primitive:slice>', - 'R>', - 'primitive:slice>', - 'R>', - 'primitive:array>', - 'primitive:array', - 'primitive:array', -]; - const EXPECTED = [ { - // R> + 'query': 'R>', 'returned': [], 'in_args': [ { 'path': 'slice_array', 'name': 'alpha' }, ], }, { - // primitive:slice> + 'query': 'primitive:slice>', 'returned': [ { 'path': 'slice_array', 'name': 'alef' }, ], 'in_args': [], }, { - // R> + 'query': 'R>', 'returned': [], 'in_args': [], }, { - // primitive:slice> + 'query': 'primitive:slice>', 'returned': [], 'in_args': [], }, { - // R> + 'query': 'R>', 'returned': [ { 'path': 'slice_array', 'name': 'bet' }, ], 'in_args': [], }, { - // primitive:array> + 'query': 'primitive:array>', 'returned': [], 'in_args': [ { 'path': 'slice_array', 'name': 'beta' }, ], }, { - // primitive::array + 'query': 'primitive:array', 'in_args': [ { 'path': 'slice_array', 'name': 'gamma' }, ], }, { - // primitive::array + 'query': 'primitive:array', 'in_args': [ { 'path': 'slice_array', 'name': 'gamma' }, ], diff --git a/tests/rustdoc-js/struct-like-variant.js b/tests/rustdoc-js/struct-like-variant.js index f6deea51e7d4d..7b9bec7aea832 100644 --- a/tests/rustdoc-js/struct-like-variant.js +++ b/tests/rustdoc-js/struct-like-variant.js @@ -1,6 +1,5 @@ -const QUERY = 'name'; - const EXPECTED = { + 'query': 'name', 'others': [ { 'path': 'struct_like_variant::Enum::Bar', 'name': 'name', 'desc': 'This is a name.' }, ], diff --git a/tests/rustdoc-js/substring.js b/tests/rustdoc-js/substring.js index af05cd1ad34d1..96efa992bb685 100644 --- a/tests/rustdoc-js/substring.js +++ b/tests/rustdoc-js/substring.js @@ -1,6 +1,5 @@ -const QUERY = 'waker_from'; - const EXPECTED = { + 'query': 'waker_from', 'others': [ { 'path': 'substring::SuperWaker', 'name': 'local_waker_from_nonlocal' }, { 'path': 'substring::SuperWakerTask', 'name': 'local_waker_from_nonlocal' }, diff --git a/tests/rustdoc-js/summaries.js b/tests/rustdoc-js/summaries.js index dfb11e80414c1..ae3aefb0c48a0 100644 --- a/tests/rustdoc-js/summaries.js +++ b/tests/rustdoc-js/summaries.js @@ -1,19 +1,20 @@ // ignore-tidy-linelength -const QUERY = ['summaries', 'summaries::Sidebar', 'summaries::Sidebar2']; - const EXPECTED = [ { + 'query': 'summaries', 'others': [ { 'path': '', 'name': 'summaries', 'desc': 'This summary has a link, [code], and Sidebar2 intra-doc.' }, ], }, { + 'query': 'summaries::Sidebar', 'others': [ { 'path': 'summaries', 'name': 'Sidebar', 'desc': 'This code will be rendered in a code tag.' }, ], }, { + 'query': 'summaries::Sidebar2', 'others': [ { 'path': 'summaries', 'name': 'Sidebar2', 'desc': '' }, ], diff --git a/tests/rustdoc-js/where-clause.js b/tests/rustdoc-js/where-clause.js index 86254a80e20f3..8dccf197be060 100644 --- a/tests/rustdoc-js/where-clause.js +++ b/tests/rustdoc-js/where-clause.js @@ -1,28 +1,31 @@ -const QUERY = ['trait', '-> trait', 't1, t2', '-> shazam', 'drizzel -> shazam']; - const EXPECTED = [ { + 'query': 'trait', 'in_args': [ { 'path': 'where_clause', 'name': 'abracadabra' }, ], }, { + 'query': '-> trait', 'others': [ { 'path': 'where_clause', 'name': 'alacazam' }, ], }, { + 'query': 't1, t2', 'others': [ { 'path': 'where_clause', 'name': 'presto' }, ], }, { + 'query': '-> shazam', 'others': [ { 'path': 'where_clause', 'name': 'bippety' }, { 'path': 'where_clause::Drizzel', 'name': 'boppety' }, ], }, { + 'query': 'drizzel -> shazam', 'others': [ { 'path': 'where_clause::Drizzel', 'name': 'boppety' }, ], From a655b4d0162694193faa16f993cb0cad5ba45d48 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Fri, 9 Jun 2023 20:10:43 +0100 Subject: [PATCH 11/13] Update cargo --- src/tools/cargo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/cargo b/src/tools/cargo index b0fa79679e717..49b6d9e179a91 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit b0fa79679e717cd077b7fc0fa4166f47107f1ba9 +Subproject commit 49b6d9e179a91cf7645142541c9563443f64bf2b From 46becfdf9c807e0108a78bb4df9b8330b10422c8 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Mon, 10 Apr 2023 14:20:38 +0300 Subject: [PATCH 12/13] expand: Change how `#![cfg(FALSE)]` behaves on crate root Previously it removed all other attributes from the crate root. Now it removes only attributes below itself. So it becomes possible to configure some global crate properties even for fully unconfigured crates. --- compiler/rustc_expand/src/config.rs | 8 +++++--- compiler/rustc_expand/src/expand.rs | 20 +++++++++++++++---- tests/ui/cfg/auxiliary/cfg_false_lib.rs | 6 ++---- .../auxiliary/cfg_false_lib_no_std_after.rs | 5 +++++ .../auxiliary/cfg_false_lib_no_std_before.rs | 8 ++++++++ tests/ui/cfg/cfg-false-feature.rs | 6 ++---- tests/ui/cfg/cfg-false-feature.stderr | 17 +++------------- tests/ui/cfg/cfg_false_no_std-1.rs | 10 ++++++++++ tests/ui/cfg/cfg_false_no_std-2.rs | 11 ++++++++++ tests/ui/cfg/cfg_false_no_std.rs | 3 +-- 10 files changed, 63 insertions(+), 31 deletions(-) create mode 100644 tests/ui/cfg/auxiliary/cfg_false_lib_no_std_after.rs create mode 100644 tests/ui/cfg/auxiliary/cfg_false_lib_no_std_before.rs create mode 100644 tests/ui/cfg/cfg_false_no_std-1.rs create mode 100644 tests/ui/cfg/cfg_false_no_std-2.rs diff --git a/compiler/rustc_expand/src/config.rs b/compiler/rustc_expand/src/config.rs index 690f80f6876e4..bcfa5313bde3a 100644 --- a/compiler/rustc_expand/src/config.rs +++ b/compiler/rustc_expand/src/config.rs @@ -197,9 +197,11 @@ pub fn pre_configure_attrs(sess: &Session, attrs: &[Attribute]) -> ast::AttrVec config_tokens: false, lint_node_id: ast::CRATE_NODE_ID, }; - let attrs: ast::AttrVec = - attrs.iter().flat_map(|attr| strip_unconfigured.process_cfg_attr(attr)).collect(); - if strip_unconfigured.in_cfg(&attrs) { attrs } else { ast::AttrVec::new() } + attrs + .iter() + .flat_map(|attr| strip_unconfigured.process_cfg_attr(attr)) + .take_while(|attr| !is_cfg(attr) || strip_unconfigured.cfg_true(attr).0) + .collect() } #[macro_export] diff --git a/compiler/rustc_expand/src/expand.rs b/compiler/rustc_expand/src/expand.rs index dd8863df1953c..9850723a857e9 100644 --- a/compiler/rustc_expand/src/expand.rs +++ b/compiler/rustc_expand/src/expand.rs @@ -1039,7 +1039,12 @@ trait InvocationCollectorNode: HasAttrs + HasNodeId + Sized { ) -> Result { Ok(noop_flat_map(node, collector)) } - fn expand_cfg_false(&mut self, collector: &mut InvocationCollector<'_, '_>, span: Span) { + fn expand_cfg_false( + &mut self, + collector: &mut InvocationCollector<'_, '_>, + _pos: usize, + span: Span, + ) { collector.cx.emit_err(RemoveNodeNotSupported { span, descr: Self::descr() }); } @@ -1409,8 +1414,15 @@ impl InvocationCollectorNode for ast::Crate { fn noop_visit(&mut self, visitor: &mut V) { noop_visit_crate(self, visitor) } - fn expand_cfg_false(&mut self, collector: &mut InvocationCollector<'_, '_>, _span: Span) { - self.attrs.clear(); + fn expand_cfg_false( + &mut self, + collector: &mut InvocationCollector<'_, '_>, + pos: usize, + _span: Span, + ) { + // Attributes above `cfg(FALSE)` are left in place, because we may want to configure + // some global crate properties even on fully unconfigured crates. + self.attrs.truncate(pos); // Standard prelude imports are left in the crate for backward compatibility. self.items.truncate(collector.cx.num_standard_library_imports); } @@ -1804,7 +1816,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> { continue; } - node.expand_cfg_false(self, span); + node.expand_cfg_false(self, pos, span); continue; } sym::cfg_attr => { diff --git a/tests/ui/cfg/auxiliary/cfg_false_lib.rs b/tests/ui/cfg/auxiliary/cfg_false_lib.rs index 3c011d72b02c5..6c2dbb44d2a40 100644 --- a/tests/ui/cfg/auxiliary/cfg_false_lib.rs +++ b/tests/ui/cfg/auxiliary/cfg_false_lib.rs @@ -1,6 +1,4 @@ -// It is unclear whether a fully unconfigured crate should link to standard library, -// or what its `no_std`/`no_core`/`compiler_builtins` status, more precisely. -// Currently the usual standard library prelude is added to such crates, -// and therefore they link to libstd. +// `#![no_std]` on a fully unconfigured crate is respected if it's placed before `cfg(FALSE)`. +// This crate has no such attribute, therefore this crate does link to libstd. #![cfg(FALSE)] diff --git a/tests/ui/cfg/auxiliary/cfg_false_lib_no_std_after.rs b/tests/ui/cfg/auxiliary/cfg_false_lib_no_std_after.rs new file mode 100644 index 0000000000000..3cfa6c510d020 --- /dev/null +++ b/tests/ui/cfg/auxiliary/cfg_false_lib_no_std_after.rs @@ -0,0 +1,5 @@ +// `#![no_std]` on a fully unconfigured crate is respected if it's placed before `cfg(FALSE)`. +// Therefore this crate does link to libstd. + +#![cfg(FALSE)] +#![no_std] diff --git a/tests/ui/cfg/auxiliary/cfg_false_lib_no_std_before.rs b/tests/ui/cfg/auxiliary/cfg_false_lib_no_std_before.rs new file mode 100644 index 0000000000000..8e89545b8f40d --- /dev/null +++ b/tests/ui/cfg/auxiliary/cfg_false_lib_no_std_before.rs @@ -0,0 +1,8 @@ +// `#![no_std]` on a fully unconfigured crate is respected if it's placed before `cfg(FALSE)`. +// Therefore this crate doesn't link to libstd. + +// no-prefer-dynamic + +#![no_std] +#![crate_type = "lib"] +#![cfg(FALSE)] diff --git a/tests/ui/cfg/cfg-false-feature.rs b/tests/ui/cfg/cfg-false-feature.rs index 21ea3ec79b4d6..84c231562f1e1 100644 --- a/tests/ui/cfg/cfg-false-feature.rs +++ b/tests/ui/cfg/cfg-false-feature.rs @@ -1,5 +1,4 @@ -// It is unclear which features should be in effect in a fully unconfigured crate (issue #104633). -// Currently none on the features are in effect, so we get the feature gates reported. +// Features above `cfg(FALSE)` are in effect in a fully unconfigured crate (issue #104633). // check-pass // compile-flags: --crate-type lib @@ -8,8 +7,7 @@ #![cfg(FALSE)] #![feature(box_syntax)] -macro mac() {} //~ WARN `macro` is experimental - //~| WARN unstable syntax can change at any point in the future +macro mac() {} // OK trait A = Clone; //~ WARN trait aliases are experimental //~| WARN unstable syntax can change at any point in the future diff --git a/tests/ui/cfg/cfg-false-feature.stderr b/tests/ui/cfg/cfg-false-feature.stderr index 14673fbdb1444..34093036205fe 100644 --- a/tests/ui/cfg/cfg-false-feature.stderr +++ b/tests/ui/cfg/cfg-false-feature.stderr @@ -1,5 +1,5 @@ warning: trait aliases are experimental - --> $DIR/cfg-false-feature.rs:14:1 + --> $DIR/cfg-false-feature.rs:12:1 | LL | trait A = Clone; | ^^^^^^^^^^^^^^^^ @@ -9,19 +9,8 @@ LL | trait A = Clone; = warning: unstable syntax can change at any point in the future, causing a hard error! = note: for more information, see issue #65860 -warning: `macro` is experimental - --> $DIR/cfg-false-feature.rs:11:1 - | -LL | macro mac() {} - | ^^^^^^^^^^^^^^ - | - = note: see issue #39412 for more information - = help: add `#![feature(decl_macro)]` to the crate attributes to enable - = warning: unstable syntax can change at any point in the future, causing a hard error! - = note: for more information, see issue #65860 - warning: box pattern syntax is experimental - --> $DIR/cfg-false-feature.rs:18:9 + --> $DIR/cfg-false-feature.rs:16:9 | LL | let box _ = Box::new(0); | ^^^^^ @@ -31,5 +20,5 @@ LL | let box _ = Box::new(0); = warning: unstable syntax can change at any point in the future, causing a hard error! = note: for more information, see issue #65860 -warning: 3 warnings emitted +warning: 2 warnings emitted diff --git a/tests/ui/cfg/cfg_false_no_std-1.rs b/tests/ui/cfg/cfg_false_no_std-1.rs new file mode 100644 index 0000000000000..bcb49e5135364 --- /dev/null +++ b/tests/ui/cfg/cfg_false_no_std-1.rs @@ -0,0 +1,10 @@ +// No error, panic handler is supplied by libstd linked though the empty library. + +// check-pass +// aux-build: cfg_false_lib_no_std_after.rs + +#![no_std] + +extern crate cfg_false_lib_no_std_after as _; + +fn main() {} diff --git a/tests/ui/cfg/cfg_false_no_std-2.rs b/tests/ui/cfg/cfg_false_no_std-2.rs new file mode 100644 index 0000000000000..0a2bfd5f68b12 --- /dev/null +++ b/tests/ui/cfg/cfg_false_no_std-2.rs @@ -0,0 +1,11 @@ +// Error, the linked empty library is `no_std` and doesn't provide a panic handler. + +// dont-check-compiler-stderr +// error-pattern: `#[panic_handler]` function required, but not found +// aux-build: cfg_false_lib_no_std_before.rs + +#![no_std] + +extern crate cfg_false_lib_no_std_before as _; + +fn main() {} diff --git a/tests/ui/cfg/cfg_false_no_std.rs b/tests/ui/cfg/cfg_false_no_std.rs index 319ea078187c2..4fa831715ede1 100644 --- a/tests/ui/cfg/cfg_false_no_std.rs +++ b/tests/ui/cfg/cfg_false_no_std.rs @@ -1,5 +1,4 @@ -// Currently no error because the panic handler is supplied by libstd linked though the empty -// library, but the desirable behavior is unclear (see comments in cfg_false_lib.rs). +// No error, panic handler is supplied by libstd linked though the empty library. // check-pass // aux-build: cfg_false_lib.rs From 3152ac34bd36bd3b4e580f65f4c95b964fbfe34b Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Fri, 9 Jun 2023 21:56:16 +0000 Subject: [PATCH 13/13] Ignore tests that hang in new solver --- .../ui/closures/issue-72408-nested-closures-exponential.rs | 1 + .../ui/issues/issue-37311-type-length-limit/issue-37311.rs | 1 + .../issues/issue-37311-type-length-limit/issue-37311.stderr | 4 ++-- tests/ui/iterators/issue-58952-filter-type-length.rs | 2 ++ tests/ui/recursion/issue-83150.rs | 1 + tests/ui/recursion/issue-83150.stderr | 6 +++--- tests/ui/traits/issue-91949-hangs-on-recursion.rs | 1 + tests/ui/traits/issue-91949-hangs-on-recursion.stderr | 4 ++-- 8 files changed, 13 insertions(+), 7 deletions(-) diff --git a/tests/ui/closures/issue-72408-nested-closures-exponential.rs b/tests/ui/closures/issue-72408-nested-closures-exponential.rs index 2d6ba936572d5..d064ebceffd5c 100644 --- a/tests/ui/closures/issue-72408-nested-closures-exponential.rs +++ b/tests/ui/closures/issue-72408-nested-closures-exponential.rs @@ -1,4 +1,5 @@ // build-pass +// ignore-compare-mode-next-solver (hangs) // Closures include captured types twice in a type tree. // diff --git a/tests/ui/issues/issue-37311-type-length-limit/issue-37311.rs b/tests/ui/issues/issue-37311-type-length-limit/issue-37311.rs index 50d1f166c9865..c109be005238f 100644 --- a/tests/ui/issues/issue-37311-type-length-limit/issue-37311.rs +++ b/tests/ui/issues/issue-37311-type-length-limit/issue-37311.rs @@ -1,5 +1,6 @@ // build-fail // normalize-stderr-test: ".nll/" -> "/" +// ignore-compare-mode-next-solver (hangs) trait Mirror { type Image; diff --git a/tests/ui/issues/issue-37311-type-length-limit/issue-37311.stderr b/tests/ui/issues/issue-37311-type-length-limit/issue-37311.stderr index 5b8299fe839d7..87832dd29b284 100644 --- a/tests/ui/issues/issue-37311-type-length-limit/issue-37311.stderr +++ b/tests/ui/issues/issue-37311-type-length-limit/issue-37311.stderr @@ -1,11 +1,11 @@ error: reached the recursion limit while instantiating `<(&(&(..., ...), ...), ...) as Foo>::recurse` - --> $DIR/issue-37311.rs:17:9 + --> $DIR/issue-37311.rs:18:9 | LL | (self, self).recurse(); | ^^^^^^^^^^^^^^^^^^^^^^ | note: `::recurse` defined here - --> $DIR/issue-37311.rs:16:5 + --> $DIR/issue-37311.rs:17:5 | LL | fn recurse(&self) { | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/iterators/issue-58952-filter-type-length.rs b/tests/ui/iterators/issue-58952-filter-type-length.rs index 6d12db8d13730..8e9cc84ec0339 100644 --- a/tests/ui/iterators/issue-58952-filter-type-length.rs +++ b/tests/ui/iterators/issue-58952-filter-type-length.rs @@ -1,4 +1,6 @@ // run-pass +// ignore-compare-mode-next-solver (hangs) + //! This snippet causes the type length to blowup exponentially, //! so check that we don't accidentally exceed the type length limit. // FIXME: Once the size of iterator adaptors is further reduced, diff --git a/tests/ui/recursion/issue-83150.rs b/tests/ui/recursion/issue-83150.rs index 38353d161c133..75dcdc59f21c1 100644 --- a/tests/ui/recursion/issue-83150.rs +++ b/tests/ui/recursion/issue-83150.rs @@ -2,6 +2,7 @@ // compile-flags: -Copt-level=0 // normalize-stderr-test: "long-type-\d+" -> "long-type-hash" //~^^^ ERROR overflow evaluating the requirement +// ignore-compare-mode-next-solver (hangs) fn main() { let mut iter = 0u8..1; diff --git a/tests/ui/recursion/issue-83150.stderr b/tests/ui/recursion/issue-83150.stderr index 64683ae3a6ebd..eae58771a4169 100644 --- a/tests/ui/recursion/issue-83150.stderr +++ b/tests/ui/recursion/issue-83150.stderr @@ -1,5 +1,5 @@ warning: function cannot return without recursing - --> $DIR/issue-83150.rs:11:1 + --> $DIR/issue-83150.rs:12:1 | LL | fn func>(iter: &mut T) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing @@ -9,10 +9,10 @@ LL | func(&mut iter.map(|x| x + 1)) = help: a `loop` may express intention better if this is on purpose = note: `#[warn(unconditional_recursion)]` on by default -error[E0275]: overflow evaluating the requirement `Map<&mut std::ops::Range, [closure@$DIR/issue-83150.rs:12:24: 12:27]>: Iterator` +error[E0275]: overflow evaluating the requirement `Map<&mut std::ops::Range, [closure@$DIR/issue-83150.rs:13:24: 13:27]>: Iterator` | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_83150`) - = note: required for `&mut Map<&mut std::ops::Range, [closure@$DIR/issue-83150.rs:12:24: 12:27]>` to implement `Iterator` + = note: required for `&mut Map<&mut std::ops::Range, [closure@$DIR/issue-83150.rs:13:24: 13:27]>` to implement `Iterator` = note: 65 redundant requirements hidden = note: required for `&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<..., ...>, ...>, ...>, ...>, ...>, ...>, ...>` to implement `Iterator` = note: the full type name has been written to '$TEST_BUILD_DIR/recursion/issue-83150/issue-83150.long-type-hash.txt' diff --git a/tests/ui/traits/issue-91949-hangs-on-recursion.rs b/tests/ui/traits/issue-91949-hangs-on-recursion.rs index 4eca643a92d4c..312d5d08c7df8 100644 --- a/tests/ui/traits/issue-91949-hangs-on-recursion.rs +++ b/tests/ui/traits/issue-91949-hangs-on-recursion.rs @@ -3,6 +3,7 @@ // error-pattern: overflow evaluating the requirement ` as Iterator>::Item == ()` // error-pattern: function cannot return without recursing // normalize-stderr-test: "long-type-\d+" -> "long-type-hash" +// ignore-compare-mode-next-solver (hangs) // Regression test for #91949. // This hanged *forever* on 1.56, fixed by #90423. diff --git a/tests/ui/traits/issue-91949-hangs-on-recursion.stderr b/tests/ui/traits/issue-91949-hangs-on-recursion.stderr index 144990d50f000..c721dd41a2c15 100644 --- a/tests/ui/traits/issue-91949-hangs-on-recursion.stderr +++ b/tests/ui/traits/issue-91949-hangs-on-recursion.stderr @@ -1,5 +1,5 @@ warning: function cannot return without recursing - --> $DIR/issue-91949-hangs-on-recursion.rs:23:1 + --> $DIR/issue-91949-hangs-on-recursion.rs:24:1 | LL | / fn recurse(elements: T) -> Vec LL | | where @@ -16,7 +16,7 @@ error[E0275]: overflow evaluating the requirement ` as Iter | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "512"]` attribute to your crate (`issue_91949_hangs_on_recursion`) note: required for `IteratorOfWrapped<(), std::iter::Empty<()>>` to implement `Iterator` - --> $DIR/issue-91949-hangs-on-recursion.rs:16:32 + --> $DIR/issue-91949-hangs-on-recursion.rs:17:32 | LL | impl> Iterator for IteratorOfWrapped { | -------- ^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^