Skip to content

Conversation

lapla-cogito
Copy link
Contributor

@lapla-cogito lapla-cogito commented Jan 14, 2025

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 a no_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 in no_std environments as well.

changelog: [redundant_closure]: correct suggestion in no_std
changelog: [repeat_vec_with_capacity]: correct suggestion in no_std
changelog: [single_range_in_vec_init]: don't emit suggestion to use Vec in no_std
changelog: [drain_collect]: correct suggestion in no_std
changelog: [map_with_unused_argument_over_ranges]: correct suggestion in no_std

also close #13895

@rustbot
Copy link
Collaborator

rustbot commented Jan 14, 2025

r? @dswij

rustbot has assigned @dswij.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jan 14, 2025
@@ -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) {
Copy link
Contributor Author

@lapla-cogito lapla-cogito Jan 14, 2025

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.

@rustbot
Copy link
Collaborator

rustbot commented Jan 26, 2025

Could not assign reviewer from: y21.
User(s) y21 are either the PR author, already assigned, or on vacation. Please use r? to specify someone else to assign.

@lapla-cogito
Copy link
Contributor Author

r? clippy

@rustbot rustbot assigned Manishearth and unassigned dswij Jan 26, 2025
@Manishearth Manishearth added this pull request to the merge queue Jan 27, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 27, 2025
@Manishearth Manishearth added this pull request to the merge queue Jan 27, 2025
Merged via the queue into rust-lang:master with commit 83bde36 Jan 27, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

redundant_closure makes incorrect suggestion
4 participants