about summary refs log tree commit diff
path: root/src/librustc_hir
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2020-05-29 09:44:41 -0700
committerEsteban Küber <esteban@kuber.com.ar>2020-05-29 10:11:59 -0700
commit0d18136b776cd7cda2c4932f447e6484377f42b2 (patch)
treed62304ae99b750b4ebcc952a1eb1b223a420b9ad /src/librustc_hir
parent04243710a0077ad140b8259c21bc1aac02057a48 (diff)
downloadrust-0d18136b776cd7cda2c4932f447e6484377f42b2.tar.gz
rust-0d18136b776cd7cda2c4932f447e6484377f42b2.zip
Move common code to `WhereClause`
Diffstat (limited to 'src/librustc_hir')
-rw-r--r--src/librustc_hir/hir.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/librustc_hir/hir.rs b/src/librustc_hir/hir.rs
index ef398ab25d3..a46871ac807 100644
--- a/src/librustc_hir/hir.rs
+++ b/src/librustc_hir/hir.rs
@@ -525,6 +525,13 @@ impl WhereClause<'_> {
     pub fn span_for_predicates_or_empty_place(&self) -> Span {
         self.span
     }
+
+    /// `Span` where further predicates would be suggested, accounting for trailing commas, like
+    ///  in `fn foo<T>(t: T) where T: Foo,` so we don't suggest two trailing commas.
+    pub fn tail_span_for_suggestion(&self) -> Span {
+        let end = self.span_for_predicates_or_empty_place().shrink_to_hi();
+        self.predicates.last().map(|p| p.span()).unwrap_or(end).shrink_to_hi().to(end)
+    }
 }
 
 /// A single predicate in a where-clause.