diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2016-10-26 20:51:49 -0700 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2016-11-08 14:17:18 -0800 |
| commit | 3edb4fc56345ba2d33a04e952e1d402b08bc676c (patch) | |
| tree | 417fc24e1e68f842d207b3738890876466cb6652 /src/test | |
| parent | b5f6d7ec2d4e231b9ef0c8a9e8e7ec8a7f67d2ae (diff) | |
| download | rust-3edb4fc56345ba2d33a04e952e1d402b08bc676c.tar.gz rust-3edb4fc56345ba2d33a04e952e1d402b08bc676c.zip | |
Point to type argument span when used as trait
Given the following code:
```rust
struct Foo<T: Clone>(T);
use std::ops::Add;
impl<T: Clone, Add> Add for Foo<T> {
type Output = usize;
fn add(self, rhs: Self) -> Self::Output {
unimplemented!();
}
}
```
present the following output:
```nocode
error[E0404]: `Add` is not a trait
--> file3.rs:5:21
|
5 | impl<T: Clone, Add> Add for Okok<T> {
| --- ^^^ expected trait, found type parameter
| |
| type parameter defined here
```
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/issue-3907.rs | 2 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-5035.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/codemap_tests/two_files.stderr | 2 | ||||
| -rw-r--r-- | src/test/ui/span/issue-35987.rs | 21 | ||||
| -rw-r--r-- | src/test/ui/span/issue-35987.stderr | 12 |
5 files changed, 36 insertions, 3 deletions
diff --git a/src/test/compile-fail/issue-3907.rs b/src/test/compile-fail/issue-3907.rs index 93556577ad3..86906ed9af2 100644 --- a/src/test/compile-fail/issue-3907.rs +++ b/src/test/compile-fail/issue-3907.rs @@ -18,7 +18,7 @@ struct S { } impl Foo for S { //~ ERROR: `Foo` is not a trait - //~| NOTE: not a trait + //~| NOTE: expected trait, found type alias //~| NOTE: type aliases cannot be used for traits fn bar() { } } diff --git a/src/test/compile-fail/issue-5035.rs b/src/test/compile-fail/issue-5035.rs index 7a36012925e..8ebcba47134 100644 --- a/src/test/compile-fail/issue-5035.rs +++ b/src/test/compile-fail/issue-5035.rs @@ -11,7 +11,7 @@ trait I {} type K = I; impl K for isize {} //~ ERROR: `K` is not a trait - //~| NOTE: not a trait + //~| NOTE: expected trait, found type alias //~| NOTE: aliases cannot be used for traits use ImportError; //~ ERROR unresolved import `ImportError` [E0432] diff --git a/src/test/ui/codemap_tests/two_files.stderr b/src/test/ui/codemap_tests/two_files.stderr index d58e7148f61..d05e6eb2bbe 100644 --- a/src/test/ui/codemap_tests/two_files.stderr +++ b/src/test/ui/codemap_tests/two_files.stderr @@ -2,7 +2,7 @@ error[E0404]: `Bar` is not a trait --> $DIR/two_files.rs:15:6 | 15 | impl Bar for Baz { } - | ^^^ not a trait + | ^^^ expected trait, found type alias | = note: type aliases cannot be used for traits diff --git a/src/test/ui/span/issue-35987.rs b/src/test/ui/span/issue-35987.rs new file mode 100644 index 00000000000..8ff5f3b8398 --- /dev/null +++ b/src/test/ui/span/issue-35987.rs @@ -0,0 +1,21 @@ +// Copyright 2016 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. + +struct Foo<T: Clone>(T); + +use std::ops::Add; + +impl<T: Clone, Add> Add for Foo<T> { + type Output = usize; + + fn add(self, rhs: Self) -> Self::Output { + unimplemented!(); + } +} diff --git a/src/test/ui/span/issue-35987.stderr b/src/test/ui/span/issue-35987.stderr new file mode 100644 index 00000000000..2370b3d6c61 --- /dev/null +++ b/src/test/ui/span/issue-35987.stderr @@ -0,0 +1,12 @@ +error[E0404]: `Add` is not a trait + --> $DIR/issue-35987.rs:15:21 + | +15 | impl<T: Clone, Add> Add for Foo<T> { + | --- ^^^ expected trait, found type parameter + | | + | type parameter defined here + +error: main function not found + +error: cannot continue compilation due to previous error + |
