Use raw pointer for NUL-terminated file location with #[track_caller]#142579
Use raw pointer for NUL-terminated file location with #[track_caller]#142579Darksonn wants to merge 2 commits intorust-lang:masterfrom
#[track_caller]#142579Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I don't think that this is really a disadvantage, as the compiler is perfectly able to remove an unnecessary call to |
|
There is still a plan to make |
|
We discussed this in the libs-api meeting. There wasn't much enthusiasm for this change. Part of the reason is that we might still make Because of these reasons, I'm closing this PR. |
|
Thanks! Marking the feature as implementation complete in the tracking issue. |
… r=Mark-Simulacrum Do not include NUL-terminator in computed length This PR contains just the first commit of rust-lang#142579 which changes it so that the string length stored in the `Location` is the length of the `&str` rather than the length of the `&CStr`. Since most users will want the `&str` length, it seems better to optimize for that use-case. There should be no visible changes in the behavior or API.
… r=Mark-Simulacrum Do not include NUL-terminator in computed length This PR contains just the first commit of rust-lang#142579 which changes it so that the string length stored in the `Location` is the length of the `&str` rather than the length of the `&CStr`. Since most users will want the `&str` length, it seems better to optimize for that use-case. There should be no visible changes in the behavior or API.
… r=Mark-Simulacrum Do not include NUL-terminator in computed length This PR contains just the first commit of rust-lang#142579 which changes it so that the string length stored in the `Location` is the length of the `&str` rather than the length of the `&CStr`. Since most users will want the `&str` length, it seems better to optimize for that use-case. There should be no visible changes in the behavior or API.
… r=Mark-Simulacrum Do not include NUL-terminator in computed length This PR contains just the first commit of rust-lang#142579 which changes it so that the string length stored in the `Location` is the length of the `&str` rather than the length of the `&CStr`. Since most users will want the `&str` length, it seems better to optimize for that use-case. There should be no visible changes in the behavior or API.
… r=Mark-Simulacrum Do not include NUL-terminator in computed length This PR contains just the first commit of rust-lang#142579 which changes it so that the string length stored in the `Location` is the length of the `&str` rather than the length of the `&CStr`. Since most users will want the `&str` length, it seems better to optimize for that use-case. There should be no visible changes in the behavior or API.
Rollup merge of #142708 - Darksonn:location-len-without-nul, r=Mark-Simulacrum Do not include NUL-terminator in computed length This PR contains just the first commit of #142579 which changes it so that the string length stored in the `Location` is the length of the `&str` rather than the length of the `&CStr`. Since most users will want the `&str` length, it seems better to optimize for that use-case. There should be no visible changes in the behavior or API.
…imulacrum Do not include NUL-terminator in computed length This PR contains just the first commit of rust-lang/rust#142579 which changes it so that the string length stored in the `Location` is the length of the `&str` rather than the length of the `&CStr`. Since most users will want the `&str` length, it seems better to optimize for that use-case. There should be no visible changes in the behavior or API.
… r=Mark-Simulacrum Do not include NUL-terminator in computed length This PR contains just the first commit of rust-lang#142579 which changes it so that the string length stored in the `Location` is the length of the `&str` rather than the length of the `&CStr`. Since most users will want the `&str` length, it seems better to optimize for that use-case. There should be no visible changes in the behavior or API.
As a follow-up to the
Location::file_with_nulACP, I'm filing this PR to ask a question for T-libs-api:This question is listed as an unresolved question in the ACP and tracking issue.
The main advantage of a raw pointer is that creating a
&CStrrequires knowing the length. This means that if we reintroduce the optimization from #117431 of not storing the length anywhere, callers offile_with_nulwill make an unnecessary call tostrlenwhen they just need to pass the pointer into C code. The main disadvantage is that using the raw pointer is unsafe.Tracking issue: #141727