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