-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pretty printer improvements #14106
Pretty printer improvements #14106
Conversation
Is the binary from |
Sadly no, I think that because there's any slight difference at all in the AST that the binary output is quite different. I imagine that they are very similar in functionality, however. |
Does |
Not quite, sadly. By using |
Should have all the tests passing now. |
Hm, I wonder if rustc src/libcore/lib.rs --test --pretty expanded > coretest.rs
rustc coretest.rs
./coretest works. |
Some(ast_map::NodeItem(item)) => item, | ||
_ => return, | ||
}; | ||
if !cx.checked_raw_pointers.insert(item.id) { return } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little confused about why this would ever be hit? Surely the visitor visits each item once?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, of course: The automatically_derived
attribute applies to impl
s, and so one can have multiple impl
s corresponding to a single struct
/enum
.
Running |
Travis has relevant failures. |
Inject `extern crate {std, native}` before `use` statements. Add `#![feature(glob)]` since `use std::prelude::*` is used. (Unfortunately `rustc --pretty expanded` does not converge, since `extern crate` and `use std::prelude::*` is injected at every iteration.)
Some `Expr` needs parentheses when printed. For example, without parentheses, `ExprUnary(UnNeg, ExprBinary(BiAdd, ..))` becomes `-lhs + rhs` which is wrong. Those cases don't appear in ordinary code (since parentheses are explicitly added) but they can appear in manually crafted ast by extensions.
The tests use managed boxes, but are not perfectly feature-gated because they use `@` inside macros. (It causes issue after `--pretty expanded`.)
After testing `--pretty normal`, it tries to run `--pretty expanded` and typecheck output. Here we don't check convergence since it really diverges: for every iteration, some extra lines (e.g.`extern crate std`) are inserted. Some tests are `ignore-pretty`-ed since they cause various issues with `--pretty expanded`.
* Added `// no-pretty-expanded` to pretty-print a test, but not run it through the `expanded` variant. * Removed #[deriving] and other expanded attributes after they are expanded * Removed hacks around &str and &&str and friends (from both the parser and the pretty printer). * Un-ignored a bunch of tests
Integers are always parsed as a u64 in libsyntax, but they're stored as i64. The parser and pretty printer both printed an i64 instead of u64, sometimes introducing an extra negative sign.
This uses the trick of replacing the << token with a < token to parse closure types correctly. Closes rust-lang#13324
The pretty printer handles inlines comments quite badly
When expanding, an extra unsafe block is generated which is currently not handled well.
Previously, literals "1i" were printed as "1". This fixes the numeric-method-autoexport test for pretty printing.
Now that the #[deriving] attribute is removed, the raw_pointers_deriving lint was broken. This commit restores the lint by preserving lint attributes across #[deriving] to the implementations and using #[automatically_derived] as the trigger for activating the lint.
When printing doc comments, always put a newline after them in a macro invocation to ensure that a line-doc-comment doesn't consume remaining tokens on the line.
Closes #14184 (std: Move the owned module from core to std) Closes #14183 (Allow blocks in const expressions) Closes #14176 (Add tests for from_bits.) Closes #14175 (Replaced ~T by Box<T> in manual) Closes #14173 (Implements Default trait for BigInt and BigUint) Closes #14171 (Fix #8391) Closes #14159 (Clean up unicode code in libstd) Closes #14126 (docs: Add a not found page) Closes #14123 (add a line to the example to clarify semantics) Closes #14106 (Pretty printer improvements) Closes #14083 (rustllvm: Add LLVMRustArrayType) Closes #13957 (io: Implement process wait timeouts)
Rebasing of #13596, plus some extra fixes.
These commands now execute without error: