You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Include type bindings on string representation of impl Trait #63526
Include type arguments for traits when displaying impl Trait. For example, the following:
error[E0282]: type annotations needed for `impl std::future::Future`
--> $DIR/cannot-infer-async-enabled-impl-trait-bindings.rs:14:9
|
LL | let fut = async {
| --- consider giving `fut` the explicit type `impl std::future::Future`, with the type parameters specified
LL | make_unit()?;
| ^^^^^^^^^^^^ cannot infer type
should be
error[E0282]: type annotations needed for `impl std::future::Future`
--> $DIR/cannot-infer-async-enabled-impl-trait-bindings.rs:14:9
|
LL | let fut = async {
| --- consider giving `fut` the explicit type `impl std::future::Future<Output=_>`, with the type parameters specified
LL | make_unit()?;
| ^^^^^^^^^^^^ cannot infer type
@estebank Would you mind giving me a few pointers? I looked through the source code but it wasn't completely obvious to me on how to achieve this. Is this already supported by the FmtPrinter or something new that has to be implemented?
I'm not sure if this codepath is using FmtPrinter (I did a quick check changing this to "im pl " and I didn't see any change to this error. I think that what you want to look at is
This issue seems to be about associated type bindings, but the title mentions type parameters.
The whole to_opt_poly_trait_ref check results in hiding all the bounds that aren't trait bounds.
Due to impl Foo + Bar existing, I think this is harder than the dyn Trait case, because you have to pair up projection bounds to the right trait, kind of like how rustdoc does for displaying something nicer.
This makes me think E-easy is not the right label, but I'm not sure yet.
In the future please cc me on all ty::print-related issues/PRs.
changed the title [-]Include type parameters on string representation of `impl Trait`[/-][+]Include type bindings on string representation of `impl Trait`[/+]on Jul 13, 2020
error[E0282]: type annotations needed
--> $DIR/cannot-infer-async.rs:13:9
|
LL | Ok(())
| ^^ cannot infer type of the type parameter `E` declared on the enum `Result`
|
help: consider specifying the generic arguments
|
LL | Ok::<(), E>(())
| +++++++++
Activity
iluuu1994 commentedon Aug 14, 2019
@rustbot claim
Should have time tonight. 🙂
iluuu1994 commentedon Aug 14, 2019
I'll probably better wait until #63507 is merged 😊
estebank commentedon Aug 14, 2019
@iluuu1994 that should happen sometime today.
iluuu1994 commentedon Aug 16, 2019
@estebank Would you mind giving me a few pointers? I looked through the source code but it wasn't completely obvious to me on how to achieve this. Is this already supported by the
FmtPrinteror something new that has to be implemented?estebank commentedon Aug 19, 2019
I'm not sure if this codepath is using
FmtPrinter(I did a quick check changing this to"im pl "and I didn't see any change to this error. I think that what you want to look at isrust/src/librustc/ty/print/mod.rs
Lines 212 to 255 in afc39bb
and make it use the
_substs, but again, I'm not 100% sure that is the case.iluuu1994 commentedon Aug 19, 2019
I will try that, thanks @estebank 🙂
estebank commentedon Aug 19, 2019
It's less than ideal, but using
RUSTC_LOG=rustc::ty::print=debugcauses astack overflow, which makes it harder to figure out what's going on:estebank commentedon Aug 21, 2019
@iluuu1994 this is the code you want to modify:
rust/src/librustc/ty/print/pretty.rs
Lines 556 to 604 in bea0372
probably looking at how associated types are printed for
dyntypes should help:rust/src/librustc/ty/print/pretty.rs
Lines 724 to 794 in bea0372
iluuu1994 commentedon Aug 21, 2019
Thanks! Sorry I've just not gotten around to it. Hopefully tonight 😊
oliviabrown9 commentedon Sep 27, 2019
@iluuu1994 Are you still working on this? If not, I can grab it :)
iluuu1994 commentedon Sep 27, 2019
@oliviabrown9 Nope, feel free to take over.
eddyb commentedon Sep 27, 2019
This issue seems to be about associated type bindings, but the title mentions type parameters.
The whole
to_opt_poly_trait_refcheck results in hiding all the bounds that aren't trait bounds.Due to
impl Foo + Barexisting, I think this is harder than thedyn Traitcase, because you have to pair up projection bounds to the right trait, kind of like how rustdoc does for displaying something nicer.This makes me think
E-easyis not the right label, but I'm not sure yet.In the future please cc me on all
ty::print-related issues/PRs.cc @nikomatsakis @matthewjasper
JohnTitor commentedon Apr 17, 2020
@rustbot release-assignment
[-]Include type parameters on string representation of `impl Trait`[/-][+]Include type bindings on string representation of `impl Trait`[/+]estebank commentedon May 20, 2024
Current output: