diff --git a/Cargo.lock b/Cargo.lock index a5e5c0d5..34cc5928 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,14 +1,5 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -[[package]] -name = "aho-corasick" -version = "0.7.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5" -dependencies = [ - "memchr", -] - [[package]] name = "ansi_term" version = "0.11.0" @@ -78,15 +69,9 @@ dependencies = [ [[package]] name = "byteorder" -version = "1.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" - -[[package]] -name = "cfg-if" -version = "0.1.10" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" +checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b" [[package]] name = "cfg-if" @@ -131,22 +116,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "02d96d1e189ef58269ebe5b97953da3274d83a93af647c2ddd6f9dab28cedb8d" dependencies = [ "autocfg", - "cfg-if 1.0.0", + "cfg-if", "lazy_static", ] [[package]] name = "derive_more" -version = "0.15.0" +version = "0.99.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a141330240c921ec6d074a3e188a7c7ef95668bb95e7d44fa0e5778ec2a7afe" +checksum = "41cb0e6161ad61ed084a36ba71fbba9e3ac5aee3606fb607fe08da6acbcf3d8c" dependencies = [ - "lazy_static", - "proc-macro2 0.4.30", - "quote 0.6.13", - "regex", - "rustc_version", - "syn 0.15.44", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -171,20 +153,20 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ - "cfg-if 0.1.10", + "cfg-if", "libc", "wasi", ] [[package]] name = "heck" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" +checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac" dependencies = [ "unicode-segmentation", ] @@ -200,9 +182,9 @@ dependencies = [ [[package]] name = "itoa" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" +checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" [[package]] name = "lazy_static" @@ -212,15 +194,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.81" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb" - -[[package]] -name = "memchr" -version = "2.3.4" +version = "0.2.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" +checksum = "89203f3fba0a3795506acaad8ebce3c80c0af93f994d5a1d7a0b1eeb23271929" [[package]] name = "num-traits" @@ -231,40 +207,22 @@ dependencies = [ "autocfg", ] -[[package]] -name = "proc-macro2" -version = "0.4.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -dependencies = [ - "unicode-xid 0.1.0", -] - [[package]] name = "proc-macro2" version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" dependencies = [ - "unicode-xid 0.2.1", -] - -[[package]] -name = "quote" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" -dependencies = [ - "proc-macro2 0.4.30", + "unicode-xid", ] [[package]] name = "quote" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +checksum = "991431c3519a3f36861882da93630ce66b52918dcf1b8e2fd66b397fc96f28df" dependencies = [ - "proc-macro2 1.0.24", + "proc-macro2", ] [[package]] @@ -284,24 +242,6 @@ dependencies = [ "rust-argon2", ] -[[package]] -name = "regex" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", - "thread_local", -] - -[[package]] -name = "regex-syntax" -version = "0.6.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189" - [[package]] name = "rspirv" version = "0.7.0" @@ -319,8 +259,8 @@ name = "rspirv-autogen" version = "0.1.0" dependencies = [ "heck", - "proc-macro2 1.0.24", - "quote 1.0.7", + "proc-macro2", + "quote", "serde", "serde_derive", "serde_json", @@ -346,61 +286,37 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver", -] - [[package]] name = "ryu" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - [[package]] name = "serde" -version = "1.0.118" +version = "1.0.119" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800" +checksum = "9bdd36f49e35b61d49efd8aa7fc068fd295961fd2286d0b2ee9a4c7a14e99cc3" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.118" +version = "1.0.119" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df" +checksum = "552954ce79a059ddd5fd68c271592374bd15cab2274970380c000118aeffe1cd" dependencies = [ - "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.54", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "serde_json" -version = "1.0.60" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1500e84d27fe482ed1dc791a56eddc2f230046a040fa908c08bda1d9fb615779" +checksum = "4fceb2595057b6891a4ee808f70054bd2d12f0e97f1cbb78689b59f676df325a" dependencies = [ "itoa", "ryu", @@ -424,24 +340,13 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "syn" -version = "0.15.44" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +checksum = "cc60a3d73ea6594cd712d830cc1f0390fd71542d8c8cd24e70cc54cdfd5e05d5" dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "unicode-xid 0.1.0", -] - -[[package]] -name = "syn" -version = "1.0.54" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2af957a63d6bd42255c359c93d9bfdb97076bd3b820897ce55ffbfbf107f44" -dependencies = [ - "proc-macro2 1.0.24", - "quote 1.0.7", - "unicode-xid 0.2.1", + "proc-macro2", + "quote", + "unicode-xid", ] [[package]] @@ -464,15 +369,6 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "thread_local" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" -dependencies = [ - "lazy_static", -] - [[package]] name = "unicode-segmentation" version = "1.7.1" @@ -485,12 +381,6 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" - [[package]] name = "unicode-xid" version = "0.2.1" diff --git a/autogen/src/dr.rs b/autogen/src/dr.rs index e548ca92..c929ed9e 100644 --- a/autogen/src/dr.rs +++ b/autogen/src/dr.rs @@ -1,3 +1,5 @@ +use std::collections::HashSet; + use crate::structs; use crate::utils::*; @@ -240,7 +242,19 @@ pub fn gen_dr_operand_kinds(grammar: &[structs::OperandKind]) -> TokenStream { }; let kind_enum = { - let kinds = kind_and_ty.iter().map(|(kind, ty)| quote! {#kind(#ty)}); + let mut types_seen = HashSet::new(); + + // To prevent ambiguity we don't want to generate an implementation for `Word` at all: + types_seen.insert(quote!(spirv::Word).to_string()); + + let kinds = kind_and_ty.iter().map(|(kind, ty)| { + let v = quote!(#kind(#ty)); + if types_seen.insert(ty.to_string()) { + v + } else { + quote!(#[from(ignore)] #v) + } + }); quote! { #[doc = "Data representation of a SPIR-V operand."] #[derive(Clone, Debug, PartialEq, From)] diff --git a/autogen/src/sr.rs b/autogen/src/sr.rs index 6bfe12fe..14f935aa 100644 --- a/autogen/src/sr.rs +++ b/autogen/src/sr.rs @@ -235,11 +235,10 @@ pub fn gen_sr_code_from_operand_kind_grammar( }) .collect(); let tokens = quote! { - use derive_more::From; use spirv; /// SPIR-V decorations. - #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord, From)] + #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] pub enum Decoration { #( #enumerants ),* } diff --git a/rspirv/Cargo.toml b/rspirv/Cargo.toml index 93714eea..58184352 100644 --- a/rspirv/Cargo.toml +++ b/rspirv/Cargo.toml @@ -19,7 +19,7 @@ travis-ci = { repository = "gfx-rs/rspirv" } [dependencies] clippy = { version = "0.0", optional = true } -derive_more = "0.15" +derive_more = "0.99" fxhash = "0.2" num-traits = "0.2" diff --git a/rspirv/dr/autogen_operand.rs b/rspirv/dr/autogen_operand.rs index 02bcbc54..05549ff3 100644 --- a/rspirv/dr/autogen_operand.rs +++ b/rspirv/dr/autogen_operand.rs @@ -40,13 +40,17 @@ pub enum Operand { RayQueryIntersection(spirv::RayQueryIntersection), RayQueryCommittedIntersectionType(spirv::RayQueryCommittedIntersectionType), RayQueryCandidateIntersectionType(spirv::RayQueryCandidateIntersectionType), + #[from(ignore)] IdMemorySemantics(spirv::Word), + #[from(ignore)] IdScope(spirv::Word), + #[from(ignore)] IdRef(spirv::Word), LiteralInt32(u32), LiteralInt64(u64), LiteralFloat32(f32), LiteralFloat64(f64), + #[from(ignore)] LiteralExtInstInteger(u32), LiteralSpecConstantOpInteger(spirv::Op), LiteralString(String), diff --git a/rspirv/dr/constructs.rs b/rspirv/dr/constructs.rs index e2112cb6..b1464df1 100644 --- a/rspirv/dr/constructs.rs +++ b/rspirv/dr/constructs.rs @@ -309,13 +309,6 @@ impl<'a> convert::From<&'a str> for Operand { } } -impl convert::From for Operand { - /// Converts the given `u32` `val` into an `Operand::LiteralInt32`. - fn from(val: u32) -> Self { - Operand::LiteralInt32(val) - } -} - #[cfg(test)] mod tests { use crate::dr; diff --git a/rspirv/sr/autogen_decoration.rs b/rspirv/sr/autogen_decoration.rs index ace64096..2c35bd90 100644 --- a/rspirv/sr/autogen_decoration.rs +++ b/rspirv/sr/autogen_decoration.rs @@ -2,10 +2,9 @@ // external/spirv.core.grammar.json. // DO NOT MODIFY! -use derive_more::From; use spirv; #[doc = r" SPIR-V decorations."] -#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord, From)] +#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] pub enum Decoration { RelaxedPrecision, SpecId(u32), diff --git a/spirv/lib.rs b/spirv/lib.rs index fc91afe4..e48e2b88 100644 --- a/spirv/lib.rs +++ b/spirv/lib.rs @@ -12,6 +12,5 @@ #![cfg_attr(rustfmt, rustfmt_skip)] use bitflags::bitflags; -use num_traits; include!("autogen_spirv.rs");