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

conflicting impl since nightly-2024-05-01 #125763

Closed
conradludgate opened this issue May 30, 2024 · 13 comments · Fixed by neondatabase/neon#8142
Closed

conflicting impl since nightly-2024-05-01 #125763

conradludgate opened this issue May 30, 2024 · 13 comments · Fixed by neondatabase/neon#8142
Labels
A-coherence Area: Coherence C-bug Category: This is a bug. disposition-close This PR / issue is in PFCP or FCP with a disposition to close it. finished-final-comment-period The final comment period is finished for this PR / Issue. T-types Relevant to the types team, which will review and decide on the PR/issue.

Comments

@conradludgate
Copy link
Contributor

conradludgate commented May 30, 2024

Code

I tried this code:

https://github.com/conradludgate/measured/tree/b2978b32e2065cb6257244829b5fd6ae1dba4576

pub trait LabelGroupSet {
    type Group<'a>: LabelGroup;
}

impl<T: LabelSet> LabelGroupSet for T
where
    for<'a> T::Value<'a>: LabelGroup,
{
    type Group<'a> = T::Value<'a>;
}

pub trait LabelSet {
    type Value<'a>;
}

impl<T: LabelGroupSet + ?Sized> LabelGroupSet for &'static T {
    type Group<'a> = T::Group<'a>;
}

pub trait LabelGroup {}

I expected to see this happen: compiles successfully

Instead, this happened:

error[E0119]: conflicting implementations of trait `LabelGroupSet` for type `&'static _`
   --> core/src/label/value.rs:45:1
    |
45  | / impl<T: LabelSet> LabelGroupSet for T
46  | | where
47  | |     for<'a> T::Value<'a>: LabelGroup,
    | |_____________________________________^ conflicting implementation for `&'static _`
    |
   ::: core/src/label/group.rs:133:1
    |
133 |   impl<T: LabelGroupSet + ?Sized> LabelGroupSet for &'static T {
    |   ------------------------------------------------------------ first implementation here
    |
    = note: downstream crates may implement trait `label::value::LabelSet` for type `&'static _`
    = note: downstream crates may implement trait `label::group::LabelGroup` for type `<&'static _ as label::value::LabelSet>::Value<'a>`

Version it worked on

It most recently worked on: nightly-2024-04-30

Version with regression

according to cargo-bisect-rustc, the regression started with nightly-2024-05-01 in #117164

@conradludgate conradludgate added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels May 30, 2024
@rustbot rustbot added I-prioritize Issue: Indicates that prioritization has been requested for this issue. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels May 30, 2024
@Nilstrieb
Copy link
Member

the PR was FCPd, so I expect this to be expected breakage, but @lcnr @fmease in case it's not.

@lcnr lcnr added the T-types Relevant to the types team, which will review and decide on the PR/issue. label May 30, 2024
@lcnr
Copy link
Contributor

lcnr commented May 30, 2024

Thank you for opening this issue!

further minimized

pub trait Overlap {}
impl<T: Overlap + ?Sized> Overlap for &'static T {}
impl<T: LabelSet> Overlap for T
where
    for<'a> T::Value<'a>: LabelGroup,
{}

pub trait LabelGroup {}
pub trait LabelSet {
    type Value<'a>;
}

This pattern is #114061. Coherence now considers for<'a> <&'static ?x as LabelSet>::Value<'a>: LabelGroup to be unknowable, as downstream crates could implement LabelSet for &'static LocalType where there's an impl of LabelGroup for LocalType. This should break. The FCP in #117164 (comment) did not mention that this part of the change will immediately be a hard error instead of a future-compat lint.

We use orphan_check_trait_ref in two places: for the orphan check itself, and when checking whether some trait goal is "knowable" We only added the future compat lint behavior to the orphan check, always using the correct approach in trait_ref_is_knowable. This is the first regression caused by that.

InCrate::Remote => {
// The inference variable might be unified with a local
// type in that remote crate.
ControlFlow::Break(OrphanCheckEarlyExit::LocalTy(ty))
}


Sorry for not mentioning this in the original FCP. I was aware of this immediate breakage but did not mention it.

Changing this to also be a future compat lint is annoying and I intentionally did not suggest this in #117164, as that is "inside of the trait solver" and has a smaller impact than the changes to the orphan check itself.

