{"action":"opened","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/21231","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/21231/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/21231/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/21231/events","html_url":"https://github.com/rust-lang/rust/issues/21231","id":54565821,"number":21231,"title":"Typechecking does not scale well for deeply nested types","user":{"login":"Marwes","id":957312,"avatar_url":"https://avatars.githubusercontent.com/u/957312?v=3","gravatar_id":"","url":"https://api.github.com/users/Marwes","html_url":"https://github.com/Marwes","followers_url":"https://api.github.com/users/Marwes/followers","following_url":"https://api.github.com/users/Marwes/following{/other_user}","gists_url":"https://api.github.com/users/Marwes/gists{/gist_id}","starred_url":"https://api.github.com/users/Marwes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Marwes/subscriptions","organizations_url":"https://api.github.com/users/Marwes/orgs","repos_url":"https://api.github.com/users/Marwes/repos","events_url":"https://api.github.com/users/Marwes/events{/privacy}","received_events_url":"https://api.github.com/users/Marwes/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-01-16T11:30:25Z","updated_at":"2015-01-16T11:30:25Z","closed_at":null,"body":"Currently trying to write a parser combinator library and ideally I would like to have everything statically dispatched which means that the types created can become very deeply nested. There are ways around this of course but I would still not expect the compiler to hang for so long. Sadly I can't come up with a nice small example since simply creating a generic struct (struct A<X, Y>(X, Y);) and nesting it deeply does not seem to be affected.\r\n\r\n56s 1138 characters long type\r\n```\r\nparser-combinators::parser::Map<parser-combinators::parser::Skip<parser-combinators::parser::With<parser-combinators::parser::StringP<'_, _>, parser-combinators::parser::Map<parser-combinators::parser::SepBy<parser-combinators::parser::And<parser-combinators::parser::Skip<parser-combinators::parser::Map<parser-combinators::parser::Skip<parser-combinators::parser::With<parser-combinators::parser::StringP<'_, _>, parser-combinators::parser::Chars<parser-combinators::parser::Satisfy<_, closure[main.rs:16:24: 16:70]>>>, parser-combinators::parser::StringP<'_, _>>, closure[main.rs:18:14: 18:31], collections::string::String>, parser-combinators::parser::StringP<'_, _>>, fn(parser-combinators::primitives::State<_>) -> core::result::Result<(Value, parser-combinators::primitives::State<_>), parser-combinators::primitives::ParseError>>, parser-combinators::parser::StringP<'_, _>>, closure[main.rs:23:14: 23:45], std::collections::hash::map::HashMap<collections::string::String, Value>>>, parser-combinators::parser::StringP<'_, _>>, fn(std::collections::hash::map::HashMap<collections::string::String, Value>) -> Value {Object}, Value>\r\n```\r\n200s 1264 characters long type (should just be one more type nested)\r\n```\r\nparser-combinators::parser::Map<parser-combinators::parser::Skip<parser-combinators::parser::With<parser-combinators::parser::StringP<'_, _>, parser-combinators::parser::Map<parser-combinators::parser::SepBy<parser-combinators::parser::And<parser-combinators::parser::Skip<parser-combinators::parser::Map<parser-combinators::parser::With<parser-combinators::parser::Many<parser-combinators::parser::Satisfy<_, fn(char) -> bool>>, parser-combinators::parser::Skip<parser-combinators::parser::With<parser-combinators::parser::StringP<'_, _>, parser-combinators::parser::Chars<parser-combinators::parser::Satisfy<_, closure[main.rs:17:24: 17:70]>>>, parser-combinators::parser::StringP<'_, _>>>, closure[main.rs:19:14: 19:31], collections::string::String>, parser-combinators::parser::StringP<'_, _>>, fn(parser-combinators::primitives::State<_>) -> core::result::Result<(Value, parser-combinators::primitives::State<_>), parser-combinators::primitives::ParseError>>, parser-combinators::parser::StringP<'_, _>>, closure[main.rs:24:14: 24:45], std::collections::hash::map::HashMap<collections::string::String, Value>>>, parser-combinators::parser::StringP<'_, _>>, fn(std::collections::hash::map::HashMap<collections::string::String, Value>) -> Value {Object}, Value>\r\n```\r\nCode compiled using https://github.com/Marwes/parser-combinators\r\n```\r\nextern crate \"parser-combinators\" as parser_combinators;\r\nuse parser_combinators::*;\r\nuse parser_combinators::primitives::{State, Stream};\r\nuse std::collections::HashMap;\r\n\r\nenum Value {\r\n    Number(f64),\r\n    String(String),\r\n    Bool(bool),\r\n    Null,\r\n    Object(HashMap<String, Value>),\r\n    Array(Vec<Value>)\r\n}\r\nfn value<I: Stream<Item=char>>(input: State<I>) -> ParseResult<Value, I> {\r\n    let char = satisfy(|c| \"\\\"\\\\\".chars().find(|x| *x == c).is_none());\r\n    let json_string = between(string(\"\\\"\"), string(\"\\\"\"), chars(char))\r\n        .map(|s| s.to_string());\r\n    let field = json_string\r\n        .skip(string(\":\"))\r\n        .and(value as fn (_) -> _);\r\n    let fields = sep_by(field, string(\",\"))\r\n        .map(|vec| vec.into_iter().collect());\r\n    let mut object: () = between(string(\"{\"), string(\"}\"), fields)\r\n        .map(Value::Object);\r\n    object\r\n        .parse_state(input)\r\n}\r\n\r\n\r\nfn main() {\r\n}\r\n```"}}