Add a test case using associated types cross crate. Fixes #18048.

This commit is contained in:
Niko Matsakis 2014-12-29 15:12:11 -05:00
parent 208d32d192
commit cdd5ff842d
2 changed files with 52 additions and 0 deletions

View File

@ -0,0 +1,24 @@
// 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.
#![crate_type="lib"]
#![feature(associated_types)]
pub trait Bar {
type T;
fn get(x: Option<Self>) -> <Self as Bar>::T;
}
impl Bar for int {
type T = uint;
fn get(_: Option<int>) -> uint { 22 }
}

View File

@ -0,0 +1,28 @@
// 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.
// aux-build:issue-18048-lib.rs
// Test that we are able to reference cross-crate traits that employ
// associated types.
#![feature(associated_types)]
extern crate "issue-18048-lib" as bar;
use bar::Bar;
fn foo<B:Bar>(b: B) -> <B as Bar>::T {
Bar::get(None::<B>)
}
fn main() {
println!("{}", foo(3i));
}