Skip to content

nohup: #[allow(clippy::unwrap_used, reason = ...)]#11361

Merged
sylvestre merged 1 commit intouutils:mainfrom
oech3:patch-2
Mar 18, 2026
Merged

nohup: #[allow(clippy::unwrap_used, reason = ...)]#11361
sylvestre merged 1 commit intouutils:mainfrom
oech3:patch-2

Conversation

@oech3
Copy link
Contributor

@oech3 oech3 commented Mar 17, 2026

No description provided.

@oech3 oech3 marked this pull request as ready for review March 17, 2026 10:52
@xtqqczze
Copy link
Contributor

We should use #[expect] for these cases.

@xtqqczze
Copy link
Contributor

In actual fact, why not use .expect instead of .unwrap?

@oech3
Copy link
Contributor Author

oech3 commented Mar 17, 2026

.except increases binary size and this unwrap() is clearly safe...

@xtqqczze
Copy link
Contributor

I see no difference in binary size, I guess uu_app is inlined so the check never happens.

@oech3
Copy link
Contributor Author

oech3 commented Mar 17, 2026

Optimized at compile time?

@xtqqczze
Copy link
Contributor

Optimized at compile time?

Yes, in release build.

@oech3
Copy link
Contributor Author

oech3 commented Mar 17, 2026

cmp said they are different for me.

@xtqqczze
Copy link
Contributor

xtqqczze commented Mar 17, 2026

I checked with:

cargo build -p uu_nohup --release
wc -c <  target/release/nohup

and saw the same size with .unwrap vs .expect

@xtqqczze
Copy link
Contributor

There is no reason not to use .expect.

@oech3
Copy link
Contributor Author

oech3 commented Mar 18, 2026

Binary size increases

@xtqqczze
Copy link
Contributor

I see no difference (for aarch64-apple-darwin)

unwrap:

$ cargo build -p uu_nohup --release
$ wc -c <  target/release/nohup
1134704

expect:

$ cargo build -p uu_nohup --release
$ wc -c <  target/release/nohup
1134704

@oech3
Copy link
Contributor Author

oech3 commented Mar 18, 2026

1212336->1212352 (stripped --release, rustc 1.94.0 (4a4ef493e 2026-03-02) (Arch Linux rust 1:1.94.0-2.1)

@xtqqczze
Copy link
Contributor

That's interesting, I used rustc 1.94.0 (4a4ef493e 2026-03-02) (aarch64-apple-darwin)

+16 bytes is likely just noise though

@sylvestre sylvestre merged commit 85467d8 into uutils:main Mar 18, 2026
160 checks passed
@oech3 oech3 deleted the patch-2 branch March 18, 2026 13:14
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.

3 participants