Skip to content

Regression in 1.42.2: Code from start of macro becomes part of the snapshot #833

@konstin

Description

@konstin

What happened?

#720 introduced a regression: While previously --accept worked correctly, it now adds some Rust code in the prefix and indents incorrectly:

@@ -68,18 +68,18 @@ fn compatible_python_incompatible_override() -> Result<()> {
     let output = uv_snapshot!(filters, command(&context, python_versions)
         .arg("--python-version=3.9")
         , @r"
-                 success: false
-                 exit_code: 1
-                 ----- stdout -----
-
-                 ----- stderr -----
-                 warning: The requested Python version 3.9 is not available; 3.11.[X] will be used to build dependencies instead.
-                   × No solution found when resolving dependencies:
-                   ╰─▶ Because the requested Python version (>=3.9) does not satisfy Python>=3.10 and package-a==1.0.0 depends on Python>=3.10, we can conclude that package-a==1.0.0 cannot be used.
-                       And because you require package-a==1.0.0, we can conclude that your requirements are unsatisfiable.
-
-                       hint: The `--python-version` value (>=3.9) includes Python versions that are not supported by your dependencies (e.g., package-a==1.0.0 only supports >=3.10). Consider using a higher `--python-version` value.
-                 "
+    let output = success: false
+    let output = exit_code: 1
+    let output = ----- stdout -----
+
+    let output = ----- stderr -----
+    let output = warning: The requested Python version 3.9 is not available; 3.11.[X] will be used to build dependencies instead.
+    let output =   × No solution found when resolving dependencies:
+    let output =   ╰─▶ Because the requested Python version (>=3.9) does not satisfy Python>=3.10 and package-a==1.0.0 depends on Python>=3.10, we can conclude that package-a==1.0.0 cannot be used.
+    let output =       And because you require package-a==1.0.0, we can conclude that your requirements are unsatisfiable.
+
+    let output =       hint: The `--python-version` value (>=3.9) includes Python versions that are not supported by your dependencies (e.g., package-a==1.0.0 only supports >=3.10). Consider using a higher `--python-version` value.
+    let output = "
     );
 
     output.assert().failure();

CC @nicholassm

Reproduction steps

git clone https://github.com/astral-sh/uv
git checkout eaa4651df074fcc1f55b1e81735e4a9199e8b430
cargo binstall -y [email protected]
bash scripts/sync_scenarios.sh # GOOD
cargo binstall -y [email protected]
bash scripts/sync_scenarios.sh # BAD

Bisecting with the insta (cargo install --path cargo-insta/ --bin cargo-insta) narrowed this down to #720.

rustc Version

rustc 1.91.1 (ed61e7d7e 2025-11-07)

insta Version

1.43.2, doesn't change the regression

cargo insta --version output

1.42.1, 1.42.2, latest main (6cb41af)

What did you expect?

The snapshot doesn't pull in Rust code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions