Stream: t-compiler

Topic: Const generics infer; review session ii


Charles Lew (Apr 22 2019 at 20:19, on Zulip):

Just wake up to check up the progress with the const generics. Did the review session happen today? @nikomatsakis

nikomatsakis (Apr 22 2019 at 21:28, on Zulip):

@Charles Lew I didn't get to it, I was about to post a comment that I fell behind :(

nikomatsakis (Apr 22 2019 at 21:28, on Zulip):

I may yet

varkor (Apr 22 2019 at 21:36, on Zulip):

I added a test, but the other tests (that were working on #53645) seem not to be working with the latest infer changes, so I haven't added them yet

varkor (Apr 22 2019 at 21:37, on Zulip):

I haven't got around to checking whether it's because there are still some missing things in the infer PR, or whether something has broken in the meantime

varkor (Apr 22 2019 at 23:08, on Zulip):

(I've added another test)

varkor (Apr 23 2019 at 12:24, on Zulip):

okay, there are a few tests there now

eddyb (Apr 23 2019 at 12:48, on Zulip):

@nikomatsakis fwiw, the more unblocking thing to do is answering point-wise questions about the type/trait/infer system, in light of recent changes

Charles Lew (Apr 24 2019 at 02:07, on Zulip):

Mmm, did the session rescheduled again?

Charles Lew (Apr 24 2019 at 17:04, on Zulip):

@nikomatsakis a ping to make sure the review session actually get rescheduled.

nikomatsakis (Apr 24 2019 at 18:03, on Zulip):

Update: I spent some time reading it but didn't get as far as I would like.

nikomatsakis (Apr 24 2019 at 19:04, on Zulip):

@varkor so I was playing with this test case, and it doesn't compile

#![feature(const_generics)]

fn foo<const C: usize>(x: [u8; C]) { }

fn main() {
    let data = [1, 2, 3];
    foo(data);
}
nikomatsakis (Apr 24 2019 at 19:04, on Zulip):

I guess this is known to you :)

nikomatsakis (Apr 24 2019 at 19:04, on Zulip):

the error I get is

error[E0282]: type annotations needed
 --> /home/nmatsakis/tmp/const-generics-1.rs:7:5
  |
7 |     foo(data);
  |     ^^^ cannot infer type for `fn([u8; _]) {foo::<_>}`
nikomatsakis (Apr 24 2019 at 19:05, on Zulip):

I guess I have to trace through the code, presumably the unification logic is either missing or disabled

nikomatsakis (Apr 24 2019 at 19:15, on Zulip):

OK, well, I guess the problem is the relate logic here

nikomatsakis (Apr 24 2019 at 19:18, on Zulip):

Is it expected that this test ICEs and gives other errors?

struct Foo<const C: usize> {
    data: usize
}

fn foo<const C: usize>(x: Foo<C>) { }
// compiler doesn't really like the `Foo<C>` there

fn main() {
    let data: Foo<3> = Foo::<3> { data: 22 };
    foo(data);
}
varkor (Apr 24 2019 at 19:36, on Zulip):

@nikomatsakis: it's known that quite a few things don't work

varkor (Apr 24 2019 at 19:36, on Zulip):

some are due to the questions in the RFC

varkor (Apr 24 2019 at 19:36, on Zulip):

others are probably oversights

varkor (Apr 24 2019 at 19:37, on Zulip):

I'm not sure what the best way forward is — that is, whether we want to get everything working before merging, or fix problems as follow ups

varkor (Apr 24 2019 at 19:37, on Zulip):

the latter is probably less hassle

varkor (Apr 24 2019 at 19:38, on Zulip):

I have a few extra tests that ICE (that I haven't added to the PR) that I know about

varkor (Apr 24 2019 at 19:39, on Zulip):

but some simple tests are passing now, at least :)

nikomatsakis (Apr 24 2019 at 19:41, on Zulip):

I'm not sure what the best way forward is — that is, whether we want to get everything working before merging, or fix problems as follow ups

probably best to merge bit by bit. I am just sort of trying to wrap my head around what this PR itself enables

nikomatsakis (Apr 24 2019 at 19:41, on Zulip):

anyway I think I'll try to review eddyb's specific questions

nikomatsakis (Apr 26 2019 at 20:42, on Zulip):

Hey @varkor @yodal! On Github I wrote:

maybe we can sync up a bit next week and you can try to talk me through it? (Over Zulip would be fine.) I'm interested in having the design here written out and submitted as a proposal. Anyway, I'll ping you on Zulip to discuss.

So this is me pinging you both =) what do you think?

varkor (Apr 26 2019 at 20:47, on Zulip):

sounds good :+1:
it'd be useful to make sure @eddyb is available too, as the overarching strategy for the PRs was following the guidelines here and doing something analogous to type parameters by default

varkor (Apr 26 2019 at 20:48, on Zulip):

regarding the specific comments: as we discussed previously, there's definitely opportunity for refactoring afterwards, but that can be considered mostly as a separate issue

varkor (Apr 26 2019 at 20:49, on Zulip):

canonicalisation is one of the trickier parts, so I imagine there are some kinks to work out there (though as you say, I'm not sure whether it's worth addressing in this PR, or afterwards)

varkor (Apr 26 2019 at 20:53, on Zulip):

thanks for reviewing :)

yodal (Apr 26 2019 at 21:28, on Zulip):

I am also up for sitting down for a chat. That said, I am not sure how much I can add other than to say that we followed the patterns in what was already done.

yodal (Apr 26 2019 at 21:29, on Zulip):

Cannonicalization is definitely just past where I have been comfortable working because I don't quite understand everything that is going on from a bigger picture

yodal (Apr 26 2019 at 21:30, on Zulip):

Also, I haven't been lurking on Zulip because I only used it for the last review session, but I will try to stick around so that you can reach me

eddyb (Apr 30 2019 at 07:44, on Zulip):

I vaguely understand canonicalization, but I'm not comfortable with edge cases

eddyb (Apr 30 2019 at 07:45, on Zulip):

as in, I think I know how to make some things work, but not how to keep everything sound etc.

varkor (Apr 30 2019 at 21:41, on Zulip):

I've fixed the remaining issue with shallow_resolve, so I think there are just the questions about canonicalisation to go?

Last update: Nov 16 2019 at 02:35UTC