-
-
Notifications
You must be signed in to change notification settings - Fork 84
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
New "module_missing" lint to detect missing, renamed, or non-visible modules #534
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
49d2d1a
Update lockfile to latest trustfall-rustdoc-adapter(s)
nmathewson 0014353
Add a new "module_missing" lint
nmathewson 8d25044
module_missing: Add expected positives for trait_missing*
nmathewson 6351ca6
fixup! Add a new "module_missing" lint
nmathewson c853f31
fixup! Add a new "module_missing" lint
nmathewson ac0497c
Update test_crates/module_missing/new/src/lib.rs
obi1kenobi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
SemverQuery( | ||
id: "module_missing", | ||
human_readable_name: "pub module removed or renamed", | ||
description: "A module can no longer be imported by its prior path", | ||
required_update: Major, | ||
reference_link: Some("https://doc.rust-lang.org/cargo/reference/semver.html#item-remove"), | ||
query: r#" | ||
{ | ||
CrateDiff { | ||
baseline { | ||
item { | ||
... on Module { | ||
visibility_limit @filter(op: "=", value: ["$public"]) @output | ||
name @output | ||
|
||
importable_path { | ||
path @output @tag | ||
} | ||
|
||
span_: span @optional { | ||
filename @output | ||
begin_line @output | ||
} | ||
} | ||
} | ||
} | ||
current @fold @transform(op: "count") @filter(op: "=", value: ["$zero"]) { | ||
item { | ||
... on Module { | ||
visibility_limit @filter(op: "=", value: ["$public"]) | ||
|
||
importable_path { | ||
path @filter(op: "=", value: ["%path"]) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}"#, | ||
arguments: { | ||
"public": "public", | ||
"zero": 0, | ||
}, | ||
error_message: "A publicly-visible module cannot be imported by its prior path. A `pub use` may have been removed, or the module may have been renamed, removed, or made non-visible.", | ||
per_result_error_template: Some("{mod {{join \"::\" path}}, previously in file {{span_filename}}:{{span_begin_line}}"), | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
publish = false | ||
name = "module_missing" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Removing this, but no warning should happen: | ||
// it isn't public. | ||
// | ||
//mod a { | ||
//} | ||
|
||
mod b { | ||
// Removing this, but no warning should happen: | ||
// it isn't visible. | ||
// pub mod b { | ||
// } | ||
} | ||
|
||
pub mod bb { | ||
// Removing this should cause a warning. | ||
//pub mod will_remove { | ||
//} | ||
obi1kenobi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
// Making this private should cause a warning | ||
pub(crate) mod will_make_private { | ||
mod e { | ||
} | ||
obi1kenobi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
// Adding a module shouldn't cause problems. | ||
pub mod new_module { | ||
} |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
publish = false | ||
name = "module_missing" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
mod a { | ||
} | ||
|
||
mod b { | ||
pub mod b { | ||
} | ||
obi1kenobi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
pub mod bb { | ||
pub mod will_remove { | ||
} | ||
} | ||
|
||
pub mod will_make_private { | ||
mod e { | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"./test_crates/module_missing/": [ | ||
{ | ||
"name": String("will_remove"), | ||
"path": List([ | ||
String("module_missing"), | ||
String("bb"), | ||
String("will_remove"), | ||
]), | ||
"span_begin_line": Uint64(10), | ||
"span_filename": String("src/lib.rs"), | ||
"visibility_limit": String("public"), | ||
}, | ||
{ | ||
"name": String("will_make_private"), | ||
"path": List([ | ||
String("module_missing"), | ||
String("will_make_private"), | ||
]), | ||
"span_begin_line": Uint64(14), | ||
"span_filename": String("src/lib.rs"), | ||
"visibility_limit": String("public"), | ||
}, | ||
], | ||
"./test_crates/trait_missing/": [ | ||
{ | ||
"name": String("my_pub_mod"), | ||
"path": List([ | ||
String("trait_missing"), | ||
String("my_pub_mod"), | ||
]), | ||
"span_begin_line": Uint64(5), | ||
"span_filename": String("src/lib.rs"), | ||
"visibility_limit": String("public"), | ||
}, | ||
], | ||
"./test_crates/trait_missing_with_major_bump/": [ | ||
{ | ||
"name": String("my_pub_mod"), | ||
"path": List([ | ||
String("trait_missing_with_major_bump"), | ||
String("my_pub_mod"), | ||
]), | ||
"span_begin_line": Uint64(5), | ||
"span_filename": String("src/lib.rs"), | ||
"visibility_limit": String("public"), | ||
}, | ||
], | ||
} |
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.