fix [std_instead_of_core]: don't assume alloc/core are in the extern prelude#17296
Open
bushrat011899 wants to merge 2 commits into
Open
fix [std_instead_of_core]: don't assume alloc/core are in the extern prelude#17296bushrat011899 wants to merge 2 commits into
alloc/core are in the extern prelude#17296bushrat011899 wants to merge 2 commits into
Conversation
Collaborator
|
r? @Jarcho rustbot has assigned @Jarcho. Use Why was this reviewer chosen?The reviewer was selected based on:
|
Contributor
Author
If `alloc` or `core` aren't present in the prelude, then downgrade suggestions to helps to avoid suggesting broken fixes.
0478a30 to
e34e2dc
Compare
|
Lintcheck changes for e34e2dc
This comment will be updated if you push new changes |
Contributor
Author
|
The large quantity of changes in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
alloc::collections::VecDeque#16695Solution
The current version of this lint doesn't consider the extern prelude before emitting a suggestion, which can lead to fix failures. For example:
This currently emits a failing fix, since it suggests replacing
std::vec::Vecwithalloc::vec::Vec, butallocis not available. This PR addresses this by demoting suggestions to helps ifalloc/corearen't obviously available. "Obvious" means:coreis available ifno_coreandno_implicit_preludearen't used orextern crate core;is present at the crate root (and thus added to the extern prelude)allocis available ifextern crate alloc;is present at the crate root (and thus added to the extern prelude)Renaming crates, or non-root usage of
extern crateis not considered for brevity. Since the lint is always emitted, the worst case scenario is a suggestion isn't automatically applicable.Notes
Please write a short comment explaining your change (or "none" for internal only changes)
changelog: fix certain false positive suggestions for [
std_instead_of_core] whenallocorcorearen't in the extern prelude.