diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2014-12-29 15:12:11 -0500 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2014-12-30 09:36:23 -0500 |
| commit | cdd5ff842db9eec168736998b2a5b72ba415e5bb (patch) | |
| tree | 0a34331561a0cd8e979a9c80d44598a264291ef8 | |
| parent | 208d32d19253603833ec6f5184a71e8730a35285 (diff) | |
| download | rust-cdd5ff842db9eec168736998b2a5b72ba415e5bb.tar.gz rust-cdd5ff842db9eec168736998b2a5b72ba415e5bb.zip | |
Add a test case using associated types cross crate. Fixes #18048.
| -rw-r--r-- | src/test/auxiliary/issue-18048-lib.rs | 24 | ||||
| -rw-r--r-- | src/test/run-pass/issue-18048.rs | 28 |
2 files changed, 52 insertions, 0 deletions
diff --git a/src/test/auxiliary/issue-18048-lib.rs b/src/test/auxiliary/issue-18048-lib.rs new file mode 100644 index 00000000000..52cc216657b --- /dev/null +++ b/src/test/auxiliary/issue-18048-lib.rs @@ -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 } +} diff --git a/src/test/run-pass/issue-18048.rs b/src/test/run-pass/issue-18048.rs new file mode 100644 index 00000000000..7cd6e5eb0d5 --- /dev/null +++ b/src/test/run-pass/issue-18048.rs @@ -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)); +} |
