diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-18 02:49:50 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-18 02:49:50 +0000 |
commit | 9835e2ae736235810b4ea1c162ca5e65c547e770 (patch) | |
tree | 3fcebf40ed70e581d776a8a4c65923e8ec20e026 /compiler/rustc_ast_pretty/src/pprust | |
parent | Releasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff) | |
download | rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip |
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_ast_pretty/src/pprust')
-rw-r--r-- | compiler/rustc_ast_pretty/src/pprust/state.rs | 11 | ||||
-rw-r--r-- | compiler/rustc_ast_pretty/src/pprust/state/expr.rs | 33 |
2 files changed, 40 insertions, 4 deletions
diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs index 849336c86..3f80728a2 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state.rs @@ -210,6 +210,10 @@ pub fn literal_to_string(lit: token::Lit) -> String { token::ByteStrRaw(n) => { format!("br{delim}\"{string}\"{delim}", delim = "#".repeat(n as usize), string = symbol) } + token::CStr => format!("c\"{symbol}\""), + token::CStrRaw(n) => { + format!("cr{delim}\"{symbol}\"{delim}", delim = "#".repeat(n as usize)) + } token::Integer | token::Float | token::Bool | token::Err => symbol.to_string(), }; @@ -1570,12 +1574,19 @@ impl<'a> State<'a> { GenericBound::Trait(tref, modifier) => { match modifier { TraitBoundModifier::None => {} + TraitBoundModifier::Negative => { + self.word("!"); + } TraitBoundModifier::Maybe => { self.word("?"); } TraitBoundModifier::MaybeConst => { self.word_space("~const"); } + TraitBoundModifier::MaybeConstNegative => { + self.word_space("~const"); + self.word("!"); + } TraitBoundModifier::MaybeConstMaybe => { self.word_space("~const"); self.word("?"); diff --git a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs index 776bf5424..87c32ffce 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs @@ -341,10 +341,16 @@ impl<'a> State<'a> { self.print_type(ty); } ast::ExprKind::Type(expr, ty) => { - let prec = AssocOp::Colon.precedence() as i8; - self.print_expr_maybe_paren(expr, prec); - self.word_space(":"); + self.word("type_ascribe!("); + self.ibox(0); + self.print_expr(expr); + + self.word(","); + self.space_if_not_bol(); self.print_type(ty); + + self.end(); + self.word(")"); } ast::ExprKind::Let(pat, scrutinee, _) => { self.print_let(pat, scrutinee); @@ -447,7 +453,7 @@ impl<'a> State<'a> { self.ibox(0); self.print_block_with_attrs(blk, attrs); } - ast::ExprKind::Await(expr) => { + ast::ExprKind::Await(expr, _) => { self.print_expr_maybe_paren(expr, parser::PREC_POSTFIX); self.word(".await"); } @@ -549,6 +555,25 @@ impl<'a> State<'a> { self.end(); self.pclose(); } + ast::ExprKind::OffsetOf(container, fields) => { + self.word("builtin # offset_of"); + self.popen(); + self.rbox(0, Inconsistent); + self.print_type(container); + self.word(","); + self.space(); + + if let Some((&first, rest)) = fields.split_first() { + self.print_ident(first); + + for &field in rest { + self.word("."); + self.print_ident(field); + } + } + self.pclose(); + self.end(); + } ast::ExprKind::MacCall(m) => self.print_mac(m), ast::ExprKind::Paren(e) => { self.popen(); |