-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Rust nightly broke formatdoc! #106408
Comments
Uh, this is pretty bad. I did not intend to break anything, but I think I see what's going on. I'll take a look but I'm not sure whether it will be easy, as I don't think this code should technically compile according to our rule for format_args captures (but in my opinion this should work). If we don't find a conclusion quickly enough it might be worth it to revert e6c02aa. |
The documentation clearly says that it shouldn't work. But it was accepted for a year. The question now, obviously, is: how many crates actually managed to depend on that misfeature. |
Note that you accidentally fixed another bug in the indoc crate… although maybe not in a way the guy who filed that bug expected. |
Where exactly does it say that it shouldn't work? Note that |
It does look like the RFC's rejection of #[proc_macro]
pub fn foo(_: proc_macro::TokenStream) -> proc_macro::TokenStream {
r#"{ let x = 5; format!("{x}") }"#.parse().unwrap()
} fn main() {
dbg!(procmacro::foo!());
}
I don't really see any reason to outright reject this, it's still possible to implement the same thing but it forces the proc-macro to parse the format string and extract all the parameters and individually span them ( |
WG-prioritization assigning priority (Zulip discussion). @rustbot label -I-prioritize +P-medium |
…ther-it-really-is-a-literal, r=compiler-errors Revert "Improve heuristics whether `format_args` string is a source literal" This reverts commit e6c02aa (from rust-lang#106195). Keeps the code improvements from the PR and the test (as a known-bug). Works around rust-lang#106408 while a proper fix is discussed more thoroughly in rust-lang#106505, as proposed by `@tmandry.` Reopens rust-lang#106191 r? compiler-errors
Closing this as the revert in #107041 fixed this and also added a test for this. |
I guess good deeds don't go unpubished.
When I filed issue about
indoc
crashing the compiler with safe code I was, kinda, expecting that fix for the issue would lead to successful compilation, not regression.Note that this code:
works on all version of Rust starting from 1.58 till 1.67.
Now it no longer works (after fix for #106191).
One may argue that code was never supposed to work, but since it was supported for whole year… it's probably good to note it somewhere (preferable in release notes, I guess).
The text was updated successfully, but these errors were encountered: