Repository: rust-analyzer/rust-analyzer
Pull request #10803 (2021-11-18 20:45:06)

minor: Simplify
bors r+


Patch:
diff --git a/crates/hir/src/attrs.rs b/crates/hir/src/attrs.rs
index 2f6eed82cb..c7a8463a3c 100644
--- a/crates/hir/src/attrs.rs
+++ b/crates/hir/src/attrs.rs
@@ -147,7 +147,7 @@ fn resolve_doc_path(
         AttrDefId::MacroDefId(_) => return None,
     };
     let path = ast::Path::parse(link).ok()?;
-    let modpath = ModPath::from_src(db.upcast(), path, &Hygiene::new_unhygienic())?;
+    let modpath = ModPath::from_src(db.upcast(), path, &Hygiene::new_unhygienic()).unwrap();
     let resolved = resolver.resolve_module_path_in_items(db.upcast(), &modpath);
     let resolved = if resolved == PerNs::none() {
         resolver.resolve_module_path_in_trait_assoc_items(db.upcast(), &modpath)?
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index 4fdcb88bbf..d59c26438b 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -1457,10 +1457,6 @@ impl Const {
         db.const_data(self.id).name.clone()
     }
 
-    pub fn value(self, db: &dyn HirDatabase) -> Option<ast::Expr> {
-        self.source(db)?.value.body()
-    }
-
     pub fn ty(self, db: &dyn HirDatabase) -> Type {
         let data = db.const_data(self.id);
         let resolver = self.id.resolver(db.upcast());
@@ -1497,10 +1493,6 @@ impl Static {
         db.static_data(self.id).mutable
     }
 
-    pub fn value(self, db: &dyn HirDatabase) -> Option<ast::Expr> {
-        self.source(db)?.value.body()
-    }
-
     pub fn ty(self, db: &dyn HirDatabase) -> Type {
         let data = db.static_data(self.id);
         let resolver = self.id.resolver(db.upcast());
diff --git a/crates/hir_def/src/attr.rs b/crates/hir_def/src/attr.rs
index fd45eccf5a..711062c713 100644
--- a/crates/hir_def/src/attr.rs
+++ b/crates/hir_def/src/attr.rs
@@ -723,34 +723,32 @@ impl Attr {
     /// to derive macros.
     ///
     /// Returns `None` when the attribute does not have a well-formed `#[derive]` attribute input.
-    pub(crate) fn parse_derive(&self) -> Option<impl Iterator<Item = ModPath>> {
-        if let Some(AttrInput::TokenTree(args, _)) = self.input.as_deref() {
-            if args.delimiter_kind() != Some(DelimiterKind::Parenthesis) {
-                return None;
-            }
-            let mut counter = 0;
-            let paths = args
-                .token_trees
-                .iter()
-                .group_by(move |tt| {
-                    if let tt::TokenTree::Leaf(tt::Leaf::Punct(Punct { char: ',', .. })) = tt {
-                        counter += 1;
-                    }
-                    counter
-                })
-                .into_iter()
-                .map(|(_, tts)| {
-                    let segments = tts.filter_map(|tt| match tt {
-                        tt::TokenTree::Leaf(tt::Leaf::Ident(id)) => Some(id.as_name()),
-                        _ => None,
-                    });
-                    ModPath::from_segments(PathKind::Plain, segments)
-                })
-                .collect::<Vec<_>>();
-
-            return Some(paths.into_iter());
+    pub(crate) fn parse_derive(&self) -> Option<impl Iterator<Item = ModPath> + '_> {
+        let args = match self.input.as_deref() {
+            Some(AttrInput::TokenTree(args, _)) => args,
+            _ => return None,
+        };
+
+        if args.delimiter_kind() != Some(DelimiterKind::Parenthesis) {
+            return None;
         }
-        None
+        let paths = args
+            .token_trees
+            .iter()
+            .group_by(|tt| {
+                matches!(tt, tt::TokenTree::Leaf(tt::Leaf::Punct(Punct { char: ',', .. })))
+            })
+            .into_iter()
+            .map(|(_, tts)| {
+                let segments = tts.filter_map(|tt| match tt {
+                    tt::TokenTree::Leaf(tt::Leaf::Ident(id)) => Some(id.as_name()),
+                    _ => None,
+                });
+                ModPath::from_segments(PathKind::Plain, segments)
+            })
+            .collect::<Vec<_>>();
+
+        return Some(paths.into_iter());
     }
 
     pub fn string_value(&self) -> Option<&SmolStr> {
diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs
index bafba0672f..964af8a8a4 100644
--- a/crates/hir_def/src/nameres/collector.rs
+++ b/crates/hir_def/src/nameres/collector.rs
@@ -226,13 +226,6 @@ enum MacroDirectiveKind {
     Attr { ast_id: AstIdWithPath<ast::Item>, attr: Attr, mod_item: ModItem },
 }
 
-struct DefData<'a> {
-    id: ModuleDefId,
-    name: &'a Name,
-    visibility: &'a RawVisibility,
-    has_constructor: bool,
-}
-
 /// Walks the tree of module recursively
 struct DefCollector<'a> {
     db: &'a dyn DefDatabase,
@@ -1353,19 +1346,18 @@ impl DefCollector<'_> {
         }
 
         for directive in &self.unresolved_imports {
-            if let ImportSource::Import { id: import, use_tree } = &directive.import.source {
-                if let (Some(krate), PathKind::Plain | PathKind::Abs) =
-                    (directive.import.path.segments().first(), &directive.import.path.kind)
-                {
-                    if diagnosed_extern_crates.contains(krate) {
-                        continue;
-                    }
+            if let ImportSource::Import { id: import, use_tree } = directive.import.source {
+                if matches!(
+                    (directive.import.path.segments().first(), &directive.import.path.kind),
+                    (Some(krate), PathKind::Plain | PathKind::Abs) if diagnosed_extern_crates.contains(krate)
+                ) {
+                    continue;
                 }
 
                 self.def_map.diagnostics.push(DefDiagnostic::unresolved_import(
                     directive.module_id,
-                    *import,
-                    *use_tree,
+                    import,
+                    use_tree,
                 ));
             }
         }
@@ -1386,6 +1378,13 @@ struct ModCollector<'a, 'b> {
 
 impl ModCollector<'_, '_> {
     fn collect(&mut self, items: &[ModItem]) {
+        struct DefData<'a> {
+            id: ModuleDefId,
+            name: &'a Name,
+            visibility: &'a RawVisibility,
+            has_constructor: bool,
+        }
+
         let krate = self.def_collector.def_map.krate;
 
         // Note: don't assert that inserted value is fresh: it's simply not true
@@ -1403,18 +1402,18 @@ impl ModCollector<'_, '_> {
         // This should be processed eagerly instead of deferred to resolving.
         // `#[macro_use] extern crate` is hoisted to imports macros before collecting
         // any other items.
-        for item in items {
-            let attrs = self.item_tree.attrs(self.def_collector.db, krate, (*item).into());
+        for &item in items {
+            let attrs = self.item_tree.attrs(self.def_collector.db, krate, item.into());
             if attrs.cfg().map_or(true, |cfg| self.is_cfg_enabled(&cfg)) {
                 if let ModItem::ExternCrate(id) = item {
-                    let import = self.item_tree[*id].clone();
+                    let import = &self.item_tree[id];
                     let attrs = self.item_tree.attrs(
                         self.def_collector.db,
                         krate,
-                        ModItem::from(*id).into(),
+                        ModItem::from(id).into(),
                     );
                     if attrs.by_key("macro_use").exists() {
-                        self.def_collector.import_macros_from_extern_crate(self.module_id, &import);
+                        self.def_collector.import_macros_from_extern_crate(self.module_id, import);
                     }
                 }
             }
@@ -1656,9 +1655,7 @@ impl ModCollector<'_, '_> {
                         let is_enabled = item_tree
                             .top_level_attrs(db, self.def_collector.def_map.krate)
                             .cfg()
-                            .map_or(true, |cfg| {
-                                self.def_collector.cfg_options.check(&cfg) != Some(false)
-                            });
+                            .map_or(true, |cfg| self.is_cfg_enabled(&cfg));
                         if is_enabled {
                             let module_id = self.push_child_module(
                                 module.name.clone(),
@@ -1675,12 +1672,12 @@ impl ModCollector<'_, '_> {
                                 mod_dir,
                             }
                             .collect(item_tree.top_level_items());
-                            if is_macro_use
+                            let is_macro_use = is_macro_use
                                 || item_tree
                                     .top_level_attrs(db, self.def_collector.def_map.krate)
                                     .by_key("macro_use")
-                                    .exists()
-                            {
+                                    .exists();
+                            if is_macro_use {
                                 self.import_all_legacy_macros(module_id);
                             }
                         }
@@ -1714,14 +1711,17 @@ impl ModCollector<'_, '_> {
                 ModuleOrigin::File { declaration, definition, is_mod_rs }
             }
         };
+
         let res = modules.alloc(ModuleData::new(origin, vis));
         modules[res].parent = Some(self.module_id);
         for (name, mac) in modules[self.module_id].scope.collect_legacy_macros() {
             modules[res].scope.define_legacy_macro(name, mac)
         }
         modules[self.module_id].children.insert(name.clone(), res);
+
         let module = self.def_collector.def_map.module_id(res);
-        let def: ModuleDefId = module.into();
+        let def = ModuleDefId::from(module);
+
         self.def_collector.def_map.modules[self.module_id].scope.declare(def);
         self.def_collector.update(
             self.module_id,
@@ -1786,30 +1786,29 @@ impl ModCollector<'_, '_> {
     }
 
     fn is_builtin_or_registered_attr(&self, path: &ModPath) -> bool {
-        if path.kind == PathKind::Plain {
-            if let Some(tool_module) = path.segments().first() {
-                let tool_module = tool_module.to_smol_str();
-                let is_tool = builtin_attr::TOOL_MODULES
-                    .iter()
-                    .copied()
-                    .chain(self.def_collector.registered_tools.iter().map(SmolStr::as_str))
-                    .any(|m| tool_module == *m);
-                if is_tool {
-                    return true;
-                }
+        if path.kind != PathKind::Plain {
+            return false;
+        }
+
+        let segments = path.segments();
+
+        if let Some(name) = segments.first() {
+            let name = name.to_smol_str();
+            let pred = |n: &_| *n == name;
+
+            let registered = self.def_collector.registered_tools.iter().map(SmolStr::as_str);
+            let is_tool = builtin_attr::TOOL_MODULES.iter().copied().chain(registered).any(pred);
+            if is_tool {
+                return true;
             }
 
-            if let Some(name) = path.as_ident() {
-                let name = name.to_smol_str();
-                let is_inert = builtin_attr::INERT_ATTRIBUTES
-                    .iter()
-                    .copied()
-                    .chain(self.def_collector.registered_attrs.iter().map(SmolStr::as_str))
-                    .any(|attr| name == *attr);
+            if segments.len() == 1 {
+                let registered = self.def_collector.registered_attrs.iter().map(SmolStr::as_str);
+                let is_inert =
+                    builtin_attr::INERT_ATTRIBUTES.iter().copied().chain(registered).any(pred);
                 return is_inert;
             }
         }
-
         false
     }
 
@@ -1831,7 +1830,7 @@ impl ModCollector<'_, '_> {
 
         let is_export = export_attr.exists();
         let is_local_inner = if is_export {
-            export_attr.tt_values().map(|it| &it.token_trees).flatten().any(|it| match it {
+            export_attr.tt_values().flat_map(|it| &it.token_trees).any(|it| match it {
                 tt::TokenTree::Leaf(tt::Leaf::Ident(ident)) => {
                     ident.text.contains("local_inner_macros")
                 }
@@ -1852,12 +1851,14 @@ impl ModCollector<'_, '_> {
                     &name
                 }
                 None => {
-                    match attrs.by_key("rustc_builtin_macro").tt_values().next().and_then(|tt| {
-                        match tt.token_trees.first() {
-                            Some(tt::TokenTree::Leaf(tt::Leaf::Ident(name))) => Some(name),
-                            _ => None,
-                        }
-                    }) {
+                    let explicit_name =
+                        attrs.by_key("rustc_builtin_macro").tt_values().next().and_then(|tt| {
+                            match tt.token_trees.first() {
+                                Some(tt::TokenTree::Leaf(tt::Leaf::Ident(name))) => Some(name),
+                                _ => None,
+                            }
+                        });
+                    match explicit_name {
                         Some(ident) => {
                             name = ident.as_name();
                             &name
@@ -1947,7 +1948,7 @@ impl ModCollector<'_, '_> {
     }
 
     fn collect_macro_call(&mut self, mac: &MacroCall) {
-        let ast_id = AstIdWithPath::new(self.file_id(), mac.ast_id, (*mac.path).clone());
+        let ast_id = AstIdWithPath::new(self.file_id(), mac.ast_id, ModPath::clone(&mac.path));
 
         // Case 1: try to resolve in legacy scope and expand macro_rules
         let mut error = None;
diff --git a/crates/hir_def/src/nameres/mod_resolution.rs b/crates/hir_def/src/nameres/mod_resolution.rs
index bd2588e592..b6f1b17870 100644
--- a/crates/hir_def/src/nameres/mod_resolution.rs
+++ b/crates/hir_def/src/nameres/mod_resolution.rs
@@ -24,22 +24,13 @@ impl ModDir {
     pub(super) fn root() -> ModDir {
         ModDir { dir_path: DirPath::empty(), root_non_dir_owner: false, depth: 0 }
     }
-    fn child(&self, dir_path: DirPath, root_non_dir_owner: bool) -> Option<ModDir> {
-        let depth = self.depth + 1;
-        if MOD_DEPTH_LIMIT.check(depth as usize).is_err() {
-            tracing::error!("MOD_DEPTH_LIMIT exceeded");
-            cov_mark::hit!(circular_mods);
-            return None;
-        }
-        Some(ModDir { dir_path, root_non_dir_owner, depth })
-    }
 
     pub(super) fn descend_into_definition(
         &self,
         name: &Name,
         attr_path: Option<&SmolStr>,
     ) -> Option<ModDir> {
-        let path = match attr_path.map(|it| it.as_str()) {
+        let path = match attr_path.map(SmolStr::as_str) {
             None => {
                 let mut path = self.dir_path.clone();
                 path.push(&name.to_smol_str());
@@ -56,6 +47,16 @@ impl ModDir {
         self.child(path, false)
     }
 
+    fn child(&self, dir_path: DirPath, root_non_dir_owner: bool) -> Option<ModDir> {
+        let depth = self.depth + 1;
+        if MOD_DEPTH_LIMIT.check(depth as usize).is_err() {
+            tracing::error!("MOD_DEPTH_LIMIT exceeded");
+            cov_mark::hit!(circular_mods);
+            return None;
+        }
+        Some(ModDir { dir_path, root_non_dir_owner, depth })
+    }
+
     pub(super) fn resolve_declaration(
         &self,
         db: &dyn DefDatabase,
diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs
index 2ebf46b564..f4fb52647e 100644
--- a/crates/ide/src/hover.rs
+++ b/crates/ide/src/hover.rs
@@ -314,7 +314,6 @@ fn goto_type_action_for_def(db: &RootDatabase, def: Definition) -> Option<HoverA
             Definition::Local(it) => it.ty(db),
             Definition::GenericParam(hir::GenericParam::ConstParam(it)) => it.ty(db),
             Definition::Field(field) => field.ty(db),
-            Definition::Function(function) => function.ret_type(db),
             _ => return None,
         };
 
diff --git a/crates/ide/src/hover/render.rs b/crates/ide/src/hover/render.rs
index e872d9b1fb..59068028ed 100644
--- a/crates/ide/src/hover/render.rs
+++ b/crates/ide/src/hover/render.rs
@@ -1,6 +1,4 @@
 //! Logic for rendering the different hover messages
-use std::fmt::Display;
-
 use either::Either;
 use hir::{AsAssocItem, HasAttrs, HasSource, HirDisplay, Semantics, TypeInfo};
 use ide_db::{
@@ -354,8 +352,8 @@ pub(super) fn definition(
         Definition::Function(it) => label_and_docs(db, it),
         Definition::Adt(it) => label_and_docs(db, it),
         Definition::Variant(it) => label_and_docs(db, it),
-        Definition::Const(it) => label_value_and_docs(db, it, |it| it.value(db)),
-        Definition::Static(it) => label_value_and_docs(db, it, |it| it.value(db)),
+        Definition::Const(it) => label_and_docs(db, it),
+        Definition::Static(it) => label_and_docs(db, it),
         Definition::Trait(it) => label_and_docs(db, it),
         Definition::TypeAlias(it) => label_and_docs(db, it),
         Definition::BuiltinType(it) => {
@@ -383,25 +381,6 @@ where
     (label, docs)
 }
 
-fn label_value_and_docs<D, E, V>(
-    db: &RootDatabase,
-    def: D,
-    value_extractor: E,
-) -> (String, Option<hir::Documentation>)
-where
-    D: HasAttrs + HirDisplay,
-    E: Fn(&D) -> Option<V>,
-    V: Display,
-{
-    let label = if let Some(value) = (value_extractor)(&def) {
-        format!("{} = {}", def.display(db), value)
-    } else {
-        def.display(db).to_string()
-    };
-    let docs = def.attrs(db).docs();
-    (label, docs)
-}
-
 fn definition_mod_path(db: &RootDatabase, def: &Definition) -> Option<String> {
     if let Definition::GenericParam(_) = def {
         return None;
diff --git a/crates/parser/src/grammar/patterns.rs b/crates/parser/src/grammar/patterns.rs
index 70ff87b238..9da94ce162 100644
--- a/crates/parser/src/grammar/patterns.rs
+++ b/crates/parser/src/grammar/patterns.rs
@@ -74,11 +74,6 @@ fn pattern_single_r(p: &mut Parser, recovery_set: TokenSet) {
         //         Some(0) | None => (),
         //         Some(1..) => ()
         //     }
-        //
-        //     match (10 as u8, 5 as u8) {
-        //         (0, _) => (),
-        //         (1.., _) => ()
-        //     }
         // }
 
         // FIXME: support half_open_range_patterns (`..=2`),
@@ -90,7 +85,7 @@ fn pattern_single_r(p: &mut Parser, recovery_set: TokenSet) {
 
                 // `0 .. =>` or `let 0 .. =` or `Some(0 .. )`
                 //       ^                ^                ^
-                if p.at(T![=]) | p.at(T![')']) | p.at(T![,]) {
+                if p.at(T![=]) | p.at(T![')']) {
                     // test half_open_range_pat
                     // fn f() { let 0 .. = 1u32; }
                 } else {
diff --git a/crates/proc_macro_srv/src/abis/mod.rs b/crates/proc_macro_srv/src/abis/mod.rs
index 0de15b4832..5d7c623b0a 100644
--- a/crates/proc_macro_srv/src/abis/mod.rs
+++ b/crates/proc_macro_srv/src/abis/mod.rs
@@ -69,26 +69,22 @@ impl Abi {
         symbol_name: String,
         info: RustCInfo,
     ) -> Result<Abi, LoadProcMacroDylibError> {
-        // FIXME: this should use exclusive ranges when they're stable
-        // https://github.com/rust-lang/rust/issues/37854
-        match (info.version.0, info.version.1) {
-            (1, 47..=54) => {
-                let inner = unsafe { Abi_1_47::from_lib(lib, symbol_name) }?;
-                Ok(Abi::Abi1_47(inner))
-            }
-            (1, 55..=55) => {
-                let inner = unsafe { Abi_1_55::from_lib(lib, symbol_name) }?;
-                Ok(Abi::Abi1_55(inner))
-            }
-            (1, 56..=57) => {
-                let inner = unsafe { Abi_1_56::from_lib(lib, symbol_name) }?;
-                Ok(Abi::Abi1_56(inner))
-            }
-            (1, 58..) => {
-                let inner = unsafe { Abi_1_58::from_lib(lib, symbol_name) }?;
-                Ok(Abi::Abi1_58(inner))
-            }
-            _ => Err(LoadProcMacroDylibError::UnsupportedABI),
+        if info.version.0 != 1 {
+            Err(LoadProcMacroDylibError::UnsupportedABI)
+        } else if info.version.1 < 47 {
+            Err(LoadProcMacroDylibError::UnsupportedABI)
+        } else if info.version.1 < 54 {
+            let inner = unsafe { Abi_1_47::from_lib(lib, symbol_name) }?;
+            Ok(Abi::Abi1_47(inner))
+        } else if info.version.1 < 56 {
+            let inner = unsafe { Abi_1_55::from_lib(lib, symbol_name) }?;
+            Ok(Abi::Abi1_55(inner))
+        } else if info.version.1 < 57 {
+            let inner = unsafe { Abi_1_56::from_lib(lib, symbol_name) }?;
+            Ok(Abi::Abi1_56(inner))
+        } else {
+            let inner = unsafe { Abi_1_58::from_lib(lib, symbol_name) }?;
+            Ok(Abi::Abi1_58(inner))
         }
     }
 


Test patch:
diff --git a/crates/ide/src/hover/tests.rs b/crates/ide/src/hover/tests.rs
index 3b415c54fb..2aa54fc33f 100644
--- a/crates/ide/src/hover/tests.rs
+++ b/crates/ide/src/hover/tests.rs
@@ -503,52 +503,30 @@ fn hover_const_static() {
     check(
         r#"const foo$0: u32 = 123;"#,
         expect![[r#"
-            *foo*
-
-            ```rust
-            test
-            ```
-
-            ```rust
-            const foo: u32 = 123
-            ```
-        "#]],
-    );
-    check(
-        r#"
-const foo$0: u32 = {
-    let x = foo();
-    x + 100
-};"#,
-        expect![[r#"
-            *foo*
+                *foo*
 
-            ```rust
-            test
-            ```
+                ```rust
+                test
+                ```
 
-            ```rust
-            const foo: u32 = {
-                let x = foo();
-                x + 100
-            }
-            ```
-        "#]],
+                ```rust
+                const foo: u32
+                ```
+            "#]],
     );
-
     check(
         r#"static foo$0: u32 = 456;"#,
         expect![[r#"
-            *foo*
+                *foo*
 
-            ```rust
-            test
-            ```
+                ```rust
+                test
+                ```
 
-            ```rust
-            static foo: u32 = 456
-            ```
-        "#]],
+                ```rust
+                static foo: u32
+                ```
+            "#]],
     );
 }
 
@@ -810,16 +788,16 @@ fn main() {
 }
 "#,
         expect![[r#"
-            *C*
+                *C*
 
-            ```rust
-            test
-            ```
+                ```rust
+                test
+                ```
 
-            ```rust
-            const C: u32 = 1
-            ```
-        "#]],
+                ```rust
+                const C: u32
+                ```
+            "#]],
     )
 }
 
@@ -1718,43 +1696,40 @@ fn test_hover_test_has_action() {
 fn foo_$0test() {}
 "#,
         expect![[r#"
-            [
-                Reference(
-                    FilePosition {
-                        file_id: FileId(
-                            0,
-                        ),
-                        offset: 11,
-                    },
-                ),
-                Runnable(
-                    Runnable {
-                        use_name_in_title: false,
-                        nav: NavigationTarget {
+                [
+                    Reference(
+                        FilePosition {
                             file_id: FileId(
                                 0,
                             ),
-                            full_range: 0..24,
-                            focus_range: 11..19,
-                            name: "foo_test",
-                            kind: Function,
+                            offset: 11,
                         },
-                        kind: Test {
-                            test_id: Path(
-                                "foo_test",
-                            ),
-                            attr: TestAttr {
-                                ignore: false,
+                    ),
+                    Runnable(
+                        Runnable {
+                            use_name_in_title: false,
+                            nav: NavigationTarget {
+                                file_id: FileId(
+                                    0,
+                                ),
+                                full_range: 0..24,
+                                focus_range: 11..19,
+                                name: "foo_test",
+                                kind: Function,
                             },
+                            kind: Test {
+                                test_id: Path(
+                                    "foo_test",
+                                ),
+                                attr: TestAttr {
+                                    ignore: false,
+                                },
+                            },
+                            cfg: None,
                         },
-                        cfg: None,
-                    },
-                ),
-                GoToType(
-                    [],
-                ),
-            ]
-        "#]],
+                    ),
+                ]
+            "#]],
     );
 }
 
@@ -3201,20 +3176,20 @@ fn foo() {
 }
 "#,
         expect![[r#"
-            *FOO*
+                *FOO*
 
-            ```rust
-            test
-            ```
+                ```rust
+                test
+                ```
 
-            ```rust
-            const FOO: usize = 3
-            ```
+                ```rust
+                const FOO: usize
+                ```
 
-            ---
+                ---
 
-            This is a doc
-        "#]],
+                This is a doc
+            "#]],
     );
 }
 
diff --git a/crates/syntax/test_data/parser/inline/ok/0058_range_pat.rast b/crates/syntax/test_data/parser/inline/ok/0058_range_pat.rast
index 0eb5af54b8..5d5803f751 100644
--- a/crates/syntax/test_data/parser/inline/ok/0058_range_pat.rast
+++ b/crates/syntax/test_data/parser/inline/ok/0058_range_pat.rast
@@ -1,5 +1,5 @@
-SOURCE_FILE@0..307
-  FN@0..306
+SOURCE_FILE@0..223
+  FN@0..222
     FN_KW@0..2 "fn"
     WHITESPACE@2..3 " "
     NAME@3..7
@@ -8,8 +8,8 @@ SOURCE_FILE@0..307
       L_PAREN@7..8 "("
       R_PAREN@8..9 ")"
     WHITESPACE@9..10 " "
-    BLOCK_EXPR@10..306
-      STMT_LIST@10..306
+    BLOCK_EXPR@10..222
+      STMT_LIST@10..222
         L_CURLY@10..11 "{"
         WHITESPACE@11..16 "\n    "
         EXPR_STMT@16..132
@@ -96,156 +96,80 @@ SOURCE_FILE@0..307
               WHITESPACE@126..131 "\n    "
               R_CURLY@131..132 "}"
         WHITESPACE@132..138 "\n\n    "
-        EXPR_STMT@138..220
-          MATCH_EXPR@138..220
-            MATCH_KW@138..143 "match"
-            WHITESPACE@143..144 " "
-            CALL_EXPR@144..158
-              PATH_EXPR@144..148
-                PATH@144..148
-                  PATH_SEGMENT@144..148
-                    NAME_REF@144..148
-                      IDENT@144..148 "Some"
-              ARG_LIST@148..158
-                L_PAREN@148..149 "("
-                CAST_EXPR@149..157
-                  LITERAL@149..151
-                    INT_NUMBER@149..151 "10"
-                  WHITESPACE@151..152 " "
-                  AS_KW@152..154 "as"
-                  WHITESPACE@154..155 " "
-                  PATH_TYPE@155..157
-                    PATH@155..157
-                      PATH_SEGMENT@155..157
-                        NAME_REF@155..157
-                          IDENT@155..157 "u8"
-                R_PAREN@157..158 ")"
-            WHITESPACE@158..159 " "
-            MATCH_ARM_LIST@159..220
-              L_CURLY@159..160 "{"
-              WHITESPACE@160..169 "\n        "
-              MATCH_ARM@169..190
-                OR_PAT@169..183
-                  TUPLE_STRUCT_PAT@169..176
-                    PATH@169..173
-                      PATH_SEGMENT@169..173
-                        NAME_REF@169..173
-                          IDENT@169..173 "Some"
-                    L_PAREN@173..174 "("
-                    LITERAL_PAT@174..175
-                      LITERAL@174..175
-                        INT_NUMBER@174..175 "0"
-                    R_PAREN@175..176 ")"
-                  WHITESPACE@176..177 " "
-                  PIPE@177..178 "|"
-                  WHITESPACE@178..179 " "
-                  IDENT_PAT@179..183
-                    NAME@179..183
-                      IDENT@179..183 "None"
-                WHITESPACE@183..184 " "
-                FAT_ARROW@184..186 "=>"
-                WHITESPACE@186..187 " "
-                TUPLE_EXPR@187..189
-                  L_PAREN@187..188 "("
-                  R_PAREN@188..189 ")"
-                COMMA@189..190 ","
-              WHITESPACE@190..199 "\n        "
-              MATCH_ARM@199..214
-                TUPLE_STRUCT_PAT@199..208
-                  PATH@199..203
-                    PATH_SEGMENT@199..203
-                      NAME_REF@199..203
-                        IDENT@199..203 "Some"
-                  L_PAREN@203..204 "("
-                  RANGE_PAT@204..207
-                    LITERAL_PAT@204..205
-                      LITERAL@204..205
-                        INT_NUMBER@204..205 "1"
-                    DOT2@205..207 ".."
-                  R_PAREN@207..208 ")"
-                WHITESPACE@208..209 " "
-                FAT_ARROW@209..211 "=>"
-                WHITESPACE@211..212 " "
-                TUPLE_EXPR@212..214
-                  L_PAREN@212..213 "("
-                  R_PAREN@213..214 ")"
-              WHITESPACE@214..219 "\n    "
-              R_CURLY@219..220 "}"
-        WHITESPACE@220..226 "\n\n    "
-        MATCH_EXPR@226..304
-          MATCH_KW@226..231 "match"
-          WHITESPACE@231..232 " "
-          TUPLE_EXPR@232..251
-            L_PAREN@232..233 "("
-            CAST_EXPR@233..241
-              LITERAL@233..235
-                INT_NUMBER@233..235 "10"
-              WHITESPACE@235..236 " "
-              AS_KW@236..238 "as"
-              WHITESPACE@238..239 " "
-              PATH_TYPE@239..241
-                PATH@239..241
-                  PATH_SEGMENT@239..241
-                    NAME_REF@239..241
-                      IDENT@239..241 "u8"
-            COMMA@241..242 ","
-            WHITESPACE@242..243 " "
-            CAST_EXPR@243..250
-              LITERAL@243..244
-                INT_NUMBER@243..244 "5"
-              WHITESPACE@244..245 " "
-              AS_KW@245..247 "as"
-              WHITESPACE@247..248 " "
-              PATH_TYPE@248..250
-                PATH@248..250
-                  PATH_SEGMENT@248..250
-                    NAME_REF@248..250
-                      IDENT@248..250 "u8"
-            R_PAREN@250..251 ")"
-          WHITESPACE@251..252 " "
-          MATCH_ARM_LIST@252..304
-            L_CURLY@252..253 "{"
-            WHITESPACE@253..262 "\n        "
-            MATCH_ARM@262..275
-              TUPLE_PAT@262..268
-                L_PAREN@262..263 "("
-                LITERAL_PAT@263..264
-                  LITERAL@263..264
-                    INT_NUMBER@263..264 "0"
-                COMMA@264..265 ","
-                WHITESPACE@265..266 " "
-                WILDCARD_PAT@266..267
-                  UNDERSCORE@266..267 "_"
-                R_PAREN@267..268 ")"
-              WHITESPACE@268..269 " "
-              FAT_ARROW@269..271 "=>"
-              WHITESPACE@271..272 " "
-              TUPLE_EXPR@272..274
-                L_PAREN@272..273 "("
-                R_PAREN@273..274 ")"
-              COMMA@274..275 ","
-            WHITESPACE@275..284 "\n        "
-            MATCH_ARM@284..298
-              TUPLE_PAT@284..292
-                L_PAREN@284..285 "("
-                RANGE_PAT@285..288
-                  LITERAL_PAT@285..286
-                    LITERAL@285..286
-                      INT_NUMBER@285..286 "1"
-                  DOT2@286..288 ".."
-                COMMA@288..289 ","
-                WHITESPACE@289..290 " "
-                WILDCARD_PAT@290..291
-                  UNDERSCORE@290..291 "_"
-                R_PAREN@291..292 ")"
-              WHITESPACE@292..293 " "
-              FAT_ARROW@293..295 "=>"
-              WHITESPACE@295..296 " "
-              TUPLE_EXPR@296..298
-                L_PAREN@296..297 "("
-                R_PAREN@297..298 ")"
-            WHITESPACE@298..303 "\n    "
-            R_CURLY@303..304 "}"
-        WHITESPACE@304..305 "\n"
-        R_CURLY@305..306 "}"
-  WHITESPACE@306..307 "\n"
+        MATCH_EXPR@138..220
+          MATCH_KW@138..143 "match"
+          WHITESPACE@143..144 " "
+          CALL_EXPR@144..158
+            PATH_EXPR@144..148
+              PATH@144..148
+                PATH_SEGMENT@144..148
+                  NAME_REF@144..148
+                    IDENT@144..148 "Some"
+            ARG_LIST@148..158
+              L_PAREN@148..149 "("
+              CAST_EXPR@149..157
+                LITERAL@149..151
+                  INT_NUMBER@149..151 "10"
+                WHITESPACE@151..152 " "
+                AS_KW@152..154 "as"
+                WHITESPACE@154..155 " "
+                PATH_TYPE@155..157
+                  PATH@155..157
+                    PATH_SEGMENT@155..157
+                      NAME_REF@155..157
+                        IDENT@155..157 "u8"
+              R_PAREN@157..158 ")"
+          WHITESPACE@158..159 " "
+          MATCH_ARM_LIST@159..220
+            L_CURLY@159..160 "{"
+            WHITESPACE@160..169 "\n        "
+            MATCH_ARM@169..190
+              OR_PAT@169..183
+                TUPLE_STRUCT_PAT@169..176
+                  PATH@169..173
+                    PATH_SEGMENT@169..173
+                      NAME_REF@169..173
+                        IDENT@169..173 "Some"
+                  L_PAREN@173..174 "("
+                  LITERAL_PAT@174..175
+                    LITERAL@174..175
+                      INT_NUMBER@174..175 "0"
+                  R_PAREN@175..176 ")"
+                WHITESPACE@176..177 " "
+                PIPE@177..178 "|"
+                WHITESPACE@178..179 " "
+                IDENT_PAT@179..183
+                  NAME@179..183
+                    IDENT@179..183 "None"
+              WHITESPACE@183..184 " "
+              FAT_ARROW@184..186 "=>"
+              WHITESPACE@186..187 " "
+              TUPLE_EXPR@187..189
+                L_PAREN@187..188 "("
+                R_PAREN@188..189 ")"
+              COMMA@189..190 ","
+            WHITESPACE@190..199 "\n        "
+            MATCH_ARM@199..214
+              TUPLE_STRUCT_PAT@199..208
+                PATH@199..203
+                  PATH_SEGMENT@199..203
+                    NAME_REF@199..203
+                      IDENT@199..203 "Some"
+                L_PAREN@203..204 "("
+                RANGE_PAT@204..207
+                  LITERAL_PAT@204..205
+                    LITERAL@204..205
+                      INT_NUMBER@204..205 "1"
+                  DOT2@205..207 ".."
+                R_PAREN@207..208 ")"
+              WHITESPACE@208..209 " "
+              FAT_ARROW@209..211 "=>"
+              WHITESPACE@211..212 " "
+              TUPLE_EXPR@212..214
+                L_PAREN@212..213 "("
+                R_PAREN@213..214 ")"
+            WHITESPACE@214..219 "\n    "
+            R_CURLY@219..220 "}"
+        WHITESPACE@220..221 "\n"
+        R_CURLY@221..222 "}"
+  WHITESPACE@222..223 "\n"
diff --git a/crates/syntax/test_data/parser/inline/ok/0058_range_pat.rs b/crates/syntax/test_data/parser/inline/ok/0058_range_pat.rs
index 6c586a8956..fa91efd212 100644
--- a/crates/syntax/test_data/parser/inline/ok/0058_range_pat.rs
+++ b/crates/syntax/test_data/parser/inline/ok/0058_range_pat.rs
@@ -10,9 +10,4 @@ fn main() {
         Some(0) | None => (),
         Some(1..) => ()
     }
-
-    match (10 as u8, 5 as u8) {
-        (0, _) => (),
-        (1.., _) => ()
-    }
 }