Skip to content

Commit 77a975d

Browse files
committed
use option_env! instead of env!
1 parent 7d70434 commit 77a975d

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/librustc/back/rpath.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ pub fn get_rpath_relative_to_output(os: abi::Os,
133133
}
134134

135135
pub fn get_install_prefix_rpath(sysroot: &Path, target_triple: &str) -> ~str {
136-
let install_prefix = env!("CFG_PREFIX");
136+
let install_prefix = option_env!("CFG_PREFIX").expect("CFG_PREFIX");
137137

138138
let tlib = filesearch::relative_target_lib_path(sysroot, target_triple);
139139
let mut path = Path::new(install_prefix);
@@ -171,7 +171,7 @@ mod test {
171171
fn test_prefix_rpath() {
172172
let sysroot = filesearch::get_or_default_sysroot();
173173
let res = get_install_prefix_rpath(&sysroot, "triple");
174-
let mut d = Path::new(env!("CFG_PREFIX"));
174+
let mut d = Path::new((option_env!("CFG_PREFIX")).expect("CFG_PREFIX"));
175175
d.push("lib");
176176
d.push(filesearch::rustlibdir());
177177
d.push("triple/lib");

src/librustc/driver/driver.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,8 @@ pub fn host_triple() -> &'static str {
802802
// Instead of grabbing the host triple (for the current host), we grab (at
803803
// compile time) the target triple that this rustc is built with and
804804
// calling that (at runtime) the host triple.
805-
env!("CFG_COMPILER_HOST_TRIPLE")
805+
(option_env!("CFG_COMPILER_HOST_TRIPLE")).
806+
expect("CFG_COMPILER_HOST_TRIPLE")
806807
}
807808

808809
pub fn build_session_options(matches: &getopts::Matches) -> session::Options {

src/librustc/middle/trans/debuginfo.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,8 @@ fn compile_unit_metadata(cx: &CrateContext) {
984984
};
985985

986986
debug!("compile_unit_metadata: {:?}", compile_unit_name);
987-
let producer = format!("rustc version {}", env!("CFG_VERSION"));
987+
let producer = format!("rustc version {}",
988+
(option_env!("CFG_VERSION")).expect("CFG_VERSION"));
988989

989990
compile_unit_name.with_ref(|compile_unit_name| {
990991
work_dir.as_vec().with_c_str(|work_dir| {

0 commit comments

Comments
 (0)