Skip to content

Fix clippy lints that will become warnings - #435

Merged
sholderbach merged 2 commits into
nushell:mainfrom
sholderbach:future-clippy
Jun 3, 2022
Merged

sholderbach merged 2 commits into
nushell:mainfrom
sholderbach:future-clippy

Conversation

@sholderbach

Copy link
Copy Markdown
Member

clippy from the nightly future

clippy from the nightly future
@sholderbach sholderbach added the chore Various work that should be done to keep the repo in a nice shape label May 30, 2022
@sholderbach
sholderbach marked this pull request as draft May 30, 2022 16:38
@sholderbach

sholderbach commented May 30, 2022 •

Copy link
Copy Markdown
Member Author

This lint/change is nasty as ansi_term and thus nu_ansi_term on their AnsiGenericString implement Display to apply the styling and Deref to just return the underlying &str and as ToString is implemented for any T: Display + ?Sized the to_string implementation relies on the Display defined for the type alias AnsiString and not on the impl ToString for str for the &str accessible through Deref.

Applying the suggested fix will remove syntax highlighting!!!
image
image

This [lint](https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_to_owned) is nasty as `ansi_term` and thus `nu_ansi_term` on their `AnsiGenericString` implement `Display` to apply the styling and `Deref` to just return the underlying `&str`.
As [`ToString` is implemented for any `T: Display + ?Sized` ](https://doc.rust-lang.org/std/string/trait.ToString.html#impl-ToString-6) the to_string implementation relies on the `Display` defined for the type alias `AnsiString` and not on the `impl ToString for str` for the `&str` accessible through `Deref`.

Applying the suggested fix will remove syntax highlighting!!!
@sholderbach
sholderbach marked this pull request as ready for review June 3, 2022 08:47
@sholderbach
sholderbach merged commit 265e599 into nushell:main Jun 3, 2022
@sholderbach
sholderbach deleted the future-clippy branch June 3, 2022 08:47
sholderbach added a commit to nushell/nushell that referenced this pull request Jun 3, 2022
Resolves an unexpected issue due to `Deref` and `ToString` interacting

Details: nushell/nu-ansi-term#5 and nushell/reedline#435 (comment)

Also updates reedline: Includes a fix for a panic when the directory containing the history is deleted during a running reedline session. (nushell/reedline#436)
fennewald pushed a commit to fennewald/nushell that referenced this pull request Jun 27, 2022
Resolves an unexpected issue due to `Deref` and `ToString` interacting

Details: nushell/nu-ansi-term#5 and nushell/reedline#435 (comment)

Also updates reedline: Includes a fix for a panic when the directory containing the history is deleted during a running reedline session. (nushell/reedline#436)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Various work that should be done to keep the repo in a nice shape

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant