about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorMichael Woerister <michaelwoerister@posteo.net>2016-12-08 16:55:51 -0500
committerMichael Woerister <michaelwoerister@posteo.net>2016-12-08 17:06:56 -0500
commitd602d7b97e737c461fdd0ff724d092ec53707157 (patch)
treeb75979205d659c8dfc482abd0ff9394b0a6025e6 /src/test
parent209308439a1099b285520459f57e380f18793c07 (diff)
downloadrust-d602d7b97e737c461fdd0ff724d092ec53707157.tar.gz
rust-d602d7b97e737c461fdd0ff724d092ec53707157.zip
Extend middle::reachable to also consider provided trait methods.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/run-pass/auxiliary/issue_38226_aux.rs33
-rw-r--r--src/test/run-pass/issue-38226.rs24
2 files changed, 57 insertions, 0 deletions
diff --git a/src/test/run-pass/auxiliary/issue_38226_aux.rs b/src/test/run-pass/auxiliary/issue_38226_aux.rs
new file mode 100644
index 00000000000..d48a9733685
--- /dev/null
+++ b/src/test/run-pass/auxiliary/issue_38226_aux.rs
@@ -0,0 +1,33 @@
+// Copyright 2016 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.
+
+#![crate_type="rlib"]
+
+#[inline(never)]
+pub fn foo<T>() {
+    let _: Box<SomeTrait> = Box::new(SomeTraitImpl);
+}
+
+pub fn bar() {
+    SomeTraitImpl.bar();
+}
+
+mod submod {
+    pub trait SomeTrait {
+        fn bar(&self) {
+            panic!("NO")
+        }
+    }
+}
+
+use self::submod::SomeTrait;
+
+pub struct SomeTraitImpl;
+impl SomeTrait for SomeTraitImpl {}
diff --git a/src/test/run-pass/issue-38226.rs b/src/test/run-pass/issue-38226.rs
new file mode 100644
index 00000000000..33604212af9
--- /dev/null
+++ b/src/test/run-pass/issue-38226.rs
@@ -0,0 +1,24 @@
+// Copyright 2016 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.
+
+// This test makes sure that we don't run into a linker error because of the
+// middle::reachable pass missing trait methods with default impls.
+
+// aux-build:issue_38226_aux.rs
+
+// Need -Cno-prepopulate-passes to really disable inlining, otherwise the faulty
+// code gets optimized out:
+// compile-flags: -Cno-prepopulate-passes
+
+extern crate issue_38226_aux;
+
+fn main() {
+    issue_38226_aux::foo::<()>();
+}