Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
184 commits
Select commit Hold shift + click to select a range
177f9f9
add '-Z profile-queries' debug flag
May 23, 2017
46e04f1
send QueryBegin message on channel; TODO-Send: actually create the ch…
May 23, 2017
dfa863c
profile_queries_msg macro; all messages in place
May 24, 2017
aa5becd
spawning thread, but getting the compiler to overflow in some checks:…
May 24, 2017
86fb705
avoid tcx lifetime in the inter-thread profile-queries messages
May 24, 2017
9d71b21
add control messages (halt and dump); parse traces to dump
Jun 6, 2017
741376b
basic HTML output
Jun 14, 2017
d8569eb
profile-queries: test runs; debugging; now crashes with 'cannot acces…
Jun 14, 2017
947c1a7
detect closed channel; text with query constructor string in final HTML
Jun 14, 2017
84b880d
Add hint about the return code of panic!
dns2utf8 Jun 15, 2017
b4ceece
add CSS style to rust code; change filename to 'profile_queries.html'
Jun 15, 2017
8861084
tidiness checks pass
Jun 15, 2017
5fe6b2a
profile-queries: durations in HTML output
Jun 19, 2017
a4b788d
profile queries: time as fractions of total
Jun 19, 2017
90c4427
profile-queries: create counts file
Jun 20, 2017
413290b
profile-queries: aggregate counts and durations for queries
Jun 20, 2017
8205c34
Note different versions of same crate when absolute paths of differen…
Yorwba Jun 22, 2017
21bb60a
Replace `grep -z` by `tr -d '\r\n' | grep` for cross-compatibility
Yorwba Jun 29, 2017
01b6c94
Implement Eq/Hash/Debug etc. for unsized tuples.
qnighy Jul 1, 2017
728d26c
Add a test for unsized tuple impls.
qnighy Jul 4, 2017
d539057
Insert current implementation header
dns2utf8 Jul 5, 2017
9e001ce
Be more specific about the implications of the panic!
dns2utf8 Jul 5, 2017
05d3526
`rustc_on_unimplemented` supports referring to trait
estebank Jul 1, 2017
010dea1
Stabilize float_bits_conv
est31 Jul 4, 2017
28ce292
Add `isize` and `usize` constructors to Literal
alexcrichton Jul 6, 2017
4d58b04
Redox: add stat methods(); support is_symlink()
ids1024 Jul 6, 2017
6008004
Only match a fragment specifier the if it starts with certain tokens.
kennytm Jun 26, 2017
bca8570
incr.comp.: Don't include span information in the ICH of type definit…
michaelwoerister Jul 7, 2017
b8b4f56
Update compiler_builtins submodule for probestack fix
alexcrichton Jul 8, 2017
c6b280e
Add warning to BufWriter documentation
Jul 9, 2017
f2566bb
Correct some stability attributes
ollie27 Jul 10, 2017
2557800
Split DepNode::ItemSignature into non-overlapping variants.
michaelwoerister Jun 22, 2017
ca0a403
incr.comp.: Improve debug output for work products.
michaelwoerister Jun 23, 2017
9808661
Add StableHash implementation for ty::Instance.
michaelwoerister Jun 30, 2017
e00bec2
Allow 'tcx in define_dep_nodes! and deduplicate some DepNodes.
michaelwoerister Jun 30, 2017
f8b774f
Deduplicate DepNode::ConstEval()
michaelwoerister Jul 3, 2017
13e87d1
Fix some `tidy` errors.
michaelwoerister Jul 4, 2017
089860b
incr.comp.: Manage dependency graph on main thread.
michaelwoerister Jul 4, 2017
0363a23
incr.comp.: Introduce the concept of anonymous DepNodes.
michaelwoerister Jun 23, 2017
6d049fb
incr.comp.: Cache DepNodes with corresponding query results.
michaelwoerister Jul 4, 2017
37f56a2
Use similar compression settings as before updating to use flate2
oyvindln Jul 10, 2017
4f1f671
don't panic in `dep_node_debug_str` if `self.data` is `None`
nikomatsakis Jul 10, 2017
01c6437
tweaks; tidy
Jul 10, 2017
9228d23
Auto merge of #43028 - michaelwoerister:dedup-dep-nodes, r=nikomatsakis
bors Jul 10, 2017
bc8733f
update .mailmap
zackmdavis Jul 10, 2017
32ae12b
Add LocalKey::try_with as an alternative to state
PlasmaPower Jul 10, 2017
77bd4dc
Disable big-endian simd in swap_nonoverlapping_bytes
cuviper Jul 11, 2017
a45c8b0
Use LocalKey::try_with in std
PlasmaPower Jul 11, 2017
1999bfa
Auto merge of #42913 - kennytm:fix-40569-ident-without-backtrack, r=j…
bors Jul 11, 2017
a1f180b
Auto merge of #43147 - oyvindln:deflate_fix, r=alexcrichton
bors Jul 11, 2017
18712e6
compiletest: Refactor: Move the `ignore-{}` logic into its own method.
kennytm Jul 6, 2017
ef26f17
Clean up some code
GuillaumeGomez Jul 1, 2017
24a5cea
tweak word ordering
nikomatsakis Jul 10, 2017
0cf8f85
fail in case nothing to run was found
GuillaumeGomez Jul 10, 2017
4582ecd
compiletest: Support custom normalization rules.
kennytm Jul 6, 2017
34209b0
Merge ui/README.md into COMPILER_TESTS.md and describe how custom UI …
kennytm Jul 6, 2017
dddf24d
Auto merge of #43006 - GuillaumeGomez:e0611-cleanup, r=nikomatsakis
bors Jul 11, 2017
a148f5b
Enable profiler on "alternate" builds
SimonSapin Jul 11, 2017
7109d03
Allow setting the limit on std::io::Take.
Mark-Simulacrum Jun 16, 2017
687ee7f
Downgrade ProjectionTy's TraitRef to its substs
tbg Jul 11, 2017
133c1bc
Wrap long line
dns2utf8 Jul 11, 2017
8b5549d
Fix @alexcrichton comments
PlasmaPower Jul 11, 2017
1475e2c
Auto merge of #42388 - tschottdorf:projty-substs, r=nikomatsakis
bors Jul 11, 2017
9475ae4
Auto merge of #43116 - alexcrichton:probestack, r=sfackler
bors Jul 11, 2017
bac4bb9
Refactor methods onto Printer struct.
Mark-Simulacrum Jun 25, 2017
16b486c
Refactor cur_cmnt_and_lit away.
Mark-Simulacrum Jun 25, 2017
0343136
Make a few functions non-public
Mark-Simulacrum Jun 25, 2017
40f03a1
Refactor call_with_pp functions to not take a payload.
Mark-Simulacrum Jun 25, 2017
b6a2d7e
support pub(restricted) in thread_local!
durka Apr 1, 2017
8cce5bc
use :vis in thread_local!
durka Apr 19, 2017
8e7c488
stage0 fallback
durka Apr 21, 2017
f9f4707
let #[allow_internal_unstable] cover :vis
durka Apr 21, 2017
b360b44
Auto merge of #43083 - kennytm:fix-42434-custom-stdxxx-normalization,…
bors Jul 11, 2017
51260f4
Redox: Use O_NOFOLLOW for lstat()
ids1024 Jul 4, 2017
62b2e54
Refactor: {Lvalue,Rvalue,Operand}::ty only need the locals' types, no…
RalfJung Jul 11, 2017
cd71ea7
Auto merge of #43056 - ids1024:nofollow2, r=burntsushi
bors Jul 12, 2017
4871dba
update crate dependencies
steveklabnik Jun 27, 2017
d1f1f86
Auto merge of #42936 - steveklabnik:update-mdbook, r=alexcrichton
bors Jul 12, 2017
8ac29bd
Auto merge of #42697 - Mark-Simulacrum:take-limit, r=aturon
bors Jul 12, 2017
a260baa
Reintroduce expansion info for proc macros 1.1
oli-obk Jul 11, 2017
8bba5ad
Auto merge of #43107 - michaelwoerister:less-span-info-in-debug, r=ni…
bors Jul 12, 2017
4f030d0
integrate anon dep nodes into trait selection
nikomatsakis Jul 10, 2017
b2b19ec
Auto merge of #42897 - Mark-Simulacrum:pretty-print-refactor, r=jseyf…
bors Jul 12, 2017
ecf62e4
[LLVM] Avoid losing the !nonnull attribute in SROA
arielb1 Jul 1, 2017
500518a
Rollup merge of #42670 - dns2utf8:panic_return_code, r=steveklabnik
Mark-Simulacrum Jul 12, 2017
0926f9b
Rollup merge of #42826 - Yorwba:type-mismatch-same-absolute-paths, r=…
Mark-Simulacrum Jul 12, 2017
1a7dc0a
Rollup merge of #43000 - estebank:on-unimplemented-path, r=arielb1
Mark-Simulacrum Jul 12, 2017
e5288c9
Rollup merge of #43011 - qnighy:unsized-tuple-impls, r=aturon
Mark-Simulacrum Jul 12, 2017
2510116
Rollup merge of #43098 - alexcrichton:more-proc-macro, r=jseyfried
Mark-Simulacrum Jul 12, 2017
6aeb0f0
Rollup merge of #43100 - ids1024:stat2, r=aturon
Mark-Simulacrum Jul 12, 2017
cc20ab1
Rollup merge of #43136 - jgallag88:bufWriterDocs, r=steveklabnik
Mark-Simulacrum Jul 12, 2017
388fce9
Rollup merge of #43137 - ollie27:stab, r=aturon
Mark-Simulacrum Jul 12, 2017
f86e433
Add regression tests to ensure stable drop order
aochagavia Jul 8, 2017
2dcbef7
Add the Code of Conduct to the repository.
steveklabnik Jul 12, 2017
38df82d
Tweak the CoC to point to the online version.
steveklabnik Jul 12, 2017
a301f84
Use try_with for with implementation
PlasmaPower Jul 12, 2017
1a694fe
move trace and profile logic into sep mod; move init logic into commo…
Jul 12, 2017
f85579d
Auto merge of #43181 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
bors Jul 12, 2017
a01c91c
Document error coercion to false in path-ext methods + see also sections
Havvy Jun 27, 2017
66fce33
overload the mir ty methods to make them more ergonomic to use
RalfJung Jul 12, 2017
e1ad190
rename trait to conform with 'getter trait' pattern
RalfJung Jul 12, 2017
0bbc315
please tidy by shortening lines
RalfJung Jul 12, 2017
b7a4c54
Change language in Travis configuration to shell
Mark-Simulacrum Jul 12, 2017
2503461
Updated docker images to factor out common scripts
Ophirr33 Jul 9, 2017
0d617ce
Update tcp.rs
jackpot51 Jul 13, 2017
bd9428a
Update mod.rs
jackpot51 Jul 13, 2017
362dd8a
Update fs.rs
jackpot51 Jul 13, 2017
21f2ace
Update mod.rs
jackpot51 Jul 13, 2017
4259ae6
Update fs.rs
jackpot51 Jul 13, 2017
cfd4c81
Auto merge of #43198 - rust-lang:travis-shell, r=alexcrichton
bors Jul 13, 2017
06ffdeb
Auto merge of #43129 - Ophirr33:master, r=alexcrichton
bors Jul 13, 2017
b2c0707
Auto merge of #43158 - PlasmaPower:thread-local-try-with, r=alexcrichton
bors Jul 13, 2017
cb92ab9
Reduce the usage of features in compiletest and libtest
oli-obk Jul 12, 2017
3aaa809
Rollup merge of #42926 - Havvy:doc-path-ext, r=steveklabnik
steveklabnik Jul 13, 2017
8dc69ff
Rollup merge of #43125 - aochagavia:stable_drop, r=arielb1
steveklabnik Jul 13, 2017
ddf43b5
Rollup merge of #43157 - zackmdavis:mail_map, r=steveklabnik
steveklabnik Jul 13, 2017
591d8a1
Rollup merge of #43167 - SimonSapin:alt-profiler, r=alexcrichton
steveklabnik Jul 13, 2017
a14b30c
Rollup merge of #43187 - steveklabnik:code-of-conduct, r=alexcrichton
steveklabnik Jul 13, 2017
9d4b462
Rollup merge of #43203 - jackpot51:patch-2, r=alexcrichton
steveklabnik Jul 13, 2017
da3f5b8
Rollup merge of #43204 - jackpot51:patch-3, r=alexcrichton
steveklabnik Jul 13, 2017
bdcebc9
Update the `cargo` submodule
alexcrichton Jul 13, 2017
3bf8116
Split old and experimental wasm builders
tlively Jul 7, 2017
03f22fd
windows::fs::symlink_dir: fix example to actually use symlink_dir
RalfJung Jul 13, 2017
b90e510
Forward more Iterator methods for str::Bytes
SimonSapin Jul 5, 2017
2007987
Forward more Iterator methods for iter::Rev
SimonSapin Jul 5, 2017
b5c5a0c
Fix regression involving identifiers in `macro_rules!` patterns.
jseyfried Jul 13, 2017
ab91c70
Auto merge of #43216 - steveklabnik:rollup, r=steveklabnik
bors Jul 14, 2017
1da51cc
Fix minor typo in std::path documentation.
kennytm Jul 14, 2017
5757e05
Fix backtrace on Redox
jackpot51 Jul 14, 2017
20f77c6
Auto merge of #43026 - arielb1:llvm-next, r=alexcrichton
bors Jul 14, 2017
ae4803a
Auto merge of #43175 - tlively:wasm-split-bots, r=alexcrichton
bors Jul 14, 2017
e760ba2
Update the books.
steveklabnik Jul 14, 2017
30ad625
add u128/i128 to sum/product implementors
zackmdavis Jul 14, 2017
6d9d82d
Auto merge of #43180 - oli-obk:compiletest, r=alexcrichton
bors Jul 14, 2017
0af5c00
Add support for dylibs with Address Sanitizer. This supports cdylibs …
Firstyear Jun 17, 2017
23ecebd
Auto merge of #43174 - RalfJung:refactor-ty, r=nikomatsakis
bors Jul 14, 2017
b4502f7
Auto merge of #43184 - nikomatsakis:incr-comp-anonymize-trait-selecti…
bors Jul 15, 2017
e7a9f1b
Rollup merge of #43074 - SimonSapin:iter, r=aturon
frewsxcv Jul 15, 2017
c3a8347
Rollup merge of #43145 - GuillaumeGomez:build-error-if-nothing, r=Mar…
frewsxcv Jul 15, 2017
721f736
Rollup merge of #43159 - cuviper:ptr-swap-simd, r=arielb1
frewsxcv Jul 15, 2017
351c476
Rollup merge of #43202 - jackpot51:patch-1, r=sfackler
frewsxcv Jul 15, 2017
877e62e
Rollup merge of #43222 - RalfJung:symlink, r=sfackler
frewsxcv Jul 15, 2017
57bc82d
Rollup merge of #43228 - redox-os:backtrace_fix, r=alexcrichton
frewsxcv Jul 15, 2017
09b3ea7
Rollup merge of #43229 - kennytm:return-false-if-path-is-relative-hah…
frewsxcv Jul 15, 2017
e3825ec
Rollup merge of #43240 - steveklabnik:update-books, r=QuietMisdreavus
frewsxcv Jul 15, 2017
8658908
Auto merge of #43185 - durka:thread-local-pub-restricted, r=alexcrichton
bors Jul 15, 2017
70cd955
Auto merge of #43179 - oli-obk:mark_all_the_expansions, r=jseyfried
bors Jul 15, 2017
c4373bd
Auto merge of #43207 - alexcrichton:update-cargo, r=nikomatsakis
bors Jul 15, 2017
db19bf0
Document default values for primitive types
vbrandl Jul 15, 2017
a783fe2
Auto merge of #43246 - frewsxcv:rollup, r=frewsxcv
bors Jul 15, 2017
caf125f
Rephrase the doc string
vbrandl Jul 15, 2017
086eaa7
Auto merge of #43224 - jseyfried:fix_macro_idents_regression, r=nrc
bors Jul 15, 2017
5f37110
Compile `compiler_builtins` with `abort` panic strategy
petrochenkov Jul 15, 2017
be18613
Auto merge of #43252 - vbrandl:doc/default-values, r=GuillaumeGomez
bors Jul 16, 2017
8f1339a
Auto merge of #43237 - zackmdavis:missing_sum_and_product_for_128_bit…
bors Jul 16, 2017
b115968
Fix `range_covered_by_constructor` for exclusive ranges.
feadoor Jul 16, 2017
1b3c339
Update function name to reflect reality
feadoor Jul 16, 2017
56071f6
Auto merge of #43055 - est31:stabilize_float_bits_conv, r=sfackler
bors Jul 17, 2017
08652ec
Auto merge of #43258 - petrochenkov:cbabort, r=alexcrichton
bors Jul 17, 2017
2579793
Remove exception from license check for strings.rs
nrc May 22, 2017
04415dc
Run RLS tests
nrc Jun 30, 2017
88cf76a
Auto merge of #42146 - nrc:rls-rust, r=alexcrichton
bors Jul 17, 2017
4a28663
Move some tests from compile-fail to ui
oli-obk May 16, 2017
a9d9a4a
Change some helps to suggestions
oli-obk May 16, 2017
eb7f429
Move resolve diagnostic instability to compile-fail
oli-obk Jul 17, 2017
5803f99
Auto merge of #42033 - oli-obk:suggestions, r=petrochenkov
bors Jul 17, 2017
028569a
Auto merge of #43266 - feadoor:issue-43253-exclusive-range-warning, r…
bors Jul 17, 2017
2652ce6
Auto merge of #42711 - Firstyear:san-on-dylib, r=alexcrichton
bors Jul 17, 2017
5580c19
write log of queries
Jul 17, 2017
9967e9e
Support generic lifetime arguments in method calls
petrochenkov Jun 6, 2017
7ca378b
Prohibit lifetime arguments in path segments with late bound lifetime…
petrochenkov Jun 23, 2017
e40cedb
Detect implicitly defined late bound lifetime parameters as well
petrochenkov Jun 24, 2017
46f427b
Fix incorrect subst index
petrochenkov Jul 11, 2017
36be634
rustc waits for profile-queries dump to complete
Jul 17, 2017
9153bb3
add minimal doc
Jul 17, 2017
f9fabc1
tidy
Jul 17, 2017
39114f9
Make `late_bound_lifetime_arguments` lint warn-by-default
petrochenkov Jul 17, 2017
c843661
travis: Make a few `curl` invocations more resilient
alexcrichton Jul 17, 2017
2e63340
Auto merge of #43293 - alexcrichton:fail-curl, r=Mark-Simulacrum
bors Jul 18, 2017
83c659e
Auto merge of #42492 - petrochenkov:methlife, r=nikomatsakis
bors Jul 18, 2017
d245dc4
add '-Z profile-queries' debug flag
May 23, 2017
081ab8e
tidy
Jul 17, 2017
e56a8a8
rebase
Jul 18, 2017
74a7234
fix nits from Niko
Jul 18, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactor cur_cmnt_and_lit away.
The literal index was increased in only next_lit, so it isn't
necessary: code now uses an iterator. The cur_cmnt field is also moved
to be increased in print_comment instead of after each call to
print_comment.
  • Loading branch information
