diff options
| author | leonardo.yvens <leoyvens@gmail.com> | 2018-05-12 16:43:42 -0300 |
|---|---|---|
| committer | leonardo.yvens <leoyvens@gmail.com> | 2018-05-12 16:43:42 -0300 |
| commit | 56bc4c249093f8b63fbc2dc35b4343871808d282 (patch) | |
| tree | bdbd489a4490db947de065844b508c051ed22ee3 /src/test/run-pass/impl-trait | |
| parent | e6db79f2ca07e4e533f4e940462a42f1093e52f3 (diff) | |
| download | rust-56bc4c249093f8b63fbc2dc35b4343871808d282.tar.gz rust-56bc4c249093f8b63fbc2dc35b4343871808d282.zip | |
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/run-pass/impl-trait')
| -rw-r--r-- | src/test/run-pass/impl-trait/issue-49376.rs | 29 |
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() {} |
