about summary refs log tree commit diff
path: root/src/test/ui/impl-trait
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-10-07 19:30:24 +0000
committerbors <bors@rust-lang.org>2018-10-07 19:30:24 +0000
commitb2d6ea98b0db53889c5427e5a23cddb3bcb63040 (patch)
treebd63322b8fb1b86ea70912c2d81a79d7633f4afb /src/test/ui/impl-trait
parent0ee045ea09127e5318e9cb1fff85ec34b9e3e6eb (diff)
parente24f4d57b01be3eb3b36c49385cbe89e096586bc (diff)
downloadrust-b2d6ea98b0db53889c5427e5a23cddb3bcb63040.tar.gz
rust-b2d6ea98b0db53889c5427e5a23cddb3bcb63040.zip
Auto merge of #54810 - 1aim:unused-impl-trait, r=oli-obk
Fix dead code lint for functions using impl Trait

Fixes https://github.com/rust-lang/rust/issues/54754

This is a minimal fix that doesn't add any new queries or touches unnecessary code. Please nominate for beta backport if wanted.
Diffstat (limited to 'src/test/ui/impl-trait')
-rw-r--r--src/test/ui/impl-trait/existential-minimal.rs15
-rw-r--r--src/test/ui/impl-trait/issue-42479.rs27
-rw-r--r--src/test/ui/impl-trait/issue-49376.rs31
3 files changed, 73 insertions, 0 deletions
diff --git a/src/test/ui/impl-trait/existential-minimal.rs b/src/test/ui/impl-trait/existential-minimal.rs
new file mode 100644
index 00000000000..ff9209251aa
--- /dev/null
+++ b/src/test/ui/impl-trait/existential-minimal.rs
@@ -0,0 +1,15 @@
+// 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.
+
+// compile-pass
+
+fn main() {}
+
+fn foo() -> impl std::fmt::Debug { "cake" }
diff --git a/src/test/ui/impl-trait/issue-42479.rs b/src/test/ui/impl-trait/issue-42479.rs
new file mode 100644
index 00000000000..fbf2c3f8a4e
--- /dev/null
+++ b/src/test/ui/impl-trait/issue-42479.rs
@@ -0,0 +1,27 @@
+// Copyright 2017 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.
+
+// compile-pass
+
+use std::iter::once;
+
+struct Foo {
+    x: i32,
+}
+
+impl Foo {
+    fn inside(&self) -> impl Iterator<Item = &i32> {
+        once(&self.x)
+    }
+}
+
+fn main() {
+    println!("hi");
+}
diff --git a/src/test/ui/impl-trait/issue-49376.rs b/src/test/ui/impl-trait/issue-49376.rs
new file mode 100644
index 00000000000..1dfea0b9573
--- /dev/null
+++ b/src/test/ui/impl-trait/issue-49376.rs
@@ -0,0 +1,31 @@
+// 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.
+
+// compile-pass
+
+// 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() {}