Skip to content
This repository was archived by the owner on May 12, 2022. It is now read-only.

Commit e2fc581

Browse files
committed
fix(designer): recognize isize and usize as primitive types
Addresses the problem in which they were interpreted as crate names (as in `::isize` and `::usize`).
1 parent 2a6f6a6 commit e2fc581

File tree

5 files changed

+30
-1
lines changed

5 files changed

+30
-1
lines changed

tcw3/designer/src/codegen/resolve.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ fn is_path_rooted_or_crate(path: &Path) -> bool {
250250
fn is_builtin_type_ident(ident: &Ident) -> bool {
251251
[
252252
"i8", "i16", "i32", "i64", "i128", "u8", "u16", "u32", "u64", "u128", "f32", "f64", "bool",
253-
"char", "str",
253+
"char", "str", "usize", "isize",
254254
]
255255
.iter()
256256
.any(|&s| *ident == s)

tcw3/designer/tests_impl/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ mod interop {
2525
mod misc {
2626
mod exprpath;
2727
mod genericresolve;
28+
mod primitives;
2829
mod weakref;
2930
}
3031

tcw3/designer/tests_impl/lib.tcwdl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import!("func/inline.tcwdl");
66
import!("interop/builder_simple.tcwdl");
77
import!("misc/exprpath.tcwdl");
88
import!("misc/genericresolve.tcwdl");
9+
import!("misc/primitives.tcwdl");
910
import!("misc/weakref.tcwdl");
1011
import!("objinit/alias.tcwdl");
1112
import!("objinit/shorthand.tcwdl");
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#![allow(dead_code)]
2+
3+
designer_impl! { crate::misc::primitives::Comp }
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
use tcw3::pal;
2+
3+
comp crate::misc::primitives::Comp {
4+
const wm: pal::Wm { set; }
5+
6+
// Primitive types should be treated as-is and shouldn't be
7+
prop f_bool: bool = false;
8+
prop f_char: char = 'x';
9+
prop f_f32: f32 = 0.0;
10+
prop f_f64: f64 = 0.0;
11+
prop f_i128: i128 = 0;
12+
prop f_i16: i16 = 0;
13+
prop f_i32: i32 = 0;
14+
prop f_i64: i64 = 0;
15+
prop f_i8: i8 = 0;
16+
prop f_isize: isize = 0;
17+
prop f_str: Box<str> = String::new().into_boxed_str();
18+
prop f_u128: u128 = 0;
19+
prop f_u16: u16 = 0;
20+
prop f_u32: u32 = 0;
21+
prop f_u64: u64 = 0;
22+
prop f_u8: u8 = 0;
23+
prop f_usize: usize = 0;
24+
}

0 commit comments

Comments
 (0)