Skip to content

Commit 5f72ba2

Browse files
committed
fix(perry-ui-gtk4): upcast pango sub-attrs to Attribute (v0.5.889)
PR #716 added crates/perry-ui-gtk4/src/widgets/attributed_text.rs with pango Attribute construction that doesn't compile against the pango-rs sub-attribute type hierarchy. `AttrInt::new_weight()` etc. return concrete subtype (AttrInt, AttrSize, AttrColor); the push closure expects the parent `pango::Attribute`. Need explicit .upcast() per the glib type system. The error didn't surface on #716's CI because the gtk4 doc-tests matrix entry is disabled (v0.5.874 timeouts), and the release build matrix is the only path that builds perry-ui-gtk4 cross-arch. Surfaced on v0.5.888's release run. 5 sites updated. Uses gtk4::glib::object::Cast trait import.
1 parent a8991cd commit 5f72ba2

3 files changed

Lines changed: 14 additions & 9 deletions

File tree

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
88

99
Perry is a native TypeScript compiler written in Rust that compiles TypeScript source code directly to native executables. It uses SWC for TypeScript parsing and LLVM for code generation.
1010

11-
**Current Version:** 0.5.875
11+
**Current Version:** 0.5.889
1212

1313

1414
## TypeScript Parity Status

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ opt-level = "s" # Optimize for size in stdlib
188188
opt-level = 3
189189

190190
[workspace.package]
191-
version = "0.5.875"
191+
version = "0.5.889"
192192
edition = "2021"
193193
license = "MIT"
194194
repository = "https://github.com/PerryTS/perry"

crates/perry-ui-gtk4/src/widgets/attributed_text.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,23 +95,28 @@ pub fn append(
9595
buf.attrs.insert(attr);
9696
};
9797

98+
// pango-rs sub-attribute types (`AttrInt`, `AttrSize`, `AttrColor`)
99+
// are subclasses of `pango::Attribute` in the glib type system.
100+
// `.upcast()` lifts them to the parent type the push closure
101+
// expects. Without the upcast the build fails with E0308
102+
// mismatched-types (introduced in PR #716, surfaced when the
103+
// release-packages workflow built perry-ui-gtk4 cross-arch).
104+
use gtk4::glib::object::Cast;
98105
if bold != 0 {
99-
push(pango::AttrInt::new_weight(pango::Weight::Bold));
106+
push(pango::AttrInt::new_weight(pango::Weight::Bold).upcast());
100107
}
101108
if italic != 0 {
102-
push(pango::AttrInt::new_style(pango::Style::Italic));
109+
push(pango::AttrInt::new_style(pango::Style::Italic).upcast());
103110
}
104111
if underline != 0 {
105-
push(pango::AttrInt::new_underline(pango::Underline::Single));
112+
push(pango::AttrInt::new_underline(pango::Underline::Single).upcast());
106113
}
107114
if font_size > 0.0 {
108-
push(pango::AttrSize::new(
109-
(font_size * pango::SCALE as f64) as i32,
110-
));
115+
push(pango::AttrSize::new((font_size * pango::SCALE as f64) as i32).upcast());
111116
}
112117
if a > 0.0 {
113118
let to16 = |v: f64| (v.clamp(0.0, 1.0) * 65535.0) as u16;
114-
push(pango::AttrColor::new_foreground(to16(r), to16(g), to16(b)));
119+
push(pango::AttrColor::new_foreground(to16(r), to16(g), to16(b)).upcast());
115120
}
116121

117122
label.set_text(&buf.text);

0 commit comments

Comments
 (0)