Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: dtolnay/prettyplease
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.2.20
Choose a base ref
...
head repository: dtolnay/prettyplease
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0.2.21
Choose a head ref
  • 11 commits
  • 6 files changed
  • 1 contributor

Commits on Jun 6, 2024

  1. Update unstable rustc_parse code to nightly-2024-06-06

    dtolnay committed Jun 6, 2024
    Copy the full SHA
    22da86d View commit details

Commits on Jun 24, 2024

  1. Raise minimum supported compiler to 1.61

    Required by syn 2.0.68.
    dtolnay committed Jun 24, 2024
    Copy the full SHA
    8f7bb3a View commit details
  2. Copy the full SHA
    060a8ad View commit details
  3. Work around rustfmt 'rewriting static' bug

    dtolnay committed Jun 24, 2024
    Copy the full SHA
    39a3f75 View commit details
  4. Merge pull request #76 from dtolnay/rustfmtbug

    Work around rustfmt "rewriting static" bug
    dtolnay authored Jun 24, 2024
    Copy the full SHA
    93f2078 View commit details

Commits on Aug 10, 2024

  1. Resolve single_match_else pedantic clippy lint

        warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
           --> src/path.rs:175:21
            |
        175 |           let qself = match qself {
            |  _____________________^
        176 | |             Some(qself) => qself,
        177 | |             None => {
        178 | |                 self.path(path, kind);
        179 | |                 return;
        180 | |             }
        181 | |         };
            | |_________^
            |
            = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match_else
            = note: `-W clippy::single-match-else` implied by `-W clippy::pedantic`
            = help: to override `-W clippy::pedantic` add `#[allow(clippy::single_match_else)]`
        help: try
            |
        175 ~         let qself = if let Some(qself) = qself { qself } else {
        176 +             self.path(path, kind);
        177 +             return;
        178 ~         };
            |
    dtolnay committed Aug 10, 2024
    Copy the full SHA
    8584223 View commit details

Commits on Aug 24, 2024

  1. Revert "Work around rustfmt 'rewriting static' bug"

    This reverts commit 39a3f75.
    dtolnay committed Aug 24, 2024
    Copy the full SHA
    cff71f3 View commit details
  2. Merge pull request #78 from dtolnay/rustfmtbug

    Revert "Work around rustfmt 'rewriting static' bug"
    dtolnay authored Aug 24, 2024
    Copy the full SHA
    53aac30 View commit details
  3. Pretty-print tail calls (become)

    dtolnay committed Aug 24, 2024
    Copy the full SHA
    d2881c3 View commit details
  4. Merge pull request #79 from dtolnay/tailcall

    Pretty-print tail calls (`become`)
    dtolnay authored Aug 24, 2024
    Copy the full SHA
    11c45ff View commit details
  5. Release 0.2.21

    dtolnay committed Aug 24, 2024
    Copy the full SHA
    ea2044e View commit details
Showing with 30 additions and 13 deletions.
  1. +1 −1 .github/workflows/ci.yml
  2. +4 −4 Cargo.toml
  3. +2 −1 examples/update/update-examples.rs
  4. +17 −0 src/expr.rs
  5. +1 −1 src/lib.rs
  6. +5 −6 src/path.rs
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ jobs:
strategy:
fail-fast: false
matrix:
rust: [nightly, beta, stable, 1.60.0]
rust: [nightly, beta, stable, 1.61.0]
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "prettyplease"
version = "0.2.20"
version = "0.2.21"
authors = ["David Tolnay <dtolnay@gmail.com>"]
autoexamples = false
categories = ["development-tools"]
@@ -12,20 +12,20 @@ keywords = ["rustfmt"]
license = "MIT OR Apache-2.0"
links = "prettyplease02"
repository = "https://github.com/dtolnay/prettyplease"
rust-version = "1.60"
rust-version = "1.61"

[features]
verbatim = ["syn/parsing"]

[dependencies]
proc-macro2 = { version = "1.0.80", default-features = false }
syn = { version = "2.0.59", default-features = false, features = ["full"] }
syn = { version = "2.0.76", default-features = false, features = ["full"] }

[dev-dependencies]
indoc = "2"
proc-macro2 = { version = "1.0.80", default-features = false }
quote = { version = "1.0.35", default-features = false }
syn = { version = "2.0.59", default-features = false, features = ["parsing"] }
syn = { version = "2.0.76", default-features = false, features = ["parsing"] }

[lib]
doc-scrape-examples = false
3 changes: 2 additions & 1 deletion examples/update/update-examples.rs
Original file line number Diff line number Diff line change
@@ -38,7 +38,8 @@ fn main() -> Result<()> {
let mut string = rustc_span::create_session_globals_then(Edition2021, None, || {
let locale_resources = rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec();
let sess = ParseSess::new(locale_resources);
let krate = rustc_parse::parse_crate_from_file(&input_path, &sess).unwrap();
let mut parser = rustc_parse::new_parser_from_file(&sess, &input_path, None).unwrap();
let krate = parser.parse_crate_mod().unwrap();
rustc_ast_pretty::pprust::crate_to_string_for_macros(&krate)
});
string.push('\n');
17 changes: 17 additions & 0 deletions src/expr.rs
Original file line number Diff line number Diff line change
@@ -681,10 +681,16 @@ impl Printer {
enum ExprVerbatim {
Empty,
Ellipsis,
Become(Become),
Builtin(Builtin),
RawReference(RawReference),
}

struct Become {
attrs: Vec<Attribute>,
tail_call: Expr,
}

struct Builtin {
attrs: Vec<Attribute>,
name: Ident,
@@ -709,6 +715,11 @@ impl Printer {
let lookahead = ahead.lookahead1();
if input.is_empty() {
Ok(ExprVerbatim::Empty)
} else if lookahead.peek(Token![become]) {
input.advance_to(&ahead);
input.parse::<Token![become]>()?;
let tail_call: Expr = input.parse()?;
Ok(ExprVerbatim::Become(Become { attrs, tail_call }))
} else if lookahead.peek(kw::builtin) {
input.advance_to(&ahead);
input.parse::<kw::builtin>()?;
@@ -751,6 +762,12 @@ impl Printer {
ExprVerbatim::Ellipsis => {
self.word("...");
}
ExprVerbatim::Become(expr) => {
self.outer_attrs(&expr.attrs);
self.word("become");
self.nbsp();
self.expr(&expr.tail_call);
}
ExprVerbatim::Builtin(expr) => {
self.outer_attrs(&expr.attrs);
self.word("builtin # ");
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -320,7 +320,7 @@
//! these situations with conditional punctuation tokens whose selection can be
//! deferred and populated after it's known that the group is or is not broken.
#![doc(html_root_url = "https://docs.rs/prettyplease/0.2.20")]
#![doc(html_root_url = "https://docs.rs/prettyplease/0.2.21")]
#![allow(
clippy::cast_possible_wrap,
clippy::cast_sign_loss,
11 changes: 5 additions & 6 deletions src/path.rs
Original file line number Diff line number Diff line change
@@ -172,12 +172,11 @@ impl Printer {
}

pub fn qpath(&mut self, qself: &Option<QSelf>, path: &Path, kind: PathKind) {
let qself = match qself {
Some(qself) => qself,
None => {
self.path(path, kind);
return;
}
let qself = if let Some(qself) = qself {
qself
} else {
self.path(path, kind);
return;
};

assert!(qself.position < path.segments.len());