Skip to content

Commit 11580ce

Browse files
committed
Address review comments
1 parent a699f17 commit 11580ce

File tree

5 files changed

+11
-13
lines changed

5 files changed

+11
-13
lines changed

src/librustc_parse/parser/expr.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,9 @@ impl<'a> Parser<'a> {
10731073
self.maybe_recover_from_bad_qpath(expr, true)
10741074
}
10751075

1076+
/// Returns a string literal if the next token is a string literal.
1077+
/// In case of error returns `Some(lit)` if the next token is a literal with a wrong kind,
1078+
/// and returns `None` if the next token is not literal at all.
10761079
pub fn parse_str_lit(&mut self) -> Result<ast::StrLit, Option<Lit>> {
10771080
match self.parse_opt_lit() {
10781081
Some(lit) => match lit.kind {

src/libsyntax/ast.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -2448,10 +2448,7 @@ pub enum Extern {
24482448

24492449
impl Extern {
24502450
pub fn from_abi(abi: Option<StrLit>) -> Extern {
2451-
match abi {
2452-
Some(abi) => Extern::Explicit(abi),
2453-
None => Extern::Implicit,
2454-
}
2451+
abi.map_or(Extern::Implicit, Extern::Explicit)
24552452
}
24562453
}
24572454

src/libsyntax_ext/asm.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,8 @@ fn parse_asm_str<'a>(p: &mut Parser<'a>) -> PResult<'a, Symbol> {
7272
Ok(str_lit) => Ok(str_lit.symbol_unescaped),
7373
Err(opt_lit) => {
7474
let span = opt_lit.map_or(p.token.span, |lit| lit.span);
75-
let msg = "expected string literal";
76-
let mut err = p.sess.span_diagnostic.struct_span_fatal(span, msg);
77-
err.span_label(span, msg);
75+
let mut err = p.sess.span_diagnostic.struct_span_err(span, "expected string literal");
76+
err.span_label(span, "not a string literal");
7877
Err(err)
7978
}
8079
}

src/libsyntax_pos/symbol.rs

-1
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,6 @@ symbols! {
570570
rust_2018_preview,
571571
rust_begin_unwind,
572572
rustc,
573-
Rust,
574573
RustcDecodable,
575574
RustcEncodable,
576575
rustc_allocator,

src/test/ui/asm/asm-parse-errors.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ error: expected string literal
88
--> $DIR/asm-parse-errors.rs:5:18
99
|
1010
LL | asm!("nop" : struct);
11-
| ^^^^^^ expected string literal
11+
| ^^^^^^ not a string literal
1212

1313
error: expected string literal
1414
--> $DIR/asm-parse-errors.rs:6:30
1515
|
1616
LL | asm!("mov %eax, $$0x2" : struct);
17-
| ^^^^^^ expected string literal
17+
| ^^^^^^ not a string literal
1818

1919
error: expected `(`, found keyword `struct`
2020
--> $DIR/asm-parse-errors.rs:7:39
@@ -32,7 +32,7 @@ error: expected string literal
3232
--> $DIR/asm-parse-errors.rs:9:44
3333
|
3434
LL | asm!("in %dx, %al" : "={al}"(result) : struct);
35-
| ^^^^^^ expected string literal
35+
| ^^^^^^ not a string literal
3636

3737
error: expected `(`, found keyword `struct`
3838
--> $DIR/asm-parse-errors.rs:10:51
@@ -50,13 +50,13 @@ error: expected string literal
5050
--> $DIR/asm-parse-errors.rs:12:36
5151
|
5252
LL | asm!("mov $$0x200, %eax" : : : struct);
53-
| ^^^^^^ expected string literal
53+
| ^^^^^^ not a string literal
5454

5555
error: expected string literal
5656
--> $DIR/asm-parse-errors.rs:13:45
5757
|
5858
LL | asm!("mov eax, 2" : "={eax}"(foo) : : : struct);
59-
| ^^^^^^ expected string literal
59+
| ^^^^^^ not a string literal
6060

6161
error: inline assembly must be a string literal
6262
--> $DIR/asm-parse-errors.rs:14:10

0 commit comments

Comments
 (0)