rust-clippy
rust-clippy copied to clipboard
Add `manual_as_slice` lint
This pr adds the manual_as_slice lint.
closes: rust-lang/rust-clippy#7633
changelog: add [manual_as_slice] lint
I like manual_as_slice, it shows the intended behavior for the lint. I'll make the changes
I think you need to re-bless the tests.
I'm gonna restrict is to Vec, array and slice in that case, since doing this on a string also would not work
Is it possible to get this working on vec since its not a language item?
Is it possible to get this working on vec since its not a language item?
Language items are items that the compiler needs when it transforms code. For example, it needs panic!() as a language item, as it will generate calls to it. alloc::vec::Vec is not in this category, as the compiler never needs to transform the code in a way that would build a vector.
However, Vec is a diagnostic item, which means that you can get methods from clippy_utils (look for "diagnostic" there) to identify whether something is a Vec or not. Most of the things Clippy needs to identify in the standard library are marked as diagnostic items, and we can mark new items if we need them, so that we can easily use them in lints.
:umbrella: The latest upstream changes (possibly d7b27ecbf319446dd9563a433e9694fa3bcd0d8c) made this pull request unmergeable. Please resolve the merge conflicts.
:umbrella: The latest upstream changes (possibly b379d54c22f9f6b9577075d7f89645ac2498c931) made this pull request unmergeable. Please resolve the merge conflicts.
since doing this on a string also would not work
I think it would work, you'd just need to suggest as_str/as_str_mut instead. But this could be left as a future improvement