Skip to content
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

Point out str::as_ptr is not nul-terminated #88463

Closed
wants to merge 1 commit into from

Conversation

lukaslueg
Copy link
Contributor

Adds a paragraph to the documentation of str::as_ptr() and str::as_mut_ptr() (and by extension String) pointing out that the pointer can not be used as a C-like string; trying to do so in FFI will result in hilarity.

@rust-highfive
Copy link
Collaborator

r? @joshtriplett

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 29, 2021
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-10 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
Set({"src/doc/edition-guide"}) not skipped for "bootstrap::doc::EditionGuide" -- not in ["src/tools/tidy"]
Rustbook (x86_64-unknown-linux-gnu) - edition-guide
Building stage0 tool linkchecker (x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 0.12s
std/string/struct.String.html:858: broken link - `std/std/ffi/struct.CString.html`
std/string/struct.String.html:872: broken link - `std/std/ffi/struct.CString.html`
number of HTML files scanned: 28420
number of HTML redirects found: 8894
number of links checked: 1608984
number of links ignored due to external: 65111

@lukaslueg
Copy link
Contributor Author

What's the policy on links from core (where str lives) to std (where CString lives). Should I just unlink the reference?

@the8472
Copy link
Member

the8472 commented Aug 29, 2021

You can specify them as a path to the generated doc html file instead. grep for ../../ to find some examples. To verify that the link works you can run ./x.py test linkchecker library/std --stage 0.

@lukaslueg
Copy link
Contributor Author

Ah, it seems the problem is that the link is included in the docs for core::str and std::String (due to the deref-impl). A link of the form "../../std" either breaks for the former or the latter.

@joshtriplett
Copy link
Member

This change seems reasonable to me. r=me when CI passes.

@lukaslueg
Copy link
Contributor Author

I'll need a hint on how to solve the linking catch 22. It seems to me a direct link to CString (../../....) is needed as str lives in core, while CString lives in std. But String has a Deref<Target=str>, and the link that is valid from core::str to std::CString is not valid from std::String to std::CString. I could also simply remove the direct link.

@the8472 the8472 added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Sep 8, 2021
@JohnCSimon
Copy link
Member

ping from triage:
@lukaslueg
Returning to you to address build failures and after that, please switch back to S-waiting-on-review.
thanks.

@rustbot label: +S-waiting-on-author -S-waiting-on-review

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 27, 2021
@JohnCSimon
Copy link
Member

ping from triage:
@lukaslueg can you post your status on this PR? Thank you.

@lukaslueg
Copy link
Contributor Author

@JohnCSimon As in my previous comment: I'll need a hint on how to solve the intra-doc-linking issue that arose here: A direct link from str to CString (via ../../....) is needed as str lives in core while CString lives in std. But String has a Deref<Target=str>, and the hard-link that is valid from core::str to std::CString is not valid from std::String -> Deref<str> to std::CString. I could also simply remove the intra-doc link if there is no solution to this.

@JohnCSimon
Copy link
Member

@RalfJung @Manishearth can you help with this?

@Manishearth
Copy link
Member

@jyn514 I forgot what the current status of core-to-std intra links was, overall I'm fine with allowlisting this if we have to

@jyn514
Copy link
Member

jyn514 commented Nov 8, 2021

No, there's no way to link from core to std with intra-doc links. #74481
You'll have to add it to the ignored errors in the linkchecker.

@JohnCSimon JohnCSimon added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 5, 2021
@JohnCSimon
Copy link
Member

Ping from triage:
@lukaslueg PR hasnt been touched in three months. Closing as inactive, feel free to reopen.

@rustbot label: +S-inactive

@JohnCSimon JohnCSimon closed this Jan 30, 2022
@rustbot rustbot added the S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. label Jan 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants