From e3aba17ef1e070dd55a8d0f73cc53fa6480fddca Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Tue, 24 Mar 2026 20:23:48 -0700 Subject: [PATCH 01/12] Add a `sealed::Sealed` trait to `core`, like that in `std` This allows traits in `core` to be sealed as well. This could be the same trait as `std` via a re-export, but that would require `core::sealed` to be `pub` (even if unstable). Keep them as separate traits for now. --- library/core/src/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 35f93d8fb33b2..e0750f0784458 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -110,6 +110,7 @@ #![feature(offset_of_enum)] #![feature(panic_internals)] #![feature(pattern_type_macro)] +#![feature(sealed)] #![feature(ub_checks)] // tidy-alphabetical-end // @@ -216,6 +217,14 @@ pub mod from { pub use crate::macros::builtin::From; } +mod sealed { + /// This trait being unreachable from outside the crate + /// prevents outside implementations of our extension traits. + /// This allows adding more trait methods in the future. + #[unstable(feature = "sealed", issue = "none")] + pub trait Sealed {} +} + // We don't export this through #[macro_export] for now, to avoid breakage. #[unstable(feature = "autodiff", issue = "124509")] /// Unstable module containing the unstable `autodiff` macro. From 0f6ad8d7ad8aecd3fc7508c95ebad1378e7fad0f Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Tue, 24 Mar 2026 20:23:58 -0700 Subject: [PATCH 02/12] Implement `core::sealed::Sealed` for all numeric types --- library/core/src/num/mod.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/library/core/src/num/mod.rs b/library/core/src/num/mod.rs index 333e44649d8f6..92ae19460532c 100644 --- a/library/core/src/num/mod.rs +++ b/library/core/src/num/mod.rs @@ -1795,3 +1795,12 @@ macro_rules! from_str_int_impl { from_str_int_impl! { signed isize i8 i16 i32 i64 i128 } from_str_int_impl! { unsigned usize u8 u16 u32 u64 u128 } + +macro_rules! impl_sealed { + ($($t:ty)*) => {$( + /// Allows extension traits within `core`. + #[unstable(feature = "sealed", issue = "none")] + impl crate::sealed::Sealed for $t {} + )*} +} +impl_sealed! { isize i8 i16 i32 i64 i128 usize u8 u16 u32 u64 u128 } From f0c7cd28b8d8eb7f9a1bb48df1a0f9c049af5677 Mon Sep 17 00:00:00 2001 From: binarycat Date: Tue, 31 Mar 2026 09:37:01 -0500 Subject: [PATCH 03/12] build_helper: fix yarn locking, add check, and bump lockfile --- src/build_helper/src/npm.rs | 12 ++- yarn.lock | 174 ++++++++++++++++-------------------- 2 files changed, 85 insertions(+), 101 deletions(-) diff --git a/src/build_helper/src/npm.rs b/src/build_helper/src/npm.rs index 2a558b5618b3d..311bf8d8176e7 100644 --- a/src/build_helper/src/npm.rs +++ b/src/build_helper/src/npm.rs @@ -1,7 +1,7 @@ use std::error::Error; use std::path::{Path, PathBuf}; use std::process::Command; -use std::{fs, io}; +use std::{env, fs, io}; /// Install all the npm deps, and return the path of `node_modules`. pub fn install(src_root_path: &Path, out_dir: &Path, yarn: &Path) -> Result { @@ -19,7 +19,7 @@ pub fn install(src_root_path: &Path, out_dir: &Path, yarn: &Path) -> Result Result::from(format!( + "yarn lockfile was modified despite --frozen-lockfile. please file a bug report. this check can be bypassed by setting $BOOTSTRAP_SKIP_YARN_LOCK_CHECK`" + )))); + } Ok(nm_path) } diff --git a/yarn.lock b/yarn.lock index 89380ba693bc9..22149b09682b9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -102,18 +102,17 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" -"@puppeteer/browsers@2.3.0": - version "2.3.0" - resolved "https://registry.yarnpkg.com/@puppeteer/browsers/-/browsers-2.3.0.tgz#791ea7d80450fea24eb19fb1d70c367ad4e08cae" - integrity sha512-ioXoq9gPxkss4MYhD+SFaU9p1IHFUX0ILAWFPyjGaBdjLsYAlZw6j1iLA0N/m12uVHLFDfSYNF7EQccjinIMDA== +"@puppeteer/browsers@2.13.0": + version "2.13.0" + resolved "https://registry.yarnpkg.com/@puppeteer/browsers/-/browsers-2.13.0.tgz#10f980c6d65efeff77f8a3cac6e1a7ac10604500" + integrity sha512-46BZJYJjc/WwmKjsvDFykHtXrtomsCIrwYQPOP7VfMJoZY2bsDF9oROBABR3paDjDcmkUye1Pb1BqdcdiipaWA== dependencies: - debug "^4.3.5" + debug "^4.4.3" extract-zip "^2.0.1" progress "^2.0.3" - proxy-agent "^6.4.0" - semver "^7.6.3" - tar-fs "^3.0.6" - unbzip2-stream "^1.4.3" + proxy-agent "^6.5.0" + semver "^7.7.4" + tar-fs "^3.1.1" yargs "^17.7.2" "@so-ric/colorspace@^1.1.6": @@ -266,11 +265,6 @@ bare-url@^2.2.2: dependencies: bare-path "^3.0.0" -base64-js@^1.3.1: - version "1.5.1" - resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" - integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== - baseline-browser-mapping@^2.8.19: version "2.8.25" resolved "https://registry.yarnpkg.com/baseline-browser-mapping/-/baseline-browser-mapping-2.8.25.tgz#947dc6f81778e0fa0424a2ab9ea09a3033e71109" @@ -296,14 +290,14 @@ braces@^3.0.3: dependencies: fill-range "^7.1.1" -browser-ui-test@^0.22.2: - version "0.22.3" - resolved "https://registry.yarnpkg.com/browser-ui-test/-/browser-ui-test-0.22.3.tgz#83a3dccc93b738887f555d52aae64cb2b7885d66" - integrity sha512-y3TmrJ146stGQ4+Pk6I8Erxb1Uj5kzIPGGoWJmK9V73Kv9L+u0L4yjW5/4pNszFCy07FqC9FxQvOAL+/4RTorg== +browser-ui-test@^0.23.3: + version "0.23.3" + resolved "https://registry.yarnpkg.com/browser-ui-test/-/browser-ui-test-0.23.3.tgz#fe3b978cfe43d09ee9edd4b9d939a936dd654c30" + integrity sha512-VWiRH7sSwpnQSe1Rll5iOPS+IeFa1rMThCXrP5Pwspm95OOA8Wylv2B6yqreEw25DE3qPmgJUeZZC7Uh9wnjSg== dependencies: css-unit-converter "^1.1.2" pngjs "^3.4.0" - puppeteer "^22.15.0" + puppeteer "^24.31.0" readline-sync "^1.4.10" browserslist@^4.23.3: @@ -322,14 +316,6 @@ buffer-crc32@~0.2.3: resolved "https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242" integrity sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ== -buffer@^5.2.1: - version "5.7.1" - resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0" - integrity sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ== - dependencies: - base64-js "^1.3.1" - ieee754 "^1.1.13" - callsites@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" @@ -348,14 +334,13 @@ chalk@^4.0.0: ansi-styles "^4.1.0" supports-color "^7.1.0" -chromium-bidi@0.6.3: - version "0.6.3" - resolved "https://registry.yarnpkg.com/chromium-bidi/-/chromium-bidi-0.6.3.tgz#363fe1ca6b9c6122b9f1b2a47f9449ecf712f755" - integrity sha512-qXlsCmpCZJAnoTYI83Iu6EdYQpMYdVkCfq08KDh2pmlVqK5t5IA9mGs4/LwCwp4fqisSOMXZxP3HIh8w8aRn0A== +chromium-bidi@14.0.0: + version "14.0.0" + resolved "https://registry.yarnpkg.com/chromium-bidi/-/chromium-bidi-14.0.0.tgz#15a12ab083ae519a49a724e94994ca0a9ced9c8e" + integrity sha512-9gYlLtS6tStdRWzrtXaTMnqcM4dudNegMXJxkR0I/CXObHalYeYcAMPrL19eroNZHtJ8DQmu1E+ZNOYu/IXMXw== dependencies: - mitt "3.0.1" - urlpattern-polyfill "10.0.0" - zod "3.23.8" + mitt "^3.0.1" + zod "^3.24.1" cliui@^8.0.1: version "8.0.1" @@ -444,7 +429,7 @@ data-uri-to-buffer@^6.0.2: resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-6.0.2.tgz#8a58bb67384b261a38ef18bea1810cb01badd28b" integrity sha512-7hvf7/GW8e86rW0ptuwS3OcBGDjIi6SZva7hCyWC0yYry2cOPmLIjXAUHI6DK2HsnwJd9ifmt57i8eV2n4YNpw== -debug@4, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.4, debug@^4.3.5, debug@^4.3.6: +debug@4, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.4, debug@^4.4.3: version "4.4.3" resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.3.tgz#c6ae432d9bd9662582fce08709b038c58e9e3d6a" integrity sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA== @@ -465,10 +450,10 @@ degenerator@^5.0.0: escodegen "^2.1.0" esprima "^4.0.1" -devtools-protocol@0.0.1312386: - version "0.0.1312386" - resolved "https://registry.yarnpkg.com/devtools-protocol/-/devtools-protocol-0.0.1312386.tgz#5ab824d6f1669ec6c6eb0fba047e73601d969052" - integrity sha512-DPnhUXvmvKT2dFA/j7B+riVLUt9Q6RKJlcppojL5CoRywJJKLDYnRlw0gTFKfgDPHP5E04UoB71SxoJlVZy8FA== +devtools-protocol@0.0.1581282: + version "0.0.1581282" + resolved "https://registry.yarnpkg.com/devtools-protocol/-/devtools-protocol-0.0.1581282.tgz#7f289b837e052ad04eb16e9575877801c2b3716c" + integrity sha512-nv7iKtNZQshSW2hKzYNr46nM/Cfh5SEvE2oV0/SEGgc9XupIY5ggf84Cz8eJIkBce7S3bmTAauFD6aysMpnqsQ== doctrine@^3.0.0: version "3.0.0" @@ -842,11 +827,6 @@ https-proxy-agent@^7.0.6: agent-base "^7.1.2" debug "4" -ieee754@^1.1.13: - version "1.2.1" - resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" - integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== - ignore@^5.2.0: version "5.3.2" resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.3.2.tgz#3cd40e729f3643fd87cb04e50bf0eb722bc596f5" @@ -1036,7 +1016,7 @@ minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2: dependencies: brace-expansion "^1.1.7" -mitt@3.0.1: +mitt@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/mitt/-/mitt-3.0.1.tgz#ea36cf0cc30403601ae074c8f77b7092cdab36d1" integrity sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw== @@ -1185,7 +1165,7 @@ progress@^2.0.3: resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== -proxy-agent@^6.4.0: +proxy-agent@^6.5.0: version "6.5.0" resolved "https://registry.yarnpkg.com/proxy-agent/-/proxy-agent-6.5.0.tgz#9e49acba8e4ee234aacb539f89ed9c23d02f232d" integrity sha512-TmatMXdr2KlRiA2CyDu8GqR8EjahTG3aY3nXjdzFyoZbmB8hrBsTyMezhULIXKnC0jpfjlmiZ3+EaCzoInSu/A== @@ -1217,26 +1197,30 @@ punycode@^2.1.0: resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5" integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg== -puppeteer-core@22.15.0: - version "22.15.0" - resolved "https://registry.yarnpkg.com/puppeteer-core/-/puppeteer-core-22.15.0.tgz#c76926cce5dbc177572797a9dacc325c313fa91a" - integrity sha512-cHArnywCiAAVXa3t4GGL2vttNxh7GqXtIYGym99egkNJ3oG//wL9LkvO4WE8W1TJe95t1F1ocu9X4xWaGsOKOA== - dependencies: - "@puppeteer/browsers" "2.3.0" - chromium-bidi "0.6.3" - debug "^4.3.6" - devtools-protocol "0.0.1312386" - ws "^8.18.0" - -puppeteer@^22.15.0: - version "22.15.0" - resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-22.15.0.tgz#4f842087090f1d9017ce947512e7baff55a10e75" - integrity sha512-XjCY1SiSEi1T7iSYuxS82ft85kwDJUS7wj1Z0eGVXKdtr5g4xnVcbjwxhq5xBnpK/E7x1VZZoJDxpjAOasHT4Q== - dependencies: - "@puppeteer/browsers" "2.3.0" +puppeteer-core@24.40.0: + version "24.40.0" + resolved "https://registry.yarnpkg.com/puppeteer-core/-/puppeteer-core-24.40.0.tgz#1f389cd9432cb077f703ca2cb6758490cdccbc7e" + integrity sha512-MWL3XbUCfVgGR0gRsidzT6oKJT2QydPLhMITU6HoVWiiv4gkb6gJi3pcdAa8q4HwjBTbqISOWVP4aJiiyUJvag== + dependencies: + "@puppeteer/browsers" "2.13.0" + chromium-bidi "14.0.0" + debug "^4.4.3" + devtools-protocol "0.0.1581282" + typed-query-selector "^2.12.1" + webdriver-bidi-protocol "0.4.1" + ws "^8.19.0" + +puppeteer@^24.31.0: + version "24.40.0" + resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-24.40.0.tgz#6df6aeee9dabf29bed3bb2be5c209d00518d4a79" + integrity sha512-IxQbDq93XHVVLWHrAkFP7F7iHvb9o0mgfsSIMlhHb+JM+JjM1V4v4MNSQfcRWJopx9dsNOr9adYv0U5fm9BJBQ== + dependencies: + "@puppeteer/browsers" "2.13.0" + chromium-bidi "14.0.0" cosmiconfig "^9.0.0" - devtools-protocol "0.0.1312386" - puppeteer-core "22.15.0" + devtools-protocol "0.0.1581282" + puppeteer-core "24.40.0" + typed-query-selector "^2.12.1" queue-microtask@^1.2.2: version "1.2.3" @@ -1296,10 +1280,10 @@ safe-stable-stringify@^2.3.1: resolved "https://registry.yarnpkg.com/safe-stable-stringify/-/safe-stable-stringify-2.5.0.tgz#4ca2f8e385f2831c432a719b108a3bf7af42a1dd" integrity sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA== -semver@^7.6.3: - version "7.7.3" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.7.3.tgz#4b5f4143d007633a8dc671cd0a6ef9147b8bb946" - integrity sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q== +semver@^7.7.4: + version "7.7.4" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.7.4.tgz#28464e36060e991fa7a11d0279d2d3f3b57a7e8a" + integrity sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA== shebang-command@^2.0.0: version "2.0.0" @@ -1401,10 +1385,10 @@ supports-color@^7.1.0: dependencies: has-flag "^4.0.0" -tar-fs@^3.0.6: - version "3.1.1" - resolved "https://registry.yarnpkg.com/tar-fs/-/tar-fs-3.1.1.tgz#4f164e59fb60f103d472360731e8c6bb4a7fe9ef" - integrity sha512-LZA0oaPOc2fVo82Txf3gw+AkEd38szODlptMYejQUhndHMLQ9M059uXR+AfS7DNo0NpINvSqDsvyaCrBVkptWg== +tar-fs@^3.1.1: + version "3.1.2" + resolved "https://registry.yarnpkg.com/tar-fs/-/tar-fs-3.1.2.tgz#114b012f54796f31e62f3e57792820a80b83ae6e" + integrity sha512-QGxxTxxyleAdyM3kpFs14ymbYmNFrfY+pHj7Z8FgtbZ7w2//VAgLMac7sT6nRpIHjppXO2AwwEOg0bPFVRcmXw== dependencies: pump "^3.0.0" tar-stream "^3.1.5" @@ -1438,11 +1422,6 @@ text-table@^0.2.0: resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" integrity sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw== -through@^2.3.8: - version "2.3.8" - resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" - integrity sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg== - to-regex-range@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" @@ -1472,19 +1451,16 @@ type-fest@^0.20.2: resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4" integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ== +typed-query-selector@^2.12.1: + version "2.12.1" + resolved "https://registry.yarnpkg.com/typed-query-selector/-/typed-query-selector-2.12.1.tgz#04423bfb71b8f3aee3df1c29598ed6c7c8f55284" + integrity sha512-uzR+FzI8qrUEIu96oaeBJmd9E7CFEiQ3goA5qCVgc4s5llSubcfGHq9yUstZx/k4s9dXHVKsE35YWoFyvEqEHA== + typescript@^5.8.3: version "5.9.3" resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.9.3.tgz#5b4f59e15310ab17a216f5d6cf53ee476ede670f" integrity sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw== -unbzip2-stream@^1.4.3: - version "1.4.3" - resolved "https://registry.yarnpkg.com/unbzip2-stream/-/unbzip2-stream-1.4.3.tgz#b0da04c4371311df771cdc215e87f2130991ace7" - integrity sha512-mlExGW4w71ebDJviH16lQLtZS32VKqsSfk80GCfUlwT/4/hNRFsoscrF/c++9xinkMzECL1uL9DDwXqFWkruPg== - dependencies: - buffer "^5.2.1" - through "^2.3.8" - undici-types@~7.16.0: version "7.16.0" resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-7.16.0.tgz#ffccdff36aea4884cbfce9a750a0580224f58a46" @@ -1505,16 +1481,16 @@ uri-js@^4.2.2: dependencies: punycode "^2.1.0" -urlpattern-polyfill@10.0.0: - version "10.0.0" - resolved "https://registry.yarnpkg.com/urlpattern-polyfill/-/urlpattern-polyfill-10.0.0.tgz#f0a03a97bfb03cdf33553e5e79a2aadd22cac8ec" - integrity sha512-H/A06tKD7sS1O1X2SshBVeA5FLycRpjqiBeqGKmBwBDBy28EnRjORxTNe269KSSr5un5qyWi1iL61wLxpd+ZOg== - util-deprecate@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw== +webdriver-bidi-protocol@0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/webdriver-bidi-protocol/-/webdriver-bidi-protocol-0.4.1.tgz#d411e7b8e158408d83bb166b0b4f1054fa3f077e" + integrity sha512-ARrjNjtWRRs2w4Tk7nqrf2gBI0QXWuOmMCx2hU+1jUt6d00MjMxURrhxhGbrsoiZKJrhTSTzbIrc554iKI10qw== + which@^2.0.1: version "2.0.2" resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" @@ -1567,10 +1543,10 @@ wrappy@1: resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== -ws@^8.18.0: - version "8.18.3" - resolved "https://registry.yarnpkg.com/ws/-/ws-8.18.3.tgz#b56b88abffde62791c639170400c93dcb0c95472" - integrity sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg== +ws@^8.19.0: + version "8.20.0" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.20.0.tgz#4cd9532358eba60bc863aad1623dfb045a4d4af8" + integrity sha512-sAt8BhgNbzCtgGbt2OxmpuryO63ZoDk/sqaB/znQm94T4fCEsy/yV+7CdC1kJhOU9lboAEU7R3kquuycDoibVA== y18n@^5.0.5: version "5.0.8" @@ -1608,7 +1584,7 @@ yocto-queue@^0.1.0: resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== -zod@3.23.8: - version "3.23.8" - resolved "https://registry.yarnpkg.com/zod/-/zod-3.23.8.tgz#e37b957b5d52079769fb8097099b592f0ef4067d" - integrity sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g== +zod@^3.24.1: + version "3.25.76" + resolved "https://registry.yarnpkg.com/zod/-/zod-3.25.76.tgz#26841c3f6fd22a6a2760e7ccb719179768471e34" + integrity sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ== From ea421bf991b797fbd574aa138ce4b31ae28cf483 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Tue, 24 Mar 2026 20:22:46 -0700 Subject: [PATCH 04/12] Add integer truncation and extension methods This provides `.truncate()`, `.saturating_truncate()`, `.checked_truncate()`, and `.extend()`. These only work within the same signedness (use `.cast_signed()` and `.cast_unsigned()` to change sign). The truncation methods only work to smaller (or equal) types. `.extend()` only works to larger (or equal) types. For the purposes of truncation and extending, `usize` is considered larger than `u16` or `u8`. This is consistent with `From`/`Into` conversions. Adding these methods results in needing to update the output of one test that gets a new method-name similarity result. Co-authored-by: Amanieu d'Antras --- library/core/src/num/int_macros.rs | 80 ++++++++++++++++ library/core/src/num/mod.rs | 1 + library/core/src/num/traits.rs | 125 +++++++++++++++++++++++++ library/core/src/num/uint_macros.rs | 74 +++++++++++++++ tests/ui/imports/issue-114682-3.stderr | 6 +- 5 files changed, 285 insertions(+), 1 deletion(-) create mode 100644 library/core/src/num/traits.rs diff --git a/library/core/src/num/int_macros.rs b/library/core/src/num/int_macros.rs index aba0eaf8d4842..c49ba93660a95 100644 --- a/library/core/src/num/int_macros.rs +++ b/library/core/src/num/int_macros.rs @@ -3944,5 +3944,85 @@ macro_rules! int_impl { self } } + + /// Truncate an integer to an integer of the same size or smaller, preserving the least + /// significant bits. + /// + /// # Examples + /// + /// ``` + /// #![feature(integer_extend_truncate)] + #[doc = concat!("assert_eq!(120i8, 120", stringify!($SelfT), ".truncate());")] + #[doc = concat!("assert_eq!(-120i8, (-120", stringify!($SelfT), ").truncate());")] + /// assert_eq!(120i8, 376i32.truncate()); + /// ``` + #[must_use = "this returns the truncated value and does not modify the original"] + #[unstable(feature = "integer_extend_truncate", issue = "154330")] + #[inline] + pub fn truncate(self) -> Target + where Self: traits::TruncateTarget + { + traits::TruncateTarget::internal_truncate(self) + } + + /// Truncate an integer to an integer of the same size or smaller, saturating at numeric bounds + /// instead of truncating. + /// + /// # Examples + /// + /// ``` + /// #![feature(integer_extend_truncate)] + #[doc = concat!("assert_eq!(120i8, 120", stringify!($SelfT), ".saturating_truncate());")] + #[doc = concat!("assert_eq!(-120i8, (-120", stringify!($SelfT), ").saturating_truncate());")] + /// assert_eq!(127i8, 376i32.saturating_truncate()); + /// assert_eq!(-128i8, (-1000i32).saturating_truncate()); + /// ``` + #[must_use = "this returns the truncated value and does not modify the original"] + #[unstable(feature = "integer_extend_truncate", issue = "154330")] + #[inline] + pub fn saturating_truncate(self) -> Target + where Self: traits::TruncateTarget + { + traits::TruncateTarget::internal_saturating_truncate(self) + } + + /// Truncate an integer to an integer of the same size or smaller, returning `None` if the value + /// is outside the bounds of the smaller type. + /// + /// # Examples + /// + /// ``` + /// #![feature(integer_extend_truncate)] + #[doc = concat!("assert_eq!(Some(120i8), 120", stringify!($SelfT), ".checked_truncate());")] + #[doc = concat!("assert_eq!(Some(-120i8), (-120", stringify!($SelfT), ").checked_truncate());")] + /// assert_eq!(None, 376i32.checked_truncate::()); + /// assert_eq!(None, (-1000i32).checked_truncate::()); + /// ``` + #[must_use = "this returns the truncated value and does not modify the original"] + #[unstable(feature = "integer_extend_truncate", issue = "154330")] + #[inline] + pub fn checked_truncate(self) -> Option + where Self: traits::TruncateTarget + { + traits::TruncateTarget::internal_checked_truncate(self) + } + + /// Extend to an integer of the same size or larger, preserving its value. + /// + /// # Examples + /// + /// ``` + /// #![feature(integer_extend_truncate)] + #[doc = concat!("assert_eq!(120i128, 120i8.extend());")] + #[doc = concat!("assert_eq!(-120i128, (-120i8).extend());")] + /// ``` + #[must_use = "this returns the extended value and does not modify the original"] + #[unstable(feature = "integer_extend_truncate", issue = "154330")] + #[inline] + pub fn extend(self) -> Target + where Self: traits::ExtendTarget + { + traits::ExtendTarget::internal_extend(self) + } } } diff --git a/library/core/src/num/mod.rs b/library/core/src/num/mod.rs index 92ae19460532c..5ba3695bc45c9 100644 --- a/library/core/src/num/mod.rs +++ b/library/core/src/num/mod.rs @@ -46,6 +46,7 @@ mod error; mod float_parse; mod nonzero; mod saturating; +mod traits; mod wrapping; /// 100% perma-unstable diff --git a/library/core/src/num/traits.rs b/library/core/src/num/traits.rs new file mode 100644 index 0000000000000..3d0e7146f3fd4 --- /dev/null +++ b/library/core/src/num/traits.rs @@ -0,0 +1,125 @@ +/// Definitions of traits for numeric types +// Implementation based on `num_conv` by jhpratt, under (MIT OR Apache-2.0). + +/// Trait for types that this type can be truncated to +#[unstable(feature = "num_internals", reason = "internal implementation detail", issue = "none")] +pub trait TruncateTarget: crate::sealed::Sealed { + #[doc(hidden)] + fn internal_truncate(self) -> Target; + + #[doc(hidden)] + fn internal_saturating_truncate(self) -> Target; + + #[doc(hidden)] + fn internal_checked_truncate(self) -> Option; +} + +/// Trait for types that this type can be truncated to +#[unstable(feature = "num_internals", reason = "internal implementation detail", issue = "none")] +pub trait ExtendTarget: crate::sealed::Sealed { + #[doc(hidden)] + fn internal_extend(self) -> Target; +} + +macro_rules! impl_truncate { + ($($from:ty => $($to:ty),+;)*) => {$($( + const _: () = assert!( + size_of::<$from>() >= size_of::<$to>(), + concat!( + "cannot truncate ", + stringify!($from), + " to ", + stringify!($to), + " because ", + stringify!($from), + " is smaller than ", + stringify!($to) + ) + ); + + #[unstable(feature = "num_internals", reason = "internal implementation detail", issue = "none")] + impl TruncateTarget<$to> for $from { + #[inline] + fn internal_truncate(self) -> $to { + self as _ + } + + #[inline] + fn internal_saturating_truncate(self) -> $to { + if self > <$to>::MAX as Self { + <$to>::MAX + } else if self < <$to>::MIN as Self { + <$to>::MIN + } else { + self as _ + } + } + + #[inline] + fn internal_checked_truncate(self) -> Option<$to> { + if self > <$to>::MAX as Self || self < <$to>::MIN as Self { + None + } else { + Some(self as _) + } + } + } + )+)*}; +} + +macro_rules! impl_extend { + ($($from:ty => $($to:ty),+;)*) => {$($( + const _: () = assert!( + size_of::<$from>() <= size_of::<$to>(), + concat!( + "cannot extend ", + stringify!($from), + " to ", + stringify!($to), + " because ", + stringify!($from), + " is larger than ", + stringify!($to) + ) + ); + + #[unstable(feature = "num_internals", reason = "internal implementation detail", issue = "none")] + impl ExtendTarget<$to> for $from { + fn internal_extend(self) -> $to { + self as _ + } + } + )+)*}; +} + +impl_truncate! { + u8 => u8; + u16 => u16, u8; + u32 => u32, u16, u8; + u64 => u64, u32, u16, u8; + u128 => u128, u64, u32, u16, u8; + usize => usize, u16, u8; + + i8 => i8; + i16 => i16, i8; + i32 => i32, i16, i8; + i64 => i64, i32, i16, i8; + i128 => i128, i64, i32, i16, i8; + isize => isize, i16, i8; +} + +impl_extend! { + u8 => u8, u16, u32, u64, u128, usize; + u16 => u16, u32, u64, u128, usize; + u32 => u32, u64, u128; + u64 => u64, u128; + u128 => u128; + usize => usize; + + i8 => i8, i16, i32, i64, i128, isize; + i16 => i16, i32, i64, i128, isize; + i32 => i32, i64, i128; + i64 => i64, i128; + i128 => i128; + isize => isize; +} diff --git a/library/core/src/num/uint_macros.rs b/library/core/src/num/uint_macros.rs index 27dbe6d3f1d8b..41f45be72d478 100644 --- a/library/core/src/num/uint_macros.rs +++ b/library/core/src/num/uint_macros.rs @@ -4107,5 +4107,79 @@ macro_rules! uint_impl { #[deprecated(since = "TBD", note = "replaced by the `MAX` associated constant on this type")] #[rustc_diagnostic_item = concat!(stringify!($SelfT), "_legacy_fn_max_value")] pub const fn max_value() -> Self { Self::MAX } + + /// Truncate an integer to an integer of the same size or smaller, preserving the least + /// significant bits. + /// + /// # Examples + /// + /// ``` + /// #![feature(integer_extend_truncate)] + #[doc = concat!("assert_eq!(120u8, 120", stringify!($SelfT), ".truncate());")] + /// assert_eq!(120u8, 376u32.truncate()); + /// ``` + #[must_use = "this returns the truncated value and does not modify the original"] + #[unstable(feature = "integer_extend_truncate", issue = "154330")] + #[inline] + pub fn truncate(self) -> Target + where Self: traits::TruncateTarget + { + traits::TruncateTarget::internal_truncate(self) + } + + /// Truncate an integer to an integer of the same size or smaller, saturating at numeric bounds + /// instead of truncating. + /// + /// # Examples + /// + /// ``` + /// #![feature(integer_extend_truncate)] + #[doc = concat!("assert_eq!(120u8, 120", stringify!($SelfT), ".saturating_truncate());")] + /// assert_eq!(255u8, 376u32.saturating_truncate()); + /// ``` + #[must_use = "this returns the truncated value and does not modify the original"] + #[unstable(feature = "integer_extend_truncate", issue = "154330")] + #[inline] + pub fn saturating_truncate(self) -> Target + where Self: traits::TruncateTarget + { + traits::TruncateTarget::internal_saturating_truncate(self) + } + + /// Truncate an integer to an integer of the same size or smaller, returning `None` if the value + /// is outside the bounds of the smaller type. + /// + /// # Examples + /// + /// ``` + /// #![feature(integer_extend_truncate)] + #[doc = concat!("assert_eq!(Some(120u8), 120", stringify!($SelfT), ".checked_truncate());")] + /// assert_eq!(None, 376u32.checked_truncate::()); + /// ``` + #[must_use = "this returns the truncated value and does not modify the original"] + #[unstable(feature = "integer_extend_truncate", issue = "154330")] + #[inline] + pub fn checked_truncate(self) -> Option + where Self: traits::TruncateTarget + { + traits::TruncateTarget::internal_checked_truncate(self) + } + + /// Extend to an integer of the same size or larger, preserving its value. + /// + /// # Examples + /// + /// ``` + /// #![feature(integer_extend_truncate)] + #[doc = concat!("assert_eq!(120u128, 120u8.extend());")] + /// ``` + #[must_use = "this returns the extended value and does not modify the original"] + #[unstable(feature = "integer_extend_truncate", issue = "154330")] + #[inline] + pub fn extend(self) -> Target + where Self: traits::ExtendTarget + { + traits::ExtendTarget::internal_extend(self) + } } } diff --git a/tests/ui/imports/issue-114682-3.stderr b/tests/ui/imports/issue-114682-3.stderr index 6af7a4e026140..0b8c8d3ae7972 100644 --- a/tests/ui/imports/issue-114682-3.stderr +++ b/tests/ui/imports/issue-114682-3.stderr @@ -5,13 +5,17 @@ LL | fn ext(&self) {} | --- the method is available for `u8` here ... LL | a.ext(); - | ^^^ method not found in `u8` + | ^^^ | = help: items from traits can only be used if the trait is in scope help: trait `SettingsExt` which provides `ext` is implemented but not in scope; perhaps you want to import it | LL + use auto::SettingsExt; | +help: there is a method `extend` with a similar name + | +LL | a.extend(); + | +++ error: aborting due to 1 previous error From 68c833906666fb428e6a32f8006f3bc8f6a7833e Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Wed, 25 Mar 2026 23:52:10 -0700 Subject: [PATCH 05/12] Make truncate and extend use const traits to work in const contexts --- library/core/src/num/int_macros.rs | 20 ++++++++++++-------- library/core/src/num/traits.rs | 12 ++++++++---- library/core/src/num/uint_macros.rs | 20 ++++++++++++-------- 3 files changed, 32 insertions(+), 20 deletions(-) diff --git a/library/core/src/num/int_macros.rs b/library/core/src/num/int_macros.rs index c49ba93660a95..b148c7578db26 100644 --- a/library/core/src/num/int_macros.rs +++ b/library/core/src/num/int_macros.rs @@ -3958,9 +3958,10 @@ macro_rules! int_impl { /// ``` #[must_use = "this returns the truncated value and does not modify the original"] #[unstable(feature = "integer_extend_truncate", issue = "154330")] + #[rustc_const_unstable(feature = "integer_truncate_extend", issue = "154330")] #[inline] - pub fn truncate(self) -> Target - where Self: traits::TruncateTarget + pub const fn truncate(self) -> Target + where Self: [const] traits::TruncateTarget { traits::TruncateTarget::internal_truncate(self) } @@ -3979,9 +3980,10 @@ macro_rules! int_impl { /// ``` #[must_use = "this returns the truncated value and does not modify the original"] #[unstable(feature = "integer_extend_truncate", issue = "154330")] + #[rustc_const_unstable(feature = "integer_truncate_extend", issue = "154330")] #[inline] - pub fn saturating_truncate(self) -> Target - where Self: traits::TruncateTarget + pub const fn saturating_truncate(self) -> Target + where Self: [const] traits::TruncateTarget { traits::TruncateTarget::internal_saturating_truncate(self) } @@ -4000,9 +4002,10 @@ macro_rules! int_impl { /// ``` #[must_use = "this returns the truncated value and does not modify the original"] #[unstable(feature = "integer_extend_truncate", issue = "154330")] + #[rustc_const_unstable(feature = "integer_truncate_extend", issue = "154330")] #[inline] - pub fn checked_truncate(self) -> Option - where Self: traits::TruncateTarget + pub const fn checked_truncate(self) -> Option + where Self: [const] traits::TruncateTarget { traits::TruncateTarget::internal_checked_truncate(self) } @@ -4018,9 +4021,10 @@ macro_rules! int_impl { /// ``` #[must_use = "this returns the extended value and does not modify the original"] #[unstable(feature = "integer_extend_truncate", issue = "154330")] + #[rustc_const_unstable(feature = "integer_truncate_extend", issue = "154330")] #[inline] - pub fn extend(self) -> Target - where Self: traits::ExtendTarget + pub const fn extend(self) -> Target + where Self: [const] traits::ExtendTarget { traits::ExtendTarget::internal_extend(self) } diff --git a/library/core/src/num/traits.rs b/library/core/src/num/traits.rs index 3d0e7146f3fd4..9ce4d878a6e09 100644 --- a/library/core/src/num/traits.rs +++ b/library/core/src/num/traits.rs @@ -3,7 +3,8 @@ /// Trait for types that this type can be truncated to #[unstable(feature = "num_internals", reason = "internal implementation detail", issue = "none")] -pub trait TruncateTarget: crate::sealed::Sealed { +#[rustc_const_unstable(feature = "integer_truncate_extend", issue = "154330")] +pub const trait TruncateTarget: crate::sealed::Sealed { #[doc(hidden)] fn internal_truncate(self) -> Target; @@ -16,7 +17,8 @@ pub trait TruncateTarget: crate::sealed::Sealed { /// Trait for types that this type can be truncated to #[unstable(feature = "num_internals", reason = "internal implementation detail", issue = "none")] -pub trait ExtendTarget: crate::sealed::Sealed { +#[rustc_const_unstable(feature = "integer_truncate_extend", issue = "154330")] +pub const trait ExtendTarget: crate::sealed::Sealed { #[doc(hidden)] fn internal_extend(self) -> Target; } @@ -38,7 +40,8 @@ macro_rules! impl_truncate { ); #[unstable(feature = "num_internals", reason = "internal implementation detail", issue = "none")] - impl TruncateTarget<$to> for $from { + #[rustc_const_unstable(feature = "integer_truncate_extend", issue = "154330")] + impl const TruncateTarget<$to> for $from { #[inline] fn internal_truncate(self) -> $to { self as _ @@ -84,7 +87,8 @@ macro_rules! impl_extend { ); #[unstable(feature = "num_internals", reason = "internal implementation detail", issue = "none")] - impl ExtendTarget<$to> for $from { + #[rustc_const_unstable(feature = "integer_truncate_extend", issue = "154330")] + impl const ExtendTarget<$to> for $from { fn internal_extend(self) -> $to { self as _ } diff --git a/library/core/src/num/uint_macros.rs b/library/core/src/num/uint_macros.rs index 41f45be72d478..e048f8f485390 100644 --- a/library/core/src/num/uint_macros.rs +++ b/library/core/src/num/uint_macros.rs @@ -4120,9 +4120,10 @@ macro_rules! uint_impl { /// ``` #[must_use = "this returns the truncated value and does not modify the original"] #[unstable(feature = "integer_extend_truncate", issue = "154330")] + #[rustc_const_unstable(feature = "integer_truncate_extend", issue = "154330")] #[inline] - pub fn truncate(self) -> Target - where Self: traits::TruncateTarget + pub const fn truncate(self) -> Target + where Self: [const] traits::TruncateTarget { traits::TruncateTarget::internal_truncate(self) } @@ -4139,9 +4140,10 @@ macro_rules! uint_impl { /// ``` #[must_use = "this returns the truncated value and does not modify the original"] #[unstable(feature = "integer_extend_truncate", issue = "154330")] + #[rustc_const_unstable(feature = "integer_truncate_extend", issue = "154330")] #[inline] - pub fn saturating_truncate(self) -> Target - where Self: traits::TruncateTarget + pub const fn saturating_truncate(self) -> Target + where Self: [const] traits::TruncateTarget { traits::TruncateTarget::internal_saturating_truncate(self) } @@ -4158,9 +4160,10 @@ macro_rules! uint_impl { /// ``` #[must_use = "this returns the truncated value and does not modify the original"] #[unstable(feature = "integer_extend_truncate", issue = "154330")] + #[rustc_const_unstable(feature = "integer_truncate_extend", issue = "154330")] #[inline] - pub fn checked_truncate(self) -> Option - where Self: traits::TruncateTarget + pub const fn checked_truncate(self) -> Option + where Self: [const] traits::TruncateTarget { traits::TruncateTarget::internal_checked_truncate(self) } @@ -4175,9 +4178,10 @@ macro_rules! uint_impl { /// ``` #[must_use = "this returns the extended value and does not modify the original"] #[unstable(feature = "integer_extend_truncate", issue = "154330")] + #[rustc_const_unstable(feature = "integer_truncate_extend", issue = "154330")] #[inline] - pub fn extend(self) -> Target - where Self: traits::ExtendTarget + pub const fn extend(self) -> Target + where Self: [const] traits::ExtendTarget { traits::ExtendTarget::internal_extend(self) } From 9bdf217810e77b7d58e43030dd61a65172ab1354 Mon Sep 17 00:00:00 2001 From: binarycat Date: Tue, 31 Mar 2026 12:51:12 -0500 Subject: [PATCH 06/12] rustdoc: seperate methods and associated functions in sidebar --- src/librustdoc/clean/types.rs | 9 ++ src/librustdoc/html/render/sidebar.rs | 132 ++++++++++++-------- tests/rustdoc-gui/hash-item-expansion.goml | 4 +- tests/rustdoc-gui/sidebar-mobile.goml | 2 +- tests/rustdoc-html/sidebar/sidebar-items.rs | 8 ++ tests/rustdoc-html/typedef.rs | 2 +- 6 files changed, 103 insertions(+), 54 deletions(-) diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index ad70fc1096691..7d40bc95ec089 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -465,6 +465,15 @@ impl Item { .unwrap_or(false) } + /// Returns true if item is an associated function with a `self` parameter. + pub(crate) fn has_self_param(&self) -> bool { + if let ItemKind::MethodItem(box Function { decl, .. }, _) = &self.inner.kind { + decl.receiver_type().is_some() + } else { + false + } + } + pub(crate) fn span(&self, tcx: TyCtxt<'_>) -> Option { let kind = match &self.kind { ItemKind::StrippedItem(k) => k, diff --git a/src/librustdoc/html/render/sidebar.rs b/src/librustdoc/html/render/sidebar.rs index a4535792ac3ce..d40c9501cabc1 100644 --- a/src/librustdoc/html/render/sidebar.rs +++ b/src/librustdoc/html/render/sidebar.rs @@ -433,6 +433,7 @@ fn sidebar_assoc_items<'a>( let mut assoc_consts = Vec::new(); let mut assoc_types = Vec::new(); + let mut assoc_fns = Vec::new(); let mut methods = Vec::new(); if let Some(v) = cache.impls.get(&did) { let mut used_links = FxHashSet::default(); @@ -443,7 +444,12 @@ fn sidebar_assoc_items<'a>( for impl_ in v.iter().map(|i| i.inner_impl()).filter(|i| i.trait_.is_none()) { assoc_consts.extend(get_associated_constants(impl_, used_links_bor)); assoc_types.extend(get_associated_types(impl_, used_links_bor)); - methods.extend(get_methods(impl_, false, used_links_bor, false, cx.tcx())); + methods.extend(get_methods( + impl_, + GetMethodsMode::AlsoCollectAssocFns { assoc_fns: &mut assoc_fns }, + used_links_bor, + cx.tcx(), + )); } // We want links' order to be reproducible so we don't use unstable sort. assoc_consts.sort(); @@ -462,6 +468,11 @@ fn sidebar_assoc_items<'a>( "associatedtype", assoc_types, ), + LinkBlock::new( + Link::new("implementations", "Associated Functions"), + "method", + assoc_fns, + ), LinkBlock::new(Link::new("implementations", "Methods"), "method", methods), ]; @@ -546,7 +557,15 @@ fn sidebar_deref_methods<'a>( i.inner_impl().trait_.is_none() && real_target.is_doc_subtype_of(&i.inner_impl().for_, c) }) - .flat_map(|i| get_methods(i.inner_impl(), true, used_links, deref_mut, cx.tcx())) + .flat_map(|i| { + get_methods( + i.inner_impl(), + GetMethodsMode::Deref { deref_mut }, + used_links, + cx.tcx(), + ) + .collect::>() + }) .collect::>(); if !ret.is_empty() { let id = if let Some(target_def_id) = real_target.def_id(c) { @@ -734,69 +753,82 @@ fn get_next_url(used_links: &mut FxHashSet, url: String) -> String { format!("{url}-{add}") } +enum GetMethodsMode<'r, 'l> { + Deref { deref_mut: bool }, + AlsoCollectAssocFns { assoc_fns: &'r mut Vec> }, +} + fn get_methods<'a>( i: &'a clean::Impl, - for_deref: bool, + mut mode: GetMethodsMode<'_, 'a>, used_links: &mut FxHashSet, - deref_mut: bool, tcx: TyCtxt<'_>, -) -> Vec> { - i.items - .iter() - .filter_map(|item| { - if let Some(ref name) = item.name - && item.is_method() - && (!for_deref || super::should_render_item(item, deref_mut, tcx)) - { - Some(Link::new( +) -> impl Iterator> { + i.items.iter().filter_map(move |item| { + if let Some(ref name) = item.name + && item.is_method() + { + let mut build_link = || { + Link::new( get_next_url(used_links, format!("{typ}.{name}", typ = ItemType::Method)), name.as_str(), - )) - } else { - None + ) + }; + match &mut mode { + &mut GetMethodsMode::Deref { deref_mut } => { + if super::should_render_item(item, deref_mut, tcx) { + Some(build_link()) + } else { + None + } + } + GetMethodsMode::AlsoCollectAssocFns { assoc_fns } => { + if item.has_self_param() { + Some(build_link()) + } else { + assoc_fns.push(build_link()); + None + } + } } - }) - .collect() + } else { + None + } + }) } fn get_associated_constants<'a>( i: &'a clean::Impl, used_links: &mut FxHashSet, -) -> Vec> { - i.items - .iter() - .filter_map(|item| { - if let Some(ref name) = item.name - && item.is_associated_const() - { - Some(Link::new( - get_next_url(used_links, format!("{typ}.{name}", typ = ItemType::AssocConst)), - name.as_str(), - )) - } else { - None - } - }) - .collect() +) -> impl Iterator> { + i.items.iter().filter_map(|item| { + if let Some(ref name) = item.name + && item.is_associated_const() + { + Some(Link::new( + get_next_url(used_links, format!("{typ}.{name}", typ = ItemType::AssocConst)), + name.as_str(), + )) + } else { + None + } + }) } fn get_associated_types<'a>( i: &'a clean::Impl, used_links: &mut FxHashSet, -) -> Vec> { - i.items - .iter() - .filter_map(|item| { - if let Some(ref name) = item.name - && item.is_associated_type() - { - Some(Link::new( - get_next_url(used_links, format!("{typ}.{name}", typ = ItemType::AssocType)), - name.as_str(), - )) - } else { - None - } - }) - .collect() +) -> impl Iterator> { + i.items.iter().filter_map(|item| { + if let Some(ref name) = item.name + && item.is_associated_type() + { + Some(Link::new( + get_next_url(used_links, format!("{typ}.{name}", typ = ItemType::AssocType)), + name.as_str(), + )) + } else { + None + } + }) } diff --git a/tests/rustdoc-gui/hash-item-expansion.goml b/tests/rustdoc-gui/hash-item-expansion.goml index a7a5c3cb48345..8661641206685 100644 --- a/tests/rustdoc-gui/hash-item-expansion.goml +++ b/tests/rustdoc-gui/hash-item-expansion.goml @@ -5,7 +5,7 @@ assert-attribute: ("#blanket-implementations-list > details:nth-child(2)", {"ope // We first check that the impl block is open by default. assert-attribute: ("#implementations-list details", {"open": ""}) // To ensure that we will click on the currently hidden method. -assert-text: (".sidebar-elems section .block li > a", "must_use") -click: ".sidebar-elems section .block li > a" +assert-text: (".sidebar-elems section ul:nth-of-type(2) li > a", "must_use") +click: ".sidebar-elems ul:nth-of-type(2) li > a" // We check that the impl block was opened as expected so that we can see the method. assert-attribute: ("#implementations-list > details", {"open": ""}) diff --git a/tests/rustdoc-gui/sidebar-mobile.goml b/tests/rustdoc-gui/sidebar-mobile.goml index 3183650b555a8..61c1555fbc0e3 100644 --- a/tests/rustdoc-gui/sidebar-mobile.goml +++ b/tests/rustdoc-gui/sidebar-mobile.goml @@ -48,7 +48,7 @@ assert-property: ("rustdoc-topbar", {"clientHeight": "45"}) // Check that clicking an element from the sidebar scrolls to the right place // so the target is not obscured by the topbar. click: ".sidebar-menu-toggle" -click: ".sidebar-elems section .block li > a" +click: ".sidebar-elems section ul:nth-of-type(2) li > a" assert-position: ("#method\.must_use", {"y": 45}) // Check that the bottom-most item on the sidebar menu can be scrolled fully into view. diff --git a/tests/rustdoc-html/sidebar/sidebar-items.rs b/tests/rustdoc-html/sidebar/sidebar-items.rs index 6e13457796e5e..bd0893dac3e36 100644 --- a/tests/rustdoc-html/sidebar/sidebar-items.rs +++ b/tests/rustdoc-html/sidebar/sidebar-items.rs @@ -42,6 +42,14 @@ pub struct Bar { waza: u32, } +//@ has foo/struct.Bar.html +//@ has - '//div[@class="sidebar-elems"]//h3/a[@href="#implementations"]' 'Associated Functions' +//@ has - '//div[@class="sidebar-elems"]//h3/a[@href="#implementations"]' 'Methods' +impl Bar { + pub fn method(&self) {} + pub fn assoc_fn() {} +} + //@ has foo/enum.En.html //@ has - '//div[@class="sidebar-elems"]//h3/a[@href="#variants"]' 'Variants' //@ has - '//*[@class="sidebar-elems"]//section//a' 'Foo' diff --git a/tests/rustdoc-html/typedef.rs b/tests/rustdoc-html/typedef.rs index 3fdc2788bcacf..4eae3c7258213 100644 --- a/tests/rustdoc-html/typedef.rs +++ b/tests/rustdoc-html/typedef.rs @@ -13,7 +13,7 @@ impl MyStruct { //@ has - '//*[@class="impl"]//h3[@class="code-header"]' 'impl MyTrait for MyAlias' //@ hasraw - 'Alias docstring' //@ has - '//*[@class="sidebar"]//*[@class="location"]' 'MyAlias' -//@ has - '//*[@class="sidebar"]//a[@href="#implementations"]' 'Methods' +//@ has - '//*[@class="sidebar"]//a[@href="#implementations"]' 'Associated Functions' //@ has - '//*[@class="sidebar"]//a[@href="#trait-implementations"]' 'Trait Implementations' /// Alias docstring pub type MyAlias = MyStruct; From dc9836e29ccf1d4cadf46ec36fcc2e8d86ab5d2b Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Tue, 31 Mar 2026 21:49:46 +0200 Subject: [PATCH 07/12] change `c_double` to `f32` on `avr` targets --- library/core/src/ffi/c_double.md | 2 +- library/core/src/ffi/primitives.rs | 30 ++++++++++++++++++++++++------ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/library/core/src/ffi/c_double.md b/library/core/src/ffi/c_double.md index d49e29b6e6e7f..8586dec909d92 100644 --- a/library/core/src/ffi/c_double.md +++ b/library/core/src/ffi/c_double.md @@ -1,6 +1,6 @@ Equivalent to C's `double` type. -This type will almost always be [`f64`], which is guaranteed to be an [IEEE 754 double-precision float] in Rust. That said, the standard technically only guarantees that it be a floating-point number with at least the precision of a [`float`], and it may be `f32` or something entirely different from the IEEE-754 standard. +This type will almost always be [`f64`], which is guaranteed to be an [IEEE 754 double-precision float] in Rust. That said, the standard technically only guarantees that it be a floating-point number with at least the precision of a [`float`]; some 16-bit systems use [`f32`], for example. Esoteric systems could use something entirely different from the IEEE-754 standard. [IEEE 754 double-precision float]: https://en.wikipedia.org/wiki/IEEE_754 [`float`]: c_float diff --git a/library/core/src/ffi/primitives.rs b/library/core/src/ffi/primitives.rs index fa23cf33af431..11dad9a65470c 100644 --- a/library/core/src/ffi/primitives.rs +++ b/library/core/src/ffi/primitives.rs @@ -15,24 +15,27 @@ macro_rules! type_alias { } } -type_alias! { "c_char.md", c_char = c_char_definition::c_char; #[doc(cfg(all()))] } +// `#[doc(cfg(true))]` is used to prevent rustdoc from displaying a "Available on ..." box. +// The implementation of these constants is target-specific, but every target does define them. + +type_alias! { "c_char.md", c_char = c_char_definition::c_char; #[doc(cfg(true))] } type_alias! { "c_schar.md", c_schar = i8; } type_alias! { "c_uchar.md", c_uchar = u8; } type_alias! { "c_short.md", c_short = i16; } type_alias! { "c_ushort.md", c_ushort = u16; } -type_alias! { "c_int.md", c_int = c_int_definition::c_int; #[doc(cfg(all()))] } -type_alias! { "c_uint.md", c_uint = c_int_definition::c_uint; #[doc(cfg(all()))] } +type_alias! { "c_int.md", c_int = c_int_definition::c_int; #[doc(cfg(true))] } +type_alias! { "c_uint.md", c_uint = c_int_definition::c_uint; #[doc(cfg(true))] } -type_alias! { "c_long.md", c_long = c_long_definition::c_long; #[doc(cfg(all()))] } -type_alias! { "c_ulong.md", c_ulong = c_long_definition::c_ulong; #[doc(cfg(all()))] } +type_alias! { "c_long.md", c_long = c_long_definition::c_long; #[doc(cfg(true))] } +type_alias! { "c_ulong.md", c_ulong = c_long_definition::c_ulong; #[doc(cfg(true))] } type_alias! { "c_longlong.md", c_longlong = i64; } type_alias! { "c_ulonglong.md", c_ulonglong = u64; } type_alias! { "c_float.md", c_float = f32; } -type_alias! { "c_double.md", c_double = f64; } +type_alias! { "c_double.md", c_double= c_double_definition::c_double; #[doc(cfg(true))] } mod c_char_definition { crate::cfg_select! { @@ -183,3 +186,18 @@ mod c_int_definition { } } } + +mod c_double_definition { + crate::cfg_select! { + target_arch = "avr" => { + // avr: + // Per https://gcc.gnu.org/wiki/avr-gcc#Type_Layout. The table says `4,8` because + // in C the width of `double` can be changed with the `-mdouble=32/64` setting. But + // 32-bits is the default for the rust avr target. + pub(super) type c_double = f32; + } + _ => { + pub(super) type c_double = f64; + } + } +} From 95d5ecf3ab075e82503f4fb40893ac5899442653 Mon Sep 17 00:00:00 2001 From: yukang Date: Wed, 1 Apr 2026 09:21:45 +0800 Subject: [PATCH 08/12] Fix associated bound suggestion span issue --- .../error_reporting/infer/note_and_explain.rs | 8 +++- .../associated-error-bound-issue-145586.fixed | 38 +++++++++++++++++++ .../associated-error-bound-issue-145586.rs | 38 +++++++++++++++++++ ...associated-error-bound-issue-145586.stderr | 22 +++++++++++ 4 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 tests/ui/trait-bounds/associated-error-bound-issue-145586.fixed create mode 100644 tests/ui/trait-bounds/associated-error-bound-issue-145586.rs create mode 100644 tests/ui/trait-bounds/associated-error-bound-issue-145586.stderr diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs index 7f53fdbc2c9f8..6bfd9c78df5d5 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs @@ -105,7 +105,13 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { if !sp.contains(p_span) { diag.span_label(p_span, format!("{expected}this type parameter")); } - let parent = p_def_id.as_local().and_then(|id| { + let param_def_id = match *proj.self_ty().kind() { + ty::Param(param) => { + tcx.generics_of(body_owner_def_id).type_param(param, tcx).def_id + } + _ => p_def_id, + }; + let parent = param_def_id.as_local().and_then(|id| { let local_id = tcx.local_def_id_to_hir_id(id); let generics = tcx.parent_hir_node(local_id).generics()?; Some((id, generics)) diff --git a/tests/ui/trait-bounds/associated-error-bound-issue-145586.fixed b/tests/ui/trait-bounds/associated-error-bound-issue-145586.fixed new file mode 100644 index 0000000000000..d5754132e028a --- /dev/null +++ b/tests/ui/trait-bounds/associated-error-bound-issue-145586.fixed @@ -0,0 +1,38 @@ +//@ run-rustfix + +#![allow(dead_code)] + +use std::marker::PhantomData; + +trait Visitor<'de> { + type Value; +} + +trait Deserializer<'de> { + type Error; + + fn deserialize_ignored_any(self, visitor: V) -> Result + where + V: Visitor<'de>; +} + +struct Wrapper<'de, T, E>(Result, PhantomData<&'de ()>); + +impl<'de, T, E> Deserializer<'de> for Wrapper<'de, T, E> +where + T: Deserializer<'de, Error = E>, +{ + type Error = E; + + fn deserialize_ignored_any(self, visitor: V) -> Result + where + V: Visitor<'de>, + { + match self.0 { + Ok(deserializer) => deserializer.deserialize_ignored_any(visitor), //~ ERROR mismatched types + Err(error) => Err(error), + } + } +} + +fn main() {} diff --git a/tests/ui/trait-bounds/associated-error-bound-issue-145586.rs b/tests/ui/trait-bounds/associated-error-bound-issue-145586.rs new file mode 100644 index 0000000000000..7b33cecbccd6f --- /dev/null +++ b/tests/ui/trait-bounds/associated-error-bound-issue-145586.rs @@ -0,0 +1,38 @@ +//@ run-rustfix + +#![allow(dead_code)] + +use std::marker::PhantomData; + +trait Visitor<'de> { + type Value; +} + +trait Deserializer<'de> { + type Error; + + fn deserialize_ignored_any(self, visitor: V) -> Result + where + V: Visitor<'de>; +} + +struct Wrapper<'de, T, E>(Result, PhantomData<&'de ()>); + +impl<'de, T, E> Deserializer<'de> for Wrapper<'de, T, E> +where + T: Deserializer<'de>, +{ + type Error = E; + + fn deserialize_ignored_any(self, visitor: V) -> Result + where + V: Visitor<'de>, + { + match self.0 { + Ok(deserializer) => deserializer.deserialize_ignored_any(visitor), //~ ERROR mismatched types + Err(error) => Err(error), + } + } +} + +fn main() {} diff --git a/tests/ui/trait-bounds/associated-error-bound-issue-145586.stderr b/tests/ui/trait-bounds/associated-error-bound-issue-145586.stderr new file mode 100644 index 0000000000000..18cfece99ffa6 --- /dev/null +++ b/tests/ui/trait-bounds/associated-error-bound-issue-145586.stderr @@ -0,0 +1,22 @@ +error[E0308]: mismatched types + --> $DIR/associated-error-bound-issue-145586.rs:32:33 + | +LL | impl<'de, T, E> Deserializer<'de> for Wrapper<'de, T, E> + | - expected this type parameter +... +LL | fn deserialize_ignored_any(self, visitor: V) -> Result + | ----------------------------- expected `Result<>::Value, E>` because of return type +... +LL | Ok(deserializer) => deserializer.deserialize_ignored_any(visitor), + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Result<>::Value, E>`, found `Result<>::Value, ...>` + | + = note: expected enum `Result<_, E>` + found enum `Result<_, >::Error>` +help: consider further restricting this bound + | +LL | T: Deserializer<'de, Error = E>, + | +++++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. From 50c6679c0b60cac63fd02806e776cd27de928b6c Mon Sep 17 00:00:00 2001 From: yukang Date: Wed, 1 Apr 2026 09:22:17 +0800 Subject: [PATCH 09/12] fix unit test naming style --- ...> deep-level-send-bound-check-issue-40827.rs} | 0 ...ep-level-send-bound-check-issue-40827.stderr} | 16 ++++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) rename tests/ui/trait-bounds/{deep-level-Send-bound-check-issue-40827.rs => deep-level-send-bound-check-issue-40827.rs} (100%) rename tests/ui/trait-bounds/{deep-level-Send-bound-check-issue-40827.stderr => deep-level-send-bound-check-issue-40827.stderr} (76%) diff --git a/tests/ui/trait-bounds/deep-level-Send-bound-check-issue-40827.rs b/tests/ui/trait-bounds/deep-level-send-bound-check-issue-40827.rs similarity index 100% rename from tests/ui/trait-bounds/deep-level-Send-bound-check-issue-40827.rs rename to tests/ui/trait-bounds/deep-level-send-bound-check-issue-40827.rs diff --git a/tests/ui/trait-bounds/deep-level-Send-bound-check-issue-40827.stderr b/tests/ui/trait-bounds/deep-level-send-bound-check-issue-40827.stderr similarity index 76% rename from tests/ui/trait-bounds/deep-level-Send-bound-check-issue-40827.stderr rename to tests/ui/trait-bounds/deep-level-send-bound-check-issue-40827.stderr index 7b59fe72f431e..3776c355318d0 100644 --- a/tests/ui/trait-bounds/deep-level-Send-bound-check-issue-40827.stderr +++ b/tests/ui/trait-bounds/deep-level-send-bound-check-issue-40827.stderr @@ -1,5 +1,5 @@ error[E0277]: `Rc` cannot be shared between threads safely - --> $DIR/deep-level-Send-bound-check-issue-40827.rs:14:7 + --> $DIR/deep-level-send-bound-check-issue-40827.rs:14:7 | LL | f(Foo(Arc::new(Bar::B(None)))); | - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Rc` cannot be shared between threads safely @@ -8,24 +8,24 @@ LL | f(Foo(Arc::new(Bar::B(None)))); | = help: within `Bar`, the trait `Sync` is not implemented for `Rc` note: required because it appears within the type `Bar` - --> $DIR/deep-level-Send-bound-check-issue-40827.rs:6:6 + --> $DIR/deep-level-send-bound-check-issue-40827.rs:6:6 | LL | enum Bar { | ^^^ = note: required for `Arc` to implement `Send` note: required because it appears within the type `Foo` - --> $DIR/deep-level-Send-bound-check-issue-40827.rs:4:8 + --> $DIR/deep-level-send-bound-check-issue-40827.rs:4:8 | LL | struct Foo(Arc); | ^^^ note: required by a bound in `f` - --> $DIR/deep-level-Send-bound-check-issue-40827.rs:11:9 + --> $DIR/deep-level-send-bound-check-issue-40827.rs:11:9 | LL | fn f(_: T) {} | ^^^^ required by this bound in `f` error[E0277]: `Rc` cannot be sent between threads safely - --> $DIR/deep-level-Send-bound-check-issue-40827.rs:14:7 + --> $DIR/deep-level-send-bound-check-issue-40827.rs:14:7 | LL | f(Foo(Arc::new(Bar::B(None)))); | - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Rc` cannot be sent between threads safely @@ -34,18 +34,18 @@ LL | f(Foo(Arc::new(Bar::B(None)))); | = help: within `Bar`, the trait `Send` is not implemented for `Rc` note: required because it appears within the type `Bar` - --> $DIR/deep-level-Send-bound-check-issue-40827.rs:6:6 + --> $DIR/deep-level-send-bound-check-issue-40827.rs:6:6 | LL | enum Bar { | ^^^ = note: required for `Arc` to implement `Send` note: required because it appears within the type `Foo` - --> $DIR/deep-level-Send-bound-check-issue-40827.rs:4:8 + --> $DIR/deep-level-send-bound-check-issue-40827.rs:4:8 | LL | struct Foo(Arc); | ^^^ note: required by a bound in `f` - --> $DIR/deep-level-Send-bound-check-issue-40827.rs:11:9 + --> $DIR/deep-level-send-bound-check-issue-40827.rs:11:9 | LL | fn f(_: T) {} | ^^^^ required by this bound in `f` From 910677fcc625fcff770158b4184ff64e4b57320c Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 1 Apr 2026 16:38:30 +1100 Subject: [PATCH 10/12] Rename `HirCtx` as `Hcx`. PR #154634 recently renamed many type parameters that impl `HashStableContext` as `Hcx`. It missed a few that are named `HirCtx`. This commit renames them. --- compiler/rustc_hir/src/stable_hash_impls.rs | 36 ++++++++++----------- compiler/rustc_middle/src/hir/mod.rs | 4 +-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/compiler/rustc_hir/src/stable_hash_impls.rs b/compiler/rustc_hir/src/stable_hash_impls.rs index 58649a694880b..d2d6529619662 100644 --- a/compiler/rustc_hir/src/stable_hash_impls.rs +++ b/compiler/rustc_hir/src/stable_hash_impls.rs @@ -13,48 +13,48 @@ use crate::lints::DelayedLints; /// instead of implementing everything in `rustc_middle`. pub trait HashStableContext: rustc_ast::HashStableContext + rustc_abi::HashStableContext {} -impl ToStableHashKey for BodyId { +impl ToStableHashKey for BodyId { type KeyType = (DefPathHash, ItemLocalId); #[inline] - fn to_stable_hash_key(&self, hcx: &HirCtx) -> (DefPathHash, ItemLocalId) { + fn to_stable_hash_key(&self, hcx: &Hcx) -> (DefPathHash, ItemLocalId) { let BodyId { hir_id } = *self; hir_id.to_stable_hash_key(hcx) } } -impl ToStableHashKey for ItemId { +impl ToStableHashKey for ItemId { type KeyType = DefPathHash; #[inline] - fn to_stable_hash_key(&self, hcx: &HirCtx) -> DefPathHash { + fn to_stable_hash_key(&self, hcx: &Hcx) -> DefPathHash { self.owner_id.def_id.to_stable_hash_key(hcx) } } -impl ToStableHashKey for TraitItemId { +impl ToStableHashKey for TraitItemId { type KeyType = DefPathHash; #[inline] - fn to_stable_hash_key(&self, hcx: &HirCtx) -> DefPathHash { + fn to_stable_hash_key(&self, hcx: &Hcx) -> DefPathHash { self.owner_id.def_id.to_stable_hash_key(hcx) } } -impl ToStableHashKey for ImplItemId { +impl ToStableHashKey for ImplItemId { type KeyType = DefPathHash; #[inline] - fn to_stable_hash_key(&self, hcx: &HirCtx) -> DefPathHash { + fn to_stable_hash_key(&self, hcx: &Hcx) -> DefPathHash { self.owner_id.def_id.to_stable_hash_key(hcx) } } -impl ToStableHashKey for ForeignItemId { +impl ToStableHashKey for ForeignItemId { type KeyType = DefPathHash; #[inline] - fn to_stable_hash_key(&self, hcx: &HirCtx) -> DefPathHash { + fn to_stable_hash_key(&self, hcx: &Hcx) -> DefPathHash { self.owner_id.def_id.to_stable_hash_key(hcx) } } @@ -66,8 +66,8 @@ impl ToStableHashKey for ForeignItemId // want to pick up on a reference changing its target, so we hash the NodeIds // in "DefPath Mode". -impl<'tcx, HirCtx: crate::HashStableContext> HashStable for OwnerNodes<'tcx> { - fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) { +impl<'tcx, Hcx: crate::HashStableContext> HashStable for OwnerNodes<'tcx> { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { // We ignore the `nodes` and `bodies` fields since these refer to information included in // `hash` which is hashed in the collector and used for the crate hash. // `local_id_to_def_id` is also ignored because is dependent on the body, then just hashing @@ -78,15 +78,15 @@ impl<'tcx, HirCtx: crate::HashStableContext> HashStable for OwnerNodes<' } } -impl HashStable for DelayedLints { - fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) { +impl HashStable for DelayedLints { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let DelayedLints { opt_hash, .. } = *self; opt_hash.unwrap().hash_stable(hcx, hasher); } } -impl<'tcx, HirCtx: crate::HashStableContext> HashStable for AttributeMap<'tcx> { - fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) { +impl<'tcx, Hcx: crate::HashStableContext> HashStable for AttributeMap<'tcx> { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { // We ignore the `map` since it refers to information included in `opt_hash` which is // hashed in the collector and used for the crate hash. let AttributeMap { opt_hash, define_opaque: _, map: _ } = *self; @@ -94,8 +94,8 @@ impl<'tcx, HirCtx: crate::HashStableContext> HashStable for AttributeMap } } -impl HashStable for HashIgnoredAttrId { - fn hash_stable(&self, _hcx: &mut HirCtx, _hasher: &mut StableHasher) { +impl HashStable for HashIgnoredAttrId { + fn hash_stable(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) { /* we don't hash HashIgnoredAttrId, we ignore them */ } } diff --git a/compiler/rustc_middle/src/hir/mod.rs b/compiler/rustc_middle/src/hir/mod.rs index ad56e462d2934..dfce7e0917608 100644 --- a/compiler/rustc_middle/src/hir/mod.rs +++ b/compiler/rustc_middle/src/hir/mod.rs @@ -77,8 +77,8 @@ impl<'hir> Crate<'hir> { } } -impl HashStable for Crate<'_> { - fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) { +impl HashStable for Crate<'_> { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let Crate { opt_hir_hash, .. } = self; opt_hir_hash.unwrap().hash_stable(hcx, hasher) } From d9a8a553cd601d6c25f7557021a01ea0370738bb Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 1 Apr 2026 16:51:01 +1100 Subject: [PATCH 11/12] Reorder `use`/`mod` items in `rustc_session`. They're in multiple sections with no rhyme or reason. --- compiler/rustc_session/src/lib.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_session/src/lib.rs b/compiler/rustc_session/src/lib.rs index 1741dde90f5cf..29192f267ed3a 100644 --- a/compiler/rustc_session/src/lib.rs +++ b/compiler/rustc_session/src/lib.rs @@ -11,28 +11,24 @@ #![recursion_limit = "256"] // tidy-alphabetical-end -pub mod errors; - -pub mod utils; +pub use getopts; pub use lint::{declare_lint, declare_lint_pass, declare_tool_lint, impl_lint_pass}; pub use rustc_lint_defs as lint; -pub mod parse; +pub use session::*; pub mod code_stats; +pub mod errors; +pub mod parse; +pub mod utils; #[macro_use] pub mod config; pub mod cstore; pub mod filesearch; mod macros; mod options; +pub mod output; pub mod search_paths; - mod session; -pub use session::*; - -pub mod output; - -pub use getopts; /// Requirements for a `StableHashingContext` to be used in this crate. /// This is a hack to allow using the `HashStable_Generic` derive macro From 1a9a284ad253fb0fd1d52e880789dc6848599d93 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 1 Apr 2026 16:41:28 +1100 Subject: [PATCH 12/12] Simplify `HashStableContext`. `derive(HashStable_Generic)` generates impls like this: ``` impl<__CTX> HashStable<__CTX> for ExpnKind where __CTX: crate::HashStableContext { fn hash_stable(&self, hcx : &mut __CTX, __hasher: &mut StableHasher) { ... } } ``` This is used for crates that are upstream of `rustc_middle`. The `crate::HashStableContext` bound means every crate that uses `derive(HashStable_Generic)` must provide (or import) a trait `HashStableContext` which `rustc_middle` then impls. In `rustc_span` this trait is sensible, with three methods. In other crates, this trait is empty, and there is the following trait hierarchy: ``` rustc_session::HashStableContext | | | rustc_hir::HashStableContext | / \ rustc_ast::HashStableContext rustc_abi::HashStableContext | rustc_span::HashStableContext ``` All very strange and unnecessary. This commit changes `derive(HashStable_Generic)` to use `rustc_span::HashStableContext` instead of `crate::HashStableContext`. This eliminates the need for all the empty `HashStableContext` traits and impls. Much better. --- compiler/rustc_abi/src/lib.rs | 6 ------ compiler/rustc_ast/src/ast.rs | 5 +++-- compiler/rustc_ast/src/lib.rs | 5 ----- compiler/rustc_ast/src/tokenstream.rs | 4 ++-- compiler/rustc_hir/src/def.rs | 4 ++-- compiler/rustc_hir/src/lib.rs | 1 - compiler/rustc_hir/src/stable_hash_impls.rs | 24 +++++++++------------ compiler/rustc_hir_id/src/lib.rs | 4 ++-- compiler/rustc_lint_defs/src/lib.rs | 4 ++-- compiler/rustc_macros/src/hash_stable.rs | 2 +- compiler/rustc_middle/src/hir/mod.rs | 2 +- compiler/rustc_middle/src/ich/hcx.rs | 9 ++------ compiler/rustc_session/src/config.rs | 5 +++-- compiler/rustc_session/src/lib.rs | 5 ----- compiler/rustc_span/src/lib.rs | 8 +++---- compiler/rustc_target/src/lib.rs | 2 -- 16 files changed, 32 insertions(+), 58 deletions(-) diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs index 253dff6f8e75c..42e272fdafb5d 100644 --- a/compiler/rustc_abi/src/lib.rs +++ b/compiler/rustc_abi/src/lib.rs @@ -67,12 +67,6 @@ pub use layout::{FIRST_VARIANT, FieldIdx, LayoutCalculator, LayoutCalculatorErro #[cfg(feature = "nightly")] pub use layout::{Layout, TyAbiInterface, TyAndLayout}; -/// Requirements for a `StableHashingContext` to be used in this crate. -/// This is a hack to allow using the `HashStable_Generic` derive macro -/// instead of implementing everything in `rustc_middle`. -#[cfg(feature = "nightly")] -pub trait HashStableContext {} - #[derive(Clone, Copy, PartialEq, Eq, Default)] #[cfg_attr( feature = "nightly", diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 71ec1c5042fda..87633cade1b6a 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -31,7 +31,8 @@ use rustc_data_structures::tagged_ptr::Tag; use rustc_macros::{Decodable, Encodable, HashStable_Generic, Walkable}; pub use rustc_span::AttrId; use rustc_span::{ - ByteSymbol, DUMMY_SP, ErrorGuaranteed, Ident, Span, Spanned, Symbol, kw, respan, sym, + ByteSymbol, DUMMY_SP, ErrorGuaranteed, HashStableContext, Ident, Span, Spanned, Symbol, kw, + respan, sym, }; use thin_vec::{ThinVec, thin_vec}; @@ -120,7 +121,7 @@ impl PartialEq<&[Symbol]> for Path { } } -impl HashStable for Path { +impl HashStable for Path { fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.segments.len().hash_stable(hcx, hasher); for segment in &self.segments { diff --git a/compiler/rustc_ast/src/lib.rs b/compiler/rustc_ast/src/lib.rs index ac3e77b0b5d6f..4178db1bfb09d 100644 --- a/compiler/rustc_ast/src/lib.rs +++ b/compiler/rustc_ast/src/lib.rs @@ -36,8 +36,3 @@ pub mod visit; pub use self::ast::*; pub use self::ast_traits::{AstNodeWrapper, HasAttrs, HasNodeId, HasTokens}; - -/// Requirements for a `StableHashingContext` to be used in this crate. -/// This is a hack to allow using the `HashStable_Generic` derive macro -/// instead of implementing everything in `rustc_middle`. -pub trait HashStableContext: rustc_span::HashStableContext {} diff --git a/compiler/rustc_ast/src/tokenstream.rs b/compiler/rustc_ast/src/tokenstream.rs index 8953391ac58bf..06bd6f03e9350 100644 --- a/compiler/rustc_ast/src/tokenstream.rs +++ b/compiler/rustc_ast/src/tokenstream.rs @@ -14,7 +14,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::sync; use rustc_macros::{Decodable, Encodable, HashStable_Generic, Walkable}; use rustc_serialize::{Decodable, Encodable}; -use rustc_span::{DUMMY_SP, Span, SpanDecoder, SpanEncoder, Symbol, sym}; +use rustc_span::{DUMMY_SP, HashStableContext, Span, SpanDecoder, SpanEncoder, Symbol, sym}; use thin_vec::ThinVec; use crate::ast::AttrStyle; @@ -826,7 +826,7 @@ impl FromIterator for TokenStream { impl HashStable for TokenStream where - Hcx: crate::HashStableContext, + Hcx: HashStableContext, { fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { for sub_tt in self.iter() { diff --git a/compiler/rustc_hir/src/def.rs b/compiler/rustc_hir/src/def.rs index 78bd709dd4844..cae8bb89233b2 100644 --- a/compiler/rustc_hir/src/def.rs +++ b/compiler/rustc_hir/src/def.rs @@ -8,9 +8,9 @@ use rustc_data_structures::stable_hasher::ToStableHashKey; use rustc_data_structures::unord::UnordMap; use rustc_error_messages::{DiagArgValue, IntoDiagArg}; use rustc_macros::{Decodable, Encodable, HashStable_Generic}; -use rustc_span::Symbol; use rustc_span::def_id::{DefId, LocalDefId}; use rustc_span::hygiene::MacroKind; +use rustc_span::{HashStableContext, Symbol}; use crate::definitions::DefPathData; use crate::hir; @@ -712,7 +712,7 @@ impl IntoDiagArg for Namespace { } } -impl ToStableHashKey for Namespace { +impl ToStableHashKey for Namespace { type KeyType = Namespace; #[inline] diff --git a/compiler/rustc_hir/src/lib.rs b/compiler/rustc_hir/src/lib.rs index 9c2fec8677854..c2d9f879cd601 100644 --- a/compiler/rustc_hir/src/lib.rs +++ b/compiler/rustc_hir/src/lib.rs @@ -43,7 +43,6 @@ pub use hir::*; pub use lang_items::{LangItem, LanguageItems}; pub use rustc_ast::attr::version::*; pub use stability::*; -pub use stable_hash_impls::HashStableContext; pub use target::{MethodKind, Target}; arena_types!(rustc_arena::declare_arena); diff --git a/compiler/rustc_hir/src/stable_hash_impls.rs b/compiler/rustc_hir/src/stable_hash_impls.rs index d2d6529619662..a157fc0ccbb0c 100644 --- a/compiler/rustc_hir/src/stable_hash_impls.rs +++ b/compiler/rustc_hir/src/stable_hash_impls.rs @@ -1,4 +1,5 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey}; +use rustc_span::HashStableContext; use rustc_span::def_id::DefPathHash; use crate::HashIgnoredAttrId; @@ -8,12 +9,7 @@ use crate::hir::{ use crate::hir_id::ItemLocalId; use crate::lints::DelayedLints; -/// Requirements for a `StableHashingContext` to be used in this crate. -/// This is a hack to allow using the `HashStable_Generic` derive macro -/// instead of implementing everything in `rustc_middle`. -pub trait HashStableContext: rustc_ast::HashStableContext + rustc_abi::HashStableContext {} - -impl ToStableHashKey for BodyId { +impl ToStableHashKey for BodyId { type KeyType = (DefPathHash, ItemLocalId); #[inline] @@ -23,7 +19,7 @@ impl ToStableHashKey for BodyId { } } -impl ToStableHashKey for ItemId { +impl ToStableHashKey for ItemId { type KeyType = DefPathHash; #[inline] @@ -32,7 +28,7 @@ impl ToStableHashKey for ItemId { } } -impl ToStableHashKey for TraitItemId { +impl ToStableHashKey for TraitItemId { type KeyType = DefPathHash; #[inline] @@ -41,7 +37,7 @@ impl ToStableHashKey for TraitItemId { } } -impl ToStableHashKey for ImplItemId { +impl ToStableHashKey for ImplItemId { type KeyType = DefPathHash; #[inline] @@ -50,7 +46,7 @@ impl ToStableHashKey for ImplItemId { } } -impl ToStableHashKey for ForeignItemId { +impl ToStableHashKey for ForeignItemId { type KeyType = DefPathHash; #[inline] @@ -66,7 +62,7 @@ impl ToStableHashKey for ForeignItemId { // want to pick up on a reference changing its target, so we hash the NodeIds // in "DefPath Mode". -impl<'tcx, Hcx: crate::HashStableContext> HashStable for OwnerNodes<'tcx> { +impl<'tcx, Hcx: HashStableContext> HashStable for OwnerNodes<'tcx> { fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { // We ignore the `nodes` and `bodies` fields since these refer to information included in // `hash` which is hashed in the collector and used for the crate hash. @@ -78,14 +74,14 @@ impl<'tcx, Hcx: crate::HashStableContext> HashStable for OwnerNodes<'tcx> { } } -impl HashStable for DelayedLints { +impl HashStable for DelayedLints { fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let DelayedLints { opt_hash, .. } = *self; opt_hash.unwrap().hash_stable(hcx, hasher); } } -impl<'tcx, Hcx: crate::HashStableContext> HashStable for AttributeMap<'tcx> { +impl<'tcx, Hcx: HashStableContext> HashStable for AttributeMap<'tcx> { fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { // We ignore the `map` since it refers to information included in `opt_hash` which is // hashed in the collector and used for the crate hash. @@ -94,7 +90,7 @@ impl<'tcx, Hcx: crate::HashStableContext> HashStable for AttributeMap<'tcx> } } -impl HashStable for HashIgnoredAttrId { +impl HashStable for HashIgnoredAttrId { fn hash_stable(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) { /* we don't hash HashIgnoredAttrId, we ignore them */ } diff --git a/compiler/rustc_hir_id/src/lib.rs b/compiler/rustc_hir_id/src/lib.rs index ffff3f979f9e3..064ce4ed4cafe 100644 --- a/compiler/rustc_hir_id/src/lib.rs +++ b/compiler/rustc_hir_id/src/lib.rs @@ -8,7 +8,7 @@ use std::fmt::{self, Debug}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableOrd, ToStableHashKey}; use rustc_macros::{Decodable, Encodable, HashStable_Generic}; -pub use rustc_span::HashStableContext; +use rustc_span::HashStableContext; use rustc_span::def_id::{CRATE_DEF_ID, DefId, DefIndex, DefPathHash, LocalDefId}; #[derive(Copy, Clone, PartialEq, Eq, Hash, Encodable, Decodable)] @@ -176,7 +176,7 @@ pub const CRATE_HIR_ID: HirId = pub const CRATE_OWNER_ID: OwnerId = OwnerId { def_id: CRATE_DEF_ID }; -impl ToStableHashKey for HirId { +impl ToStableHashKey for HirId { type KeyType = (DefPathHash, ItemLocalId); #[inline] diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs index af1d1854fa5a0..1c86d553f9b6a 100644 --- a/compiler/rustc_lint_defs/src/lib.rs +++ b/compiler/rustc_lint_defs/src/lib.rs @@ -8,11 +8,11 @@ use rustc_data_structures::stable_hasher::{ HashStable, StableCompare, StableHasher, ToStableHashKey, }; use rustc_error_messages::{DiagArgValue, IntoDiagArg}; -use rustc_hir_id::{HashStableContext, HirId, ItemLocalId}; +use rustc_hir_id::{HirId, ItemLocalId}; use rustc_macros::{Decodable, Encodable, HashStable_Generic}; use rustc_span::def_id::DefPathHash; pub use rustc_span::edition::Edition; -use rustc_span::{Ident, Span, Symbol, sym}; +use rustc_span::{HashStableContext, Ident, Span, Symbol, sym}; use serde::{Deserialize, Serialize}; pub use self::Level::*; diff --git a/compiler/rustc_macros/src/hash_stable.rs b/compiler/rustc_macros/src/hash_stable.rs index fa67adb406ed2..adb93e375c32c 100644 --- a/compiler/rustc_macros/src/hash_stable.rs +++ b/compiler/rustc_macros/src/hash_stable.rs @@ -84,7 +84,7 @@ fn hash_stable_derive_with_mode( match mode { HashStableMode::Normal => {} HashStableMode::Generic => { - s.add_where_predicate(parse_quote! { __CTX: crate::HashStableContext }); + s.add_where_predicate(parse_quote! { __CTX: ::rustc_span::HashStableContext }); } HashStableMode::NoContext => {} } diff --git a/compiler/rustc_middle/src/hir/mod.rs b/compiler/rustc_middle/src/hir/mod.rs index dfce7e0917608..814b333cfb0f8 100644 --- a/compiler/rustc_middle/src/hir/mod.rs +++ b/compiler/rustc_middle/src/hir/mod.rs @@ -21,7 +21,7 @@ use rustc_hir::lints::DelayedLint; use rustc_hir::*; use rustc_index::IndexVec; use rustc_macros::{Decodable, Encodable, HashStable}; -use rustc_span::{ErrorGuaranteed, ExpnId, Span}; +use rustc_span::{ErrorGuaranteed, ExpnId, HashStableContext, Span}; use crate::query::Providers; use crate::ty::{ResolverAstLowering, TyCtxt}; diff --git a/compiler/rustc_middle/src/ich/hcx.rs b/compiler/rustc_middle/src/ich/hcx.rs index 2e118dc3359fa..0e1cee2970f71 100644 --- a/compiler/rustc_middle/src/ich/hcx.rs +++ b/compiler/rustc_middle/src/ich/hcx.rs @@ -6,7 +6,7 @@ use rustc_hir::definitions::DefPathHash; use rustc_session::Session; use rustc_session::cstore::Untracked; use rustc_span::source_map::SourceMap; -use rustc_span::{CachingSourceMapView, DUMMY_SP, Pos, Span}; +use rustc_span::{CachingSourceMapView, DUMMY_SP, HashStableContext, Pos, Span}; // Very often, we are hashing something that does not need the `CachingSourceMapView`, so we // initialize it lazily. @@ -73,7 +73,7 @@ impl<'a> StableHashingContext<'a> { } } -impl<'a> rustc_span::HashStableContext for StableHashingContext<'a> { +impl<'a> HashStableContext for StableHashingContext<'a> { /// Hashes a span in a stable way. We can't directly hash the span's `BytePos` fields (that /// would be similar to hashing pointers, since those are just offsets into the `SourceMap`). /// Instead, we hash the (file name, line, column) triple, which stays the same even if the @@ -189,8 +189,3 @@ impl<'a> rustc_span::HashStableContext for StableHashingContext<'a> { ); } } - -impl<'a> rustc_abi::HashStableContext for StableHashingContext<'a> {} -impl<'a> rustc_ast::HashStableContext for StableHashingContext<'a> {} -impl<'a> rustc_hir::HashStableContext for StableHashingContext<'a> {} -impl<'a> rustc_session::HashStableContext for StableHashingContext<'a> {} diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index e37247d7dd837..1e95482a8c7e6 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -23,7 +23,8 @@ use rustc_macros::{BlobDecodable, Decodable, Encodable, HashStable_Generic}; use rustc_span::edition::{DEFAULT_EDITION, EDITION_NAME_LIST, Edition, LATEST_STABLE_EDITION}; use rustc_span::source_map::FilePathMapping; use rustc_span::{ - FileName, RealFileName, RemapPathScopeComponents, SourceFileHashAlgorithm, Symbol, sym, + FileName, HashStableContext, RealFileName, RemapPathScopeComponents, SourceFileHashAlgorithm, + Symbol, sym, }; use rustc_target::spec::{ FramePointer, LinkSelfContainedComponents, LinkerFeatures, PanicStrategy, SplitDebuginfo, @@ -38,7 +39,7 @@ use crate::errors::FileWriteFail; pub use crate::options::*; use crate::search_paths::SearchPath; use crate::utils::CanonicalizedPath; -use crate::{EarlyDiagCtxt, HashStableContext, Session, filesearch, lint}; +use crate::{EarlyDiagCtxt, Session, filesearch, lint}; mod cfg; mod externs; diff --git a/compiler/rustc_session/src/lib.rs b/compiler/rustc_session/src/lib.rs index 29192f267ed3a..04e12f1afce68 100644 --- a/compiler/rustc_session/src/lib.rs +++ b/compiler/rustc_session/src/lib.rs @@ -29,8 +29,3 @@ mod options; pub mod output; pub mod search_paths; mod session; - -/// Requirements for a `StableHashingContext` to be used in this crate. -/// This is a hack to allow using the `HashStable_Generic` derive macro -/// instead of implementing everything in `rustc_middle`. -pub trait HashStableContext: rustc_ast::HashStableContext + rustc_hir::HashStableContext {} diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index 6794ffb311e32..97de708290fb4 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -2796,10 +2796,10 @@ impl InnerSpan { } } -/// Requirements for a `StableHashingContext` to be used in this crate. -/// -/// This is a hack to allow using the [`HashStable_Generic`] derive macro -/// instead of implementing everything in rustc_middle. +/// This trait lets `HashStable` and `derive(HashStable_Generic)` be used in +/// this crate (and other crates upstream of `rustc_middle`), while leaving +/// certain operations to be defined in `rustc_middle` where more things are +/// visible. pub trait HashStableContext { /// The main event: stable hashing of a span. fn span_hash_stable(&mut self, span: Span, hasher: &mut StableHasher); diff --git a/compiler/rustc_target/src/lib.rs b/compiler/rustc_target/src/lib.rs index 1dc62cb3659cc..d46802bf45d1a 100644 --- a/compiler/rustc_target/src/lib.rs +++ b/compiler/rustc_target/src/lib.rs @@ -24,8 +24,6 @@ pub mod target_features; #[cfg(test)] mod tests; -use rustc_abi::HashStableContext; - /// The name of rustc's own place to organize libraries. /// /// Used to be `rustc`, now the default is `rustlib`.