Skip to content

Commit

Permalink
Auto merge of rust-lang#93048 - matthiaskrgr:rollup-cz5ma34, r=matthi…
Browse files Browse the repository at this point in the history
…askrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#90782 (Implement raw-dylib support for windows-gnu)
 - rust-lang#91150 (Let qpath contain NtTy: `<$:ty as $:ty>::…`)
 - rust-lang#92425 (Improve SIMD casts)
 - rust-lang#92692 (Simplify and unify rustdoc sidebar styles)
 - rust-lang#92780 (Directly use ConstValue for single literals in blocks)
 - rust-lang#92924 (Delete pretty printer tracing)
 - rust-lang#93018 (Remove some unused `Ord` derives based on `Span`)
 - rust-lang#93026 (fix typo in `max` description for f32/f64)
 - rust-lang#93035 (Fix stdarch submodule pointing to commit outside tree)

Failed merges:

 - rust-lang#92861 (Rustdoc mobile: put out-of-band info on its own line)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Jan 18, 2022
2 parents 9ad5d82 + f851a84 commit e5e2b0b
Show file tree
Hide file tree
Showing 73 changed files with 902 additions and 742 deletions.
1 change: 0 additions & 1 deletion Cargo.lock
Expand Up @@ -3433,7 +3433,6 @@ version = "0.0.0"
dependencies = [
"rustc_ast",
"rustc_span",
"tracing",
]

[[package]]
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ast/src/ast.rs
Expand Up @@ -2006,7 +2006,7 @@ bitflags::bitflags! {
}
}

