Skip to content

Commit 777e25a

Browse files
authored
repair Ord for UseSegment (#6375)
Previously, `Ord` for `UseSegment` was not Transitive, causing `user-provided comparison function does not correctly implement a total order` panic.
1 parent 96cc01b commit 777e25a

File tree

4 files changed

+74
-2
lines changed

4 files changed

+74
-2
lines changed

src/imports.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -943,10 +943,10 @@ impl Ord for UseSegment {
943943
version_sort(ia, ib)
944944
} else {
945945
// snake_case < CamelCase < UPPER_SNAKE_CASE
946-
if ia.starts_with(char::is_uppercase) && ib.starts_with(char::is_lowercase) {
946+
if ia.starts_with(char::is_uppercase) && !ib.starts_with(char::is_uppercase) {
947947
return Ordering::Greater;
948948
}
949-
if ia.starts_with(char::is_lowercase) && ib.starts_with(char::is_uppercase) {
949+
if !ia.starts_with(char::is_uppercase) && ib.starts_with(char::is_uppercase) {
950950
return Ordering::Less;
951951
}
952952
if is_upper_snake_case(ia) && !is_upper_snake_case(ib) {

tests/source/issue-6333.rs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// rustfmt-edition: 2021
2+
// rustfmt-max_width: 125
3+
pub use ::dafny_runtime::Sequence;
4+
pub use ::std::rc::Rc;
5+
pub use crate::r#_StructuredEncryptionUtil_Compile::CanonCryptoItem;
6+
pub use ::dafny_runtime::itertools::Itertools;
7+
pub use crate::software::amazon::cryptography::dbencryptionsdk::structuredencryption::internaldafny::types::CryptoAction;
8+
pub use crate::software::amazon::cryptography::materialproviders::internaldafny::types::EncryptedDataKey;
9+
pub use ::dafny_runtime::Object;
10+
pub use crate::software::amazon::cryptography::primitives::internaldafny::types::IAwsCryptographicPrimitivesClient;
11+
pub use crate::software::amazon::cryptography::materialproviders::internaldafny::types::AlgorithmSuiteInfo;
12+
pub use ::dafny_runtime::DafnyCharUTF16;
13+
pub use crate::r#_StructuredEncryptionUtil_Compile::MessageID;
14+
pub use crate::software::amazon::cryptography::materialproviders::internaldafny::types::EncryptionMaterials;
15+
pub use crate::r#_Wrappers_Compile::Outcome;
16+
pub use ::dafny_runtime::string_utf16_of;
17+
pub use ::dafny_runtime::int;
18+
pub use ::dafny_runtime::MapBuilder;
19+
pub use ::dafny_runtime::_System::nat;
20+
pub use crate::software::amazon::cryptography::primitives::internaldafny::types::HMacInput;
21+
pub use ::dafny_runtime::rd;
22+
pub use ::dafny_runtime::truncate;
23+
pub use ::dafny_runtime::DafnyTypeEq;
24+
pub use ::dafny_runtime::DafnyType;

tests/target/issue-6333-2024.rs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// rustfmt-edition: 2024
2+
// rustfmt-max_width: 125
3+
pub use crate::r#_StructuredEncryptionUtil_Compile::CanonCryptoItem;
4+
pub use crate::r#_StructuredEncryptionUtil_Compile::MessageID;
5+
pub use crate::r#_Wrappers_Compile::Outcome;
6+
pub use crate::software::amazon::cryptography::dbencryptionsdk::structuredencryption::internaldafny::types::CryptoAction;
7+
pub use crate::software::amazon::cryptography::materialproviders::internaldafny::types::AlgorithmSuiteInfo;
8+
pub use crate::software::amazon::cryptography::materialproviders::internaldafny::types::EncryptedDataKey;
9+
pub use crate::software::amazon::cryptography::materialproviders::internaldafny::types::EncryptionMaterials;
10+
pub use crate::software::amazon::cryptography::primitives::internaldafny::types::HMacInput;
11+
pub use crate::software::amazon::cryptography::primitives::internaldafny::types::IAwsCryptographicPrimitivesClient;
12+
pub use ::dafny_runtime::_System::nat;
13+
pub use ::dafny_runtime::DafnyCharUTF16;
14+
pub use ::dafny_runtime::DafnyType;
15+
pub use ::dafny_runtime::DafnyTypeEq;
16+
pub use ::dafny_runtime::MapBuilder;
17+
pub use ::dafny_runtime::Object;
18+
pub use ::dafny_runtime::Sequence;
19+
pub use ::dafny_runtime::int;
20+
pub use ::dafny_runtime::itertools::Itertools;
21+
pub use ::dafny_runtime::rd;
22+
pub use ::dafny_runtime::string_utf16_of;
23+
pub use ::dafny_runtime::truncate;
24+
pub use ::std::rc::Rc;

tests/target/issue-6333.rs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// rustfmt-edition: 2021
2+
// rustfmt-max_width: 125
3+
pub use crate::r#_StructuredEncryptionUtil_Compile::CanonCryptoItem;
4+
pub use crate::r#_StructuredEncryptionUtil_Compile::MessageID;
5+
pub use crate::r#_Wrappers_Compile::Outcome;
6+
pub use crate::software::amazon::cryptography::dbencryptionsdk::structuredencryption::internaldafny::types::CryptoAction;
7+
pub use crate::software::amazon::cryptography::materialproviders::internaldafny::types::AlgorithmSuiteInfo;
8+
pub use crate::software::amazon::cryptography::materialproviders::internaldafny::types::EncryptedDataKey;
9+
pub use crate::software::amazon::cryptography::materialproviders::internaldafny::types::EncryptionMaterials;
10+
pub use crate::software::amazon::cryptography::primitives::internaldafny::types::HMacInput;
11+
pub use crate::software::amazon::cryptography::primitives::internaldafny::types::IAwsCryptographicPrimitivesClient;
12+
pub use ::dafny_runtime::_System::nat;
13+
pub use ::dafny_runtime::int;
14+
pub use ::dafny_runtime::itertools::Itertools;
15+
pub use ::dafny_runtime::rd;
16+
pub use ::dafny_runtime::string_utf16_of;
17+
pub use ::dafny_runtime::truncate;
18+
pub use ::dafny_runtime::DafnyCharUTF16;
19+
pub use ::dafny_runtime::DafnyType;
20+
pub use ::dafny_runtime::DafnyTypeEq;
21+
pub use ::dafny_runtime::MapBuilder;
22+
pub use ::dafny_runtime::Object;
23+
pub use ::dafny_runtime::Sequence;
24+
pub use ::std::rc::Rc;

0 commit comments

Comments
 (0)