diff --git a/src/test/run-pass/default-ty-param-fallback/trait_def_rules_over_impl.rs b/src/test/run-pass/default-ty-param-fallback/trait_def_rules_over_impl.rs new file mode 100644 index 0000000000000..4bcf7a1176848 --- /dev/null +++ b/src/test/run-pass/default-ty-param-fallback/trait_def_rules_over_impl.rs @@ -0,0 +1,31 @@ +// Copyright 2015 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. + +#![feature(default_type_parameter_fallback)] + +trait Bar { + // Current we consider only the default in the trait, + // never the one in the impl. + // Is this good? Is it bad? Is it just the way it works? + // If this is ok then we should forbid writing the default in the impl. + fn method(&self) -> A; +} + +struct Foo; + +impl Bar for Foo { + fn method(&self) -> A { + A::default() + } +} + +fn main() { + Foo.method(); +}