diff options
Diffstat (limited to 'src/test/incremental/issue-82920-predicate-order-miscompile.rs')
-rw-r--r-- | src/test/incremental/issue-82920-predicate-order-miscompile.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/test/incremental/issue-82920-predicate-order-miscompile.rs b/src/test/incremental/issue-82920-predicate-order-miscompile.rs new file mode 100644 index 000000000..793af679c --- /dev/null +++ b/src/test/incremental/issue-82920-predicate-order-miscompile.rs @@ -0,0 +1,31 @@ +// revisions: rpass1 rpass2 + +trait MyTrait: One + Two {} +impl<T> One for T { + fn method_one(&self) -> usize { + 1 + } +} +impl<T> Two for T { + fn method_two(&self) -> usize { + 2 + } +} +impl<T: One + Two> MyTrait for T {} + +fn main() { + let a: &dyn MyTrait = &true; + assert_eq!(a.method_one(), 1); + assert_eq!(a.method_two(), 2); +} + +// Re-order traits 'One' and 'Two' between compilation +// sessions + +#[cfg(rpass1)] +trait One { fn method_one(&self) -> usize; } + +trait Two { fn method_two(&self) -> usize; } + +#[cfg(rpass2)] +trait One { fn method_one(&self) -> usize; } |