Skip to content

Keyword/modifier generics #164

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

Closed
oli-obk opened this issue May 4, 2022 · 1 comment
Closed

Keyword/modifier generics #164

oli-obk opened this issue May 4, 2022 · 1 comment
Labels
meeting-proposal Proposal for a lang team design meeting T-lang

Comments

@oli-obk
Copy link

oli-obk commented May 4, 2022

Summary

We want to allow users to be generic over at least the following keywords:

  • mut
  • const
  • async
  • extern
  • unsafe

We already support a limited version for const (only a sugared version, not explictly being generic over it), because const fn foo<T: ~const Trait>(t: T) { t.method() } is usable outside a const context with types that don't impl const Trait, and inside const contexts the types must have an impl const Trait.

As a first step we want to actually change the implementation of this feature inside rustc to re-use the generics and substitution infrastructure.

As a next step we want to play with async to allow the same kind of async if async bounds as well as async trait declarations and impl async Trait for Type declarations for those bounds to be useful.

Most of this will initially happen with attributes instead of syntax changes, but we want to start exploring possible syntax (hopefully without the ~ placeholder modifier) for the sugar.

I've talked about sugar, but what we'll likely want in the farther future is to allow writing the desugared version directly in the surface language. Basically I envision something like the following (modulo syntax bikeshed, but mostly in the right places)

const fn foo<T: ~const Trait>(t: T)

// the above desugars to

for<effect K> const<K> fn foo<T: const<K> Trait>(t: T)

The details of how we think this should work are in a doc that'll be ready for consumption in time for this meeting.

Background reading

About this issue

This issue corresponds to a lang-team design meeting proposal. It corresponds
to a possible topic of discussion that may be scheduled for deeper discussion
during one of our design meetings.

@nikomatsakis
Copy link
Contributor

This meeting happened, thought I can't find the minutes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
meeting-proposal Proposal for a lang team design meeting T-lang
Projects
None yet
Development

No branches or pull requests

2 participants