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

HasSource::source should be infallible #15088

Closed
Veykril opened this issue Jun 19, 2023 · 4 comments · Fixed by #15140
Closed

HasSource::source should be infallible #15088

Veykril opened this issue Jun 19, 2023 · 4 comments · Fixed by #15140
Labels
C-enhancement Category: enhancement E-easy

Comments

@Veykril
Copy link
Member

Veykril commented Jun 19, 2023

None of the implementations ever return None, so it should not return an option either. https://github.com/veykril/rust-analyzer/blob/9476fdaaa96323800b43c528e59617b14908d6a2/crates/hir/src/has_source.rs#L23

@Veykril Veykril added E-easy C-enhancement Category: enhancement labels Jun 19, 2023
@Veykril
Copy link
Member Author

Veykril commented Jun 19, 2023

A lot of TryToNav impls can probably move over to the infallible ToNav version as well as a follow up

@tetsuharuohzeki
Copy link
Contributor

I would like to take this.

However, HasSource::source has been changed to return Option once in #6913.
Was the motivation in #6913 outdated?

@Veykril
Copy link
Member Author

Veykril commented Jun 26, 2023

Oh, I forgot about that. Hmm having it return an Option does make sense then given we might want to support rlibs someday. We should at least have a comment on the trait then describing this design.

@tetsuharuohzeki
Copy link
Contributor

@Veykril I open #15140 to add why we use Option for HasSource::source

@bors bors closed this as completed in 8769cd2 Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: enhancement E-easy
Projects
None yet
2 participants