You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
editor or extension: Zed, Neovim (via rustaceanvim)
relevant settings: No environment variables, default settings for both editors and rustaceanvim.
repository link (if public, optional): No need, see the snippet.
When applying a snippet in assert!, debug_assert! or format! any whitespace (excluding ones inside string literals) get removed, and possibly broken code is inserted.
The problematic snippets I tested are box and unsafe but there might be more.
The exact behavior depends on the snippet, but using another snippet breaks things further and instead of just removing whitespaces. See a few examples in the reproducer.
code snippet to reproduce:
This is the code before applying the snippet.
fnmain(){let a = true;assert!(if a == false{true} else {false});}
After applying the snippet the whitespace's are removed from whatever was inside of it.
The example is with the unsafe snippet but it works with any of the snippets mentioned above.
fnmain(){let a = true;assert!(unsafe{ ifa==false{true}else{false}})}
Not only does this break any code that needs whitespace's, it tampers with undo's in Zed as well (not in Neovim so Im unsure if this part is an editor bug or configuration bug of some kind).
Issuing an undo after applying the snippet yields us with:
fnmain(){let a = true;assert!(if a == false{true} else {false}.unsafe{ ifa==false{true}else{false}})}
There are many snippet combinations that could be broken so just leaving a few examples instead of all possible combinations.
Applying a box snippet followed by an unsafe snippet.
Reversiving the order of how the snippet is applied yields us the correct result except of the missing whitespace's.
fnmain(){let a = true;assert!(Box::new(ifa==false{true}else{false}).unsafe{})}
Applying a box snippet twice.
fnmain(){let a = true;assert!(Box::new(ifa==false{true}else{false}).Box)}
The text was updated successfully, but these errors were encountered:
airblast-dev
changed the title
Broken snippets being applied in assert! and debug_assert!
Broken snippets being applied in assert!, debug_assert! and format!Jan 29, 2025
rust-analyzer version: rust-analyzer 1 (248bd51 2025-01-18)
rustc version: rustc 1.83.0 (90b35a623 2024-11-26)
editor or extension: Zed, Neovim (via rustaceanvim)
relevant settings: No environment variables, default settings for both editors and rustaceanvim.
repository link (if public, optional): No need, see the snippet.
When applying a snippet in
assert!
,debug_assert!
orformat!
any whitespace (excluding ones inside string literals) get removed, and possibly broken code is inserted.The problematic snippets I tested are
box
andunsafe
but there might be more.The exact behavior depends on the snippet, but using another snippet breaks things further and instead of just removing whitespaces. See a few examples in the reproducer.
code snippet to reproduce:
This is the code before applying the snippet.
After applying the snippet the whitespace's are removed from whatever was inside of it.
The example is with the
unsafe
snippet but it works with any of the snippets mentioned above.Not only does this break any code that needs whitespace's, it tampers with undo's in Zed as well (not in Neovim so Im unsure if this part is an editor bug or configuration bug of some kind).
Issuing an undo after applying the snippet yields us with:
There are many snippet combinations that could be broken so just leaving a few examples instead of all possible combinations.
Applying a box snippet followed by an unsafe snippet.
Reversiving the order of how the snippet is applied yields us the correct result except of the missing whitespace's.
Applying a box snippet twice.
The text was updated successfully, but these errors were encountered: