diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml index ee292c0137..acb0961d27 100644 --- a/.github/workflows/clippy.yml +++ b/.github/workflows/clippy.yml @@ -137,6 +137,8 @@ jobs: run: cargo clippy -p test_async - name: Clippy test_bcrypt run: cargo clippy -p test_bcrypt + - name: Clippy test_bindgen + run: cargo clippy -p test_bindgen - name: Clippy test_calling_convention run: cargo clippy -p test_calling_convention - name: Clippy test_cfg_generic diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 93cb7fd187..f2d302e115 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -163,6 +163,8 @@ jobs: run: cargo test -p test_async --target ${{ matrix.target }} ${{ matrix.etc }} - name: Test test_bcrypt run: cargo test -p test_bcrypt --target ${{ matrix.target }} ${{ matrix.etc }} + - name: Test test_bindgen + run: cargo test -p test_bindgen --target ${{ matrix.target }} ${{ matrix.etc }} - name: Test test_calling_convention run: cargo test -p test_calling_convention --target ${{ matrix.target }} ${{ matrix.etc }} - name: Test test_cfg_generic @@ -253,10 +255,10 @@ jobs: run: cargo test -p test_registry --target ${{ matrix.target }} ${{ matrix.etc }} - name: Test test_registry_default run: cargo test -p test_registry_default --target ${{ matrix.target }} ${{ matrix.etc }} - - name: Test test_reserved - run: cargo test -p test_reserved --target ${{ matrix.target }} ${{ matrix.etc }} - name: Clean run: cargo clean + - name: Test test_reserved + run: cargo test -p test_reserved --target ${{ matrix.target }} ${{ matrix.etc }} - name: Test test_resources run: cargo test -p test_resources --target ${{ matrix.target }} ${{ matrix.etc }} - name: Test test_result diff --git a/crates/libs/bindgen/Cargo.toml b/crates/libs/bindgen/Cargo.toml index 26490d254f..fb6fe2ee6f 100644 --- a/crates/libs/bindgen/Cargo.toml +++ b/crates/libs/bindgen/Cargo.toml @@ -24,10 +24,6 @@ metadata = [] windows-metadata = { path = "../metadata", version = "0.58.0" } rayon = "1.7" -[dependencies.syn] -version = "2.0" -features = ["full", "extra-traits"] - [dependencies.proc-macro2] version = "1.0" features = ["span-locations"] diff --git a/crates/libs/bindgen/src/error.rs b/crates/libs/bindgen/src/error.rs index 5227f4c213..8ab7acc8ac 100644 --- a/crates/libs/bindgen/src/error.rs +++ b/crates/libs/bindgen/src/error.rs @@ -6,37 +6,13 @@ pub type Result = std::result::Result; pub struct Error { message: String, path: String, - span: Option<(usize, usize)>, -} - -impl std::error::Error for Error {} - -impl From for std::io::Error { - fn from(error: Error) -> Self { - std::io::Error::new(std::io::ErrorKind::Other, error.message.as_str()) - } -} - -impl From for Error { - fn from(error: syn::Error) -> Self { - let start = error.span().start(); - Self { - message: error.to_string(), - span: Some((start.line, start.column)), - ..Self::default() - } - } } impl std::fmt::Display for Error { fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { writeln!(fmt, "error: {}", self.message)?; if !self.path.is_empty() { - if let Some((line, column)) = self.span { - writeln!(fmt, " --> {}:{line}:{column}", self.path)?; - } else { - writeln!(fmt, " --> {}", self.path)?; - } + writeln!(fmt, " --> {}", self.path)?; } Ok(()) } diff --git a/crates/tests/misc/bindgen/Cargo.toml b/crates/tests/misc/bindgen/Cargo.toml new file mode 100644 index 0000000000..98d88840b9 --- /dev/null +++ b/crates/tests/misc/bindgen/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "test_bindgen" +version = "0.0.0" +edition = "2021" +publish = false + +[lib] +doc = false +doctest = false + +[dependencies.windows-bindgen] +workspace = true diff --git a/crates/tests/misc/bindgen/src/lib.rs b/crates/tests/misc/bindgen/src/lib.rs new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/crates/tests/misc/bindgen/src/lib.rs @@ -0,0 +1 @@ + diff --git a/crates/tests/misc/bindgen/tests/tests.rs b/crates/tests/misc/bindgen/tests/tests.rs new file mode 100644 index 0000000000..f5859e3132 --- /dev/null +++ b/crates/tests/misc/bindgen/tests/tests.rs @@ -0,0 +1,13 @@ +#[test] +fn test() { + let e = windows_bindgen::bindgen(["--etc", "file_not_found.txt"]).unwrap_err(); + + assert_eq!( + format!("{e}"), + "error: failed to read lines\n --> file_not_found.txt\n" + ); + + let e = windows_bindgen::bindgen(["-etc"]).unwrap_err(); + + assert_eq!(format!("{e}"), "error: invalid option `-etc`\n"); +}