-
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into git2-to-gix
- Loading branch information
Showing
16 changed files
with
302 additions
and
14 deletions.
There are no files selected for viewing
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
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-public.", | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
SemverQuery( | ||
id: "trait_removed_associated_constant", | ||
human_readable_name: "trait's associated constant was removed", | ||
description: "A trait's associated constant was removed or renamed", | ||
required_update: Major, | ||
reference_link: Some("https://doc.rust-lang.org/cargo/reference/semver.html#item-remove"), | ||
query: r#" | ||
{ | ||
CrateDiff { | ||
baseline { | ||
item { | ||
... on Trait { | ||
trait_name: name @output | ||
visibility_limit @filter(op: "=", value: ["$public"]) @output | ||
importable_path { | ||
path @output @tag | ||
} | ||
associated_constant { | ||
associated_constant: name @output @tag | ||
span_: span @optional { | ||
filename @output | ||
begin_line @output | ||
} | ||
} | ||
} | ||
} | ||
} | ||
current { | ||
item { | ||
... on Trait { | ||
visibility_limit @filter(op: "=", value: ["$public"]) | ||
importable_path { | ||
path @filter(op: "=", value: ["%path"]) | ||
} | ||
associated_constant @fold @transform(op: "count") @filter(op: "=", value: ["$zero"]) { | ||
name @filter(op: "=", value: ["%associated_constant"]) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}"#, | ||
arguments: { | ||
"public": "public", | ||
"zero": 0, | ||
}, | ||
error_message: "A public trait's associated constant was removed or renamed.", | ||
per_result_error_template: Some("associated constant {{trait_name}}::{{associated_constant}}, previously at {{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,24 @@ | ||
// 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 {} | ||
} | ||
|
||
// Making this private should cause a warning | ||
pub(crate) mod will_make_private { | ||
mod e {} | ||
} | ||
|
||
// 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,13 @@ | ||
mod a {} | ||
|
||
mod b { | ||
pub mod b {} | ||
} | ||
|
||
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,7 @@ | ||
[package] | ||
publish = false | ||
name = "trait_removed_associated_constant" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
11 changes: 11 additions & 0 deletions
11
test_crates/trait_removed_associated_constant/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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
pub trait RemovedAssociatedConstantFromTrait { | ||
} | ||
|
||
pub trait TraitWithConstant { | ||
const APPLE: i32; | ||
} | ||
|
||
pub trait RemovedAssociatedConstantDefaultFromTrait: TraitWithConstant {} | ||
|
||
// this trait is private therefore removing the constant is not breaking | ||
trait PrivateTraitWithTypeRemoved {} |
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 = "trait_removed_associated_constant" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
23 changes: 23 additions & 0 deletions
23
test_crates/trait_removed_associated_constant/old/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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
pub trait RemovedAssociatedConstantFromTrait { | ||
const APPLE: i32; | ||
} | ||
|
||
pub trait TraitWithConstant { | ||
const APPLE: i32; | ||
} | ||
|
||
pub trait RemovedAssociatedConstantDefaultFromTrait: TraitWithConstant { | ||
const APPLE: i32 = 2; | ||
} | ||
|
||
// this trait is private therefore removing the constant is not breaking | ||
trait PrivateTraitWithTypeRemoved { | ||
const APPLE: i32; | ||
} | ||
|
||
/// This trait should not be reported by the `trait_removed_associated_constant` rule: | ||
/// it will be removed altogether, so the correct rule to catch it is | ||
/// the `trait_missing` rule and not the rule for missing associated constants. | ||
pub trait RemovedTrait { | ||
const APPLE: i32; | ||
} |
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(8), | ||
"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(11), | ||
"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"), | ||
}, | ||
], | ||
} |
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,26 @@ | ||
{ | ||
"./test_crates/trait_removed_associated_constant/": [ | ||
{ | ||
"associated_constant": String("APPLE"), | ||
"path": List([ | ||
String("trait_removed_associated_constant"), | ||
String("RemovedAssociatedConstantFromTrait"), | ||
]), | ||
"span_begin_line": Uint64(2), | ||
"span_filename": String("src/lib.rs"), | ||
"trait_name": String("RemovedAssociatedConstantFromTrait"), | ||
"visibility_limit": String("public"), | ||
}, | ||
{ | ||
"associated_constant": String("APPLE"), | ||
"path": List([ | ||
String("trait_removed_associated_constant"), | ||
String("RemovedAssociatedConstantDefaultFromTrait"), | ||
]), | ||
"span_begin_line": Uint64(10), | ||
"span_filename": String("src/lib.rs"), | ||
"trait_name": String("RemovedAssociatedConstantDefaultFromTrait"), | ||
"visibility_limit": String("public"), | ||
}, | ||
], | ||
} |