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/proc-macro2
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.0.66
Choose a base ref
...
head repository: dtolnay/proc-macro2
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1.0.67
Choose a head ref
  • 20 commits
  • 7 files changed
  • 1 contributor

Commits on Jul 17, 2023

  1. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    Copy the full SHA
    ea99b07 View commit details
  2. Symlink proc-macro2 src dir into proc-macro2-fallback manifest dir

    Because `..` is otherwise not available to `cargo package`.
    
           Compiling proc-macro2-fallback v1.0.66
        error: couldn't read ../src/lib.rs: No such file or directory (os error 2)
    
        error: could not compile `proc-macro2-fallback` (lib) due to previous error
        error: failed to verify package tarball
    dtolnay committed Jul 17, 2023

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    Copy the full SHA
    88bee74 View commit details
  3. Merge pull request #400 from dtolnay/fallback

    Add proc-macro2-fallback crate containing just the fallback implemention
    dtolnay authored Jul 17, 2023

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    Copy the full SHA
    35877a6 View commit details
  4. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    Copy the full SHA
    03e7a51 View commit details

Commits on Jul 22, 2023

  1. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    Copy the full SHA
    c71dd29 View commit details

Commits on Jul 23, 2023

  1. Revert "Temporarily disable -Zrandomize-layout due to rustc ICE"

    Fixed in nightly-2023-07-23.
    
    This reverts commit c71dd29.
    dtolnay committed Jul 23, 2023

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    Copy the full SHA
    132fe1c View commit details

Commits on Aug 10, 2023

  1. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    Copy the full SHA
    cfc480b View commit details

Commits on Aug 11, 2023

  1. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    Copy the full SHA
    53167c1 View commit details

Commits on Aug 23, 2023

  1. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    Copy the full SHA
    241fc38 View commit details
  2. Merge pull request #403 from dtolnay/syn2

    Update syn 1.0 links to syn 2.0
    dtolnay authored Aug 23, 2023

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    Copy the full SHA
    2d05345 View commit details

Commits on Aug 29, 2023

  1. Update afl crate to 0.14

    dtolnay committed Aug 29, 2023

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    Copy the full SHA
    2cc9ef0 View commit details
  2. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    Copy the full SHA
    45ef770 View commit details

Commits on Sep 5, 2023

  1. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    Copy the full SHA
    5a225cf View commit details

Commits on Sep 10, 2023

  1. Re-enable honggfuzz CI

    dtolnay committed Sep 10, 2023

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    Copy the full SHA
    4ec3a42 View commit details
  2. Merge pull request #404 from dtolnay/honggfuzz

    Re-enable honggfuzz CI
    dtolnay authored Sep 10, 2023

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    Copy the full SHA
    7017480 View commit details

Commits on Sep 13, 2023

  1. Ignore missing_safety_doc clippy lint

        warning: unsafe function's docs miss `# Safety` section
            --> src/lib.rs:1240:5
             |
        1240 |     pub unsafe fn from_str_unchecked(repr: &str) -> Self {
             |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
             |
             = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc
             = note: `-W clippy::missing-safety-doc` implied by `-W clippy::all`
             = help: to override `-W clippy::all` add `#[allow(clippy::missing_safety_doc)]`
    dtolnay committed Sep 13, 2023

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    Copy the full SHA
    2e96778 View commit details
  2. Copy the full SHA
    14a481d View commit details
  3. Merge pull request #406 from dtolnay/error

    Parse rustc's representation of macro expansion error
    dtolnay authored Sep 13, 2023
    Copy the full SHA
    60c62dc View commit details
  4. Copy the full SHA
    8bf6937 View commit details
  5. Release 1.0.67

    dtolnay committed Sep 13, 2023
    Copy the full SHA
    a803dd1 View commit details
Showing with 27 additions and 20 deletions.
  1. +8 −10 .github/workflows/ci.yml
  2. +1 −1 Cargo.toml
  3. +1 −1 README.md
  4. +2 −2 fuzz/Cargo.toml
  5. +1 −1 fuzz/fuzz_targets/parse_token_stream.rs
  6. +5 −4 src/lib.rs
  7. +9 −1 src/parse.rs
18 changes: 8 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ jobs:
rust: [1.56.0, stable, beta]
timeout-minutes: 45
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{matrix.rust}}
@@ -51,7 +51,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: rust-src
@@ -82,7 +82,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- run: cargo generate-lockfile -Z minimal-versions
- run: cargo check --locked
@@ -94,7 +94,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
target: wasm32-unknown-unknown
@@ -108,7 +108,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: rust-src
@@ -118,18 +118,16 @@ jobs:
working-directory: fuzz
- uses: dtolnay/install@honggfuzz
- run: sudo apt-get install binutils-dev libunwind-dev
continue-on-error: true # https://github.com/dtolnay/proc-macro2/issues/387
- run: cargo hfuzz build --no-default-features --features honggfuzz
working-directory: fuzz
continue-on-error: true # https://github.com/dtolnay/proc-macro2/issues/387

