-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
Add lint inherent_associated_pub_const_missing #714
Merged
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
d1ba5a7
Added lint inherent_associated_pub_const_missing
arpity22 37702f4
fixes
arpity22 9ba6760
Modifications
arpity22 0c677cc
Modifications
arpity22 79adc6d
Merge branch 'obi1kenobi:main' into main
arpity22 6ff5d23
Adding new test cases
arpity22 bd81dc1
editing test output
arpity22 99b523d
Merge branch 'obi1kenobi:main' into main
arpity22 3995496
Adding new test cases
arpity22 8042812
Adding new test cases
arpity22 938db7d
Update src/lints/inherent_associated_pub_const_missing.ron
arpity22 ea1f008
adding test case
arpity22 f11a39f
Merge branch 'main' into main
arpity22 76b2b57
Merge branch 'obi1kenobi:main' into main
arpity22 90c3172
adding test case
arpity22 49eb155
Merge branch 'main' of github.com:arpity22/cargo-semver-checks
arpity22 4cf6944
Update src/lints/inherent_associated_pub_const_missing.ron
arpity22 4081a40
Merge branch 'main' into main
arpity22 c4062cf
Merge branch 'main' into main
obi1kenobi 11c7098
Merge branch 'main' into main
obi1kenobi afb330a
Query Modifications
arpity22 60b2ed3
Formatting
arpity22 353d8a8
Merge branch 'main' into main
arpity22 c42b06c
Apply suggestions from code review
obi1kenobi 7da4ce5
Merge branch 'main' into main
obi1kenobi File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
test_crates/inherent_associated_pub_const_missing/new/src/lib.rs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,26 @@ | ||
pub struct StructA {} | ||
impl StructA { | ||
pub const PublicConstantB: i32 = 0; | ||
#[doc(hidden)] | ||
pub const PublicConstantE: i32 = 0; | ||
pub const PublicConstantRenamedA: i32 = 0; | ||
} | ||
struct StructB {} | ||
impl StructB { | ||
#[doc(hidden)] | ||
pub const PublicConstantD: i32 = 0; | ||
pub const PublicConstantRenamedB: i32 = 0; | ||
} | ||
#[doc(hidden)] | ||
pub struct StructC {} | ||
impl StructC {} | ||
#[doc(hidden)] | ||
pub struct StructD {} | ||
impl StructD { | ||
pub const PublicConstantG: i32 = 0; | ||
} | ||
pub struct StructE {} | ||
#[doc(hidden)] | ||
impl StructE { | ||
pub const PublicConstantI: i32 = 0; | ||
} | ||
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
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.
Could you add these kinds of variants to the baseline as well, so that we also test whether removals of
doc(hidden)
in all these places results in the lint being triggered?Right now, I think these tests still don't target the
public_api_eligible
lines in the query I pointed out, because those lines were in thebaseline
arm of the query, whereas this code is only evaluated in thecurrent
arm since it's in thenew
directory in the test crate.Also, as a bit of a nitpick: please consider adding blank lines between different items, such as between structs and impl blocks etc. Code this tight is quite difficult to read, even if
rustfmt
lets it go through.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.
Sorry for the misunderstanding, so we want test cases for when we remove the const from impl block/struct that were #[doc(hidden)] or we remove the const that was #[doc(hidden)] and the lint should be triggered in such cases
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.
We want both kinds of test cases.
At a high level, our tests serve three purposes:
So we want to check
#[doc(hidden)]
in all the places where it can appear, both where it's added innew
and where it's removed innew
, as well as where it remains unchanged betweenold
andnew
.Currently, you have the first kind of test covered well.
Removing
#[doc(hidden)]
from any of these places while also removing the constant is not a major change, and shouldn't trigger the lint. This is the second kind of test, and is not currently covered.Making the const, its impl block, or the owning type become
#[doc(hidden)]
is a major change, but one for a different lint. (Same if the owning type got deleted altogether.) Even if the const itself is removed altogether, this lint shouldn't trigger here. This is the third kind of test, and is partially covered.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.
Summary of added test cases:
struct_now_doc_hidden
triggeredThere 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.
Excellent, nicely done!