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

Restore Opaque behavior to coherence check #99666

Merged
merged 1 commit into from
Jul 26, 2022

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Jul 24, 2022

Fixes #99663.

This broke in 84c3fcd. I'm not exactly certain that adding this behavior back is necessarily correct, but at least the UI test I provided may stimulate some thoughts.

I think delaying a bug here is certainly not correct in the case of opaques -- if we want to change coherence behavior for opaques, then we should at least be emitting a new error.

r? @lcnr

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jul 24, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 24, 2022
@compiler-errors
Copy link
Member Author

#99552 (comment)

The algorithm replicates the existing behaviour, so...

Hm, guess not?

@lcnr
Copy link
Contributor

lcnr commented Jul 25, 2022

Hm, guess not?

@compiler-errors is the Opaque difference the only reason why you wrote this?

@compiler-errors
Copy link
Member Author

compiler-errors commented Jul 25, 2022

@lcnr that's the only difference I could find, but I didn't look further than the opaque change that I touched in this PR.

Just pointed out that comment because it seems #99552 did change behavior, not just replicated the old behavior like the comment suggested, unless I'm misunderstanding the point of that comment.

Copy link
Contributor

@lcnr lcnr left a comment

Choose a reason for hiding this comment

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

please add the following as an additional test:

#![feature(type_alias_impl_trait)]

struct Outer<T: ?Sized> {
    i: InnerSend<T>,
}

type InnerSend<T: ?Sized> = impl Send;

fn constrain<T: ?Sized>() -> InnerSend<T> {
    ()
}

trait SendMustNotImplDrop {}
impl<T: ?Sized + Send + Drop> SendMustNotImplDrop for T {}
impl<T: ?Sized> SendMustNotImplDrop for Outer<T> {}

fn main() {}

this triggers the ice using auto traits.

It was surprising to me that we never look into the opaque types during coherence, causing an ICE for closures etc as well, (by changing constrain to || ()). The reason for that is that is_knowable fails for auto trait/sized impls on Opaque types as they always result in Conflict::Upstream.

r=me after adding this test and fixing my nit

compiler/rustc_trait_selection/src/traits/coherence.rs Outdated Show resolved Hide resolved
src/test/ui/coherence/issue-99663.rs Outdated Show resolved Hide resolved
@lcnr
Copy link
Contributor

lcnr commented Jul 25, 2022

Just pointed out that comment because it seems #99552 did change behavior, not just replicated the old behavior like the comment suggested, unless I'm misunderstanding the point of that comment.

It did change the behavior for Opaque types because we thought that case would be unreachable.

I interpreted the comment by oli to be about #99552 my new FIXME. While orphan_check_trait_ref is now "visibly wrong" (or at least in need of some further thought), it does keep the previous behavior, so merging it as is was fine.

// FIXME: Constants should participate in orphan checking.
fn visit_const(&mut self, _c: ty::Const<'tcx>) -> ControlFlow<Self::BreakTy> {
ControlFlow::CONTINUE
}

@compiler-errors
Copy link
Member Author

@bors r=lcnr

@bors
Copy link
Contributor

bors commented Jul 26, 2022

📌 Commit b7cf9f7 has been approved by lcnr

It is now in the queue for this repository.

@bors bors 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 Jul 26, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Jul 26, 2022
Restore `Opaque` behavior to coherence check

Fixes rust-lang#99663.

This broke in 84c3fcd. I'm not exactly certain that adding this behavior back is necessarily correct, but at least the UI test I provided may stimulate some thoughts.

I think delaying a bug here is certainly not correct in the case of opaques -- if we want to change coherence behavior for opaques, then we should at least be emitting a new error.

r? `@lcnr`
This was referenced Jul 26, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 26, 2022
Rollup of 5 pull requests

Successful merges:

 - rust-lang#99618 (handle consts with param/infer in `const_eval_resolve` better)
 - rust-lang#99666 (Restore `Opaque` behavior to coherence check)
 - rust-lang#99692 (interpret, ptr_offset_from: refactor and test too-far-apart check)
 - rust-lang#99739 (Remove erroneous E0133 code from an error message.)
 - rust-lang#99748 (Use full type name instead of just saying `impl Trait` in "captures lifetime" error)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 99350de into rust-lang:master Jul 26, 2022
@rustbot rustbot added this to the 1.64.0 milestone Jul 26, 2022
@compiler-errors compiler-errors deleted the issue-99663 branch August 11, 2023 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant 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.

Documentation build failed for teloxide v0.10.1
5 participants