Mark-Simulacrum committed Jul 11, 2017
commit 16b486ce6ec1c15e4019925c22a7abff83db9950
36 changes: 17 additions & 19 deletions src/librustc/hir/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use syntax::parse::ParseSess;
use syntax::parse::lexer::comments;
use syntax::print::pp::{self, Breaks};
use syntax::print::pp::Breaks::{Consistent, Inconsistent};
use syntax::print::pprust::{self as ast_pp, PrintState};
use syntax::print::pprust::PrintState;
use syntax::ptr::P;
use syntax::symbol::keywords;
use syntax_pos::{self, BytePos};
Expand All @@ -27,6 +27,8 @@ use hir::{PatKind, RegionTyParamBound, TraitTyParamBound, TraitBoundModifier, Ra

use std::cell::Cell;
use std::io::{self, Write, Read};
use std::iter::Peekable;
use std::vec;

pub enum AnnNode<'a> {
NodeName(&'a ast::Name),
Expand Down Expand Up @@ -77,8 +79,8 @@ pub struct State<'a> {
pub s: pp::Printer<'a>,
cm: Option<&'a CodeMap>,
comments: Option<Vec<comments::Comment>>,
literals: Option<Vec<comments::Literal>>,
cur_cmnt_and_lit: ast_pp::CurrentCommentAndLiteral,
literals: Peekable<vec::IntoIter<comments::Literal>>,
cur_cmnt: usize,
boxes: Vec<pp::Breaks>,
ann: &'a (PpAnn + 'a),
}
Expand All @@ -96,12 +98,16 @@ impl<'a> PrintState<'a> for State<'a> {
&mut self.comments
}

fn cur_cmnt_and_lit(&mut self) -> &mut ast_pp::CurrentCommentAndLiteral {
&mut self.cur_cmnt_and_lit
fn cur_cmnt(&mut self) -> &mut usize {
&mut self.cur_cmnt
}

fn literals(&self) -> &Option<Vec<comments::Literal>> {
&self.literals
fn cur_lit(&mut self) -> Option<&comments::Literal> {
self.literals.peek()
}

fn bump_lit(&mut self) -> Option<comments::Literal> {
self.literals.next()
}
}

Expand Down Expand Up @@ -169,11 +175,8 @@ impl<'a> State<'a> {
s: pp::mk_printer(out, default_columns),
cm: Some(cm),
comments: comments.clone(),
literals: literals.clone(),
cur_cmnt_and_lit: ast_pp::CurrentCommentAndLiteral {
cur_cmnt: 0,
cur_lit: 0,
},
literals: literals.unwrap_or_default().into_iter().peekable(),
cur_cmnt: 0,
boxes: Vec::new(),
ann,
}
Expand All @@ -189,11 +192,8 @@ pub fn to_string<F>(ann: &PpAnn, f: F) -> String
s: pp::mk_printer(Box::new(&mut wr), default_columns),
cm: None,
comments: None,
literals: None,
cur_cmnt_and_lit: ast_pp::CurrentCommentAndLiteral {
cur_cmnt: 0,
cur_lit: 0,
},
literals: vec![].into_iter().peekable(),
cur_cmnt: 0,
boxes: Vec::new(),
ann,
};
Expand Down Expand Up @@ -2131,7 +2131,6 @@ impl<'a> State<'a> {
if span.hi < (*cmnt).pos && (*cmnt).pos < next &&
span_line.line == comment_line.line {
self.print_comment(cmnt)?;
self.cur_cmnt_and_lit.cur_cmnt += 1;
}
}
Ok(())
Expand All @@ -2147,7 +2146,6 @@ impl<'a> State<'a> {
match self.next_comment() {
Some(ref cmnt) => {
self.print_comment(cmnt)?;
self.cur_cmnt_and_lit.cur_cmnt += 1;
}
_ => break,
}
Expand Down
84 changes: 38 additions & 46 deletions src/libsyntax/print/pprust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ use tokenstream::{self, TokenStream, TokenTree};

use std::ascii;
use std::io::{self, Write, Read};
use std::iter;
use std::iter::{self, Peekable};
use std::vec;

pub enum AnnNode<'a> {
NodeIdent(&'a ast::Ident),
Expand All @@ -53,18 +54,12 @@ pub struct NoAnn;

impl PpAnn for NoAnn {}

#[derive(Copy, Clone)]
pub struct CurrentCommentAndLiteral {
pub cur_cmnt: usize,
pub cur_lit: usize,
}

pub struct State<'a> {
pub s: pp::Printer<'a>,
cm: Option<&'a CodeMap>,
comments: Option<Vec<comments::Comment> >,
literals: Option<Vec<comments::Literal> >,
cur_cmnt_and_lit: CurrentCommentAndLiteral,
literals: Peekable<vec::IntoIter<comments::Literal>>,
cur_cmnt: usize,
boxes: Vec<pp::Breaks>,
ann: &'a (PpAnn+'a),
}
Expand All @@ -80,11 +75,8 @@ pub fn rust_printer_annotated<'a>(writer: Box<Write+'a>,
s: pp::mk_printer(writer, DEFAULT_COLUMNS),
cm: None,
comments: None,
literals: None,
cur_cmnt_and_lit: CurrentCommentAndLiteral {
cur_cmnt: 0,
cur_lit: 0
},
literals: vec![].into_iter().peekable(),
cur_cmnt: 0,
boxes: Vec::new(),
ann: ann,
}
Expand Down Expand Up @@ -160,11 +152,8 @@ impl<'a> State<'a> {
s: pp::mk_printer(out, DEFAULT_COLUMNS),
cm: Some(cm),
comments: comments,
literals: literals,
cur_cmnt_and_lit: CurrentCommentAndLiteral {
cur_cmnt: 0,
cur_lit: 0
},
literals: literals.unwrap_or_default().into_iter().peekable(),
cur_cmnt: 0,
boxes: Vec::new(),
ann: ann,
}
Expand Down Expand Up @@ -451,8 +440,9 @@ pub trait PrintState<'a> {
fn writer(&mut self) -> &mut pp::Printer<'a>;
fn boxes(&mut self) -> &mut Vec<pp::Breaks>;
fn comments(&mut self) -> &mut Option<Vec<comments::Comment>>;
fn cur_cmnt_and_lit(&mut self) -> &mut CurrentCommentAndLiteral;
fn literals(&self) -> &Option<Vec<comments::Literal>>;
fn cur_cmnt(&mut self) -> &mut usize;
fn cur_lit(&mut self) -> Option<&comments::Literal>;
fn bump_lit(&mut self) -> Option<comments::Literal>;

