Skip to content

Commit 8c6b550

Browse files
committed
Remove various workarounds that prevented breaking changes
Next release will be a breaking release.
1 parent 29b3b4d commit 8c6b550

File tree

22 files changed

+119
-325
lines changed

22 files changed

+119
-325
lines changed

crates/dispatch2/translation-config.toml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,8 @@ fn.dispatch_data_create_subrange.unsafe = true
255255
fn.dispatch_group_enter.unsafe = true
256256
fn.dispatch_group_leave.unsafe = true
257257

258-
# TODO(breaking): The cleanup handler is run on the queue, so it must be
259-
# Send + Sync.
260-
fn.dispatch_io_create_with_io.unsafe = false
258+
# The cleanup handler is run on the queue, so it must be Send + Sync.
259+
fn.dispatch_io_create_with_io.unsafe = true
261260

262261
# object.h
263262
# NOTE: These work on a raw context pointer, but that's
@@ -297,7 +296,7 @@ fn.dispatch_allow_send_signals.unsafe = true
297296
# All values allowed, negative will return NULL
298297
fn.dispatch_semaphore_create.unsafe = false
299298

300-
# TODO(breaking): Make these unsafe (the handler function must be correct).
301-
fn.dispatch_source_set_event_handler_f.unsafe = false
302-
fn.dispatch_source_set_cancel_handler_f.unsafe = false
303-
fn.dispatch_source_set_registration_handler_f.unsafe = false
299+
# The handler function must be correct.
300+
fn.dispatch_source_set_event_handler_f.unsafe = true
301+
fn.dispatch_source_set_cancel_handler_f.unsafe = true
302+
fn.dispatch_source_set_registration_handler_f.unsafe = true

crates/objc2/src/topics/FRAMEWORKS_CHANGELOG.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,22 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
2828

2929
Breaking changes are noted elsewhere in this changelog entry.
3030
* Changed the value of `kUSBHostPortPropertyPortNumber`.
31-
32-
### Removed
33-
* **BREAKING**: Removed a lot of deprecated function aliases. Use the methods instead.
3431
* **BREAKING**: Fixed a bunch of nullability and generics information in:
3532
- `CoreFoundation` / `objc2-core-foundation`.
3633
- `CoreGraphics` / `objc2-core-graphics`.
3734
- `CoreText` / `objc2-core-text`.
3835
- `SystemConfiguration` / `objc2-system-configuration`.
36+
* **BREAKING**: Made `NSWindow::delegate`/`NSWindow::setDelegate` `unsafe`, it breaks type-safety if used together with `NSSavePanel`.
37+
38+
### Removed
39+
* **BREAKING**: Removed a lot of deprecated function aliases. Use the methods instead.
3940
* **BREAKING**: Removed `MTLAutoreleased*` typedefs.
4041
* **BREAKING**: Removed `UIButtonConfiguration::tintedGlassButtonConfiguration`.
4142
* **BREAKING**: Removed `UIDocumentBrowserAction::imageOnlyForContextMenu` and
4243
`UIDocumentBrowserAction::setImageOnlyForContextMenu`.
4344
* **BREAKING**: Removed `ColorSyncProfile::tag_count`.
4445
* **BREAKING**: Removed `HMErrorCode::QuotaExceeded`.
46+
* **BREAKING**: Removed `NSStatusBar::new`.
4547

4648
### Fixed
4749
* Fixed the encoding check in `NSUUID` methods.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
use objc2_core_foundation::cf_type;
2+
3+
#[allow(dead_code)]
4+
struct TISInputSource {}
5+
6+
// Test old syntax still works (used by dependencies).
7+
cf_type!(
8+
#[encoding_name = "__TISInputSource"]
9+
unsafe impl TISInputSource {}
10+
);
11+
12+
fn main() {}

