From 2ea9e04bf71e85746453b26d3bebe4d0400b7421 Mon Sep 17 00:00:00 2001 From: nzrq <42440961+nzrq@users.noreply.github.com> Date: Fri, 3 Jun 2022 13:05:57 -0400 Subject: [PATCH 01/11] Add note to documentation of HashSet::intersection --- library/std/src/collections/hash/set.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/library/std/src/collections/hash/set.rs b/library/std/src/collections/hash/set.rs index 19428fe9a2339..6ca4b7fa2d9ed 100644 --- a/library/std/src/collections/hash/set.rs +++ b/library/std/src/collections/hash/set.rs @@ -588,6 +588,13 @@ where /// Visits the values representing the intersection, /// i.e., the values that are both in `self` and `other`. /// + /// Note: this operation does not guarantee which collection + /// is visited from `self` or `other`. This has consequences + /// for values which may be defined as equal by the `Eq` trait + /// but which are not physically equivalent (eg. they may have + /// fields which differ or do not participate in the definition + /// of equivalence). + /// /// # Examples /// /// ``` From fdd8b6229e3fea8d29c2262a123df05123797040 Mon Sep 17 00:00:00 2001 From: nzrq <42440961+nzrq@users.noreply.github.com> Date: Fri, 3 Jun 2022 17:34:15 -0400 Subject: [PATCH 02/11] Update set.rs --- library/std/src/collections/hash/set.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/library/std/src/collections/hash/set.rs b/library/std/src/collections/hash/set.rs index 6ca4b7fa2d9ed..de1431b1dba39 100644 --- a/library/std/src/collections/hash/set.rs +++ b/library/std/src/collections/hash/set.rs @@ -588,12 +588,10 @@ where /// Visits the values representing the intersection, /// i.e., the values that are both in `self` and `other`. /// - /// Note: this operation does not guarantee which collection - /// is visited from `self` or `other`. This has consequences - /// for values which may be defined as equal by the `Eq` trait - /// but which are not physically equivalent (eg. they may have - /// fields which differ or do not participate in the definition - /// of equivalence). + /// Note: When an equal element is present in `self` and `other` + /// then the resulting `Intersection` may yield references to + /// one or the other, which will be visible in properties of `T` + /// not participating in the `Eq` implementation. /// /// # Examples /// From fc4e8c7f0d4611a4fce40b0e991c03fbe349af04 Mon Sep 17 00:00:00 2001 From: nzrq <42440961+nzrq@users.noreply.github.com> Date: Sat, 4 Jun 2022 20:03:55 -0400 Subject: [PATCH 03/11] Update library/std/src/collections/hash/set.rs Co-authored-by: David Tolnay --- library/std/src/collections/hash/set.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/collections/hash/set.rs b/library/std/src/collections/hash/set.rs index de1431b1dba39..0a0c08eb1e9f2 100644 --- a/library/std/src/collections/hash/set.rs +++ b/library/std/src/collections/hash/set.rs @@ -588,7 +588,7 @@ where /// Visits the values representing the intersection, /// i.e., the values that are both in `self` and `other`. /// - /// Note: When an equal element is present in `self` and `other` + /// When an equal element is present in `self` and `other` /// then the resulting `Intersection` may yield references to /// one or the other, which will be visible in properties of `T` /// not participating in the `Eq` implementation. From 116eec247afd46d124242fbb8e563d6fccc5f96e Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 6 Jun 2022 13:57:54 +0200 Subject: [PATCH 04/11] Add "no-confusing-arrow" eslint check --- src/librustdoc/html/static/.eslintrc.js | 1 + src/librustdoc/html/static/js/main.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/html/static/.eslintrc.js b/src/librustdoc/html/static/.eslintrc.js index bd83b254caacb..6700369aa7aab 100644 --- a/src/librustdoc/html/static/.eslintrc.js +++ b/src/librustdoc/html/static/.eslintrc.js @@ -78,5 +78,6 @@ module.exports = { "block-scoped-var": "error", "guard-for-in": "error", "no-alert": "error", + "no-confusing-arrow": "error", } }; diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index 548aeedd03384..414bca850e3dc 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -882,7 +882,7 @@ function loadCss(cssFileName) { ["-", "Collapse all sections"], ].map(x => "
" + x[0].split(" ") - .map((y, index) => (index & 1) === 0 ? "" + y + "" : " " + y + " ") + .map((y, index) => ((index & 1) === 0 ? "" + y + "" : " " + y + " ")) .join("") + "
" + x[1] + "
").join(""); const div_shortcuts = document.createElement("div"); addClass(div_shortcuts, "shortcuts"); From 0e66868138f9461edcb4de273792193d19d3f4b2 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 6 Jun 2022 13:58:53 +0200 Subject: [PATCH 05/11] Add "no-div-regex" eslint check --- src/librustdoc/html/static/.eslintrc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/librustdoc/html/static/.eslintrc.js b/src/librustdoc/html/static/.eslintrc.js index 6700369aa7aab..0d72aadbce142 100644 --- a/src/librustdoc/html/static/.eslintrc.js +++ b/src/librustdoc/html/static/.eslintrc.js @@ -79,5 +79,6 @@ module.exports = { "guard-for-in": "error", "no-alert": "error", "no-confusing-arrow": "error", + "no-div-regex": "error", } }; From b48bbd4e2f6c29493174f721850ff47379a1c982 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 6 Jun 2022 14:00:43 +0200 Subject: [PATCH 06/11] Add "no-floating-decimal" eslint check --- src/librustdoc/html/static/.eslintrc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/librustdoc/html/static/.eslintrc.js b/src/librustdoc/html/static/.eslintrc.js index 0d72aadbce142..2ffcbb8259114 100644 --- a/src/librustdoc/html/static/.eslintrc.js +++ b/src/librustdoc/html/static/.eslintrc.js @@ -80,5 +80,6 @@ module.exports = { "no-alert": "error", "no-confusing-arrow": "error", "no-div-regex": "error", + "no-floating-decimal": "error", } }; From b827847d1936ab1fae2dd002659dca736e084c2d Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 6 Jun 2022 14:01:52 +0200 Subject: [PATCH 07/11] Add "no-implicit-globals" eslint check --- src/librustdoc/html/static/.eslintrc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/librustdoc/html/static/.eslintrc.js b/src/librustdoc/html/static/.eslintrc.js index 2ffcbb8259114..d6e96bd71e43a 100644 --- a/src/librustdoc/html/static/.eslintrc.js +++ b/src/librustdoc/html/static/.eslintrc.js @@ -81,5 +81,6 @@ module.exports = { "no-confusing-arrow": "error", "no-div-regex": "error", "no-floating-decimal": "error", + "no-implicit-globals": "error", } }; From d0909bdddc95558ae55f551eb1ae9c6fd825ee61 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 6 Jun 2022 14:02:37 +0200 Subject: [PATCH 08/11] Add "no-implied-eval" eslint check --- src/librustdoc/html/static/.eslintrc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/librustdoc/html/static/.eslintrc.js b/src/librustdoc/html/static/.eslintrc.js index d6e96bd71e43a..10c79a2042ae1 100644 --- a/src/librustdoc/html/static/.eslintrc.js +++ b/src/librustdoc/html/static/.eslintrc.js @@ -82,5 +82,6 @@ module.exports = { "no-div-regex": "error", "no-floating-decimal": "error", "no-implicit-globals": "error", + "no-implied-eval": "error", } }; From cd5e73be3f10e78fb603f7dd3c673e4959f0bed0 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 6 Jun 2022 14:03:26 +0200 Subject: [PATCH 09/11] Add "no-label-var" eslint check --- src/librustdoc/html/static/.eslintrc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/librustdoc/html/static/.eslintrc.js b/src/librustdoc/html/static/.eslintrc.js index 10c79a2042ae1..9088e06e50803 100644 --- a/src/librustdoc/html/static/.eslintrc.js +++ b/src/librustdoc/html/static/.eslintrc.js @@ -83,5 +83,6 @@ module.exports = { "no-floating-decimal": "error", "no-implicit-globals": "error", "no-implied-eval": "error", + "no-label-var": "error", } }; From 0664bd8b2ab0ea25d6db69de28544820adc34ed9 Mon Sep 17 00:00:00 2001 From: Ikko Ashimine Date: Mon, 6 Jun 2022 21:16:31 +0900 Subject: [PATCH 10/11] Fix typo in redundant_pattern_match.rs alway -> always --- .../clippy/clippy_lints/src/matches/redundant_pattern_match.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/clippy/clippy_lints/src/matches/redundant_pattern_match.rs b/src/tools/clippy/clippy_lints/src/matches/redundant_pattern_match.rs index 1a8b9d15f370f..b1728b0ae18ca 100644 --- a/src/tools/clippy/clippy_lints/src/matches/redundant_pattern_match.rs +++ b/src/tools/clippy/clippy_lints/src/matches/redundant_pattern_match.rs @@ -68,7 +68,7 @@ fn temporaries_need_ordered_drop<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr< } } }, - // the base type is alway taken by reference. + // the base type is always taken by reference. // e.g. In `(vec![0])[0]` the vector is a temporary value. ExprKind::Index(base, index) => { if !matches!(base.kind, ExprKind::Path(_)) { From 7d114c7713537af3a1f67c15a67473e6f3f5a509 Mon Sep 17 00:00:00 2001 From: nzrq <42440961+nzrq@users.noreply.github.com> Date: Mon, 6 Jun 2022 17:14:58 -0400 Subject: [PATCH 11/11] Apply suggestions from code review Co-authored-by: David Tolnay --- library/std/src/collections/hash/set.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/library/std/src/collections/hash/set.rs b/library/std/src/collections/hash/set.rs index 0a0c08eb1e9f2..fa498a987d6af 100644 --- a/library/std/src/collections/hash/set.rs +++ b/library/std/src/collections/hash/set.rs @@ -590,8 +590,9 @@ where /// /// When an equal element is present in `self` and `other` /// then the resulting `Intersection` may yield references to - /// one or the other, which will be visible in properties of `T` - /// not participating in the `Eq` implementation. + /// one or the other. This can be relevant if `T` contains fields which + /// are not compared by its `Eq` implementation, and may hold different + /// value between the two equal copies of `T` in the two sets. /// /// # Examples ///