godot-rust / gdext

Rust bindings for Godot 4
https://mastodon.gamedev.place/@GodotRust
Mozilla Public License 2.0
2.99k stars 187 forks source link

Ambiguous method call in `#[godot_api]` generated code #858

Open vby opened 1 month ago

vby commented 1 month ago

[edit bromeon: Rust codetags]

Here is a minimal reproducible code:

#[derive(GodotClass)]
#[class(base=Sprite2D)]
pub struct Player {
    base: Base<Sprite2D>,
}

#[godot_api]
impl ISprite2D for Player {
    fn init(base: Base<Sprite2D>) -> Self {
        Self { base }
    }

    fn process(&mut self, delta: f64) {}
}

trait TraitA {
    fn process(&mut self, delta: f64);
}

impl TraitA for Player {
    fn process(&mut self, delta: f64) {}
}
error[E0034]: multiple applicable items in scope
  --> src/player.rs:17:8
   |
17 |     fn process(&mut self, delta: f64) {}
   |        ^^^^^^^ multiple `process` found
Bromeon commented 1 month ago

Good catch, maybe we should explicitly qualify the code-generated virtual call.

Also, you can use ```rs to add syntax highlighting 🙂