Commit Graph

779 Commits

Author SHA1 Message Date
David Tolnay
e9a734c1b1
Ignore assertions_on_result_states clippy lint
error: called `assert!` with `Result::is_err`
      --> tests/comments.rs:68:5
       |
    68 |     assert!("/*/".parse::<TokenStream>().is_err());
       |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `"/*/".parse::<TokenStream>().unwrap_err()`
       |
       = note: `-D clippy::assertions-on-result-states` implied by `-D clippy::all`
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_result_states

    error: called `assert!` with `Result::is_ok`
       --> tests/test.rs:224:5
        |
    224 |     assert!("1".parse::<Literal>().is_ok());
        |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `"1".parse::<Literal>().unwrap()`
        |
        = note: `-D clippy::assertions-on-result-states` implied by `-D clippy::all`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_result_states

    error: called `assert!` with `Result::is_ok`
       --> tests/test.rs:225:5
        |
    225 |     assert!("-1".parse::<Literal>().is_ok());
        |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `"-1".parse::<Literal>().unwrap()`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_result_states

    error: called `assert!` with `Result::is_ok`
       --> tests/test.rs:226:5
        |
    226 |     assert!("-1u12".parse::<Literal>().is_ok());
        |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `"-1u12".parse::<Literal>().unwrap()`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_result_states

    error: called `assert!` with `Result::is_ok`
       --> tests/test.rs:227:5
        |
    227 |     assert!("1.0".parse::<Literal>().is_ok());
        |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `"1.0".parse::<Literal>().unwrap()`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_result_states

    error: called `assert!` with `Result::is_ok`
       --> tests/test.rs:228:5
        |
    228 |     assert!("-1.0".parse::<Literal>().is_ok());
        |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `"-1.0".parse::<Literal>().unwrap()`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_result_states

    error: called `assert!` with `Result::is_ok`
       --> tests/test.rs:229:5
        |
    229 |     assert!("-1.0f12".parse::<Literal>().is_ok());
        |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `"-1.0f12".parse::<Literal>().unwrap()`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_result_states

    error: called `assert!` with `Result::is_ok`
       --> tests/test.rs:230:5
        |
    230 |     assert!("'a'".parse::<Literal>().is_ok());
        |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `"'a'".parse::<Literal>().unwrap()`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_result_states

    error: called `assert!` with `Result::is_ok`
       --> tests/test.rs:231:5
        |
    231 |     assert!("\"\n\"".parse::<Literal>().is_ok());
        |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `"\"\n\"".parse::<Literal>().unwrap()`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_result_states

    error: called `assert!` with `Result::is_err`
       --> tests/test.rs:232:5
        |
    232 |     assert!("0 1".parse::<Literal>().is_err());
        |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `"0 1".parse::<Literal>().unwrap_err()`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_result_states

    error: called `assert!` with `Result::is_err`
       --> tests/test.rs:233:5
        |
    233 |     assert!(" 0".parse::<Literal>().is_err());
        |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `" 0".parse::<Literal>().unwrap_err()`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_result_states

    error: called `assert!` with `Result::is_err`
       --> tests/test.rs:234:5
        |
    234 |     assert!("0 ".parse::<Literal>().is_err());
        |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `"0 ".parse::<Literal>().unwrap_err()`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_result_states

    error: called `assert!` with `Result::is_err`
       --> tests/test.rs:235:5
        |
    235 |     assert!("/* comment */0".parse::<Literal>().is_err());
        |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `"/* comment */0".parse::<Literal>().unwrap_err()`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_result_states

    error: called `assert!` with `Result::is_err`
       --> tests/test.rs:236:5
        |
    236 |     assert!("0/* comment */".parse::<Literal>().is_err());
        |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `"0/* comment */".parse::<Literal>().unwrap_err()`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_result_states

    error: called `assert!` with `Result::is_err`
       --> tests/test.rs:237:5
        |
    237 |     assert!("0// comment".parse::<Literal>().is_err());
        |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `"0// comment".parse::<Literal>().unwrap_err()`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_result_states

    error: called `assert!` with `Result::is_err`
       --> tests/test.rs:238:5
        |
    238 |     assert!("- 1".parse::<Literal>().is_err());
        |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `"- 1".parse::<Literal>().unwrap_err()`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_result_states

    error: called `assert!` with `Result::is_err`
       --> tests/test.rs:239:5
        |
    239 |     assert!("- 1.0".parse::<Literal>().is_err());
        |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `"- 1.0".parse::<Literal>().unwrap_err()`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_result_states

    error: called `assert!` with `Result::is_err`
       --> tests/test.rs:240:5
        |
    240 |     assert!("-\"\"".parse::<Literal>().is_err());
        |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `"-\"\"".parse::<Literal>().unwrap_err()`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_result_states

    error: called `assert!` with `Result::is_err`
       --> tests/test.rs:385:5
        |
    385 |     assert!(s.parse::<TokenStream>().is_err());
        |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `s.parse::<TokenStream>().unwrap_err()`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_result_states
