Skip to content

Conversation

@rarensu
Copy link
Contributor

@rarensu rarensu commented Sep 15, 2025

Improved documentation for many items. Update: removed unused Result type. Update: properly using the Result type, where appropriate, while avoiding some avoidable panics.

Previous PR in sequence was #400
Next PR in sequence was #402

An additional PR #405 branches from this point.

@cberner cberner force-pushed the format-fix-document-etc-07/15 branch from 14fbf5d to b912763 Compare September 15, 2025 03:39
Copy link
Owner

@cberner cberner left a comment

Choose a reason for hiding this comment

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

Had a minor comment about non-errors which I don't think we should document. If it doesn't make sense for a function to return an error, we should change the signature instead

@rarensu rarensu force-pushed the format-fix-document-etc-07/15 branch 3 times, most recently from bbbe3cd to 91f844f Compare September 15, 2025 15:40
@rarensu
Copy link
Contributor Author

rarensu commented Sep 15, 2025

I removed the redundant "does not error" documentation. Instead, I propose a commit in which we remove the unused Result type.

Update: Sorry about the repeated pushing. Cargo fmt was being picky and rebasing is tricky sometimes.

@rarensu rarensu force-pushed the format-fix-document-etc-07/15 branch from 91f844f to d89c8cb Compare September 15, 2025 15:42
@rarensu rarensu requested a review from cberner September 15, 2025 15:51
@rarensu
Copy link
Contributor Author

rarensu commented Sep 16, 2025

@cberner
About returning a meaningful error in BackgroundSession::new(). Since the error type has to match the error type of the mount/spawn functions I had to convert from poison error to io error. It's not great, but it's better than having a # Panic section. Sadly, this addition triggered cargo fmt to insist on breaking up the method chain.

About the unmount functions. Claude suggested that it makes sense to handle the error, rather than return it, for the unmount case. Just because another thread panicked, doesn't mean that an unmount is unsafe or impossible. In fact, probably, the mount data is just fine and we can still do the unmount. No panics, no errors, it just does what it does.

@rarensu rarensu force-pushed the format-fix-document-etc-07/15 branch from d89c8cb to b496085 Compare September 16, 2025 16:41
@cberner
Copy link
Owner

cberner commented Sep 17, 2025

Hmm, I'll need to look at that change some more. Can you split the panic changes into a separate PR? Let's make this one only about the doc changes

@rarensu rarensu force-pushed the format-fix-document-etc-07/15 branch from 64d9786 to b6602ec Compare September 17, 2025 16:24
src/session.rs Outdated
Comment on lines 278 to 279
/// # Panics
/// Panics if the background thread can't be recovered.
Copy link
Owner

Choose a reason for hiding this comment

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

Let's remove this. It's an implementation detail

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Clippy says if the function can panic, it should have documentation about that. Are you saying that we should pretend that the function cannot panic?

Copy link
Owner

Choose a reason for hiding this comment

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

I think we should only document things that are part of the public API, rather than implementation details. That is they're not going to change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed most of them, but I didn't remove this one. Joining a background thread can panic, and sometimes should, panic. For example,

  • A panic in the session thread would propagate to the main thread on join().
  • A deadlocked session thread may or may not cause a panic on join(), depending on the OS.

These are both just a normal part of joining a background thread. The underlying call to thread::join() even has its own # Panic documentation. It would be disingenuous to imply that our function is somehow free from panics.

I did improve the # Panic section by clarifying an example.

src/notify.rs Outdated
/// inotify watchers of a file deletion.
/// # Errors
/// Returns an error if the notification data is too large.
/// Propagates errors due to communicating with the fuse device.
Copy link
Owner

Choose a reason for hiding this comment

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

Propagates errors due to communicating with the fuse device.

Let's remove this in all the messages. I don't think it adds useful information. Returning an io::Result already explains that it propagates errors

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess that is a fair criticism.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted all of the unnecessary ones, but I did need to write something for the notify functions, so I revised the statement to clarify that it's the kernel causing the errors.

Clippy says that functions with the potential to error or panic should be labeled by a markdown section `#` in the doc string. [missing_errors_doc](https://rust-lang.github.io/rust-clippy/rust-1.51.0/index.html#missing_errors_doc)
I've done my best to write some kind of reasonable statements; there is room for improvement.
Repaired incorrect doc strings which were likely the result of copy and paste errors.
@rarensu rarensu force-pushed the format-fix-document-etc-07/15 branch from b6602ec to 09ac510 Compare September 19, 2025 15:54
@rarensu rarensu mentioned this pull request Sep 19, 2025
@cberner cberner merged commit 36862fc into cberner:master Sep 20, 2025
9 checks passed
@cberner
Copy link
Owner

cberner commented Sep 20, 2025

Merged. Thanks for iterating on this. lgtm!

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