Updated expect messages in library/alloc/src/ffi/c_str.rs to follow the style guide - #159853
Conversation
|
rustbot has assigned @Mark-Simulacrum. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| /// // We are certain that our string doesn't have 0 bytes in the middle, | ||
| /// // so we can .expect() | ||
| /// let c_to_print = CString::new("Hello, world!").expect("CString::new failed"); | ||
| /// let c_to_print = CString::new("Hello, world!").expect("the provided string should not have a nul byte"); |
There was a problem hiding this comment.
Thinking a bit on these messages that are more documentation facing (so more effort to consider what's the best), "the provided string" language seems to vaguely suggesting a variable, when we're actually using a constant. Perhaps it would be more clear to say like:
"we provided a string without NUL bytes, so CString::new should not fail"
"we provided bytes that are invalid UTF-8, so `into_string` should fail" // (we can also use `expect_err` instead of `.ok().expect`)
"we provided bytes that has one NUL byte exactly at the end, so CString::from_vec_with_nul should not fail"|
Reminder, once the PR becomes ready for a review, use |
|
Since this was reviewed earlier by @fee1-dead, I'll assign them as the reviewer. I hope that isn't an issue. r? @fee1-dead |
|
nice! I don't de jure have the perms to approve something in libcore, but given that this is only a user facing change for docs, should be pretty uncontroversial: @bors r+ rollup |
Updated expect messages for `CString` struct and method documentation Completes a task with rust-lang#159751. Updates the expect messages in `library/alloc/src/ffi/c_str.rs`.
Updated expect messages for `CString` struct and method documentation Completes a task with rust-lang#159751. Updates the expect messages in `library/alloc/src/ffi/c_str.rs`.
Rollup of 20 pull requests Successful merges: - #138618 (Support using const pointers in asm `const` operand) - #157962 (Lower paths to functions in const args as ConstKind::Error) - #158404 (trait_solver: normalize next-gen region constraints) - #158709 (rustdoc: warn on improperly interleaved HTML/MD) - #159720 (document #[global_allocator] constraints) - #159732 (optimization: don't look for diagnostic/canonical items without rustc_attrs enabled) - #159738 (implement `CovariantUnsafeCell`) - #159740 (reuse regular exported_non_generic_symbols logic in Miri) - #159780 (check `extern "custom"` function pointers) - #159786 (rustdoc-js: ignore editor temp files in test folder discovery) - #159819 (std::sync::poison: disable auto_cfg on PoisonError::new) - #155388 (stepping into where-clauses during normalization may be productive) - #155914 (when bailing on ambiguity, don't force other results to ambig) - #159439 (Fix(lib/fs/win): Fall back on Win32 delete for `Dir::remove_file`) - #159676 (Update wasm-component-ld to 0.5.27) - #159730 (allow accessing the contents of UnsafeCell without going through get) - #159809 (Avoid `#[target_features]`) - #159826 (Remove redundant `#[rustc_paren_sugar]` feature gate) - #159853 (Updated expect messages for `CString` struct and method documentation) - #159877 (Revert "Export `derive` at `core::derive` and `std::derive`")
Rollup of 20 pull requests Successful merges: - #138618 (Support using const pointers in asm `const` operand) - #157962 (Lower paths to functions in const args as ConstKind::Error) - #158404 (trait_solver: normalize next-gen region constraints) - #158709 (rustdoc: warn on improperly interleaved HTML/MD) - #159720 (document #[global_allocator] constraints) - #159732 (optimization: don't look for diagnostic/canonical items without rustc_attrs enabled) - #159738 (implement `CovariantUnsafeCell`) - #159740 (reuse regular exported_non_generic_symbols logic in Miri) - #159780 (check `extern "custom"` function pointers) - #159786 (rustdoc-js: ignore editor temp files in test folder discovery) - #159819 (std::sync::poison: disable auto_cfg on PoisonError::new) - #155388 (stepping into where-clauses during normalization may be productive) - #155914 (when bailing on ambiguity, don't force other results to ambig) - #159439 (Fix(lib/fs/win): Fall back on Win32 delete for `Dir::remove_file`) - #159676 (Update wasm-component-ld to 0.5.27) - #159730 (allow accessing the contents of UnsafeCell without going through get) - #159809 (Avoid `#[target_features]`) - #159826 (Remove redundant `#[rustc_paren_sugar]` feature gate) - #159853 (Updated expect messages for `CString` struct and method documentation) - #159877 (Revert "Export `derive` at `core::derive` and `std::derive`")
Updated expect messages for `CString` struct and method documentation Completes a task with rust-lang#159751. Updates the expect messages in `library/alloc/src/ffi/c_str.rs`.
Rollup of 23 pull requests Successful merges: - #159720 (document #[global_allocator] constraints) - #159732 (optimization: don't look for diagnostic/canonical items without rustc_attrs enabled) - #159738 (implement `CovariantUnsafeCell`) - #159740 (reuse regular exported_non_generic_symbols logic in Miri) - #159780 (check `extern "custom"` function pointers) - #159786 (rustdoc-js: ignore editor temp files in test folder discovery) - #159819 (std::sync::poison: disable auto_cfg on PoisonError::new) - #155388 (stepping into where-clauses during normalization may be productive) - #155914 (when bailing on ambiguity, don't force other results to ambig) - #159204 (Add support to caller_location to rustc_public) - #159411 ([rustdoc] Correctly handle output options with --show-coverage) - #159439 (Fix(lib/fs/win): Fall back on Win32 delete for `Dir::remove_file`) - #159676 (Update wasm-component-ld to 0.5.27) - #159730 (allow accessing the contents of UnsafeCell without going through get) - #159809 (Avoid `#[target_features]`) - #159810 (Add tuple never coercion collection regression test) - #159826 (Remove redundant `#[rustc_paren_sugar]` feature gate) - #159853 (Updated expect messages for `CString` struct and method documentation) - #159877 (Revert "Export `derive` at `core::derive` and `std::derive`") - #159878 (bootstrap: Remove obsolete option `build.compiletest-use-stage0-libtest`) - #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) - #159895 (rustc-dev-guide subtree update)
Updated expect messages for `CString` struct and method documentation Completes a task with rust-lang#159751. Updates the expect messages in `library/alloc/src/ffi/c_str.rs`.
Rollup of 23 pull requests Successful merges: - #159673 (bootstrap: forward -fdebug-prefix-map when using cc) - #159720 (document #[global_allocator] constraints) - #159732 (optimization: don't look for diagnostic/canonical items without rustc_attrs enabled) - #159738 (implement `CovariantUnsafeCell`) - #159740 (reuse regular exported_non_generic_symbols logic in Miri) - #159780 (check `extern "custom"` function pointers) - #159786 (rustdoc-js: ignore editor temp files in test folder discovery) - #159819 (std::sync::poison: disable auto_cfg on PoisonError::new) - #155388 (stepping into where-clauses during normalization may be productive) - #155914 (when bailing on ambiguity, don't force other results to ambig) - #159204 (Add support to caller_location to rustc_public) - #159411 ([rustdoc] Correctly handle output options with --show-coverage) - #159439 (Fix(lib/fs/win): Fall back on Win32 delete for `Dir::remove_file`) - #159676 (Update wasm-component-ld to 0.5.27) - #159730 (allow accessing the contents of UnsafeCell without going through get) - #159809 (Avoid `#[target_features]`) - #159810 (Add tuple never coercion collection regression test) - #159826 (Remove redundant `#[rustc_paren_sugar]` feature gate) - #159853 (Updated expect messages for `CString` struct and method documentation) - #159878 (bootstrap: Remove obsolete option `build.compiletest-use-stage0-libtest`) - #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) - #159895 (rustc-dev-guide subtree update)
Updated expect messages for `CString` struct and method documentation Completes a task with rust-lang#159751. Updates the expect messages in `library/alloc/src/ffi/c_str.rs`.
Updated expect messages for `CString` struct and method documentation Completes a task with rust-lang#159751. Updates the expect messages in `library/alloc/src/ffi/c_str.rs`.
Updated expect messages for `CString` struct and method documentation Completes a task with rust-lang#159751. Updates the expect messages in `library/alloc/src/ffi/c_str.rs`.
Updated expect messages for `CString` struct and method documentation Completes a task with rust-lang#159751. Updates the expect messages in `library/alloc/src/ffi/c_str.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)
…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 28 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) - #159962 (miri subtree update) - #156570 (tests: extend remap-path-prefix-std to all stdlib rlibs) - #159617 (Fix up `#[linkage]` target checking) - #159633 (Improve workings of attribute suggestions) - #159733 (std: Switch implementations of `thread_local!` for WASI) - #159783 (Check unsafe impls on safe EIIs) - #159810 (Add tuple never coercion collection regression test) - #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) - #159927 (Remove sve2 from the ImpliedFeatures of AArch64 v9a.) - #159936 (Minor `rustc_ast::ast` doc cleanups) - #159945 (Update expect messages in library/core/src/ptr/non_null.rs) - #159950 (Add CFI tests for return types and never type)
…uwer Rollup of 28 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) - #159962 (miri subtree update) - #156570 (tests: extend remap-path-prefix-std to all stdlib rlibs) - #159617 (Fix up `#[linkage]` target checking) - #159633 (Improve workings of attribute suggestions) - #159733 (std: Switch implementations of `thread_local!` for WASI) - #159783 (Check unsafe impls on safe EIIs) - #159810 (Add tuple never coercion collection regression test) - #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) - #159927 (Remove sve2 from the ImpliedFeatures of AArch64 v9a.) - #159936 (Minor `rustc_ast::ast` doc cleanups) - #159945 (Update expect messages in library/core/src/ptr/non_null.rs) - #159950 (Add CFI tests for return types and never type)
…uwer Rollup of 28 pull requests Successful merges: - rust-lang/rust#159638 (bootstrap: Split the `Step` trait into multiple traits) - rust-lang/rust#159774 (rustc_trait_selection: fix trait solver hang caused by degenerate obligations) - rust-lang/rust#159837 (line-tables-only test: check that the line number matches the function name) - rust-lang/rust#159946 (Update Enzyme submodule to imporve llvm-cov) - rust-lang/rust#159962 (miri subtree update) - rust-lang/rust#156570 (tests: extend remap-path-prefix-std to all stdlib rlibs) - rust-lang/rust#159617 (Fix up `#[linkage]` target checking) - rust-lang/rust#159633 (Improve workings of attribute suggestions) - rust-lang/rust#159733 (std: Switch implementations of `thread_local!` for WASI) - rust-lang/rust#159783 (Check unsafe impls on safe EIIs) - rust-lang/rust#159810 (Add tuple never coercion collection regression test) - rust-lang/rust#159826 (Remove redundant `#[rustc_paren_sugar]` feature gate) - rust-lang/rust#159846 (Implement `str::copy_from_str`) - rust-lang/rust#159849 (rustc_parse: Stop returning `Option` from statement parsing) - rust-lang/rust#159853 (Updated expect messages for `CString` struct and method documentation) - rust-lang/rust#159875 (More cleanup in `rustc_attr_parsing`) - rust-lang/rust#159882 (Update expect messages in library/alloc/boxed.rs and library/alloc/string.rs to follow the style guide) - rust-lang/rust#159891 (Split multiline derives into std/rustc macros) - rust-lang/rust#159893 (Fix `find_attr` hygiene and `rustc_hir` cleanups) - rust-lang/rust#159895 (rustc-dev-guide subtree update) - rust-lang/rust#159902 (Clarify that the expected runtime symbols signature is for the current target only) - rust-lang/rust#159914 (Fix error in diagnostic on_unmatched_args) - rust-lang/rust#159917 (spare capacity mut constification) - rust-lang/rust#159918 (rename abort_unwind → abort_on_unwind) - rust-lang/rust#159927 (Remove sve2 from the ImpliedFeatures of AArch64 v9a.) - rust-lang/rust#159936 (Minor `rustc_ast::ast` doc cleanups) - rust-lang/rust#159945 (Update expect messages in library/core/src/ptr/non_null.rs) - rust-lang/rust#159950 (Add CFI tests for return types and never type)
CString struct and method documentation|
@fee1-dead could you link this PR on the checkbox for |
…uwer Rollup of 28 pull requests Successful merges: - rust-lang/rust#159638 (bootstrap: Split the `Step` trait into multiple traits) - rust-lang/rust#159774 (rustc_trait_selection: fix trait solver hang caused by degenerate obligations) - rust-lang/rust#159837 (line-tables-only test: check that the line number matches the function name) - rust-lang/rust#159946 (Update Enzyme submodule to imporve llvm-cov) - rust-lang/rust#159962 (miri subtree update) - rust-lang/rust#156570 (tests: extend remap-path-prefix-std to all stdlib rlibs) - rust-lang/rust#159617 (Fix up `#[linkage]` target checking) - rust-lang/rust#159633 (Improve workings of attribute suggestions) - rust-lang/rust#159733 (std: Switch implementations of `thread_local!` for WASI) - rust-lang/rust#159783 (Check unsafe impls on safe EIIs) - rust-lang/rust#159810 (Add tuple never coercion collection regression test) - rust-lang/rust#159826 (Remove redundant `#[rustc_paren_sugar]` feature gate) - rust-lang/rust#159846 (Implement `str::copy_from_str`) - rust-lang/rust#159849 (rustc_parse: Stop returning `Option` from statement parsing) - rust-lang/rust#159853 (Updated expect messages for `CString` struct and method documentation) - rust-lang/rust#159875 (More cleanup in `rustc_attr_parsing`) - rust-lang/rust#159882 (Update expect messages in library/alloc/boxed.rs and library/alloc/string.rs to follow the style guide) - rust-lang/rust#159891 (Split multiline derives into std/rustc macros) - rust-lang/rust#159893 (Fix `find_attr` hygiene and `rustc_hir` cleanups) - rust-lang/rust#159895 (rustc-dev-guide subtree update) - rust-lang/rust#159902 (Clarify that the expected runtime symbols signature is for the current target only) - rust-lang/rust#159914 (Fix error in diagnostic on_unmatched_args) - rust-lang/rust#159917 (spare capacity mut constification) - rust-lang/rust#159918 (rename abort_unwind → abort_on_unwind) - rust-lang/rust#159927 (Remove sve2 from the ImpliedFeatures of AArch64 v9a.) - rust-lang/rust#159936 (Minor `rustc_ast::ast` doc cleanups) - rust-lang/rust#159945 (Update expect messages in library/core/src/ptr/non_null.rs) - rust-lang/rust#159950 (Add CFI tests for return types and never type)
Completes a task with #159751. Updates the expect messages in
library/alloc/src/ffi/c_str.rs.