]> git.lizzy.rs Git - rust.git/blob - tests/ui/option_env_unwrap.rs
Auto merge of #68717 - petrochenkov:stabexpat, r=varkor
[rust.git] / tests / ui / option_env_unwrap.rs
1 // aux-build:macro_rules.rs
2 #![warn(clippy::option_env_unwrap)]
3
4 #[macro_use]
5 extern crate macro_rules;
6
7 macro_rules! option_env_unwrap {
8     ($env: expr) => {
9         option_env!($env).unwrap()
10     };
11     ($env: expr, $message: expr) => {
12         option_env!($env).expect($message)
13     };
14 }
15
16 fn main() {
17     let _ = option_env!("PATH").unwrap();
18     let _ = option_env!("PATH").expect("environment variable PATH isn't set");
19     let _ = option_env_unwrap!("PATH");
20     let _ = option_env_unwrap!("PATH", "environment variable PATH isn't set");
21     let _ = option_env_unwrap_external!("PATH");
22     let _ = option_env_unwrap_external!("PATH", "environment variable PATH isn't set");
23 }