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

Remove Errors section from var_os docs #109894

Merged

Conversation

fleetingbytes
Copy link
Contributor

Remove Errors section from var_os documentation, fixes #109893

Remove `Errors` section from `var_os` documentation
@rustbot
Copy link
Collaborator

rustbot commented Apr 3, 2023

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @cuviper (or someone else) soon.

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 (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Apr 3, 2023
@Noratrieb Noratrieb changed the title Update env.rs Remove Errors section from var_os docs Apr 3, 2023
@Noratrieb
Copy link
Member

While it can't return an error, it can still return None, so I guess the docs should be changed to mention that instead. (yay, return type consistency between var and var_os :(. )

@fleetingbytes
Copy link
Contributor Author

fleetingbytes commented Apr 3, 2023

@Nilstrieb the documentation already mentions that var_os returns None if it is not present or if there is other errors. But additionally it currently says that var_os "returns an error if ..." which that can't be true, since its return type is Option.

@ChrisDenton
Copy link
Member

Right, the wording should be more like "on Error returns None" and then list the things that might cause it to return None.

I don't think removing the section entirely is a good idea. It contains useful information even if it mixes up the return type.

Re-introduced some of the former errors as situations where `None` is returned.
@rustbot
Copy link
Collaborator

rustbot commented Apr 3, 2023

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@fleetingbytes
Copy link
Contributor Author

I don't think removing the section entirely is a good idea. It contains useful information even if it mixes up the return type.

Good point. I have reworded the documentation. The original Errors are now reformulated as situations where None is returned. (The error about invalid Unicode is gone for good, though.)

library/std/src/env.rs Outdated Show resolved Hide resolved
fleetingbytes and others added 3 commits April 3, 2023 17:13
Co-authored-by: León Orell Valerian Liehr <[email protected]>
Original `var_os` description said that it _may_ return an error if the value contains `=` or NUL. Let's make no promises on the `None` return value in these situation either, keep it in the [potential mood](https://en.wikipedia.org/wiki/Grammatical_mood#Potential).
@@ -236,22 +236,14 @@ fn _var(key: &OsStr) -> Result<String, VarError> {
}

/// Fetches the environment variable `key` from the current process, returning
/// [`None`] if the variable isn't set or there's another error.
/// [`None`] if the environment variable isn't set. It may return `None` also
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, the first paragraph is best as a relatively short "title", as that's what will be listed on the module page. Can you break this up?

Further referring to `var_os` as a "function" (like in `var`), rather than "method".
@cuviper
Copy link
Member

cuviper commented Apr 11, 2023

Thanks!

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Apr 11, 2023

📌 Commit 7d26963 has been approved by cuviper

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 11, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 12, 2023
…mpiler-errors

Rollup of 10 pull requests

Successful merges:

 - rust-lang#96971 (Initial support for loongarch64-unknown-linux-gnu)
 - rust-lang#109894 (Remove Errors section from var_os docs)
 - rust-lang#110000 (Rename tests/ui/unique to tests/ui/box/unit)
 - rust-lang#110018 (Pass host linker to compiletest.)
 - rust-lang#110104 ( Reword the docstring in todo! macro definition, fixing a typo)
 - rust-lang#110113 (Fix `x test ui --target foo` when download-rustc is enabled)
 - rust-lang#110126 (Support safe transmute in new solver)
 - rust-lang#110155 (Fix typos in librustdoc, tools and config files)
 - rust-lang#110162 (rustdoc: remove redundant expandSection code from main.js)
 - rust-lang#110173 (kmc-solid: Implement `Socket::read_buf`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 8a7a665 into rust-lang:master Apr 12, 2023
@rustbot rustbot added this to the 1.70.0 milestone Apr 12, 2023
evanj added a commit to evanj/rust that referenced this pull request Aug 9, 2024
The documentation incorrectly stated that std::env::var could return
an error for variable names containing '=' or the NUL byte. Copy the
correct documentation from var_os.

var_os was fixed in Commit 8a7a665, Pull Request rust-lang#109894, which
closed Issue rust-lang#109893.

This documentation was incorrectly added in commit f2c0f29, which
replaced a panic in var_os by returning None, but documented the
change as "May error if ...".

Reference the specific error values and link to them.
evanj added a commit to evanj/rust that referenced this pull request Aug 9, 2024
The documentation incorrectly stated that std::env::var could return
an error for variable names containing '=' or the NUL byte. Copy the
correct documentation from var_os.

var_os was fixed in Commit 8a7a665, Pull Request rust-lang#109894, which
closed Issue rust-lang#109893.

This documentation was incorrectly added in commit f2c0f29, which
replaced a panic in var_os by returning None, but documented the
change as "May error if ...".

Reference the specific error values and link to them.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 18, 2024
…rkingjubilee

doc: std::env::var: Returns None for names with '=' or NUL byte

The documentation incorrectly stated that std::env::var could return an error for variable names containing '=' or the NUL byte. Copy the correct documentation from var_os.

var_os was fixed in Commit 8a7a665, Pull Request rust-lang#109894, which closed Issue rust-lang#109893.

This documentation was incorrectly added in commit f2c0f29, which replaced a panic in var_os by returning None, but documented the change as "May error if ...".

Reference the specific error values and link to them.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 18, 2024
…rkingjubilee

doc: std::env::var: Returns None for names with '=' or NUL byte

The documentation incorrectly stated that std::env::var could return an error for variable names containing '=' or the NUL byte. Copy the correct documentation from var_os.

var_os was fixed in Commit 8a7a665, Pull Request rust-lang#109894, which closed Issue rust-lang#109893.

This documentation was incorrectly added in commit f2c0f29, which replaced a panic in var_os by returning None, but documented the change as "May error if ...".

Reference the specific error values and link to them.
tgross35 added a commit to tgross35/rust that referenced this pull request Aug 19, 2024
…rkingjubilee

doc: std::env::var: Returns None for names with '=' or NUL byte

The documentation incorrectly stated that std::env::var could return an error for variable names containing '=' or the NUL byte. Copy the correct documentation from var_os.

var_os was fixed in Commit 8a7a665, Pull Request rust-lang#109894, which closed Issue rust-lang#109893.

This documentation was incorrectly added in commit f2c0f29, which replaced a panic in var_os by returning None, but documented the change as "May error if ...".

Reference the specific error values and link to them.
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Aug 19, 2024
Rollup merge of rust-lang#128902 - evanj:evan.jones/env-var-doc, r=workingjubilee

doc: std::env::var: Returns None for names with '=' or NUL byte

The documentation incorrectly stated that std::env::var could return an error for variable names containing '=' or the NUL byte. Copy the correct documentation from var_os.

var_os was fixed in Commit 8a7a665, Pull Request rust-lang#109894, which closed Issue rust-lang#109893.

This documentation was incorrectly added in commit f2c0f29, which replaced a panic in var_os by returning None, but documented the change as "May error if ...".

Reference the specific error values and link to them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

var_os never returns an error
7 participants