-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Add #[must_use] to from_value conversions #89753
Add #[must_use] to from_value conversions #89753
Conversation
3fe1c3b
to
4967c6a
Compare
This comment has been minimized.
This comment has been minimized.
4967c6a
to
cf2bcd1
Compare
If we find any significant number of crates that are using one of these methods to convert to a type with Drop as a means of freeing it, we should consider reverting the addition of must_use to that method to avoid excessive disruption. Such a code pattern would be unusual but legitimate. We're allowed to add warnings to existing code, but we typically take into account how many warnings we're adding to the ecosystem. |
@bors r+ |
📌 Commit cf2bcd1 has been approved by |
…rsions, r=joshtriplett Add #[must_use] to from_value conversions I added two methods to the list myself. Clippy did not flag them because they take `mut` args, but neither modifies their argument. ```rust core::str const unsafe fn from_utf8_unchecked_mut(v: &mut [u8]) -> &mut str; std::ffi::CString unsafe fn from_raw(ptr: *mut c_char) -> CString; ``` I put a custom note on `from_raw`: ```rust #[must_use = "call `drop(from_raw(ptr))` if you intend to drop the `CString`"] pub unsafe fn from_raw(ptr: *mut c_char) -> CString { ``` Parent issue: rust-lang#89692 r? `@joshtriplett`
…laumeGomez Rollup of 7 pull requests Successful merges: - rust-lang#89655 (bootstrap: don't use `--merges` to look for commit hashes for downloading artifacts) - rust-lang#89726 (Add #[must_use] to alloc constructors) - rust-lang#89729 (Add #[must_use] to core and std constructors) - rust-lang#89743 (Fix RUSTC_LOG handling) - rust-lang#89753 (Add #[must_use] to from_value conversions) - rust-lang#89754 (Cleanup .item-table CSS) - rust-lang#89761 (:arrow_up: rust-analyzer) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Is there any particular reason why this was added to |
@BurntSushi No, I don't believe so. I don't remember excluding it. I'm guessing I simply didn't catch |
I added two methods to the list myself. Clippy did not flag them because they take
mut
args, but neither modifies their argument.I put a custom note on
from_raw
:Parent issue: #89692
r? @joshtriplett