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.21
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.22
Choose a head ref
  • 12 commits
  • 4 files changed
  • 1 contributor

Commits on Sep 25, 2020

  1. Verified

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

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

    Parse integer suffix beginning with a hex digit
    dtolnay authored Sep 25, 2020

    Verified

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

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

    This commit was signed with the committer’s verified signature. The key has expired.
    Copy the full SHA
    88ad48d View commit details
  6. Merge pull request #253 from dtolnay/lit

    Reject duplicate sign in float literal
    dtolnay authored Sep 25, 2020

    Verified

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

    This commit was signed with the committer’s verified signature. The key has expired.
    Copy the full SHA
    40bab5a View commit details
  8. Merge pull request #254 from dtolnay/lit

    Remove special case on f32/f64 suffix
    dtolnay authored Sep 25, 2020

    Verified

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

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

    This commit was signed with the committer’s verified signature. The key has expired.
    Copy the full SHA
    bdee769 View commit details
  11. Merge pull request #255 from dtolnay/lit

    Parse float suffix beginning with `E`
    dtolnay authored Sep 25, 2020

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    Copy the full SHA
    788d243 View commit details
  12. Release 1.0.22

    dtolnay committed Sep 25, 2020

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    Copy the full SHA
    92c9551 View commit details
Showing with 37 additions and 12 deletions.
  1. +1 −1 Cargo.toml
  2. +1 −1 src/lib.rs
  3. +31 −10 src/parse.rs
  4. +4 −0 tests/test.rs
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.21" # remember to update html_root_url
version = "1.0.22" # remember to update html_root_url
authors = ["Alex Crichton <alex@alexcrichton.com>", "David Tolnay <dtolnay@gmail.com>"]
license = "MIT OR Apache-2.0"
readme = "README.md"
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -78,7 +78,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.21")]
#![doc(html_root_url = "https://docs.rs/proc-macro2/1.0.22")]
#![cfg_attr(any(proc_macro_span, super_unstable), feature(proc_macro_span))]
#![cfg_attr(super_unstable, feature(proc_macro_raw_ident, proc_macro_def_site))]
#![allow(clippy::needless_doctest_main)]
41 changes: 31 additions & 10 deletions src/parse.rs
Original file line number Diff line number Diff line change
@@ -585,21 +585,30 @@ fn float_digits(input: Cursor) -> Result<Cursor, LexError> {
}
}

let rest = input.advance(len);
if !(has_dot || has_exp || rest.starts_with("f32") || rest.starts_with("f64")) {
if !(has_dot || has_exp) {
return Err(LexError);
}

if has_exp {
let token_before_exp = if has_dot {
Ok(input.advance(len - 1))
} else {
Err(LexError)
};
let mut has_sign = false;
let mut has_exp_value = false;
while let Some(&ch) = chars.peek() {
match ch {
'+' | '-' => {
if has_exp_value {
break;
}
if has_sign {
return token_before_exp;
}
chars.next();
len += 1;
has_sign = true;
}
'0'..='9' => {
chars.next();
@@ -614,7 +623,7 @@ fn float_digits(input: Cursor) -> Result<Cursor, LexError> {
}
}
if !has_exp_value {
return Err(LexError);
return token_before_exp;
}
}

@@ -648,10 +657,25 @@ fn digits(mut input: Cursor) -> Result<Cursor, LexError> {
let mut len = 0;
let mut empty = true;
for b in input.bytes() {
let digit = match b {
b'0'..=b'9' => (b - b'0') as u64,
b'a'..=b'f' => 10 + (b - b'a') as u64,
b'A'..=b'F' => 10 + (b - b'A') as u64,
match b {
b'0'..=b'9' => {
let digit = (b - b'0') as u64;
if digit >= base {
return Err(LexError);
}
}
b'a'..=b'f' => {
let digit = 10 + (b - b'a') as u64;
if digit >= base {
break;
}
}
b'A'..=b'F' => {
let digit = 10 + (b - b'A') as u64;
if digit >= base {
break;
}
}
b'_' => {
if empty && base == 10 {
return Err(LexError);
@@ -661,9 +685,6 @@ fn digits(mut input: Cursor) -> Result<Cursor, LexError> {
}
_ => break,
};
if digit >= base {
return Err(LexError);
}
len += 1;
empty = false;
}
4 changes: 4 additions & 0 deletions tests/test.rs
Original file line number Diff line number Diff line change
@@ -115,6 +115,10 @@ fn literal_suffix() {
assert_eq!(token_count("r#\"\"#r"), 1);
assert_eq!(token_count("'c'c"), 1);
assert_eq!(token_count("b'b'b"), 1);
assert_eq!(token_count("0E"), 1);
assert_eq!(token_count("0o0A"), 1);
assert_eq!(token_count("0E--0"), 4);
assert_eq!(token_count("0.0ECMA"), 1);
}

#[test]