-
-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Previously, the `left.cmp(&right)` call could resolve to `Iterator::cmp`. A malicious impl could even force it to use `fn(&mut self, rhs: &Self)`! Code exploiting this bug is unlikely, but it could hit other errors, so this way the error emitted is much nicer. Also makes the previous trybuild test for PostgresEq more realistic.
- Loading branch information
1 parent
fe7fe7c
commit a8a09a0
Showing
5 changed files
with
41 additions
and
8 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
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,20 @@ | ||
use pgrx::prelude::*; | ||
use serde::{Serialize, Deserialize}; | ||
|
||
#[derive(Serialize, Deserialize, PartialEq, PartialOrd, PostgresType, PostgresOrd)] | ||
pub struct BrokenType { | ||
int: i32, | ||
} | ||
|
||
impl BrokenType { | ||
fn cmp(&mut self, _other: &Self) -> Anything { | ||
Anything::Whatever | ||
} | ||
} | ||
|
||
#[repr(u8)] | ||
enum Anything { | ||
Whatever = 0, | ||
} | ||
|
||
fn main() {} |
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,12 @@ | ||
error[E0277]: the trait bound `BrokenType: std::cmp::Ord` is not satisfied | ||
--> tests/ui/total_ord_for_postgres_ord.rs:4:71 | ||
| | ||
4 | #[derive(Serialize, Deserialize, PartialEq, PartialOrd, PostgresType, PostgresOrd)] | ||
| ^^^^^^^^^^^ the trait `std::cmp::Ord` is not implemented for `BrokenType` | ||
| | ||
= note: this error originates in the derive macro `PostgresOrd` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
help: consider annotating `BrokenType` with `#[derive(Ord)]` | ||
| | ||
5 + #[derive(Ord)] | ||
6 | pub struct BrokenType { | ||
| |