Stream: t-lang

Topic: 57893 coherence


nikomatsakis (Jan 13 2020 at 18:21, on Zulip):

Hmm, @T-lang, thinking more about #57893, it occurs to me that another potential solution -- one that is perhaps safer in the short term -- is to say that a trait T is not dyn-safe if:

That, coupled with saying that all fns in a dyn-overlapping impl are (conceptually, at least) default, would be a fairly targeted change, and would not (I think) be very likely to break anyone. In particular it obviates the concern about traits that "just happen" to be dyn-safe being forced to use default.

nikomatsakis (Jan 13 2020 at 18:21, on Zulip):

It does mean of course that the dyn-safe rules are getting increasingly arcane

nikomatsakis (Jan 13 2020 at 18:21, on Zulip):

But that's kind of true regardless

nikomatsakis (Jan 13 2020 at 18:22, on Zulip):

Under this change, I think that all of the breakage I saw in practice would be removed, but I can test that

nikomatsakis (Jan 13 2020 at 18:29, on Zulip):

(I'm experimenting with this change now, should be fairly easy to implement.)

Taylor Cramer (Jan 13 2020 at 18:47, on Zulip):

trait T is not dyn-safe if: it has a "potentially dyn-overlapping impl" and it has associated items that are not fns

nit: associated items that are not fns which do not have a where Self: Sized bound, right?

nikomatsakis (Jan 13 2020 at 18:48, on Zulip):

mm I don't think so

nikomatsakis (Jan 13 2020 at 18:48, on Zulip):

I guess maybe eventually

nikomatsakis (Jan 13 2020 at 18:48, on Zulip):

but that would be like trait Foo { type X where Self: Sized; }

nikomatsakis (Jan 13 2020 at 18:48, on Zulip):

which, without GATs, we don't even really support

nikomatsakis (Jan 13 2020 at 18:49, on Zulip):

or hmm

nikomatsakis (Jan 13 2020 at 18:49, on Zulip):

or are you saying that if you have a where Self: Sized fn, that is potentially a problem? I don't think it is -- it's not present in the vtable, but it's also not invokable on a dyn Trait type

Taylor Cramer (Jan 13 2020 at 18:49, on Zulip):

I definitely have reasons why I would want that to be supported.

Taylor Cramer (Jan 13 2020 at 18:49, on Zulip):

^^ no, your example Foo is similar to what I had in mind.

Taylor Cramer (Jan 13 2020 at 18:52, on Zulip):

I definitely have reasons why I would want that to be supported.

(e.g. a method with a where Self: Sized bound that returns a where Self: Sized associated type)

nikomatsakis (Jan 13 2020 at 18:55, on Zulip):

ok, well, I agree we could add that caveat

nikomatsakis (Jan 14 2020 at 00:41, on Zulip):

I updated https://github.com/rust-lang/rust/pull/66037 with this idea -- not @Taylor Cramer's variant, just the basic one, but I think we could extend it

Last update: Jan 28 2020 at 00:40UTC