Skip to content

Commit

Permalink
use option_env! instead of env!
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Apr 24, 2014
1 parent 7d70434 commit 77a975d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/librustc/back/rpath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ pub fn get_rpath_relative_to_output(os: abi::Os,
}

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

let tlib = filesearch::relative_target_lib_path(sysroot, target_triple);
let mut path = Path::new(install_prefix);
Expand Down Expand Up @@ -171,7 +171,7 @@ mod test {
fn test_prefix_rpath() {
let sysroot = filesearch::get_or_default_sysroot();
let res = get_install_prefix_rpath(&sysroot, "triple");
let mut d = Path::new(env!("CFG_PREFIX"));
let mut d = Path::new((option_env!("CFG_PREFIX")).expect("CFG_PREFIX"));
d.push("lib");
d.push(filesearch::rustlibdir());
d.push("triple/lib");
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,8 @@ pub fn host_triple() -> &'static str {
// Instead of grabbing the host triple (for the current host), we grab (at
// compile time) the target triple that this rustc is built with and
// calling that (at runtime) the host triple.
env!("CFG_COMPILER_HOST_TRIPLE")
(option_env!("CFG_COMPILER_HOST_TRIPLE")).
expect("CFG_COMPILER_HOST_TRIPLE")
}

pub fn build_session_options(matches: &getopts::Matches) -> session::Options {
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/middle/trans/debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,8 @@ fn compile_unit_metadata(cx: &CrateContext) {
};

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

compile_unit_name.with_ref(|compile_unit_name| {
work_dir.as_vec().with_c_str(|work_dir| {
Expand Down

0 comments on commit 77a975d

Please sign in to comment.