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

Cannot mix impl Trait and explicit generic arguments #71869

Closed
glandium opened this issue May 4, 2020 · 4 comments
Closed

Cannot mix impl Trait and explicit generic arguments #71869

glandium opened this issue May 4, 2020 · 4 comments
Labels
C-bug Category: This is a bug.

Comments

@glandium
Copy link
Contributor

glandium commented May 4, 2020

I tried this code:

trait Foo {}

impl Foo for usize {}

fn bar<T: Foo>(_t: impl Foo) -> T {
    unimplemented!();
}

fn main() {
    bar::<usize>(42);
}

I expected this would give the explicit return value.

Instead, this happened:

error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position
  --> src/main.rs:10:11
   |
10 |     bar::<usize>(42);
   |           ^^^^^ explicit generic argument not allowed
@glandium glandium added the C-bug Category: This is a bug. label May 4, 2020
@jonas-schievink
Copy link
Contributor

This is working as intended, see the impl trait RFCs for details.

@glandium
Copy link
Contributor Author

glandium commented May 4, 2020

I don't see anything mentioned in https://github.com/rust-lang/rfcs/blob/master/text/1951-expand-impl-trait.md. There's something about the lack of explicit instantiation for the simple case, but nothing for mixed cases like the example I pasted.

@jonas-schievink
Copy link
Contributor

Ah, it looks like this was documented on the tracking issue instead: #44721

@glandium
Copy link
Contributor Author

glandium commented May 4, 2020

That issue says "for now", which implies it's not the wanted final state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

2 participants