2022-07-29 22:06:04 -07:00
David Tolnay
a77588be7e
Release 1.0.42 2022-07-25 16:21:29 -07:00
David Tolnay
a2b46f9c3b
Remove allocation from RcVec -> RcVecBuilder conversion 2022-07-25 13:55:03 -07:00
David Tolnay
d8c056b7e7
Clean up RcVec::get_mut 2022-07-25 13:25:09 -07:00
David Tolnay
0fbcf3bc6c
Eliminate redundant RcVec::new 2022-07-25 13:24:42 -07:00
David Tolnay
20eb5ed1d7
Merge pull request #341 from dtolnay/rcvec
Replace Rc<Vec<T>> with RcVec<T>
2022-07-25 12:24:24 -07:00
David Tolnay
275aaeb76b
Replace Rc<Vec<T>> with RcVec<T> 2022-07-25 12:16:46 -07:00
David Tolnay
e338234ead
Merge pull request #342 from dtolnay/debug
Improve Debug representation of token_stream::IntoIter
2022-07-25 12:16:36 -07:00
David Tolnay
9d91c4979f
Improve Debug representation of token_stream::IntoIter 2022-07-25 12:08:52 -07:00
David Tolnay
ee0e583d46
Merge pull request #340 from dtolnay/extend
Reduce make_mut calls in FromIterator and Extend impls
2022-07-25 11:10:00 -07:00
David Tolnay
c5db3d6da6
Reduce make_mut calls in FromIterator and Extend impls 2022-07-25 11:06:47 -07:00
David Tolnay
f66898b7da
Merge pull request #339 from dtolnay/push
Rename the two different token push methods
2022-07-25 11:05:53 -07:00
David Tolnay
c39fd4c3c9
Rename the two different token push methods 2022-07-25 10:58:53 -07:00
David Tolnay
682d119f4e
Merge pull request #338 from dtolnay/builder
Remove Vec from API of fallback::TokenStream
2022-07-25 10:52:12 -07:00
David Tolnay
535675e13c
Remove Vec from API of fallback::TokenStream 2022-07-25 10:46:33 -07:00
David Tolnay
3b8d972bab
Merge pull request #337 from dtolnay/doccomment
Eliminate a Vec alloc from doc comment parsing
2022-07-25 10:46:24 -07:00
David Tolnay
25eb2fbdce
Eliminate a Vec alloc from doc comment parsing 2022-07-25 10:42:22 -07:00
David Tolnay
09947f2e7f
Merge pull request #335 from dtolnay/rc
Reference count TokenStream in fallback mode
2022-07-25 00:05:12 -07:00
David Tolnay
6c66d8acd6
Reference count TokenStream in fallback mode 2022-07-24 23:47:00 -07:00
David Tolnay
67778bc3d2
Release 1.0.41 2022-07-24 21:45:15 -07:00
David Tolnay
6a3515559b
Merge pull request #334 from dtolnay/sizehint
Expose size_hint() for TokenStream's iterator
2022-07-24 21:44:31 -07:00
David Tolnay
25a20e0671
Expose size_hint() for TokenStream's iterator 2022-07-24 21:34:18 -07:00
David Tolnay
f4273659a2
Add test of ineffective TokenStream size_hint 2022-07-24 21:34:03 -07:00
David Tolnay
6ed82b0b83
Fix typo in nika XXX comment 2022-07-20 13:54:48 -07:00
David Tolnay
e4ed201c04
Fix rountrips typo in several places 2022-07-20 13:52:59 -07:00
David Tolnay
e6bc873948
Release 1.0.40 2022-06-19 18:40:49 -07:00
David Tolnay
10a20e0872
Copy Ident::new_raw comment from proc_macro 2022-06-19 18:40:25 -07:00
David Tolnay
c08b24a02a
Touch up new_raw workaround comment
This comment was copied verbatim from quote but that code was
substantially different. They started with a string _including_ the r#
prefix, and then used &id[2..] to obtain an unraw version of it, which
is what "unraw" in the comment refers to. The code in proc-macro2 is
doing the opposite.
2022-06-19 18:36:41 -07:00
David Tolnay
3191e5e3f4
Show r# in another raw identifier panic 2022-06-19 18:28:03 -07:00
David Tolnay
0de81dab0f
Include r# in the invalid raw identifier panic
This is how quote's implementation did it prior to https://github.com/dtolnay/quote/pull/225.
2022-06-19 18:23:12 -07:00
David Tolnay
9a4f130f4e
Avoid having most of the new_raw test be unreachable code 2022-06-19 18:21:24 -07:00
David Tolnay
c1d32cef31
Merge pull request #333 from dtolnay/validate
Delete unreachable cases from raw identifier check
2022-06-19 18:20:01 -07:00
David Tolnay
4be2a86fce
Delete unreachable cases from raw identifier check
"" is ruled out by the check for `if string.is_empty()` at the top.
"$crate" and "{{root}}" are ruled out because their first character does
not pass `is_ident_start`.
2022-06-19 18:15:36 -07:00
David Tolnay
d9184771a4
Remove validate var
Not sure why this is here. Maybe it used to need to be mutated in an old
incarnation of this code.
2022-06-19 18:14:32 -07:00
David Tolnay
83ed7b8642
Merge pull request #332 from dtolnay/validate
Move raw ident validate into validate_ident
2022-06-19 18:11:47 -07:00
David Tolnay
868a8ea2d9
Restore compatibility with rustc older than 1.33
error[E0658]: multiple patterns in `if let` and `while let` are unstable (see issue #48215)
       --> src/fallback.rs:704:9
        |
    704 | /         if let "" | "_" | "super" | "self" | "Self" | "crate" | "$crate" | "{{root}}" = string {
    705 | |             panic!("`{}` cannot be a raw identifier", string);
    706 | |         }
        | |_________^
2022-06-19 18:08:24 -07:00
David Tolnay
e04304ffa3
Move raw ident validate into validate_ident 2022-06-19 18:04:40 -07:00
David Tolnay
8b3a2dd476
Format with rustfmt 1.5.0 2022-06-19 18:04:11 -07:00
David Tolnay
32a0b27e16
Merge pull request #331 from mystor/ident_new_raw
Mark Ident::new_raw as no longer semver-exempt
2022-06-19 17:57:32 -07:00
Nika Layzell
0e97a926c5 Reject invalid raw identifiers in the fallback 2022-06-19 20:03:02 -04:00
Nika Layzell
2ecccd0fc3 Mark Ident::new_raw as no longer semver-exempt
The previous Compiler behaviour appears to have been broken, in that it
would return a non-raw string literal, so it was replaced with the
fallback code from quote [1].

[1]: eeabf0d42e/src/runtime.rs (L409-L422)
2022-06-19 19:54:19 -04:00
David Tolnay
11dea16ad8
Use upstreamed docs.rs icon in docs.rs badge 2022-06-11 10:15:58 -07:00
David Tolnay
4b24b6e879
Check all crates in workspace for outdated deps 2022-06-06 14:39:23 -07:00
David Tolnay
6e59fa0959
Release 1.0.39 2022-05-16 15:30:03 -07:00
David Tolnay
aec2129b9f
Replace unicode-xid with unicode-ident crate 2022-05-16 15:27:01 -07:00
David Tolnay
8649302c7e
Run miri in stricter miri-strict-provenance mode 2022-05-06 04:01:33 -07:00
David Tolnay
b501cdf2f4
Release 1.0.38 2022-05-05 21:45:55 -07:00
David Tolnay
4445659b0f
Merge pull request #328 from dtolnay/formatpushstring
Eliminate an allocation from Literal::byte_string
2022-05-05 21:43:35 -07:00
David Tolnay
d307f5650a
Restore support for rust pre-1.33
error[E0658]: renaming imports with `_` is unstable (see issue 48216)
     --> src/fallback.rs:7:38
      |
    7 | use std::fmt::{self, Debug, Display, Write as _};
      |                                      ^^^^^^^^^^
2022-05-05 21:39:23 -07:00
David Tolnay
16c4bb476c
Eliminate an allocation from Literal::byte_string
error: `format!(..)` appended to existing `String`
       --> src/fallback.rs:879:22
        |
    879 |                 _ => escaped.push_str(&format!("\\x{:02X}", b)),
        |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: `-D clippy::format-push-string` implied by `-D clippy::all`
        = help: consider using `write!` to avoid the extra allocation
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#format_push_string
2022-05-05 21:35:00 -07:00