diff --git a/ValeRuster/src/indexer.rs b/ValeRuster/src/indexer.rs index ea9b959c2..bfe8e52e1 100644 --- a/ValeRuster/src/indexer.rs +++ b/ValeRuster/src/indexer.rs @@ -343,9 +343,9 @@ fn infer_missing_owners( let direct_child_keys = include_impls_children( crates, &primitive_name_to_uid, direct_child_uids_without_methods)?; - println!("Direct child keys: {:?}", &direct_child_keys); + // println!("Direct child keys: {:?}", &direct_child_keys); let direct_child_uids = collapse_children(&direct_child_keys); - println!("Direct child uids: {:?}", &direct_child_uids); + // println!("Direct child uids: {:?}", &direct_child_uids); // Now look for all their methods. let mut method_keys = Vec::new(); for direct_child_uid in direct_child_uids { @@ -498,7 +498,7 @@ fn determine_ultimate_owner( .map(|id| (id.clone(), lookup_uid(crates, id))) .collect::>(); parent_uids_and_items.sort_by_key(|(_uid, item)| item.span.as_ref().unwrap().filename.to_str().as_ref().unwrap().len()); - println!("Heuristic, estimating owner for {:?} is {:?}", item_uid, parent_uids_and_items.iter().next().unwrap().clone()); + // println!("Heuristic, estimating owner for {:?} is {:?}", item_uid, parent_uids_and_items.iter().next().unwrap().clone()); parent_uids_and_items .into_iter() .map(|x| x.0) diff --git a/ValeRuster/src/main.rs b/ValeRuster/src/main.rs index 649c2c750..4a0a23e6e 100644 --- a/ValeRuster/src/main.rs +++ b/ValeRuster/src/main.rs @@ -609,10 +609,16 @@ mod capi; let output = Command::new(&cargo_path) .args(&[ + "+nightly", "cbuild", + "--release", &("--manifest-path=".to_string() + output_dir_path + "/Cargo.toml"), "--destdir=clibthing", + "--target", "aarch64-apple-darwin", + "-Z", "build-std-features=panic_immediate_abort", + "-Z", "build-std=std,panic_abort", "--library-type", "staticlib"]) + .env("RUSTFLAGS", "-Zlocation-detail=none") .output() .with_context(|| "Failed to execute cbuild command")?; if output.status.code() == Some(0) { @@ -868,7 +874,7 @@ fn impl_from_matches_generic_args( if let Some(trait_) = &impl_.trait_ { if let Some(args) = &trait_.args { match args.as_ref() { - GenericArgs::AngleBracketed { args: args, .. } => { + GenericArgs::AngleBracketed { args, .. } => { args } GenericArgs::Parenthesized { .. } => unimplemented!(), @@ -964,6 +970,18 @@ fn match_generic_arg_valtype( current_height: i64, ) -> Option { match (generic_arg, generic_param) { + // The order of these cases is important, for example we want to match + // any type to a generic variable T before we do anything else. + (_, Type::Generic(generic_param_name)) => { + generics.insert( + generic_param_name.clone(), + SimpleType { + imm_ref: false, + mut_ref: false, + valtype: generic_arg.clone() + }); + Some(current_height) + } (_, _) if is_primitive(&item_index.primitive_uid_to_name, &generic_arg.id) => { if let Type::Primitive(generic_param_primitive_name) = generic_param { if item_index.primitive_uid_to_name.get(&generic_arg.id).unwrap() == generic_param_primitive_name { @@ -983,16 +1001,6 @@ fn match_generic_arg_valtype( None } } - (_, Type::Generic(generic_param_name)) => { - generics.insert( - generic_param_name.clone(), - SimpleType { - imm_ref: false, - mut_ref: false, - valtype: generic_arg.clone() - }); - Some(current_height) - } ( _, Type::ResolvedPath(rustdoc_types::Path { name: generic_param_name, args: _generic_params, .. }) @@ -1220,9 +1228,9 @@ fn instantiate_struct( builder += "#[repr(C)]\n"; builder += "pub struct "; builder += as_; - builder += " ([u8; "; + builder += " (std::mem::MaybeUninit<[u8; "; builder += &size.to_string(); - builder += "]);\n"; + builder += "]>);\n"; builder += "const_assert_eq!(std::mem::size_of::<"; builder += &rustify_simple_type(&crates, &item_index, &needle_type, None)?; builder += ">(), "; @@ -1303,7 +1311,7 @@ fn instantiate_func( } rust_builder += &rustify_simple_type(&crates, &item_index, needle_type, Some(func))?; rust_builder += "("; - for (param_name, param_type) in params { + for (param_name, _param_type) in params { rust_builder += param_name; rust_builder += "_rs,"; } @@ -1330,7 +1338,7 @@ fn instantiate_func( } fn list_struct_and_methods(v: &Crate, struct_name: &String) { - for (id, item) in &v.index { + for (_id, item) in &v.index { match &item.inner { ItemEnum::Struct(struuct) => { match &item.name {