diff options
| author | bors <bors@rust-lang.org> | 2016-12-11 06:37:19 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2016-12-11 06:37:19 +0000 |
| commit | 368e092c26d40da2d4442bf7cf1b6e4df13a6f87 (patch) | |
| tree | 95d7ee7e177aad13fd902ce731fd3cbb421b3d1b /src/test | |
| parent | ea798527e42379af207b3da9e9aef41fd7e812c8 (diff) | |
| parent | 5d35dfb01edd8f53862ac30e1eaec2cea40bace9 (diff) | |
| download | rust-368e092c26d40da2d4442bf7cf1b6e4df13a6f87.tar.gz rust-368e092c26d40da2d4442bf7cf1b6e4df13a6f87.zip | |
Auto merge of #38250 - michaelwoerister:trait-methods-in-reachable, r=alexcrichton
Consider provided trait methods in middle::reachable Fixes https://github.com/rust-lang/rust/issues/38226 by also considering trait methods with default implementation instead of just methods provided in an impl. r? @alexcrichton cc @panicbit
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/run-pass/auxiliary/issue_38226_aux.rs | 33 | ||||
| -rw-r--r-- | src/test/run-pass/issue-38226.rs | 24 |
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::<()>(); +} |