#[derive(Clone, PartialEq, PartialOrd, Encodable, Decodable, Debug, Hash, HashStable_Generic)]
#[derive(Clone, PartialEq, Encodable, Decodable, Debug, Hash, HashStable_Generic)]
pub enum InlineAsmTemplatePiece {
String(String),
Placeholder { operand_idx: usize, modifier: Option<char>, span: Span },
Expand Down Expand Up @@ -2211,7 +2211,7 @@ pub enum IsAuto {
No,
}

#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Encodable, Decodable, Debug)]
#[derive(Copy, Clone, PartialEq, Eq, Hash, Encodable, Decodable, Debug)]
#[derive(HashStable_Generic)]
pub enum Unsafe {
Yes(Span),
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_ast_pretty/Cargo.toml
Expand Up @@ -7,6 +7,5 @@ edition = "2021"
doctest = false

[dependencies]
tracing = "0.1"
rustc_span = { path = "../rustc_span" }
rustc_ast = { path = "../rustc_ast" }
52 changes: 0 additions & 52 deletions compiler/rustc_ast_pretty/src/pp.rs
Expand Up @@ -138,7 +138,6 @@ use ring::RingBuffer;
use std::borrow::Cow;
use std::collections::VecDeque;
use std::fmt;
use tracing::debug;

/// How to break. Described in more detail in the module docs.
#[derive(Clone, Copy, PartialEq)]
Expand Down Expand Up @@ -193,22 +192,6 @@ impl fmt::Display for Token {
}
}

fn buf_str(buf: &RingBuffer<BufEntry>, left: usize, right: usize, lim: usize) -> String {
let mut i = left;
let mut l = lim;
let mut s = String::from("[");
while i != right && l != 0 {
l -= 1;
if i != left {
s.push_str(", ");
}
s.push_str(&format!("{}={}", buf[i].size, &buf[i].token));
i += 1;
}
s.push(']');
s
}

#[derive(Copy, Clone)]
enum PrintStackBreak {
Fits,
Expand Down Expand Up @@ -267,7 +250,6 @@ impl Default for BufEntry {
impl Printer {
pub fn new() -> Self {
let linewidth = 78;
debug!("Printer::new {}", linewidth);
let mut buf = RingBuffer::new();
buf.advance_right();
Printer {
Expand Down Expand Up @@ -310,16 +292,13 @@ impl Printer {
} else {
self.advance_right();
}
debug!("pp Begin({})/buffer Vec<{},{}>", b.offset, self.left, self.right);
self.scan_push(BufEntry { token: Token::Begin(b), size: -self.right_total });
}

fn scan_end(&mut self) {
if self.scan_stack.is_empty() {
debug!("pp End/print Vec<{},{}>", self.left, self.right);
self.print_end();
} else {
debug!("pp End/buffer Vec<{},{}>", self.left, self.right);
self.advance_right();
self.scan_push(BufEntry { token: Token::End, size: -1 });
}
Expand All @@ -334,18 +313,15 @@ impl Printer {
} else {
self.advance_right();
}
debug!("pp Break({})/buffer Vec<{},{}>", b.offset, self.left, self.right);
self.check_stack(0);
self.scan_push(BufEntry { token: Token::Break(b), size: -self.right_total });
self.right_total += b.blank_space;
}

fn scan_string(&mut self, s: Cow<'static, str>) {
if self.scan_stack.is_empty() {
debug!("pp String('{}')/print Vec<{},{}>", s, self.left, self.right);
self.print_string(s);
} else {
debug!("pp String('{}')/buffer Vec<{},{}>", s, self.left, self.right);
self.advance_right();
let len = s.len() as isize;
self.buf[self.right] = BufEntry { token: Token::String(s), size: len };
Expand All @@ -355,18 +331,8 @@ impl Printer {
}

fn check_stream(&mut self) {
debug!(
"check_stream Vec<{}, {}> with left_total={}, right_total={}",
self.left, self.right, self.left_total, self.right_total
);
if self.right_total - self.left_total > self.space {
debug!(
"scan window is {}, longer than space on line ({})",
self.right_total - self.left_total,
self.space
);
if Some(&self.left) == self.scan_stack.back() {
debug!("setting {} to infinity and popping", self.left);
let scanned = self.scan_pop_bottom();
self.buf[scanned].size = SIZE_INFINITY;
}
Expand All @@ -378,7 +344,6 @@ impl Printer {
}

fn scan_push(&mut self, entry: BufEntry) {
debug!("scan_push {}", self.right);
self.buf[self.right] = entry;
self.scan_stack.push_front(self.right);
}
Expand All @@ -401,11 +366,6 @@ impl Printer {
}

fn advance_left(&mut self) {
debug!(
"advance_left Vec<{},{}>, sizeof({})={}",
self.left, self.right, self.left, self.buf[self.left].size
);

let mut left_size = self.buf[self.left].size;

while left_size >= 0 {
Expand Down Expand Up @@ -465,14 +425,12 @@ impl Printer {
}

fn print_newline(&mut self, amount: isize) {
debug!("NEWLINE {}", amount);
self.out.push('\n');
self.pending_indentation = 0;
self.indent(amount);
}

fn indent(&mut self, amount: isize) {
debug!("INDENT {}", amount);
self.pending_indentation += amount;
}

Expand All @@ -485,40 +443,33 @@ impl Printer {
fn print_begin(&mut self, b: BeginToken, l: isize) {
if l > self.space {
let col = self.margin - self.space + b.offset;
debug!("print Begin -> push broken block at col {}", col);
self.print_stack
.push(PrintStackElem { offset: col, pbreak: PrintStackBreak::Broken(b.breaks) });
} else {
debug!("print Begin -> push fitting block");
self.print_stack.push(PrintStackElem { offset: 0, pbreak: PrintStackBreak::Fits });
}
}

fn print_end(&mut self) {
debug!("print End -> pop End");
self.print_stack.pop().unwrap();
}

fn print_break(&mut self, b: BreakToken, l: isize) {
let top = self.get_top();
match top.pbreak {
PrintStackBreak::Fits => {
debug!("print Break({}) in fitting block", b.blank_space);
self.space -= b.blank_space;
self.indent(b.blank_space);
}
PrintStackBreak::Broken(Breaks::Consistent) => {
debug!("print Break({}+{}) in consistent block", top.offset, b.offset);
self.print_newline(top.offset + b.offset);
self.space = self.margin - (top.offset + b.offset);
}
PrintStackBreak::Broken(Breaks::Inconsistent) => {
if l > self.space {
debug!("print Break({}+{}) w/ newline in inconsistent", top.offset, b.offset);
self.print_newline(top.offset + b.offset);
self.space = self.margin - (top.offset + b.offset);
} else {
debug!("print Break({}) w/o newline in inconsistent", b.blank_space);
self.indent(b.blank_space);
self.space -= b.blank_space;
}
Expand All @@ -528,7 +479,6 @@ impl Printer {

fn print_string(&mut self, s: Cow<'static, str>) {
let len = s.len() as isize;
debug!("print String({})", s);
// assert!(len <= space);
self.space -= len;

Expand All @@ -545,8 +495,6 @@ impl Printer {
}

fn print(&mut self, token: Token, l: isize) {
debug!("print {} {} (remaining line space={})", token, l, self.space);
debug!("{}", buf_str(&self.buf, self.left, self.right, 6));
match token {
Token::Begin(b) => self.print_begin(b, l),
Token::End => self.print_end(),
Expand Down

0 comments on commit e5e2b0b

Please sign in to comment.