Skip to content

Fix two const_trait_impl issues - #100336

Merged
bors merged 4 commits into
rust-lang:masterfrom
fee1-dead-contrib:fix-wf-const-trait
Aug 22, 2022
Merged

Fix two const_trait_impl issues#100336
bors merged 4 commits into
rust-lang:masterfrom
fee1-dead-contrib:fix-wf-const-trait

Conversation

@fee1-dead

@fee1-deadfee1-dead commented Aug 9, 2022

Copy link
Copy Markdown
Member

r? @oli-obk

Fixes#100222.
Fixes#100543.

@rustbotrustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Aug 9, 2022
@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 9, 2022
@rust-log-analyzer

This comment has been minimized.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't you also be applying this to arg types too?

@compiler-errorscompiler-errorsAug 14, 2022

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I guess a deeper question is whether this should be fixed in rustc_trait_selection::traits::wf instead..?

Or I guess whether we should be doing wfcheck with a Constness::Const param-env at all? e.g. should we just be doing param_env.without_const when constructing the wfcx

Like, is it ever required for correctness to register a wf obligation with Constness::Const? What would break/be unsound/be incorrect if we just made the param-env not const during wfcheck?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whether we should be doing wfcheck with a Constness::Const param-env at all?

We should. For an impl to be well-formed, all super traits must be fulfilled. In the case of const super traits, we need to ensure that the parent trait has a constimpl.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I mean for the nominal obligations of the projection types in the signature, for example. Not necessarily when we verify that a trait's supertraits are satisfied.

Put in a different way, any time we instantiate a WellFormed predicate, is it ever wrong to pass a param env with no constness there instead?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems desirable. This is related to #100543. I'm going to look into this further.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tend to agree with @compiler-errors' reasoning here (it was my first thought when looking at the code).

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been done, but only from one producer of wf obligations, to fix this issue. The second fix is unfortunate but is the only solution I can find without breaking the tests.

@estebank

Copy link
Copy Markdown
Contributor

@oli-obk is currently out. CC @rust-lang/types

r? rust-lang/types

@rust-highfiverust-highfive assigned lcnr and unassigned oli-obkAug 15, 2022
@rust-log-analyzer

This comment has been minimized.

@fee1-dead
fee1-deadforce-pushed the fix-wf-const-trait branch 2 times, most recently from 85c785a to 758b550CompareAugust 16, 2022 06:28
@fee1-deadfee1-dead changed the title Fix wf check on #[const_trait] return typesFix two const_trait_impl issuesAug 16, 2022
@bors

bors commented Aug 22, 2022

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #100654) made this pull request unmergeable. Please resolve the merge conflicts.

@oli-obk

Copy link
Copy Markdown
Contributor

r? @oli-obk

@rust-highfiverust-highfive assigned oli-obk and unassigned lcnrAug 22, 2022
Comment on lines 9 to 12

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So... the problem was that this is not Self: ~const Index, but it was tested as such? Do we have tests for various combinations of #[const_trait] being on the super trait or not, and being on the trait itself or not?

@oli-obk

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Aug 22, 2022

Copy link
Copy Markdown
Collaborator

📌 Commit f019b6c has been approved by oli-obk

It is now in the queue for this repository.

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 22, 2022
@oli-obk

Copy link
Copy Markdown
Contributor

r=me with CI passing ^^

@fee1-dead

Copy link
Copy Markdown
MemberAuthor

@bors r=oli-obk

@bors

bors commented Aug 22, 2022

Copy link
Copy Markdown
Collaborator

📌 Commit f1db3be has been approved by oli-obk

It is now in the queue for this repository.

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Aug 22, 2022
…it, r=oli-obk
Fix two const_trait_impl issues
r? `@oli-obk`
Fixesrust-lang#100222.
Fixesrust-lang#100543.
@Dylan-DPCDylan-DPC mentioned this pull request Aug 22, 2022
@Dylan-DPCDylan-DPC mentioned this pull request Aug 22, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 22, 2022
Rollup of 8 pull requests
Successful merges:
- rust-lang#98200 (Expand potential inner `Or` pattern for THIR)
- rust-lang#99770 (Make some const prop mir-opt tests `unit-test`s)
- rust-lang#99957 (Rework Ipv6Addr::is_global to check for global reachability rather than global scope - rebase)
- rust-lang#100331 (Guarantee `try_reserve` preserves the contents on error)
- rust-lang#100336 (Fix two const_trait_impl issues)
- rust-lang#100713 (Convert diagnostics in parser/expr to SessionDiagnostic)
- rust-lang#100820 (Use pointer `is_aligned*` methods)
- rust-lang#100872 (Add guarantee that Vec::default() does not alloc)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit 14c8a68 into rust-lang:masterAug 22, 2022
@rustbotrustbot added this to the 1.65.0 milestone Aug 22, 2022
@fee1-dead
fee1-dead deleted the fix-wf-const-trait branch August 23, 2022 01:09
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

regression: can't compare X with _ in const contexts #[const_trait] and super trait error

9 participants

@fee1-dead@rust-log-analyzer@estebank@bors@oli-obk@compiler-errors@rust-highfive@lcnr@rustbot