From cdd5ff842db9eec168736998b2a5b72ba415e5bb Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 29 Dec 2014 15:12:11 -0500 Subject: [PATCH] Add a test case using associated types cross crate. Fixes #18048. --- src/test/auxiliary/issue-18048-lib.rs | 24 +++++++++++++++++++++++ src/test/run-pass/issue-18048.rs | 28 +++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 src/test/auxiliary/issue-18048-lib.rs create mode 100644 src/test/run-pass/issue-18048.rs 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 or the MIT license +// , 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) -> ::T; +} + +impl Bar for int { + type T = uint; + + fn get(_: Option) -> 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 or the MIT license +// , 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: B) -> ::T { + Bar::get(None::) +} + +fn main() { + println!("{}", foo(3i)); +}