Uh oh!
There was an error while loading. Please reload this page.
Point to type argument span when used as trait - #37428
Conversation
rust-highfive
commented
Oct 27, 2016
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @pnkfelix (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
There was a problem hiding this comment.
I'm not convinced that this is the best way of getting the type argument's span. Does anyone have a pointer as to an alternative?
There was a problem hiding this comment.
I remember doing such a thing but can't find the PR. From my point of view, this is correct. However I can totally overpass a better solution.
Anything in mind @eddyb?
There was a problem hiding this comment.
Seems okay. If there are duplicate type parameter names, you'll get a different error for that.
870fe6a to
169d580Compareestebank
commented
Nov 7, 2016
169d580 to
c56cc5fCompareThere was a problem hiding this comment.
This is redundant. You can do &t.ident.name.as_str() == name instead.
There was a problem hiding this comment.
You can return Some(t.span); instead of breaking, and get rid of the local variable span.
There was a problem hiding this comment.
Yeah, returning is probably slightly cleaner/easier to read.
sophiajt
commented
Nov 8, 2016
A nit or two to fix, but otherwise seems okay to me. |
c56cc5f to
0037756CompareGiven 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
```0037756 to
3edb4fcCompareestebank
commented
Nov 9, 2016
@jonathandturner fixed. |
sanxiyn
commented
Nov 9, 2016
@bors r+ |
bors
commented
Nov 9, 2016
📌 Commit 3edb4fc has been approved by |
…=sanxiyn
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
```
Fixesrust-lang#35987.
Given the following code:
present the following output:
Fixes#35987.