Repository navigation
False negative for "the trait bound K: Ord is not satisfied" #88244
Description
Activity
- addedF-const_trait_impl`#![feature(const_trait_impl)]``#![feature(const_trait_impl)]`
on Aug 22, 2021 I should add that this used to compile. I noticed the error after updating my compiler.
I did not record the old version number, but it was very old. Maybe 1.51 or so.
The code example will (most likely) compile again once #88040 is merged. However the underlying issue isn’t addressed; that PR just removes the
K: Ordbound fromBTreeMap::newentirely.searched nightlies: from nightly-2021-08-14 to nightly-2021-08-22
regressed nightly: nightly-2021-08-15
searched commits: from 5a19ffe to 8007b50
regressed commit: 136eaa1bisected with cargo-bisect-rustc v0.6.0
Host triple: x86_64-unknown-linux-gnu
Reproduce with:cargo bisect-rustc --access github --regress error
I’m not sure I quite understand the description of #87375
Is the code in this issue working as intended or is this a bug?
Okay, if I understand this correctly, there’s currently a
K: Ordand not aK: ?const Ordbound onBTreeMap::new, so this is expected breakage, right? If so, we can close this issue. (Also in this case, it is a BTreeMap-specific issue after all, and #88040 will fix the problem for good.)Reacted by beef@rustbot label A-associated-items, requires-nightly
- addedA-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.This issue requires a nightly compiler in some way. When possible, use a F-* label instead.
on Aug 27, 2021 So #88328 just got merged, and that means instead of inferring bounds on const fns to be
const, we now require an opt-in for those bounds. The latest nightly should work again.Reacted by Frank Steffahn and Stefan LankesI can confirm this works again in the playground.
I tried this code:
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=77d9f2d244245a27faedba8a04c6ca14
I expected it to compile.
Instead I get the error:
It complains that
K: Ordis not satisfied.But
K: ProtoandProto: OrdthereforeK: Ord.The code also fails if I explicitly add the
K: Ordtrait bound to the impl.Meta
I tried using the most recent nightly on macOS 11.3 (Big Sur) and on the playground.