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

🔬 Tracking issue for RFC 2089: Implied bounds #44491

Open
aturon opened this Issue Sep 11, 2017 · 5 comments

Comments

Projects
None yet
8 participants
@aturon
Member

aturon commented Sep 11, 2017

This is a tracking issue for the RFC "Implied bounds" (rust-lang/rfcs#2089).

Steps:

Unresolved questions:

  • Should we try to limit the range of implied bounds to be crate-local (or module-local, etc)?
  • @nikomatsakis pointed here that implied bounds can interact badly with current inference rules.
@skade

This comment has been minimized.

Contributor

skade commented Nov 23, 2017

I have a question not covered in the RFC (that not necessarily has to be part of the RFC): what will error reporting on bounds violations look like? Will it point to the original definition of the bound?

@ExpHP

This comment has been minimized.

Contributor

ExpHP commented Jan 24, 2018

I'm not part of this, but I'll summarize what appears to be the current state of this feature from what I can find:


This tracking issue was posted shortly before the 2017 impl period began, and it looks like it fell under the scope of the WG-compiler-traits workgroup. On the workgroup's dropbox doc I see (under Query model):

We do have to handle cycles at least as well as chalk for implied bounds to work out

I searched the issue tracker for recent issues/PRs about bound cycles or the query model, but nothing stood out.

@nikomatsakis nikomatsakis changed the title Tracking issue for RFC 2089: Implied bounds 🔬 Tracking issue for RFC 2089: Implied bounds Feb 25, 2018

@matthewjasper matthewjasper referenced this issue Apr 3, 2018

Open

Implied bounds #293

0 of 2 tasks complete
@Laaas

This comment has been minimized.

Laaas commented Jun 10, 2018

Is this ready for being implemented? And if so, could I get some mentoring instructions?

@scalexm

This comment has been minimized.

Member

scalexm commented Jun 12, 2018

Sorry, it seems like this issue has been remaining silent for a long time!
Basically the current state of implied bounds is as follows:

  • implied bounds have already been prototyped in chalk, the main work was done in rust-lang-nursery/chalk#82 and another amount of work was done in rust-lang-nursery/chalk#134 where we sketched how implied bounds and generic associated types would interfere
  • now the recent effort has been to somehow « connect » rustc and chalk, more info here

We would definitely appreciate contributions for this second point, which may eventually enable really cool features in rustc like implied bounds, generic associated types and more generally better type inference. See you on the Zulip stream!

@scottmcm

This comment has been minimized.

Member

scottmcm commented Jul 31, 2018

I don't know if this is feasible, but if it is, I think it'd be a nice restriction, so wanted to record it for future consideration:

I think this feature is great for direct uses, but weird for "sideways" uses. To try a concrete example:

// in a world where `struct HashSet<T: Hash+Eq>`...
fn foo<T>(s: &mut HashSet<T>, a: T, b: T) -> bool {
    let r = a == b; // not allowed, because _this_ method doesn't know T: PartialEq
    s.insert(a); // allowed, because the method's `Self` type is HashSet, where we always know Hash+eq
    r
}

I think that would keep the core "look, I'm calling a hashset method, so obviously it's Hash+Eq; I shouldn't need to say so again" but still wouldn't let you directly call things on traits that you never mentioned.

(I do, however, think that in that world, impl<T> HashSet<T> or impl<T> Foo for HashSet<T> should allow use of T:Hash+Eq in the whole impl block, since again it's core to the "self type".)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment