Skip to content

Commit 96c90cc

Browse files
#[cfg] for post_install_msg_{unix,win}
1 parent e49ff3d commit 96c90cc

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

src/cli/self_update.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ these changes will be reverted.
124124
};
125125
}
126126

127-
#[cfg(unix)]
127+
#[cfg(not(windows))]
128128
macro_rules! pre_install_msg_unix {
129129
() => {
130130
pre_install_msg_template!(
@@ -155,6 +155,7 @@ but will not be added automatically."
155155
};
156156
}
157157

158+
#[cfg(not(windows))]
158159
macro_rules! post_install_msg_unix {
159160
() => {
160161
r"# Rust is installed now. Great!
@@ -168,6 +169,7 @@ To configure your current shell run `source {cargo_home}/env`
168169
};
169170
}
170171

172+
#[cfg(windows)]
171173
macro_rules! post_install_msg_win {
172174
() => {
173175
r"# Rust is installed now. Great!
@@ -179,6 +181,7 @@ correct environment, but you may need to restart your current shell.
179181
};
180182
}
181183

184+
#[cfg(not(windows))]
182185
macro_rules! post_install_msg_unix_no_modify_path {
183186
() => {
184187
r"# Rust is installed now. Great!
@@ -191,6 +194,7 @@ To configure your current shell run `source {cargo_home}/env`
191194
};
192195
}
193196

197+
#[cfg(windows)]
194198
macro_rules! post_install_msg_win_no_modify_path {
195199
() => {
196200
r"# Rust is installed now. Great!
@@ -366,17 +370,23 @@ pub fn install(
366370
let cargo_home = canonical_cargo_home()?;
367371
#[cfg(windows)]
368372
let cargo_home = cargo_home.replace('\\', r"\\");
369-
let msg = match (opts.no_modify_path, cfg!(unix)) {
370-
(false, true) => format!(post_install_msg_unix!(), cargo_home = cargo_home),
371-
(false, false) => format!(post_install_msg_win!(), cargo_home = cargo_home),
372-
(true, true) => format!(
373-
post_install_msg_unix_no_modify_path!(),
374-
cargo_home = cargo_home
375-
),
376-
(true, false) => format!(
373+
#[cfg(windows)]
374+
let msg = if opts.no_modify_path {
375+
format!(
377376
post_install_msg_win_no_modify_path!(),
378377
cargo_home = cargo_home
379-
),
378+
)
379+
} else {
380+
format!(post_install_msg_win!(), cargo_home = cargo_home)
381+
};
382+
#[cfg(not(windows))]
383+
let msg = if opts.no_modify_path {
384+
format!(
385+
post_install_msg_unix_no_modify_path!(),
386+
cargo_home = cargo_home
387+
)
388+
} else {
389+
format!(post_install_msg_unix!(), cargo_home = cargo_home)
380390
};
381391
md(&mut term, msg);
382392

0 commit comments

Comments
 (0)