diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 217f179751..02a3b62287 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,7 +10,7 @@ on: env: CARGO_INCREMENTAL: 0 CARGO_NET_RETRY: 10 - RUN_SLOW_TESTS: 1 + CI: 1 RUST_BACKTRACE: short RUSTFLAGS: -D warnings RUSTUP_MAX_RETRIES: 10 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index fd184e8f10..4db122ec75 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -60,6 +60,10 @@ jobs: if: matrix.os != 'ubuntu-latest' run: cargo xtask dist + - name: Nightly analysis-stats check + if: matrix.os == 'ubuntu-latest' && github.ref != 'refs/heads/release' + run: ./dist/rust-analyzer-linux analysis-stats . + - name: Upload artifacts uses: actions/upload-artifact@v1 with: diff --git a/Cargo.lock b/Cargo.lock index 91a57bf796..eb9824218f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -995,6 +995,7 @@ dependencies = [ "ra_prof", "ra_syntax", "rustc-hash", + "smallvec", "stdx", "test_utils", ] diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs index fa3d3913f8..c698d6e8c4 100644 --- a/crates/ra_assists/src/lib.rs +++ b/crates/ra_assists/src/lib.rs @@ -5,6 +5,11 @@ //! certain context. For example, if the cursor is over `,`, a "swap `,`" assist //! becomes available. +#[allow(unused)] +macro_rules! eprintln { + ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; +} + mod assist_ctx; mod marks; #[cfg(test)] diff --git a/crates/ra_hir/src/diagnostics.rs b/crates/ra_hir/src/diagnostics.rs index a9040ea3d5..c82883d0c1 100644 --- a/crates/ra_hir/src/diagnostics.rs +++ b/crates/ra_hir/src/diagnostics.rs @@ -1,4 +1,4 @@ //! FIXME: write short doc here pub use hir_def::diagnostics::UnresolvedModule; pub use hir_expand::diagnostics::{AstDiagnostic, Diagnostic, DiagnosticSink}; -pub use hir_ty::diagnostics::{MissingFields, MissingOkInTailExpr, NoSuchField}; +pub use hir_ty::diagnostics::{MissingFields, MissingMatchArms, MissingOkInTailExpr, NoSuchField}; diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs index 16a5fe9680..2ad231d368 100644 --- a/crates/ra_hir/src/semantics.rs +++ b/crates/ra_hir/src/semantics.rs @@ -9,6 +9,7 @@ use hir_def::{ AsMacroCall, TraitId, }; use hir_expand::ExpansionInfo; +use itertools::Itertools; use ra_db::{FileId, FileRange}; use ra_prof::profile; use ra_syntax::{ @@ -135,7 +136,6 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { node: &SyntaxNode, offset: TextUnit, ) -> impl Iterator + '_ { - use itertools::Itertools; node.token_at_offset(offset) .map(|token| self.ancestors_with_macros(token.parent())) .kmerge_by(|node1, node2| node1.text_range().len() < node2.text_range().len()) diff --git a/crates/ra_hir/src/semantics/source_to_def.rs b/crates/ra_hir/src/semantics/source_to_def.rs index 8843f28354..66724919b0 100644 --- a/crates/ra_hir/src/semantics/source_to_def.rs +++ b/crates/ra_hir/src/semantics/source_to_def.rs @@ -208,12 +208,12 @@ impl SourceToDefCtx<'_, '_> { for container in src.cloned().ancestors_with_macros(self.db.upcast()).skip(1) { let res: GenericDefId = match_ast! { match (container.value) { - ast::FnDef(it) => { self.fn_to_def(container.with_value(it))?.into() }, - ast::StructDef(it) => { self.struct_to_def(container.with_value(it))?.into() }, - ast::EnumDef(it) => { self.enum_to_def(container.with_value(it))?.into() }, - ast::TraitDef(it) => { self.trait_to_def(container.with_value(it))?.into() }, - ast::TypeAliasDef(it) => { self.type_alias_to_def(container.with_value(it))?.into() }, - ast::ImplDef(it) => { self.impl_to_def(container.with_value(it))?.into() }, + ast::FnDef(it) => self.fn_to_def(container.with_value(it))?.into(), + ast::StructDef(it) => self.struct_to_def(container.with_value(it))?.into(), + ast::EnumDef(it) => self.enum_to_def(container.with_value(it))?.into(), + ast::TraitDef(it) => self.trait_to_def(container.with_value(it))?.into(), + ast::TypeAliasDef(it) => self.type_alias_to_def(container.with_value(it))?.into(), + ast::ImplDef(it) => self.impl_to_def(container.with_value(it))?.into(), _ => continue, } }; @@ -226,9 +226,9 @@ impl SourceToDefCtx<'_, '_> { for container in src.cloned().ancestors_with_macros(self.db.upcast()).skip(1) { let res: DefWithBodyId = match_ast! { match (container.value) { - ast::ConstDef(it) => { self.const_to_def(container.with_value(it))?.into() }, - ast::StaticDef(it) => { self.static_to_def(container.with_value(it))?.into() }, - ast::FnDef(it) => { self.fn_to_def(container.with_value(it))?.into() }, + ast::ConstDef(it) => self.const_to_def(container.with_value(it))?.into(), + ast::StaticDef(it) => self.static_to_def(container.with_value(it))?.into(), + ast::FnDef(it) => self.fn_to_def(container.with_value(it))?.into(), _ => continue, } }; diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index bd32ac20aa..2d27bbdf8e 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs @@ -7,6 +7,11 @@ //! Note that `hir_def` is a work in progress, so not all of the above is //! actually true. +#[allow(unused)] +macro_rules! eprintln { + ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; +} + pub mod db; pub mod attr; diff --git a/crates/ra_hir_expand/src/builtin_derive.rs b/crates/ra_hir_expand/src/builtin_derive.rs index 79aea5806c..bb45b0f1da 100644 --- a/crates/ra_hir_expand/src/builtin_derive.rs +++ b/crates/ra_hir_expand/src/builtin_derive.rs @@ -73,9 +73,9 @@ fn parse_adt(tt: &tt::Subtree) -> Result { let node = item.syntax(); let (name, params) = match_ast! { match node { - ast::StructDef(it) => { (it.name(), it.type_param_list()) }, - ast::EnumDef(it) => { (it.name(), it.type_param_list()) }, - ast::UnionDef(it) => { (it.name(), it.type_param_list()) }, + ast::StructDef(it) => (it.name(), it.type_param_list()), + ast::EnumDef(it) => (it.name(), it.type_param_list()), + ast::UnionDef(it) => (it.name(), it.type_param_list()), _ => { debug!("unexpected node is {:?}", node); return Err(mbe::ExpandError::ConversionError) diff --git a/crates/ra_hir_ty/Cargo.toml b/crates/ra_hir_ty/Cargo.toml index 45be08430a..9a4a7aa6f7 100644 --- a/crates/ra_hir_ty/Cargo.toml +++ b/crates/ra_hir_ty/Cargo.toml @@ -9,6 +9,7 @@ doctest = false [dependencies] arrayvec = "0.5.1" +smallvec = "1.2.0" ena = "0.13.1" log = "0.4.8" rustc-hash = "1.1.0" diff --git a/crates/ra_hir_ty/src/_match.rs b/crates/ra_hir_ty/src/_match.rs new file mode 100644 index 0000000000..f29a25505b --- /dev/null +++ b/crates/ra_hir_ty/src/_match.rs @@ -0,0 +1,1411 @@ +//! This module implements match statement exhaustiveness checking and usefulness checking +//! for match arms. +//! +//! It is modeled on the rustc module `librustc_mir_build::hair::pattern::_match`, which +//! contains very detailed documentation about the algorithms used here. I've duplicated +//! most of that documentation below. +//! +//! This file includes the logic for exhaustiveness and usefulness checking for +//! pattern-matching. Specifically, given a list of patterns for a type, we can +//! tell whether: +//! (a) the patterns cover every possible constructor for the type [exhaustiveness] +//! (b) each pattern is necessary [usefulness] +//! +//! The algorithm implemented here is a modified version of the one described in: +//! http://moscova.inria.fr/~maranget/papers/warn/index.html +//! However, to save future implementors from reading the original paper, we +//! summarise the algorithm here to hopefully save time and be a little clearer +//! (without being so rigorous). +//! +//! The core of the algorithm revolves about a "usefulness" check. In particular, we +//! are trying to compute a predicate `U(P, p)` where `P` is a list of patterns (we refer to this as +//! a matrix). `U(P, p)` represents whether, given an existing list of patterns +//! `P_1 ..= P_m`, adding a new pattern `p` will be "useful" (that is, cover previously- +//! uncovered values of the type). +//! +//! If we have this predicate, then we can easily compute both exhaustiveness of an +//! entire set of patterns and the individual usefulness of each one. +//! (a) the set of patterns is exhaustive iff `U(P, _)` is false (i.e., adding a wildcard +//! match doesn't increase the number of values we're matching) +//! (b) a pattern `P_i` is not useful if `U(P[0..=(i-1), P_i)` is false (i.e., adding a +//! pattern to those that have come before it doesn't increase the number of values +//! we're matching). +//! +//! During the course of the algorithm, the rows of the matrix won't just be individual patterns, +//! but rather partially-deconstructed patterns in the form of a list of patterns. The paper +//! calls those pattern-vectors, and we will call them pattern-stacks. The same holds for the +//! new pattern `p`. +//! +//! For example, say we have the following: +//! ``` +//! // x: (Option, Result<()>) +//! match x { +//! (Some(true), _) => {} +//! (None, Err(())) => {} +//! (None, Err(_)) => {} +//! } +//! ``` +//! Here, the matrix `P` starts as: +//! [ +//! [(Some(true), _)], +//! [(None, Err(()))], +//! [(None, Err(_))], +//! ] +//! We can tell it's not exhaustive, because `U(P, _)` is true (we're not covering +//! `[(Some(false), _)]`, for instance). In addition, row 3 is not useful, because +//! all the values it covers are already covered by row 2. +//! +//! A list of patterns can be thought of as a stack, because we are mainly interested in the top of +//! the stack at any given point, and we can pop or apply constructors to get new pattern-stacks. +//! To match the paper, the top of the stack is at the beginning / on the left. +//! +//! There are two important operations on pattern-stacks necessary to understand the algorithm: +//! 1. We can pop a given constructor off the top of a stack. This operation is called +//! `specialize`, and is denoted `S(c, p)` where `c` is a constructor (like `Some` or +//! `None`) and `p` a pattern-stack. +//! If the pattern on top of the stack can cover `c`, this removes the constructor and +//! pushes its arguments onto the stack. It also expands OR-patterns into distinct patterns. +//! Otherwise the pattern-stack is discarded. +//! This essentially filters those pattern-stacks whose top covers the constructor `c` and +//! discards the others. +//! +//! For example, the first pattern above initially gives a stack `[(Some(true), _)]`. If we +//! pop the tuple constructor, we are left with `[Some(true), _]`, and if we then pop the +//! `Some` constructor we get `[true, _]`. If we had popped `None` instead, we would get +//! nothing back. +//! +//! This returns zero or more new pattern-stacks, as follows. We look at the pattern `p_1` +//! on top of the stack, and we have four cases: +//! 1.1. `p_1 = c(r_1, .., r_a)`, i.e. the top of the stack has constructor `c`. We +//! push onto the stack the arguments of this constructor, and return the result: +//! r_1, .., r_a, p_2, .., p_n +//! 1.2. `p_1 = c'(r_1, .., r_a')` where `c ≠ c'`. We discard the current stack and +//! return nothing. +//! 1.3. `p_1 = _`. We push onto the stack as many wildcards as the constructor `c` has +//! arguments (its arity), and return the resulting stack: +//! _, .., _, p_2, .., p_n +//! 1.4. `p_1 = r_1 | r_2`. We expand the OR-pattern and then recurse on each resulting +//! stack: +//! S(c, (r_1, p_2, .., p_n)) +//! S(c, (r_2, p_2, .., p_n)) +//! +//! 2. We can pop a wildcard off the top of the stack. This is called `D(p)`, where `p` is +//! a pattern-stack. +//! This is used when we know there are missing constructor cases, but there might be +//! existing wildcard patterns, so to check the usefulness of the matrix, we have to check +//! all its *other* components. +//! +//! It is computed as follows. We look at the pattern `p_1` on top of the stack, +//! and we have three cases: +//! 1.1. `p_1 = c(r_1, .., r_a)`. We discard the current stack and return nothing. +//! 1.2. `p_1 = _`. We return the rest of the stack: +//! p_2, .., p_n +//! 1.3. `p_1 = r_1 | r_2`. We expand the OR-pattern and then recurse on each resulting +//! stack. +//! D((r_1, p_2, .., p_n)) +//! D((r_2, p_2, .., p_n)) +//! +//! Note that the OR-patterns are not always used directly in Rust, but are used to derive the +//! exhaustive integer matching rules, so they're written here for posterity. +//! +//! Both those operations extend straightforwardly to a list or pattern-stacks, i.e. a matrix, by +//! working row-by-row. Popping a constructor ends up keeping only the matrix rows that start with +//! the given constructor, and popping a wildcard keeps those rows that start with a wildcard. +//! +//! +//! The algorithm for computing `U` +//! ------------------------------- +//! The algorithm is inductive (on the number of columns: i.e., components of tuple patterns). +//! That means we're going to check the components from left-to-right, so the algorithm +//! operates principally on the first component of the matrix and new pattern-stack `p`. +//! This algorithm is realised in the `is_useful` function. +//! +//! Base case. (`n = 0`, i.e., an empty tuple pattern) +//! - If `P` already contains an empty pattern (i.e., if the number of patterns `m > 0`), +//! then `U(P, p)` is false. +//! - Otherwise, `P` must be empty, so `U(P, p)` is true. +//! +//! Inductive step. (`n > 0`, i.e., whether there's at least one column +//! [which may then be expanded into further columns later]) +//! We're going to match on the top of the new pattern-stack, `p_1`. +//! - If `p_1 == c(r_1, .., r_a)`, i.e. we have a constructor pattern. +//! Then, the usefulness of `p_1` can be reduced to whether it is useful when +//! we ignore all the patterns in the first column of `P` that involve other constructors. +//! This is where `S(c, P)` comes in: +//! `U(P, p) := U(S(c, P), S(c, p))` +//! This special case is handled in `is_useful_specialized`. +//! +//! For example, if `P` is: +//! [ +//! [Some(true), _], +//! [None, 0], +//! ] +//! and `p` is [Some(false), 0], then we don't care about row 2 since we know `p` only +//! matches values that row 2 doesn't. For row 1 however, we need to dig into the +//! arguments of `Some` to know whether some new value is covered. So we compute +//! `U([[true, _]], [false, 0])`. +//! +//! - If `p_1 == _`, then we look at the list of constructors that appear in the first +//! component of the rows of `P`: +//! + If there are some constructors that aren't present, then we might think that the +//! wildcard `_` is useful, since it covers those constructors that weren't covered +//! before. +//! That's almost correct, but only works if there were no wildcards in those first +//! components. So we need to check that `p` is useful with respect to the rows that +//! start with a wildcard, if there are any. This is where `D` comes in: +//! `U(P, p) := U(D(P), D(p))` +//! +//! For example, if `P` is: +//! [ +//! [_, true, _], +//! [None, false, 1], +//! ] +//! and `p` is [_, false, _], the `Some` constructor doesn't appear in `P`. So if we +//! only had row 2, we'd know that `p` is useful. However row 1 starts with a +//! wildcard, so we need to check whether `U([[true, _]], [false, 1])`. +//! +//! + Otherwise, all possible constructors (for the relevant type) are present. In this +//! case we must check whether the wildcard pattern covers any unmatched value. For +//! that, we can think of the `_` pattern as a big OR-pattern that covers all +//! possible constructors. For `Option`, that would mean `_ = None | Some(_)` for +//! example. The wildcard pattern is useful in this case if it is useful when +//! specialized to one of the possible constructors. So we compute: +//! `U(P, p) := ∃(k ϵ constructors) U(S(k, P), S(k, p))` +//! +//! For example, if `P` is: +//! [ +//! [Some(true), _], +//! [None, false], +//! ] +//! and `p` is [_, false], both `None` and `Some` constructors appear in the first +//! components of `P`. We will therefore try popping both constructors in turn: we +//! compute U([[true, _]], [_, false]) for the `Some` constructor, and U([[false]], +//! [false]) for the `None` constructor. The first case returns true, so we know that +//! `p` is useful for `P`. Indeed, it matches `[Some(false), _]` that wasn't matched +//! before. +//! +//! - If `p_1 == r_1 | r_2`, then the usefulness depends on each `r_i` separately: +//! `U(P, p) := U(P, (r_1, p_2, .., p_n)) +//! || U(P, (r_2, p_2, .., p_n))` +use std::sync::Arc; + +use smallvec::{smallvec, SmallVec}; + +use crate::{ + db::HirDatabase, + expr::{Body, Expr, Literal, Pat, PatId}, + InferenceResult, +}; +use hir_def::{adt::VariantData, EnumVariantId, VariantId}; + +#[derive(Debug, Clone, Copy)] +/// Either a pattern from the source code being analyzed, represented as +/// as `PatId`, or a `Wild` pattern which is created as an intermediate +/// step in the match checking algorithm and thus is not backed by a +/// real `PatId`. +/// +/// Note that it is totally valid for the `PatId` variant to contain +/// a `PatId` which resolves to a `Wild` pattern, if that wild pattern +/// exists in the source code being analyzed. +enum PatIdOrWild { + PatId(PatId), + Wild, +} + +impl PatIdOrWild { + fn as_pat(self, cx: &MatchCheckCtx) -> Pat { + match self { + PatIdOrWild::PatId(id) => cx.body.pats[id].clone(), + PatIdOrWild::Wild => Pat::Wild, + } + } + + fn as_id(self) -> Option { + match self { + PatIdOrWild::PatId(id) => Some(id), + PatIdOrWild::Wild => None, + } + } +} + +impl From for PatIdOrWild { + fn from(pat_id: PatId) -> Self { + Self::PatId(pat_id) + } +} + +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct MatchCheckNotImplemented; + +/// The return type of `is_useful` is either an indication of usefulness +/// of the match arm, or an error in the case the match statement +/// is made up of types for which exhaustiveness checking is currently +/// not completely implemented. +/// +/// The `std::result::Result` type is used here rather than a custom enum +/// to allow the use of `?`. +pub type MatchCheckResult = Result; + +#[derive(Debug)] +/// A row in a Matrix. +/// +/// This type is modeled from the struct of the same name in `rustc`. +pub(crate) struct PatStack(PatStackInner); +type PatStackInner = SmallVec<[PatIdOrWild; 2]>; + +impl PatStack { + pub(crate) fn from_pattern(pat_id: PatId) -> PatStack { + Self(smallvec!(pat_id.into())) + } + + pub(crate) fn from_wild() -> PatStack { + Self(smallvec!(PatIdOrWild::Wild)) + } + + fn from_slice(slice: &[PatIdOrWild]) -> PatStack { + Self(SmallVec::from_slice(slice)) + } + + fn from_vec(v: PatStackInner) -> PatStack { + Self(v) + } + + fn is_empty(&self) -> bool { + self.0.is_empty() + } + + fn head(&self) -> PatIdOrWild { + self.0[0] + } + + fn get_head(&self) -> Option { + self.0.first().copied() + } + + fn to_tail(&self) -> PatStack { + Self::from_slice(&self.0[1..]) + } + + fn replace_head_with(&self, pat_ids: &[PatId]) -> PatStack { + let mut patterns: PatStackInner = smallvec![]; + for pat in pat_ids { + patterns.push((*pat).into()); + } + for pat in &self.0[1..] { + patterns.push(*pat); + } + PatStack::from_vec(patterns) + } + + /// Computes `D(self)`. + /// + /// See the module docs and the associated documentation in rustc for details. + fn specialize_wildcard(&self, cx: &MatchCheckCtx) -> Option { + if matches!(self.head().as_pat(cx), Pat::Wild) { + Some(self.to_tail()) + } else { + None + } + } + + /// Computes `S(constructor, self)`. + /// + /// See the module docs and the associated documentation in rustc for details. + fn specialize_constructor( + &self, + cx: &MatchCheckCtx, + constructor: &Constructor, + ) -> MatchCheckResult> { + let result = match (self.head().as_pat(cx), constructor) { + (Pat::Tuple(ref pat_ids), Constructor::Tuple { arity }) => { + debug_assert_eq!( + pat_ids.len(), + *arity, + "we type check before calling this code, so we should never hit this case", + ); + + Some(self.replace_head_with(pat_ids)) + } + (Pat::Lit(lit_expr), Constructor::Bool(constructor_val)) => { + match cx.body.exprs[lit_expr] { + Expr::Literal(Literal::Bool(pat_val)) if *constructor_val == pat_val => { + Some(self.to_tail()) + } + // it was a bool but the value doesn't match + Expr::Literal(Literal::Bool(_)) => None, + // perhaps this is actually unreachable given we have + // already checked that these match arms have the appropriate type? + _ => return Err(MatchCheckNotImplemented), + } + } + (Pat::Wild, constructor) => Some(self.expand_wildcard(cx, constructor)?), + (Pat::Path(_), Constructor::Enum(constructor)) => { + // enums with no associated data become `Pat::Path` + let pat_id = self.head().as_id().expect("we know this isn't a wild"); + if !enum_variant_matches(cx, pat_id, *constructor) { + None + } else { + Some(self.to_tail()) + } + } + (Pat::TupleStruct { args: ref pat_ids, .. }, Constructor::Enum(constructor)) => { + let pat_id = self.head().as_id().expect("we know this isn't a wild"); + if !enum_variant_matches(cx, pat_id, *constructor) { + None + } else { + Some(self.replace_head_with(pat_ids)) + } + } + (Pat::Or(_), _) => return Err(MatchCheckNotImplemented), + (_, _) => return Err(MatchCheckNotImplemented), + }; + + Ok(result) + } + + /// A special case of `specialize_constructor` where the head of the pattern stack + /// is a Wild pattern. + /// + /// Replaces the Wild pattern at the head of the pattern stack with N Wild patterns + /// (N >= 0), where N is the arity of the given constructor. + fn expand_wildcard( + &self, + cx: &MatchCheckCtx, + constructor: &Constructor, + ) -> MatchCheckResult { + assert_eq!( + Pat::Wild, + self.head().as_pat(cx), + "expand_wildcard must only be called on PatStack with wild at head", + ); + + let mut patterns: PatStackInner = smallvec![]; + + for _ in 0..constructor.arity(cx)? { + patterns.push(PatIdOrWild::Wild); + } + + for pat in &self.0[1..] { + patterns.push(*pat); + } + + Ok(PatStack::from_vec(patterns)) + } +} + +#[derive(Debug)] +/// A collection of PatStack. +/// +/// This type is modeled from the struct of the same name in `rustc`. +pub(crate) struct Matrix(Vec); + +impl Matrix { + pub(crate) fn empty() -> Self { + Self(vec![]) + } + + pub(crate) fn push(&mut self, cx: &MatchCheckCtx, row: PatStack) { + if let Some(Pat::Or(pat_ids)) = row.get_head().map(|pat_id| pat_id.as_pat(cx)) { + // Or patterns are expanded here + for pat_id in pat_ids { + self.0.push(PatStack::from_pattern(pat_id)); + } + } else { + self.0.push(row); + } + } + + fn is_empty(&self) -> bool { + self.0.is_empty() + } + + fn heads(&self) -> Vec { + self.0.iter().map(|p| p.head()).collect() + } + + /// Computes `D(self)` for each contained PatStack. + /// + /// See the module docs and the associated documentation in rustc for details. + fn specialize_wildcard(&self, cx: &MatchCheckCtx) -> Self { + Self::collect(cx, self.0.iter().filter_map(|r| r.specialize_wildcard(cx))) + } + + /// Computes `S(constructor, self)` for each contained PatStack. + /// + /// See the module docs and the associated documentation in rustc for details. + fn specialize_constructor( + &self, + cx: &MatchCheckCtx, + constructor: &Constructor, + ) -> MatchCheckResult { + let mut new_matrix = Matrix::empty(); + for pat in &self.0 { + if let Some(pat) = pat.specialize_constructor(cx, constructor)? { + new_matrix.push(cx, pat); + } + } + + Ok(new_matrix) + } + + fn collect>(cx: &MatchCheckCtx, iter: T) -> Self { + let mut matrix = Matrix::empty(); + + for pat in iter { + // using push ensures we expand or-patterns + matrix.push(cx, pat); + } + + matrix + } +} + +#[derive(Clone, Debug, PartialEq)] +/// An indication of the usefulness of a given match arm, where +/// usefulness is defined as matching some patterns which were +/// not matched by an prior match arms. +/// +/// We may eventually need an `Unknown` variant here. +pub enum Usefulness { + Useful, + NotUseful, +} + +pub struct MatchCheckCtx<'a> { + pub body: Arc, + pub infer: Arc, + pub db: &'a dyn HirDatabase, +} + +/// Given a set of patterns `matrix`, and pattern to consider `v`, determines +/// whether `v` is useful. A pattern is useful if it covers cases which were +/// not previously covered. +/// +/// When calling this function externally (that is, not the recursive calls) it +/// expected that you have already type checked the match arms. All patterns in +/// matrix should be the same type as v, as well as they should all be the same +/// type as the match expression. +pub(crate) fn is_useful( + cx: &MatchCheckCtx, + matrix: &Matrix, + v: &PatStack, +) -> MatchCheckResult { + if v.is_empty() { + let result = if matrix.is_empty() { Usefulness::Useful } else { Usefulness::NotUseful }; + + return Ok(result); + } + + if let Pat::Or(pat_ids) = v.head().as_pat(cx) { + let mut found_unimplemented = false; + let any_useful = pat_ids.iter().any(|&pat_id| { + let v = PatStack::from_pattern(pat_id); + + match is_useful(cx, matrix, &v) { + Ok(Usefulness::Useful) => true, + Ok(Usefulness::NotUseful) => false, + _ => { + found_unimplemented = true; + false + } + } + }); + + return if any_useful { + Ok(Usefulness::Useful) + } else if found_unimplemented { + Err(MatchCheckNotImplemented) + } else { + Ok(Usefulness::NotUseful) + }; + } + + if let Some(constructor) = pat_constructor(cx, v.head())? { + let matrix = matrix.specialize_constructor(&cx, &constructor)?; + let v = v + .specialize_constructor(&cx, &constructor)? + .expect("we know this can't fail because we get the constructor from `v.head()` above"); + + is_useful(&cx, &matrix, &v) + } else { + // expanding wildcard + let mut used_constructors: Vec = vec![]; + for pat in matrix.heads() { + if let Some(constructor) = pat_constructor(cx, pat)? { + used_constructors.push(constructor); + } + } + + // We assume here that the first constructor is the "correct" type. Since we + // only care about the "type" of the constructor (i.e. if it is a bool we + // don't care about the value), this assumption should be valid as long as + // the match statement is well formed. We currently uphold this invariant by + // filtering match arms before calling `is_useful`, only passing in match arms + // whose type matches the type of the match expression. + match &used_constructors.first() { + Some(constructor) if all_constructors_covered(&cx, constructor, &used_constructors) => { + // If all constructors are covered, then we need to consider whether + // any values are covered by this wildcard. + // + // For example, with matrix '[[Some(true)], [None]]', all + // constructors are covered (`Some`/`None`), so we need + // to perform specialization to see that our wildcard will cover + // the `Some(false)` case. + // + // Here we create a constructor for each variant and then check + // usefulness after specializing for that constructor. + let mut found_unimplemented = false; + for constructor in constructor.all_constructors(cx) { + let matrix = matrix.specialize_constructor(&cx, &constructor)?; + let v = v.expand_wildcard(&cx, &constructor)?; + + match is_useful(&cx, &matrix, &v) { + Ok(Usefulness::Useful) => return Ok(Usefulness::Useful), + Ok(Usefulness::NotUseful) => continue, + _ => found_unimplemented = true, + }; + } + + if found_unimplemented { + Err(MatchCheckNotImplemented) + } else { + Ok(Usefulness::NotUseful) + } + } + _ => { + // Either not all constructors are covered, or the only other arms + // are wildcards. Either way, this pattern is useful if it is useful + // when compared to those arms with wildcards. + let matrix = matrix.specialize_wildcard(&cx); + let v = v.to_tail(); + + is_useful(&cx, &matrix, &v) + } + } + } +} + +#[derive(Debug, Clone, Copy)] +/// Similar to TypeCtor, but includes additional information about the specific +/// value being instantiated. For example, TypeCtor::Bool doesn't contain the +/// boolean value. +enum Constructor { + Bool(bool), + Tuple { arity: usize }, + Enum(EnumVariantId), +} + +impl Constructor { + fn arity(&self, cx: &MatchCheckCtx) -> MatchCheckResult { + let arity = match self { + Constructor::Bool(_) => 0, + Constructor::Tuple { arity } => *arity, + Constructor::Enum(e) => { + match cx.db.enum_data(e.parent).variants[e.local_id].variant_data.as_ref() { + VariantData::Tuple(struct_field_data) => struct_field_data.len(), + VariantData::Unit => 0, + _ => return Err(MatchCheckNotImplemented), + } + } + }; + + Ok(arity) + } + + fn all_constructors(&self, cx: &MatchCheckCtx) -> Vec { + match self { + Constructor::Bool(_) => vec![Constructor::Bool(true), Constructor::Bool(false)], + Constructor::Tuple { .. } => vec![*self], + Constructor::Enum(e) => cx + .db + .enum_data(e.parent) + .variants + .iter() + .map(|(local_id, _)| { + Constructor::Enum(EnumVariantId { parent: e.parent, local_id }) + }) + .collect(), + } + } +} + +/// Returns the constructor for the given pattern. Should only return None +/// in the case of a Wild pattern. +fn pat_constructor(cx: &MatchCheckCtx, pat: PatIdOrWild) -> MatchCheckResult> { + let res = match pat.as_pat(cx) { + Pat::Wild => None, + Pat::Tuple(pats) => Some(Constructor::Tuple { arity: pats.len() }), + Pat::Lit(lit_expr) => match cx.body.exprs[lit_expr] { + Expr::Literal(Literal::Bool(val)) => Some(Constructor::Bool(val)), + _ => return Err(MatchCheckNotImplemented), + }, + Pat::TupleStruct { .. } | Pat::Path(_) => { + let pat_id = pat.as_id().expect("we already know this pattern is not a wild"); + let variant_id = + cx.infer.variant_resolution_for_pat(pat_id).ok_or(MatchCheckNotImplemented)?; + match variant_id { + VariantId::EnumVariantId(enum_variant_id) => { + Some(Constructor::Enum(enum_variant_id)) + } + _ => return Err(MatchCheckNotImplemented), + } + } + _ => return Err(MatchCheckNotImplemented), + }; + + Ok(res) +} + +fn all_constructors_covered( + cx: &MatchCheckCtx, + constructor: &Constructor, + used_constructors: &[Constructor], +) -> bool { + match constructor { + Constructor::Tuple { arity } => { + used_constructors.iter().any(|constructor| match constructor { + Constructor::Tuple { arity: used_arity } => arity == used_arity, + _ => false, + }) + } + Constructor::Bool(_) => { + if used_constructors.is_empty() { + return false; + } + + let covers_true = + used_constructors.iter().any(|c| matches!(c, Constructor::Bool(true))); + let covers_false = + used_constructors.iter().any(|c| matches!(c, Constructor::Bool(false))); + + covers_true && covers_false + } + Constructor::Enum(e) => cx.db.enum_data(e.parent).variants.iter().all(|(id, _)| { + for constructor in used_constructors { + if let Constructor::Enum(e) = constructor { + if id == e.local_id { + return true; + } + } + } + + false + }), + } +} + +fn enum_variant_matches(cx: &MatchCheckCtx, pat_id: PatId, enum_variant_id: EnumVariantId) -> bool { + Some(enum_variant_id.into()) == cx.infer.variant_resolution_for_pat(pat_id) +} + +#[cfg(test)] +mod tests { + pub(super) use insta::assert_snapshot; + pub(super) use ra_db::fixture::WithFixture; + + pub(super) use crate::test_db::TestDB; + + pub(super) fn check_diagnostic_message(content: &str) -> String { + TestDB::with_single_file(content).0.diagnostics().0 + } + + pub(super) fn check_diagnostic(content: &str) { + let diagnostic_count = TestDB::with_single_file(content).0.diagnostics().1; + + assert_eq!(1, diagnostic_count, "no diagnostic reported"); + } + + pub(super) fn check_no_diagnostic(content: &str) { + let diagnostic_count = TestDB::with_single_file(content).0.diagnostics().1; + + assert_eq!(0, diagnostic_count, "expected no diagnostic, found one"); + } + + #[test] + fn empty_tuple_no_arms_diagnostic_message() { + let content = r" + fn test_fn() { + match () { + } + } + "; + + assert_snapshot!( + check_diagnostic_message(content), + @"\"()\": Missing match arm\n" + ); + } + + #[test] + fn empty_tuple_no_arms() { + let content = r" + fn test_fn() { + match () { + } + } + "; + + check_diagnostic(content); + } + + #[test] + fn empty_tuple_wild() { + let content = r" + fn test_fn() { + match () { + _ => {} + } + } + "; + + check_no_diagnostic(content); + } + + #[test] + fn empty_tuple_no_diagnostic() { + let content = r" + fn test_fn() { + match () { + () => {} + } + } + "; + + check_no_diagnostic(content); + } + + #[test] + fn tuple_of_empty_tuple_no_arms() { + let content = r" + fn test_fn() { + match (()) { + } + } + "; + + check_diagnostic(content); + } + + #[test] + fn tuple_of_empty_tuple_no_diagnostic() { + let content = r" + fn test_fn() { + match (()) { + (()) => {} + } + } + "; + + check_no_diagnostic(content); + } + + #[test] + fn tuple_of_two_empty_tuple_no_arms() { + let content = r" + fn test_fn() { + match ((), ()) { + } + } + "; + + check_diagnostic(content); + } + + #[test] + fn tuple_of_two_empty_tuple_no_diagnostic() { + let content = r" + fn test_fn() { + match ((), ()) { + ((), ()) => {} + } + } + "; + + check_no_diagnostic(content); + } + + #[test] + fn bool_no_arms() { + let content = r" + fn test_fn() { + match false { + } + } + "; + + check_diagnostic(content); + } + + #[test] + fn bool_missing_arm() { + let content = r" + fn test_fn() { + match false { + true => {} + } + } + "; + + check_diagnostic(content); + } + + #[test] + fn bool_no_diagnostic() { + let content = r" + fn test_fn() { + match false { + true => {} + false => {} + } + } + "; + + check_no_diagnostic(content); + } + + #[test] + fn tuple_of_bools_no_arms() { + let content = r" + fn test_fn() { + match (false, true) { + } + } + "; + + check_diagnostic(content); + } + + #[test] + fn tuple_of_bools_missing_arms() { + let content = r" + fn test_fn() { + match (false, true) { + (true, true) => {}, + } + } + "; + + check_diagnostic(content); + } + + #[test] + fn tuple_of_bools_missing_arm() { + let content = r" + fn test_fn() { + match (false, true) { + (false, true) => {}, + (false, false) => {}, + (true, false) => {}, + } + } + "; + + check_diagnostic(content); + } + + #[test] + fn tuple_of_bools_with_wilds() { + let content = r" + fn test_fn() { + match (false, true) { + (false, _) => {}, + (true, false) => {}, + (_, true) => {}, + } + } + "; + + check_no_diagnostic(content); + } + + #[test] + fn tuple_of_bools_no_diagnostic() { + let content = r" + fn test_fn() { + match (false, true) { + (true, true) => {}, + (true, false) => {}, + (false, true) => {}, + (false, false) => {}, + } + } + "; + + check_no_diagnostic(content); + } + + #[test] + fn tuple_of_bools_binding_missing_arms() { + let content = r" + fn test_fn() { + match (false, true) { + (true, _x) => {}, + } + } + "; + + check_diagnostic(content); + } + + #[test] + fn tuple_of_bools_binding_no_diagnostic() { + let content = r" + fn test_fn() { + match (false, true) { + (true, _x) => {}, + (false, true) => {}, + (false, false) => {}, + } + } + "; + + check_no_diagnostic(content); + } + + #[test] + fn tuple_of_tuple_and_bools_no_arms() { + let content = r" + fn test_fn() { + match (false, ((), false)) { + } + } + "; + + check_diagnostic(content); + } + + #[test] + fn tuple_of_tuple_and_bools_missing_arms() { + let content = r" + fn test_fn() { + match (false, ((), false)) { + (true, ((), true)) => {}, + } + } + "; + + check_diagnostic(content); + } + + #[test] + fn tuple_of_tuple_and_bools_no_diagnostic() { + let content = r" + fn test_fn() { + match (false, ((), false)) { + (true, ((), true)) => {}, + (true, ((), false)) => {}, + (false, ((), true)) => {}, + (false, ((), false)) => {}, + } + } + "; + + check_no_diagnostic(content); + } + + #[test] + fn tuple_of_tuple_and_bools_wildcard_missing_arms() { + let content = r" + fn test_fn() { + match (false, ((), false)) { + (true, _) => {}, + } + } + "; + + check_diagnostic(content); + } + + #[test] + fn tuple_of_tuple_and_bools_wildcard_no_diagnostic() { + let content = r" + fn test_fn() { + match (false, ((), false)) { + (true, ((), true)) => {}, + (true, ((), false)) => {}, + (false, _) => {}, + } + } + "; + + check_no_diagnostic(content); + } + + #[test] + fn enum_no_arms() { + let content = r" + enum Either { + A, + B, + } + fn test_fn() { + match Either::A { + } + } + "; + + check_diagnostic(content); + } + + #[test] + fn enum_missing_arms() { + let content = r" + enum Either { + A, + B, + } + fn test_fn() { + match Either::B { + Either::A => {}, + } + } + "; + + check_diagnostic(content); + } + + #[test] + fn enum_no_diagnostic() { + let content = r" + enum Either { + A, + B, + } + fn test_fn() { + match Either::B { + Either::A => {}, + Either::B => {}, + } + } + "; + + check_no_diagnostic(content); + } + + #[test] + fn enum_ref_missing_arms() { + let content = r" + enum Either { + A, + B, + } + fn test_fn() { + match &Either::B { + Either::A => {}, + } + } + "; + + check_diagnostic(content); + } + + #[test] + fn enum_ref_no_diagnostic() { + let content = r" + enum Either { + A, + B, + } + fn test_fn() { + match &Either::B { + Either::A => {}, + Either::B => {}, + } + } + "; + + check_no_diagnostic(content); + } + + #[test] + fn enum_containing_bool_no_arms() { + let content = r" + enum Either { + A(bool), + B, + } + fn test_fn() { + match Either::B { + } + } + "; + + check_diagnostic(content); + } + + #[test] + fn enum_containing_bool_missing_arms() { + let content = r" + enum Either { + A(bool), + B, + } + fn test_fn() { + match Either::B { + Either::A(true) => (), + Either::B => (), + } + } + "; + + check_diagnostic(content); + } + + #[test] + fn enum_containing_bool_no_diagnostic() { + let content = r" + enum Either { + A(bool), + B, + } + fn test_fn() { + match Either::B { + Either::A(true) => (), + Either::A(false) => (), + Either::B => (), + } + } + "; + + check_no_diagnostic(content); + } + + #[test] + fn enum_containing_bool_with_wild_no_diagnostic() { + let content = r" + enum Either { + A(bool), + B, + } + fn test_fn() { + match Either::B { + Either::B => (), + _ => (), + } + } + "; + + check_no_diagnostic(content); + } + + #[test] + fn enum_containing_bool_with_wild_2_no_diagnostic() { + let content = r" + enum Either { + A(bool), + B, + } + fn test_fn() { + match Either::B { + Either::A(_) => (), + Either::B => (), + } + } + "; + + check_no_diagnostic(content); + } + + #[test] + fn enum_different_sizes_missing_arms() { + let content = r" + enum Either { + A(bool), + B(bool, bool), + } + fn test_fn() { + match Either::A(false) { + Either::A(_) => (), + Either::B(false, _) => (), + } + } + "; + + check_diagnostic(content); + } + + #[test] + fn enum_different_sizes_no_diagnostic() { + let content = r" + enum Either { + A(bool), + B(bool, bool), + } + fn test_fn() { + match Either::A(false) { + Either::A(_) => (), + Either::B(true, _) => (), + Either::B(false, _) => (), + } + } + "; + + check_no_diagnostic(content); + } + + #[test] + fn or_no_diagnostic() { + let content = r" + enum Either { + A(bool), + B(bool, bool), + } + fn test_fn() { + match Either::A(false) { + Either::A(true) | Either::A(false) => (), + Either::B(true, _) => (), + Either::B(false, _) => (), + } + } + "; + + check_no_diagnostic(content); + } + + #[test] + fn tuple_of_enum_no_diagnostic() { + let content = r" + enum Either { + A(bool), + B(bool, bool), + } + enum Either2 { + C, + D, + } + fn test_fn() { + match (Either::A(false), Either2::C) { + (Either::A(true), _) | (Either::A(false), _) => (), + (Either::B(true, _), Either2::C) => (), + (Either::B(false, _), Either2::C) => (), + (Either::B(_, _), Either2::D) => (), + } + } + "; + + check_no_diagnostic(content); + } + + #[test] + fn mismatched_types() { + let content = r" + enum Either { + A, + B, + } + enum Either2 { + C, + D, + } + fn test_fn() { + match Either::A { + Either2::C => (), + Either2::D => (), + } + } + "; + + // Match arms with the incorrect type are filtered out. + check_diagnostic(content); + } + + #[test] + fn mismatched_types_with_different_arity() { + let content = r" + fn test_fn() { + match (true, false) { + (true, false, true) => (), + (true) => (), + } + } + "; + + // Match arms with the incorrect type are filtered out. + check_diagnostic(content); + } + + #[test] + fn enum_not_in_scope() { + let content = r" + fn test_fn() { + match Foo::Bar { + Foo::Baz => (), + } + } + "; + + // The enum is not in scope so we don't perform exhaustiveness + // checking, but we want to be sure we don't panic here (and + // we don't create a diagnostic). + check_no_diagnostic(content); + } +} + +#[cfg(test)] +mod false_negatives { + //! The implementation of match checking here is a work in progress. As we roll this out, we + //! prefer false negatives to false positives (ideally there would be no false positives). This + //! test module should document known false negatives. Eventually we will have a complete + //! implementation of match checking and this module will be empty. + //! + //! The reasons for documenting known false negatives: + //! + //! 1. It acts as a backlog of work that can be done to improve the behavior of the system. + //! 2. It ensures the code doesn't panic when handling these cases. + + use super::tests::*; + + #[test] + fn integers() { + let content = r" + fn test_fn() { + match 5 { + 10 => (), + 11..20 => (), + } + } + "; + + // This is a false negative. + // We don't currently check integer exhaustiveness. + check_no_diagnostic(content); + } + + #[test] + fn enum_record() { + let content = r" + enum Either { + A { foo: u32 }, + B, + } + fn test_fn() { + match Either::B { + Either::A { foo: 5 } => (), + } + } + "; + + // This is a false negative. + // We don't currently handle enum record types. + check_no_diagnostic(content); + } + + #[test] + fn internal_or() { + let content = r" + fn test_fn() { + enum Either { + A(bool), + B, + } + match Either::B { + Either::A(true | false) => (), + } + } + "; + + // This is a false negative. + // We do not currently handle patterns with internal `or`s. + check_no_diagnostic(content); + } +} diff --git a/crates/ra_hir_ty/src/diagnostics.rs b/crates/ra_hir_ty/src/diagnostics.rs index 0f8522021e..8cbce11686 100644 --- a/crates/ra_hir_ty/src/diagnostics.rs +++ b/crates/ra_hir_ty/src/diagnostics.rs @@ -6,7 +6,7 @@ use hir_expand::{db::AstDatabase, name::Name, HirFileId, InFile}; use ra_syntax::{ast, AstNode, AstPtr, SyntaxNodePtr}; use stdx::format_to; -pub use hir_def::diagnostics::UnresolvedModule; +pub use hir_def::{diagnostics::UnresolvedModule, expr::MatchArm}; pub use hir_expand::diagnostics::{AstDiagnostic, Diagnostic, DiagnosticSink}; #[derive(Debug)] @@ -62,6 +62,25 @@ impl AstDiagnostic for MissingFields { } } +#[derive(Debug)] +pub struct MissingMatchArms { + pub file: HirFileId, + pub match_expr: AstPtr, + pub arms: AstPtr, +} + +impl Diagnostic for MissingMatchArms { + fn message(&self) -> String { + String::from("Missing match arm") + } + fn source(&self) -> InFile { + InFile { file_id: self.file, value: self.match_expr.into() } + } + fn as_any(&self) -> &(dyn Any + Send + 'static) { + self + } +} + #[derive(Debug)] pub struct MissingOkInTailExpr { pub file: HirFileId, diff --git a/crates/ra_hir_ty/src/expr.rs b/crates/ra_hir_ty/src/expr.rs index eb1209d08b..6547eedae6 100644 --- a/crates/ra_hir_ty/src/expr.rs +++ b/crates/ra_hir_ty/src/expr.rs @@ -13,9 +13,10 @@ use rustc_hash::FxHashSet; use crate::{ db::HirDatabase, - diagnostics::{MissingFields, MissingOkInTailExpr}, + diagnostics::{MissingFields, MissingMatchArms, MissingOkInTailExpr}, utils::variant_data, ApplicationTy, InferenceResult, Ty, TypeCtor, + _match::{is_useful, MatchCheckCtx, Matrix, PatStack, Usefulness}, }; pub use hir_def::{ @@ -51,15 +52,99 @@ impl<'a, 'b> ExprValidator<'a, 'b> { for e in body.exprs.iter() { if let (id, Expr::RecordLit { path, fields, spread }) = e { self.validate_record_literal(id, path, fields, *spread, db); + } else if let (id, Expr::Match { expr, arms }) = e { + self.validate_match(id, *expr, arms, db, self.infer.clone()); } } let body_expr = &body[body.body_expr]; - if let Expr::Block { statements: _, tail: Some(t) } = body_expr { + if let Expr::Block { tail: Some(t), .. } = body_expr { self.validate_results_in_tail_expr(body.body_expr, *t, db); } } + fn validate_match( + &mut self, + id: ExprId, + match_expr: ExprId, + arms: &[MatchArm], + db: &dyn HirDatabase, + infer: Arc, + ) { + let (body, source_map): (Arc, Arc) = + db.body_with_source_map(self.func.into()); + + let match_expr_ty = match infer.type_of_expr.get(match_expr) { + Some(ty) => ty, + // If we can't resolve the type of the match expression + // we cannot perform exhaustiveness checks. + None => return, + }; + + let cx = MatchCheckCtx { body, infer: infer.clone(), db }; + let pats = arms.iter().map(|arm| arm.pat); + + let mut seen = Matrix::empty(); + for pat in pats { + // We skip any patterns whose type we cannot resolve. + // + // This could lead to false positives in this diagnostic, so + // it might be better to skip the entire diagnostic if we either + // cannot resolve a match arm or determine that the match arm has + // the wrong type. + if let Some(pat_ty) = infer.type_of_pat.get(pat) { + // We only include patterns whose type matches the type + // of the match expression. If we had a InvalidMatchArmPattern + // diagnostic or similar we could raise that in an else + // block here. + // + // When comparing the types, we also have to consider that rustc + // will automatically de-reference the match expression type if + // necessary. + // + // FIXME we should use the type checker for this. + if pat_ty == match_expr_ty + || match_expr_ty + .as_reference() + .map(|(match_expr_ty, _)| match_expr_ty == pat_ty) + .unwrap_or(false) + { + // If we had a NotUsefulMatchArm diagnostic, we could + // check the usefulness of each pattern as we added it + // to the matrix here. + let v = PatStack::from_pattern(pat); + seen.push(&cx, v); + } + } + } + + match is_useful(&cx, &seen, &PatStack::from_wild()) { + Ok(Usefulness::Useful) => (), + // if a wildcard pattern is not useful, then all patterns are covered + Ok(Usefulness::NotUseful) => return, + // this path is for unimplemented checks, so we err on the side of not + // reporting any errors + _ => return, + } + + if let Ok(source_ptr) = source_map.expr_syntax(id) { + if let Some(expr) = source_ptr.value.left() { + let root = source_ptr.file_syntax(db.upcast()); + if let ast::Expr::MatchExpr(match_expr) = expr.to_node(&root) { + if let (Some(match_expr), Some(arms)) = + (match_expr.expr(), match_expr.match_arm_list()) + { + self.sink.push(MissingMatchArms { + file: source_ptr.file_id, + match_expr: AstPtr::new(&match_expr), + arms: AstPtr::new(&arms), + }) + } + } + } + } + } + fn validate_record_literal( &mut self, id: ExprId, diff --git a/crates/ra_hir_ty/src/infer/pat.rs b/crates/ra_hir_ty/src/infer/pat.rs index 86acd27f8d..69bbb4307f 100644 --- a/crates/ra_hir_ty/src/infer/pat.rs +++ b/crates/ra_hir_ty/src/infer/pat.rs @@ -21,9 +21,13 @@ impl<'a> InferenceContext<'a> { subpats: &[PatId], expected: &Ty, default_bm: BindingMode, + id: PatId, ) -> Ty { let (ty, def) = self.resolve_variant(path); let var_data = def.map(|it| variant_data(self.db.upcast(), it)); + if let Some(variant) = def { + self.write_variant_resolution(id.into(), variant); + } self.unify(&ty, expected); let substs = ty.substs().unwrap_or_else(Substs::empty); @@ -152,7 +156,7 @@ impl<'a> InferenceContext<'a> { Ty::apply_one(TypeCtor::Ref(*mutability), subty) } Pat::TupleStruct { path: p, args: subpats } => { - self.infer_tuple_struct_pat(p.as_ref(), subpats, expected, default_bm) + self.infer_tuple_struct_pat(p.as_ref(), subpats, expected, default_bm, pat) } Pat::Record { path: p, args: fields } => { self.infer_record_pat(p.as_ref(), fields, expected, default_bm, pat) diff --git a/crates/ra_hir_ty/src/infer/path.rs b/crates/ra_hir_ty/src/infer/path.rs index 318652c611..2b6bc0f798 100644 --- a/crates/ra_hir_ty/src/infer/path.rs +++ b/crates/ra_hir_ty/src/infer/path.rs @@ -67,8 +67,16 @@ impl<'a> InferenceContext<'a> { ValueNs::FunctionId(it) => it.into(), ValueNs::ConstId(it) => it.into(), ValueNs::StaticId(it) => it.into(), - ValueNs::StructId(it) => it.into(), - ValueNs::EnumVariantId(it) => it.into(), + ValueNs::StructId(it) => { + self.write_variant_resolution(id, it.into()); + + it.into() + } + ValueNs::EnumVariantId(it) => { + self.write_variant_resolution(id, it.into()); + + it.into() + } }; let ty = self.db.value_ty(typable); diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs index a9022dee77..18f74d3b12 100644 --- a/crates/ra_hir_ty/src/lib.rs +++ b/crates/ra_hir_ty/src/lib.rs @@ -1,6 +1,11 @@ //! The type system. We currently use this to infer types for completion, hover //! information and various assists. +#[allow(unused)] +macro_rules! eprintln { + ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; +} + macro_rules! impl_froms { ($e:ident: $($v:ident $(($($sv:ident),*))?),*) => { $( @@ -38,6 +43,7 @@ mod tests; #[cfg(test)] mod test_db; mod marks; +mod _match; use std::ops::Deref; use std::sync::Arc; @@ -855,7 +861,8 @@ pub trait TypeWalk { ); self } - // /// Shifts up debruijn indices of `Ty::Bound` vars by `n`. + + /// Shifts up debruijn indices of `Ty::Bound` vars by `n`. fn shift_bound_vars(self, n: DebruijnIndex) -> Self where Self: Sized, diff --git a/crates/ra_hir_ty/src/test_db.rs b/crates/ra_hir_ty/src/test_db.rs index 208096aab6..3a4d58bf9c 100644 --- a/crates/ra_hir_ty/src/test_db.rs +++ b/crates/ra_hir_ty/src/test_db.rs @@ -105,8 +105,9 @@ impl TestDB { } // FIXME: don't duplicate this - pub fn diagnostics(&self) -> String { + pub fn diagnostics(&self) -> (String, u32) { let mut buf = String::new(); + let mut count = 0; let crate_graph = self.crate_graph(); for krate in crate_graph.iter() { let crate_def_map = self.crate_def_map(krate); @@ -133,13 +134,14 @@ impl TestDB { let infer = self.infer(f.into()); let mut sink = DiagnosticSink::new(|d| { format_to!(buf, "{:?}: {}\n", d.syntax_node(self).text(), d.message()); + count += 1; }); infer.add_diagnostics(self, f, &mut sink); let mut validator = ExprValidator::new(f, infer, &mut sink); validator.validate_body(self); } } - buf + (buf, count) } } diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs index c3d793cc29..e6ac0aec3b 100644 --- a/crates/ra_hir_ty/src/tests.rs +++ b/crates/ra_hir_ty/src/tests.rs @@ -309,7 +309,8 @@ fn no_such_field_diagnostics() { } ", ) - .diagnostics(); + .diagnostics() + .0; assert_snapshot!(diagnostics, @r###" "baz: 62": no such field diff --git a/crates/ra_hir_ty/src/tests/traits.rs b/crates/ra_hir_ty/src/tests/traits.rs index 081aa943a4..22ae6ca909 100644 --- a/crates/ra_hir_ty/src/tests/traits.rs +++ b/crates/ra_hir_ty/src/tests/traits.rs @@ -2021,3 +2021,28 @@ fn main() { "### ); } + +#[test] +fn dyn_trait_through_chalk() { + let t = type_at( + r#" +//- /main.rs +struct Box {} +#[lang = "deref"] +trait Deref { + type Target; +} +impl Deref for Box { + type Target = T; +} +trait Trait { + fn foo(&self); +} + +fn test(x: Box) { + x.foo()<|>; +} +"#, + ); + assert_eq!(t, "()"); +} diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs index 53ce362ea2..1bc0f07135 100644 --- a/crates/ra_hir_ty/src/traits/chalk.rs +++ b/crates/ra_hir_ty/src/traits/chalk.rs @@ -427,7 +427,12 @@ impl ToChalk for GenericPredicate { db: &dyn HirDatabase, where_clause: chalk_ir::QuantifiedWhereClause, ) -> GenericPredicate { - match where_clause.value { + // we don't produce any where clauses with binders and can't currently deal with them + match where_clause + .value + .shifted_out(&Interner) + .expect("unexpected bound vars in where clause") + { chalk_ir::WhereClause::Implemented(tr) => { GenericPredicate::Implemented(from_chalk(db, tr)) } diff --git a/crates/ra_ide/src/call_info.rs b/crates/ra_ide/src/call_info.rs index 39d09a07fe..ca57eceff7 100644 --- a/crates/ra_ide/src/call_info.rs +++ b/crates/ra_ide/src/call_info.rs @@ -109,7 +109,7 @@ impl FnCallNode { syntax.ancestors().find_map(|node| { match_ast! { match node { - ast::CallExpr(it) => { Some(FnCallNode::CallExpr(it)) }, + ast::CallExpr(it) => Some(FnCallNode::CallExpr(it)), ast::MethodCallExpr(it) => { let arg_list = it.arg_list()?; if !syntax.text_range().is_subrange(&arg_list.syntax().text_range()) { @@ -117,8 +117,8 @@ impl FnCallNode { } Some(FnCallNode::MethodCallExpr(it)) }, - ast::MacroCall(it) => { Some(FnCallNode::MacroCallExpr(it)) }, - _ => { None }, + ast::MacroCall(it) => Some(FnCallNode::MacroCallExpr(it)), + _ => None, } } }) @@ -127,10 +127,10 @@ impl FnCallNode { pub(crate) fn with_node_exact(node: &SyntaxNode) -> Option { match_ast! { match node { - ast::CallExpr(it) => { Some(FnCallNode::CallExpr(it)) }, - ast::MethodCallExpr(it) => { Some(FnCallNode::MethodCallExpr(it)) }, - ast::MacroCall(it) => { Some(FnCallNode::MacroCallExpr(it)) }, - _ => { None }, + ast::CallExpr(it) => Some(FnCallNode::CallExpr(it)), + ast::MethodCallExpr(it) => Some(FnCallNode::MethodCallExpr(it)), + ast::MacroCall(it) => Some(FnCallNode::MacroCallExpr(it)), + _ => None, } } } diff --git a/crates/ra_ide/src/completion.rs b/crates/ra_ide/src/completion.rs index 93157bbba6..4a1a2a04a7 100644 --- a/crates/ra_ide/src/completion.rs +++ b/crates/ra_ide/src/completion.rs @@ -10,8 +10,8 @@ mod complete_pattern; mod complete_fn_param; mod complete_keyword; mod complete_snippet; -mod complete_path; -mod complete_scope; +mod complete_qualified_path; +mod complete_unqualified_path; mod complete_postfix; mod complete_macro_in_item_position; mod complete_trait_impl; @@ -85,8 +85,8 @@ pub(crate) fn completions( complete_keyword::complete_use_tree_keyword(&mut acc, &ctx); complete_snippet::complete_expr_snippet(&mut acc, &ctx); complete_snippet::complete_item_snippet(&mut acc, &ctx); - complete_path::complete_path(&mut acc, &ctx); - complete_scope::complete_scope(&mut acc, &ctx); + complete_qualified_path::complete_qualified_path(&mut acc, &ctx); + complete_unqualified_path::complete_unqualified_path(&mut acc, &ctx); complete_dot::complete_dot(&mut acc, &ctx); complete_record::complete_record(&mut acc, &ctx); complete_pattern::complete_pattern(&mut acc, &ctx); diff --git a/crates/ra_ide/src/completion/complete_fn_param.rs b/crates/ra_ide/src/completion/complete_fn_param.rs index 9226ac0551..62ae5ccb46 100644 --- a/crates/ra_ide/src/completion/complete_fn_param.rs +++ b/crates/ra_ide/src/completion/complete_fn_param.rs @@ -18,8 +18,8 @@ pub(super) fn complete_fn_param(acc: &mut Completions, ctx: &CompletionContext) for node in ctx.token.parent().ancestors() { match_ast! { match node { - ast::SourceFile(it) => { process(it, &mut params) }, - ast::ItemList(it) => { process(it, &mut params) }, + ast::SourceFile(it) => process(it, &mut params), + ast::ItemList(it) => process(it, &mut params), _ => (), } } diff --git a/crates/ra_ide/src/completion/complete_keyword.rs b/crates/ra_ide/src/completion/complete_keyword.rs index 1e053ea4a6..38f9c34e72 100644 --- a/crates/ra_ide/src/completion/complete_keyword.rs +++ b/crates/ra_ide/src/completion/complete_keyword.rs @@ -86,9 +86,9 @@ fn is_in_loop_body(leaf: &SyntaxToken) -> bool { } let loop_body = match_ast! { match node { - ast::ForExpr(it) => { it.loop_body() }, - ast::WhileExpr(it) => { it.loop_body() }, - ast::LoopExpr(it) => { it.loop_body() }, + ast::ForExpr(it) => it.loop_body(), + ast::WhileExpr(it) => it.loop_body(), + ast::LoopExpr(it) => it.loop_body(), _ => None, } }; diff --git a/crates/ra_ide/src/completion/complete_path.rs b/crates/ra_ide/src/completion/complete_qualified_path.rs similarity index 99% rename from crates/ra_ide/src/completion/complete_path.rs rename to crates/ra_ide/src/completion/complete_qualified_path.rs index 3ed2ae2b63..d98523406a 100644 --- a/crates/ra_ide/src/completion/complete_path.rs +++ b/crates/ra_ide/src/completion/complete_qualified_path.rs @@ -6,7 +6,7 @@ use test_utils::tested_by; use crate::completion::{CompletionContext, Completions}; -pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { +pub(super) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionContext) { let path = match &ctx.path_prefix { Some(path) => path.clone(), _ => return, diff --git a/crates/ra_ide/src/completion/complete_record.rs b/crates/ra_ide/src/completion/complete_record.rs index 01dd8c6db7..79f5c8c8f9 100644 --- a/crates/ra_ide/src/completion/complete_record.rs +++ b/crates/ra_ide/src/completion/complete_record.rs @@ -1,12 +1,13 @@ //! Complete fields in record literals and patterns. -use crate::completion::{CompletionContext, Completions}; use ra_syntax::{ast, ast::NameOwner, SmolStr}; +use crate::completion::{CompletionContext, Completions}; + pub(super) fn complete_record(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> { let (ty, variant, already_present_fields) = match (ctx.record_lit_pat.as_ref(), ctx.record_lit_syntax.as_ref()) { (None, None) => return None, - (Some(_), Some(_)) => panic!("A record cannot be both a literal and a pattern"), + (Some(_), Some(_)) => unreachable!("A record cannot be both a literal and a pattern"), (Some(record_pat), _) => ( ctx.sema.type_of_pat(&record_pat.clone().into())?, ctx.sema.resolve_record_pattern(record_pat)?, @@ -59,9 +60,10 @@ fn pattern_ascribed_fields(record_pat: &ast::RecordPat) -> Vec { #[cfg(test)] mod tests { mod record_lit_tests { - use crate::completion::{test_utils::do_completion, CompletionItem, CompletionKind}; use insta::assert_debug_snapshot; + use crate::completion::{test_utils::do_completion, CompletionItem, CompletionKind}; + fn complete(code: &str) -> Vec { do_completion(code, CompletionKind::Reference) } @@ -204,9 +206,10 @@ mod tests { } mod record_pat_tests { - use crate::completion::{test_utils::do_completion, CompletionItem, CompletionKind}; use insta::assert_debug_snapshot; + use crate::completion::{test_utils::do_completion, CompletionItem, CompletionKind}; + fn complete(code: &str) -> Vec { do_completion(code, CompletionKind::Reference) } diff --git a/crates/ra_ide/src/completion/complete_scope.rs b/crates/ra_ide/src/completion/complete_unqualified_path.rs similarity index 99% rename from crates/ra_ide/src/completion/complete_scope.rs rename to crates/ra_ide/src/completion/complete_unqualified_path.rs index 665597e4cb..efde9bf731 100644 --- a/crates/ra_ide/src/completion/complete_scope.rs +++ b/crates/ra_ide/src/completion/complete_unqualified_path.rs @@ -2,7 +2,7 @@ use crate::completion::{CompletionContext, Completions}; -pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) { +pub(super) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionContext) { if !(ctx.is_trivial_path && !ctx.is_pat_binding_or_const) { return; } diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs index b8213d62f5..f833d2a9ad 100644 --- a/crates/ra_ide/src/completion/completion_context.rs +++ b/crates/ra_ide/src/completion/completion_context.rs @@ -50,6 +50,8 @@ pub(crate) struct CompletionContext<'a> { pub(super) dot_receiver_is_ambiguous_float_literal: bool, /// If this is a call (method or function) in particular, i.e. the () are already there. pub(super) is_call: bool, + /// If this is a macro call, i.e. the () are already there. + pub(super) is_macro_call: bool, pub(super) is_path_type: bool, pub(super) has_type_args: bool, } @@ -102,6 +104,7 @@ impl<'a> CompletionContext<'a> { is_new_item: false, dot_receiver: None, is_call: false, + is_macro_call: false, is_path_type: false, has_type_args: false, dot_receiver_is_ambiguous_float_literal: false, @@ -269,6 +272,7 @@ impl<'a> CompletionContext<'a> { .and_then(ast::PathExpr::cast) .and_then(|it| it.syntax().parent().and_then(ast::CallExpr::cast)) .is_some(); + self.is_macro_call = path.syntax().parent().and_then(ast::MacroCall::cast).is_some(); self.is_path_type = path.syntax().parent().and_then(ast::PathType::cast).is_some(); self.has_type_args = segment.type_arg_list().is_some(); diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs index cdfd7bc324..55f75b15aa 100644 --- a/crates/ra_ide/src/completion/presentation.rs +++ b/crates/ra_ide/src/completion/presentation.rs @@ -174,7 +174,8 @@ impl Completions { .set_deprecated(is_deprecated(macro_, ctx.db)) .detail(detail); - builder = if ctx.use_item_syntax.is_some() { + builder = if ctx.use_item_syntax.is_some() || ctx.is_macro_call { + tested_by!(dont_insert_macro_call_parens_unncessary); builder.insert_text(name) } else { let macro_braces_to_insert = @@ -960,7 +961,8 @@ mod tests { } #[test] - fn dont_insert_macro_call_braces_in_use() { + fn dont_insert_macro_call_parens_unncessary() { + covers!(dont_insert_macro_call_parens_unncessary); assert_debug_snapshot!( do_reference_completion( r" @@ -986,6 +988,41 @@ mod tests { }, ] "### - ) + ); + + assert_debug_snapshot!( + do_reference_completion( + r" + //- /main.rs + macro_rules frobnicate { + () => () + } + fn main() { + frob<|>!(); + } + " + ), + @r###" + [ + CompletionItem { + label: "frobnicate!", + source_range: [56; 60), + delete: [56; 60), + insert: "frobnicate", + kind: Macro, + detail: "macro_rules! frobnicate", + }, + CompletionItem { + label: "main()", + source_range: [56; 60), + delete: [56; 60), + insert: "main()$0", + kind: Function, + lookup: "main", + detail: "fn main()", + }, + ] + "### + ); } } diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs index c1d7ddaf23..901ad104c1 100644 --- a/crates/ra_ide/src/diagnostics.rs +++ b/crates/ra_ide/src/diagnostics.rs @@ -101,6 +101,14 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec fix, }) }) + .on::(|d| { + res.borrow_mut().push(Diagnostic { + range: d.highlight_range(), + message: d.message(), + severity: Severity::Error, + fix: None, + }) + }) .on::(|d| { let node = d.ast(db); let replacement = format!("Ok({})", node.syntax()); @@ -291,7 +299,7 @@ mod tests { fn check_no_diagnostic(content: &str) { let (analysis, file_id) = single_file(content); let diagnostics = analysis.diagnostics(file_id).unwrap(); - assert_eq!(diagnostics.len(), 0); + assert_eq!(diagnostics.len(), 0, "expected no diagnostic, found one"); } #[test] diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs index d57451cc8c..e61846995a 100644 --- a/crates/ra_ide/src/display/navigation_target.rs +++ b/crates/ra_ide/src/display/navigation_target.rs @@ -399,17 +399,17 @@ pub(crate) fn docs_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> Option match_ast! { match node { - ast::FnDef(it) => { it.doc_comment_text() }, - ast::StructDef(it) => { it.doc_comment_text() }, - ast::EnumDef(it) => { it.doc_comment_text() }, - ast::TraitDef(it) => { it.doc_comment_text() }, - ast::Module(it) => { it.doc_comment_text() }, - ast::TypeAliasDef(it) => { it.doc_comment_text() }, - ast::ConstDef(it) => { it.doc_comment_text() }, - ast::StaticDef(it) => { it.doc_comment_text() }, - ast::RecordFieldDef(it) => { it.doc_comment_text() }, - ast::EnumVariant(it) => { it.doc_comment_text() }, - ast::MacroCall(it) => { it.doc_comment_text() }, + ast::FnDef(it) => it.doc_comment_text(), + ast::StructDef(it) => it.doc_comment_text(), + ast::EnumDef(it) => it.doc_comment_text(), + ast::TraitDef(it) => it.doc_comment_text(), + ast::Module(it) => it.doc_comment_text(), + ast::TypeAliasDef(it) => it.doc_comment_text(), + ast::ConstDef(it) => it.doc_comment_text(), + ast::StaticDef(it) => it.doc_comment_text(), + ast::RecordFieldDef(it) => it.doc_comment_text(), + ast::EnumVariant(it) => it.doc_comment_text(), + ast::MacroCall(it) => it.doc_comment_text(), _ => None, } } @@ -424,16 +424,16 @@ pub(crate) fn description_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> match_ast! { match node { - ast::FnDef(it) => { it.short_label() }, - ast::StructDef(it) => { it.short_label() }, - ast::EnumDef(it) => { it.short_label() }, - ast::TraitDef(it) => { it.short_label() }, - ast::Module(it) => { it.short_label() }, - ast::TypeAliasDef(it) => { it.short_label() }, - ast::ConstDef(it) => { it.short_label() }, - ast::StaticDef(it) => { it.short_label() }, - ast::RecordFieldDef(it) => { it.short_label() }, - ast::EnumVariant(it) => { it.short_label() }, + ast::FnDef(it) => it.short_label(), + ast::StructDef(it) => it.short_label(), + ast::EnumDef(it) => it.short_label(), + ast::TraitDef(it) => it.short_label(), + ast::Module(it) => it.short_label(), + ast::TypeAliasDef(it) => it.short_label(), + ast::ConstDef(it) => it.short_label(), + ast::StaticDef(it) => it.short_label(), + ast::RecordFieldDef(it) => it.short_label(), + ast::EnumVariant(it) => it.short_label(), _ => None, } } diff --git a/crates/ra_ide/src/display/structure.rs b/crates/ra_ide/src/display/structure.rs index 5774e9a8b4..7a774785c0 100644 --- a/crates/ra_ide/src/display/structure.rs +++ b/crates/ra_ide/src/display/structure.rs @@ -117,18 +117,18 @@ fn structure_node(node: &SyntaxNode) -> Option { decl_with_detail(it, Some(detail)) }, - ast::StructDef(it) => { decl(it) }, - ast::EnumDef(it) => { decl(it) }, - ast::EnumVariant(it) => { decl(it) }, - ast::TraitDef(it) => { decl(it) }, - ast::Module(it) => { decl(it) }, + ast::StructDef(it) => decl(it), + ast::EnumDef(it) => decl(it), + ast::EnumVariant(it) => decl(it), + ast::TraitDef(it) => decl(it), + ast::Module(it) => decl(it), ast::TypeAliasDef(it) => { let ty = it.type_ref(); decl_with_type_ref(it, ty) }, - ast::RecordFieldDef(it) => { decl_with_ascription(it) }, - ast::ConstDef(it) => { decl_with_ascription(it) }, - ast::StaticDef(it) => { decl_with_ascription(it) }, + ast::RecordFieldDef(it) => decl_with_ascription(it), + ast::ConstDef(it) => decl_with_ascription(it), + ast::StaticDef(it) => decl_with_ascription(it), ast::ImplDef(it) => { let target_type = it.target_type()?; let target_trait = it.target_trait(); diff --git a/crates/ra_ide/src/goto_type_definition.rs b/crates/ra_ide/src/goto_type_definition.rs index 869a4708b7..bd2688df1b 100644 --- a/crates/ra_ide/src/goto_type_definition.rs +++ b/crates/ra_ide/src/goto_type_definition.rs @@ -18,9 +18,9 @@ pub(crate) fn goto_type_definition( let (ty, node) = sema.ancestors_with_macros(token.parent()).find_map(|node| { let ty = match_ast! { match node { - ast::Expr(expr) => { sema.type_of_expr(&expr)? }, - ast::Pat(pat) => { sema.type_of_pat(&pat)? }, - _ => { return None }, + ast::Expr(expr) => sema.type_of_expr(&expr)?, + ast::Pat(pat) => sema.type_of_pat(&pat)?, + _ => return None, } }; diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index 2853810865..5599f143f2 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs @@ -10,6 +10,11 @@ // For proving that RootDatabase is RefUnwindSafe. #![recursion_limit = "128"] +#[allow(unused)] +macro_rules! eprintln { + ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; +} + pub mod mock_analysis; mod source_change; diff --git a/crates/ra_ide/src/marks.rs b/crates/ra_ide/src/marks.rs index 1236cb773c..5e1f135c56 100644 --- a/crates/ra_ide/src/marks.rs +++ b/crates/ra_ide/src/marks.rs @@ -7,4 +7,5 @@ test_utils::marks!( dont_complete_current_use test_resolve_parent_module_on_module_decl search_filters_by_range + dont_insert_macro_call_parens_unncessary ); diff --git a/crates/ra_ide/src/runnables.rs b/crates/ra_ide/src/runnables.rs index 74877e90fe..9433f3a247 100644 --- a/crates/ra_ide/src/runnables.rs +++ b/crates/ra_ide/src/runnables.rs @@ -49,8 +49,8 @@ pub(crate) fn runnables(db: &RootDatabase, file_id: FileId) -> Vec { fn runnable(sema: &Semantics, item: SyntaxNode) -> Option { match_ast! { match item { - ast::FnDef(it) => { runnable_fn(sema, it) }, - ast::Module(it) => { runnable_mod(sema, it) }, + ast::FnDef(it) => runnable_fn(sema, it), + ast::Module(it) => runnable_mod(sema, it), _ => None, } } diff --git a/crates/ra_ide_db/src/search.rs b/crates/ra_ide_db/src/search.rs index 05a0eed30a..1bf014149a 100644 --- a/crates/ra_ide_db/src/search.rs +++ b/crates/ra_ide_db/src/search.rs @@ -286,7 +286,7 @@ fn reference_access(def: &Definition, name_ref: &ast::NameRef) -> Option {None} + _ => None } } }); diff --git a/crates/ra_ide_db/src/symbol_index.rs b/crates/ra_ide_db/src/symbol_index.rs index 0f46f93c17..d30458d865 100644 --- a/crates/ra_ide_db/src/symbol_index.rs +++ b/crates/ra_ide_db/src/symbol_index.rs @@ -354,14 +354,14 @@ fn to_symbol(node: &SyntaxNode) -> Option<(SmolStr, SyntaxNodePtr, TextRange)> { } match_ast! { match node { - ast::FnDef(it) => { decl(it) }, - ast::StructDef(it) => { decl(it) }, - ast::EnumDef(it) => { decl(it) }, - ast::TraitDef(it) => { decl(it) }, - ast::Module(it) => { decl(it) }, - ast::TypeAliasDef(it) => { decl(it) }, - ast::ConstDef(it) => { decl(it) }, - ast::StaticDef(it) => { decl(it) }, + ast::FnDef(it) => decl(it), + ast::StructDef(it) => decl(it), + ast::EnumDef(it) => decl(it), + ast::TraitDef(it) => decl(it), + ast::Module(it) => decl(it), + ast::TypeAliasDef(it) => decl(it), + ast::ConstDef(it) => decl(it), + ast::StaticDef(it) => decl(it), ast::MacroCall(it) => { if it.is_macro_rules().is_some() { decl(it) diff --git a/crates/ra_syntax/src/tests.rs b/crates/ra_syntax/src/tests.rs index 6a8cb6bb57..355843b946 100644 --- a/crates/ra_syntax/src/tests.rs +++ b/crates/ra_syntax/src/tests.rs @@ -3,7 +3,7 @@ use std::{ path::{Component, Path, PathBuf}, }; -use test_utils::{collect_tests, dir_tests, project_dir, read_text}; +use test_utils::{collect_rust_files, dir_tests, project_dir, read_text}; use crate::{fuzz, tokenize, SourceFile, SyntaxError, TextRange, TextUnit, Token}; @@ -13,12 +13,12 @@ fn lexer_tests() { // * Add tests for unicode escapes in byte-character and [raw]-byte-string literals // * Add tests for unescape errors - dir_tests(&test_data_dir(), &["lexer/ok"], |text, path| { + dir_tests(&test_data_dir(), &["lexer/ok"], "txt", |text, path| { let (tokens, errors) = tokenize(text); assert_errors_are_absent(&errors, path); dump_tokens_and_errors(&tokens, &errors, text) }); - dir_tests(&test_data_dir(), &["lexer/err"], |text, path| { + dir_tests(&test_data_dir(), &["lexer/err"], "txt", |text, path| { let (tokens, errors) = tokenize(text); assert_errors_are_present(&errors, path); dump_tokens_and_errors(&tokens, &errors, text) @@ -40,13 +40,13 @@ fn main() { #[test] fn parser_tests() { - dir_tests(&test_data_dir(), &["parser/inline/ok", "parser/ok"], |text, path| { + dir_tests(&test_data_dir(), &["parser/inline/ok", "parser/ok"], "rast", |text, path| { let parse = SourceFile::parse(text); let errors = parse.errors(); assert_errors_are_absent(&errors, path); parse.debug_dump() }); - dir_tests(&test_data_dir(), &["parser/err", "parser/inline/err"], |text, path| { + dir_tests(&test_data_dir(), &["parser/err", "parser/inline/err"], "rast", |text, path| { let parse = SourceFile::parse(text); let errors = parse.errors(); assert_errors_are_present(&errors, path); @@ -56,14 +56,14 @@ fn parser_tests() { #[test] fn parser_fuzz_tests() { - for (_, text) in collect_tests(&test_data_dir(), &["parser/fuzz-failures"]) { + for (_, text) in collect_rust_files(&test_data_dir(), &["parser/fuzz-failures"]) { fuzz::check_parser(&text) } } #[test] fn reparse_fuzz_tests() { - for (_, text) in collect_tests(&test_data_dir(), &["reparse/fuzz-failures"]) { + for (_, text) in collect_rust_files(&test_data_dir(), &["reparse/fuzz-failures"]) { let check = fuzz::CheckReparse::from_data(text.as_bytes()).unwrap(); println!("{:?}", check); check.run(); diff --git a/crates/ra_syntax/src/validation.rs b/crates/ra_syntax/src/validation.rs index 7915cf8cb2..f85b3e61b4 100644 --- a/crates/ra_syntax/src/validation.rs +++ b/crates/ra_syntax/src/validation.rs @@ -88,12 +88,12 @@ pub(crate) fn validate(root: &SyntaxNode) -> Vec { for node in root.descendants() { match_ast! { match node { - ast::Literal(it) => { validate_literal(it, &mut errors) }, - ast::BlockExpr(it) => { block::validate_block_expr(it, &mut errors) }, - ast::FieldExpr(it) => { validate_numeric_name(it.name_ref(), &mut errors) }, - ast::RecordField(it) => { validate_numeric_name(it.name_ref(), &mut errors) }, - ast::Visibility(it) => { validate_visibility(it, &mut errors) }, - ast::RangeExpr(it) => { validate_range_expr(it, &mut errors) }, + ast::Literal(it) => validate_literal(it, &mut errors), + ast::BlockExpr(it) => block::validate_block_expr(it, &mut errors), + ast::FieldExpr(it) => validate_numeric_name(it.name_ref(), &mut errors), + ast::RecordField(it) => validate_numeric_name(it.name_ref(), &mut errors), + ast::Visibility(it) => validate_visibility(it, &mut errors), + ast::RangeExpr(it) => validate_range_expr(it, &mut errors), _ => (), } } diff --git a/crates/ra_syntax/test_data/parser/err/0000_struct_field_missing_comma.txt b/crates/ra_syntax/test_data/parser/err/0000_struct_field_missing_comma.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0000_struct_field_missing_comma.txt rename to crates/ra_syntax/test_data/parser/err/0000_struct_field_missing_comma.rast diff --git a/crates/ra_syntax/test_data/parser/err/0001_item_recovery_in_file.txt b/crates/ra_syntax/test_data/parser/err/0001_item_recovery_in_file.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0001_item_recovery_in_file.txt rename to crates/ra_syntax/test_data/parser/err/0001_item_recovery_in_file.rast diff --git a/crates/ra_syntax/test_data/parser/err/0002_duplicate_shebang.txt b/crates/ra_syntax/test_data/parser/err/0002_duplicate_shebang.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0002_duplicate_shebang.txt rename to crates/ra_syntax/test_data/parser/err/0002_duplicate_shebang.rast diff --git a/crates/ra_syntax/test_data/parser/err/0003_C++_semicolon.txt b/crates/ra_syntax/test_data/parser/err/0003_C++_semicolon.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0003_C++_semicolon.txt rename to crates/ra_syntax/test_data/parser/err/0003_C++_semicolon.rast diff --git a/crates/ra_syntax/test_data/parser/err/0004_use_path_bad_segment.txt b/crates/ra_syntax/test_data/parser/err/0004_use_path_bad_segment.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0004_use_path_bad_segment.txt rename to crates/ra_syntax/test_data/parser/err/0004_use_path_bad_segment.rast diff --git a/crates/ra_syntax/test_data/parser/err/0005_attribute_recover.txt b/crates/ra_syntax/test_data/parser/err/0005_attribute_recover.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0005_attribute_recover.txt rename to crates/ra_syntax/test_data/parser/err/0005_attribute_recover.rast diff --git a/crates/ra_syntax/test_data/parser/err/0006_named_field_recovery.txt b/crates/ra_syntax/test_data/parser/err/0006_named_field_recovery.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0006_named_field_recovery.txt rename to crates/ra_syntax/test_data/parser/err/0006_named_field_recovery.rast diff --git a/crates/ra_syntax/test_data/parser/err/0007_stray_curly_in_file.txt b/crates/ra_syntax/test_data/parser/err/0007_stray_curly_in_file.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0007_stray_curly_in_file.txt rename to crates/ra_syntax/test_data/parser/err/0007_stray_curly_in_file.rast diff --git a/crates/ra_syntax/test_data/parser/err/0008_item_block_recovery.txt b/crates/ra_syntax/test_data/parser/err/0008_item_block_recovery.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0008_item_block_recovery.txt rename to crates/ra_syntax/test_data/parser/err/0008_item_block_recovery.rast diff --git a/crates/ra_syntax/test_data/parser/err/0009_broken_struct_type_parameter.txt b/crates/ra_syntax/test_data/parser/err/0009_broken_struct_type_parameter.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0009_broken_struct_type_parameter.txt rename to crates/ra_syntax/test_data/parser/err/0009_broken_struct_type_parameter.rast diff --git a/crates/ra_syntax/test_data/parser/err/0010_unsafe_lambda_block.txt b/crates/ra_syntax/test_data/parser/err/0010_unsafe_lambda_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0010_unsafe_lambda_block.txt rename to crates/ra_syntax/test_data/parser/err/0010_unsafe_lambda_block.rast diff --git a/crates/ra_syntax/test_data/parser/err/0011_extern_struct.txt b/crates/ra_syntax/test_data/parser/err/0011_extern_struct.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0011_extern_struct.txt rename to crates/ra_syntax/test_data/parser/err/0011_extern_struct.rast diff --git a/crates/ra_syntax/test_data/parser/err/0012_broken_lambda.txt b/crates/ra_syntax/test_data/parser/err/0012_broken_lambda.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0012_broken_lambda.txt rename to crates/ra_syntax/test_data/parser/err/0012_broken_lambda.rast diff --git a/crates/ra_syntax/test_data/parser/err/0013_invalid_type.txt b/crates/ra_syntax/test_data/parser/err/0013_invalid_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0013_invalid_type.txt rename to crates/ra_syntax/test_data/parser/err/0013_invalid_type.rast diff --git a/crates/ra_syntax/test_data/parser/err/0014_where_no_bounds.txt b/crates/ra_syntax/test_data/parser/err/0014_where_no_bounds.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0014_where_no_bounds.txt rename to crates/ra_syntax/test_data/parser/err/0014_where_no_bounds.rast diff --git a/crates/ra_syntax/test_data/parser/err/0015_curly_in_params.txt b/crates/ra_syntax/test_data/parser/err/0015_curly_in_params.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0015_curly_in_params.txt rename to crates/ra_syntax/test_data/parser/err/0015_curly_in_params.rast diff --git a/crates/ra_syntax/test_data/parser/err/0016_missing_semi.txt b/crates/ra_syntax/test_data/parser/err/0016_missing_semi.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0016_missing_semi.txt rename to crates/ra_syntax/test_data/parser/err/0016_missing_semi.rast diff --git a/crates/ra_syntax/test_data/parser/err/0017_incomplete_binexpr.txt b/crates/ra_syntax/test_data/parser/err/0017_incomplete_binexpr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0017_incomplete_binexpr.txt rename to crates/ra_syntax/test_data/parser/err/0017_incomplete_binexpr.rast diff --git a/crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.txt b/crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.txt rename to crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.rast diff --git a/crates/ra_syntax/test_data/parser/err/0019_let_recover.txt b/crates/ra_syntax/test_data/parser/err/0019_let_recover.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0019_let_recover.txt rename to crates/ra_syntax/test_data/parser/err/0019_let_recover.rast diff --git a/crates/ra_syntax/test_data/parser/err/0020_fn_recover.txt b/crates/ra_syntax/test_data/parser/err/0020_fn_recover.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0020_fn_recover.txt rename to crates/ra_syntax/test_data/parser/err/0020_fn_recover.rast diff --git a/crates/ra_syntax/test_data/parser/err/0021_incomplete_param.txt b/crates/ra_syntax/test_data/parser/err/0021_incomplete_param.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0021_incomplete_param.txt rename to crates/ra_syntax/test_data/parser/err/0021_incomplete_param.rast diff --git a/crates/ra_syntax/test_data/parser/err/0022_bad_exprs.txt b/crates/ra_syntax/test_data/parser/err/0022_bad_exprs.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0022_bad_exprs.txt rename to crates/ra_syntax/test_data/parser/err/0022_bad_exprs.rast diff --git a/crates/ra_syntax/test_data/parser/err/0023_mismatched_paren.txt b/crates/ra_syntax/test_data/parser/err/0023_mismatched_paren.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0023_mismatched_paren.txt rename to crates/ra_syntax/test_data/parser/err/0023_mismatched_paren.rast diff --git a/crates/ra_syntax/test_data/parser/err/0024_many_type_parens.txt b/crates/ra_syntax/test_data/parser/err/0024_many_type_parens.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0024_many_type_parens.txt rename to crates/ra_syntax/test_data/parser/err/0024_many_type_parens.rast diff --git a/crates/ra_syntax/test_data/parser/err/0025_nope.txt b/crates/ra_syntax/test_data/parser/err/0025_nope.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0025_nope.txt rename to crates/ra_syntax/test_data/parser/err/0025_nope.rast diff --git a/crates/ra_syntax/test_data/parser/err/0026_imp_recovery.txt b/crates/ra_syntax/test_data/parser/err/0026_imp_recovery.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0026_imp_recovery.txt rename to crates/ra_syntax/test_data/parser/err/0026_imp_recovery.rast diff --git a/crates/ra_syntax/test_data/parser/err/0027_incomplere_where_for.txt b/crates/ra_syntax/test_data/parser/err/0027_incomplere_where_for.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0027_incomplere_where_for.txt rename to crates/ra_syntax/test_data/parser/err/0027_incomplere_where_for.rast diff --git a/crates/ra_syntax/test_data/parser/err/0029_field_completion.txt b/crates/ra_syntax/test_data/parser/err/0029_field_completion.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0029_field_completion.txt rename to crates/ra_syntax/test_data/parser/err/0029_field_completion.rast diff --git a/crates/ra_syntax/test_data/parser/err/0031_block_inner_attrs.txt b/crates/ra_syntax/test_data/parser/err/0031_block_inner_attrs.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0031_block_inner_attrs.txt rename to crates/ra_syntax/test_data/parser/err/0031_block_inner_attrs.rast diff --git a/crates/ra_syntax/test_data/parser/err/0032_match_arms_inner_attrs.txt b/crates/ra_syntax/test_data/parser/err/0032_match_arms_inner_attrs.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0032_match_arms_inner_attrs.txt rename to crates/ra_syntax/test_data/parser/err/0032_match_arms_inner_attrs.rast diff --git a/crates/ra_syntax/test_data/parser/err/0033_match_arms_outer_attrs.txt b/crates/ra_syntax/test_data/parser/err/0033_match_arms_outer_attrs.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0033_match_arms_outer_attrs.txt rename to crates/ra_syntax/test_data/parser/err/0033_match_arms_outer_attrs.rast diff --git a/crates/ra_syntax/test_data/parser/err/0034_bad_box_pattern.txt b/crates/ra_syntax/test_data/parser/err/0034_bad_box_pattern.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0034_bad_box_pattern.txt rename to crates/ra_syntax/test_data/parser/err/0034_bad_box_pattern.rast diff --git a/crates/ra_syntax/test_data/parser/err/0035_use_recover.txt b/crates/ra_syntax/test_data/parser/err/0035_use_recover.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0035_use_recover.txt rename to crates/ra_syntax/test_data/parser/err/0035_use_recover.rast diff --git a/crates/ra_syntax/test_data/parser/err/0036_partial_use.txt b/crates/ra_syntax/test_data/parser/err/0036_partial_use.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0036_partial_use.txt rename to crates/ra_syntax/test_data/parser/err/0036_partial_use.rast diff --git a/crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.txt b/crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.txt rename to crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.rast diff --git a/crates/ra_syntax/test_data/parser/err/0038_endless_inclusive_range.txt b/crates/ra_syntax/test_data/parser/err/0038_endless_inclusive_range.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0038_endless_inclusive_range.txt rename to crates/ra_syntax/test_data/parser/err/0038_endless_inclusive_range.rast diff --git a/crates/ra_syntax/test_data/parser/err/0039_lambda_recovery.txt b/crates/ra_syntax/test_data/parser/err/0039_lambda_recovery.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0039_lambda_recovery.txt rename to crates/ra_syntax/test_data/parser/err/0039_lambda_recovery.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0001_array_type_missing_semi.txt b/crates/ra_syntax/test_data/parser/inline/err/0001_array_type_missing_semi.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0001_array_type_missing_semi.txt rename to crates/ra_syntax/test_data/parser/inline/err/0001_array_type_missing_semi.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0002_misplaced_label_err.txt b/crates/ra_syntax/test_data/parser/inline/err/0002_misplaced_label_err.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0002_misplaced_label_err.txt rename to crates/ra_syntax/test_data/parser/inline/err/0002_misplaced_label_err.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0003_pointer_type_no_mutability.txt b/crates/ra_syntax/test_data/parser/inline/err/0003_pointer_type_no_mutability.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0003_pointer_type_no_mutability.txt rename to crates/ra_syntax/test_data/parser/inline/err/0003_pointer_type_no_mutability.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0004_impl_type.txt b/crates/ra_syntax/test_data/parser/inline/err/0004_impl_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0004_impl_type.txt rename to crates/ra_syntax/test_data/parser/inline/err/0004_impl_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0005_fn_pointer_type_missing_fn.txt b/crates/ra_syntax/test_data/parser/inline/err/0005_fn_pointer_type_missing_fn.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0005_fn_pointer_type_missing_fn.txt rename to crates/ra_syntax/test_data/parser/inline/err/0005_fn_pointer_type_missing_fn.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0006_unsafe_block_in_mod.txt b/crates/ra_syntax/test_data/parser/inline/err/0006_unsafe_block_in_mod.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0006_unsafe_block_in_mod.txt rename to crates/ra_syntax/test_data/parser/inline/err/0006_unsafe_block_in_mod.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0007_async_without_semicolon.txt b/crates/ra_syntax/test_data/parser/inline/err/0007_async_without_semicolon.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0007_async_without_semicolon.txt rename to crates/ra_syntax/test_data/parser/inline/err/0007_async_without_semicolon.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0008_pub_expr.txt b/crates/ra_syntax/test_data/parser/inline/err/0008_pub_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0008_pub_expr.txt rename to crates/ra_syntax/test_data/parser/inline/err/0008_pub_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0009_attr_on_expr_not_allowed.txt b/crates/ra_syntax/test_data/parser/inline/err/0009_attr_on_expr_not_allowed.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0009_attr_on_expr_not_allowed.txt rename to crates/ra_syntax/test_data/parser/inline/err/0009_attr_on_expr_not_allowed.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0010_bad_tuple_index_expr.txt b/crates/ra_syntax/test_data/parser/inline/err/0010_bad_tuple_index_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0010_bad_tuple_index_expr.txt rename to crates/ra_syntax/test_data/parser/inline/err/0010_bad_tuple_index_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.txt b/crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.txt rename to crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0013_static_underscore.txt b/crates/ra_syntax/test_data/parser/inline/err/0013_static_underscore.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0013_static_underscore.txt rename to crates/ra_syntax/test_data/parser/inline/err/0013_static_underscore.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.txt b/crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.txt rename to crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.txt b/crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0002_use_tree_list.txt b/crates/ra_syntax/test_data/parser/inline/ok/0002_use_tree_list.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0002_use_tree_list.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0002_use_tree_list.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0003_where_pred_for.txt b/crates/ra_syntax/test_data/parser/inline/ok/0003_where_pred_for.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0003_where_pred_for.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0003_where_pred_for.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0004_value_parameters_no_patterns.txt b/crates/ra_syntax/test_data/parser/inline/ok/0004_value_parameters_no_patterns.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0004_value_parameters_no_patterns.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0004_value_parameters_no_patterns.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0005_function_type_params.txt b/crates/ra_syntax/test_data/parser/inline/ok/0005_function_type_params.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0005_function_type_params.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0005_function_type_params.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0006_self_param.txt b/crates/ra_syntax/test_data/parser/inline/ok/0006_self_param.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0006_self_param.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0006_self_param.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0007_type_param_bounds.txt b/crates/ra_syntax/test_data/parser/inline/ok/0007_type_param_bounds.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0007_type_param_bounds.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0007_type_param_bounds.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0008_path_part.txt b/crates/ra_syntax/test_data/parser/inline/ok/0008_path_part.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0008_path_part.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0008_path_part.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0009_loop_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0009_loop_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0009_loop_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0009_loop_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0010_extern_block.txt b/crates/ra_syntax/test_data/parser/inline/ok/0010_extern_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0010_extern_block.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0010_extern_block.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0011_field_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0011_field_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0011_field_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0011_field_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0012_type_item_where_clause.txt b/crates/ra_syntax/test_data/parser/inline/ok/0012_type_item_where_clause.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0012_type_item_where_clause.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0012_type_item_where_clause.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0013_pointer_type_mut.txt b/crates/ra_syntax/test_data/parser/inline/ok/0013_pointer_type_mut.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0013_pointer_type_mut.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0013_pointer_type_mut.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0014_never_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0014_never_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0014_never_type.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0014_never_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0015_continue_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0015_continue_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0015_continue_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0015_continue_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.txt b/crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0017_array_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0017_array_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0017_array_type.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0017_array_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0018_arb_self_types.txt b/crates/ra_syntax/test_data/parser/inline/ok/0018_arb_self_types.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0018_arb_self_types.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0018_arb_self_types.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0019_unary_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0019_unary_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0019_unary_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0019_unary_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0020_use_star.txt b/crates/ra_syntax/test_data/parser/inline/ok/0020_use_star.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0020_use_star.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0020_use_star.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.txt b/crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0022_crate_visibility.txt b/crates/ra_syntax/test_data/parser/inline/ok/0022_crate_visibility.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0022_crate_visibility.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0022_crate_visibility.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0023_placeholder_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0023_placeholder_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0023_placeholder_type.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0023_placeholder_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0024_slice_pat.txt b/crates/ra_syntax/test_data/parser/inline/ok/0024_slice_pat.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0024_slice_pat.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0024_slice_pat.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0025_slice_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0025_slice_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0025_slice_type.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0025_slice_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0026_tuple_pat_fields.txt b/crates/ra_syntax/test_data/parser/inline/ok/0026_tuple_pat_fields.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0026_tuple_pat_fields.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0026_tuple_pat_fields.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0027_ref_pat.txt b/crates/ra_syntax/test_data/parser/inline/ok/0027_ref_pat.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0027_ref_pat.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0027_ref_pat.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0028_impl_trait_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0028_impl_trait_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0028_impl_trait_type.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0028_impl_trait_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0029_cast_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0029_cast_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0029_cast_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0029_cast_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0030_cond.txt b/crates/ra_syntax/test_data/parser/inline/ok/0030_cond.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0030_cond.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0030_cond.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0031_while_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0031_while_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0031_while_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0031_while_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0032_fn_pointer_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0032_fn_pointer_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0032_fn_pointer_type.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0032_fn_pointer_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0033_reference_type;.txt b/crates/ra_syntax/test_data/parser/inline/ok/0033_reference_type;.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0033_reference_type;.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0033_reference_type;.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0034_break_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0034_break_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0034_break_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0034_break_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0036_unsafe_extern_fn.txt b/crates/ra_syntax/test_data/parser/inline/ok/0036_unsafe_extern_fn.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0036_unsafe_extern_fn.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0036_unsafe_extern_fn.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0037_qual_paths.txt b/crates/ra_syntax/test_data/parser/inline/ok/0037_qual_paths.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0037_qual_paths.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0037_qual_paths.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0038_full_range_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0038_full_range_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0038_full_range_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0038_full_range_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0039_type_arg.txt b/crates/ra_syntax/test_data/parser/inline/ok/0039_type_arg.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0039_type_arg.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0039_type_arg.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0040_crate_keyword_vis.txt b/crates/ra_syntax/test_data/parser/inline/ok/0040_crate_keyword_vis.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0040_crate_keyword_vis.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0040_crate_keyword_vis.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0041_trait_item.txt b/crates/ra_syntax/test_data/parser/inline/ok/0041_trait_item.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0041_trait_item.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0041_trait_item.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0042_call_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0042_call_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0042_call_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0042_call_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0043_use_alias.txt b/crates/ra_syntax/test_data/parser/inline/ok/0043_use_alias.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0043_use_alias.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0043_use_alias.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0044_block_items.txt b/crates/ra_syntax/test_data/parser/inline/ok/0044_block_items.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0044_block_items.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0044_block_items.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0045_param_list_opt_patterns.txt b/crates/ra_syntax/test_data/parser/inline/ok/0045_param_list_opt_patterns.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0045_param_list_opt_patterns.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0045_param_list_opt_patterns.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0046_singleton_tuple_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0046_singleton_tuple_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0046_singleton_tuple_type.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0046_singleton_tuple_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.txt b/crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0048_path_type_with_bounds.txt b/crates/ra_syntax/test_data/parser/inline/ok/0048_path_type_with_bounds.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0048_path_type_with_bounds.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0048_path_type_with_bounds.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0050_fn_decl.txt b/crates/ra_syntax/test_data/parser/inline/ok/0050_fn_decl.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0050_fn_decl.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0050_fn_decl.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0051_unit_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0051_unit_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0051_unit_type.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0051_unit_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0052_path_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0052_path_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0052_path_type.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0052_path_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0053_path_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0053_path_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0053_path_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0053_path_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0054_record_field_attrs.txt b/crates/ra_syntax/test_data/parser/inline/ok/0054_record_field_attrs.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0054_record_field_attrs.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0054_record_field_attrs.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0055_literal_pattern.txt b/crates/ra_syntax/test_data/parser/inline/ok/0055_literal_pattern.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0055_literal_pattern.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0055_literal_pattern.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0056_where_clause.txt b/crates/ra_syntax/test_data/parser/inline/ok/0056_where_clause.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0056_where_clause.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0056_where_clause.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0057_const_fn.txt b/crates/ra_syntax/test_data/parser/inline/ok/0057_const_fn.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0057_const_fn.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0057_const_fn.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0058_range_pat.txt b/crates/ra_syntax/test_data/parser/inline/ok/0058_range_pat.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0058_range_pat.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0058_range_pat.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0059_match_arms_commas.txt b/crates/ra_syntax/test_data/parser/inline/ok/0059_match_arms_commas.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0059_match_arms_commas.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0059_match_arms_commas.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0060_extern_crate.txt b/crates/ra_syntax/test_data/parser/inline/ok/0060_extern_crate.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0060_extern_crate.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0060_extern_crate.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0061_record_lit.txt b/crates/ra_syntax/test_data/parser/inline/ok/0061_record_lit.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0061_record_lit.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0061_record_lit.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0062_mod_contents.txt b/crates/ra_syntax/test_data/parser/inline/ok/0062_mod_contents.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0062_mod_contents.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0062_mod_contents.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.txt b/crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0064_if_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0064_if_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0064_if_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0064_if_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0065_dyn_trait_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0065_dyn_trait_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0065_dyn_trait_type.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0065_dyn_trait_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0066_match_arm.txt b/crates/ra_syntax/test_data/parser/inline/ok/0066_match_arm.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0066_match_arm.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0066_match_arm.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0067_crate_path.txt b/crates/ra_syntax/test_data/parser/inline/ok/0067_crate_path.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0067_crate_path.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0067_crate_path.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0068_union_items.txt b/crates/ra_syntax/test_data/parser/inline/ok/0068_union_items.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0068_union_items.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0068_union_items.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0069_use_tree_list_after_path.txt b/crates/ra_syntax/test_data/parser/inline/ok/0069_use_tree_list_after_path.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0069_use_tree_list_after_path.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0069_use_tree_list_after_path.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0070_stmt_bin_expr_ambiguity.txt b/crates/ra_syntax/test_data/parser/inline/ok/0070_stmt_bin_expr_ambiguity.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0070_stmt_bin_expr_ambiguity.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0070_stmt_bin_expr_ambiguity.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0071_match_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0071_match_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0071_match_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0071_match_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0072_return_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0072_return_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0072_return_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0072_return_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0073_type_item_type_params.txt b/crates/ra_syntax/test_data/parser/inline/ok/0073_type_item_type_params.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0073_type_item_type_params.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0073_type_item_type_params.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0074_stmt_postfix_expr_ambiguity.txt b/crates/ra_syntax/test_data/parser/inline/ok/0074_stmt_postfix_expr_ambiguity.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0074_stmt_postfix_expr_ambiguity.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0074_stmt_postfix_expr_ambiguity.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0075_block.txt b/crates/ra_syntax/test_data/parser/inline/ok/0075_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0075_block.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0075_block.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0076_function_where_clause.txt b/crates/ra_syntax/test_data/parser/inline/ok/0076_function_where_clause.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0076_function_where_clause.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0076_function_where_clause.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0077_try_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0077_try_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0077_try_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0077_try_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0078_type_item.txt b/crates/ra_syntax/test_data/parser/inline/ok/0078_type_item.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0078_type_item.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0078_type_item.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.txt b/crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0080_postfix_range.txt b/crates/ra_syntax/test_data/parser/inline/ok/0080_postfix_range.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0080_postfix_range.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0080_postfix_range.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0082_ref_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0082_ref_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0082_ref_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0082_ref_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0083_struct_items.txt b/crates/ra_syntax/test_data/parser/inline/ok/0083_struct_items.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0083_struct_items.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0083_struct_items.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0084_paren_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0084_paren_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0084_paren_type.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0084_paren_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0085_expr_literals.txt b/crates/ra_syntax/test_data/parser/inline/ok/0085_expr_literals.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0085_expr_literals.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0085_expr_literals.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0086_function_ret_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0086_function_ret_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0086_function_ret_type.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0086_function_ret_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.txt b/crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0088_break_ambiguity.txt b/crates/ra_syntax/test_data/parser/inline/ok/0088_break_ambiguity.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0088_break_ambiguity.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0088_break_ambiguity.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0089_extern_fn.txt b/crates/ra_syntax/test_data/parser/inline/ok/0089_extern_fn.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0089_extern_fn.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0089_extern_fn.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0090_type_param_default.txt b/crates/ra_syntax/test_data/parser/inline/ok/0090_type_param_default.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0090_type_param_default.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0090_type_param_default.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.txt b/crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0092_fn_pointer_type_with_ret.txt b/crates/ra_syntax/test_data/parser/inline/ok/0092_fn_pointer_type_with_ret.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0092_fn_pointer_type_with_ret.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0092_fn_pointer_type_with_ret.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0093_index_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0093_index_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0093_index_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0093_index_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.txt b/crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0095_placeholder_pat.txt b/crates/ra_syntax/test_data/parser/inline/ok/0095_placeholder_pat.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0095_placeholder_pat.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0095_placeholder_pat.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0096_no_semi_after_block.txt b/crates/ra_syntax/test_data/parser/inline/ok/0096_no_semi_after_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0096_no_semi_after_block.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0096_no_semi_after_block.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.txt b/crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0098_const_unsafe_fn.txt b/crates/ra_syntax/test_data/parser/inline/ok/0098_const_unsafe_fn.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0098_const_unsafe_fn.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0098_const_unsafe_fn.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0099_param_list.txt b/crates/ra_syntax/test_data/parser/inline/ok/0099_param_list.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0099_param_list.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0099_param_list.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0100_for_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0100_for_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0100_for_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0100_for_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0101_unsafe_fn.txt b/crates/ra_syntax/test_data/parser/inline/ok/0101_unsafe_fn.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0101_unsafe_fn.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0101_unsafe_fn.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0102_record_field_pat_list.txt b/crates/ra_syntax/test_data/parser/inline/ok/0102_record_field_pat_list.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0102_record_field_pat_list.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0102_record_field_pat_list.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0103_array_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0103_array_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0103_array_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0103_array_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0104_path_fn_trait_args.txt b/crates/ra_syntax/test_data/parser/inline/ok/0104_path_fn_trait_args.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0104_path_fn_trait_args.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0104_path_fn_trait_args.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0105_block_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0105_block_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0105_block_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0105_block_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0106_lambda_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0106_lambda_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0106_lambda_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0106_lambda_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0107_method_call_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0107_method_call_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0107_method_call_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0107_method_call_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0108_tuple_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0108_tuple_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0108_tuple_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0108_tuple_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0109_label.txt b/crates/ra_syntax/test_data/parser/inline/ok/0109_label.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0109_label.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0109_label.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0110_use_path.txt b/crates/ra_syntax/test_data/parser/inline/ok/0110_use_path.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0110_use_path.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0110_use_path.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.txt b/crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0112_bind_pat.txt b/crates/ra_syntax/test_data/parser/inline/ok/0112_bind_pat.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0112_bind_pat.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0112_bind_pat.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0113_nocontentexpr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0113_nocontentexpr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0113_nocontentexpr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0113_nocontentexpr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0114_tuple_struct_where.txt b/crates/ra_syntax/test_data/parser/inline/ok/0114_tuple_struct_where.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0114_tuple_struct_where.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0114_tuple_struct_where.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0115_tuple_field_attrs.txt b/crates/ra_syntax/test_data/parser/inline/ok/0115_tuple_field_attrs.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0115_tuple_field_attrs.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0115_tuple_field_attrs.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0117_macro_call_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0117_macro_call_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0117_macro_call_type.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0117_macro_call_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.txt b/crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0118_match_guard.txt b/crates/ra_syntax/test_data/parser/inline/ok/0118_match_guard.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0118_match_guard.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0118_match_guard.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0120_match_arms_inner_attribute.txt b/crates/ra_syntax/test_data/parser/inline/ok/0120_match_arms_inner_attribute.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0120_match_arms_inner_attribute.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0120_match_arms_inner_attribute.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0121_match_arms_outer_attributes.txt b/crates/ra_syntax/test_data/parser/inline/ok/0121_match_arms_outer_attributes.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0121_match_arms_outer_attributes.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0121_match_arms_outer_attributes.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0122_generic_lifetime_type_attribute.txt b/crates/ra_syntax/test_data/parser/inline/ok/0122_generic_lifetime_type_attribute.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0122_generic_lifetime_type_attribute.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0122_generic_lifetime_type_attribute.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0123_param_list_vararg.txt b/crates/ra_syntax/test_data/parser/inline/ok/0123_param_list_vararg.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0123_param_list_vararg.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0123_param_list_vararg.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0124_async_fn.txt b/crates/ra_syntax/test_data/parser/inline/ok/0124_async_fn.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0124_async_fn.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0124_async_fn.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0125_crate_keyword_path.txt b/crates/ra_syntax/test_data/parser/inline/ok/0125_crate_keyword_path.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0125_crate_keyword_path.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0125_crate_keyword_path.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0125_record_literal_field_with_attr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0125_record_literal_field_with_attr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0125_record_literal_field_with_attr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0125_record_literal_field_with_attr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0126_attr_on_expr_stmt.txt b/crates/ra_syntax/test_data/parser/inline/ok/0126_attr_on_expr_stmt.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0126_attr_on_expr_stmt.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0126_attr_on_expr_stmt.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0127_attr_on_last_expr_in_block.txt b/crates/ra_syntax/test_data/parser/inline/ok/0127_attr_on_last_expr_in_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0127_attr_on_last_expr_in_block.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0127_attr_on_last_expr_in_block.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.txt b/crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0129_marco_pat.txt b/crates/ra_syntax/test_data/parser/inline/ok/0129_marco_pat.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0129_marco_pat.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0129_marco_pat.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0130_let_stmt.txt b/crates/ra_syntax/test_data/parser/inline/ok/0130_let_stmt.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0130_let_stmt.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0130_let_stmt.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0130_try_block_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0130_try_block_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0130_try_block_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0130_try_block_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0131_existential_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0131_existential_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0131_existential_type.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0131_existential_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0132_box_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0132_box_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0132_box_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0132_box_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0134_nocontentexpr_after_item.txt b/crates/ra_syntax/test_data/parser/inline/ok/0134_nocontentexpr_after_item.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0134_nocontentexpr_after_item.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0134_nocontentexpr_after_item.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0137_await_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0137_await_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0137_await_expr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0137_await_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0138_associated_type_bounds.txt b/crates/ra_syntax/test_data/parser/inline/ok/0138_associated_type_bounds.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0138_associated_type_bounds.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0138_associated_type_bounds.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0138_expression_after_block.txt b/crates/ra_syntax/test_data/parser/inline/ok/0138_expression_after_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0138_expression_after_block.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0138_expression_after_block.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0139_param_outer_arg.txt b/crates/ra_syntax/test_data/parser/inline/ok/0139_param_outer_arg.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0139_param_outer_arg.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0139_param_outer_arg.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0142_for_range_from.txt b/crates/ra_syntax/test_data/parser/inline/ok/0142_for_range_from.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0142_for_range_from.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0142_for_range_from.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0143_box_pat.txt b/crates/ra_syntax/test_data/parser/inline/ok/0143_box_pat.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0143_box_pat.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0143_box_pat.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0144_dot_dot_pat.txt b/crates/ra_syntax/test_data/parser/inline/ok/0144_dot_dot_pat.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0144_dot_dot_pat.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0144_dot_dot_pat.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0145_record_field_pat.txt b/crates/ra_syntax/test_data/parser/inline/ok/0145_record_field_pat.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0145_record_field_pat.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0145_record_field_pat.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0146_as_precedence.txt b/crates/ra_syntax/test_data/parser/inline/ok/0146_as_precedence.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0146_as_precedence.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0146_as_precedence.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0147_const_param.txt b/crates/ra_syntax/test_data/parser/inline/ok/0147_const_param.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0147_const_param.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0147_const_param.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0147_macro_def.txt b/crates/ra_syntax/test_data/parser/inline/ok/0147_macro_def.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0147_macro_def.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0147_macro_def.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0148_pub_macro_def.txt b/crates/ra_syntax/test_data/parser/inline/ok/0148_pub_macro_def.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0148_pub_macro_def.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0148_pub_macro_def.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0150_array_attrs.txt b/crates/ra_syntax/test_data/parser/inline/ok/0150_array_attrs.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0150_array_attrs.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0150_array_attrs.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0150_impl_type_params.txt b/crates/ra_syntax/test_data/parser/inline/ok/0150_impl_type_params.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0150_impl_type_params.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0150_impl_type_params.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0151_trait_alias.txt b/crates/ra_syntax/test_data/parser/inline/ok/0151_trait_alias.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0151_trait_alias.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0151_trait_alias.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0152_arg_with_attr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0152_arg_with_attr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0152_arg_with_attr.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0152_arg_with_attr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0154_fn_pointer_param_ident_path.txt b/crates/ra_syntax/test_data/parser/inline/ok/0154_fn_pointer_param_ident_path.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0154_fn_pointer_param_ident_path.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0154_fn_pointer_param_ident_path.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0155_closure_params.txt b/crates/ra_syntax/test_data/parser/inline/ok/0155_closure_params.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0155_closure_params.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0155_closure_params.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0156_fn_def_param.txt b/crates/ra_syntax/test_data/parser/inline/ok/0156_fn_def_param.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0156_fn_def_param.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0156_fn_def_param.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0156_or_pattern.txt b/crates/ra_syntax/test_data/parser/inline/ok/0156_or_pattern.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0156_or_pattern.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0156_or_pattern.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0157_fn_pointer_unnamed_arg.txt b/crates/ra_syntax/test_data/parser/inline/ok/0157_fn_pointer_unnamed_arg.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0157_fn_pointer_unnamed_arg.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0157_fn_pointer_unnamed_arg.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0157_variant_discriminant.txt b/crates/ra_syntax/test_data/parser/inline/ok/0157_variant_discriminant.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0157_variant_discriminant.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0157_variant_discriminant.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0158_binop_resets_statementness.txt b/crates/ra_syntax/test_data/parser/inline/ok/0158_binop_resets_statementness.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0158_binop_resets_statementness.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0158_binop_resets_statementness.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0158_lambda_ret_block.txt b/crates/ra_syntax/test_data/parser/inline/ok/0158_lambda_ret_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0158_lambda_ret_block.txt rename to crates/ra_syntax/test_data/parser/inline/ok/0158_lambda_ret_block.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0000_empty.txt b/crates/ra_syntax/test_data/parser/ok/0000_empty.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0000_empty.txt rename to crates/ra_syntax/test_data/parser/ok/0000_empty.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0001_struct_item.txt b/crates/ra_syntax/test_data/parser/ok/0001_struct_item.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0001_struct_item.txt rename to crates/ra_syntax/test_data/parser/ok/0001_struct_item.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0002_struct_item_field.txt b/crates/ra_syntax/test_data/parser/ok/0002_struct_item_field.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0002_struct_item_field.txt rename to crates/ra_syntax/test_data/parser/ok/0002_struct_item_field.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0004_file_shebang.txt b/crates/ra_syntax/test_data/parser/ok/0004_file_shebang.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0004_file_shebang.txt rename to crates/ra_syntax/test_data/parser/ok/0004_file_shebang.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0005_fn_item.txt b/crates/ra_syntax/test_data/parser/ok/0005_fn_item.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0005_fn_item.txt rename to crates/ra_syntax/test_data/parser/ok/0005_fn_item.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0006_inner_attributes.txt b/crates/ra_syntax/test_data/parser/ok/0006_inner_attributes.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0006_inner_attributes.txt rename to crates/ra_syntax/test_data/parser/ok/0006_inner_attributes.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0007_extern_crate.txt b/crates/ra_syntax/test_data/parser/ok/0007_extern_crate.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0007_extern_crate.txt rename to crates/ra_syntax/test_data/parser/ok/0007_extern_crate.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0008_mod_item.txt b/crates/ra_syntax/test_data/parser/ok/0008_mod_item.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0008_mod_item.txt rename to crates/ra_syntax/test_data/parser/ok/0008_mod_item.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0009_use_item.txt b/crates/ra_syntax/test_data/parser/ok/0009_use_item.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0009_use_item.txt rename to crates/ra_syntax/test_data/parser/ok/0009_use_item.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0010_use_path_segments.txt b/crates/ra_syntax/test_data/parser/ok/0010_use_path_segments.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0010_use_path_segments.txt rename to crates/ra_syntax/test_data/parser/ok/0010_use_path_segments.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0011_outer_attribute.txt b/crates/ra_syntax/test_data/parser/ok/0011_outer_attribute.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0011_outer_attribute.txt rename to crates/ra_syntax/test_data/parser/ok/0011_outer_attribute.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0012_visibility.txt b/crates/ra_syntax/test_data/parser/ok/0012_visibility.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0012_visibility.txt rename to crates/ra_syntax/test_data/parser/ok/0012_visibility.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0013_use_path_self_super.txt b/crates/ra_syntax/test_data/parser/ok/0013_use_path_self_super.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0013_use_path_self_super.txt rename to crates/ra_syntax/test_data/parser/ok/0013_use_path_self_super.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0014_use_tree.txt b/crates/ra_syntax/test_data/parser/ok/0014_use_tree.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0014_use_tree.txt rename to crates/ra_syntax/test_data/parser/ok/0014_use_tree.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0015_use_tree.txt b/crates/ra_syntax/test_data/parser/ok/0015_use_tree.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0015_use_tree.txt rename to crates/ra_syntax/test_data/parser/ok/0015_use_tree.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0016_struct_flavors.txt b/crates/ra_syntax/test_data/parser/ok/0016_struct_flavors.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0016_struct_flavors.txt rename to crates/ra_syntax/test_data/parser/ok/0016_struct_flavors.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0017_attr_trailing_comma.txt b/crates/ra_syntax/test_data/parser/ok/0017_attr_trailing_comma.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0017_attr_trailing_comma.txt rename to crates/ra_syntax/test_data/parser/ok/0017_attr_trailing_comma.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0018_struct_type_params.txt b/crates/ra_syntax/test_data/parser/ok/0018_struct_type_params.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0018_struct_type_params.txt rename to crates/ra_syntax/test_data/parser/ok/0018_struct_type_params.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0019_enums.txt b/crates/ra_syntax/test_data/parser/ok/0019_enums.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0019_enums.txt rename to crates/ra_syntax/test_data/parser/ok/0019_enums.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0020_type_param_bounds.txt b/crates/ra_syntax/test_data/parser/ok/0020_type_param_bounds.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0020_type_param_bounds.txt rename to crates/ra_syntax/test_data/parser/ok/0020_type_param_bounds.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0021_extern_fn.txt b/crates/ra_syntax/test_data/parser/ok/0021_extern_fn.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0021_extern_fn.txt rename to crates/ra_syntax/test_data/parser/ok/0021_extern_fn.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0022_empty_extern_block.txt b/crates/ra_syntax/test_data/parser/ok/0022_empty_extern_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0022_empty_extern_block.txt rename to crates/ra_syntax/test_data/parser/ok/0022_empty_extern_block.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0023_static_items.txt b/crates/ra_syntax/test_data/parser/ok/0023_static_items.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0023_static_items.txt rename to crates/ra_syntax/test_data/parser/ok/0023_static_items.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0024_const_item.txt b/crates/ra_syntax/test_data/parser/ok/0024_const_item.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0024_const_item.txt rename to crates/ra_syntax/test_data/parser/ok/0024_const_item.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0025_extern_fn_in_block.txt b/crates/ra_syntax/test_data/parser/ok/0025_extern_fn_in_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0025_extern_fn_in_block.txt rename to crates/ra_syntax/test_data/parser/ok/0025_extern_fn_in_block.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0026_const_fn_in_block.txt b/crates/ra_syntax/test_data/parser/ok/0026_const_fn_in_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0026_const_fn_in_block.txt rename to crates/ra_syntax/test_data/parser/ok/0026_const_fn_in_block.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0027_unsafe_fn_in_block.txt b/crates/ra_syntax/test_data/parser/ok/0027_unsafe_fn_in_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0027_unsafe_fn_in_block.txt rename to crates/ra_syntax/test_data/parser/ok/0027_unsafe_fn_in_block.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0028_operator_binding_power.txt b/crates/ra_syntax/test_data/parser/ok/0028_operator_binding_power.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0028_operator_binding_power.txt rename to crates/ra_syntax/test_data/parser/ok/0028_operator_binding_power.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0029_range_forms.txt b/crates/ra_syntax/test_data/parser/ok/0029_range_forms.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0029_range_forms.txt rename to crates/ra_syntax/test_data/parser/ok/0029_range_forms.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0030_string_suffixes.txt b/crates/ra_syntax/test_data/parser/ok/0030_string_suffixes.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0030_string_suffixes.txt rename to crates/ra_syntax/test_data/parser/ok/0030_string_suffixes.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0030_traits.txt b/crates/ra_syntax/test_data/parser/ok/0030_traits.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0030_traits.txt rename to crates/ra_syntax/test_data/parser/ok/0030_traits.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0031_extern.txt b/crates/ra_syntax/test_data/parser/ok/0031_extern.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0031_extern.txt rename to crates/ra_syntax/test_data/parser/ok/0031_extern.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0032_where_for.txt b/crates/ra_syntax/test_data/parser/ok/0032_where_for.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0032_where_for.txt rename to crates/ra_syntax/test_data/parser/ok/0032_where_for.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0033_label_break.txt b/crates/ra_syntax/test_data/parser/ok/0033_label_break.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0033_label_break.txt rename to crates/ra_syntax/test_data/parser/ok/0033_label_break.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0034_crate_path_in_call.txt b/crates/ra_syntax/test_data/parser/ok/0034_crate_path_in_call.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0034_crate_path_in_call.txt rename to crates/ra_syntax/test_data/parser/ok/0034_crate_path_in_call.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0035_weird_exprs.txt b/crates/ra_syntax/test_data/parser/ok/0035_weird_exprs.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0035_weird_exprs.txt rename to crates/ra_syntax/test_data/parser/ok/0035_weird_exprs.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0036_fully_qualified.txt b/crates/ra_syntax/test_data/parser/ok/0036_fully_qualified.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0036_fully_qualified.txt rename to crates/ra_syntax/test_data/parser/ok/0036_fully_qualified.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0037_mod.txt b/crates/ra_syntax/test_data/parser/ok/0037_mod.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0037_mod.txt rename to crates/ra_syntax/test_data/parser/ok/0037_mod.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0038_where_pred_type.txt b/crates/ra_syntax/test_data/parser/ok/0038_where_pred_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0038_where_pred_type.txt rename to crates/ra_syntax/test_data/parser/ok/0038_where_pred_type.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0039_raw_fn_item.txt b/crates/ra_syntax/test_data/parser/ok/0039_raw_fn_item.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0039_raw_fn_item.txt rename to crates/ra_syntax/test_data/parser/ok/0039_raw_fn_item.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0040_raw_struct_item_field.txt b/crates/ra_syntax/test_data/parser/ok/0040_raw_struct_item_field.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0040_raw_struct_item_field.txt rename to crates/ra_syntax/test_data/parser/ok/0040_raw_struct_item_field.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0041_raw_keywords.txt b/crates/ra_syntax/test_data/parser/ok/0041_raw_keywords.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0041_raw_keywords.txt rename to crates/ra_syntax/test_data/parser/ok/0041_raw_keywords.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0042_ufcs_call_list.txt b/crates/ra_syntax/test_data/parser/ok/0042_ufcs_call_list.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0042_ufcs_call_list.txt rename to crates/ra_syntax/test_data/parser/ok/0042_ufcs_call_list.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0043_complex_assignment.txt b/crates/ra_syntax/test_data/parser/ok/0043_complex_assignment.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0043_complex_assignment.txt rename to crates/ra_syntax/test_data/parser/ok/0043_complex_assignment.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0044_let_attrs.txt b/crates/ra_syntax/test_data/parser/ok/0044_let_attrs.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0044_let_attrs.txt rename to crates/ra_syntax/test_data/parser/ok/0044_let_attrs.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0045_block_inner_attrs.txt b/crates/ra_syntax/test_data/parser/ok/0045_block_inner_attrs.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0045_block_inner_attrs.txt rename to crates/ra_syntax/test_data/parser/ok/0045_block_inner_attrs.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0046_extern_inner_attributes.txt b/crates/ra_syntax/test_data/parser/ok/0046_extern_inner_attributes.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0046_extern_inner_attributes.txt rename to crates/ra_syntax/test_data/parser/ok/0046_extern_inner_attributes.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0047_minus_in_inner_pattern.txt b/crates/ra_syntax/test_data/parser/ok/0047_minus_in_inner_pattern.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0047_minus_in_inner_pattern.txt rename to crates/ra_syntax/test_data/parser/ok/0047_minus_in_inner_pattern.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0048_compound_assignment.txt b/crates/ra_syntax/test_data/parser/ok/0048_compound_assignment.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0048_compound_assignment.txt rename to crates/ra_syntax/test_data/parser/ok/0048_compound_assignment.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0049_async_block.txt b/crates/ra_syntax/test_data/parser/ok/0049_async_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0049_async_block.txt rename to crates/ra_syntax/test_data/parser/ok/0049_async_block.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0050_async_block_as_argument.txt b/crates/ra_syntax/test_data/parser/ok/0050_async_block_as_argument.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0050_async_block_as_argument.txt rename to crates/ra_syntax/test_data/parser/ok/0050_async_block_as_argument.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.txt b/crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.txt rename to crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0052_for_range_block.txt b/crates/ra_syntax/test_data/parser/ok/0052_for_range_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0052_for_range_block.txt rename to crates/ra_syntax/test_data/parser/ok/0052_for_range_block.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0053_outer_attribute_on_macro_rules.txt b/crates/ra_syntax/test_data/parser/ok/0053_outer_attribute_on_macro_rules.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0053_outer_attribute_on_macro_rules.txt rename to crates/ra_syntax/test_data/parser/ok/0053_outer_attribute_on_macro_rules.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0054_qual_path_in_type_arg.txt b/crates/ra_syntax/test_data/parser/ok/0054_qual_path_in_type_arg.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0054_qual_path_in_type_arg.txt rename to crates/ra_syntax/test_data/parser/ok/0054_qual_path_in_type_arg.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0055_dot_dot_dot.txt b/crates/ra_syntax/test_data/parser/ok/0055_dot_dot_dot.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0055_dot_dot_dot.txt rename to crates/ra_syntax/test_data/parser/ok/0055_dot_dot_dot.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0056_neq_in_type.txt b/crates/ra_syntax/test_data/parser/ok/0056_neq_in_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0056_neq_in_type.txt rename to crates/ra_syntax/test_data/parser/ok/0056_neq_in_type.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0057_loop_in_call.txt b/crates/ra_syntax/test_data/parser/ok/0057_loop_in_call.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0057_loop_in_call.txt rename to crates/ra_syntax/test_data/parser/ok/0057_loop_in_call.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0058_unary_expr_precedence.txt b/crates/ra_syntax/test_data/parser/ok/0058_unary_expr_precedence.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0058_unary_expr_precedence.txt rename to crates/ra_syntax/test_data/parser/ok/0058_unary_expr_precedence.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0059_loops_in_parens.txt b/crates/ra_syntax/test_data/parser/ok/0059_loops_in_parens.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0059_loops_in_parens.txt rename to crates/ra_syntax/test_data/parser/ok/0059_loops_in_parens.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0060_as_range.txt b/crates/ra_syntax/test_data/parser/ok/0060_as_range.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0060_as_range.txt rename to crates/ra_syntax/test_data/parser/ok/0060_as_range.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0061_match_full_range.txt b/crates/ra_syntax/test_data/parser/ok/0061_match_full_range.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0061_match_full_range.txt rename to crates/ra_syntax/test_data/parser/ok/0061_match_full_range.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0062_macro_2.0.txt b/crates/ra_syntax/test_data/parser/ok/0062_macro_2.0.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0062_macro_2.0.txt rename to crates/ra_syntax/test_data/parser/ok/0062_macro_2.0.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0063_trait_fn_patterns.txt b/crates/ra_syntax/test_data/parser/ok/0063_trait_fn_patterns.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0063_trait_fn_patterns.txt rename to crates/ra_syntax/test_data/parser/ok/0063_trait_fn_patterns.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0063_variadic_fun.txt b/crates/ra_syntax/test_data/parser/ok/0063_variadic_fun.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0063_variadic_fun.txt rename to crates/ra_syntax/test_data/parser/ok/0063_variadic_fun.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0064_impl_fn_params.txt b/crates/ra_syntax/test_data/parser/ok/0064_impl_fn_params.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0064_impl_fn_params.txt rename to crates/ra_syntax/test_data/parser/ok/0064_impl_fn_params.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0065_comment_newline.txt b/crates/ra_syntax/test_data/parser/ok/0065_comment_newline.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0065_comment_newline.txt rename to crates/ra_syntax/test_data/parser/ok/0065_comment_newline.rast diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index b6a0157902..4734df16ac 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs @@ -131,37 +131,47 @@ impl Config { set(value, "/cargo/allFeatures", &mut self.cargo.all_features); set(value, "/cargo/features", &mut self.cargo.features); set(value, "/cargo/loadOutDirsFromCheck", &mut self.cargo.load_out_dirs_from_check); - if let Some(mut args) = get::>(value, "/rustfmt/overrideCommand") { - if !args.is_empty() { + match get::>(value, "/rustfmt/overrideCommand") { + Some(mut args) if !args.is_empty() => { let command = args.remove(0); self.rustfmt = RustfmtConfig::CustomCommand { command, args, } } - } else if let RustfmtConfig::Rustfmt { extra_args } = &mut self.rustfmt { - set(value, "/rustfmt/extraArgs", extra_args); - } + _ => { + if let RustfmtConfig::Rustfmt { extra_args } = &mut self.rustfmt { + set(value, "/rustfmt/extraArgs", extra_args); + } + } + }; if let Some(false) = get(value, "/checkOnSave/enable") { + // check is disabled self.check = None; } else { - if let Some(mut args) = get::>(value, "/checkOnSave/overrideCommand") { - if !args.is_empty() { + // check is enabled + match get::>(value, "/checkOnSave/overrideCommand") { + // first see if the user has completely overridden the command + Some(mut args) if !args.is_empty() => { let command = args.remove(0); self.check = Some(FlycheckConfig::CustomCommand { command, args, }); } - - } else if let Some(FlycheckConfig::CargoCommand { command, extra_args, all_targets }) = &mut self.check - { - set(value, "/checkOnSave/extraArgs", extra_args); - set(value, "/checkOnSave/command", command); - set(value, "/checkOnSave/allTargets", all_targets); - } - }; + // otherwise configure command customizations + _ => { + if let Some(FlycheckConfig::CargoCommand { command, extra_args, all_targets }) + = &mut self.check + { + set(value, "/checkOnSave/extraArgs", extra_args); + set(value, "/checkOnSave/command", command); + set(value, "/checkOnSave/allTargets", all_targets); + } + } + }; + } set(value, "/inlayHints/typeHints", &mut self.inlay_hints.type_hints); set(value, "/inlayHints/parameterHints", &mut self.inlay_hints.parameter_hints); diff --git a/crates/rust-analyzer/src/lib.rs b/crates/rust-analyzer/src/lib.rs index 02953be303..036bf62a73 100644 --- a/crates/rust-analyzer/src/lib.rs +++ b/crates/rust-analyzer/src/lib.rs @@ -13,17 +13,8 @@ pub mod cli; #[allow(unused)] -macro_rules! println { - ($($tt:tt)*) => { - compile_error!("stdout is locked, use eprintln") - }; -} - -#[allow(unused)] -macro_rules! print { - ($($tt:tt)*) => { - compile_error!("stdout is locked, use eprint") - }; +macro_rules! eprintln { + ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; } mod vfs_glob; diff --git a/crates/stdx/src/lib.rs b/crates/stdx/src/lib.rs index d2efa22363..401a568bd5 100644 --- a/crates/stdx/src/lib.rs +++ b/crates/stdx/src/lib.rs @@ -2,6 +2,21 @@ use std::{cell::Cell, fmt}; +#[inline(always)] +pub fn is_ci() -> bool { + option_env!("CI").is_some() +} + +#[macro_export] +macro_rules! eprintln { + ($($tt:tt)*) => {{ + if $crate::is_ci() { + panic!("Forgot to remove debug-print?") + } + std::eprintln!($($tt)*) + }} +} + /// Appends formatted string to a `String`. #[macro_export] macro_rules! format_to { diff --git a/crates/test_utils/src/lib.rs b/crates/test_utils/src/lib.rs index db03df1c45..4164bfd5ed 100644 --- a/crates/test_utils/src/lib.rs +++ b/crates/test_utils/src/lib.rs @@ -302,42 +302,40 @@ pub fn find_mismatch<'a>(expected: &'a Value, actual: &'a Value) -> Option<(&'a } } -/// Calls callback `f` with input code and file paths of all `.rs` files from `test_data_dir` +/// Calls callback `f` with input code and file paths for each `.rs` file in `test_data_dir` /// subdirectories defined by `paths`. /// -/// If the content of the matching `.txt` file differs from the output of `f()` +/// If the content of the matching output file differs from the output of `f()` /// the test will fail. /// -/// If there is no matching `.txt` file it will be created and filled with the +/// If there is no matching output file it will be created and filled with the /// output of `f()`, but the test will fail. -pub fn dir_tests(test_data_dir: &Path, paths: &[&str], f: F) +pub fn dir_tests(test_data_dir: &Path, paths: &[&str], outfile_extension: &str, f: F) where F: Fn(&str, &Path) -> String, { - for (path, input_code) in collect_tests(test_data_dir, paths) { - let parse_tree = f(&input_code, &path); - let path = path.with_extension("txt"); + for (path, input_code) in collect_rust_files(test_data_dir, paths) { + let actual = f(&input_code, &path); + let path = path.with_extension(outfile_extension); if !path.exists() { println!("\nfile: {}", path.display()); println!("No .txt file with expected result, creating...\n"); - println!("{}\n{}", input_code, parse_tree); - fs::write(&path, &parse_tree).unwrap(); - panic!("No expected result") + println!("{}\n{}", input_code, actual); + fs::write(&path, &actual).unwrap(); + panic!("No expected result"); } let expected = read_text(&path); - let expected = expected.as_str(); - let parse_tree = parse_tree.as_str(); - assert_equal_text(expected, parse_tree, &path); + assert_equal_text(&expected, &actual, &path); } } -/// Collects all `.rs` files from `test_data_dir` subdirectories defined by `paths`. -pub fn collect_tests(test_data_dir: &Path, paths: &[&str]) -> Vec<(PathBuf, String)> { +/// Collects all `.rs` files from `dir` subdirectories defined by `paths`. +pub fn collect_rust_files(root_dir: &Path, paths: &[&str]) -> Vec<(PathBuf, String)> { paths .iter() .flat_map(|path| { - let path = test_data_dir.to_owned().join(path); - test_from_dir(&path).into_iter() + let path = root_dir.to_owned().join(path); + rust_files_in_dir(&path).into_iter() }) .map(|path| { let text = read_text(&path); @@ -347,7 +345,7 @@ pub fn collect_tests(test_data_dir: &Path, paths: &[&str]) -> Vec<(PathBuf, Stri } /// Collects paths to all `.rs` files from `dir` in a sorted `Vec`. -fn test_from_dir(dir: &Path) -> Vec { +fn rust_files_in_dir(dir: &Path) -> Vec { let mut acc = Vec::new(); for file in fs::read_dir(&dir).unwrap() { let file = file.unwrap(); diff --git a/editors/code/package.json b/editors/code/package.json index 60ca0c69cd..8ae8ea4140 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -251,11 +251,15 @@ "description": "Additional arguments to rustfmt" }, "rust-analyzer.rustfmt.overrideCommand": { - "type": "array", + "type": [ + "null", + "array" + ], "items": { - "type": "string" + "type": "string", + "minItems": 1 }, - "default": [], + "default": null, "markdownDescription": "Advanced option, fully override the command rust-analyzer uses for formatting." }, "rust-analyzer.checkOnSave.enable": { @@ -277,11 +281,15 @@ "markdownDescription": "Cargo command to use for `cargo check`" }, "rust-analyzer.checkOnSave.overrideCommand": { - "type": "array", + "type": [ + "null", + "array" + ], "items": { - "type": "string" + "type": "string", + "minItems": 1 }, - "default": [], + "default": null, "markdownDescription": "Advanced option, fully override the command rust-analyzer uses for checking. The command should include `--message=format=json` or similar option." }, "rust-analyzer.checkOnSave.allTargets": { diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs index 4f01f84fb4..0b8243f62e 100644 --- a/xtask/src/lib.rs +++ b/xtask/src/lib.rs @@ -172,8 +172,8 @@ pub fn run_pre_cache() -> Result<()> { pub fn run_release(dry_run: bool) -> Result<()> { if !dry_run { run!("git switch release")?; - run!("git fetch upstream")?; - run!("git reset --hard upstream/master")?; + run!("git fetch upstream --tags --force")?; + run!("git reset --hard tags/nightly")?; run!("git push")?; }