I would like to not revert this change as there have been some small follow-up PRs and I want to close these unsoundnesses asap. I propose accepting this breakage and to close this issue after adding it as a test. However, given that this has slipped through the FCP process, I am open to revert and re-land with another FCP in case there are any concerns by a @rust-lang/types member.

@rfcbot fcp close

@rfcbot
Copy link

rfcbot commented May 30, 2024

Team member @lcnr has proposed to close 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.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-close This PR / issue is in PFCP or FCP with a disposition to close it. labels May 30, 2024
@fmease fmease added A-coherence Area: Coherence and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels May 30, 2024
@fmease
Copy link
Member

fmease commented May 30, 2024

I'd like to note that this kind of code would've gotten rejected with the stabilization of -Znext-solver=coherence (#121848) even without #117164 which was explicitly mentioned in #121848 (Ctrl+F "#114061" or "Unknowable candidates for higher ranked trait goals"). So technically speaking this has already been accepted by FCP (#121848 (comment)).

You can verify this yourself by running rustc +nightly-2024-04-30 mcve.rs --crate-type=lib -Znext-solver=coherence.

@conradludgate
Copy link
Contributor Author

I'm fine with the decision but it would have been nicer to have some warning with info

@fmease
Copy link
Member

fmease commented May 30, 2024

Yeah, that's understandable. Sorry about that!
#125763 (comment) was more addressed to T-types, not to you specifically.

@lcnr
Copy link
Contributor

lcnr commented May 30, 2024

yes, we did no catch the breakage in your crate when running crater, unsure why that was the case 🤔

Generally we try to open fixes or at least issues to affected projects when landing breaking changes. This relies on us actually detecting these changes however 😅

@fmease fmease removed the regression-untriaged Untriaged performance or correctness regression. label May 30, 2024
@conradludgate
Copy link
Contributor Author

yes, we did no catch the breakage in your crate when running crater, unsure why that was the case 🤔

Strange. This particular impl has been on crates.io since February 10 🤔 those crater runs were Feb-27 and Apr-27 respectively and measured is not in the dataset at all. Very strange.

https://docs.rs/measured/0.0.12/measured/label/group/trait.LabelGroupSet.html#impl-LabelGroupSet-for-T

@lqd
Copy link
Member

lqd commented May 30, 2024

yes, we did no catch the breakage in your crate when running crater, unsure why that was the case 🤔

yeah it's not the first time this happened, there's rust-lang/crater#727 and discussions on zulip IIRC

@nikomatsakis
Copy link
Contributor

nikomatsakis commented Jun 4, 2024 via email

@fmease

This comment was marked as outdated.

@rfcbot rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels Jun 6, 2024
@rfcbot
Copy link

rfcbot commented Jun 6, 2024

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

@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Jun 16, 2024
@rfcbot
Copy link

rfcbot commented Jun 16, 2024

The final comment period, with a disposition to close, 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.

@rfcbot rfcbot added the to-announce Announce this issue on triage meeting label Jun 16, 2024
@compiler-errors compiler-errors closed this as not planned Won't fix, can't repro, duplicate, stale Jun 16, 2024
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Jul 4, 2024
conradludgate added a commit to neondatabase/neon that referenced this issue Jul 9, 2024
## Problem

`cargo +nightly check` fails

## Summary of changes

Updates `measured`, `time`, and `crc32c`.

* `measured`: updated to fix
rust-lang/rust#125763.
* `time`: updated to fix rust-lang/rust#125319
* `crc32c`: updated to remove some nightly feature detection with a
removed nightly feature
skyzh pushed a commit to neondatabase/neon that referenced this issue Jul 15, 2024
## Problem

`cargo +nightly check` fails

## Summary of changes

Updates `measured`, `time`, and `crc32c`.

* `measured`: updated to fix
rust-lang/rust#125763.
* `time`: updated to fix rust-lang/rust#125319
* `crc32c`: updated to remove some nightly feature detection with a
removed nightly feature
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-coherence Area: Coherence C-bug Category: This is a bug. disposition-close This PR / issue is in PFCP or FCP with a disposition to close it. finished-final-comment-period The final comment period is finished for this PR / Issue. T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants