Skip to content

make Sized predicates coinductive #83647

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
wants to merge 2 commits into from
Closed

Conversation

lcnr
Copy link
Contributor

@lcnr lcnr commented Mar 29, 2021

🤷

needs either an MCP/RFC and wg-traits signoff. While I think this is sound, I am not too knowledgeable about coinduction so I might be wrong here.

r? @nikomatsakis

@lcnr lcnr added T-lang Relevant to the language team S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Mar 29, 2021
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 29, 2021
@lcnr lcnr force-pushed the sized-coinduction branch from 01fad28 to bfe3670 Compare March 29, 2021 18:00
@nikomatsakis
Copy link
Contributor

I'm going to want to talk about the motivation =)

@JohnCSimon JohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 18, 2021
@lcnr
Copy link
Contributor Author

lcnr commented Apr 23, 2021

I still want to add this as a test, so that I don't forget. I expect the error here to change from a predicate cycle to "recursive type Foo<()> has infinite size"

trait A { type Assoc; }

impl A for () {
    type Assoc = Foo<()>;
}
struct Foo<T: A>(T::Assoc);

fn main() {}

@lcnr
Copy link
Contributor Author

lcnr commented Apr 23, 2021

also

trait A { type Assoc: ?Sized; }

impl A for () {
    type Assoc = Foo<()>;
}
struct Foo<T: A>(T::Assoc);

fn main() {
    let x: Foo<()>;
}

@bstrie bstrie added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 12, 2021
@JohnCSimon JohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 31, 2021
@JohnCSimon
Copy link
Member

triage: @lcnr - is this still blocked?

@nikomatsakis
Copy link
Contributor

@lcnr is taking a bit of a break from Rust at the moment -- we could close this, but it's also ok to leave it open.

@crlf0710 crlf0710 removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 26, 2021
@lcnr
Copy link
Contributor Author

lcnr commented Jul 8, 2021

don't have the capacity to work on this rn

@marmeladema
Copy link
Contributor

marmeladema commented Aug 9, 2022

Would this allow to compile:

use std::borrow::Cow;

#[derive(Clone)]
enum Test<'a> {
    Int(u8),
    Array(Cow<'a, [Test<'a>]>),
}

?

@compiler-errors

This comment was marked as duplicate.

@marmeladema

This comment was marked as outdated.

Manishearth added a commit to Manishearth/rust that referenced this pull request Nov 11, 2022
…redux, r=lcnr

Make `Sized` coinductive, again

A revival of rust-lang#83647

---

What exactly makes co-induction sound? Better question: are there any unsoundness risks from this? `Sized` can't be implemented by custom `impl` blocks, nor can it be conditionally implemented based on anything other than child fields being `Sized`, right?

r? `@nikomatsakis` for whenever he gets back from vacation
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
S-blocked Status: Blocked on something else such as an RFC or other implementation work. T-lang Relevant to the language team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants