fusion-engineering / inline-python

Inline Python code directly in your Rust code
https://docs.rs/inline-python
BSD 2-Clause "Simplified" License
1.15k stars 37 forks source link

Work around Rust 2021 tokenization changes #44

Closed m-ou-se closed 3 years ago

m-ou-se commented 3 years ago

See https://github.com/rust-lang/rust/issues/88510

use inline_python::{python, Context};

pub fn foo() {
    let c: Context = python!{
        y = 123;
        x = f"{y}"
    };
}

In Rust 2021, f"{y}" is parsed as a single (currently invalid!) token. The suggestion suggests f "{y}", with a space.

We should detect f "{y}" and remove the space.

m-ou-se commented 3 years ago

This workaround is now in place and published as inline-python 0.7.1 and ct-python 0.5.3.