Skip to content

Add a fix that inserts a missing method #19950

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MatrixFrog
Copy link
Contributor

Work in progress! Not ready for review yet.

Often I will call a method even though I know it doesn't exist yet, because I'm planning to add that method.

struct Dog {}

impl Dog {
  bark(&self) {}
}

fn main() {
  let dog = Dog {};
  dog.bark();
  dog.play_dead();  // errors because the method doesn't exist yet
}

This PR adds a fix that inserts a stub for the play_dead method.

  • For now, the receiver type is &self but maybe we can figure out whether it should be self or &mut self instead?
  • Return type is not added but it could be inferred if the calling code looks like let lhs: SomeType = dog.play_dead()
  • Should the method body be todo!() or unimplemented!() or something else? What is the most consistent with how r-a does things elsewhere?
  • Need to do more testing

@ChayimFriedman2
Copy link
Contributor

Should the method body be todo!() or unimplemented!() or something else? What is the most consistent with how r-a does things elsewhere?

There is a config for what to insert in e.g. fill match arms, I think it's appropriate to use it here as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants