-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
Linter fixes #27
Linter fixes #27
Changes from 3 commits
8400d95
5dd510f
880b01b
f896030
e156005
ddb6f06
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,6 +102,7 @@ impl string_result_t { | |
pub fn success(data: impl ToString) -> string_result_t { | ||
let (code, details) = match CString::new(data.to_string()) { | ||
Ok(s) => (error_t::success, result_details_t { data: s.into_raw() }), | ||
#[allow(clippy::needless_borrow)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why just not remove the borrow here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's because the CString NulError is of a different type, and there was some case where Clippy couldn't make sense of things. Works: #[allow(clippy::needless_borrow)]
Err(err) => (error_t::invalid_result_data, (&err).into()), Does not work: Err(err) => (error_t::invalid_result_data, err.into()), Why:
However, doing the CString conversion manually works: Err(err) => (error_t::invalid_result_data, result_details_t {
data: CString::new(err.to_string())
.expect("Null byte in string_result_t success code doc comments")
.into_raw(),
}), This was referencing the code in the But that's less-than-ideal, since it's essentially identical code to the From implementation, duplicated over. It's not so simple to implement the error type for CStrings. Anyway, I've pushed that code, let me know if you have a better approach. |
||
Err(err) => (error_t::invalid_result_data, (&err).into()), | ||
}; | ||
string_result_t { code, details } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[toolchain] | ||
channel = "nightly" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hm, not sure we want to default to the nightly channel There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just noticed, as I tried setting this back to stable, it caused the issue I mentioned I had fixed by reverting to the old code mentioend in the comment here: I'm not sure we can get this to pass clippy lints on stable at this time without also making breaking changes to dependents. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems that we can again move to stable with the latest 0.59 release There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's true, how convenient :) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
// Coding conventions | ||
#![recursion_limit = "256"] | ||
#![deny(dead_code, /* missing_docs, */ warnings)] | ||
#![allow(clippy::init_numbered_fields)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably this will go away after resolving LNP-BP/client_side_validation#54 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you pls check that we still need this with the latest 0.59 stable release? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
#[macro_use] | ||
extern crate amplify; | ||
|
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.
I do not entirely get why do we need this. Is it something suggested by the linter?
This is a breaking change which will stop downstream projects from compiling, and will require a major release. Are we really that much needing it?
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.
It was originally suggested by the linter, but if that was a breaking put it back. It's basically caused by the error I mentioned and documented here:
LNP-BP/client_side_validation#54
But also, it's weird, once I put it back, the error is gone, which may also invalidate that issue. Good catch, either way, thank you. I wouldn't want to introduce bad code, nor would I want to waste your time.