forked from rust-lang/rust
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
212b2c7
commit a81c59f
Showing
7 changed files
with
168 additions
and
57 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
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
35 changes: 35 additions & 0 deletions
35
src/test/ui/specialization/soundness/partial_eq_range_inclusive.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,35 @@ | ||
// run-pass | ||
|
||
use std::cell::RefCell; | ||
use std::cmp::Ordering; | ||
|
||
struct Evil<'a, 'b> { | ||
values: RefCell<Vec<&'a str>>, | ||
to_insert: &'b String, | ||
} | ||
|
||
impl<'a, 'b> PartialEq for Evil<'a, 'b> { | ||
fn eq(&self, _other: &Self) -> bool { | ||
true | ||
} | ||
} | ||
|
||
impl<'a> PartialOrd for Evil<'a, 'a> { | ||
fn partial_cmp(&self, _other: &Self) -> Option<Ordering> { | ||
self.values.borrow_mut().push(self.to_insert); | ||
None | ||
} | ||
} | ||
|
||
fn main() { | ||
let e; | ||
let values; | ||
{ | ||
let to_insert = String::from("Hello, world!"); | ||
e = Evil { values: RefCell::new(Vec::new()), to_insert: &to_insert }; | ||
let range = &e..=&e; | ||
let _ = range == range; | ||
values = e.values; | ||
} | ||
assert_eq!(*values.borrow(), Vec::<&str>::new()); | ||
} |
Oops, something went wrong.