crates/test-ui/ui/cf_type_old_syntax.stderr

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/app/hello_world_app.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ define_class!(
108108
view.addSubview(&text_field);
109109
window.center();
110110
window.setContentMinSize(NSSize::new(300.0, 300.0));
111-
window.setDelegate(Some(ProtocolObject::from_ref(self)));
111+
unsafe { window.setDelegate(Some(ProtocolObject::from_ref(self))) };
112112

113113
// Show the window.
114114
window.makeKeyAndOrderFront(None);

framework-crates/objc2-app-kit/translation-config.toml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,9 @@ class.NSColorSampler.methods."showSamplerWithSelectionHandler:".unsafe = true
304304
# Rust's minimum supported macOS version, so that's fine.
305305
class.NSOutlineView.methods."setStronglyReferencesItems:".unsafe = true
306306

307-
# TODO(breaking): These crash, should probably be skipped (and marked
308-
# `NS_UNAVAILABLE` in the header).
309-
class.NSStatusBar.methods.new.unsafe = true
310-
class.NSStatusBar.methods.init.unsafe = true
307+
# These crash, should probably be marked `NS_UNAVAILABLE` in the header.
308+
class.NSStatusBar.methods.new.skipped = true
309+
class.NSStatusBar.methods.init.skipped = true
311310

312311
# Incorrectly overwritten, breaks type-safety.
313312
class.NSTableView.methods.dataSource.unsafe = true
@@ -326,8 +325,7 @@ class.NSTextContentStorage.methods."setDelegate:".unsafe = true
326325
class.NSTextContentManager.methods."setDelegate:".unsafe = true
327326
class.NSSavePanel.methods.delegate.unsafe = true
328327
class.NSSavePanel.methods."setDelegate:".unsafe = true
329-
# TODO(breaking): Mark this unsafe (or allow delegate protocols to break type-safety).
330-
class.NSWindow.methods.delegate.unsafe = false
331-
class.NSWindow.methods."setDelegate:".unsafe = false
328+
class.NSWindow.methods.delegate.unsafe = true
329+
class.NSWindow.methods."setDelegate:".unsafe = true
332330
class.NSComboButton.methods."setMenu:".unsafe = true
333331
class.NSResponder.methods."setMenu:".unsafe = true

framework-crates/objc2-core-data/Cargo.modified.toml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,3 @@ gnustep-1-8 = []
44
gnustep-1-9 = []
55
gnustep-2-0 = []
66
gnustep-2-1 = []
7-
8-
# TODO(breaking): Remove this
9-
NSFetchedResultsController = [
10-
"objc2-foundation/NSArray",
11-
"objc2-foundation/NSError",
12-
"objc2-foundation/NSIndexPath",
13-
"objc2-foundation/NSOrderedCollectionDifference",
14-
"objc2-foundation/NSString",
15-
"NSFetchRequest",
16-
]
17-
NSPersistentStoreResult = [
18-
"objc2-foundation/NSArray",
19-
"objc2-foundation/NSError",
20-
"objc2-foundation/NSProgress",
21-
"NSFetchRequest",
22-
]

framework-crates/objc2-core-data/Cargo.toml

Lines changed: 12 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

framework-crates/objc2-core-foundation/src/cf_type.rs

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#[macro_export]
3030
macro_rules! cf_type {
3131
(
32-
$(#[encoding_name = $encoding_name:literal])? // TODO(breaking): Remove this.
3332
unsafe impl $(<$($generic:ident : ?$sized:ident),* $(,)?>)? $ty:ident $(<$($generic_param:ident),* $(,)?>)? $(: $superclass:ty)? {}
3433
) => {
3534
// Reflexive AsRef impl.
@@ -90,12 +89,6 @@ macro_rules! cf_type {
9089
$crate::__cf_macro_helpers::fmt::Debug::fmt(this, f)
9190
}
9291
}
93-
94-
// Objective-C interop
95-
$crate::__cf_type_objc2!(
96-
impl ($(<$($generic : ?$sized),*>)?) $ty $(<$($generic_param),*>)?;
97-
$($encoding_name)?
98-
);
9992
};
10093
}
10194

@@ -151,40 +144,3 @@ macro_rules! __cf_type_superclass {
151144
}
152145
};
153146
}
154-
155-
#[doc(hidden)]
156-
#[macro_export]
157-
macro_rules! __cf_type_no_superclass {
158-
(impl ($($generics:tt)*) $ty:ty) => {};
159-
}
160-
161-
#[cfg(feature = "objc2")]
162-
#[doc(hidden)]
163-
#[macro_export]
164-
macro_rules! __cf_type_objc2 {
165-
(impl ($($generics:tt)*) $ty:ty;) => {};
166-
(impl ($($generics:tt)*) $ty:ty; $encoding:literal) => {
167-
$crate::__cf_macro_helpers::cf_objc2_type!(
168-
unsafe impl $($generics)* RefEncode<$encoding> for $ty {}
169-
);
170-
};
171-
}
172-
173-
#[cfg(not(feature = "objc2"))]
174-
#[doc(hidden)]
175-
#[macro_export]
176-
macro_rules! __cf_type_objc2 {
177-
($($t:tt)*) => {};
178-
}
179-
180-
#[cfg(test)]
181-
mod tests {
182-
#[allow(dead_code)]
183-
struct TISInputSource {}
184-
185-
// Test old syntax still works (used by dependencies).
186-
cf_type!(
187-
#[encoding_name = "__TISInputSource"]
188-
unsafe impl TISInputSource {}
189-
);
190-
}

framework-crates/objc2-core-text/translation-config.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ const.kMORTLigLastAction.use-value = true
2323
const.kMORXCoverVertical.use-value = true
2424
const.kKERXVertical.use-value = true
2525

26+
# `CTRunDelegateCreate` creates this from a nullable parameter, so this is
27+
# probably also nullable.
28+
fn.CTRunDelegateGetRefCon.return.nullability = "nullable"
29+
2630
##
2731
## Fixing bounds information.
2832
##
@@ -206,10 +210,6 @@ unsafe-default-safety.documentation-is-reviewed = true
206210
# - `CTRunGetStringIndices` takes buffer pointer, so ofc. isn't safe.
207211
unsafe-default-safety.bounds-checked-internally = true
208212

209-
# TODO(breaking): Mark this as nullable? `CTRunDelegateCreate` creates it from
210-
# a nullable parameter.
211-
fn.CTRunDelegateGetRefCon.unsafe = true
212-
213213
# Documents that:
214214
# > The return value is undefined if CTFontCollectionCreateFromAvailableFonts was used to create the collection.
215215
# But that probably isn't language-level UB.

0 commit comments

Comments
 (0)