This repository has been archived by the owner on Aug 16, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a memory leak in downcast (#262)
- Loading branch information
Showing
4 changed files
with
67 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use std::env; | ||
use std::process::Command; | ||
use std::str; | ||
use std::str::FromStr; | ||
|
||
fn main() { | ||
if rustc_has_global_alloc() { | ||
println!("cargo:rustc-cfg=has_global_alloc"); | ||
} | ||
} | ||
|
||
fn rustc_has_global_alloc() -> bool { | ||
let rustc = match env::var_os("RUSTC") { | ||
Some(rustc) => rustc, | ||
None => return false, | ||
}; | ||
|
||
let output = match Command::new(rustc).arg("--version").output() { | ||
Ok(output) => output, | ||
Err(_) => return false, | ||
}; | ||
|
||
let version = match str::from_utf8(&output.stdout) { | ||
Ok(version) => version, | ||
Err(_) => return false, | ||
}; | ||
|
||
let mut pieces = version.split('.'); | ||
if pieces.next() != Some("rustc 1") { | ||
return true; | ||
} | ||
|
||
let next = match pieces.next() { | ||
Some(next) => next, | ||
None => return false, | ||
}; | ||
|
||
u32::from_str(next).unwrap_or(0) >= 28 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters