diff options
| author | bors <bors@rust-lang.org> | 2017-09-29 15:54:44 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-09-29 15:54:44 +0000 |
| commit | 51cd06170eccf91a2d93018e939473a8db18da92 (patch) | |
| tree | 327859d8d72c0ccee89da206fa782f9a1826bb8e /src/test/compile-fail | |
| parent | 09ee9b723a6e8bdfbbd43ab452b1a4317b38e1e1 (diff) | |
| parent | 838105f09b407aa6e5239ac1aa68e53846b5b712 (diff) | |
| download | rust-51cd06170eccf91a2d93018e939473a8db18da92.tar.gz rust-51cd06170eccf91a2d93018e939473a8db18da92.zip | |
Auto merge of #44866 - mdevlamynck:impl-trait, r=eddyb
First step toward implementing impl Trait in argument position First step implementing #44721. Add a flag to hir and ty TypeParameterDef and raise an error when using explicit type parameters when calling a function using impl Trait in argument position. I don't know if there is a procedure to add an error code so I just took an available code. Is that ok ? r? @nikomatsakis
Diffstat (limited to 'src/test/compile-fail')
| -rw-r--r-- | src/test/compile-fail/synthetic-param.rs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/test/compile-fail/synthetic-param.rs b/src/test/compile-fail/synthetic-param.rs new file mode 100644 index 00000000000..a9762e383fe --- /dev/null +++ b/src/test/compile-fail/synthetic-param.rs @@ -0,0 +1,38 @@ +// 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 <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. + +#![feature(generic_param_attrs, rustc_attrs)] + +fn func<#[rustc_synthetic] T>(_: T) {} + +struct Foo; + +impl Foo { + pub fn func<#[rustc_synthetic] T>(_: T) {} +} + +struct Bar<S> { + t: S +} + +impl<S> Bar<S> { + pub fn func<#[rustc_synthetic] T>(_: T) {} +} + +fn main() { + func::<u8>(42); //~ ERROR cannot provide explicit type parameters + func(42); // Ok + + Foo::func::<u8>(42); //~ ERROR cannot provide explicit type parameters + Foo::func(42); // Ok + + Bar::<i8>::func::<u8>(42); //~ ERROR cannot provide explicit type parameters + Bar::<i8>::func(42); // Ok +} |
