Merge pull request #199 from dtolnay/bracket
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Handle parsing unseparated right angle brackets in generics
authored by David Tolnay · committed by GitHub · parents a5a98e0, fa70762 · Browse files · 2 files·+32 added−0 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+32 added−0 removed
- tests:+20 added−0 removed
- other:+12 added−0 removed
Provenance
- Commit
3f33b89- Tree
70c928c- Author
David Tolnay <dtolnay@gmail.com>- Committer
GitHub <noreply@github.com>- Parent 1
a5a98e0- Parent 2
fa70762
2 files changed+32 added−0 removed
modified:src/ensure.rs+12 added
317 unmodified lines318 (generic ($pop:ident $stack:tt) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($rangle:tt $($dup:tt)*) > $($rest:tt)*) => {319 $crate::__parse_ensure!($pop $stack $bail ($($fuel)*) {($($buf)* $rangle) $($parse)*} ($($rest)*) $($rest)*)320 };321 322+ (generic ($pop:ident $stack:tt) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} $dup:tt >> $($rest:tt)*) => {323+ $crate::__parse_ensure!($pop $stack $bail ($($fuel)*) {($($buf)* >) $($parse)*} (> $($rest)*) > $($rest)*)324+ };325+326 (generic $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} $dup:tt $lit:literal $($rest:tt)*) => {327 $crate::__parse_ensure!(arglist $stack $bail ($($fuel)*) {($($buf)* $lit) $($parse)*} ($($rest)*) $($rest)*)328 };329 12 unmodified lines342 (generic ($pop:ident $stack:tt) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} $dup:tt $ty:ty > $($rest:tt)*) => {343 $crate::__parse_ensure!($pop $stack $bail ($($fuel)*) {($($buf)* $ty >) $($parse)*} ($($rest)*) $($rest)*)344 };345 346+ (generic ($pop:ident $stack:tt) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} $dup:tt $ty:ty >> $($rest:tt)*) => {347+ $crate::__parse_ensure!($pop $stack $bail ($($fuel)*) {($($buf)* $ty >) $($parse)*} (> $($rest)*) > $($rest)*)348+ };349+350 (arglist $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($comma:tt $($dup:tt)*) , $($rest:tt)*) => {351 $crate::__parse_ensure!(generic $stack $bail ($($fuel)*) {($($buf)* $comma) $($parse)*} ($($rest)*) $($rest)*)352 };353 354 (arglist ($pop:ident $stack:tt) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($rangle:tt $($dup:tt)*) > $($rest:tt)*) => {355 $crate::__parse_ensure!($pop $stack $bail ($($fuel)*) {($($buf)* $rangle) $($parse)*} ($($rest)*) $($rest)*)356 };357 358+ (arglist ($pop:ident $stack:tt) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} $dup:tt >> $($rest:tt)*) => {359+ $crate::__parse_ensure!($pop $stack $bail ($($fuel)*) {($($buf)* >) $($parse)*} (> $($rest)*) > $($rest)*)360+ };361+362 // high precedence binary operators363 364 (atom $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($add:tt $($dup:tt)*) + $($rest:tt)*) => {365 $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $add) $($parse)*} ($($rest)*) $($rest)*)191 unmodified linesmodified:tests/test_ensure.rs+20 added
1 #![allow(2 clippy::diverging_sub_expression,3 clippy::if_same_then_else,4 clippy::ifs_same_cond,5+ clippy::items_after_statements,6 clippy::let_and_return,7 clippy::let_underscore_drop,8 clippy::match_bool,9 clippy::never_loop,309 unmodified lines319 assert_err(320 test,321 "Condition failed: `Chain::<'static>::new.t(1) == 2` (1 vs 2)",322 );323+324+ #[derive(PartialOrd, PartialEq, Debug)]325+ enum E<'a, T> {326+ #[allow(dead_code)]327+ T(&'a T),328+ U,329+ }330+331+ #[rustfmt::skip]332+ let test = || Ok(ensure!(E::U::<>>E::U::<u8>));333+ assert_err(test, "Condition failed: `E::U::<> > E::U::<u8>` (U vs U)");334+335+ #[rustfmt::skip]336+ let test = || Ok(ensure!(E::U::<u8>>E::U));337+ assert_err(test, "Condition failed: `E::U::<u8> > E::U` (U vs U)");338+339+ #[rustfmt::skip]340+ let test = || Ok(ensure!(E::U::<u8,>>E::U));341+ assert_err(test, "Condition failed: `E::U::<u8> > E::U` (U vs U)");342 }343 344 #[test]345 fn test_macro() {82 unmodified lines