Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion crates/libs/bindgen/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ pub struct Config<'a> {
pub sys_fn_extern: bool,
pub implement: bool,
pub implements: &'a Implements,
pub noexcept: bool,
pub specific_deps: bool,
pub derive: &'a Derive,
pub link: &'a str,
Expand Down
20 changes: 0 additions & 20 deletions crates/libs/bindgen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ pub fn builder() -> Bindgen {
/// | `--minimal` | Generates minimal-mode bindings: drops per-class wrapper methods and inherited interface forwarders to reduce build time. Mutually exclusive with `--sys`. |
/// | `--implement` | Includes implementation traits for WinRT interfaces. |
/// | `--implements` | Includes implementation traits for the listed types only. |
/// | `--noexcept` | Assumes all WinRT methods do not raise exceptions. |
/// | `--link` | Overrides the default `windows-link` implementation for system calls. |
///
///
Expand Down Expand Up @@ -371,9 +370,6 @@ where
builder.implement();
}
"--implements" => kind = ArgKind::Implements,
"--noexcept" => {
builder.noexcept();
}
"--specific-deps" => {
builder.specific_deps();
}
Expand Down Expand Up @@ -459,7 +455,6 @@ pub struct Bindgen {
no_toml: bool,
package: bool,
implement: bool,
noexcept: bool,
specific_deps: bool,
sys: bool,
minimal: bool,
Expand Down Expand Up @@ -636,20 +631,6 @@ impl Bindgen {
self
}

/// Assume that all WinRT methods do not raise exceptions, regardless of whether
/// they have the `NoExceptionAttribute`. This causes bindgen to emit infallible
/// signatures for HRESULT-returning WinRT methods, skipping `Result` propagation.
///
/// Methods that genuinely carry `NoExceptionAttribute` use a `debug_assert!` to
/// validate the success contract, since the metadata guarantees they cannot
/// fail. Methods that are only assumed to be infallible because of this flag
/// instead use a real `assert!` so that an unexpected failure is caught even in
/// release builds rather than silently producing a zeroed result.
pub fn noexcept(&mut self) -> &mut Self {
self.noexcept = true;
self
}

/// Use specific crate dependencies rather than `windows-core`.
pub fn specific_deps(&mut self) -> &mut Self {
self.specific_deps = true;
Expand Down Expand Up @@ -859,7 +840,6 @@ impl Bindgen {
sys_fn_extern: self.sys_fn_extern,
implement: self.implement,
implements: &implements,
noexcept: self.noexcept,
specific_deps: self.specific_deps,
link,
warnings: &warnings,
Expand Down
21 changes: 7 additions & 14 deletions crates/libs/bindgen/src/types/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl Method {

pub fn write_upcall(&self, inner: TokenStream, this: bool, config: &Config) -> TokenStream {
let reader = config.reader;
let noexcept = config.noexcept || self.def.has_attribute("NoExceptionAttribute");
let noexcept = self.def.has_attribute("NoExceptionAttribute");

let invoke_args = self.signature
.params
Expand Down Expand Up @@ -146,7 +146,7 @@ impl Method {
named_params: bool,
has_this: bool,
) -> TokenStream {
let noexcept = config.noexcept || self.def.has_attribute("NoExceptionAttribute");
let noexcept = self.def.has_attribute("NoExceptionAttribute");

let params = self.signature.params.iter().map(|p| {
let default_type = p.write_default(config);
Expand Down Expand Up @@ -497,18 +497,11 @@ impl Method {
}
};

let has_noexcept_attr = self.def.has_attribute("NoExceptionAttribute");
let noexcept = config.noexcept || has_noexcept_attr;
// When the method genuinely carries `NoExceptionAttribute` the metadata
// contract guarantees success, so `debug_assert!` is sufficient. When
// `noexcept` is only being assumed because of the `--noexcept` flag we
// have no such guarantee, so use a real `assert!` that survives release
// builds rather than silently returning a zeroed-out value.
let assert_success = if has_noexcept_attr {
quote! { debug_assert!(hresult__.0 == 0); }
} else {
quote! { assert!(hresult__.0 == 0); }
};
let noexcept = self.def.has_attribute("NoExceptionAttribute");
// `NoExceptionAttribute` carries a metadata-level guarantee that the
// method cannot fail, so a `debug_assert!` is sufficient to validate
// the success contract in debug builds.
let assert_success = quote! { debug_assert!(hresult__.0 == 0); };

let return_type = if noexcept {
if self.signature.return_type.is_interface() {
Expand Down
85 changes: 0 additions & 85 deletions crates/tests/fixtures/harness/data/bindgen/noexcept/expected.rs

This file was deleted.

This file was deleted.

7 changes: 0 additions & 7 deletions crates/tests/fixtures/harness/data/bindgen/noexcept/input.rdl

This file was deleted.

5 changes: 0 additions & 5 deletions crates/tests/fixtures/harness/tests/fixtures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ struct FixtureConfig {
no_allow: bool,
no_comment: bool,
minimal: bool,
noexcept: bool,
specific_deps: bool,
implement: bool,
implements: Vec<String>,
Expand Down Expand Up @@ -157,7 +156,6 @@ impl FixtureConfig {
"no_allow" => cfg.no_allow = parse_bool(value),
"no_comment" => cfg.no_comment = parse_bool(value),
"minimal" => cfg.minimal = parse_bool(value),
"noexcept" => cfg.noexcept = parse_bool(value),
"specific_deps" => cfg.specific_deps = parse_bool(value),
"implement" => cfg.implement = parse_bool(value),
"implements" => cfg.implements = parse_string_list(value),
Expand Down Expand Up @@ -380,9 +378,6 @@ fn run_bindgen(f: &Fixture) {
if cfg.specific_deps {
bindgen.specific_deps();
}
if cfg.noexcept {
bindgen.noexcept();
}
if cfg.implement {
bindgen.implement();
}
Expand Down
Loading