about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2019-01-11 22:04:54 -0800
committerEsteban Küber <esteban@kuber.com.ar>2019-01-11 22:04:54 -0800
commit7feb802d8982fe69d7d6acef532a87ada8aae9fb (patch)
tree25ea60e0d80f142982a38a051e8286b4eda7fb15 /src
parentde3c4be099993517dba7bb764628ff28e86f9320 (diff)
downloadrust-7feb802d8982fe69d7d6acef532a87ada8aae9fb.tar.gz
rust-7feb802d8982fe69d7d6acef532a87ada8aae9fb.zip
Small tweaks to parser errors
Diffstat (limited to 'src')
-rw-r--r--src/libsyntax/parse/parser.rs27
-rw-r--r--src/test/ui/parser/bad-lit-suffixes.stderr16
-rw-r--r--src/test/ui/parser/bad-pointer-type.rs2
-rw-r--r--src/test/ui/parser/bad-pointer-type.stderr6
-rw-r--r--src/test/ui/parser/no-unsafe-self.stderr12
5 files changed, 39 insertions, 24 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index a5ef4038885..ee93696c602 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -1012,7 +1012,10 @@ impl<'a> Parser<'a> {
                 if text.is_empty() {
                     self.span_bug(sp, "found empty literal suffix in Some")
                 }
-                self.span_err(sp, &format!("{} with a suffix is invalid", kind));
+                let msg = format!("{} with a suffix is invalid", kind);
+                self.struct_span_err(sp, &msg)
+                    .span_label(sp, msg)
+                    .emit();
             }
         }
     }
@@ -1768,9 +1771,11 @@ impl<'a> Parser<'a> {
             Mutability::Immutable
         } else {
             let span = self.prev_span;
-            self.span_err(span,
-                          "expected mut or const in raw pointer type (use \
-                           `*mut T` or `*const T` as appropriate)");
+            let msg = "expected mut or const in raw pointer type";
+            self.struct_span_err(span, msg)
+                .span_label(span, msg)
+                .help("use `*mut T` or `*const T` as appropriate")
+                .emit();
             Mutability::Immutable
         };
         let t = self.parse_ty_no_plus()?;
