@@ -364,7 +364,6 @@ pub mod builtin {
364
364
///
365
365
/// let s = fmt::format(format_args!("hello {}", "world"));
366
366
/// assert_eq!(s, format!("hello {}", "world"));
367
- ///
368
367
/// ```
369
368
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
370
369
#[ macro_export]
@@ -379,7 +378,7 @@ pub mod builtin {
379
378
/// compile time, yielding an expression of type `&'static str`.
380
379
///
381
380
/// If the environment variable is not defined, then a compilation error
382
- /// will be emitted. To not emit a compile error, use the [`option_env!`]
381
+ /// will be emitted. To not emit a compile error, use the [`option_env!`]
383
382
/// macro instead.
384
383
///
385
384
/// [`option_env!`]: ../std/macro.option_env.html
@@ -390,6 +389,20 @@ pub mod builtin {
390
389
/// let path: &'static str = env!("PATH");
391
390
/// println!("the $PATH variable at the time of compiling was: {}", path);
392
391
/// ```
392
+ ///
393
+ /// You can customize the error message by passing a string as the second
394
+ /// parameter:
395
+ ///
396
+ /// ```compile_fail
397
+ /// let doc: &'static str = env!("documentation", "what's that?!");
398
+ /// ```
399
+ ///
400
+ /// If the `documentation` environment variable is not defined, you'll get
401
+ /// the following error:
402
+ ///
403
+ /// ```text
404
+ /// error: what's that?!
405
+ /// ```
393
406
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
394
407
#[ macro_export]
395
408
macro_rules! env {
0 commit comments