Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relax bounds on HashMap/HashSet #67642

Merged
merged 2 commits into from Feb 13, 2020
Merged

Conversation

@Mark-Simulacrum
Copy link
Member

Mark-Simulacrum commented Dec 26, 2019

These APIs changed from the old bound listed to the new bound (possibly empty):

K: Hash + Eq -> K

  • new
  • with_capacity

K: Eq + Hash, S: BuildHasher -> K, S

  • with_hasher
  • with_capacity_and_hasher
  • hasher

K: Eq + Hash + Debug -> K: Debug
S: BuildHasher -> S
HashMap as Debug

K: Eq + Hash -> K
S: BuildHasher + Default -> S: Default
HashMap as Default

Resolves #44777.

No functional changes are made, and all APIs are moved to strictly less
restrictive bounds.

These APIs changed from the old bound listed to no trait bounds:

K: Hash + Eq
* new
* with_capacity

K: Eq + Hash, S: BuildHasher
* with_hasher
* with_capacity_and_hasher
* hasher

K: Eq + Hash + Debug -> K: Debug
S: BuildHasher -> S
<HashMap as Debug>

K: Eq + Hash -> K
S: BuildHasher + Default -> S: Default
<HashMap as Default>
@Amanieu

This comment has been minimized.

Copy link
Contributor

Amanieu commented Dec 26, 2019

LGTM

@rfcbot fcp merge

@rfcbot

This comment has been minimized.

Copy link

rfcbot commented Dec 26, 2019

Team member @Amanieu has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

rust-highfive commented Dec 26, 2019

