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

Parse lifetime args inside of turbofish #1319

Closed
dtolnay opened this issue Jan 23, 2023 · 0 comments · Fixed by #1320
Closed

Parse lifetime args inside of turbofish #1319

dtolnay opened this issue Jan 23, 2023 · 0 comments · Fixed by #1320

Comments

@dtolnay
Copy link
Owner

dtolnay commented Jan 23, 2023

This is apparently legal Rust syntax. It takes some effort to come up with code with lifetimes inside turbofish which rustc will accept without hitting rust-lang/rust#42868, but here is one such example:

struct Struct;

impl Struct {
    fn f<'a: 'a>(&'a self) {}
}

fn main() {
    Struct.f::<'static>();
}

Syn currently doesn't parse this syntax, it assumes the turbofish contains only types and constant expressions, and treats the lifetime as if it were a bound of a 2015-edition syntax trait object type.

error: at least one trait is required for an object type
 --> dev/main.rs:8:16
  |
8 |     Struct.f::<'static>();
  |                ^^^^^^^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant