Fix a bug with cross-crate trait impls

Closes #19056
This commit is contained in:
Nick Cameron 2015-01-01 12:29:48 +13:00
parent 10d99a9734
commit d06b7057cf
6 changed files with 50 additions and 18 deletions

View file

@ -0,0 +1,17 @@
// Copyright 2014 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.
// Test inherant trait impls work cross-crait.
pub trait Bar<'a> for ?Sized : 'a {}
impl<'a> Bar<'a> {
pub fn bar(&self) {}
}

View file

@ -10,6 +10,10 @@
// Test calling methods on an impl for a bare trait.
// aux-build:traitimpl.rs
extern crate traitimpl;
use traitimpl::Bar;
static mut COUNT: uint = 1;
trait T {}
@ -25,6 +29,9 @@ impl<'a> T+'a {
impl T for int {}
struct Foo;
impl<'a> Bar<'a> for Foo {}
fn main() {
let x: &T = &42i;
@ -33,4 +40,8 @@ fn main() {
T::bar();
unsafe { assert!(COUNT == 12); }
// Cross-crait case
let x: &Bar = &Foo;
x.bar();
}