Skip to content

Using it within println hangs compilation #21

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

Closed
Fiedzia opened this issue Jul 12, 2018 · 5 comments
Closed

Using it within println hangs compilation #21

Fiedzia opened this issue Jul 12, 2018 · 5 comments

Comments

@Fiedzia
Copy link

Fiedzia commented Jul 12, 2018

println!(indoc!("hello world"));

hangs compilation

@dtolnay
Copy link
Owner

dtolnay commented Jul 12, 2018

Thanks! Check out #17. As a workaround you can use println!("{}", indoc!(...)) or use the "unstable" feature of indoc on a nightly compiler:

[dependencies]
indoc = { version = "0.2", features = ["unstable"] }
#![feature(proc_macro, proc_macro_non_items)]

extern crate indoc;
use indoc::indoc;

fn main() {
    println!(indoc!(""));
}

@dtolnay dtolnay changed the title using it withinin println hangs compilation Using it within println hangs compilation Feb 19, 2019
@dtolnay
Copy link
Owner

dtolnay commented Feb 19, 2019

The hang is a compiler bug: rust-lang/rust#44692.

@dtolnay dtolnay mentioned this issue Feb 19, 2019
@MightyPork
Copy link

it doesn't hang for me, but indoc in format macros is not allowed because the (stable) compiler thinks it is not a string literal. Really unfortunate, as that's the use case I had for it :/

@dtolnay
Copy link
Owner

dtolnay commented Dec 6, 2019

It seems the hang was fixed in rustc 1.38.0.

error: format argument must be a string literal
 --> src/main.rs:4:14
  |
4 |     println!(indoc!(""));
  |              ^^^^^^^^^^
  |
  = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
help: you might be missing a string literal to format with
  |
4 |     println!("{}", indoc!(""));
  |              ^^^^^

@dtolnay dtolnay closed this as completed Dec 6, 2019
@dtolnay
Copy link
Owner

dtolnay commented Dec 6, 2019

@MightyPork I filed #36 to consider adding println-like macros with indented strings.

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

No branches or pull requests

3 participants