diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2020-01-21 23:01:21 -0800 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2020-01-26 10:57:18 -0800 |
| commit | 697fdc568e28fbb376567eda4edb2c2a05db68de (patch) | |
| tree | 2353388fac15725d1de0ef61d3c729dda69ba9ff /src/libsyntax | |
| parent | 8ad83afe5bcfa983a24b6f720c9ef389350f414b (diff) | |
| download | rust-697fdc568e28fbb376567eda4edb2c2a05db68de.tar.gz rust-697fdc568e28fbb376567eda4edb2c2a05db68de.zip | |
Suggest defining type parameter when appropriate
```
error[E0412]: cannot find type `T` in this scope
--> file.rs:3:12
|
3 | impl Trait<T> for Struct {}
| - ^ not found in this scope
| |
| help: you might be missing a type parameter: `<T>`
```
Fix #64298.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 5f38ac4cc0f..5c64cc440ce 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -2655,6 +2655,20 @@ impl ItemKind { ItemKind::Mac(..) | ItemKind::MacroDef(..) | ItemKind::Impl { .. } => "item", } } + + pub fn generics(&self) -> Option<&Generics> { + match self { + Self::Fn(_, generics, _) + | Self::TyAlias(_, generics) + | Self::Enum(_, generics) + | Self::Struct(_, generics) + | Self::Union(_, generics) + | Self::Trait(_, _, generics, ..) + | Self::TraitAlias(generics, _) + | Self::Impl { generics, .. } => Some(generics), + _ => None, + } + } } pub type ForeignItem = Item<ForeignItemKind>; |
