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

impl ... for ... doesn't generate code #1894

Open
NobodyForNothing opened this issue Apr 21, 2024 · 2 comments · Fixed by #1895
Open

impl ... for ... doesn't generate code #1894

NobodyForNothing opened this issue Apr 21, 2024 · 2 comments · Fixed by #1895
Labels
awaiting Waiting for responses, PR, further discussions, upstream release, etc bug Something isn't working

Comments

@NobodyForNothing
Copy link

NobodyForNothing commented Apr 21, 2024

Describe the bug

Implementing a public trait (tested with Default) for a rust struct doesn't generate corresponding dart code.

Steps to reproduce

  1. In the default template change the simple file to:
pub struct A {
    val: u32
}

impl Default for A {
    fn default() -> Self {
        A {
            val: 0
        }
    }
}

impl A {
    pub fn new() -> Self {
        A {
            val: 0
        }
    }
}
  1. run flutter_rust_bridge_codegen generate && flutter pub get
  2. The generated dart class (file simple.dart) contains the static A.new_instance method but no default method. The new method works as expected

Logs

https://pastebin.com/irT3KWT0 (github said issue is too long)

Expected behavior

I expect the generator to either:

  • Create a static default method in the A dart class (prefered)
  • Create a default function
  • Create some other class/mixin with a default function

Generated binding code

No response

OS

Arch Linux

Version of flutter_rust_bridge_codegen

No response

Flutter info

~/Coding/Flutter/derdilla-desktop/apps/calculator git:[main]
flutter doctor -v
[✓] Flutter (Channel beta, 3.22.0-0.2.pre, on Garuda Linux 6.8.7-AMD-znver3, locale en_US.UTF-8)
    • Flutter version 3.22.0-0.2.pre on channel beta at /home/derdilla/bin/apps/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 312b9e81e9 (2 days ago), 2024-04-18 20:57:54 -0700
    • Engine revision a86e74cf06
    • Dart version 3.4.0 (build 3.4.0-282.2.beta)
    • DevTools version 2.34.2

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0-rc3)
    • Android SDK at /home/derdilla/Android/Sdk
    • Platform android-34, build-tools 34.0.0-rc3
    • Java binary at: /home/derdilla/.local/share/JetBrains/Toolbox/apps/android-studio/jbr/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
    • All Android licenses accepted.

[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Linux toolchain - develop for Linux desktop
    • clang version 17.0.6
    • cmake version 3.29.2
    • ninja version 1.11.1
    • pkg-config version 2.1.1

[✓] Android Studio (version 2023.1)
    • Android Studio at /home/derdilla/bin/apps/android-studio
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)

[✓] Android Studio (version 2023.2)
    • Android Studio at /home/derdilla/.local/share/JetBrains/Toolbox/apps/android-studio
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)

[✓] IntelliJ IDEA Ultimate Edition (version 2024.1)
    • IntelliJ at /home/derdilla/.local/share/JetBrains/Toolbox/apps/intellij-idea-ultimate
    • Flutter plugin version 79.0.3
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] Connected device (1 available)
    • Linux (desktop) • linux • linux-x64 • Garuda Linux 6.8.7-AMD-znver3

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

Version of clang++

17.0.6 (clang --version)

Additional context

No response

@NobodyForNothing NobodyForNothing added the bug Something isn't working label Apr 21, 2024
Copy link

welcome bot commented Apr 21, 2024

Hi! Thanks for opening your first issue here! 😄

@fzyzcjy fzyzcjy changed the title impl ... for doesn't generate code impl ... for ... doesn't generate code Apr 21, 2024
@fzyzcjy fzyzcjy added awaiting Waiting for responses, PR, further discussions, upstream release, etc and removed awaiting Waiting for responses, PR, further discussions, upstream release, etc labels Apr 21, 2024
@fzyzcjy
Copy link
Owner

fzyzcjy commented Apr 21, 2024

Hi, yes this is not scanned currently, but it may not be hard to implement it (since impl Sth for A is surely almost identical to impl A). Feel free to PR for it, alternatively I may work on it in the next batch!

@fzyzcjy fzyzcjy added the awaiting Waiting for responses, PR, further discussions, upstream release, etc label Apr 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting Waiting for responses, PR, further discussions, upstream release, etc bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants