-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
correct suggestions in no_std
#13999
base: master
Are you sure you want to change the base?
Conversation
…n a `no_std` environment
…o_std` environment
@@ -125,7 +125,7 @@ impl LateLintPass<'_> for SingleRangeInVecInit { | |||
span, | |||
format!("{suggested_type} of `Range` that is only one element"), | |||
|diag| { | |||
if should_emit_every_value { | |||
if should_emit_every_value && !is_no_std_crate(cx) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a no_std
environment, we may use alloc::vec::Vec
, but this assumes the existence of a heap allocator, so Clippy shouldn't suggest to use alloc::vec::Vec
in general because it violates the purpose of Applicability::MaybeIncorrect
. Also, using Applicability::Unspecified
is noisy in such environments.
Could not assign reviewer from: |
r? clippy |
I opened #13896 before. However, I found that there're more cases where Clippy suggests to use modules that belong to the
std
crate even in ano_std
environment. Therefore, this PR include the changes I've made in #13896 and new changes to fix cases I found this time to prevent wrong suggestions inno_std
environments as well.changelog: [
redundant_closure
]: correct suggestion inno_std
changelog: [
repeat_vec_with_capacity
]: correct suggestion inno_std
changelog: [
single_range_in_vec_init
]: don't emit suggestion to useVec
inno_std
changelog: [
drain_collect
]: correct suggestion inno_std
changelog: [
map_with_unused_argument_over_ranges
]: correct suggestion inno_std
also close #13895