clippy:
name: Clippy
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
timeout-minutes: 45
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: clippy, rust-src
@@ -143,7 +141,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@miri
- run: cargo miri setup
- run: cargo miri test
@@ -156,7 +154,7 @@ jobs:
if: github.event_name != 'pull_request'
timeout-minutes: 45
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/install@cargo-outdated
- run: cargo outdated --workspace --exit-code 1
- run: cargo outdated --manifest-path fuzz/Cargo.toml --exit-code 1
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "proc-macro2"
version = "1.0.66" # remember to update html_root_url
version = "1.0.67" # remember to update html_root_url
authors = ["David Tolnay <dtolnay@gmail.com>", "Alex Crichton <alex@alexcrichton.com>"]
autobenches = false
categories = ["development-tools::procedural-macro-helpers"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@ pub fn my_derive(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
If parsing with [Syn], you'll use [`parse_macro_input!`] instead to propagate
parse errors correctly back to the compiler when parsing fails.

[`parse_macro_input!`]: https://docs.rs/syn/1.0/syn/macro.parse_macro_input.html
[`parse_macro_input!`]: https://docs.rs/syn/2.0/syn/macro.parse_macro_input.html

## Unstable features

4 changes: 2 additions & 2 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -9,9 +9,9 @@ publish = false
cargo-fuzz = true

[dependencies]
afl = { version = "0.13", optional = true }
afl = { version = "0.14", optional = true }
honggfuzz = { version = "0.5", optional = true }
libfuzzer-sys = { version = "0.4", optional = true }
libfuzzer-sys = { version = "0.4.7", optional = true }
proc-macro2 = { path = "..", default-features = false }

[features]
2 changes: 1 addition & 1 deletion fuzz/fuzz_targets/parse_token_stream.rs
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ fn main() {
}

#[cfg(feature = "libfuzzer")]
libfuzzer_sys::fuzz_target!(|bytes: &[u8]| { do_fuzz(bytes) });
libfuzzer_sys::fuzz_target!(|bytes: &[u8]| do_fuzz(bytes));

#[cfg(feature = "afl")]
fn main() {
9 changes: 5 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@
//! If parsing with [Syn], you'll use [`parse_macro_input!`] instead to
//! propagate parse errors correctly back to the compiler when parsing fails.
//!
//! [`parse_macro_input!`]: https://docs.rs/syn/1.0/syn/macro.parse_macro_input.html
//! [`parse_macro_input!`]: https://docs.rs/syn/2.0/syn/macro.parse_macro_input.html
//!
//! # Unstable features
//!
@@ -86,7 +86,7 @@
//! a different thread.
// Proc-macro2 types in rustdoc of other crates get linked to here.
#![doc(html_root_url = "https://docs.rs/proc-macro2/1.0.66")]
#![doc(html_root_url = "https://docs.rs/proc-macro2/1.0.67")]
#![cfg_attr(any(proc_macro_span, super_unstable), feature(proc_macro_span))]
#![cfg_attr(super_unstable, feature(proc_macro_def_site))]
#![cfg_attr(doc_cfg, feature(doc_cfg))]
@@ -98,6 +98,7 @@
clippy::let_underscore_untyped,
clippy::manual_assert,
clippy::manual_range_contains,
clippy::missing_safety_doc,
clippy::must_use_candidate,
clippy::needless_doctest_main,
clippy::new_without_default,
@@ -852,7 +853,7 @@ impl Debug for Punct {
/// Rust keywords. Use `input.call(Ident::parse_any)` when parsing to match the
/// behaviour of `Ident::new`.
///
/// [`Parse`]: https://docs.rs/syn/1.0/syn/parse/trait.Parse.html
/// [`Parse`]: https://docs.rs/syn/2.0/syn/parse/trait.Parse.html
///
/// # Examples
///
@@ -943,7 +944,7 @@ impl Ident {
/// Panics if the input string is neither a keyword nor a legal variable
/// name. If you are not sure whether the string contains an identifier and
/// need to handle an error case, use
/// <a href="https://docs.rs/syn/1.0/syn/fn.parse_str.html"><code
/// <a href="https://docs.rs/syn/2.0/syn/fn.parse_str.html"><code
/// style="padding-right:0;">syn::parse_str</code></a><code
/// style="padding-left:0;">::&lt;Ident&gt;</code>
/// rather than `Ident::new`.
10 changes: 9 additions & 1 deletion src/parse.rs
Original file line number Diff line number Diff line change
@@ -161,6 +161,10 @@ fn word_break(input: Cursor) -> Result<Cursor, Reject> {
}
}

// Rustc's representation of a macro expansion error in expression position or
// type position.
const ERROR: &str = "(/*ERROR*/)";

pub(crate) fn token_stream(mut input: Cursor) -> Result<TokenStream, LexError> {
let mut trees = TokenStreamBuilder::new();
let mut stack = Vec::new();
@@ -192,7 +196,7 @@ pub(crate) fn token_stream(mut input: Cursor) -> Result<TokenStream, LexError> {
};

if let Some(open_delimiter) = match first {
b'(' => Some(Delimiter::Parenthesis),
b'(' if !input.starts_with(ERROR) => Some(Delimiter::Parenthesis),
b'[' => Some(Delimiter::Bracket),
b'{' => Some(Delimiter::Brace),
_ => None,
@@ -267,6 +271,10 @@ fn leaf_token(input: Cursor) -> PResult<TokenTree> {
Ok((input, TokenTree::Punct(p)))
} else if let Ok((input, i)) = ident(input) {
Ok((input, TokenTree::Ident(i)))
} else if input.starts_with(ERROR) {
let rest = input.advance(ERROR.len());
let repr = crate::Literal::_new_fallback(Literal::_new(ERROR.to_owned()));
Ok((rest, TokenTree::Literal(repr)))
} else {
Err(Reject)
}