From 3edb4fc56345ba2d33a04e952e1d402b08bc676c Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Wed, 26 Oct 2016 20:51:49 -0700 Subject: Point to type argument span when used as trait Given the following code: ```rust struct Foo(T); use std::ops::Add; impl Add for Foo { 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 Add for Okok { | --- ^^^ expected trait, found type parameter | | | type parameter defined here ``` --- src/libsyntax/ast.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/libsyntax') diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 30fc4c3dd80..cc39e81fdae 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -399,6 +399,14 @@ impl Generics { pub fn is_parameterized(&self) -> bool { self.is_lt_parameterized() || self.is_type_parameterized() } + pub fn span_for_name(&self, name: &str) -> Option { + for t in &self.ty_params { + if t.ident.name.as_str() == name { + return Some(t.span); + } + } + None + } } impl Default for Generics { -- cgit 1.4.1-3-g733a5