-
-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change behavior of lint to lint API specific breakage
- Loading branch information
1 parent
164eff7
commit b244d6b
Showing
11 changed files
with
145 additions
and
90 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
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
2 changes: 1 addition & 1 deletion
2
...riant_discriminant_changed/new/Cargo.toml → ...riant_discriminant_changed/new/Cargo.toml
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
50 changes: 50 additions & 0 deletions
50
test_crates/enum_no_repr_variant_discriminant_changed/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,50 @@ | ||
// Explicit discriminant changed values. By doing so, it changed the implicit | ||
// discriminant's value as well, should be reported. | ||
pub enum ExplicitAndImplicitDiscriminantsAreChanged { | ||
First = 2, | ||
Second, | ||
Third = 5, | ||
} | ||
|
||
// Discriminant changed to be doc hidden and explicit. Being doc hidden is not relevant | ||
// since it's still part of the public API, should be reported. | ||
pub enum DiscriminantBecomesDocHiddenAndExplicit { | ||
First, | ||
#[doc(hidden)] | ||
Second = 2, | ||
} | ||
|
||
// Explicit discriminants changed values, but being private dominates, should not be | ||
// reported. | ||
enum PrivateEnum { | ||
First = 10, | ||
Second = 11, | ||
} | ||
|
||
// Discriminant changed value, but with repr, should not be reported as it involves ABI | ||
// breakage as well, and this is linted at *API* only breakage. | ||
#[repr(u8)] | ||
pub enum FieldlessWithDiscrimants { | ||
First = 10, | ||
Tuple(), | ||
Struct {}, | ||
Unit, | ||
Last = 21, | ||
} | ||
|
||
// Implicit discriminant value changed by becoming explicit, should not be reported as it involves | ||
// ABI breakage as well, and this is linted at *API* only breakage. | ||
#[repr(u8)] | ||
pub enum FieldlessChangesToExplicitDescriminant { | ||
Tuple(), | ||
Struct {}, | ||
Unit = 5, | ||
} | ||
|
||
// Variant `Struct` acquires a field. By doing so, it makes the enum not `well-defined`, | ||
// meaning it is not possible to do a numeric cast anymore on the enum, should not be reported. | ||
pub enum UnitOnlyBecomesUndefined { | ||
First, | ||
Second, | ||
Struct { a: i64 }, | ||
} |
2 changes: 1 addition & 1 deletion
2
...riant_discriminant_changed/old/Cargo.toml → ...riant_discriminant_changed/old/Cargo.toml
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
53 changes: 53 additions & 0 deletions
53
test_crates/enum_no_repr_variant_discriminant_changed/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,53 @@ | ||
// My task is: | ||
// discriminant changed value but no repr (API only) | ||
// the enum does not have an explicit representation (no repr) | ||
// we want to be super sure the 4 lints are disjoint here -- we should never have multiple of them trigger on the same variant | ||
|
||
// Explicit discriminant changed values. By doing so, it changed the implicit | ||
// discriminant's value as well, should be reported. | ||
pub enum ExplicitAndImplicitDiscriminantsAreChanged { | ||
First = 1, | ||
Second, | ||
Third = 5, | ||
} | ||
|
||
// Discriminant changed to be doc hidden and explicit. Being doc hidden is not relevant | ||
// since it's still part of the public API, should be reported. | ||
pub enum DiscriminantBecomesDocHiddenAndExplicit { | ||
First, | ||
Second, | ||
} | ||
|
||
// Explicit discriminants changed values, but being private dominates, should not be | ||
// reported. | ||
enum PrivateEnum { | ||
First = 1, | ||
Second = 2, | ||
} | ||
|
||
// Discriminant changed value, but with repr, should not be reported as it involves ABI | ||
// breakage as well, and this is linted at *API* only breakage. | ||
#[repr(u8)] | ||
pub enum FieldlessWithDiscrimants { | ||
First = 10, | ||
Tuple(), | ||
Struct {}, | ||
Unit, | ||
Last = 20, | ||
} | ||
|
||
// Implicit discriminant value changed by becoming explicit, should not be reported as it involves | ||
// ABI breakage as well, and this is linted at *API* only breakage. | ||
pub enum FieldlessChangesToExplicitDescriminant { | ||
Tuple(), | ||
Struct {}, | ||
Unit, | ||
} | ||
|
||
// Variant `Struct` acquires a field. By doing so, it makes the enum not `well-defined`, | ||
// meaning it is not possible to do a numeric cast anymore on the enum, should not be reported. | ||
pub enum UnitOnlyBecomesUndefined { | ||
First, | ||
Second, | ||
Struct {}, | ||
} |
31 changes: 0 additions & 31 deletions
31
test_crates/enum_variant_discriminant_changed/new/src/lib.rs
This file was deleted.
Oops, something went wrong.
30 changes: 0 additions & 30 deletions
30
test_crates/enum_variant_discriminant_changed/old/src/lib.rs
This file was deleted.
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
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