Skip to content
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

Meta tracking issue for impl Trait #63066

Open
1 of 11 tasks
Centril opened this issue Jul 28, 2019 · 14 comments
Open
1 of 11 tasks

Meta tracking issue for impl Trait #63066

Centril opened this issue Jul 28, 2019 · 14 comments
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC metabug Issues about issues themselves ("bugs about bugs") S-tracking-impl-incomplete Status: The implementation is incomplete. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@Centril
Copy link
Contributor

Centril commented Jul 28, 2019

This issue tracks the progress of impl Trait in general.

This issue is not for discussion about specific extensions to impl Trait and only exists to provide links to other places that track the progress of specific issues. If you wish to discuss some subject related to impl Trait, please find an existing appropriate issue below or create an new issue and comment here with a link to the newly created issue.


The impl Trait related issues currently on deck are as follows:


Open RFCs:

None.

@Centril Centril added metabug Issues about issues themselves ("bugs about bugs") T-lang Relevant to the language team, which will review and decide on the PR/issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC labels Jul 28, 2019
@kevincox
Copy link
Contributor

#65481 Allow impl Trait in trait method return values.

@sighoya

This comment has been minimized.

@Aaron1011

This comment has been minimized.

@CryZe

This comment has been minimized.

@sighoya

This comment has been minimized.

@mark-i-m

This comment has been minimized.

@CryZe

This comment has been minimized.

@Centril
Copy link
Contributor Author

Centril commented Nov 17, 2019

@sighoya @Aaron1011 @mark-i-m @CryZe This issue is not for general discussion about impl Trait. It's only intended to collect links.

This issue is not for discussion about specific extensions to impl Trait and only exists to provide links to other places that track the progress of specific issues. If you wish to discuss some subject related to impl Trait, please find an existing appropriate issue below or create an new issue and comment here with a link to the newly created issue.

strohel added a commit to strohel/rust that referenced this issue Mar 2, 2020
The existing issue rust-lang#34511 has been closed and replaced by meta-issue rust-lang#63066.

The concrete part of the new meta-issue for this feature should be rust-lang#63065.
@rphmeier
Copy link
Contributor

rphmeier commented Jun 24, 2020

@Centril

Permit type Foo = impl Bar; in trait definitions

This links to #29661 which seems to be about setting associated type defaults, whereas I understood the text to mean something like this:

trait SomeTrait {
    type Foo: Bar;

    fn foo() -> Self::Foo;
}

impl SomeTrait for X {
    type Foo = impl Bar;

    fn foo() -> Self::Foo { ... }
}

I didn't perceive #29661 to be about this use-case, but instead about something different:

trait SomeTrait {
    type Foo: Bar = SomeSpecificBar;
}

I understood "type Foo = impl Bar in trait definitions" to mean my first example and to be one of the end goals of impl Trait. Is there an issue tracking that specific feature that can be linked to?

@Nemo157
Copy link
Member

Nemo157 commented Jun 25, 2020

Trait definitions is your second example, covered by #29661. Your first example is trait implementations, which is covered by RFC 2515 (#63063), specifically the last example of RFC 2515 § Guide-level explanation § Type alias, and it currently works on nightly with #![feature(type_alias_impl_trait)].

@rphmeier
Copy link
Contributor

Thanks @Nemo157. I would find amendment to the issue text here to make clear that the link to #63063 also encompasses trait implementations and that the sub-link to #29661 is only about associated type defaults helpful. At the moment, the implication of the text is that #63063 is only about "bare" type aliases and #29661 is about impl Trait in associated types.

@devxpy
Copy link

devxpy commented Sep 6, 2020

Hello, does this include allowing impl Trait in structs? (something RFC2071 may have solved)

E.g. -

struct Session {
    client: websocket::sync::Client<impl websocket::sync::Stream>
}
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
   --> src/main.rs:139:37
    |
