aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r--crates/ra_syntax/src/algo.rs8
-rw-r--r--crates/ra_syntax/src/ast.rs6
-rw-r--r--crates/ra_syntax/src/ast/generated/nodes.rs276
-rw-r--r--crates/ra_syntax/src/ast/generated/tokens.rs8
-rw-r--r--crates/ra_syntax/src/ast/tokens.rs10
-rw-r--r--crates/ra_syntax/src/lib.rs3
-rw-r--r--crates/ra_syntax/src/parsing/text_token_source.rs89
7 files changed, 206 insertions, 194 deletions
diff --git a/crates/ra_syntax/src/algo.rs b/crates/ra_syntax/src/algo.rs
index 664894d1f..f7a885eb3 100644
--- a/crates/ra_syntax/src/algo.rs
+++ b/crates/ra_syntax/src/algo.rs
@@ -290,6 +290,11 @@ impl<'a> SyntaxRewriter<'a> {
290 N::cast(self.rewrite(node.syntax())).unwrap() 290 N::cast(self.rewrite(node.syntax())).unwrap()
291 } 291 }
292 292
293 /// Returns a node that encompasses all replacements to be done by this rewriter.
294 ///
295 /// Passing the returned node to `rewrite` will apply all replacements queued up in `self`.
296 ///
297 /// Returns `None` when there are no replacements.
293 pub fn rewrite_root(&self) -> Option<SyntaxNode> { 298 pub fn rewrite_root(&self) -> Option<SyntaxNode> {
294 assert!(self.f.is_none()); 299 assert!(self.f.is_none());
295 self.replacements 300 self.replacements
@@ -298,6 +303,9 @@ impl<'a> SyntaxRewriter<'a> {
298 SyntaxElement::Node(it) => it.clone(), 303 SyntaxElement::Node(it) => it.clone(),
299 SyntaxElement::Token(it) => it.parent(), 304 SyntaxElement::Token(it) => it.parent(),
300 }) 305 })
306 // If we only have one replacement, we must return its parent node, since `rewrite` does
307 // not replace the node passed to it.
308 .map(|it| it.parent().unwrap_or(it))
301 .fold1(|a, b| least_common_ancestor(&a, &b).unwrap()) 309 .fold1(|a, b| least_common_ancestor(&a, &b).unwrap())
302 } 310 }
303 311
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs
index eddc807d5..9d02aeef3 100644
--- a/crates/ra_syntax/src/ast.rs
+++ b/crates/ra_syntax/src/ast.rs
@@ -285,6 +285,8 @@ where
285 let pred = predicates.next().unwrap(); 285 let pred = predicates.next().unwrap();
286 let mut bounds = pred.type_bound_list().unwrap().bounds(); 286 let mut bounds = pred.type_bound_list().unwrap().bounds();
287 287
288 assert!(pred.for_token().is_none());
289 assert!(pred.type_param_list().is_none());
288 assert_eq!("T", pred.type_ref().unwrap().syntax().text().to_string()); 290 assert_eq!("T", pred.type_ref().unwrap().syntax().text().to_string());
289 assert_bound("Clone", bounds.next()); 291 assert_bound("Clone", bounds.next());
290 assert_bound("Copy", bounds.next()); 292 assert_bound("Copy", bounds.next());
@@ -322,6 +324,8 @@ where
322 let pred = predicates.next().unwrap(); 324 let pred = predicates.next().unwrap();
323 let mut bounds = pred.type_bound_list().unwrap().bounds(); 325 let mut bounds = pred.type_bound_list().unwrap().bounds();
324 326
325 assert_eq!("for<'a> F", pred.type_ref().unwrap().syntax().text().to_string()); 327 assert!(pred.for_token().is_some());
328 assert_eq!("<'a>", pred.type_param_list().unwrap().syntax().text().to_string());
329 assert_eq!("F", pred.type_ref().unwrap().syntax().text().to_string());
326 assert_bound("Fn(&'a str)", bounds.next()); 330 assert_bound("Fn(&'a str)", bounds.next());
327} 331}
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs
index cb430ca01..58141da11 100644
--- a/crates/ra_syntax/src/ast/generated/nodes.rs
+++ b/crates/ra_syntax/src/ast/generated/nodes.rs
@@ -2052,6 +2052,8 @@ pub struct WherePred {
2052} 2052}
2053impl ast::TypeBoundsOwner for WherePred {} 2053impl ast::TypeBoundsOwner for WherePred {}
2054impl WherePred { 2054impl WherePred {
2055 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }
2056 pub fn type_param_list(&self) -> Option<TypeParamList> { support::child(&self.syntax) }
2055 pub fn lifetime_token(&self) -> Option<SyntaxToken> { 2057 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
2056 support::token(&self.syntax, T![lifetime]) 2058 support::token(&self.syntax, T![lifetime])
2057 } 2059 }
@@ -4849,687 +4851,687 @@ impl AstNode for FieldDefList {
4849 } 4851 }
4850} 4852}
4851impl std::fmt::Display for NominalDef { 4853impl std::fmt::Display for NominalDef {
4852 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 4854 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4853 std::fmt::Display::fmt(self.syntax(), f) 4855 std::fmt::Display::fmt(self.syntax(), f)
4854 } 4856 }
4855} 4857}
4856impl std::fmt::Display for GenericParam { 4858impl std::fmt::Display for GenericParam {
4857 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 4859 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4858 std::fmt::Display::fmt(self.syntax(), f) 4860 std::fmt::Display::fmt(self.syntax(), f)
4859 } 4861 }
4860} 4862}
4861impl std::fmt::Display for GenericArg { 4863impl std::fmt::Display for GenericArg {
4862 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 4864 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4863 std::fmt::Display::fmt(self.syntax(), f) 4865 std::fmt::Display::fmt(self.syntax(), f)
4864 } 4866 }
4865} 4867}
4866impl std::fmt::Display for TypeRef { 4868impl std::fmt::Display for TypeRef {
4867 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 4869 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4868 std::fmt::Display::fmt(self.syntax(), f) 4870 std::fmt::Display::fmt(self.syntax(), f)
4869 } 4871 }
4870} 4872}
4871impl std::fmt::Display for ModuleItem { 4873impl std::fmt::Display for ModuleItem {
4872 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 4874 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4873 std::fmt::Display::fmt(self.syntax(), f) 4875 std::fmt::Display::fmt(self.syntax(), f)
4874 } 4876 }
4875} 4877}
4876impl std::fmt::Display for AssocItem { 4878impl std::fmt::Display for AssocItem {
4877 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 4879 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4878 std::fmt::Display::fmt(self.syntax(), f) 4880 std::fmt::Display::fmt(self.syntax(), f)
4879 } 4881 }
4880} 4882}
4881impl std::fmt::Display for ExternItem { 4883impl std::fmt::Display for ExternItem {
4882 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 4884 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4883 std::fmt::Display::fmt(self.syntax(), f) 4885 std::fmt::Display::fmt(self.syntax(), f)
4884 } 4886 }
4885} 4887}
4886impl std::fmt::Display for Expr { 4888impl std::fmt::Display for Expr {
4887 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 4889 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4888 std::fmt::Display::fmt(self.syntax(), f) 4890 std::fmt::Display::fmt(self.syntax(), f)
4889 } 4891 }
4890} 4892}
4891impl std::fmt::Display for Pat { 4893impl std::fmt::Display for Pat {
4892 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 4894 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4893 std::fmt::Display::fmt(self.syntax(), f) 4895 std::fmt::Display::fmt(self.syntax(), f)
4894 } 4896 }
4895} 4897}
4896impl std::fmt::Display for RecordInnerPat { 4898impl std::fmt::Display for RecordInnerPat {
4897 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 4899 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4898 std::fmt::Display::fmt(self.syntax(), f) 4900 std::fmt::Display::fmt(self.syntax(), f)
4899 } 4901 }
4900} 4902}
4901impl std::fmt::Display for AttrInput { 4903impl std::fmt::Display for AttrInput {
4902 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 4904 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4903 std::fmt::Display::fmt(self.syntax(), f) 4905 std::fmt::Display::fmt(self.syntax(), f)
4904 } 4906 }
4905} 4907}
4906impl std::fmt::Display for Stmt { 4908impl std::fmt::Display for Stmt {
4907 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 4909 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4908 std::fmt::Display::fmt(self.syntax(), f) 4910 std::fmt::Display::fmt(self.syntax(), f)
4909 } 4911 }
4910} 4912}
4911impl std::fmt::Display for FieldDefList { 4913impl std::fmt::Display for FieldDefList {
4912 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 4914 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4913 std::fmt::Display::fmt(self.syntax(), f) 4915 std::fmt::Display::fmt(self.syntax(), f)
4914 } 4916 }
4915} 4917}
4916impl std::fmt::Display for SourceFile { 4918impl std::fmt::Display for SourceFile {
4917 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 4919 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4918 std::fmt::Display::fmt(self.syntax(), f) 4920 std::fmt::Display::fmt(self.syntax(), f)
4919 } 4921 }
4920} 4922}
4921impl std::fmt::Display for FnDef { 4923impl std::fmt::Display for FnDef {
4922 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 4924 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4923 std::fmt::Display::fmt(self.syntax(), f) 4925 std::fmt::Display::fmt(self.syntax(), f)
4924 } 4926 }
4925} 4927}
4926impl std::fmt::Display for RetType { 4928impl std::fmt::Display for RetType {
4927 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 4929 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4928 std::fmt::Display::fmt(self.syntax(), f) 4930 std::fmt::Display::fmt(self.syntax(), f)
4929 } 4931 }
4930} 4932}
4931impl std::fmt::Display for StructDef { 4933impl std::fmt::Display for StructDef {
4932 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 4934 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4933 std::fmt::Display::fmt(self.syntax(), f) 4935 std::fmt::Display::fmt(self.syntax(), f)
4934 } 4936 }
4935} 4937}
4936impl std::fmt::Display for UnionDef { 4938impl std::fmt::Display for UnionDef {
4937 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 4939 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4938 std::fmt::Display::fmt(self.syntax(), f) 4940 std::fmt::Display::fmt(self.syntax(), f)
4939 } 4941 }
4940} 4942}
4941impl std::fmt::Display for RecordFieldDefList { 4943impl std::fmt::Display for RecordFieldDefList {
4942 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 4944 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4943 std::fmt::Display::fmt(self.syntax(), f) 4945 std::fmt::Display::fmt(self.syntax(), f)
4944 } 4946 }
4945} 4947}
4946impl std::fmt::Display for RecordFieldDef { 4948impl std::fmt::Display for RecordFieldDef {
4947 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 4949 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4948 std::fmt::Display::fmt(self.syntax(), f) 4950 std::fmt::Display::fmt(self.syntax(), f)
4949 } 4951 }
4950} 4952}
4951impl std::fmt::Display for TupleFieldDefList { 4953impl std::fmt::Display for TupleFieldDefList {
4952 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 4954 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4953 std::fmt::Display::fmt(self.syntax(), f) 4955 std::fmt::Display::fmt(self.syntax(), f)
4954 } 4956 }
4955} 4957}
4956impl std::fmt::Display for TupleFieldDef { 4958impl std::fmt::Display for TupleFieldDef {
4957 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 4959 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4958 std::fmt::Display::fmt(self.syntax(), f) 4960 std::fmt::Display::fmt(self.syntax(), f)
4959 } 4961 }
4960} 4962}
4961impl std::fmt::Display for EnumDef { 4963impl std::fmt::Display for EnumDef {
4962 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 4964 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4963 std::fmt::Display::fmt(self.syntax(), f) 4965 std::fmt::Display::fmt(self.syntax(), f)
4964 } 4966 }
4965} 4967}
4966impl std::fmt::Display for EnumVariantList { 4968impl std::fmt::Display for EnumVariantList {
4967 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 4969 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4968 std::fmt::Display::fmt(self.syntax(), f) 4970 std::fmt::Display::fmt(self.syntax(), f)
4969 } 4971 }
4970} 4972}
4971impl std::fmt::Display for EnumVariant { 4973impl std::fmt::Display for EnumVariant {
4972 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 4974 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4973 std::fmt::Display::fmt(self.syntax(), f) 4975 std::fmt::Display::fmt(self.syntax(), f)
4974 } 4976 }
4975} 4977}
4976impl std::fmt::Display for TraitDef { 4978impl std::fmt::Display for TraitDef {
4977 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 4979 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4978 std::fmt::Display::fmt(self.syntax(), f) 4980 std::fmt::Display::fmt(self.syntax(), f)
4979 } 4981 }
4980} 4982}
4981impl std::fmt::Display for Module { 4983impl std::fmt::Display for Module {
4982 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 4984 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4983 std::fmt::Display::fmt(self.syntax(), f) 4985 std::fmt::Display::fmt(self.syntax(), f)
4984 } 4986 }
4985} 4987}
4986impl std::fmt::Display for ItemList { 4988impl std::fmt::Display for ItemList {
4987 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 4989 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4988 std::fmt::Display::fmt(self.syntax(), f) 4990 std::fmt::Display::fmt(self.syntax(), f)
4989 } 4991 }
4990} 4992}
4991impl std::fmt::Display for ConstDef { 4993impl std::fmt::Display for ConstDef {
4992 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 4994 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4993 std::fmt::Display::fmt(self.syntax(), f) 4995 std::fmt::Display::fmt(self.syntax(), f)
4994 } 4996 }
4995} 4997}
4996impl std::fmt::Display for StaticDef { 4998impl std::fmt::Display for StaticDef {
4997 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 4999 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4998 std::fmt::Display::fmt(self.syntax(), f) 5000 std::fmt::Display::fmt(self.syntax(), f)
4999 } 5001 }
5000} 5002}
5001impl std::fmt::Display for TypeAliasDef { 5003impl std::fmt::Display for TypeAliasDef {
5002 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5004 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5003 std::fmt::Display::fmt(self.syntax(), f) 5005 std::fmt::Display::fmt(self.syntax(), f)
5004 } 5006 }
5005} 5007}
5006impl std::fmt::Display for ImplDef { 5008impl std::fmt::Display for ImplDef {
5007 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5009 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5008 std::fmt::Display::fmt(self.syntax(), f) 5010 std::fmt::Display::fmt(self.syntax(), f)
5009 } 5011 }
5010} 5012}
5011impl std::fmt::Display for ParenType { 5013impl std::fmt::Display for ParenType {
5012 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5014 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5013 std::fmt::Display::fmt(self.syntax(), f) 5015 std::fmt::Display::fmt(self.syntax(), f)
5014 } 5016 }
5015} 5017}
5016impl std::fmt::Display for TupleType { 5018impl std::fmt::Display for TupleType {
5017 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5019 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5018 std::fmt::Display::fmt(self.syntax(), f) 5020 std::fmt::Display::fmt(self.syntax(), f)
5019 } 5021 }
5020} 5022}
5021impl std::fmt::Display for NeverType { 5023impl std::fmt::Display for NeverType {
5022 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5024 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5023 std::fmt::Display::fmt(self.syntax(), f) 5025 std::fmt::Display::fmt(self.syntax(), f)
5024 } 5026 }
5025} 5027}
5026impl std::fmt::Display for PathType { 5028impl std::fmt::Display for PathType {
5027 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5029 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5028 std::fmt::Display::fmt(self.syntax(), f) 5030 std::fmt::Display::fmt(self.syntax(), f)
5029 } 5031 }
5030} 5032}
5031impl std::fmt::Display for PointerType { 5033impl std::fmt::Display for PointerType {
5032 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5034 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5033 std::fmt::Display::fmt(self.syntax(), f) 5035 std::fmt::Display::fmt(self.syntax(), f)
5034 } 5036 }
5035} 5037}
5036impl std::fmt::Display for ArrayType { 5038impl std::fmt::Display for ArrayType {
5037 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5039 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5038 std::fmt::Display::fmt(self.syntax(), f) 5040 std::fmt::Display::fmt(self.syntax(), f)
5039 } 5041 }
5040} 5042}
5041impl std::fmt::Display for SliceType { 5043impl std::fmt::Display for SliceType {
5042 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5044 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5043 std::fmt::Display::fmt(self.syntax(), f) 5045 std::fmt::Display::fmt(self.syntax(), f)
5044 } 5046 }
5045} 5047}
5046impl std::fmt::Display for ReferenceType { 5048impl std::fmt::Display for ReferenceType {
5047 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5049 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5048 std::fmt::Display::fmt(self.syntax(), f) 5050 std::fmt::Display::fmt(self.syntax(), f)
5049 } 5051 }
5050} 5052}
5051impl std::fmt::Display for PlaceholderType { 5053impl std::fmt::Display for PlaceholderType {
5052 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5054 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5053 std::fmt::Display::fmt(self.syntax(), f) 5055 std::fmt::Display::fmt(self.syntax(), f)
5054 } 5056 }
5055} 5057}
5056impl std::fmt::Display for FnPointerType { 5058impl std::fmt::Display for FnPointerType {
5057 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5059 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5058 std::fmt::Display::fmt(self.syntax(), f) 5060 std::fmt::Display::fmt(self.syntax(), f)
5059 } 5061 }
5060} 5062}
5061impl std::fmt::Display for ForType { 5063impl std::fmt::Display for ForType {
5062 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5064 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5063 std::fmt::Display::fmt(self.syntax(), f) 5065 std::fmt::Display::fmt(self.syntax(), f)
5064 } 5066 }
5065} 5067}
5066impl std::fmt::Display for ImplTraitType { 5068impl std::fmt::Display for ImplTraitType {
5067 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5069 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5068 std::fmt::Display::fmt(self.syntax(), f) 5070 std::fmt::Display::fmt(self.syntax(), f)
5069 } 5071 }
5070} 5072}
5071impl std::fmt::Display for DynTraitType { 5073impl std::fmt::Display for DynTraitType {
5072 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5074 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5073 std::fmt::Display::fmt(self.syntax(), f) 5075 std::fmt::Display::fmt(self.syntax(), f)
5074 } 5076 }
5075} 5077}
5076impl std::fmt::Display for TupleExpr { 5078impl std::fmt::Display for TupleExpr {
5077 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5079 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5078 std::fmt::Display::fmt(self.syntax(), f) 5080 std::fmt::Display::fmt(self.syntax(), f)
5079 } 5081 }
5080} 5082}
5081impl std::fmt::Display for ArrayExpr { 5083impl std::fmt::Display for ArrayExpr {
5082 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5084 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5083 std::fmt::Display::fmt(self.syntax(), f) 5085 std::fmt::Display::fmt(self.syntax(), f)
5084 } 5086 }
5085} 5087}
5086impl std::fmt::Display for ParenExpr { 5088impl std::fmt::Display for ParenExpr {
5087 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5089 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5088 std::fmt::Display::fmt(self.syntax(), f) 5090 std::fmt::Display::fmt(self.syntax(), f)
5089 } 5091 }
5090} 5092}
5091impl std::fmt::Display for PathExpr { 5093impl std::fmt::Display for PathExpr {
5092 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5094 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5093 std::fmt::Display::fmt(self.syntax(), f) 5095 std::fmt::Display::fmt(self.syntax(), f)
5094 } 5096 }
5095} 5097}
5096impl std::fmt::Display for LambdaExpr { 5098impl std::fmt::Display for LambdaExpr {
5097 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5099 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5098 std::fmt::Display::fmt(self.syntax(), f) 5100 std::fmt::Display::fmt(self.syntax(), f)
5099 } 5101 }
5100} 5102}
5101impl std::fmt::Display for IfExpr { 5103impl std::fmt::Display for IfExpr {
5102 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5104 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5103 std::fmt::Display::fmt(self.syntax(), f) 5105 std::fmt::Display::fmt(self.syntax(), f)
5104 } 5106 }
5105} 5107}
5106impl std::fmt::Display for LoopExpr { 5108impl std::fmt::Display for LoopExpr {
5107 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5109 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5108 std::fmt::Display::fmt(self.syntax(), f) 5110 std::fmt::Display::fmt(self.syntax(), f)
5109 } 5111 }
5110} 5112}
5111impl std::fmt::Display for EffectExpr { 5113impl std::fmt::Display for EffectExpr {
5112 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5114 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5113 std::fmt::Display::fmt(self.syntax(), f) 5115 std::fmt::Display::fmt(self.syntax(), f)
5114 } 5116 }
5115} 5117}
5116impl std::fmt::Display for ForExpr { 5118impl std::fmt::Display for ForExpr {
5117 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5119 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5118 std::fmt::Display::fmt(self.syntax(), f) 5120 std::fmt::Display::fmt(self.syntax(), f)
5119 } 5121 }
5120} 5122}
5121impl std::fmt::Display for WhileExpr { 5123impl std::fmt::Display for WhileExpr {
5122 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5124 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5123 std::fmt::Display::fmt(self.syntax(), f) 5125 std::fmt::Display::fmt(self.syntax(), f)
5124 } 5126 }
5125} 5127}
5126impl std::fmt::Display for ContinueExpr { 5128impl std::fmt::Display for ContinueExpr {
5127 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5129 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5128 std::fmt::Display::fmt(self.syntax(), f) 5130 std::fmt::Display::fmt(self.syntax(), f)
5129 } 5131 }
5130} 5132}
5131impl std::fmt::Display for BreakExpr { 5133impl std::fmt::Display for BreakExpr {
5132 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5134 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5133 std::fmt::Display::fmt(self.syntax(), f) 5135 std::fmt::Display::fmt(self.syntax(), f)
5134 } 5136 }
5135} 5137}
5136impl std::fmt::Display for Label { 5138impl std::fmt::Display for Label {
5137 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5139 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5138 std::fmt::Display::fmt(self.syntax(), f) 5140 std::fmt::Display::fmt(self.syntax(), f)
5139 } 5141 }
5140} 5142}
5141impl std::fmt::Display for BlockExpr { 5143impl std::fmt::Display for BlockExpr {
5142 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5144 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5143 std::fmt::Display::fmt(self.syntax(), f) 5145 std::fmt::Display::fmt(self.syntax(), f)
5144 } 5146 }
5145} 5147}
5146impl std::fmt::Display for ReturnExpr { 5148impl std::fmt::Display for ReturnExpr {
5147 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5149 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5148 std::fmt::Display::fmt(self.syntax(), f) 5150 std::fmt::Display::fmt(self.syntax(), f)
5149 } 5151 }
5150} 5152}
5151impl std::fmt::Display for CallExpr { 5153impl std::fmt::Display for CallExpr {
5152 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5154 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5153 std::fmt::Display::fmt(self.syntax(), f) 5155 std::fmt::Display::fmt(self.syntax(), f)
5154 } 5156 }
5155} 5157}
5156impl std::fmt::Display for MethodCallExpr { 5158impl std::fmt::Display for MethodCallExpr {
5157 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5159 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5158 std::fmt::Display::fmt(self.syntax(), f) 5160 std::fmt::Display::fmt(self.syntax(), f)
5159 } 5161 }
5160} 5162}
5161impl std::fmt::Display for IndexExpr { 5163impl std::fmt::Display for IndexExpr {
5162 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5164 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5163 std::fmt::Display::fmt(self.syntax(), f) 5165 std::fmt::Display::fmt(self.syntax(), f)
5164 } 5166 }
5165} 5167}
5166impl std::fmt::Display for FieldExpr { 5168impl std::fmt::Display for FieldExpr {
5167 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5169 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5168 std::fmt::Display::fmt(self.syntax(), f) 5170 std::fmt::Display::fmt(self.syntax(), f)
5169 } 5171 }
5170} 5172}
5171impl std::fmt::Display for AwaitExpr { 5173impl std::fmt::Display for AwaitExpr {
5172 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5174 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5173 std::fmt::Display::fmt(self.syntax(), f) 5175 std::fmt::Display::fmt(self.syntax(), f)
5174 } 5176 }
5175} 5177}
5176impl std::fmt::Display for TryExpr { 5178impl std::fmt::Display for TryExpr {
5177 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5179 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5178 std::fmt::Display::fmt(self.syntax(), f) 5180 std::fmt::Display::fmt(self.syntax(), f)
5179 } 5181 }
5180} 5182}
5181impl std::fmt::Display for CastExpr { 5183impl std::fmt::Display for CastExpr {
5182 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5184 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5183 std::fmt::Display::fmt(self.syntax(), f) 5185 std::fmt::Display::fmt(self.syntax(), f)
5184 } 5186 }
5185} 5187}
5186impl std::fmt::Display for RefExpr { 5188impl std::fmt::Display for RefExpr {
5187 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5189 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5188 std::fmt::Display::fmt(self.syntax(), f) 5190 std::fmt::Display::fmt(self.syntax(), f)
5189 } 5191 }
5190} 5192}
5191impl std::fmt::Display for PrefixExpr { 5193impl std::fmt::Display for PrefixExpr {
5192 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5194 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5193 std::fmt::Display::fmt(self.syntax(), f) 5195 std::fmt::Display::fmt(self.syntax(), f)
5194 } 5196 }
5195} 5197}
5196impl std::fmt::Display for BoxExpr { 5198impl std::fmt::Display for BoxExpr {
5197 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5199 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5198 std::fmt::Display::fmt(self.syntax(), f) 5200 std::fmt::Display::fmt(self.syntax(), f)
5199 } 5201 }
5200} 5202}
5201impl std::fmt::Display for RangeExpr { 5203impl std::fmt::Display for RangeExpr {
5202 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5204 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5203 std::fmt::Display::fmt(self.syntax(), f) 5205 std::fmt::Display::fmt(self.syntax(), f)
5204 } 5206 }
5205} 5207}
5206impl std::fmt::Display for BinExpr { 5208impl std::fmt::Display for BinExpr {
5207 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5209 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5208 std::fmt::Display::fmt(self.syntax(), f) 5210 std::fmt::Display::fmt(self.syntax(), f)
5209 } 5211 }
5210} 5212}
5211impl std::fmt::Display for Literal { 5213impl std::fmt::Display for Literal {
5212 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5214 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5213 std::fmt::Display::fmt(self.syntax(), f) 5215 std::fmt::Display::fmt(self.syntax(), f)
5214 } 5216 }
5215} 5217}
5216impl std::fmt::Display for MatchExpr { 5218impl std::fmt::Display for MatchExpr {
5217 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5219 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5218 std::fmt::Display::fmt(self.syntax(), f) 5220 std::fmt::Display::fmt(self.syntax(), f)
5219 } 5221 }
5220} 5222}
5221impl std::fmt::Display for MatchArmList { 5223impl std::fmt::Display for MatchArmList {
5222 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5224 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5223 std::fmt::Display::fmt(self.syntax(), f) 5225 std::fmt::Display::fmt(self.syntax(), f)
5224 } 5226 }
5225} 5227}
5226impl std::fmt::Display for MatchArm { 5228impl std::fmt::Display for MatchArm {
5227 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5229 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5228 std::fmt::Display::fmt(self.syntax(), f) 5230 std::fmt::Display::fmt(self.syntax(), f)
5229 } 5231 }
5230} 5232}
5231impl std::fmt::Display for MatchGuard { 5233impl std::fmt::Display for MatchGuard {
5232 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5234 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5233 std::fmt::Display::fmt(self.syntax(), f) 5235 std::fmt::Display::fmt(self.syntax(), f)
5234 } 5236 }
5235} 5237}
5236impl std::fmt::Display for RecordLit { 5238impl std::fmt::Display for RecordLit {
5237 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5239 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5238 std::fmt::Display::fmt(self.syntax(), f) 5240 std::fmt::Display::fmt(self.syntax(), f)
5239 } 5241 }
5240} 5242}
5241impl std::fmt::Display for RecordFieldList { 5243impl std::fmt::Display for RecordFieldList {
5242 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5244 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5243 std::fmt::Display::fmt(self.syntax(), f) 5245 std::fmt::Display::fmt(self.syntax(), f)
5244 } 5246 }
5245} 5247}
5246impl std::fmt::Display for RecordField { 5248impl std::fmt::Display for RecordField {
5247 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5249 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5248 std::fmt::Display::fmt(self.syntax(), f) 5250 std::fmt::Display::fmt(self.syntax(), f)
5249 } 5251 }
5250} 5252}
5251impl std::fmt::Display for OrPat { 5253impl std::fmt::Display for OrPat {
5252 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5254 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5253 std::fmt::Display::fmt(self.syntax(), f) 5255 std::fmt::Display::fmt(self.syntax(), f)
5254 } 5256 }
5255} 5257}
5256impl std::fmt::Display for ParenPat { 5258impl std::fmt::Display for ParenPat {
5257 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5259 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5258 std::fmt::Display::fmt(self.syntax(), f) 5260 std::fmt::Display::fmt(self.syntax(), f)
5259 } 5261 }
5260} 5262}
5261impl std::fmt::Display for RefPat { 5263impl std::fmt::Display for RefPat {
5262 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5264 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5263 std::fmt::Display::fmt(self.syntax(), f) 5265 std::fmt::Display::fmt(self.syntax(), f)
5264 } 5266 }
5265} 5267}
5266impl std::fmt::Display for BoxPat { 5268impl std::fmt::Display for BoxPat {
5267 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5269 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5268 std::fmt::Display::fmt(self.syntax(), f) 5270 std::fmt::Display::fmt(self.syntax(), f)
5269 } 5271 }
5270} 5272}
5271impl std::fmt::Display for BindPat { 5273impl std::fmt::Display for BindPat {
5272 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5274 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5273 std::fmt::Display::fmt(self.syntax(), f) 5275 std::fmt::Display::fmt(self.syntax(), f)
5274 } 5276 }
5275} 5277}
5276impl std::fmt::Display for PlaceholderPat { 5278impl std::fmt::Display for PlaceholderPat {
5277 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5279 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5278 std::fmt::Display::fmt(self.syntax(), f) 5280 std::fmt::Display::fmt(self.syntax(), f)
5279 } 5281 }
5280} 5282}
5281impl std::fmt::Display for DotDotPat { 5283impl std::fmt::Display for DotDotPat {
5282 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5284 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5283 std::fmt::Display::fmt(self.syntax(), f) 5285 std::fmt::Display::fmt(self.syntax(), f)
5284 } 5286 }
5285} 5287}
5286impl std::fmt::Display for PathPat { 5288impl std::fmt::Display for PathPat {
5287 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5289 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5288 std::fmt::Display::fmt(self.syntax(), f) 5290 std::fmt::Display::fmt(self.syntax(), f)
5289 } 5291 }
5290} 5292}
5291impl std::fmt::Display for SlicePat { 5293impl std::fmt::Display for SlicePat {
5292 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5294 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5293 std::fmt::Display::fmt(self.syntax(), f) 5295 std::fmt::Display::fmt(self.syntax(), f)
5294 } 5296 }
5295} 5297}
5296impl std::fmt::Display for RangePat { 5298impl std::fmt::Display for RangePat {
5297 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5299 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5298 std::fmt::Display::fmt(self.syntax(), f) 5300 std::fmt::Display::fmt(self.syntax(), f)
5299 } 5301 }
5300} 5302}
5301impl std::fmt::Display for LiteralPat { 5303impl std::fmt::Display for LiteralPat {
5302 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5304 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5303 std::fmt::Display::fmt(self.syntax(), f) 5305 std::fmt::Display::fmt(self.syntax(), f)
5304 } 5306 }
5305} 5307}
5306impl std::fmt::Display for MacroPat { 5308impl std::fmt::Display for MacroPat {
5307 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5309 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5308 std::fmt::Display::fmt(self.syntax(), f) 5310 std::fmt::Display::fmt(self.syntax(), f)
5309 } 5311 }
5310} 5312}
5311impl std::fmt::Display for RecordPat { 5313impl std::fmt::Display for RecordPat {
5312 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5314 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5313 std::fmt::Display::fmt(self.syntax(), f) 5315 std::fmt::Display::fmt(self.syntax(), f)
5314 } 5316 }
5315} 5317}
5316impl std::fmt::Display for RecordFieldPatList { 5318impl std::fmt::Display for RecordFieldPatList {
5317 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5319 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5318 std::fmt::Display::fmt(self.syntax(), f) 5320 std::fmt::Display::fmt(self.syntax(), f)
5319 } 5321 }
5320} 5322}
5321impl std::fmt::Display for RecordFieldPat { 5323impl std::fmt::Display for RecordFieldPat {
5322 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5324 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5323 std::fmt::Display::fmt(self.syntax(), f) 5325 std::fmt::Display::fmt(self.syntax(), f)
5324 } 5326 }
5325} 5327}
5326impl std::fmt::Display for TupleStructPat { 5328impl std::fmt::Display for TupleStructPat {
5327 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5329 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5328 std::fmt::Display::fmt(self.syntax(), f) 5330 std::fmt::Display::fmt(self.syntax(), f)
5329 } 5331 }
5330} 5332}
5331impl std::fmt::Display for TuplePat { 5333impl std::fmt::Display for TuplePat {
5332 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5334 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5333 std::fmt::Display::fmt(self.syntax(), f) 5335 std::fmt::Display::fmt(self.syntax(), f)
5334 } 5336 }
5335} 5337}
5336impl std::fmt::Display for Visibility { 5338impl std::fmt::Display for Visibility {
5337 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5339 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5338 std::fmt::Display::fmt(self.syntax(), f) 5340 std::fmt::Display::fmt(self.syntax(), f)
5339 } 5341 }
5340} 5342}
5341impl std::fmt::Display for Name { 5343impl std::fmt::Display for Name {
5342 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5344 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5343 std::fmt::Display::fmt(self.syntax(), f) 5345 std::fmt::Display::fmt(self.syntax(), f)
5344 } 5346 }
5345} 5347}
5346impl std::fmt::Display for NameRef { 5348impl std::fmt::Display for NameRef {
5347 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5349 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5348 std::fmt::Display::fmt(self.syntax(), f) 5350 std::fmt::Display::fmt(self.syntax(), f)
5349 } 5351 }
5350} 5352}
5351impl std::fmt::Display for MacroCall { 5353impl std::fmt::Display for MacroCall {
5352 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5354 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5353 std::fmt::Display::fmt(self.syntax(), f) 5355 std::fmt::Display::fmt(self.syntax(), f)
5354 } 5356 }
5355} 5357}
5356impl std::fmt::Display for Attr { 5358impl std::fmt::Display for Attr {
5357 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5359 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5358 std::fmt::Display::fmt(self.syntax(), f) 5360 std::fmt::Display::fmt(self.syntax(), f)
5359 } 5361 }
5360} 5362}
5361impl std::fmt::Display for TokenTree { 5363impl std::fmt::Display for TokenTree {
5362 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5364 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5363 std::fmt::Display::fmt(self.syntax(), f) 5365 std::fmt::Display::fmt(self.syntax(), f)
5364 } 5366 }
5365} 5367}
5366impl std::fmt::Display for TypeParamList { 5368impl std::fmt::Display for TypeParamList {
5367 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5369 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5368 std::fmt::Display::fmt(self.syntax(), f) 5370 std::fmt::Display::fmt(self.syntax(), f)
5369 } 5371 }
5370} 5372}
5371impl std::fmt::Display for TypeParam { 5373impl std::fmt::Display for TypeParam {
5372 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5374 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5373 std::fmt::Display::fmt(self.syntax(), f) 5375 std::fmt::Display::fmt(self.syntax(), f)
5374 } 5376 }
5375} 5377}
5376impl std::fmt::Display for ConstParam { 5378impl std::fmt::Display for ConstParam {
5377 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5379 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5378 std::fmt::Display::fmt(self.syntax(), f) 5380 std::fmt::Display::fmt(self.syntax(), f)
5379 } 5381 }
5380} 5382}
5381impl std::fmt::Display for LifetimeParam { 5383impl std::fmt::Display for LifetimeParam {
5382 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5384 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5383 std::fmt::Display::fmt(self.syntax(), f) 5385 std::fmt::Display::fmt(self.syntax(), f)
5384 } 5386 }
5385} 5387}
5386impl std::fmt::Display for TypeBound { 5388impl std::fmt::Display for TypeBound {
5387 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5389 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5388 std::fmt::Display::fmt(self.syntax(), f) 5390 std::fmt::Display::fmt(self.syntax(), f)
5389 } 5391 }
5390} 5392}
5391impl std::fmt::Display for TypeBoundList { 5393impl std::fmt::Display for TypeBoundList {
5392 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5394 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5393 std::fmt::Display::fmt(self.syntax(), f) 5395 std::fmt::Display::fmt(self.syntax(), f)
5394 } 5396 }
5395} 5397}
5396impl std::fmt::Display for WherePred { 5398impl std::fmt::Display for WherePred {
5397 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5399 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5398 std::fmt::Display::fmt(self.syntax(), f) 5400 std::fmt::Display::fmt(self.syntax(), f)
5399 } 5401 }
5400} 5402}
5401impl std::fmt::Display for WhereClause { 5403impl std::fmt::Display for WhereClause {
5402 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5404 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5403 std::fmt::Display::fmt(self.syntax(), f) 5405 std::fmt::Display::fmt(self.syntax(), f)
5404 } 5406 }
5405} 5407}
5406impl std::fmt::Display for Abi { 5408impl std::fmt::Display for Abi {
5407 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5409 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5408 std::fmt::Display::fmt(self.syntax(), f) 5410 std::fmt::Display::fmt(self.syntax(), f)
5409 } 5411 }
5410} 5412}
5411impl std::fmt::Display for ExprStmt { 5413impl std::fmt::Display for ExprStmt {
5412 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5414 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5413 std::fmt::Display::fmt(self.syntax(), f) 5415 std::fmt::Display::fmt(self.syntax(), f)
5414 } 5416 }
5415} 5417}
5416impl std::fmt::Display for LetStmt { 5418impl std::fmt::Display for LetStmt {
5417 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5419 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5418 std::fmt::Display::fmt(self.syntax(), f) 5420 std::fmt::Display::fmt(self.syntax(), f)
5419 } 5421 }
5420} 5422}
5421impl std::fmt::Display for Condition { 5423impl std::fmt::Display for Condition {
5422 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5424 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5423 std::fmt::Display::fmt(self.syntax(), f) 5425 std::fmt::Display::fmt(self.syntax(), f)
5424 } 5426 }
5425} 5427}
5426impl std::fmt::Display for ParamList { 5428impl std::fmt::Display for ParamList {
5427 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5429 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5428 std::fmt::Display::fmt(self.syntax(), f) 5430 std::fmt::Display::fmt(self.syntax(), f)
5429 } 5431 }
5430} 5432}
5431impl std::fmt::Display for SelfParam { 5433impl std::fmt::Display for SelfParam {
5432 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5434 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5433 std::fmt::Display::fmt(self.syntax(), f) 5435 std::fmt::Display::fmt(self.syntax(), f)
5434 } 5436 }
5435} 5437}
5436impl std::fmt::Display for Param { 5438impl std::fmt::Display for Param {
5437 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5439 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5438 std::fmt::Display::fmt(self.syntax(), f) 5440 std::fmt::Display::fmt(self.syntax(), f)
5439 } 5441 }
5440} 5442}
5441impl std::fmt::Display for UseItem { 5443impl std::fmt::Display for UseItem {
5442 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5444 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5443 std::fmt::Display::fmt(self.syntax(), f) 5445 std::fmt::Display::fmt(self.syntax(), f)
5444 } 5446 }
5445} 5447}
5446impl std::fmt::Display for UseTree { 5448impl std::fmt::Display for UseTree {
5447 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5449 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5448 std::fmt::Display::fmt(self.syntax(), f) 5450 std::fmt::Display::fmt(self.syntax(), f)
5449 } 5451 }
5450} 5452}
5451impl std::fmt::Display for Alias { 5453impl std::fmt::Display for Alias {
5452 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5454 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5453 std::fmt::Display::fmt(self.syntax(), f) 5455 std::fmt::Display::fmt(self.syntax(), f)
5454 } 5456 }
5455} 5457}
5456impl std::fmt::Display for UseTreeList { 5458impl std::fmt::Display for UseTreeList {
5457 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5459 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5458 std::fmt::Display::fmt(self.syntax(), f) 5460 std::fmt::Display::fmt(self.syntax(), f)
5459 } 5461 }
5460} 5462}
5461impl std::fmt::Display for ExternCrateItem { 5463impl std::fmt::Display for ExternCrateItem {
5462 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5464 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5463 std::fmt::Display::fmt(self.syntax(), f) 5465 std::fmt::Display::fmt(self.syntax(), f)
5464 } 5466 }
5465} 5467}
5466impl std::fmt::Display for ArgList { 5468impl std::fmt::Display for ArgList {
5467 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5469 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5468 std::fmt::Display::fmt(self.syntax(), f) 5470 std::fmt::Display::fmt(self.syntax(), f)
5469 } 5471 }
5470} 5472}
5471impl std::fmt::Display for Path { 5473impl std::fmt::Display for Path {
5472 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5474 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5473 std::fmt::Display::fmt(self.syntax(), f) 5475 std::fmt::Display::fmt(self.syntax(), f)
5474 } 5476 }
5475} 5477}
5476impl std::fmt::Display for PathSegment { 5478impl std::fmt::Display for PathSegment {
5477 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5479 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5478 std::fmt::Display::fmt(self.syntax(), f) 5480 std::fmt::Display::fmt(self.syntax(), f)
5479 } 5481 }
5480} 5482}
5481impl std::fmt::Display for TypeArgList { 5483impl std::fmt::Display for TypeArgList {
5482 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5484 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5483 std::fmt::Display::fmt(self.syntax(), f) 5485 std::fmt::Display::fmt(self.syntax(), f)
5484 } 5486 }
5485} 5487}
5486impl std::fmt::Display for TypeArg { 5488impl std::fmt::Display for TypeArg {
5487 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5489 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5488 std::fmt::Display::fmt(self.syntax(), f) 5490 std::fmt::Display::fmt(self.syntax(), f)
5489 } 5491 }
5490} 5492}
5491impl std::fmt::Display for AssocTypeArg { 5493impl std::fmt::Display for AssocTypeArg {
5492 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5494 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5493 std::fmt::Display::fmt(self.syntax(), f) 5495 std::fmt::Display::fmt(self.syntax(), f)
5494 } 5496 }
5495} 5497}
5496impl std::fmt::Display for LifetimeArg { 5498impl std::fmt::Display for LifetimeArg {
5497 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5499 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5498 std::fmt::Display::fmt(self.syntax(), f) 5500 std::fmt::Display::fmt(self.syntax(), f)
5499 } 5501 }
5500} 5502}
5501impl std::fmt::Display for ConstArg { 5503impl std::fmt::Display for ConstArg {
5502 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5504 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5503 std::fmt::Display::fmt(self.syntax(), f) 5505 std::fmt::Display::fmt(self.syntax(), f)
5504 } 5506 }
5505} 5507}
5506impl std::fmt::Display for MacroItems { 5508impl std::fmt::Display for MacroItems {
5507 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5509 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5508 std::fmt::Display::fmt(self.syntax(), f) 5510 std::fmt::Display::fmt(self.syntax(), f)
5509 } 5511 }
5510} 5512}
5511impl std::fmt::Display for MacroStmts { 5513impl std::fmt::Display for MacroStmts {
5512 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5514 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5513 std::fmt::Display::fmt(self.syntax(), f) 5515 std::fmt::Display::fmt(self.syntax(), f)
5514 } 5516 }
5515} 5517}
5516impl std::fmt::Display for ExternItemList { 5518impl std::fmt::Display for ExternItemList {
5517 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5519 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5518 std::fmt::Display::fmt(self.syntax(), f) 5520 std::fmt::Display::fmt(self.syntax(), f)
5519 } 5521 }
5520} 5522}
5521impl std::fmt::Display for ExternBlock { 5523impl std::fmt::Display for ExternBlock {
5522 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5524 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5523 std::fmt::Display::fmt(self.syntax(), f) 5525 std::fmt::Display::fmt(self.syntax(), f)
5524 } 5526 }
5525} 5527}
5526impl std::fmt::Display for MetaItem { 5528impl std::fmt::Display for MetaItem {
5527 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5529 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5528 std::fmt::Display::fmt(self.syntax(), f) 5530 std::fmt::Display::fmt(self.syntax(), f)
5529 } 5531 }
5530} 5532}
5531impl std::fmt::Display for MacroDef { 5533impl std::fmt::Display for MacroDef {
5532 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 5534 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5533 std::fmt::Display::fmt(self.syntax(), f) 5535 std::fmt::Display::fmt(self.syntax(), f)
5534 } 5536 }
5535} 5537}
diff --git a/crates/ra_syntax/src/ast/generated/tokens.rs b/crates/ra_syntax/src/ast/generated/tokens.rs
index f91befaac..abadd0b61 100644
--- a/crates/ra_syntax/src/ast/generated/tokens.rs
+++ b/crates/ra_syntax/src/ast/generated/tokens.rs
@@ -11,7 +11,7 @@ pub struct Whitespace {
11 pub(crate) syntax: SyntaxToken, 11 pub(crate) syntax: SyntaxToken,
12} 12}
13impl std::fmt::Display for Whitespace { 13impl std::fmt::Display for Whitespace {
14 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 14 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15 std::fmt::Display::fmt(&self.syntax, f) 15 std::fmt::Display::fmt(&self.syntax, f)
16 } 16 }
17} 17}
@@ -32,7 +32,7 @@ pub struct Comment {
32 pub(crate) syntax: SyntaxToken, 32 pub(crate) syntax: SyntaxToken,
33} 33}
34impl std::fmt::Display for Comment { 34impl std::fmt::Display for Comment {
35 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 35 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
36 std::fmt::Display::fmt(&self.syntax, f) 36 std::fmt::Display::fmt(&self.syntax, f)
37 } 37 }
38} 38}
@@ -53,7 +53,7 @@ pub struct String {
53 pub(crate) syntax: SyntaxToken, 53 pub(crate) syntax: SyntaxToken,
54} 54}
55impl std::fmt::Display for String { 55impl std::fmt::Display for String {
56 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 56 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
57 std::fmt::Display::fmt(&self.syntax, f) 57 std::fmt::Display::fmt(&self.syntax, f)
58 } 58 }
59} 59}
@@ -74,7 +74,7 @@ pub struct RawString {
74 pub(crate) syntax: SyntaxToken, 74 pub(crate) syntax: SyntaxToken,
75} 75}
76impl std::fmt::Display for RawString { 76impl std::fmt::Display for RawString {
77 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 77 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
78 std::fmt::Display::fmt(&self.syntax, f) 78 std::fmt::Display::fmt(&self.syntax, f)
79 } 79 }
80} 80}
diff --git a/crates/ra_syntax/src/ast/tokens.rs b/crates/ra_syntax/src/ast/tokens.rs
index 56378385a..2e72d4927 100644
--- a/crates/ra_syntax/src/ast/tokens.rs
+++ b/crates/ra_syntax/src/ast/tokens.rs
@@ -84,7 +84,7 @@ impl Whitespace {
84} 84}
85 85
86pub struct QuoteOffsets { 86pub struct QuoteOffsets {
87 pub quotes: [TextRange; 2], 87 pub quotes: (TextRange, TextRange),
88 pub contents: TextRange, 88 pub contents: TextRange,
89} 89}
90 90
@@ -103,7 +103,7 @@ impl QuoteOffsets {
103 let end = TextSize::of(literal); 103 let end = TextSize::of(literal);
104 104
105 let res = QuoteOffsets { 105 let res = QuoteOffsets {
106 quotes: [TextRange::new(start, left_quote), TextRange::new(right_quote, end)], 106 quotes: (TextRange::new(start, left_quote), TextRange::new(right_quote, end)),
107 contents: TextRange::new(left_quote, right_quote), 107 contents: TextRange::new(left_quote, right_quote),
108 }; 108 };
109 Some(res) 109 Some(res)
@@ -116,17 +116,17 @@ pub trait HasQuotes: AstToken {
116 let offsets = QuoteOffsets::new(text)?; 116 let offsets = QuoteOffsets::new(text)?;
117 let o = self.syntax().text_range().start(); 117 let o = self.syntax().text_range().start();
118 let offsets = QuoteOffsets { 118 let offsets = QuoteOffsets {
119 quotes: [offsets.quotes[0] + o, offsets.quotes[1] + o], 119 quotes: (offsets.quotes.0 + o, offsets.quotes.1 + o),
120 contents: offsets.contents + o, 120 contents: offsets.contents + o,
121 }; 121 };
122 Some(offsets) 122 Some(offsets)
123 } 123 }
124 fn open_quote_text_range(&self) -> Option<TextRange> { 124 fn open_quote_text_range(&self) -> Option<TextRange> {
125 self.quote_offsets().map(|it| it.quotes[0]) 125 self.quote_offsets().map(|it| it.quotes.0)
126 } 126 }
127 127
128 fn close_quote_text_range(&self) -> Option<TextRange> { 128 fn close_quote_text_range(&self) -> Option<TextRange> {
129 self.quote_offsets().map(|it| it.quotes[1]) 129 self.quote_offsets().map(|it| it.quotes.1)
130 } 130 }
131 131
132 fn text_range_between_quotes(&self) -> Option<TextRange> { 132 fn text_range_between_quotes(&self) -> Option<TextRange> {
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs
index 61e686da5..a33a35cc1 100644
--- a/crates/ra_syntax/src/lib.rs
+++ b/crates/ra_syntax/src/lib.rs
@@ -51,7 +51,8 @@ pub use crate::{
51 ptr::{AstPtr, SyntaxNodePtr}, 51 ptr::{AstPtr, SyntaxNodePtr},
52 syntax_error::SyntaxError, 52 syntax_error::SyntaxError,
53 syntax_node::{ 53 syntax_node::{
54 Direction, NodeOrToken, SyntaxElement, SyntaxNode, SyntaxToken, SyntaxTreeBuilder, 54 Direction, NodeOrToken, SyntaxElement, SyntaxElementChildren, SyntaxNode,
55 SyntaxNodeChildren, SyntaxToken, SyntaxTreeBuilder,
55 }, 56 },
56}; 57};
57pub use ra_parser::{SyntaxKind, T}; 58pub use ra_parser::{SyntaxKind, T};
diff --git a/crates/ra_syntax/src/parsing/text_token_source.rs b/crates/ra_syntax/src/parsing/text_token_source.rs
index 7ddc2c2c3..97aa3e795 100644
--- a/crates/ra_syntax/src/parsing/text_token_source.rs
+++ b/crates/ra_syntax/src/parsing/text_token_source.rs
@@ -1,40 +1,35 @@
1//! FIXME: write short doc here 1//! See `TextTokenSource` docs.
2 2
3use ra_parser::Token as PToken;
4use ra_parser::TokenSource; 3use ra_parser::TokenSource;
5 4
6use crate::{parsing::lexer::Token, SyntaxKind::EOF, TextRange, TextSize}; 5use crate::{parsing::lexer::Token, SyntaxKind::EOF, TextRange, TextSize};
7 6
7/// Implementation of `ra_parser::TokenSource` that takes tokens from source code text.
8pub(crate) struct TextTokenSource<'t> { 8pub(crate) struct TextTokenSource<'t> {
9 text: &'t str, 9 text: &'t str,
10 /// start position of each token(expect whitespace and comment) 10 /// token and its start position (non-whitespace/comment tokens)
11 /// ```non-rust 11 /// ```non-rust
12 /// struct Foo; 12 /// struct Foo;
13 /// ^------^--- 13 /// ^------^--^-
14 /// | | ^- 14 /// | | \________
15 /// 0 7 10 15 /// | \____ \
16 /// | \ |
17 /// (struct, 0) (Foo, 7) (;, 10)
16 /// ``` 18 /// ```
17 /// (token, start_offset): `[(struct, 0), (Foo, 7), (;, 10)]` 19 /// `[(struct, 0), (Foo, 7), (;, 10)]`
18 start_offsets: Vec<TextSize>, 20 token_offset_pairs: Vec<(Token, TextSize)>,
19 /// non-whitespace/comment tokens
20 /// ```non-rust
21 /// struct Foo {}
22 /// ^^^^^^ ^^^ ^^
23 /// ```
24 /// tokens: `[struct, Foo, {, }]`
25 tokens: Vec<Token>,
26 21
27 /// Current token and position 22 /// Current token and position
28 curr: (PToken, usize), 23 curr: (ra_parser::Token, usize),
29} 24}
30 25
31impl<'t> TokenSource for TextTokenSource<'t> { 26impl<'t> TokenSource for TextTokenSource<'t> {
32 fn current(&self) -> PToken { 27 fn current(&self) -> ra_parser::Token {
33 self.curr.0 28 self.curr.0
34 } 29 }
35 30
36 fn lookahead_nth(&self, n: usize) -> PToken { 31 fn lookahead_nth(&self, n: usize) -> ra_parser::Token {
37 mk_token(self.curr.1 + n, &self.start_offsets, &self.tokens) 32 mk_token(self.curr.1 + n, &self.token_offset_pairs)
38 } 33 }
39 34
40 fn bump(&mut self) { 35 fn bump(&mut self) {
@@ -43,45 +38,47 @@ impl<'t> TokenSource for TextTokenSource<'t> {
43 } 38 }
44 39
45 let pos = self.curr.1 + 1; 40 let pos = self.curr.1 + 1;
46 self.curr = (mk_token(pos, &self.start_offsets, &self.tokens), pos); 41 self.curr = (mk_token(pos, &self.token_offset_pairs), pos);
47 } 42 }
48 43
49 fn is_keyword(&self, kw: &str) -> bool { 44 fn is_keyword(&self, kw: &str) -> bool {
50 let pos = self.curr.1; 45 self.token_offset_pairs
51 if pos >= self.tokens.len() { 46 .get(self.curr.1)
52 return false; 47 .map(|(token, offset)| &self.text[TextRange::at(*offset, token.len)] == kw)
53 } 48 .unwrap_or(false)
54 let range = TextRange::at(self.start_offsets[pos], self.tokens[pos].len);
55 self.text[range] == *kw
56 } 49 }
57} 50}
58 51
59fn mk_token(pos: usize, start_offsets: &[TextSize], tokens: &[Token]) -> PToken { 52fn mk_token(pos: usize, token_offset_pairs: &[(Token, TextSize)]) -> ra_parser::Token {
60 let kind = tokens.get(pos).map(|t| t.kind).unwrap_or(EOF); 53 let (kind, is_jointed_to_next) = match token_offset_pairs.get(pos) {
61 let is_jointed_to_next = if pos + 1 < start_offsets.len() { 54 Some((token, offset)) => (
62 start_offsets[pos] + tokens[pos].len == start_offsets[pos + 1] 55 token.kind,
63 } else { 56 token_offset_pairs
64 false 57 .get(pos + 1)
58 .map(|(_, next_offset)| offset + token.len == *next_offset)
59 .unwrap_or(false),
60 ),
61 None => (EOF, false),
65 }; 62 };
66 63 ra_parser::Token { kind, is_jointed_to_next }
67 PToken { kind, is_jointed_to_next }
68} 64}
69 65
70impl<'t> TextTokenSource<'t> { 66impl<'t> TextTokenSource<'t> {
71 /// Generate input from tokens(expect comment and whitespace). 67 /// Generate input from tokens(expect comment and whitespace).
72 pub fn new(text: &'t str, raw_tokens: &'t [Token]) -> TextTokenSource<'t> { 68 pub fn new(text: &'t str, raw_tokens: &'t [Token]) -> TextTokenSource<'t> {
73 let mut tokens = Vec::new(); 69 let token_offset_pairs: Vec<_> = raw_tokens
74 let mut start_offsets = Vec::new(); 70 .iter()
75 let mut len = 0.into(); 71 .filter_map({
76 for &token in raw_tokens.iter() { 72 let mut len = 0.into();
77 if !token.kind.is_trivia() { 73 move |token| {
78 tokens.push(token); 74 let pair = if token.kind.is_trivia() { None } else { Some((*token, len)) };
79 start_offsets.push(len); 75 len += token.len;
80 } 76 pair
81 len += token.len; 77 }
82 } 78 })
79 .collect();
83 80
84 let first = mk_token(0, &start_offsets, &tokens); 81 let first = mk_token(0, &token_offset_pairs);
85 TextTokenSource { text, start_offsets, tokens, curr: (first, 0) } 82 TextTokenSource { text, token_offset_pairs, curr: (first, 0) }
86 } 83 }
87} 84}