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
This commit is contained in:
commit
368e092c26
4 changed files with 86 additions and 7 deletions
33
src/test/run-pass/auxiliary/issue_38226_aux.rs
Normal file
33
src/test/run-pass/auxiliary/issue_38226_aux.rs
Normal file
|
|
@ -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 {}
|
||||
24
src/test/run-pass/issue-38226.rs
Normal file
24
src/test/run-pass/issue-38226.rs
Normal file
|
|
@ -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::<()>();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue