You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fnfoo(){{{{pubfnfile(state::: std :: boxed ::Box<:: pest ::ParserState<Rule>>) -> :: pest ::ParseResult<:: std :: boxed ::Box<:: pest ::ParserState<Rule>>>{ state .rule(Rule:: file , | state | { state .sequence(| state | {self::SOI(state).and_then(| state | {super:: hidden ::skip(state)}).and_then(| state | { state .sequence(| state | { state .optional(| state | { state .sequence(| state | { state .optional(| state | {self::A(state).or_else(| state | {self::B(state)})}).and_then(| state | {super:: hidden ::skip(state)}).and_then(| state | {self::NEWLINE(state)})}).and_then(| state | { state .repeat(| state | { state .sequence(| state | {super:: hidden ::skip(state).and_then(| state | { state .sequence(| state | { state .optional(| state | {self::A(state).or_else(| state | {self::B(state)})}).and_then(| state | {super:: hidden ::skip(state)}).and_then(| state | {self::NEWLINE(state)})})})})})})})})}).and_then(| state | {super:: hidden ::skip(state)}).and_then(| state | {self::EOI(state)})})})}}}}}
That takes about 80s to format on my system.
Here is the original code in full:
# ! [feature (prelude_import)]# [prelude_import]use std :: prelude :: rust_2021 ::*;# [macro_use]externcrate std ;externcrate pest ;# [macro_use]externcrate pest_derive ;# [grammar = "grm.pest"]pubstructMyParser;# [allow (non_upper_case_globals)]const _PEST_GRAMMAR_MyParser :&'staticstr = "A = { \"A\" }\nB = { \"B\" }\nfile = {\n SOI ~\n (( A | B )? ~ NEWLINE)* ~\n EOI\n}\n\n";# [allow (dead_code , non_camel_case_types , clippy :: upper_case_acronyms)]pubenumRule{EOI,A,B, file ,}# [automatically_derived]# [allow (dead_code , non_camel_case_types , clippy :: upper_case_acronyms)]impl:: core :: clone ::CloneforRule{# [inline]fnclone(&self) -> Rule{*self}}# [automatically_derived]# [allow (dead_code , non_camel_case_types , clippy :: upper_case_acronyms)]impl:: core :: marker ::CopyforRule{}# [automatically_derived]# [allow (dead_code , non_camel_case_types , clippy :: upper_case_acronyms)]impl:: core :: fmt ::DebugforRule{fnfmt(&self,f:&mut:: core :: fmt ::Formatter) -> :: core :: fmt ::Result{matchself{Rule::EOI => :: core :: fmt ::Formatter::write_str(f ,"EOI"),Rule::A => :: core :: fmt ::Formatter::write_str(f ,"A"),Rule::B => :: core :: fmt ::Formatter::write_str(f ,"B"),Rule:: file => :: core :: fmt ::Formatter::write_str(f ,"file"),}}}# [allow (dead_code , non_camel_case_types , clippy :: upper_case_acronyms)]impl:: core :: marker ::StructuralEqforRule{}# [automatically_derived]# [allow (dead_code , non_camel_case_types , clippy :: upper_case_acronyms)]impl:: core :: cmp ::EqforRule{# [inline]# [doc (hidden)]# [no_coverage]fnassert_receiver_is_total_eq(&self) -> (){}}# [automatically_derived]# [allow (dead_code , non_camel_case_types , clippy :: upper_case_acronyms)]impl:: core :: hash ::HashforRule{fnhash<__H::: core :: hash ::Hasher>(&self,state:&mut__H) -> (){let __self_tag = :: core :: intrinsics ::discriminant_value(self);:: core :: hash ::Hash::hash(& __self_tag , state)}}# [automatically_derived]# [allow (dead_code , non_camel_case_types , clippy :: upper_case_acronyms)]impl:: core :: cmp ::OrdforRule{# [inline]fncmp(&self,other:&Rule) -> :: core :: cmp ::Ordering{let __self_tag = :: core :: intrinsics ::discriminant_value(self);let __arg1_tag = :: core :: intrinsics ::discriminant_value(other);:: core :: cmp ::Ord::cmp(& __self_tag ,& __arg1_tag)}}# [allow (dead_code , non_camel_case_types , clippy :: upper_case_acronyms)]impl:: core :: marker ::StructuralPartialEqforRule{}# [automatically_derived]# [allow (dead_code , non_camel_case_types , clippy :: upper_case_acronyms)]impl:: core :: cmp ::PartialEqforRule{# [inline]fneq(&self,other:&Rule) -> bool{let __self_tag = :: core :: intrinsics ::discriminant_value(self);let __arg1_tag = :: core :: intrinsics ::discriminant_value(other); __self_tag == __arg1_tag }}# [automatically_derived]# [allow (dead_code , non_camel_case_types , clippy :: upper_case_acronyms)]impl:: core :: cmp ::PartialOrdforRule{# [inline]fnpartial_cmp(&self,other:&Rule) -> :: core :: option ::Option<:: core :: cmp ::Ordering>{let __self_tag = :: core :: intrinsics ::discriminant_value(self);let __arg1_tag = :: core :: intrinsics ::discriminant_value(other);:: core :: cmp ::PartialOrd::partial_cmp(& __self_tag ,& __arg1_tag)}}# [allow (clippy :: all)]impl:: pest ::Parser<Rule>forMyParser{fnparse<'i>(rule:Rule,input:&'istr) -> :: std :: result ::Result<:: pest :: iterators ::Pairs<'i,Rule>,:: pest :: error ::Error<Rule>>{mod rules {# ! [allow (clippy :: upper_case_acronyms)]pubmod hidden {usesuper::super::Rule;# [inline]# [allow (dead_code , non_snake_case , unused_variables)]pubfnskip(state::: std :: boxed ::Box<:: pest ::ParserState<Rule>>) -> :: pest ::ParseResult<:: std :: boxed ::Box<:: pest ::ParserState<Rule>>>{Ok(state)}}pubmod visible {usesuper::super::Rule;# [inline]# [allow (non_snake_case , unused_variables)]pubfnA(state::: std :: boxed ::Box<:: pest ::ParserState<Rule>>) -> :: pest ::ParseResult<:: std :: boxed ::Box<:: pest ::ParserState<Rule>>>{ state .rule(Rule::A, | state | { state .match_string("A")})}# [inline]# [allow (non_snake_case , unused_variables)]pubfnB(state::: std :: boxed ::Box<:: pest ::ParserState<Rule>>) -> :: pest ::ParseResult<:: std :: boxed ::Box<:: pest ::ParserState<Rule>>>{ state .rule(Rule::B, | state | { state .match_string("B")})}# [inline]# [allow (non_snake_case , unused_variables)]pubfnfile(state::: std :: boxed ::Box<:: pest ::ParserState<Rule>>) -> :: pest ::ParseResult<:: std :: boxed ::Box<:: pest ::ParserState<Rule>>>{ state .rule(Rule:: file , | state | { state .sequence(| state | {self::SOI(state).and_then(| state | {super:: hidden ::skip(state)}).and_then(| state | { state .sequence(| state | { state .optional(| state | { state .sequence(| state | { state .optional(| state | {self::A(state).or_else(| state | {self::B(state)})}).and_then(| state | {super:: hidden ::skip(state)}).and_then(| state | {self::NEWLINE(state)})}).and_then(| state | { state .repeat(| state | { state .sequence(| state | {super:: hidden ::skip(state).and_then(| state | { state .sequence(| state | { state .optional(| state | {self::A(state).or_else(| state | {self::B(state)})}).and_then(| state | {super:: hidden ::skip(state)}).and_then(| state | {self::NEWLINE(state)})})})})})})})})}).and_then(| state | {super:: hidden ::skip(state)}).and_then(| state | {self::EOI(state)})})})}# [inline]# [allow (dead_code , non_snake_case , unused_variables)]pubfnEOI(state::: std :: boxed ::Box<:: pest ::ParserState<Rule>>) -> :: pest ::ParseResult<:: std :: boxed ::Box<:: pest ::ParserState<Rule>>>{ state .rule(Rule::EOI, | state | state .end_of_input())}# [inline]# [allow (dead_code , non_snake_case , unused_variables)]pubfnSOI(state::: std :: boxed ::Box<:: pest ::ParserState<Rule>>) -> :: pest ::ParseResult<:: std :: boxed ::Box<:: pest ::ParserState<Rule>>>{ state .start_of_input()}# [inline]# [allow (dead_code , non_snake_case , unused_variables)]pubfnNEWLINE(state::: std :: boxed ::Box<:: pest ::ParserState<Rule>>) -> :: pest ::ParseResult<:: std :: boxed ::Box<:: pest ::ParserState<Rule>>>{ state .match_string("\n").or_else(| state | state .match_string("\r\n")).or_else(| state | state .match_string("\r"))}}pubuseself:: visible ::*;}:: pest ::state(input , | state | {match rule {Rule::A => rules ::A(state),Rule::B => rules ::B(state),Rule:: file => rules ::file(state),Rule::EOI => rules ::EOI(state),}})}}fnmain(){}
A user reported
rustfmt
hanging at dtolnay/cargo-expand#161.Here's a semi-reduced example:
That takes about 80s to format on my system.
Here is the original code in full:
And formatting that code looks like:
The text was updated successfully, but these errors were encountered: