Skip to content

Commit

Permalink
Rollup merge of rust-lang#51014 - GuillaumeGomez:env_docs, r=QuietMis…
Browse files Browse the repository at this point in the history
…dreavus

Add documentation about env! second argument

Fixes rust-lang#48044.

r? @QuietMisdreavus
  • Loading branch information
kennytm authored May 26, 2018
2 parents 103abdb + fe9a195 commit ee18e92
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/libstd/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ pub mod builtin {
///
/// let s = fmt::format(format_args!("hello {}", "world"));
/// assert_eq!(s, format!("hello {}", "world"));
///
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[macro_export]
Expand All @@ -379,7 +378,7 @@ pub mod builtin {
/// compile time, yielding an expression of type `&'static str`.
///
/// If the environment variable is not defined, then a compilation error
/// will be emitted. To not emit a compile error, use the [`option_env!`]
/// will be emitted. To not emit a compile error, use the [`option_env!`]
/// macro instead.
///
/// [`option_env!`]: ../std/macro.option_env.html
Expand All @@ -390,6 +389,20 @@ pub mod builtin {
/// let path: &'static str = env!("PATH");
/// println!("the $PATH variable at the time of compiling was: {}", path);
/// ```
///
/// You can customize the error message by passing a string as the second
/// parameter:
///
/// ```compile_fail
/// let doc: &'static str = env!("documentation", "what's that?!");
/// ```
///
/// If the `documentation` environment variable is not defined, you'll get
/// the following error:
///
/// ```text
/// error: what's that?!
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[macro_export]
macro_rules! env {
Expand Down

0 comments on commit ee18e92

Please sign in to comment.