diff --git a/tests/ui/capture-var-nested.rs b/tests/ui/capture-var-nested.rs new file mode 100644 index 0000000..54dc432 --- /dev/null +++ b/tests/ui/capture-var-nested.rs @@ -0,0 +1,6 @@ +use indoc::indoc; + +fn main() { + let world = "world"; + println!(indoc!("Hello {world}")); +} diff --git a/tests/ui/capture-var-nested.stderr b/tests/ui/capture-var-nested.stderr new file mode 100644 index 0000000..c98b3c0 --- /dev/null +++ b/tests/ui/capture-var-nested.stderr @@ -0,0 +1,8 @@ +error: there is no argument named `world` + --> tests/ui/capture-var-nested.rs:5:21 + | +5 | println!(indoc!("Hello {world}")); + | ^^^^^^^^^^^^^^^ + | + = note: did you intend to capture a variable `world` from the surrounding scope? + = note: to avoid ambiguity, `format_args!` cannot capture variables when the format string is expanded from a macro