about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-05-14 04:56:56 +0000
committerbors <bors@rust-lang.org>2018-05-14 04:56:56 +0000
commit76027ed2ad16cbb57919fe9c4dd3849469650570 (patch)
treee3e89fa3b4e2c2bd708be42196d6eede9c191065 /src/test
parent4468e3ea3e905663e24574ded431070756e0deb5 (diff)
parent56bc4c249093f8b63fbc2dc35b4343871808d282 (diff)
downloadrust-76027ed2ad16cbb57919fe9c4dd3849469650570.tar.gz
rust-76027ed2ad16cbb57919fe9c4dd3849469650570.zip
Auto merge of #50694 - leodasvacas:fix-impl-trait-self-substitution, r=petrochenkov
Fix self referential impl Trait substitutions

A high impact bug because a lot of common traits use a `Self` substitution by default. Should be backported to beta.

There was a check for this which wasn't catching all cases, it was made more robust.

Fixes #49376
Fixes #50626

r? @petrochenkov
Diffstat (limited to 'src/test')
-rw-r--r--src/test/run-pass/impl-trait/issue-49376.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/test/run-pass/impl-trait/issue-49376.rs b/src/test/run-pass/impl-trait/issue-49376.rs
new file mode 100644
index 00000000000..b687b485fce
--- /dev/null
+++ b/src/test/run-pass/impl-trait/issue-49376.rs
@@ -0,0 +1,29 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Tests for nested self-reference which caused a stack overflow.
+
+use std::fmt::Debug;
+use std::ops::*;
+
+fn gen() -> impl PartialOrd + PartialEq + Debug { }
+
+struct Bar {}
+trait Foo<T = Self> {}
+impl Foo for Bar {}
+
+fn foo() -> impl Foo {
+    Bar {}
+}
+
+fn test_impl_ops() -> impl Add + Sub + Mul + Div { 1 }
+fn test_impl_assign_ops() -> impl AddAssign + SubAssign + MulAssign + DivAssign { 1 }
+
+fn main() {}