feat: add support for feature attributes in struct literal

Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
This commit is contained in:
Benjamin Coenen 2020-04-09 18:37:34 +02:00
commit c1317d6923
28 changed files with 7648 additions and 8155 deletions

View file

@ -23,7 +23,7 @@ use insta::assert_snapshot;
use ra_db::{fixture::WithFixture, salsa::Database, FilePosition, SourceDatabase};
use ra_syntax::{
algo,
ast::{self, AstNode},
ast::{self, AstNode, AstToken},
};
use stdx::format_to;
@ -101,7 +101,7 @@ fn infer_with_mismatches(content: &str, include_mismatches: bool) -> String {
let node = src_ptr.value.to_node(&src_ptr.file_syntax(&db));
let (range, text) = if let Some(self_param) = ast::SelfParam::cast(node.clone()) {
(self_param.self_kw_token().text_range(), "self".to_string())
(self_param.self_kw().unwrap().syntax().text_range(), "self".to_string())
} else {
(src_ptr.value.range(), node.text().to_string().replace("\n", " "))
};
@ -367,7 +367,7 @@ fn no_such_field_with_feature_flag_diagnostics_on_struct_lit() {
fn new(foo: u32) -> Self {
Self { foo }
}
#[cfg(not(feature = "foo"))]
#[cfg(not(feature = "foo"))]
fn new(bar: u32) -> Self {
Self { bar }
}