Skip to content

rust: module.rs: Replace unwrap() with expect() #142

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

Merged
merged 2 commits into from
Apr 5, 2021

Conversation

Sylfrena
Copy link

Use expect() instead of unwrap() to add more details
about the error in case of a panic.

Fixes #90.

Signed-off-by: Sumera Priyadarsini [email protected]

@Sylfrena Sylfrena marked this pull request as ready for review March 23, 2021 19:21
Copy link
Member

@ojeda ojeda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

@Sylfrena Sylfrena marked this pull request as draft March 29, 2021 09:46
@Sylfrena Sylfrena marked this pull request as ready for review March 29, 2021 10:10
@Sylfrena Sylfrena requested a review from ojeda March 29, 2021 10:10
rust/module.rs Outdated
@@ -673,5 +677,5 @@ pub fn module(ts: TokenStream) -> TokenStream {
params_modinfo = params_modinfo,
generated_array_types = generated_array_types,
initcall_section = ".initcall6.init"
).parse().unwrap()
).parse().expect("LexError returned whle trying to parse the string token stream.")
Copy link
Member

@ojeda ojeda Mar 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo:

Suggested change
).parse().expect("LexError returned whle trying to parse the string token stream.")
).parse().expect("LexError returned while trying to parse the string token stream")

Also, perhaps we can just say:

Error parsing formatted string into token stream

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I made the changes.

@Sylfrena Sylfrena marked this pull request as draft April 4, 2021 13:22
Sylfrena added 2 commits April 4, 2021 19:56
Use expect() instead of unwrap() to add more details
about the error in case of a panic.

Fixes torvalds#90.

Signed-off-by: Sumera Priyadarsini <[email protected]>
@Sylfrena Sylfrena marked this pull request as ready for review April 4, 2021 15:16
Copy link

@jabedude jabedude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ojeda ojeda merged commit b6163f9 into Rust-for-Linux:rust Apr 5, 2021
@ojeda
Copy link
Member

ojeda commented Apr 5, 2021

Thanks a lot! :-)

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

Successfully merging this pull request may close these issues.

Change unwrap()s to expect()s in module.rs
3 participants