Skip to content

Commit

Permalink
Fix mir parser to allow consecutive symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
chorman0773 committed Jan 8, 2024
1 parent e8a2d3f commit a98e5de
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
15 changes: 7 additions & 8 deletions rust/rust_mir_macro/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,18 @@ pub fn do_punct<I: Iterator<Item = TokenTree>>(
while let Some(TokenTree::Punct(c)) = tree.peek_next() {
tok.push(c.as_char());
let _ = span.get_or_insert(c.span());
if tok == punct {
return Ok(span.unwrap());
}
if c.spacing() != Spacing::Joint {
break;
}
}

if tok != punct {
return Err(Error {
text: format!("Expected {}, got `{}`", punct, tok),
span: span.unwrap_or_else(Span::call_site),
});
}

return Ok(span.unwrap());
return Err(Error {
text: format!("Expected {}, got `{}`", punct, tok),
span: span.unwrap_or_else(Span::call_site),
});
})
}

Expand Down
4 changes: 2 additions & 2 deletions rust/src/sema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3741,13 +3741,13 @@ pub fn convert_crate(
let body = if retty == Type::Never {
mir::mir! {
@0: { []
tailcall # <main> : <fnty>()
tailcall #<main>: <fnty>()
}
}
} else {
mir::mir! {
@0: { []
call _0 = # <main> : <fnty>() next @1 []
call _0 = #<main>: <fnty>() next @1 []
}
@1: { [_0]
store dead _0;
Expand Down
6 changes: 2 additions & 4 deletions test/rust/exit_42.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ extern "C" {
fn exit(status: i32) -> !;
}

fn main() {
unsafe {
exit(42);
}
fn main() -> ! {
unsafe { exit(42) }
}
4 changes: 2 additions & 2 deletions test/rust/intrin_abort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ extern "rust-intrinsic" {
pub fn __builtin_abort() -> !;
}

fn main() {
__builtin_abort();
fn main() -> ! {
__builtin_abort()
}

0 comments on commit a98e5de

Please sign in to comment.