Skip to content
Myr

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

2 files+32 added−0 removed

modified:src/ensure.rs+12 added
317 unmodified lines
318 (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 };321322 (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 };325326 (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 lines
342 (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 };345346 (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 };349350 (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 };353354 (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 };357358 (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 };361362 // high precedence binary operators363364 (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 lines
modified: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 lines
319 assert_err(320 test,321 "Condition failed: `Chain::<'static>::new.t(1) == 2` (1 vs 2)",322 );323324 #[derive(PartialOrd, PartialEq, Debug)]325 enum E<'a, T> {326 #[allow(dead_code)]327 T(&'a T),328 U,329 }330331 #[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)");334335 #[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)");338339 #[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}343344#[test]345fn test_macro() {
82 unmodified lines