summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_ast_pretty
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_ast_pretty')
-rw-r--r--compiler/rustc_ast_pretty/src/pp.rs2
-rw-r--r--compiler/rustc_ast_pretty/src/pprust/state.rs11
-rw-r--r--compiler/rustc_ast_pretty/src/pprust/state/expr.rs33
3 files changed, 41 insertions, 5 deletions
diff --git a/compiler/rustc_ast_pretty/src/pp.rs b/compiler/rustc_ast_pretty/src/pp.rs
index c93022308..7ab8c3eab 100644
--- a/compiler/rustc_ast_pretty/src/pp.rs
+++ b/compiler/rustc_ast_pretty/src/pp.rs
@@ -360,7 +360,7 @@ impl Printer {
fn check_stack(&mut self, mut depth: usize) {
while let Some(&index) = self.scan_stack.back() {
- let mut entry = &mut self.buf[index];
+ let entry = &mut self.buf[index];
match entry.token {
Token::Begin(_) => {
if depth == 0 {
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();