Skip to content
Merged
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
10 changes: 6 additions & 4 deletions rust/src/tls_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@ use std::sync::Once;

static TLS_INIT: Once = Once::new();

#[cfg(all(feature = "tls-rustls", feature = "tls-native-tls"))]
compile_error!("features `tls-rustls` and `tls-native-tls` are mutually exclusive");

#[cfg(not(any(feature = "tls-rustls", feature = "tls-native-tls")))]
compile_error!("one TLS feature must be enabled: `tls-native-tls` (default) or `tls-rustls`");
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that the mutual-exclusion compile_error! was removed, enabling both tls-native-tls and tls-rustls becomes valid and tls-rustls effectively wins. The current compile-time error text can be read as requiring exactly one TLS feature; consider clarifying it (e.g., “at least one TLS feature must be enabled; if both are enabled, rustls is used”).

Suggested change
compile_error!("one TLS feature must be enabled: `tls-native-tls` (default) or `tls-rustls`");
compile_error!(
"at least one TLS feature must be enabled: `tls-native-tls` (default) or `tls-rustls`; \
if both are enabled, `tls-rustls` is used"
);

Copilot uses AI. Check for mistakes.

/// Initializes TLS runtime defaults once for the current process.
///
/// With `tls-native-tls` (default), this is a no-op.
/// With `tls-rustls`, installs the aws-lc-rs rustls provider.
///
Comment on lines 8 to +12
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs here describe behavior for tls-native-tls vs tls-rustls, but the implementation now also supports both features simultaneously (with rustls taking precedence). Please document that precedence explicitly so downstream users aren’t surprised when tls-native-tls is enabled but becomes a no-op due to tls-rustls also being enabled.

Copilot uses AI. Check for mistakes.
/// # Panics
///
/// Panics if the `tls-rustls` feature is enabled and the aws-lc-rs
/// crypto provider fails to install.
pub fn ensure_tls_runtime() {
TLS_INIT.call_once(|| {
#[cfg(feature = "tls-rustls")]
Expand All @@ -23,7 +25,7 @@ pub fn ensure_tls_runtime() {
}
}

#[cfg(feature = "tls-native-tls")]
#[cfg(all(feature = "tls-native-tls", not(feature = "tls-rustls")))]
{}
});
}
Loading