rust/src/tools
bors 63d16b5a98 Auto merge of #117472 - jmillikin:stable-c-str-literals, r=Nilstrieb
Stabilize C string literals

RFC: https://rust-lang.github.io/rfcs/3348-c-str-literal.html

Tracking issue: https://github.com/rust-lang/rust/issues/105723

Documentation PR (reference manual): https://github.com/rust-lang/reference/pull/1423

# Stabilization report

Stabilizes C string and raw C string literals (`c"..."` and `cr#"..."#`), which are expressions of type [`&CStr`](https://doc.rust-lang.org/stable/core/ffi/struct.CStr.html). Both new literals require Rust edition 2021 or later.

```rust
const HELLO: &core::ffi::CStr = c"Hello, world!";
```

C strings may contain any byte other than `NUL` (`b'\x00'`), and their in-memory representation is guaranteed to end with `NUL`.

## Implementation

Originally implemented by PR https://github.com/rust-lang/rust/pull/108801, which was reverted due to unintentional changes to lexer behavior in Rust editions < 2021.

The current implementation landed in PR https://github.com/rust-lang/rust/pull/113476, which restricts C string literals to Rust edition >= 2021.

## Resolutions to open questions from the RFC

* Adding C character literals (`c'.'`) of type `c_char` is not part of this feature.
  * Support for `c"..."` literals does not prevent `c'.'` literals from being added in the future.
* C string literals should not be blocked on making `&CStr` a thin pointer.
  * It's possible to declare constant expressions of type `&'static CStr` in stable Rust (as of v1.59), so C string literals are not adding additional coupling on the internal representation of `CStr`.
* The unstable `concat_bytes!` macro should not accept `c"..."` literals.
  * C strings have two equally valid `&[u8]` representations (with or without terminal `NUL`), so allowing them to be used in `concat_bytes!` would be ambiguous.
* Adding a type to represent C strings containing valid UTF-8 is not part of this feature.
  * Support for a hypothetical `&Utf8CStr` may be explored in the future, should such a type be added to Rust.
2023-12-01 13:33:55 +00:00
..
build-manifest Remove now deprecated target x86_64-sun-solaris. 2023-11-20 15:15:47 +01:00
build_helper rename github_repository to git_repository 2023-11-06 15:53:32 +01:00
bump-stage0 Upgrade to indexmap 2.0.0 2023-07-03 13:51:54 -07:00
cargo@26333c7320 Update cargo 2023-11-28 16:20:25 -05:00
cargotest
clippy Auto merge of #117472 - jmillikin:stable-c-str-literals, r=Nilstrieb 2023-12-01 13:33:55 +00:00
collect-license-metadata Re-format let-else per rustfmt update 2023-07-12 21:49:27 -04:00
compiletest Auto merge of #118036 - DianQK:thinlto-tests, r=tmiasko 2023-11-30 13:33:32 +00:00
coverage-dump Add tool src/tools/coverage-dump for use by some new coverage tests 2023-09-05 11:11:48 +10:00
error_index_generator rustc_log: provide a way to init logging based on the values, not names, of the env vars 2023-11-11 15:24:33 +01:00
expand-yaml-anchors
generate-copyright
generate-windows-sys Update windows-bindgen 2023-11-17 12:18:04 +00:00
html-checker
jsondocck jsondocck: bump jsonpath to 0.3, dropping few dup dependencies 2023-11-18 12:56:54 +03:00
jsondoclint rustdoc: Rename typedef to type alias in jsondoclint 2023-08-23 11:47:35 -07:00
linkchecker linkchecker: Remove unneeded FIXME about intra-doc links 2023-08-06 13:28:43 +02:00
lint-docs Revert "Fix x test lint-docs when download-rustc is enabled" 2023-07-11 22:30:28 -05:00
lld-wrapper linker: Remove -Zgcc-ld option 2023-10-08 10:05:25 +03:00
miri Auto merge of #118408 - RalfJung:aggregate-assign-uninit, r=saethlin 2023-11-30 07:49:49 +00:00
miropt-test-tools Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
opt-dist Partial Revert: "Auto merge of #117018 - Kobzol:opt-dist-cargo-stage0" 2023-10-23 16:10:52 +02:00
remote-test-client
remote-test-server
replace-version-placeholder Only depend on CFG_VERSION in rustc_interface 2023-05-17 23:54:21 -05:00
rls Don't use serde-derive in the rls shim 2023-07-10 14:53:57 -07:00
rust-analyzer Merge commit '237712fa31' into sync-from-ra 2023-11-27 12:40:39 +02:00
rust-demangler
rust-installer bump some deps 2023-11-07 15:33:59 +03:00
rustbook
rustdoc
rustdoc-gui Improve display of parallel jobs in rustdoc-gui tester script 2023-10-16 20:16:08 +02:00
rustdoc-gui-test Make try_run return a Result<(), ()> instead of a boolean 2023-06-23 17:07:34 +02:00
rustdoc-js rustdoc-search: add support for associated types 2023-11-19 18:54:36 -07:00
rustdoc-themes Ensure build/tmp exists in rustdoc_themes::get_themes 2023-09-20 08:31:33 +02:00
rustfmt Rollup merge of #118157 - Nadrieril:never_pat-feature-gate, r=compiler-errors 2023-11-29 12:34:47 +01:00
suggest-tests Add test suggestions for mir-opt and coverage 2023-11-16 14:02:51 +11:00
tidy Remove instant from EXCEPTIONS_RUST_ANALYZER 2023-11-27 12:54:24 +02:00
tier-check
unicode-table-generator
unstable-book-gen
x Add other workspaces to linkedProjects in rust_analyzer_settings.json 2023-05-26 12:08:58 -05:00
cherry-pick.sh
publish_toolstate.py Apply changes to fix python linting errors 2023-06-16 20:56:01 -04:00