rust icon indicating copy to clipboard operation
rust copied to clipboard

Allow specialized const trait impls.

Open BGR360 opened this issue 3 years ago • 8 comments

Fixes #95186. Fixes #95187.

I've done my best to create a comprehensive test suite for the interaction between min_specialization and const_trait_impls. I wouldn't be surprised if there are interesting cases I haven't tested, please let me know.

BGR360 avatar Mar 25 '22 00:03 BGR360

r? @lcnr

(rust-highfive has picked a reviewer for you, use r? to override)

rust-highfive avatar Mar 25 '22 00:03 rust-highfive

@rustbot label +A-specialization +A-traits +F-specialization +F-const_trait_impls

EDIT: whoops i thought you could do that for PRs

BGR360 avatar Mar 25 '22 00:03 BGR360

marking this as blocked this on a general refactoring of const trait impls, see https://rust-lang.zulipchat.com/#narrow/stream/144729-wg-traits/topic/Review.3A.20specialized.20const.20trait.20impls/near/276581945

Not sure whether it would be sensible to close this issue for now or only merge the tests with their current behavior and a FIXME.

lcnr avatar Mar 25 '22 07:03 lcnr

:umbrella: The latest upstream changes (presumably #98396) made this pull request unmergeable. Please resolve the merge conflicts.

bors avatar Jun 28 '22 12:06 bors

At long last 🎉

I'll take a stab at it later today. I imagine it will be more involved than just a rebase, right? IIRC there was some sort of major refactor taking place over the last few months. I sort of expected that I would have to re-implement the fix from scratch.

EDIT: oh, after looking at the code on master, looks like PredicateKinds still have a constness. I thought I remember someone saying that that was gonna be reworked. But I'm not complaining!

BGR360 avatar Sep 11 '22 20:09 BGR360

@rustbot ready

BGR360 avatar Sep 11 '22 22:09 BGR360

@rustbot ready

BGR360 avatar Sep 14 '22 03:09 BGR360

@Rageking8: :key: Insufficient privileges: Not in reviewers

bors avatar Sep 17 '22 04:09 bors

:umbrella: The latest upstream changes (presumably #102306) made this pull request unmergeable. Please resolve the merge conflicts.

bors avatar Sep 27 '22 13:09 bors

ping from triage: @BGR360

Can you please post your status on this PR?

FYI: when a PR is ready for review, send a message containing @rustbot ready to switch to S-waiting-on-review so the PR is in the reviewer's backlog.

JohnCSimon avatar Nov 06 '22 02:11 JohnCSimon

@JohnCSimon the PR status is correct, I was requested to add an additional test and tweak the behavior of the code. I never got around to it. Let me see if it's an easy merge and if I can knock it out now.

BGR360 avatar Nov 06 '22 02:11 BGR360

@bors r=lcnr

BGR360 avatar Nov 10 '22 18:11 BGR360

@BGR360: :key: Insufficient privileges: Not in reviewers

bors avatar Nov 10 '22 18:11 bors

@lcnr I don't have permission for bors

BGR360 avatar Nov 10 '22 18:11 BGR360

The job x86_64-gnu-llvm-13 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

---- [ui] src/test/ui/rfc-2632-const-trait-impl/specializing-constness.rs stdout ----
diff of stderr:

4 LL | impl<T: Default + Sup> A for T {
6 
6 
- error: missing `~const` qualifier
+ error: missing `~const` qualifier for specialization
9    |
9    |
10 LL | impl<T: Default + Sup> A for T {

The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/rfc-2632-const-trait-impl/specializing-constness/specializing-constness.stderr
To update references, rerun the tests and pass the `--bless` flag
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args rfc-2632-const-trait-impl/specializing-constness.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/rfc-2632-const-trait-impl/specializing-constness.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/rfc-2632-const-trait-impl/specializing-constness" "-A" "unused" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/rfc-2632-const-trait-impl/specializing-constness/auxiliary"
stdout: none
--- stderr -------------------------------
error: cannot specialize on const impl with non-const impl
   |
   |
LL | impl<T: Default + Sup> A for T {


error: missing `~const` qualifier for specialization
   |
   |
LL | impl<T: Default + Sup> A for T {

error: aborting due to 2 previous errors
------------------------------------------

rust-log-analyzer avatar Nov 10 '22 20:11 rust-log-analyzer

@bors r+ rollup

lcnr avatar Nov 11 '22 13:11 lcnr

:pushpin: Commit 94f67e667be3efd1845bb95fcd25fcce11cf983c has been approved by lcnr

It is now in the queue for this repository.

bors avatar Nov 11 '22 13:11 bors