Update expect message using the recommended style in binary_heap module#159821
Update expect message using the recommended style in binary_heap module#159821SzilvasiPeter wants to merge 2 commits into
Conversation
|
Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @Darksonn (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
Why was this reviewer chosen?The reviewer was selected based on:
|
|
@Colepng this is related to the file you claimed, sorry for not grouping them together clearly. We will need to use a consistent message across those files |
|
Okay I will use the one from this pr. |
Update expect message using the recommended style in binary_heap module Related issue: rust-lang#159751
Update expect message using the recommended style in binary_heap module Related issue: rust-lang#159751
…uwer Rollup of 24 pull requests Successful merges: - #159638 (bootstrap: Split the `Step` trait into multiple traits) - #159774 (rustc_trait_selection: fix trait solver hang caused by degenerate obligations) - #159837 (line-tables-only test: check that the line number matches the function name) - #159946 (Update Enzyme submodule to imporve llvm-cov) - #159617 (Fix up `#[linkage]` target checking) - #159733 (std: Switch implementations of `thread_local!` for WASI) - #159783 (Check unsafe impls on safe EIIs) - #159810 (Add tuple never coercion collection regression test) - #159821 (Update expect message using the recommended style in binary_heap module) - #159826 (Remove redundant `#[rustc_paren_sugar]` feature gate) - #159846 (Implement `str::copy_from_str`) - #159849 (rustc_parse: Stop returning `Option` from statement parsing) - #159853 (Updated expect messages for `CString` struct and method documentation) - #159875 (More cleanup in `rustc_attr_parsing`) - #159882 (Update expect messages in library/alloc/boxed.rs and library/alloc/string.rs to follow the style guide) - #159891 (Split multiline derives into std/rustc macros) - #159893 (Fix `find_attr` hygiene and `rustc_hir` cleanups) - #159895 (rustc-dev-guide subtree update) - #159902 (Clarify that the expected runtime symbols signature is for the current target only) - #159914 (Fix error in diagnostic on_unmatched_args) - #159917 (spare capacity mut constification) - #159918 (rename abort_unwind → abort_on_unwind) - #159936 (Minor `rustc_ast::ast` doc cleanups) - #159945 (Update expect messages in library/core/src/ptr/non_null.rs)
…uwer Rollup of 24 pull requests Successful merges: - #159638 (bootstrap: Split the `Step` trait into multiple traits) - #159774 (rustc_trait_selection: fix trait solver hang caused by degenerate obligations) - #159837 (line-tables-only test: check that the line number matches the function name) - #159946 (Update Enzyme submodule to imporve llvm-cov) - #159617 (Fix up `#[linkage]` target checking) - #159733 (std: Switch implementations of `thread_local!` for WASI) - #159783 (Check unsafe impls on safe EIIs) - #159810 (Add tuple never coercion collection regression test) - #159821 (Update expect message using the recommended style in binary_heap module) - #159826 (Remove redundant `#[rustc_paren_sugar]` feature gate) - #159846 (Implement `str::copy_from_str`) - #159849 (rustc_parse: Stop returning `Option` from statement parsing) - #159853 (Updated expect messages for `CString` struct and method documentation) - #159875 (More cleanup in `rustc_attr_parsing`) - #159882 (Update expect messages in library/alloc/boxed.rs and library/alloc/string.rs to follow the style guide) - #159891 (Split multiline derives into std/rustc macros) - #159893 (Fix `find_attr` hygiene and `rustc_hir` cleanups) - #159895 (rustc-dev-guide subtree update) - #159902 (Clarify that the expected runtime symbols signature is for the current target only) - #159914 (Fix error in diagnostic on_unmatched_args) - #159917 (spare capacity mut constification) - #159918 (rename abort_unwind → abort_on_unwind) - #159936 (Minor `rustc_ast::ast` doc cleanups) - #159945 (Update expect messages in library/core/src/ptr/non_null.rs)
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This comment has been minimized.
This comment has been minimized.
|
This pull request was unapproved. This PR was contained in a rollup (#159957), which was closed. |
|
@Darksonn I updated the expect message in the |
| #[cfg_attr(not(test), rustc_diagnostic_item = "vecdeque_reserve")] | ||
| pub fn reserve(&mut self, additional: usize) { | ||
| let new_cap = self.len.checked_add(additional).expect("capacity overflow"); | ||
| let new_cap = self.len.checked_add(additional).expect("length should not overflow usize"); |
There was a problem hiding this comment.
This one I don't think we should change. It's an overflow that can actually happen for some user-provided values of additional, so the message shouldn't claim that this will not overflow when it actually can overflow. Instead the message should be tailored to be usefulf for the caller.
There was a problem hiding this comment.
I wonder if we should use let else for some of these with an explicit panic rather than expect, since I would rather not want expect to be used for "regular panic"s that just occur due to bad user input.
There was a problem hiding this comment.
I'm not sure, but that seems like a bigger change than fixing part of #159751
| pub fn append(&mut self, other: &mut Self) { | ||
| if T::IS_ZST { | ||
| self.len = self.len.checked_add(other.len).expect("capacity overflow"); | ||
| self.len = self.len.checked_add(other.len).expect("length should not overflow usize"); |
| #[inline] | ||
| fn index(&self, index: usize) -> &T { | ||
| self.get(index).expect("Out of bounds access") | ||
| self.get(index).expect("index should be within bounds") |
| #[inline] | ||
| fn index_mut(&mut self, index: usize) -> &mut T { | ||
| self.get_mut(index).expect("Out of bounds access") | ||
| self.get_mut(index).expect("index should be within bounds") |
Related issue: #159751