-
Notifications
You must be signed in to change notification settings - Fork 40
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
Return Result
in accessors instead of panic
#286
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the changes! I just put a few comments. I think it's fine to use the Infallible
type as long as we can remove the glue code in the future version of Rust.
melior/src/error.rs
Outdated
Self::Infallible => { | ||
write!(formatter, "infallible") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we emulate type Infallible = !
as described in the std
library documentation by removing this and panic on conversion?
Self::Infallible => { | |
write!(formatter, "infallible") | |
} |
melior/src/error.rs
Outdated
RunPass, | ||
TypeExpected(&'static str, String), | ||
UnknownDiagnosticSeverity(u32), | ||
Utf8(Utf8Error), | ||
Infallible, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Infallible, |
melior/src/error.rs
Outdated
|
||
impl From<Infallible> for Error { | ||
fn from(_: Infallible) -> Self { | ||
Self::Infallible |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Self::Infallible | |
unreachable!() |
Thank you for the changes again! |
As previously suggested in #274, I replaced the
.expect
with returning aResult
in the operation accessors of ODS generated dialects.I also added some variants to the
Error
enum to support this. TheInfallible
variant was added to allow usingTryInto
to convertAttribute
into itself, such that we avoid needing to handleAttribute
differently fromStringAttribute
,IntAttribute
, etc. But if you prefer, I can change the macro code to deal with this case instead, I'm honestly not a big fan of myInfallible
hack either.