-
Notifications
You must be signed in to change notification settings - Fork 913
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
rustfmt thinks it should be able to modify string values #5744
Comments
@matthiaskrgr thanks for the report. From what I can tell rustfmt doesn't modify the string lit. Running rustfmt with
rustfmt is simply warning the user that there's trailing whitespace in the input that it was unable to remove, but as far as I know it will never try to modify the string lit. |
for completeness, the same issue also arises inside macro invocations , without the need to pass fn main() {
a!(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()
)
} (Not sure why the identifier has to be this long)
|
@Wuelle I want to point out that what you're experiencing is unrelated to the current issue. In your case there is trailing whitespace in the input file that rustfmt is unable to remove because of the long identifier name. Bumping the |
I think I encountered the same issue combined with #5711
#[cfg(test)]
mod tests {
#[tokio::test]
async fn test_foo() -> Result<()> {
db.query("
INSERT INTO tbl.bar
(fkey_strategy_id, pkey_id, blockchain, token_name, token_address, quantity, updated_at, created_at)
VALUES
($1, $2, $3, $4, $5, $6, $7, $8);
", &[
&strategy.strategy_id as &(dyn ToSql + Sync),
]).await?;
Ok(())
}
} |
@qiujiangkun this is not the same issue. The trailing whitespace that rustfmt is warning you about isn't contained in the query stinrg, it's after the of The following line is way to long to fit into the default width of 100, and therefore rustfmt is unable to format the chain
rustfmt doesn't modify whitespace within string literals so you could fix this problem by dedenting the SQL query or by setting the |
I don't expect internal errors while formatting a valid program. I can accept behavior like this: |
note how line 2 inside the format string is actually "a ".
apparently rustfmt things it should be able to change this which is scary because it could potentially alter program behaviour
cargo fmt -- --error-on-unformatted --unstable-features
The text was updated successfully, but these errors were encountered: