diff options
| author | Gaëtan Cassiers <gaetan.cassiers@gmail.com> | 2015-07-02 01:20:07 +0200 |
|---|---|---|
| committer | Gaëtan Cassiers <gaetan.cassiers@gmail.com> | 2015-07-03 10:30:42 +0200 |
| commit | fc4483748c83e972a76dd3f2c215e2d8a480cb98 (patch) | |
| tree | 6e67ad1688ce8941f69a2ef93596b93fcd7cff09 /src/utils.rs | |
| parent | 54d2620ead1dd8ace78f5877e58971b96cd14767 (diff) | |
Fix fn decl rewriting in case of generics
An opening paren in generics caused a false-positive detection of args beginning. The result was the creation of comments with some code into it.
Diffstat (limited to 'src/utils.rs')
| -rw-r--r-- | src/utils.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/utils.rs b/src/utils.rs index de17f989f7a..47203a0754f 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use syntax::ast::{Visibility, Attribute, MetaItem, MetaItem_}; +use syntax::ast::{self, Visibility, Attribute, MetaItem, MetaItem_}; use syntax::codemap::{CodeMap, Span, BytePos}; use comment::FindUncommented; @@ -72,6 +72,14 @@ pub fn contains_skip(attrs: &[Attribute]) -> bool { attrs.iter().any(|a| is_skip(&a.node.value)) } +// Find the end of a TyParam +pub fn end_typaram(typaram: &ast::TyParam) -> BytePos { + typaram.bounds.last().map(|bound| match *bound { + ast::RegionTyParamBound(ref lt) => lt.span, + ast::TraitTyParamBound(ref prt, _) => prt.span, + }).unwrap_or(typaram.span).hi +} + #[inline] #[cfg(target_pointer_width="64")] // Based on the trick layed out at |
