rust/crates
bors[bot] 412eda7387
Merge #3880
3880: Add support for attributes for struct fields r=matklad a=bnjjj

Hello I try to solve this example:
```rust
struct MyStruct {
    my_val: usize,
    #[cfg(feature = "foo")]
    bar: bool,
}
impl MyStruct {
    #[cfg(feature = "foo")]
    pub(crate) fn new(my_val: usize, bar: bool) -> Self {
        Self { my_val, bar }
    }
    #[cfg(not(feature = "foo"))]
    pub(crate) fn new(my_val: usize, _bar: bool) -> Self {
        Self { my_val }
    }
}
```

Here is a draft PR to try to solve this issue. In fact for now when i have this kind of example, rust-analyzer tells me that my second Self {} miss the bar field. Which is a bug.

I have some difficulties to add this features. Here in my draft I share my work about adding attributes support on struct field data. But I'm stuck when I have to fetch attributes from parent expressions. I don't really know how to do that. For the first iteration I just want to solve my issue without solving on all different expressions. And then after I will try to implement that on different kind of expression. I think I have to fetch my FunctionId and then I will be able to find attributes with myFunction.attrs() But I don't know if it's the right way.

@matklad (or anyone else) if you can help me it would be great :D 

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-04-09 08:08:55 +00:00
..
ra_arena Use resize_with 2020-03-31 09:02:12 -04:00
ra_assists Fix add missing items assist order 2020-04-09 10:00:27 +02:00
ra_cfg Update versions 2020-02-18 16:12:40 +02:00
ra_db Merge #3727 2020-03-26 17:09:32 +00:00
ra_flycheck Centralize defaults 2020-04-01 18:56:47 +02:00
ra_fmt update itertools version to 0.9.0 2020-03-23 16:22:46 -07:00
ra_hir Move computation of missing fields into hir 2020-04-07 18:34:17 +02:00
ra_hir_def feat: add attributes support on struct fields and method #3870 2020-04-08 18:12:15 +02:00
ra_hir_expand Fix unnecessary braces warnings 2020-04-06 17:21:33 +03:00
ra_hir_ty feat: add attributes support on struct fields and method #3870 2020-04-09 09:53:53 +02:00
ra_ide Merge #3826 2020-04-08 12:00:08 +00:00
ra_ide_db Fix unnecessary braces warnings 2020-04-06 17:21:33 +03:00
ra_mbe Add L_DOLLAR for TYPE_RECOVERY_SET 2020-04-08 18:34:20 +08:00
ra_parser Add L_DOLLAR for TYPE_RECOVERY_SET 2020-04-08 18:34:20 +08:00
ra_proc_macro Introduce ra_proc_macro_srv 2020-04-03 19:01:44 +08:00
ra_proc_macro_srv Remove unused func 2020-04-09 13:04:01 +08:00
ra_prof Fix race in the tests 2020-03-30 11:33:01 +02:00
ra_project_model Migrate to privacy as per review commets 2020-04-02 21:09:03 +03:00
ra_syntax Fix warnings emitted when compiling as part of rustc 2020-04-08 14:49:19 +02:00
ra_text_edit Remove some TextUnit->usize escapees 2020-03-12 22:33:27 -04:00
ra_tt Implement ra_proc_macro client logic 2020-03-31 22:20:18 +08:00
rust-analyzer fix cargo check config with custom command 2020-04-06 21:41:31 -07:00
stdx Check for eprintln on CI 2020-04-06 17:00:18 +02:00
test_utils Migrate tests .txt -> .rast 2020-04-06 14:04:26 +03:00