The job x86_64-gnu-llvm-7 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-12-26T19:22:26.4774473Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-12-26T19:22:27.3755736Z ##[command]git config gc.auto 0
2019-12-26T19:22:27.3761106Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-12-26T19:22:27.3765658Z ##[command]git config --get-all http.proxy
2019-12-26T19:22:27.3770582Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/67642/merge:refs/remotes/pull/67642/merge
---
2019-12-26T20:24:12.1786334Z .................................................................................................... 1600/9454
2019-12-26T20:24:17.1051736Z .................................................................................................... 1700/9454
2019-12-26T20:24:26.9343551Z ..............................................................................................i..... 1800/9454
2019-12-26T20:24:35.2669281Z .................................................................................................... 1900/9454
2019-12-26T20:24:42.0488140Z ...............................................................................iiiii................ 2000/9454
2019-12-26T20:25:04.1386033Z .................................................................................................... 2200/9454
2019-12-26T20:25:06.6015517Z .................................................................................................... 2300/9454
2019-12-26T20:25:09.2421595Z .................................................................................................... 2400/9454
2019-12-26T20:25:15.7761896Z .................................................................................................... 2500/9454
---
2019-12-26T20:28:19.0324147Z ..........i...............i......................................................................... 4900/9454
2019-12-26T20:28:29.3874131Z .................................................................................................... 5000/9454
2019-12-26T20:28:34.5683745Z ......................................................i............................................. 5100/9454
2019-12-26T20:28:44.1682390Z .................................................................................................... 5200/9454
2019-12-26T20:28:50.6276057Z .....................ii.ii...........i.............................................................. 5300/9454
2019-12-26T20:28:59.8471321Z .................................................................................................... 5500/9454
2019-12-26T20:29:11.0168981Z .................................................................................................... 5600/9454
2019-12-26T20:29:18.5464324Z ...i................................................................................................ 5700/9454
2019-12-26T20:29:24.3990269Z .................................................................................................... 5800/9454
2019-12-26T20:29:24.3990269Z .................................................................................................... 5800/9454
2019-12-26T20:29:34.6352588Z ...........................................................................................ii...i..i 5900/9454
2019-12-26T20:29:47.4560925Z i............i...................................................................................... 6000/9454
2019-12-26T20:30:06.5475646Z .................................................................................................... 6200/9454
2019-12-26T20:30:13.3618270Z .................................................................................................... 6300/9454
2019-12-26T20:30:13.3618270Z .................................................................................................... 6300/9454
2019-12-26T20:30:28.4376280Z ..................i..ii............................................................................. 6400/9454
2019-12-26T20:30:48.6576270Z ..............................................................................................i..... 6600/9454
2019-12-26T20:30:50.8969523Z .................................................................................................... 6700/9454
2019-12-26T20:30:53.2346395Z ..............................................................................................i..... 6800/9454
2019-12-26T20:30:55.9926247Z .................................................................................................... 6900/9454
---
2019-12-26T20:32:36.6287595Z .................................................................................................... 7500/9454
2019-12-26T20:32:41.6488113Z .................................................................................................... 7600/9454
2019-12-26T20:32:48.4833538Z .................................................................................................... 7700/9454
2019-12-26T20:32:59.2233178Z .................................................................................................... 7800/9454
2019-12-26T20:33:05.9032876Z .........................iiii....................................................................... 7900/9454
2019-12-26T20:33:20.6807012Z .................................................................................................... 8100/9454
2019-12-26T20:33:30.5881883Z .................................................................................................... 8200/9454
2019-12-26T20:33:44.5425714Z .................................................................................................... 8300/9454
2019-12-26T20:33:51.9586164Z .................................................................................................... 8400/9454
---
2019-12-26T20:35:49.1250313Z ---- [ui] ui/const-generics/array-impls/core-traits-no-impls-length-33.rs stdout ----
2019-12-26T20:35:49.1250640Z diff of stderr:
2019-12-26T20:35:49.1250786Z 
2019-12-26T20:35:49.1250935Z 15    |
2019-12-26T20:35:49.1251118Z 16    = note: required because of the requirements on the impl of `std::cmp::Eq` for `[usize; 33]`
2019-12-26T20:35:49.1252038Z - error[E0277]: arrays only have std trait implementations for lengths 0..=32
2019-12-26T20:35:49.1252569Z -   --> $DIR/core-traits-no-impls-length-33.rs:8:19
2019-12-26T20:35:49.1252925Z -    |
2019-12-26T20:35:49.1253320Z - LL |     let mut set = HashSet::new();
2019-12-26T20:35:49.1253320Z - LL |     let mut set = HashSet::new();
2019-12-26T20:35:49.1254177Z -    |                   ^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[usize; 33]`
2019-12-26T20:35:49.1255571Z -    |
2019-12-26T20:35:49.1256050Z -    = note: required because of the requirements on the impl of `std::cmp::Eq` for `[usize; 33]`
2019-12-26T20:35:49.1256472Z -    = note: required by `std::collections::HashSet::<T>::new`
2019-12-26T20:35:49.1257899Z 27 error[E0369]: binary operation `==` cannot be applied to type `[usize; 33]`
2019-12-26T20:35:49.1258418Z 28   --> $DIR/core-traits-no-impls-length-33.rs:15:19
2019-12-26T20:35:49.1258584Z 29    |
2019-12-26T20:35:49.1260429Z 
2019-12-26T20:35:49.1260429Z 
2019-12-26T20:35:49.1261219Z 57              <&'a mut [T] as std::iter::IntoIterator>
2019-12-26T20:35:49.1262246Z 59 
2019-12-26T20:35:49.1262670Z - error: aborting due to 6 previous errors
2019-12-26T20:35:49.1262861Z + error: aborting due to 5 previous errors
2019-12-26T20:35:49.1263030Z 61 
2019-12-26T20:35:49.1263030Z 61 
2019-12-26T20:35:49.1263182Z 62 Some errors have detailed explanations: E0277, E0369.
2019-12-26T20:35:49.1263588Z 63 For more information about an error, try `rustc --explain E0277`.
2019-12-26T20:35:49.1263754Z 
2019-12-26T20:35:49.1263900Z 
2019-12-26T20:35:49.1264051Z The actual stderr differed from the expected stderr.
2019-12-26T20:35:49.1264571Z Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/const-generics/array-impls/core-traits-no-impls-length-33/core-traits-no-impls-length-33.stderr
2019-12-26T20:35:49.1265033Z To update references, rerun the tests and pass the `--bless` flag
2019-12-26T20:35:49.1265552Z To only update this specific test, also pass `--test-args const-generics/array-impls/core-traits-no-impls-length-33.rs`
2019-12-26T20:35:49.1265875Z error: 1 errors occurred comparing output.
2019-12-26T20:35:49.1266206Z status: exit code: 1
2019-12-26T20:35:49.1266206Z status: exit code: 1
2019-12-26T20:35:49.1267899Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/const-generics/array-impls/core-traits-no-impls-length-33" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/const-generics/array-impls/core-traits-no-impls-length-33/auxiliary" "-A" "unused"
2019-12-26T20:35:49.1269638Z ------------------------------------------
2019-12-26T20:35:49.1269827Z 
2019-12-26T20:35:49.1270173Z ------------------------------------------
2019-12-26T20:35:49.1270343Z stderr:
2019-12-26T20:35:49.1270343Z stderr:
2019-12-26T20:35:49.1270699Z ------------------------------------------
2019-12-26T20:35:49.1274739Z error[E0277]: arrays only have std trait implementations for lengths 0..=32
2019-12-26T20:35:49.1277092Z   --> /checkout/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.rs:2:22
2019-12-26T20:35:49.1277332Z    |
2019-12-26T20:35:49.1277680Z LL |     println!("{:?}", [0_usize; 33]);
2019-12-26T20:35:49.1277871Z    |                      ^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[usize; 33]`
2019-12-26T20:35:49.1278174Z    = note: required because of the requirements on the impl of `std::fmt::Debug` for `[usize; 33]`
2019-12-26T20:35:49.1278337Z    = note: required by `std::fmt::Debug::fmt`
2019-12-26T20:35:49.1278468Z 
2019-12-26T20:35:49.1278800Z error[E0277]: arrays only have std trait implementations for lengths 0..=32
2019-12-26T20:35:49.1278800Z error[E0277]: arrays only have std trait implementations for lengths 0..=32
2019-12-26T20:35:49.1279601Z   --> /checkout/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.rs:10:16
2019-12-26T20:35:49.1279791Z    |
2019-12-26T20:35:49.1279960Z LL |     set.insert([0_usize; 33]);
2019-12-26T20:35:49.1280120Z    |                ^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[usize; 33]`
2019-12-26T20:35:49.1280280Z    |
2019-12-26T20:35:49.1280522Z    = note: required because of the requirements on the impl of `std::cmp::Eq` for `[usize; 33]`
2019-12-26T20:35:49.1281207Z error[E0369]: binary operation `==` cannot be applied to type `[usize; 33]`
2019-12-26T20:35:49.1282253Z   --> /checkout/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.rs:15:19
2019-12-26T20:35:49.1284309Z    |
2019-12-26T20:35:49.1284309Z    |
2019-12-26T20:35:49.1284638Z LL |     [0_usize; 33] == [1_usize; 33]
2019-12-26T20:35:49.1285039Z    |     ------------- ^^ ------------- [usize; 33]
2019-12-26T20:35:49.1285134Z    |     [usize; 33]
2019-12-26T20:35:49.1285196Z    |
2019-12-26T20:35:49.1285246Z    = note: an implementation of `std::cmp::PartialEq` might be missing for `[usize; 33]`
2019-12-26T20:35:49.1285281Z 
2019-12-26T20:35:49.1285281Z 
2019-12-26T20:35:49.1285329Z error[E0369]: binary operation `<` cannot be applied to type `[usize; 33]`
2019-12-26T20:35:49.1285631Z   --> /checkout/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.rs:20:19
2019-12-26T20:35:49.1285690Z    |
2019-12-26T20:35:49.1285733Z LL |     [0_usize; 33] < [1_usize; 33]
2019-12-26T20:35:49.1285975Z    |     ------------- ^ ------------- [usize; 33]
2019-12-26T20:35:49.1286064Z    |     [usize; 33]
2019-12-26T20:35:49.1286284Z    |
2019-12-26T20:35:49.1286284Z    |
2019-12-26T20:35:49.1286334Z    = note: an implementation of `std::cmp::PartialOrd` might be missing for `[usize; 33]`
2019-12-26T20:35:49.1286531Z 
2019-12-26T20:35:49.1286584Z error[E0277]: the trait bound `&[usize; 33]: std::iter::IntoIterator` is not satisfied
2019-12-26T20:35:49.1287027Z   --> /checkout/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.rs:25:14
2019-12-26T20:35:49.1287072Z    |
2019-12-26T20:35:49.1287111Z LL |     for _ in &[0_usize; 33] {
2019-12-26T20:35:49.1287339Z    |              ^^^^^^^^^^^^^^ the trait `std::iter::IntoIterator` is not implemented for `&[usize; 33]`
2019-12-26T20:35:49.1287598Z    = help: the following implementations were found:
2019-12-26T20:35:49.1287598Z    = help: the following implementations were found:
2019-12-26T20:35:49.1288004Z              <&'a [T; _] as std::iter::IntoIterator>
2019-12-26T20:35:49.1288202Z              <&'a [T] as std::iter::IntoIterator>
2019-12-26T20:35:49.1288406Z              <&'a mut [T; _] as std::iter::IntoIterator>
2019-12-26T20:35:49.1288623Z              <&'a mut [T] as std::iter::IntoIterator>
2019-12-26T20:35:49.1288698Z 
2019-12-26T20:35:49.1288810Z error: aborting due to 5 previous errors
2019-12-26T20:35:49.1288861Z 
2019-12-26T20:35:49.1288902Z Some errors have detailed explanations: E0277, E0369.
---
2019-12-26T20:35:49.1290000Z test result: FAILED. 9406 passed; 1 failed; 47 ignored; 0 measured; 0 filtered out
2019-12-26T20:35:49.1290049Z 
2019-12-26T20:35:49.1290072Z 
2019-12-26T20:35:49.1290097Z 
2019-12-26T20:35:49.1292240Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-7/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "7.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
2019-12-26T20:35:49.1292497Z 
2019-12-26T20:35:49.1292528Z 
2019-12-26T20:35:49.1292855Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:385:22
2019-12-26T20:35:49.1292917Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
2019-12-26T20:35:49.1292917Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
2019-12-26T20:35:49.1294574Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-12-26T20:35:49.1294659Z Build completed unsuccessfully in 1:06:20
2019-12-26T20:35:49.1352411Z == clock drift check ==
2019-12-26T20:35:49.1377714Z   local time: Thu Dec 26 20:35:49 UTC 2019
2019-12-26T20:35:49.2451433Z   network time: Thu, 26 Dec 2019 20:35:49 GMT
2019-12-26T20:35:49.2453727Z == end clock drift check ==
2019-12-26T20:35:50.3076421Z 
2019-12-26T20:35:50.3187034Z ##[error]Bash exited with code '1'.
2019-12-26T20:35:50.3233344Z ##[section]Starting: Checkout
2019-12-26T20:35:50.3235144Z ==============================================================================
2019-12-26T20:35:50.3235221Z Task         : Get sources
2019-12-26T20:35:50.3235274Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@Mark-Simulacrum

This comment has been minimized.

Copy link
Member Author

Mark-Simulacrum commented Dec 26, 2019

Test failure appears to be because it is now possible to create a HashSet from [u8; 33] whereas it wasn't before. I will rebless shortly.

@Mark-Simulacrum Mark-Simulacrum force-pushed the Mark-Simulacrum:relax-bounds branch from 469a8da to 5514ead Dec 26, 2019
@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

rust-highfive commented Dec 26, 2019

The job x86_64-gnu-llvm-7 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-12-26T21:30:32.3040474Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-12-26T21:30:32.3237116Z ##[command]git config gc.auto 0
2019-12-26T21:30:32.3314371Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-12-26T21:30:32.3361949Z ##[command]git config --get-all http.proxy
2019-12-26T21:30:32.3508951Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/67642/merge:refs/remotes/pull/67642/merge
---
2019-12-26T22:29:38.9714568Z .................................................................................................... 1600/9455
2019-12-26T22:29:43.4862766Z .................................................................................................... 1700/9455
2019-12-26T22:29:52.4178689Z .............................................................................................i...... 1800/9455
2019-12-26T22:30:00.1448754Z .................................................................................................... 1900/9455
2019-12-26T22:30:06.5328013Z ...............................................................................iiiii................ 2000/9455
2019-12-26T22:30:27.6483318Z .................................................................................................... 2200/9455
2019-12-26T22:30:29.8420474Z .................................................................................................... 2300/9455
2019-12-26T22:30:32.2103678Z .................................................................................................... 2400/9455
2019-12-26T22:30:38.1168430Z .................................................................................................... 2500/9455
---
2019-12-26T22:33:29.8949363Z ..........i...............i......................................................................... 4900/9455
2019-12-26T22:33:39.6027119Z .................................................................................................... 5000/9455
2019-12-26T22:33:44.6328278Z ......................................................i............................................. 5100/9455
2019-12-26T22:33:53.8370408Z .................................................................................................... 5200/9455
2019-12-26T22:33:59.8837506Z .....................ii.ii...........i.............................................................. 5300/9455
2019-12-26T22:34:08.5762358Z .................................................................................................... 5500/9455
2019-12-26T22:34:19.1067963Z .................................................................................................... 5600/9455
2019-12-26T22:34:26.0439434Z ...i................................................................................................ 5700/9455
2019-12-26T22:34:31.4290519Z .................................................................................................... 5800/9455
2019-12-26T22:34:31.4290519Z .................................................................................................... 5800/9455
2019-12-26T22:34:41.0930903Z ...........................................................................................ii...i..i 5900/9455
2019-12-26T22:34:53.2164806Z i...........i....................................................................................... 6000/9455
2019-12-26T22:35:09.9138287Z .................................................................................................... 6200/9455
2019-12-26T22:35:16.8240618Z .................................................................................................... 6300/9455
2019-12-26T22:35:16.8240618Z .................................................................................................... 6300/9455
2019-12-26T22:35:33.3786224Z ..................i..ii............................................................................. 6400/9455
2019-12-26T22:35:52.4419532Z ...............................................................................................i.... 6600/9455
2019-12-26T22:35:54.4610516Z .................................................................................................... 6700/9455
2019-12-26T22:35:56.5559170Z ...............................................................................................i.... 6800/9455
2019-12-26T22:35:59.0553413Z .................................................................................................... 6900/9455
---
2019-12-26T22:37:33.6382663Z .................................................................................................... 7500/9455
2019-12-26T22:37:38.2633430Z .................................................................................................... 7600/9455
2019-12-26T22:37:44.5500298Z .................................................................................................... 7700/9455
2019-12-26T22:37:54.7464259Z .................................................................................................... 7800/9455
2019-12-26T22:38:00.9679688Z ..........................iiii...................................................................... 7900/9455
2019-12-26T22:38:15.4686950Z .................................................................................................... 8100/9455
2019-12-26T22:38:24.2299517Z .................................................................................................... 8200/9455
2019-12-26T22:38:37.9731629Z .................................................................................................... 8300/9455
2019-12-26T22:38:44.1652389Z .................................................................................................... 8400/9455
---
2019-12-26T22:40:35.9702167Z error: /checkout/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.rs:8: expected error not found: arrays only have std trait implementations for lengths 0..=32
2019-12-26T22:40:35.9702354Z 
2019-12-26T22:40:35.9702525Z error: 0 unexpected errors found, 1 expected errors not found
2019-12-26T22:40:35.9702660Z status: exit code: 1
2019-12-26T22:40:35.9704173Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/const-generics/array-impls/core-traits-no-impls-length-33" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/const-generics/array-impls/core-traits-no-impls-length-33/auxiliary" "-A" "unused"
2019-12-26T22:40:35.9704711Z     Error {
2019-12-26T22:40:35.9704843Z         line_num: 8,
2019-12-26T22:40:35.9704984Z         kind: Some(
2019-12-26T22:40:35.9705108Z             Error,
---
2019-12-26T22:40:35.9711482Z 
2019-12-26T22:40:35.9712035Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:385:22
2019-12-26T22:40:35.9717081Z 
2019-12-26T22:40:35.9717284Z 
2019-12-26T22:40:35.9723398Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-7/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "7.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
2019-12-26T22:40:35.9724309Z 
2019-12-26T22:40:35.9724363Z 
2019-12-26T22:40:35.9744643Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-12-26T22:40:35.9744800Z Build completed unsuccessfully in 1:03:26
2019-12-26T22:40:35.9744800Z Build completed unsuccessfully in 1:03:26
2019-12-26T22:40:35.9803542Z == clock drift check ==
2019-12-26T22:40:35.9823199Z   local time: Thu Dec 26 22:40:35 UTC 2019
2019-12-26T22:40:36.2751623Z   network time: Thu, 26 Dec 2019 22:40:36 GMT
2019-12-26T22:40:36.2751727Z == end clock drift check ==
2019-12-26T22:40:37.4199496Z 
2019-12-26T22:40:37.4320267Z ##[error]Bash exited with code '1'.
2019-12-26T22:40:37.4365367Z ##[section]Starting: Checkout
2019-12-26T22:40:37.4366891Z ==============================================================================
2019-12-26T22:40:37.4366958Z Task         : Get sources
2019-12-26T22:40:37.4367145Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@Mark-Simulacrum Mark-Simulacrum force-pushed the Mark-Simulacrum:relax-bounds branch from 5514ead to 515f642 Dec 26, 2019
@sfackler

This comment has been minimized.

Copy link
Member

sfackler commented Dec 26, 2019

What's the rationale for allowing the creation of maps that can't be used?

@Mark-Simulacrum

This comment has been minimized.

Copy link
Member Author

Mark-Simulacrum commented Dec 26, 2019

I think the primary rationale from my perspective (I am not the one who filed the original issue, nor do I have a use case myself) is to allow wrapping HashMap/HashSet in types that don't necessarily want to constrain themselves to using those always. I am not sure that I have a concrete use case -- most things I can come up with would know the type parameters (i.e., not actually be generic).

My loose idea is a type that wants to construct a HashSet/Map eagerly but may not use it except for some use cases (e.g., some graph data structure that caches nodes/edges if you call some methods, but can be used without those methods in some cases).

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Dec 27, 2019

The job x86_64-gnu-llvm-7 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-12-26T22:50:33.8714030Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-12-26T22:50:33.8731087Z ##[command]git config gc.auto 0
2019-12-26T22:50:33.8733928Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-12-26T22:50:33.8736858Z ##[command]git config --get-all http.proxy
2019-12-26T22:50:33.8739306Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/67642/merge:refs/remotes/pull/67642/merge
---
2019-12-26T23:53:04.7459203Z .................................................................................................... 1600/9455
2019-12-26T23:53:09.9326183Z .................................................................................................... 1700/9455
2019-12-26T23:53:19.9258673Z .............................................................................................i...... 1800/9455
2019-12-26T23:53:28.5551899Z .................................................................................................... 1900/9455
2019-12-26T23:53:35.6423539Z ...............................................................................iiiii................ 2000/9455
2019-12-26T23:53:58.4831435Z .................................................................................................... 2200/9455
2019-12-26T23:54:00.9873085Z .................................................................................................... 2300/9455
2019-12-26T23:54:03.6722711Z .................................................................................................... 2400/9455
2019-12-26T23:54:10.3211033Z .................................................................................................... 2500/9455
---
2019-12-26T23:57:17.3139580Z ..........i...............i......................................................................... 4900/9455
2019-12-26T23:57:27.7274689Z .................................................................................................... 5000/9455
2019-12-26T23:57:32.9979015Z ......................................................i............................................. 5100/9455
2019-12-26T23:57:42.8918905Z .................................................................................................... 5200/9455
2019-12-26T23:57:49.5091380Z .....................ii.ii...........i.............................................................. 5300/9455
2019-12-26T23:57:59.0279142Z .................................................................................................... 5500/9455
2019-12-26T23:58:10.4486694Z .................................................................................................... 5600/9455
2019-12-26T23:58:18.0421934Z ...i................................................................................................ 5700/9455
2019-12-26T23:58:23.9943519Z .................................................................................................... 5800/9455
2019-12-26T23:58:23.9943519Z .................................................................................................... 5800/9455
2019-12-26T23:58:34.6370576Z ...........................................................................................ii...i..i 5900/9455
2019-12-26T23:58:47.8313982Z i...........i....................................................................................... 6000/9455
2019-12-26T23:59:06.2283898Z .................................................................................................... 6200/9455
2019-12-26T23:59:13.8599721Z .................................................................................................... 6300/9455
2019-12-26T23:59:13.8599721Z .................................................................................................... 6300/9455
2019-12-26T23:59:31.2246975Z ..................i..ii............................................................................. 6400/9455
2019-12-26T23:59:51.9843990Z ...............................................................................................i.... 6600/9455
2019-12-26T23:59:54.2539992Z .................................................................................................... 6700/9455
2019-12-26T23:59:56.6400083Z ...............................................................................................i.... 6800/9455
2019-12-26T23:59:59.4505121Z .................................................................................................... 6900/9455
---
2019-12-27T00:01:42.8250873Z .................................................................................................... 7500/9455
2019-12-27T00:01:47.9038732Z .................................................................................................... 7600/9455
2019-12-27T00:01:54.9540174Z .................................................................................................... 7700/9455
2019-12-27T00:02:06.1131880Z .................................................................................................... 7800/9455
2019-12-27T00:02:13.0664847Z ..........................iiii...................................................................... 7900/9455
2019-12-27T00:02:28.4860979Z .................................................................................................... 8100/9455
2019-12-27T00:02:38.5788464Z .................................................................................................... 8200/9455
2019-12-27T00:02:52.9164876Z .................................................................................................... 8300/9455
2019-12-27T00:03:00.5837149Z .................................................................................................... 8400/9455
---
2019-12-27T00:05:02.4815984Z 10 error[E0277]: arrays only have std trait implementations for lengths 0..=32
2019-12-27T00:05:02.4816421Z -   --> $DIR/core-traits-no-impls-length-33.rs:10:16
2019-12-27T00:05:02.4817130Z +   --> $DIR/core-traits-no-impls-length-33.rs:9:16
2019-12-27T00:05:02.4817322Z 12    |
2019-12-27T00:05:02.4817714Z 13 LL |     set.insert([0_usize; 33]);
2019-12-27T00:05:02.4817924Z 14    |                ^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[usize; 33]`
2019-12-27T00:05:02.4818062Z 
2019-12-27T00:05:02.4818270Z 16    = note: required because of the requirements on the impl of `std::cmp::Eq` for `[usize; 33]`
2019-12-27T00:05:02.4818580Z 18 error[E0369]: binary operation `==` cannot be applied to type `[usize; 33]`
2019-12-27T00:05:02.4819350Z -   --> $DIR/core-traits-no-impls-length-33.rs:15:19
2019-12-27T00:05:02.4820183Z +   --> $DIR/core-traits-no-impls-length-33.rs:14:19
2019-12-27T00:05:02.4820641Z 20    |
2019-12-27T00:05:02.4820641Z 20    |
2019-12-27T00:05:02.4820798Z 21 LL |     [0_usize; 33] == [1_usize; 33]
2019-12-27T00:05:02.4821210Z 22    |     ------------- ^^ ------------- [usize; 33]
2019-12-27T00:05:02.4821578Z 26    = note: an implementation of `std::cmp::PartialEq` might be missing for `[usize; 33]`
2019-12-27T00:05:02.4821723Z 27 
2019-12-27T00:05:02.4821723Z 27 
2019-12-27T00:05:02.4821896Z 28 error[E0369]: binary operation `<` cannot be applied to type `[usize; 33]`
2019-12-27T00:05:02.4822488Z -   --> $DIR/core-traits-no-impls-length-33.rs:20:19
2019-12-27T00:05:02.4826019Z +   --> $DIR/core-traits-no-impls-length-33.rs:19:19
2019-12-27T00:05:02.4826306Z 30    |
2019-12-27T00:05:02.4826455Z 31 LL |     [0_usize; 33] < [1_usize; 33]
2019-12-27T00:05:02.4827017Z 32    |     ------------- ^ ------------- [usize; 33]
2019-12-27T00:05:02.4827414Z 
2019-12-27T00:05:02.4827738Z 36    = note: an implementation of `std::cmp::PartialOrd` might be missing for `[usize; 33]`
2019-12-27T00:05:02.4827907Z 37 
2019-12-27T00:05:02.4828059Z 38 error[E0277]: the trait bound `&[usize; 33]: std::iter::IntoIterator` is not satisfied
2019-12-27T00:05:02.4829118Z -   --> $DIR/core-traits-no-impls-length-33.rs:25:14
2019-12-27T00:05:02.4829751Z +   --> $DIR/core-traits-no-impls-length-33.rs:24:14
2019-12-27T00:05:02.4829943Z 40    |
2019-12-27T00:05:02.4830088Z 41 LL |     for _ in &[0_usize; 33] {
2019-12-27T00:05:02.4830274Z 42    |              ^^^^^^^^^^^^^^ the trait `std::iter::IntoIterator` is not implemented for `&[usize; 33]`
2019-12-27T00:05:02.4830523Z 
2019-12-27T00:05:02.4830685Z The actual stderr differed from the expected stderr.
2019-12-27T00:05:02.4830685Z The actual stderr differed from the expected stderr.
2019-12-27T00:05:02.4831194Z Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/const-generics/array-impls/core-traits-no-impls-length-33/core-traits-no-impls-length-33.stderr
2019-12-27T00:05:02.4831626Z To update references, rerun the tests and pass the `--bless` flag
2019-12-27T00:05:02.4832145Z To only update this specific test, also pass `--test-args const-generics/array-impls/core-traits-no-impls-length-33.rs`
2019-12-27T00:05:02.4832461Z error: 1 errors occurred comparing output.
2019-12-27T00:05:02.4832924Z status: exit code: 1
2019-12-27T00:05:02.4832924Z status: exit code: 1
2019-12-27T00:05:02.4834024Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/const-generics/array-impls/core-traits-no-impls-length-33" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/const-generics/array-impls/core-traits-no-impls-length-33/auxiliary" "-A" "unused"
2019-12-27T00:05:02.4834847Z ------------------------------------------
2019-12-27T00:05:02.4835171Z 
2019-12-27T00:05:02.4835827Z ------------------------------------------
2019-12-27T00:05:02.4836217Z stderr:
2019-12-27T00:05:02.4836217Z stderr:
2019-12-27T00:05:02.4836933Z ------------------------------------------
2019-12-27T00:05:02.4837228Z error[E0277]: arrays only have std trait implementations for lengths 0..=32
2019-12-27T00:05:02.4837972Z   --> /checkout/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.rs:2:22
2019-12-27T00:05:02.4841909Z    |
2019-12-27T00:05:02.4845291Z LL |     println!("{:?}", [0_usize; 33]);
2019-12-27T00:05:02.4851033Z    |                      ^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[usize; 33]`
2019-12-27T00:05:02.4852368Z    = note: required because of the requirements on the impl of `std::fmt::Debug` for `[usize; 33]`
2019-12-27T00:05:02.4852583Z    = note: required by `std::fmt::Debug::fmt`
2019-12-27T00:05:02.4852713Z 
2019-12-27T00:05:02.4852974Z error[E0277]: arrays only have std trait implementations for lengths 0..=32
2019-12-27T00:05:02.4852974Z error[E0277]: arrays only have std trait implementations for lengths 0..=32
2019-12-27T00:05:02.4853587Z   --> /checkout/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.rs:9:16
2019-12-27T00:05:02.4853819Z    |
2019-12-27T00:05:02.4854068Z LL |     set.insert([0_usize; 33]);
2019-12-27T00:05:02.4854318Z    |                ^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[usize; 33]`
2019-12-27T00:05:02.4854588Z    |
2019-12-27T00:05:02.4854834Z    = note: required because of the requirements on the impl of `std::cmp::Eq` for `[usize; 33]`
2019-12-27T00:05:02.4855289Z error[E0369]: binary operation `==` cannot be applied to type `[usize; 33]`
2019-12-27T00:05:02.4855860Z   --> /checkout/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.rs:14:19
2019-12-27T00:05:02.4856773Z    |
2019-12-27T00:05:02.4856773Z    |
2019-12-27T00:05:02.4856844Z LL |     [0_usize; 33] == [1_usize; 33]
2019-12-27T00:05:02.4857161Z    |     ------------- ^^ ------------- [usize; 33]
2019-12-27T00:05:02.4857275Z    |     [usize; 33]
2019-12-27T00:05:02.4857316Z    |
2019-12-27T00:05:02.4857378Z    = note: an implementation of `std::cmp::PartialEq` might be missing for `[usize; 33]`
2019-12-27T00:05:02.4857411Z 
2019-12-27T00:05:02.4857411Z 
2019-12-27T00:05:02.4857485Z error[E0369]: binary operation `<` cannot be applied to type `[usize; 33]`
2019-12-27T00:05:02.4857766Z   --> /checkout/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.rs:19:19
2019-12-27T00:05:02.4857816Z    |
2019-12-27T00:05:02.4857879Z LL |     [0_usize; 33] < [1_usize; 33]
2019-12-27T00:05:02.4858103Z    |     ------------- ^ ------------- [usize; 33]
2019-12-27T00:05:02.4858213Z    |     [usize; 33]
2019-12-27T00:05:02.4858254Z    |
2019-12-27T00:05:02.4858254Z    |
2019-12-27T00:05:02.4858304Z    = note: an implementation of `std::cmp::PartialOrd` might be missing for `[usize; 33]`
2019-12-27T00:05:02.4858338Z 
2019-12-27T00:05:02.4858406Z error[E0277]: the trait bound `&[usize; 33]: std::iter::IntoIterator` is not satisfied
2019-12-27T00:05:02.4858681Z   --> /checkout/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.rs:24:14
2019-12-27T00:05:02.4858739Z    |
2019-12-27T00:05:02.4858805Z LL |     for _ in &[0_usize; 33] {
2019-12-27T00:05:02.4858866Z    |              ^^^^^^^^^^^^^^ the trait `std::iter::IntoIterator` is not implemented for `&[usize; 33]`
2019-12-27T00:05:02.4859330Z    = help: the following implementations were found:
2019-12-27T00:05:02.4859330Z    = help: the following implementations were found:
2019-12-27T00:05:02.4859606Z              <&'a [T; _] as std::iter::IntoIterator>
2019-12-27T00:05:02.4859830Z              <&'a [T] as std::iter::IntoIterator>
2019-12-27T00:05:02.4860080Z              <&'a mut [T; _] as std::iter::IntoIterator>
2019-12-27T00:05:02.4860310Z              <&'a mut [T] as std::iter::IntoIterator>
2019-12-27T00:05:02.4860394Z 
2019-12-27T00:05:02.4860456Z error: aborting due to 5 previous errors
2019-12-27T00:05:02.4860485Z 
2019-12-27T00:05:02.4860529Z Some errors have detailed explanations: E0277, E0369.
---
2019-12-27T00:05:02.4862409Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:385:22
2019-12-27T00:05:02.4862486Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
2019-12-27T00:05:02.4862520Z 
2019-12-27T00:05:02.4862545Z 
2019-12-27T00:05:02.4864314Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-7/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "7.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
2019-12-27T00:05:02.4864743Z 
2019-12-27T00:05:02.4864772Z 
2019-12-27T00:05:02.4867965Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-12-27T00:05:02.4868038Z Build completed unsuccessfully in 1:07:42
2019-12-27T00:05:02.4868038Z Build completed unsuccessfully in 1:07:42
2019-12-27T00:05:02.4905930Z == clock drift check ==
2019-12-27T00:05:02.4922803Z   local time: Fri Dec 27 00:05:02 UTC 2019
2019-12-27T00:05:02.6557093Z   network time: Fri, 27 Dec 2019 00:05:02 GMT
2019-12-27T00:05:02.6564415Z == end clock drift check ==
2019-12-27T00:05:03.8093606Z 
2019-12-27T00:05:03.8241560Z ##[error]Bash exited with code '1'.
2019-12-27T00:05:03.8288174Z ##[section]Starting: Checkout
2019-12-27T00:05:03.8290895Z ==============================================================================
2019-12-27T00:05:03.8290970Z Task         : Get sources
2019-12-27T00:05:03.8291019Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

No functional changes are made, and all APIs are moved to strictly less
restrictive bounds.

These APIs changed from the old bound listed to the new bound:

T: Hash + Eq -> T
* new
* with_capacity

T: Eq + Hash, S: BuildHasher -> T
* with_hasher
* with_capacity_and_hasher
* hasher

T: Eq + Hash + Debug -> T: Debug
S: BuildHasher -> S
<HashSet as Debug>

T: Eq + Hash -> T
S: BuildHasher + Default -> S: Default
<HashSet as Default>
@Mark-Simulacrum Mark-Simulacrum force-pushed the Mark-Simulacrum:relax-bounds branch from 515f642 to 48859db Dec 27, 2019
@Amanieu

This comment has been minimized.

Copy link
Contributor

Amanieu commented Dec 28, 2019

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 28, 2019

📌 Commit 48859db has been approved by Amanieu

@Amanieu

This comment has been minimized.

Copy link
Contributor

Amanieu commented Dec 28, 2019

@bors r-

Oops, wrong window.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Jan 6, 2020

IIRC this is a general guideline that we've used for libstd historically, only requiring bounds when absolutely necessary. While there's not much use in creating defunkt objects relaxing the bounds can often make generic programming much easier since you don't have to thread through so many bounds in so many places.

For example Arc::new doesn't require Send+Sync values, and while Arc<T> is more useful than HashMap<K, V, NotAHasher> I think roughly the same principle applies.

Now that being said there's also the point to be made of being conservative. I suspect these bounds were actually used at some point and refactorings have since enabled us to not need them. By removing them we're never going to be able to design a hash map where they're required for these methods. That being said the current hash table is quite good, so I suspect we won't have to worry about this too too much.

@Mark-Simulacrum

This comment has been minimized.

Copy link
Member Author

Mark-Simulacrum commented Jan 6, 2020

That being said the current hash table is quite good, so I suspect we won't have to worry about this too too much.

We already provide iter() without requiring anything (i.e., K, V, and S are boundless), so Debug is implementable atop that.

The construction methods are the only ones which are a bit up in the air -- I could see us wanting to use some property of the hasher to decide how much to allocate in the future (e.g., how many "spare bits" we need or so), but I don't think it's a huge concern as I'm not aware of cases where HashMaps specialize for the hasher being used in such a way.

@rfcbot

This comment has been minimized.

Copy link

rfcbot commented Jan 11, 2020

🔔 This is now entering its final comment period, as per the review above. 🔔

@withoutboats

This comment has been minimized.

Copy link
Contributor

withoutboats commented Jan 13, 2020

I'm a bit concerned about doing this but I can't necessarily say why. It's always seemed like we were buying ourselves some cover for future compatibility by only allowing HashMaps to be constructed with hashable keys. I think I'd like to get more user feedback on this change before merging it, try to find if any community members have a compelling reason we shouldn't do this.

@Mark-Simulacrum

This comment has been minimized.

Copy link
Member Author

Mark-Simulacrum commented Jan 13, 2020

@withoutboats Do you want me to pursue that in a material way? I'm not sure where we can ask for user feedback (or who you have in mind, if anyone).

I don't personally have any stake in this either so if we choose to close it, that's fine by me as well, but I'll then also close this issue that spawned this.

@withoutboats

This comment has been minimized.

Copy link
Contributor

withoutboats commented Jan 14, 2020

@Mark-Simulacrum Not sure. If no one feels strongly either way, I'd have no concern at all pruning the bounds on things other than constructors.

I'll try to figure out how to get more feedback on the constructors changes.

@dtolnay

This comment has been minimized.

Copy link
Member

dtolnay commented Jan 14, 2020

#67642 (comment) sounds like it's referring to the K: Eq + Hash bounds on the constructors. I can't see us needing those because the only thing they do is give the constructor the ability to compare and hash keys, but a constructor would never have access to any keys that it might compare or hash. So if constructors don't possess any keys, anything they can do with an Eq + Hash bound can also be done without the bound.

#67642 (comment) refers to the S: BuildHasher bound which I suppose is possible could be useful.

@Mark-Simulacrum

This comment has been minimized.

Copy link
Member Author

Mark-Simulacrum commented Jan 16, 2020

A concrete proposal: let's re-add the BuildHasher bound, but drop the K/V bounds. I believe no one has given a reason for the K/V bounds (hard to imagine one, too, as keys and values aren't available at that point, not much you can Hash/Eq in that case), but the BuildHasher bound seems potentially useful.

@withoutboats how would you feel about this PR given that?

@rfcbot

This comment has been minimized.

Copy link

rfcbot commented Jan 21, 2020

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

The RFC will be merged soon.

@withoutboats

This comment has been minimized.

Copy link
Contributor

withoutboats commented Jan 21, 2020

sounds like it's referring to the K: Eq + Hash bounds on the constructors. I can't see us needing those because the only thing they do is give the constructor the ability to compare and hash keys, but a constructor would never have access to any keys that it might compare or hash.

My point is that you can't construct a hashmap value today unless its keys are eq and hash. So such a value cannot exist. There were previous discussions (a long time ago, so the details are vague to me) in which this seemed to provide some forward compatibility leeway for desirable changes.

@withoutboats

This comment has been minimized.

Copy link
Contributor

withoutboats commented Feb 12, 2020

Since no one has brought anything up, I've checked my box, don't block on my vague concern.

@Mark-Simulacrum

This comment has been minimized.

Copy link
Member Author

Mark-Simulacrum commented Feb 12, 2020

Okay, then I believe we are ready to go ahead with this. I'm not sure if @Amanieu meant the original "LGTM" comment as a review as well, so let's do r? @Amanieu for final review

@Amanieu

This comment has been minimized.

Copy link
Contributor

Amanieu commented Feb 12, 2020

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Feb 12, 2020

📌 Commit 48859db has been approved by Amanieu

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Feb 13, 2020
…nieu

Relax bounds on HashMap/HashSet

These APIs changed from the old bound listed to the new bound (possibly empty):

K: Hash + Eq -> K
* new
* with_capacity

K: Eq + Hash, S: BuildHasher -> K, S
* with_hasher
* with_capacity_and_hasher
* hasher

K: Eq + Hash + Debug -> K: Debug
S: BuildHasher -> S
HashMap as Debug

K: Eq + Hash -> K
S: BuildHasher + Default -> S: Default
HashMap as Default

Resolves rust-lang#44777.
bors added a commit that referenced this pull request Feb 13, 2020
Rollup of 9 pull requests

Successful merges:

 - #67642 (Relax bounds on HashMap/HashSet)
 - #68848 (Hasten macro parsing)
 - #69008 (Properly use parent generics for opaque types)
 - #69048 (Suggestion when encountering assoc types from hrtb)
 - #69049 (Optimize image sizes)
 - #69050 (Micro-optimize the heck out of LEB128 reading and writing.)
 - #69068 (Make the SGX arg cleanup implementation a NOP)
 - #69082 (When expecting `BoxFuture` and using `async {}`, suggest `Box::pin`)
 - #69104 (bootstrap: Configure cmake when building sanitizer runtimes)

Failed merges:

r? @ghost
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Feb 13, 2020

⌛️ Testing commit 48859db with merge 2e6eace...

@bors bors merged commit 48859db into rust-lang:master Feb 13, 2020
4 of 5 checks passed
4 of 5 checks passed
homu Testing commit 48859db151b839518bdd9d44a2387c0f6b65d141 with merge 2e6eaceedeeda764056eb0e2134735793533770d...
Details
pr Build #20191227.2 succeeded
Details
pr (Linux mingw-check) Linux mingw-check succeeded
Details
pr (Linux x86_64-gnu-llvm-7) Linux x86_64-gnu-llvm-7 succeeded
Details
pr (Linux x86_64-gnu-tools) Linux x86_64-gnu-tools succeeded
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

9 participants
You can’t perform that action at this time.