fn word_space(&mut self, w: &str) -> io::Result<()> {
self.writer().word(w)?;
Expand Down Expand Up @@ -518,31 +508,24 @@ pub trait PrintState<'a> {
}

fn next_lit(&mut self, pos: BytePos) -> Option<comments::Literal> {
let mut cur_lit = self.cur_cmnt_and_lit().cur_lit;

let mut result = None;
while let Some(ltrl) = self.cur_lit().cloned() {
if ltrl.pos > pos { break; }

if let Some(ref lits) = *self.literals() {
while cur_lit < lits.len() {
let ltrl = (*lits)[cur_lit].clone();
if ltrl.pos > pos { break; }
cur_lit += 1;
if ltrl.pos == pos {
result = Some(ltrl);
break;
}
// we don't need the value here since we're forced to clone cur_lit
// due to lack of NLL.
self.bump_lit();
if ltrl.pos == pos {
return Some(ltrl);
}
}

self.cur_cmnt_and_lit().cur_lit = cur_lit;
result
None
}

fn maybe_print_comment(&mut self, pos: BytePos) -> io::Result<()> {
while let Some(ref cmnt) = self.next_comment() {
if cmnt.pos < pos {
self.print_comment(cmnt)?;
self.cur_cmnt_and_lit().cur_cmnt += 1;
} else {
break
}
Expand All @@ -552,7 +535,7 @@ pub trait PrintState<'a> {

fn print_comment(&mut self,
cmnt: &comments::Comment) -> io::Result<()> {
match cmnt.style {
let r = match cmnt.style {
comments::Mixed => {
assert_eq!(cmnt.lines.len(), 1);
self.writer().zerobreak()?;
Expand Down Expand Up @@ -600,11 +583,18 @@ pub trait PrintState<'a> {
}
self.writer().hardbreak()
}
};
match r {
Ok(()) => {
*self.cur_cmnt() = *self.cur_cmnt() + 1;
Ok(())
}
Err(e) => Err(e),
}
}

fn next_comment(&mut self) -> Option<comments::Comment> {
let cur_cmnt = self.cur_cmnt_and_lit().cur_cmnt;
let cur_cmnt = *self.cur_cmnt();
match *self.comments() {
Some(ref cmnts) => {
if cur_cmnt < cmnts.len() {
Expand All @@ -619,8 +609,8 @@ pub trait PrintState<'a> {

fn print_literal(&mut self, lit: &ast::Lit) -> io::Result<()> {
self.maybe_print_comment(lit.span.lo)?;
if let Some(ref ltrl) = self.next_lit(lit.span.lo) {
return self.writer().word(&(*ltrl).lit);
if let Some(ltrl) = self.next_lit(lit.span.lo) {
return self.writer().word(&ltrl.lit);
}
match lit.node {
ast::LitKind::Str(st, style) => self.print_string(&st.as_str(), style),
Expand Down Expand Up @@ -860,12 +850,16 @@ impl<'a> PrintState<'a> for State<'a> {
&mut self.comments
}

fn cur_cmnt_and_lit(&mut self) -> &mut CurrentCommentAndLiteral {
&mut self.cur_cmnt_and_lit
fn cur_cmnt(&mut self) -> &mut usize {
&mut self.cur_cmnt
}

fn cur_lit(&mut self) -> Option<&comments::Literal> {
self.literals.peek()
}

fn literals(&self) -> &Option<Vec<comments::Literal>> {
&self.literals
fn bump_lit(&mut self) -> Option<comments::Literal> {
self.literals.next()
}
}

Expand Down Expand Up @@ -3021,7 +3015,6 @@ impl<'a> State<'a> {
let next = next_pos.unwrap_or(cmnt.pos + BytePos(1));
if span.hi < cmnt.pos && cmnt.pos < next && span_line.line == comment_line.line {
self.print_comment(cmnt)?;
self.cur_cmnt_and_lit.cur_cmnt += 1;
}
}
Ok(())
Expand All @@ -3035,7 +3028,6 @@ impl<'a> State<'a> {
}
while let Some(ref cmnt) = self.next_comment() {
self.print_comment(cmnt)?;
self.cur_cmnt_and_lit.cur_cmnt += 1;
}
Ok(())
}
Expand Down