Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No support for GATs #6633

Closed
PizzaCrust opened this issue Jan 8, 2021 · 7 comments
Closed

No support for GATs #6633

PizzaCrust opened this issue Jan 8, 2021 · 7 comments
Assignees
Labels
feature rust Issues about new language features

Comments

@PizzaCrust
Copy link

Environment

  • IntelliJ Rust plugin version: 0.3.138.3572-203
  • Rust toolchain version: 1.51.0-nightly (fde692739 2021-01-02) x86_64-pc-windows-msvc
  • IDE name and version: CLion 2020.3.1 (CL-203.6682.181)
  • Operating system: Windows 10 10.0
  • Macro expansion engine: new
  • Name resolution engine: new

Problem description

Shows error even with GATs enabled.
image

Steps to reproduce

#![feature(generic_associated_types)]

trait A {
    type Item<'a>: Sync;
}

struct B;
impl A for B {
    type Item<'a> = &'a ();
}
@Undin Undin added rust Issues about new language features feature labels Jan 10, 2021
@not-wlan
Copy link

not-wlan commented Aug 6, 2021

This should be reconsidered/reprioritized with this blog post in mind: https://blog.rust-lang.org/2021/08/03/GATs-stabilization-push.html

@mchernyavsky mchernyavsky self-assigned this Aug 9, 2021
bors bot added a commit that referenced this issue Nov 24, 2021
7976: ANN: Update inspections for Type Aliases r=vlad20012 a=mchernyavsky

Fixes #8109.

Relates to #6633.

changelog: Update inspections for Type Aliases


8153: RES: Correctly disambiguate unit struct vs const to struct r=mchernyavsky a=vlad20012

```rust
struct N;
     //X
fn bar<T>() {}
fn foo<const N: i32>() {
    bar::<N>();
}       //^
```

Co-authored-by: Mikhail Chernyavsky <mikhail.chernyavsky@jetbrains.com>
Co-authored-by: vlad20012 <beskvlad@gmail.com>
bors bot added a commit that referenced this issue Feb 15, 2022
7977: REF: Render generic parameters for associated types in `Implement Members` r=dima74 a=mchernyavsky

Relates to #6633.

changelog: Render generic parameters for associated types in `Implement Members`


Co-authored-by: Mikhail Chernyavsky <mikhail.chernyavsky@jetbrains.com>
bors bot added a commit that referenced this issue Feb 21, 2022
7816: IDE: convert JSON object to Rust struct after paste r=dima74 a=Kobzol

This PR adds a copy paste processor that tries to convert pasted JSON-like text to a Rust struct (according to the `serde` data model). Currently it does not actually implement any `serde` things on the struct to keep this PR simpler (but it's easy to add `Serialize/Deserialize` derive to the struct using existing intentions and completion).

It currently works like this:
![json](https://user-images.githubusercontent.com/4539057/136369971-6dd99a4d-372d-4ebc-ba78-aed3bbb17850.gif)

Improvements (possibly for follow-up PRs):
- [ ] Add `#[derive(Serialize, Deserialize)]`, possibly with auto import of these traits.
- [ ] Add `serde` with `derive` feature (or `serde_derive` in edition 2015) to `Cargo.toml` if it's not already included (#7405)
- [ ] Parametrize the behaviour in settings (allow to turn it off). Not sure if this is needed `@Undin?`

Fixes: #7783

changelog: You can now paste JSON objects into Rust files and convert them to a Rust struct.

8542: GRAM: Fix parsing of generic parameters for assoc types / type aliases and assoc type bindings r=vlad20012 a=mchernyavsky

Relates to #6633.

changelog: Fix parsing of generic parameters for assoc types / type aliases and assoc type bindings


8571: ANN: Fix incorrectly providing `Add unsafe to function` in the main function r=Undin a=Stzx

changelog:

Fixed: #8530 


8586: UI: fix wrong indents in new project panel with new project wizard r=ozkriff a=Undin

It's a temporary workaround. The proper solution should be done as part of #8585

| Before | After |
| - | - |
| <img width="889" alt="Screen Shot 2022-02-21 at 15 58 18" src="https://user-images.githubusercontent.com/2539310/154959839-c43eb073-2a8d-46d0-b206-ad9d62cde61b.png"> | <img width="890" alt="Screen Shot 2022-02-21 at 15 55 52" src="https://user-images.githubusercontent.com/2539310/154959488-26d3712a-5ca6-4451-b6ae-cd8edfa08d41.png"> |


Fixes #8508



changelog: Fix wrong indents in UI during creation of a new Rust project in IDEA


Co-authored-by: Jakub Beránek <berykubik@gmail.com>
Co-authored-by: mhernyavsky <chernyavsky.mikhail@gmail.com>
Co-authored-by: Stzx <silence.m@hotmail.com>
Co-authored-by: Arseniy Pendryak <a.pendryak@yandex.ru>
bors bot added a commit that referenced this issue Feb 21, 2022
7816: IDE: convert JSON object to Rust struct after paste r=dima74 a=Kobzol

This PR adds a copy paste processor that tries to convert pasted JSON-like text to a Rust struct (according to the `serde` data model). Currently it does not actually implement any `serde` things on the struct to keep this PR simpler (but it's easy to add `Serialize/Deserialize` derive to the struct using existing intentions and completion).

It currently works like this:
![json](https://user-images.githubusercontent.com/4539057/136369971-6dd99a4d-372d-4ebc-ba78-aed3bbb17850.gif)

Improvements (possibly for follow-up PRs):
- [ ] Add `#[derive(Serialize, Deserialize)]`, possibly with auto import of these traits.
- [ ] Add `serde` with `derive` feature (or `serde_derive` in edition 2015) to `Cargo.toml` if it's not already included (#7405)
- [ ] Parametrize the behaviour in settings (allow to turn it off). Not sure if this is needed `@Undin?`

Fixes: #7783

changelog: You can now paste JSON objects into Rust files and convert them to a Rust struct.

8542: GRAM: Fix parsing of generic parameters for assoc types / type aliases and assoc type bindings r=vlad20012 a=mchernyavsky

Relates to #6633.

changelog: Fix parsing of generic parameters for assoc types / type aliases and assoc type bindings


Co-authored-by: Jakub Beránek <berykubik@gmail.com>
Co-authored-by: mhernyavsky <chernyavsky.mikhail@gmail.com>
bors bot added a commit that referenced this issue Feb 22, 2022
8542: GRAM: Fix parsing of generic parameters for assoc types / type aliases and assoc type bindings r=vlad20012 a=mchernyavsky

Relates to #6633.

changelog: Fix parsing of generic parameters for assoc types / type aliases and assoc type bindings


Co-authored-by: mhernyavsky <chernyavsky.mikhail@gmail.com>
bors bot added a commit that referenced this issue Feb 22, 2022
8542: GRAM: Fix parsing of generic parameters for assoc types / type aliases and assoc type bindings r=vlad20012 a=mchernyavsky

Relates to #6633.

changelog: Fix parsing of generic parameters for assoc types / type aliases and assoc type bindings


Co-authored-by: mhernyavsky <chernyavsky.mikhail@gmail.com>
bors bot added a commit that referenced this issue Mar 9, 2022
8565: UI: Render generic parameters for assoc types if any r=dima74 a=mchernyavsky

Relates to #6633.

changelog: Render generic parameters for type aliases / associated types in UI


8596: IDE: add derive to structs generated from JSON if `serde` is in dependencies r=dima74 a=Kobzol

Improvement of #7816.

(Changelog is omitted if this gets into the same release as #7816).

8609: CARGO: use the same project toolchain to get info about stdlib as project uses r=mchernyavsky a=Undin

Previously, the plugin used a toolchain related to stdlib source directory to get info about stdlib (dependencies, edition, etc.). And usually, it's a default toolchain from `rustup` point of view.
But if a user [overrides](https://rust-lang.github.io/rustup/overrides.html) toolchain for the project, the plugin didn't use it for stdlib that sometimes produced errors like #8517

Now, the plugin retrieves the actual toolchain name (from `rustup` point of view) and passes it to all commands used to get stdlib info

Fixes #8517

changelog: Use the project toolchain to retrieve info about stdlib. Previously, the plugin used the default toolchain for it that sometimes produced errors


Co-authored-by: mhernyavsky <chernyavsky.mikhail@gmail.com>
Co-authored-by: Jakub Beránek <berykubik@gmail.com>
Co-authored-by: Arseniy Pendryak <a.pendryak@yandex.ru>
bors bot added a commit that referenced this issue Mar 9, 2022
8565: UI: Render generic parameters for assoc types if any r=dima74 a=mchernyavsky

Relates to #6633.

changelog: Render generic parameters for type aliases / associated types in UI


Co-authored-by: mhernyavsky <chernyavsky.mikhail@gmail.com>
bors bot added a commit that referenced this issue Apr 29, 2022
8542: GRAM: Fix parsing of generic parameters for assoc types / type aliases and assoc type bindings r=vlad20012 a=mchernyavsky

Relates to #6633.

changelog: Fix parsing of generic parameters for assoc types / type aliases and assoc type bindings


Co-authored-by: mhernyavsky <chernyavsky.mikhail@gmail.com>
bors bot added a commit that referenced this issue Apr 29, 2022
8542: GRAM: Fix parsing of generic parameters for assoc types / type aliases and assoc type bindings r=vlad20012 a=mchernyavsky

Relates to #6633.

changelog: Fix parsing of generic parameters for assoc types / type aliases and assoc type bindings


Co-authored-by: mhernyavsky <chernyavsky.mikhail@gmail.com>
@oersted
Copy link

oersted commented Sep 20, 2022

On the latest release (0.4.178.4873-222) use of GAT is has error lints (red) unless #![feature(generic_associated_types)] is added. This was correct until GAT was stabilised in nightly recently (1.66-nightly). Now the feature declaration is not necessary and it shows a warning if it is included (#[warn(stable_features)]).

@oersted
Copy link

oersted commented Sep 20, 2022

This where syntax also has an error lint (red)

image

However, this is the standard syntax now and it compiles fine (on latest nightly at least).
rust-lang/rust#89122

The older alternative is accepted by the editor but it shows a warning because it is deprecated (and with good reason, rust-fmt makes it look quite awkward).

image

image

@Undin
Copy link
Member

Undin commented Oct 7, 2022

On the latest release (0.4.178.4873-222) use of GAT is has error lints (red) unless #![feature(generic_associated_types)] is added. This was correct until GAT was stabilised in nightly recently (1.66-nightly). Now the feature declaration is not necessary and it shows a warning if it is included (#[warn(stable_features)]).

Will be fixed by #9480

bors bot added a commit that referenced this issue Dec 9, 2022
8544: TY: Support type inference for GATs r=vlad20012 a=mchernyavsky

Relates to #6633.

Depends on #8542.

changelog: Provide initial type inference support for [GATs](https://blog.rust-lang.org/2022/10/28/gats-stabilization.html)


Co-authored-by: Mikhail Chernyavsky <mikhail.chernyavsky@jetbrains.com>
Co-authored-by: vlad20012 <beskvlad@gmail.com>
@YaxinCheng
Copy link

Associated type with where clause is not supported yet. See screenshots:
Screenshot 2023-01-24 at 11 57 31 PM
Screenshot 2023-01-24 at 11 57 44 PM

Code to reproduce:

use std::borrow::Cow;

trait LendingIterator {
    type Item<'me> where Self: 'me;
    fn next(&mut self) -> Option<Self::Item<'_>>;
}

struct Impl<F>(F);

impl <F> LendingIterator for Impl<F>
where F: Fn(&[u8]) -> Option<Cow<'_, str>> {
    type Item<'me> = Option<Cow<'me, str>> where F: 'me;

    fn next(&mut self) -> Option<Self::Item<'_>> {
        let test_bytes = &[0_u8; 8];
        Some((self.0)(test_bytes))
    }
}

Plugin version: 0.4.186.5143-223
Rustc version: rustc 1.66.0 (69f9c33d7 2022-12-12)

@vlad20012
Copy link
Member

@YaxinCheng it will be fixed by #8826

@mchernyavsky
Copy link
Member

Closed in favor of #10187.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature rust Issues about new language features
Projects
None yet
Development

No branches or pull requests

7 participants