@@ -5612,15 +5617,20 @@ impl<'a> Parser<'a> {
                 // *mut self
                 // *not_self
                 // Emit special error for `self` cases.
+                let msg = "cannot pass `self` by raw pointer";
                 (if isolated_self(self, 1) {
                     self.bump();
-                    self.span_err(self.span, "cannot pass `self` by raw pointer");
+                    self.struct_span_err(self.span, msg)
+                        .span_label(self.span, msg)
+                        .emit();
                     SelfKind::Value(Mutability::Immutable)
                 } else if self.look_ahead(1, |t| t.is_mutability()) &&
                           isolated_self(self, 2) {
                     self.bump();
                     self.bump();
-                    self.span_err(self.span, "cannot pass `self` by raw pointer");
+                    self.struct_span_err(self.span, msg)
+                        .span_label(self.span, msg)
+                        .emit();
                     SelfKind::Value(Mutability::Immutable)
                 } else {
                     return Ok(None);
@@ -5957,7 +5967,10 @@ impl<'a> Parser<'a> {
             tps.where_clause = self.parse_where_clause()?;
             self.expect(&token::Semi)?;
             if unsafety != Unsafety::Normal {
-                self.span_err(self.prev_span, "trait aliases cannot be unsafe");
+                let msg = "trait aliases cannot be unsafe";
+                self.struct_span_err(self.prev_span, msg)
+                    .span_label(self.prev_span, msg)
+                    .emit();
             }
             Ok((ident, ItemKind::TraitAlias(tps, bounds), None))
         } else {
diff --git a/src/test/ui/parser/bad-lit-suffixes.stderr b/src/test/ui/parser/bad-lit-suffixes.stderr
index 4fd2ab8177b..0dc291ebda0 100644
--- a/src/test/ui/parser/bad-lit-suffixes.stderr
+++ b/src/test/ui/parser/bad-lit-suffixes.stderr
@@ -2,49 +2,49 @@ error: ABI spec with a suffix is invalid
   --> $DIR/bad-lit-suffixes.rs:5:5
    |
 LL |     "C"suffix //~ ERROR ABI spec with a suffix is invalid
-   |     ^^^^^^^^^
+   |     ^^^^^^^^^ ABI spec with a suffix is invalid
 
 error: ABI spec with a suffix is invalid
   --> $DIR/bad-lit-suffixes.rs:9:5
    |
 LL |     "C"suffix //~ ERROR ABI spec with a suffix is invalid
-   |     ^^^^^^^^^
+   |     ^^^^^^^^^ ABI spec with a suffix is invalid
 
 error: string literal with a suffix is invalid
   --> $DIR/bad-lit-suffixes.rs:13:5
    |
 LL |     ""suffix; //~ ERROR string literal with a suffix is invalid
-   |     ^^^^^^^^
+   |     ^^^^^^^^ string literal with a suffix is invalid
 
 error: byte string literal with a suffix is invalid
   --> $DIR/bad-lit-suffixes.rs:14:5
    |
 LL |     b""suffix; //~ ERROR byte string literal with a suffix is invalid
-   |     ^^^^^^^^^
+   |     ^^^^^^^^^ byte string literal with a suffix is invalid
 
 error: string literal with a suffix is invalid
   --> $DIR/bad-lit-suffixes.rs:15:5
    |
 LL |     r#""#suffix; //~ ERROR string literal with a suffix is invalid
-   |     ^^^^^^^^^^^
+   |     ^^^^^^^^^^^ string literal with a suffix is invalid
 
 error: byte string literal with a suffix is invalid
   --> $DIR/bad-lit-suffixes.rs:16:5
    |
 LL |     br#""#suffix; //~ ERROR byte string literal with a suffix is invalid
-   |     ^^^^^^^^^^^^
+   |     ^^^^^^^^^^^^ byte string literal with a suffix is invalid
 
 error: char literal with a suffix is invalid
   --> $DIR/bad-lit-suffixes.rs:17:5
    |
 LL |     'a'suffix; //~ ERROR char literal with a suffix is invalid
-   |     ^^^^^^^^^
+   |     ^^^^^^^^^ char literal with a suffix is invalid
 
 error: byte literal with a suffix is invalid
   --> $DIR/bad-lit-suffixes.rs:18:5
    |
 LL |     b'a'suffix; //~ ERROR byte literal with a suffix is invalid
-   |     ^^^^^^^^^^
+   |     ^^^^^^^^^^ byte literal with a suffix is invalid
 
 error: invalid width `1024` for integer literal
   --> $DIR/bad-lit-suffixes.rs:20:5
diff --git a/src/test/ui/parser/bad-pointer-type.rs b/src/test/ui/parser/bad-pointer-type.rs
index 0e5a01103dc..59e5e0c5d31 100644
--- a/src/test/ui/parser/bad-pointer-type.rs
+++ b/src/test/ui/parser/bad-pointer-type.rs
@@ -1,5 +1,5 @@
 fn foo(_: *()) {
-    //~^ expected mut or const in raw pointer type (use `*mut T` or `*const T` as appropriate)
+    //~^ ERROR expected mut or const in raw pointer type
 }
 
 fn main() {}
diff --git a/src/test/ui/parser/bad-pointer-type.stderr b/src/test/ui/parser/bad-pointer-type.stderr
index 860f9f96bb8..e18c220affe 100644
--- a/src/test/ui/parser/bad-pointer-type.stderr
+++ b/src/test/ui/parser/bad-pointer-type.stderr
@@ -1,8 +1,10 @@
-error: expected mut or const in raw pointer type (use `*mut T` or `*const T` as appropriate)
+error: expected mut or const in raw pointer type
   --> $DIR/bad-pointer-type.rs:1:11
    |
 LL | fn foo(_: *()) {
-   |           ^
+   |           ^ expected mut or const in raw pointer type
+   |
+   = help: use `*mut T` or `*const T` as appropriate
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/parser/no-unsafe-self.stderr b/src/test/ui/parser/no-unsafe-self.stderr
index 364c22a9622..84779b09dc7 100644
--- a/src/test/ui/parser/no-unsafe-self.stderr
+++ b/src/test/ui/parser/no-unsafe-self.stderr
@@ -2,37 +2,37 @@ error: cannot pass `self` by raw pointer
   --> $DIR/no-unsafe-self.rs:4:17
    |
 LL |     fn foo(*mut self); //~ ERROR cannot pass `self` by raw pointer
-   |                 ^^^^
+   |                 ^^^^ cannot pass `self` by raw pointer
 
 error: cannot pass `self` by raw pointer
   --> $DIR/no-unsafe-self.rs:5:19
    |
 LL |     fn baz(*const self); //~ ERROR cannot pass `self` by raw pointer
-   |                   ^^^^
+   |                   ^^^^ cannot pass `self` by raw pointer
 
 error: cannot pass `self` by raw pointer
   --> $DIR/no-unsafe-self.rs:6:13
    |
 LL |     fn bar(*self); //~ ERROR cannot pass `self` by raw pointer
-   |             ^^^^
+   |             ^^^^ cannot pass `self` by raw pointer
 
 error: cannot pass `self` by raw pointer
   --> $DIR/no-unsafe-self.rs:11:17
    |
 LL |     fn foo(*mut self) { } //~ ERROR cannot pass `self` by raw pointer
-   |                 ^^^^
+   |                 ^^^^ cannot pass `self` by raw pointer
 
 error: cannot pass `self` by raw pointer
   --> $DIR/no-unsafe-self.rs:12:19
    |
 LL |     fn baz(*const self) { } //~ ERROR cannot pass `self` by raw pointer
-   |                   ^^^^
+   |                   ^^^^ cannot pass `self` by raw pointer
 
 error: cannot pass `self` by raw pointer
   --> $DIR/no-unsafe-self.rs:13:13
    |
 LL |     fn bar(*self) { } //~ ERROR cannot pass `self` by raw pointer
-   |             ^^^^
+   |             ^^^^ cannot pass `self` by raw pointer
 
 error: aborting due to 6 previous errors