Auto merge of #122822 - matthiaskrgr:rollup-rjgmnbe, r=matthiaskrgr

Rollup of 8 pull requests

Successful merges:

 - #122222 (deref patterns: bare-bones feature gate and typechecking)
 - #122358 (Don't ICE when encountering bound regions in generator interior type)
 - #122696 (Add bare metal riscv32 target.)
 - #122773 (make "expected paren or brace" error translatable)
 - #122795 (Inherit `RUSTC_BOOTSTRAP` when testing wasm)
 - #122799 (Replace closures with `_` when suggesting fully qualified path for method call)
 - #122801 (Fix misc printing issues in emit=stable_mir)
 - #122806 (Make `type_ascribe!` not a built-in)

Failed merges:

 - #122771 (add some comments to hir::ModuleItems)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2024-03-21 13:28:59 +00:00
commit 2627e9f301
60 changed files with 752 additions and 720 deletions

View file

@ -1939,11 +1939,11 @@ impl<'a> Parser<'a> {
/// Parse `builtin # ident(args,*)`.
fn parse_expr_builtin(&mut self) -> PResult<'a, P<Expr>> {
self.parse_builtin(|this, lo, ident| {
if ident.name == sym::offset_of {
return Ok(Some(this.parse_expr_offset_of(lo)?));
}
Ok(None)
Ok(match ident.name {
sym::offset_of => Some(this.parse_expr_offset_of(lo)?),
sym::type_ascribe => Some(this.parse_expr_type_ascribe(lo)?),
_ => None,
})
})
}
@ -1978,6 +1978,7 @@ impl<'a> Parser<'a> {
ret
}
/// Built-in macro for `offset_of!` expressions.
pub(crate) fn parse_expr_offset_of(&mut self, lo: Span) -> PResult<'a, P<Expr>> {
let container = self.parse_ty()?;
self.expect(&TokenKind::Comma)?;
@ -2007,6 +2008,15 @@ impl<'a> Parser<'a> {
Ok(self.mk_expr(span, ExprKind::OffsetOf(container, fields)))
}
/// Built-in macro for type ascription expressions.
pub(crate) fn parse_expr_type_ascribe(&mut self, lo: Span) -> PResult<'a, P<Expr>> {
let expr = self.parse_expr()?;
self.expect(&token::Comma)?;
let ty = self.parse_ty()?;
let span = lo.to(self.token.span);
Ok(self.mk_expr(span, ExprKind::Type(expr, ty)))
}
/// 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.