about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2019-11-16 20:11:05 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2019-11-17 01:11:28 +0300
commit11580ced403211c8c422a952a2c5dabedf6812d6 (patch)
tree8d8bac55b4a4a793af8c1a94036537bb39acb31f
parenta699f17483baeff87dc027331bce9a552a6b0624 (diff)
downloadrust-11580ced403211c8c422a952a2c5dabedf6812d6.tar.gz
rust-11580ced403211c8c422a952a2c5dabedf6812d6.zip
Address review comments
-rw-r--r--src/librustc_parse/parser/expr.rs3
-rw-r--r--src/libsyntax/ast.rs5
-rw-r--r--src/libsyntax_ext/asm.rs5
-rw-r--r--src/libsyntax_pos/symbol.rs1
-rw-r--r--src/test/ui/asm/asm-parse-errors.stderr10
5 files changed, 11 insertions, 13 deletions
diff --git a/src/librustc_parse/parser/expr.rs b/src/librustc_parse/parser/expr.rs
index be1dc4f19a7..a56a7bf1802 100644
--- a/src/librustc_parse/parser/expr.rs
+++ b/src/librustc_parse/parser/expr.rs
@@ -1073,6 +1073,9 @@ impl<'a> Parser<'a> {
         self.maybe_recover_from_bad_qpath(expr, true)
     }
 
+    /// Returns a string literal if the next token is a string literal.
+    /// In case of error returns `Some(lit)` if the next token is a literal with a wrong kind,
+    /// and returns `None` if the next token is not literal at all.
     pub fn parse_str_lit(&mut self) -> Result<ast::StrLit, Option<Lit>> {
         match self.parse_opt_lit() {
             Some(lit) => match lit.kind {
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index dee493a708e..bbf00825acb 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -2448,10 +2448,7 @@ pub enum Extern {
 
 impl Extern {
     pub fn from_abi(abi: Option<StrLit>) -> Extern {
-        match abi {
-            Some(abi) => Extern::Explicit(abi),
-            None => Extern::Implicit,
-        }
+        abi.map_or(Extern::Implicit, Extern::Explicit)
     }
 }
 
diff --git a/src/libsyntax_ext/asm.rs b/src/libsyntax_ext/asm.rs
index 9b37143557e..bd345a9a7da 100644
--- a/src/libsyntax_ext/asm.rs
+++ b/src/libsyntax_ext/asm.rs
@@ -72,9 +72,8 @@ fn parse_asm_str<'a>(p: &mut Parser<'a>) -> PResult<'a, Symbol> {
         Ok(str_lit) => Ok(str_lit.symbol_unescaped),
         Err(opt_lit) => {
             let span = opt_lit.map_or(p.token.span, |lit| lit.span);
-            let msg = "expected string literal";
-            let mut err = p.sess.span_diagnostic.struct_span_fatal(span, msg);
-            err.span_label(span, msg);
+            let mut err = p.sess.span_diagnostic.struct_span_err(span, "expected string literal");
+            err.span_label(span, "not a string literal");
             Err(err)
         }
     }
diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs
index b3e9576f43f..86eaeeab5a4 100644
--- a/src/libsyntax_pos/symbol.rs
+++ b/src/libsyntax_pos/symbol.rs
@@ -570,7 +570,6 @@ symbols! {
         rust_2018_preview,
         rust_begin_unwind,
         rustc,
-        Rust,
         RustcDecodable,
         RustcEncodable,
         rustc_allocator,
diff --git a/src/test/ui/asm/asm-parse-errors.stderr b/src/test/ui/asm/asm-parse-errors.stderr
index 9fe59d12e12..2b29332fef5 100644
--- a/src/test/ui/asm/asm-parse-errors.stderr
+++ b/src/test/ui/asm/asm-parse-errors.stderr
@@ -8,13 +8,13 @@ error: expected string literal
   --> $DIR/asm-parse-errors.rs:5:18
    |
 LL |     asm!("nop" : struct);
-   |                  ^^^^^^ expected string literal
+   |                  ^^^^^^ not a string literal
 
 error: expected string literal
   --> $DIR/asm-parse-errors.rs:6:30
    |
 LL |     asm!("mov %eax, $$0x2" : struct);
-   |                              ^^^^^^ expected string literal
+   |                              ^^^^^^ not a string literal
 
 error: expected `(`, found keyword `struct`
   --> $DIR/asm-parse-errors.rs:7:39
@@ -32,7 +32,7 @@ error: expected string literal
   --> $DIR/asm-parse-errors.rs:9:44
    |
 LL |     asm!("in %dx, %al" : "={al}"(result) : struct);
-   |                                            ^^^^^^ expected string literal
+   |                                            ^^^^^^ not a string literal
 
 error: expected `(`, found keyword `struct`
   --> $DIR/asm-parse-errors.rs:10:51
@@ -50,13 +50,13 @@ error: expected string literal
   --> $DIR/asm-parse-errors.rs:12:36
    |
 LL |     asm!("mov $$0x200, %eax" : : : struct);
-   |                                    ^^^^^^ expected string literal
+   |                                    ^^^^^^ not a string literal
 
 error: expected string literal
   --> $DIR/asm-parse-errors.rs:13:45
    |
 LL |     asm!("mov eax, 2" : "={eax}"(foo) : : : struct);
-   |                                             ^^^^^^ expected string literal
+   |                                             ^^^^^^ not a string literal
 
 error: inline assembly must be a string literal
   --> $DIR/asm-parse-errors.rs:14:10