-
Notifications
You must be signed in to change notification settings - Fork 71
Clippy related fixes #469
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
Clippy related fixes #469
Conversation
1. Fix Pattern Type Mismatch by Adding deref's 2. Move commented `else if` to previous block in `intrinsic.rs`
1. Use `clone_from` in place of `clone()` in `builder.rs` 2. Change `&name` to `name.clone()` in `debuginfo.rs`(Is this really efficient? But I can't find other workarounds.)
cmd: `cargo clippy --fix --lib -p rustc_codegen_gcc --allow-dirtyxs`
This looks like an (inverted) exclusive-or but I still leave it as it is in clippy.
Changed for clippy naming convention requirement: ``` warning: methods called `from_*` usually take no `self` --> src/int.rs:996:22 | 996 | fn from_low_high(&self, typ: Type<'gcc>, low: i64, high: i64) -> RValue<'gcc> { | ^^^^^ | = help: consider choosing a less ambiguous name = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#wrong_self_convention = note: `#[warn(clippy::wrong_self_convention)]` on by default ```
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.
Thanks! The clone()
should not be necessary.
src/builder.rs
Outdated
bx: &mut Builder<'a, 'gcc, 'tcx>, | ||
rvalue: RValue<'gcc>, | ||
) -> RValue<'gcc> { | ||
fn set_rvalue_location<'gcc>(bx: &mut Builder<'_, 'gcc, '_>, rvalue: RValue<'gcc>) -> RValue<'gcc> { |
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.
Not sure I like this change (since I fear this might make the lifetime error messages harder to understand), but I'm not sure if there's a way to disable this lint in a way that clippy will still warn about lifetimes that could be removed on simple references.
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.
Opened an issue.
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.
Currently we should simply close the lint, I guess.
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 will revert the whole tempdragon@ad97b8c.
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.
Reverted in tempdragon/rustc_codegen_gcc@390f906, adding #![allow(clippy::needless_lifetimes)]
to allow this in clippy.
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 seems this specific function (at least) was not reverted.
src/intrinsic/mod.rs
Outdated
/*else if use_integer_compare { | ||
let integer_ty = self.type_ix(layout.size.bits()); // FIXME(antoyo): LLVM creates an integer of 96 bits for [i32; 3], but gcc doesn't support this, so it creates an integer of 128 bits. | ||
let ptr_ty = self.type_ptr_to(integer_ty); | ||
let a_ptr = self.bitcast(a, ptr_ty); | ||
let a_val = self.load(integer_ty, a_ptr, layout.align.abi); | ||
let b_ptr = self.bitcast(b, ptr_ty); | ||
let b_val = self.load(integer_ty, b_ptr, layout.align.abi); | ||
self.icmp(IntPredicate::IntEQ, a_val, b_val) | ||
}*/ | ||
} else { |
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 believe this is not correct. Please revert to the original code, but put the else
on the same line as the end of the comment, like this:
}*/ else {
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.
Sadly, the rustfmt
doesn't seem to allow this.
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 automatically inserts a newline and then cause the following warning:
warning: this is an `else {..}` but the formatting might hide it
--> src/intrinsic/mod.rs:311:18
|
311 | ... }
| ________^
312 | | ... /*else if use_integer_compare {
313 | | ... let integer_ty = self.type_ix(layout.size.bits()); // FIXME(antoyo): LLVM creates...
314 | | ... let ptr_ty = self.type_ptr_to(integer_ty);
... |
320 | | ... }*/
321 | | ... else {
| |___________^
|
= note: to remove this lint, remove the `else` or remove the new line between `else` and `{..}`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_else_formatting
= note: `#[warn(clippy::suspicious_else_formatting)]` on by default
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 don't currently know if there is a way that fits both your requirements and rustfmt and clippy.
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.
Should I try to have clippy ignore this or should I handle this in other ways?
Also, if you want, please add |
Added in 4e4efb9 |
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.
This is good to me.
@tempdragon: Please tell me if you wanted to do any other changes or if I can merge this PR.
Look good to me. Thanks for your review! |
Thanks for your contribution! |
from_low_high_rvalues
andfrom_low_high
in tempdragon/rustc_codegen_gcc@a7d39b8cargo clippy --fix --lib -p rustc_codegen_gcc --allow-dirtyxs
, as is done in tempdragon/rustc_codegen_gcc@ad97b8c. However, since I am not an expert in lifetime, I can't guarantee its correctness(But it passed the workflow anyway.)shift
was removed for use ofi
, but theshift
variable still looks weird here.clone()
to solvepattern_type_mismatch
lint in tempdragon/rustc_codegen_gcc@8d4d878, but it looks less efficient. I should apologize because I do doubt if there is a better way to fix this here.Probably gonna solve #457.