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

Apply some of the cargo clippy suggestions #649

Merged
merged 1 commit into from
Sep 8, 2024

Conversation

nyurik
Copy link
Contributor

@nyurik nyurik commented Aug 2, 2024

As @workingjubilee mentioned, no one is really paying for professional maintenance of backtrace-rs, so might as well try to do some volunteer upkeep. Just to keep things tidy.

Note that the code does not seem to have had cargo fmt run in a while, but I don't want to do it as part of code-changing PR.

The enum backtrace::print::PrintFmt {} seem to be requiring #[non_exhaustive], but that may result in some breaking changes? Not certain how this should be handled, and probably in a separate PR.

@nyurik nyurik force-pushed the linting branch 2 times, most recently from 77ab8ac to 0e4e715 Compare August 2, 2024 22:18
build.rs Outdated Show resolved Hide resolved
Copy link
Member

@workingjubilee workingjubilee left a comment

Choose a reason for hiding this comment

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

...huh, I seem to be having trouble finding which tests actually would break here if the refactoring here was wrong...

src/symbolize/mod.rs Outdated Show resolved Hide resolved
src/symbolize/gimli/elf.rs Outdated Show resolved Hide resolved
@@ -21,7 +21,7 @@ impl Mapping {
pub fn new(path: &Path) -> Option<Mapping> {
let map = super::mmap(path)?;
Mapping::mk_or_other(map, |map, stash| {
let object = Object::parse(&map)?;
let object = Object::parse(map)?;
Copy link
Member

Choose a reason for hiding this comment

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

mk_or_other is such a weird function...

Comment on lines 126 to 131
if let Some(name) = id.xcoff_name() {
let data = object.section(stash, name).unwrap_or(&[]);
Ok(EndianSlice::new(data, Endian))
} else {
Ok(EndianSlice::new(&[], Endian))
}
Copy link
Member

Choose a reason for hiding this comment

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

I would somewhat prefer this stay as-is because "all the AIX code in this fn is at its own indentation" is on-purpose. I didn't specifically say so it was when I accepted this code, but I picked the "rightward drift" and other stylistic nits several times and this was not an oversight.

If you would prefer refactoring this in a different way that appeases the lint and keeps the current visible divide between "AIX" and "everyone else" then that's fine too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, fixed it with two sections - clear separation, plus IDE highlights which one is active

src/types.rs Show resolved Hide resolved
build.rs Outdated Show resolved Hide resolved
src/capture.rs Outdated Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
src/print.rs Show resolved Hide resolved
@nyurik
Copy link
Contributor Author

nyurik commented Aug 2, 2024

thx for the review, will fix it shortly...

@workingjubilee
Copy link
Member

workingjubilee commented Aug 2, 2024

I would not consider changing PrintFmt to use the actual #[non_exhaustive] attribute instead of the "non-exhaustive by convention" to be a breaking change. I would not recommend doing it in this PR however, no.

@nyurik
Copy link
Contributor Author

nyurik commented Aug 3, 2024

Note that asserting stacktrace in the unit test is kinda hacky -- skip_inner_frames is included in non-miri output

# On Linux

   0: skip_inner_frames::backtrace_new_should_start_with_call_site_trace
             at /home/nyurik/dev/rust/backtrace-rs/tests/skip_inner_frames.rs:39:13
   1: skip_inner_frames::backtrace_new_should_start_with_call_site_trace::{{closure}}
             at /home/nyurik/dev/rust/backtrace-rs/tests/skip_inner_frames.rs:35:53
   ...

# MIRI

   0: backtrace_new_should_start_with_call_site_trace
             at tests/skip_inner_frames.rs:39:13
   1: backtrace_new_should_start_with_call_site_trace::{closure#0}
             at tests/skip_inner_frames.rs:35:53
   ...

workingjubilee pushed a commit that referenced this pull request Aug 24, 2024
@workingjubilee
Copy link
Member

The test being hacky is fine, all tests are allowed to be hacky forever and ever as long as the test is correctly testing at least what it is supposed to test. However something merge conflicted with this, sorry about that.

@nyurik
Copy link
Contributor Author

nyurik commented Aug 25, 2024

@workingjubilee fixed

@workingjubilee workingjubilee merged commit 386a42a into rust-lang:master Sep 8, 2024
41 checks passed
@nyurik nyurik deleted the linting branch September 8, 2024 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants