From 37250679bc01a2e48d4a00e70dbf480c492983f1 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Mon, 22 Dec 2014 12:38:04 -0800 Subject: [PATCH] Regression test for #3902 Closes #3902. --- .../trait-static-method-generic-inference.rs | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/test/run-pass/trait-static-method-generic-inference.rs diff --git a/src/test/run-pass/trait-static-method-generic-inference.rs b/src/test/run-pass/trait-static-method-generic-inference.rs new file mode 100644 index 00000000000..4151ad6530e --- /dev/null +++ b/src/test/run-pass/trait-static-method-generic-inference.rs @@ -0,0 +1,40 @@ +// 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. + +mod base { + pub trait HasNew { + fn new() -> T; + } + + pub struct Foo { + dummy: (), + } + + impl HasNew for Foo { + fn new() -> Foo { + Foo { dummy: () } + } + } + + pub struct Bar { + dummy: (), + } + + impl HasNew for Bar { + fn new() -> Bar { + Bar { dummy: () } + } + } +} + +pub fn main() { + let _f: base::Foo = base::HasNew::new(); + let _b: base::Bar = base::HasNew::new(); +}