Add a test case using associated types cross crate. Fixes #18048.
This commit is contained in:
parent
208d32d192
commit
cdd5ff842d
24
src/test/auxiliary/issue-18048-lib.rs
Normal file
24
src/test/auxiliary/issue-18048-lib.rs
Normal 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 }
|
||||
}
|
28
src/test/run-pass/issue-18048.rs
Normal file
28
src/test/run-pass/issue-18048.rs
Normal 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));
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user