139 |     client: websocket::sync::Client<impl websocket::sync::Stream>,
    |                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The current workaround for doing this is quite unergonomic -

use anyhow::Result;
use websocket;

fn main() -> Result<()> {
    let session = create_session()?;
    Ok(())
}

struct Session<T: websocket::sync::Stream> {
    client: websocket::sync::Client<T>,
}

fn create_session() -> Result<Session<impl websocket::sync::Stream>> {
    let client = websocket::ClientBuilder::new("ws://...")?.connect_insecure()?;
    Ok(Session { client })
} 

Source

vs if this was implemented -

use anyhow::Result;
use websocket;

fn main() -> Result<()> {
    let session = Session::new()?;
    Ok(())
}

struct Session {
    client: websocket::sync::Client<impl websocket::sync::Stream>
}

impl Session {
	fn new() -> Result<Self> {
	    let client = websocket::ClientBuilder::new("ws://...")?.connect_insecure()?;
	    Ok(Session { client })
	}
}

@ibraheemdev
Copy link
Member

ibraheemdev commented Jan 3, 2021

Is there a tracking issue for named existential types? The original tracking issue (#44685) was closed as a duplicate of #34511, which was closed in favor of this issue, but I don't see named existential types mentioned anywhere here...

@memoryruins
Copy link
Contributor

Is there a tracking issue for named existential types?

@ibraheemdev #63063
https://rust-lang.github.io/rfcs/2515-type_alias_impl_trait.html

n1tram1 added a commit to ks0n/goOSe that referenced this issue Jan 14, 2022
Memory discovery (finding how much we have, where etc...) shouldn't be
hardcoded in `mm/mod.rs`. Instead it should be in the Architecture trait
so that each platform can do its thing (riscv/arm => device tree, x86 =>
multiboot info or e820).

Originaly I just wanted a `memory_regions -> impl Iterator<Item=T>`
method in the Architecture trait. But oh boy no...
Currently a method that returns an impl Trait is not possible (rustc
1.59.0-nightly).
In the future, this should be possible, see: rust-lang/rust#63066

Meanwhile, this is what I came up with.
Since I can't return an impl Trait but I can pass one as parameter, I
have a `for_all_memory_regions` method that creates the iterator and
then calls the closure with that parameter. Code that uses that is a bit
more ugly and less clear than if I could have returned an impl Trait,
but it should do for now. This MUST be fixed when the above issue is
resolved.
Also the type signatures are a bit *complex*, this is due to my vicious
fight with the rust borrow-checking-and-mighty-type-checking gods of
Rust.

Last but not least, a quote from the great:
Tout est simple, tout est complexe, a vous de trouver la solution, une solution peut en cacher une autre
-- Garnier
n1tram1 added a commit to ks0n/goOSe that referenced this issue Jan 15, 2022
Memory discovery (finding how much we have, where etc...) shouldn't be
hardcoded in `mm/mod.rs`. Instead it should be in the Architecture trait
so that each platform can do its thing (riscv/arm => device tree, x86 =>
multiboot info or e820).

Originaly I just wanted a `memory_regions -> impl Iterator<Item=T>`
method in the Architecture trait. But oh boy no...
Currently a method that returns an impl Trait is not possible (rustc
1.59.0-nightly).
In the future, this should be possible, see: rust-lang/rust#63066

Meanwhile, this is what I came up with.
Since I can't return an impl Trait but I can pass one as parameter, I
have a `for_all_memory_regions` method that creates the iterator and
then calls the closure with that parameter. Code that uses that is a bit
more ugly and less clear than if I could have returned an impl Trait,
but it should do for now. This MUST be fixed when the above issue is
resolved.
Also the type signatures are a bit *complex*, this is due to my vicious
fight with the rust borrow-checking-and-mighty-type-checking gods of
Rust.

Last but not least, a quote from the great:
Tout est simple, tout est complexe, a vous de trouver la solution, une solution peut en cacher une autre
-- Garnier
n1tram1 added a commit to ks0n/goOSe that referenced this issue Feb 17, 2022
Memory discovery (finding how much we have, where etc...) shouldn't be
hardcoded in `mm/mod.rs`. Instead it should be in the Architecture trait
so that each platform can do its thing (riscv/arm => device tree, x86 =>
multiboot info or e820).

Originaly I just wanted a `memory_regions -> impl Iterator<Item=T>`
method in the Architecture trait. But oh boy no...
Currently a method that returns an impl Trait is not possible (rustc
1.59.0-nightly).
In the future, this should be possible, see: rust-lang/rust#63066

Meanwhile, this is what I came up with.
Since I can't return an impl Trait but I can pass one as parameter, I
have a `for_all_memory_regions` method that creates the iterator and
then calls the closure with that parameter. Code that uses that is a bit
more ugly and less clear than if I could have returned an impl Trait,
but it should do for now. This MUST be fixed when the above issue is
resolved.
Also the type signatures are a bit *complex*, this is due to my vicious
fight with the rust borrow-checking-and-mighty-type-checking gods of
Rust.

Last but not least, a quote from the great:
Tout est simple, tout est complexe, a vous de trouver la solution, une solution peut en cacher une autre
-- Garnier
n1tram1 added a commit to ks0n/goOSe that referenced this issue Feb 17, 2022
Memory discovery (finding how much we have, where etc...) shouldn't be
hardcoded in `mm/mod.rs`. Instead it should be in the Architecture trait
so that each platform can do its thing (riscv/arm => device tree, x86 =>
multiboot info or e820).

Originaly I just wanted a `memory_regions -> impl Iterator<Item=T>`
method in the Architecture trait. But oh boy no...
Currently a method that returns an impl Trait is not possible (rustc
1.59.0-nightly).
In the future, this should be possible, see: rust-lang/rust#63066

Meanwhile, this is what I came up with.
Since I can't return an impl Trait but I can pass one as parameter, I
have a `for_all_memory_regions` method that creates the iterator and
then calls the closure with that parameter. Code that uses that is a bit
more ugly and less clear than if I could have returned an impl Trait,
but it should do for now. This MUST be fixed when the above issue is
resolved.
Also the type signatures are a bit *complex*, this is due to my vicious
fight with the rust borrow-checking-and-mighty-type-checking gods of
Rust.

Last but not least, a quote from the great:
Tout est simple, tout est complexe, a vous de trouver la solution, une solution peut en cacher une autre
-- Garnier
n1tram1 added a commit to ks0n/goOSe that referenced this issue Feb 17, 2022
Memory discovery (finding how much we have, where etc...) shouldn't be
hardcoded in `mm/mod.rs`. Instead it should be in the Architecture trait
so that each platform can do its thing (riscv/arm => device tree, x86 =>
multiboot info or e820).

Originaly I just wanted a `memory_regions -> impl Iterator<Item=T>`
method in the Architecture trait. But oh boy no...
Currently a method that returns an impl Trait is not possible (rustc
1.59.0-nightly).
In the future, this should be possible, see: rust-lang/rust#63066

Meanwhile, this is what I came up with.
Since I can't return an impl Trait but I can pass one as parameter, I
have a `for_all_memory_regions` method that creates the iterator and
then calls the closure with that parameter. Code that uses that is a bit
more ugly and less clear than if I could have returned an impl Trait,
but it should do for now. This MUST be fixed when the above issue is
resolved.
Also the type signatures are a bit *complex*, this is due to my vicious
fight with the rust borrow-checking-and-mighty-type-checking gods of
Rust.

Last but not least, a quote from the great:
Tout est simple, tout est complexe, a vous de trouver la solution, une solution peut en cacher une autre
-- Garnier
n1tram1 added a commit to ks0n/goOSe that referenced this issue Feb 17, 2022
Memory discovery (finding how much we have, where etc...) shouldn't be
hardcoded in `mm/mod.rs`. Instead it should be in the Architecture trait
so that each platform can do its thing (riscv/arm => device tree, x86 =>
multiboot info or e820).

Originaly I just wanted a `memory_regions -> impl Iterator<Item=T>`
method in the Architecture trait. But oh boy no...
Currently a method that returns an impl Trait is not possible (rustc
1.59.0-nightly).
In the future, this should be possible, see: rust-lang/rust#63066

Meanwhile, this is what I came up with.
Since I can't return an impl Trait but I can pass one as parameter, I
have a `for_all_memory_regions` method that creates the iterator and
then calls the closure with that parameter. Code that uses that is a bit
more ugly and less clear than if I could have returned an impl Trait,
but it should do for now. This MUST be fixed when the above issue is
resolved.
Also the type signatures are a bit *complex*, this is due to my vicious
fight with the rust borrow-checking-and-mighty-type-checking gods of
Rust.

Last but not least, a quote from the great:
Tout est simple, tout est complexe, a vous de trouver la solution, une solution peut en cacher une autre
-- Garnier
n1tram1 added a commit to ks0n/goOSe that referenced this issue Feb 17, 2022
Memory discovery (finding how much we have, where etc...) shouldn't be
hardcoded in `mm/mod.rs`. Instead it should be in the Architecture trait
so that each platform can do its thing (riscv/arm => device tree, x86 =>
multiboot info or e820).

Originaly I just wanted a `memory_regions -> impl Iterator<Item=T>`
method in the Architecture trait. But oh boy no...
Currently a method that returns an impl Trait is not possible (rustc
1.59.0-nightly).
In the future, this should be possible, see: rust-lang/rust#63066

Meanwhile, this is what I came up with.
Since I can't return an impl Trait but I can pass one as parameter, I
have a `for_all_memory_regions` method that creates the iterator and
then calls the closure with that parameter. Code that uses that is a bit
more ugly and less clear than if I could have returned an impl Trait,
but it should do for now. This MUST be fixed when the above issue is
resolved.
Also the type signatures are a bit *complex*, this is due to my vicious
fight with the rust borrow-checking-and-mighty-type-checking gods of
Rust.

Last but not least, a quote from the great:
Tout est simple, tout est complexe, a vous de trouver la solution, une solution peut en cacher une autre
-- Garnier
n1tram1 added a commit to ks0n/goOSe that referenced this issue Mar 15, 2022
Memory discovery (finding how much we have, where etc...) shouldn't be
hardcoded in `mm/mod.rs`. Instead it should be in the Architecture trait
so that each platform can do its thing (riscv/arm => device tree, x86 =>
multiboot info or e820).

Originaly I just wanted a `memory_regions -> impl Iterator<Item=T>`
method in the Architecture trait. But oh boy no...
Currently a method that returns an impl Trait is not possible (rustc
1.59.0-nightly).
In the future, this should be possible, see: rust-lang/rust#63066

Meanwhile, this is what I came up with.
Since I can't return an impl Trait but I can pass one as parameter, I
have a `for_all_memory_regions` method that creates the iterator and
then calls the closure with that parameter. Code that uses that is a bit
more ugly and less clear than if I could have returned an impl Trait,
but it should do for now. This MUST be fixed when the above issue is
resolved.
Also the type signatures are a bit *complex*, this is due to my vicious
fight with the rust borrow-checking-and-mighty-type-checking gods of
Rust.

Last but not least, a quote from the great:
Tout est simple, tout est complexe, a vous de trouver la solution, une solution peut en cacher une autre
-- Garnier
@joshtriplett joshtriplett added the S-tracking-impl-incomplete Status: The implementation is incomplete. label Jun 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC metabug Issues about issues themselves ("bugs about bugs") S-tracking-impl-incomplete Status: The implementation is incomplete. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests