about summary refs log tree commit diff
path: root/src/libsyntax_pos
diff options
context:
space:
mode:
authorAriel Ben-Yehuda <arielb1@mail.tau.ac.il>2017-04-05 23:01:06 +0000
committerGitHub <noreply@github.com>2017-04-05 23:01:06 +0000
commitcee05080219bde70125882ef32c0a882544b9f50 (patch)
treef918f3255ceb45636d37a3d4ebb850773449aa78 /src/libsyntax_pos
parenta18202792ad4f64ba8762544899cac827ac1d5cd (diff)
parent8f31e191c6caa1986276f2dda207135a255ee1f6 (diff)
downloadrust-cee05080219bde70125882ef32c0a882544b9f50.tar.gz
rust-cee05080219bde70125882ef32c0a882544b9f50.zip
Rollup merge of #40815 - estebank:issue-40006, r=GuillaumeGomez
Identify missing item category in `impl`s

```rust
struct S;
impl S {
    pub hello_method(&self) {
        println!("Hello");
    }
}
fn main() { S.hello_method(); }
```

```rust
error: missing `fn` for method declaration
 --> file.rs:3:4
  |
3 |     pub hello_method(&self) {
  |        ^ missing `fn`
```

Fix #40006. r? @pnkfelix CC @jonathandturner @GuillaumeGomez
Diffstat (limited to 'src/libsyntax_pos')
-rw-r--r--src/libsyntax_pos/lib.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs
index 3f09b2009a7..9b88b9f7696 100644
--- a/src/libsyntax_pos/lib.rs
+++ b/src/libsyntax_pos/lib.rs
@@ -189,6 +189,30 @@ impl Span {
             Span { hi: end.hi, ..self }
         }
     }
+
+    pub fn between(self, end: Span) -> Span {
+        Span {
+            lo: self.hi,
+            hi: end.lo,
+            ctxt: if end.ctxt == SyntaxContext::empty() {
+                end.ctxt
+            } else {
+                self.ctxt
+            }
+        }
+    }
+
+    pub fn until(self, end: Span) -> Span {
+        Span {
+            lo: self.lo,
+            hi: end.lo,
+            ctxt: if end.ctxt == SyntaxContext::empty() {
+                end.ctxt
+            } else {
+                self.ctxt
+            }
+        }
+    }
 }
 
 #[derive(Clone, Debug)]