Add well known values to --check-cfg implementation
This commit is contained in:
parent
50e61a1a66
commit
4aa92aff05
7 changed files with 196 additions and 8 deletions
|
@ -186,12 +186,16 @@ impl PanicStrategy {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn desc_symbol(&self) -> Symbol {
|
||||
pub const fn desc_symbol(&self) -> Symbol {
|
||||
match *self {
|
||||
PanicStrategy::Unwind => sym::unwind,
|
||||
PanicStrategy::Abort => sym::abort,
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn all() -> [Symbol; 2] {
|
||||
[Self::Abort.desc_symbol(), Self::Unwind.desc_symbol()]
|
||||
}
|
||||
}
|
||||
|
||||
impl ToJson for PanicStrategy {
|
||||
|
@ -614,7 +618,7 @@ impl SanitizerSet {
|
|||
/// Return sanitizer's name
|
||||
///
|
||||
/// Returns none if the flags is a set of sanitizers numbering not exactly one.
|
||||
fn as_str(self) -> Option<&'static str> {
|
||||
pub fn as_str(self) -> Option<&'static str> {
|
||||
Some(match self {
|
||||
SanitizerSet::ADDRESS => "address",
|
||||
SanitizerSet::CFI => "cfi",
|
||||
|
@ -2137,6 +2141,18 @@ impl Target {
|
|||
))
|
||||
}
|
||||
|
||||
/// Load a built-in target
|
||||
pub fn expect_builtin(target_triple: &TargetTriple) -> Target {
|
||||
match *target_triple {
|
||||
TargetTriple::TargetTriple(ref target_triple) => {
|
||||
load_builtin(target_triple).expect("built-in target")
|
||||
}
|
||||
TargetTriple::TargetPath(..) => {
|
||||
panic!("built-in targets doens't support target-paths")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Search for a JSON file specifying the given target triple.
|
||||
///
|
||||
/// If none is found in `$RUST_TARGET_PATH`, look for a file called `target.json` inside the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue