Eliminate some Option<NativeLibKind>s
This commit is contained in:
parent
529d488f1a
commit
8dbe4d9ba4
4 changed files with 33 additions and 34 deletions
|
|
@ -300,30 +300,30 @@ fn test_native_libs_tracking_hash_different_values() {
|
|||
|
||||
// Reference
|
||||
v1.libs = vec![
|
||||
(String::from("a"), None, Some(NativeLibKind::StaticBundle)),
|
||||
(String::from("b"), None, Some(NativeLibKind::Framework)),
|
||||
(String::from("c"), None, Some(NativeLibKind::Unspecified)),
|
||||
(String::from("a"), None, NativeLibKind::StaticBundle),
|
||||
(String::from("b"), None, NativeLibKind::Framework),
|
||||
(String::from("c"), None, NativeLibKind::Unspecified),
|
||||
];
|
||||
|
||||
// Change label
|
||||
v2.libs = vec![
|
||||
(String::from("a"), None, Some(NativeLibKind::StaticBundle)),
|
||||
(String::from("X"), None, Some(NativeLibKind::Framework)),
|
||||
(String::from("c"), None, Some(NativeLibKind::Unspecified)),
|
||||
(String::from("a"), None, NativeLibKind::StaticBundle),
|
||||
(String::from("X"), None, NativeLibKind::Framework),
|
||||
(String::from("c"), None, NativeLibKind::Unspecified),
|
||||
];
|
||||
|
||||
// Change kind
|
||||
v3.libs = vec![
|
||||
(String::from("a"), None, Some(NativeLibKind::StaticBundle)),
|
||||
(String::from("b"), None, Some(NativeLibKind::StaticBundle)),
|
||||
(String::from("c"), None, Some(NativeLibKind::Unspecified)),
|
||||
(String::from("a"), None, NativeLibKind::StaticBundle),
|
||||
(String::from("b"), None, NativeLibKind::StaticBundle),
|
||||
(String::from("c"), None, NativeLibKind::Unspecified),
|
||||
];
|
||||
|
||||
// Change new-name
|
||||
v4.libs = vec![
|
||||
(String::from("a"), None, Some(NativeLibKind::StaticBundle)),
|
||||
(String::from("b"), Some(String::from("X")), Some(NativeLibKind::Framework)),
|
||||
(String::from("c"), None, Some(NativeLibKind::Unspecified)),
|
||||
(String::from("a"), None, NativeLibKind::StaticBundle),
|
||||
(String::from("b"), Some(String::from("X")), NativeLibKind::Framework),
|
||||
(String::from("c"), None, NativeLibKind::Unspecified),
|
||||
];
|
||||
|
||||
assert!(v1.dep_tracking_hash() != v2.dep_tracking_hash());
|
||||
|
|
@ -345,21 +345,21 @@ fn test_native_libs_tracking_hash_different_order() {
|
|||
|
||||
// Reference
|
||||
v1.libs = vec![
|
||||
(String::from("a"), None, Some(NativeLibKind::StaticBundle)),
|
||||
(String::from("b"), None, Some(NativeLibKind::Framework)),
|
||||
(String::from("c"), None, Some(NativeLibKind::Unspecified)),
|
||||
(String::from("a"), None, NativeLibKind::StaticBundle),
|
||||
(String::from("b"), None, NativeLibKind::Framework),
|
||||
(String::from("c"), None, NativeLibKind::Unspecified),
|
||||
];
|
||||
|
||||
v2.libs = vec![
|
||||
(String::from("b"), None, Some(NativeLibKind::Framework)),
|
||||
(String::from("a"), None, Some(NativeLibKind::StaticBundle)),
|
||||
(String::from("c"), None, Some(NativeLibKind::Unspecified)),
|
||||
(String::from("b"), None, NativeLibKind::Framework),
|
||||
(String::from("a"), None, NativeLibKind::StaticBundle),
|
||||
(String::from("c"), None, NativeLibKind::Unspecified),
|
||||
];
|
||||
|
||||
v3.libs = vec![
|
||||
(String::from("c"), None, Some(NativeLibKind::Unspecified)),
|
||||
(String::from("a"), None, Some(NativeLibKind::StaticBundle)),
|
||||
(String::from("b"), None, Some(NativeLibKind::Framework)),
|
||||
(String::from("c"), None, NativeLibKind::Unspecified),
|
||||
(String::from("a"), None, NativeLibKind::StaticBundle),
|
||||
(String::from("b"), None, NativeLibKind::Framework),
|
||||
];
|
||||
|
||||
assert!(v1.dep_tracking_hash() == v2.dep_tracking_hash());
|
||||
|
|
|
|||
|
|
@ -241,8 +241,8 @@ impl Collector<'tcx> {
|
|||
.drain_filter(|lib| {
|
||||
if let Some(lib_name) = lib.name {
|
||||
if lib_name.as_str() == *name {
|
||||
if let Some(k) = kind {
|
||||
lib.kind = k;
|
||||
if kind != NativeLibKind::Unspecified {
|
||||
lib.kind = kind;
|
||||
}
|
||||
if let &Some(ref new_name) = new_name {
|
||||
lib.name = Some(Symbol::intern(new_name));
|
||||
|
|
@ -258,7 +258,7 @@ impl Collector<'tcx> {
|
|||
let new_name = new_name.as_ref().map(|s| &**s); // &Option<String> -> Option<&str>
|
||||
let lib = NativeLib {
|
||||
name: Some(Symbol::intern(new_name.unwrap_or(name))),
|
||||
kind: if let Some(k) = kind { k } else { NativeLibKind::Unspecified },
|
||||
kind,
|
||||
cfg: None,
|
||||
foreign_module: None,
|
||||
wasm_import_module: None,
|
||||
|
|
|
|||
|
|
@ -1452,7 +1452,7 @@ fn select_debuginfo(
|
|||
fn parse_libs(
|
||||
matches: &getopts::Matches,
|
||||
error_format: ErrorOutputType,
|
||||
) -> Vec<(String, Option<String>, Option<NativeLibKind>)> {
|
||||
) -> Vec<(String, Option<String>, NativeLibKind)> {
|
||||
matches
|
||||
.opt_strs("l")
|
||||
.into_iter()
|
||||
|
|
@ -1462,11 +1462,11 @@ fn parse_libs(
|
|||
let mut parts = s.splitn(2, '=');
|
||||
let kind = parts.next().unwrap();
|
||||
let (name, kind) = match (parts.next(), kind) {
|
||||
(None, name) => (name, None),
|
||||
(Some(name), "dylib") => (name, Some(NativeLibKind::Dylib)),
|
||||
(Some(name), "framework") => (name, Some(NativeLibKind::Framework)),
|
||||
(Some(name), "static") => (name, Some(NativeLibKind::StaticBundle)),
|
||||
(Some(name), "static-nobundle") => (name, Some(NativeLibKind::StaticNoBundle)),
|
||||
(None, name) => (name, NativeLibKind::Unspecified),
|
||||
(Some(name), "dylib") => (name, NativeLibKind::Dylib),
|
||||
(Some(name), "framework") => (name, NativeLibKind::Framework),
|
||||
(Some(name), "static") => (name, NativeLibKind::StaticBundle),
|
||||
(Some(name), "static-nobundle") => (name, NativeLibKind::StaticNoBundle),
|
||||
(_, s) => {
|
||||
early_error(
|
||||
error_format,
|
||||
|
|
@ -1478,7 +1478,7 @@ fn parse_libs(
|
|||
);
|
||||
}
|
||||
};
|
||||
if kind == Some(NativeLibKind::StaticNoBundle) && !nightly_options::is_nightly_build() {
|
||||
if kind == NativeLibKind::StaticNoBundle && !nightly_options::is_nightly_build() {
|
||||
early_error(
|
||||
error_format,
|
||||
"the library kind 'static-nobundle' is only \
|
||||
|
|
@ -2058,7 +2058,6 @@ crate mod dep_tracking {
|
|||
impl_dep_tracking_hash_via_hash!(Option<RelroLevel>);
|
||||
impl_dep_tracking_hash_via_hash!(Option<lint::Level>);
|
||||
impl_dep_tracking_hash_via_hash!(Option<PathBuf>);
|
||||
impl_dep_tracking_hash_via_hash!(Option<NativeLibKind>);
|
||||
impl_dep_tracking_hash_via_hash!(CrateType);
|
||||
impl_dep_tracking_hash_via_hash!(MergeFunctions);
|
||||
impl_dep_tracking_hash_via_hash!(PanicStrategy);
|
||||
|
|
@ -2084,7 +2083,7 @@ crate mod dep_tracking {
|
|||
impl_dep_tracking_hash_for_sortable_vec_of!(PathBuf);
|
||||
impl_dep_tracking_hash_for_sortable_vec_of!(CrateType);
|
||||
impl_dep_tracking_hash_for_sortable_vec_of!((String, lint::Level));
|
||||
impl_dep_tracking_hash_for_sortable_vec_of!((String, Option<String>, Option<NativeLibKind>));
|
||||
impl_dep_tracking_hash_for_sortable_vec_of!((String, Option<String>, NativeLibKind));
|
||||
impl_dep_tracking_hash_for_sortable_vec_of!((String, u64));
|
||||
impl_dep_tracking_hash_for_sortable_vec_of!(Sanitizer);
|
||||
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ top_level_options!(
|
|||
describe_lints: bool [UNTRACKED],
|
||||
output_types: OutputTypes [TRACKED],
|
||||
search_paths: Vec<SearchPath> [UNTRACKED],
|
||||
libs: Vec<(String, Option<String>, Option<NativeLibKind>)> [TRACKED],
|
||||
libs: Vec<(String, Option<String>, NativeLibKind)> [TRACKED],
|
||||
maybe_sysroot: Option<PathBuf> [UNTRACKED],
|
||||
|
||||
target_triple: TargetTriple [TRACKED],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue