Skip to content

Commit d2f294c

Browse files
committed
compiler: Remove unnecessary StructName::User checks
The node check covers this already.
1 parent 6f15cca commit d2f294c

File tree

7 files changed

+8
-8
lines changed

7 files changed

+8
-8
lines changed

api/node/rust/interpreter/component_compiler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl JsComponentCompiler {
114114
pub fn structs(&self, env: Env) -> HashMap<String, JsUnknown> {
115115
fn convert_type(env: &Env, ty: &Type) -> Option<(String, JsUnknown)> {
116116
match ty {
117-
Type::Struct(s) if s.name.is_some() && s.node.is_some() => {
117+
Type::Struct(s) if s.node.is_some() => {
118118
let name = s.name.slint_name().unwrap();
119119
let struct_instance = to_js_unknown(
120120
env,

api/python/slint/interpreter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ impl CompilationResult {
183183

184184
for struct_or_enum in self.result.structs_and_enums(i_slint_core::InternalToken {}) {
185185
match struct_or_enum {
186-
Type::Struct(s) if s.name.is_some() && s.node.is_some() => {
186+
Type::Struct(s) if s.node.is_some() => {
187187
let struct_instance =
188188
self.type_collection.struct_to_py(slint_interpreter::Struct::from_iter(
189189
s.fields.iter().map(|(name, field_type)| {

internal/compiler/generator/cpp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ pub fn generate_types(used_types: &[Type], config: &Config) -> File {
921921

922922
for ty in used_types {
923923
match ty {
924-
Type::Struct(s) if s.name.is_some() && s.node.is_some() => {
924+
Type::Struct(s) if s.node.is_some() => {
925925
generate_struct(&mut file, &s.name, &s.fields, s.node.as_ref().unwrap());
926926
}
927927
Type::Enumeration(en) => {
@@ -4344,7 +4344,7 @@ pub fn generate_type_aliases(file: &mut File, doc: &Document) {
43444344
Some((&export.0.name, component.id.clone()))
43454345
}
43464346
Either::Right(ty) => match &ty {
4347-
Type::Struct(s) if s.name.is_some() && s.node.is_some() => {
4347+
Type::Struct(s) if s.node.is_some() => {
43484348
Some((&export.0.name, s.name.cpp_type().unwrap()))
43494349
}
43504350
Type::Enumeration(en) => Some((&export.0.name, en.name.clone())),

internal/compiler/generator/cpp_live_preview.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ fn convert_from_value_fn(ty: &Type) -> String {
500500
fn generate_value_conversions(file: &mut File, structs_and_enums: &[Type]) {
501501
for ty in structs_and_enums {
502502
match ty {
503-
Type::Struct(s) if s.name.is_some() && s.node.is_some() => {
503+
Type::Struct(s) if s.node.is_some() => {
504504
let StructName::User(struct_name) = &s.name else {
505505
return;
506506
};

internal/compiler/generator/rust.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3645,7 +3645,7 @@ pub fn generate_named_exports(exports: &crate::object_tree::Exports) -> Vec<Toke
36453645
}
36463646
}
36473647
Either::Right(ty) => match &ty {
3648-
Type::Struct(s) if s.name.is_some() && s.node.is_some() => {
3648+
Type::Struct(s) if s.node.is_some() => {
36493649
if let StructName::User(user_name) = &s.name
36503650
&& *user_name == export.0.name
36513651
{

internal/interpreter/dynamic_item_tree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,7 @@ pub async fn load(
950950
Some((&export.0.name, &component.id))
951951
}
952952
Either::Right(ty) => match &ty {
953-
Type::Struct(s) if s.name.is_some() && s.node.is_some() => {
953+
Type::Struct(s) if s.node.is_some() => {
954954
if let StructName::User(user_name) = &s.name {
955955
Some((&export.0.name, user_name))
956956
} else {

tools/lsp/language.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,7 @@ fn get_document_symbols(
12531253
.collect::<Vec<_>>();
12541254

12551255
r.extend(inner_types.iter().filter_map(|c| match c {
1256-
Type::Struct(s) if s.name.is_some() && s.node.is_some() => Some(DocumentSymbol {
1256+
Type::Struct(s) if s.node.is_some() => Some(DocumentSymbol {
12571257
range: util::node_to_lsp_range(
12581258
s.node.as_ref().unwrap().parent().as_ref()?,
12591259
document_cache.format,

0 commit comments

Comments
 (0)