From 9918693037dce8aa4bb6f08741b6812923486c18 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 19 Jun 2024 11:26:03 +0200 Subject: Merging upstream version 1.76.0+dfsg1. Signed-off-by: Daniel Baumann --- compiler/rustc_ast_pretty/src/pp.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'compiler/rustc_ast_pretty/src/pp.rs') diff --git a/compiler/rustc_ast_pretty/src/pp.rs b/compiler/rustc_ast_pretty/src/pp.rs index 7ab8c3eab..96f5eff68 100644 --- a/compiler/rustc_ast_pretty/src/pp.rs +++ b/compiler/rustc_ast_pretty/src/pp.rs @@ -165,20 +165,20 @@ enum IndentStyle { } #[derive(Clone, Copy, Default, PartialEq)] -pub struct BreakToken { +pub(crate) struct BreakToken { offset: isize, blank_space: isize, pre_break: Option, } #[derive(Clone, Copy, PartialEq)] -pub struct BeginToken { +pub(crate) struct BeginToken { indent: IndentStyle, breaks: Breaks, } -#[derive(Clone, PartialEq)] -pub enum Token { +#[derive(PartialEq)] +pub(crate) enum Token { // In practice a string token contains either a `&'static str` or a // `String`. `Cow` is overkill for this because we never modify the data, // but it's more convenient than rolling our own more specialized type. @@ -229,7 +229,6 @@ pub struct Printer { last_printed: Option, } -#[derive(Clone)] struct BufEntry { token: Token, size: isize, @@ -251,16 +250,16 @@ impl Printer { } } - pub fn last_token(&self) -> Option<&Token> { + pub(crate) fn last_token(&self) -> Option<&Token> { self.last_token_still_buffered().or_else(|| self.last_printed.as_ref()) } - pub fn last_token_still_buffered(&self) -> Option<&Token> { + pub(crate) fn last_token_still_buffered(&self) -> Option<&Token> { self.buf.last().map(|last| &last.token) } /// Be very careful with this! - pub fn replace_last_token_still_buffered(&mut self, token: Token) { + pub(crate) fn replace_last_token_still_buffered(&mut self, token: Token) { self.buf.last_mut().unwrap().token = token; } @@ -314,7 +313,7 @@ impl Printer { } } - pub fn offset(&mut self, offset: isize) { + pub(crate) fn offset(&mut self, offset: isize) { if let Some(BufEntry { token: Token::Break(token), .. }) = &mut self.buf.last_mut() { token.offset += offset; } -- cgit v1.2.3