GraphiteEditor/Graphite · error · syn::Error

Unsupported type format

Error message

Unsupported type format

What it means

The context type `C` in `MessageHandler<M, C>` under `#[message_handler_data]` must be one of: a type path, a tuple, or a reference. Any other type shape — arrays (`[u8; 4]`), slices (`[u8]`), pointers (`*const T`), `dyn Trait` trait objects, `impl Trait`, function pointers, or `never` — falls through the match and is rejected.

Source

Thrown at proc-macros/src/message_handler_data_attr.rs:92

								let type_line_number = type_ident.span().start().line;

								let tr = clean_rust_type_syntax(type_reference.to_token_stream().to_string());
								quote! {
									#input_item
									impl #message_type {
										pub fn message_handler_data_str() -> MessageData {
											MessageData::new(format!("{}", #tr), #type_ident::field_types(), #type_ident::path(), #type_ident::line_number())
										}

										pub fn message_handler_str() -> MessageData {
											MessageData::new(format!("{}", stringify!(#input_type)), #input_type::field_types(), #input_type::path(), #input_type::line_number())

										}
									}
								}
							}
							_ => return Err(syn::Error::new(t.span(), "Unsupported type format")),
						}
					}

					_ => quote! {
						#input_item
					},
				};
				return Ok(impl_item);
			}
		}
	}
	Ok(input_item)
}

View on GitHub (pinned to c507b35645)

Solutions

  1. Wrap the unsupported type in a named struct or use the conventional `ToolMessageData` path type as C.
  2. For fixed-size data, prefer a tuple `(u8, u8, u8, u8)` (supported) or a named struct instead of an array.
  3. For dyn contexts, introduce a concrete newtype that implements the abstraction and pass its path.

Example fix

// before
#[message_handler_data]
impl MessageHandler<ToolMessage, [u8; 4]> for MyTool { ... }

// after
#[derive(ExtractField)]
struct ColorContext {
	r: u8, g: u8, b: u8, a: u8,
}
#[message_handler_data]
impl MessageHandler<ToolMessage, ColorContext> for MyTool { ... }
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: Writing `impl MessageHandler<Msg, [u8; 4]> for …`, `impl MessageHandler<Msg, *mut Ctx>`, `impl MessageHandler<Msg, dyn Ctx>` or `impl MessageHandler<Msg, Box<dyn Ctx>>` — Box is a path, but `dyn Ctx` / array / slice / raw-pointer context types hit the catch-all arm.

Common situations: Performance-motivated switches to arrays or raw pointers for context data, or threading `dyn Trait` context objects through the handler in an attempt to abstract over tools.

Related errors


AI-assisted analysis of GraphiteEditor/Graphite@c507b35645 (2026-08-16). Data as JSON: /api/errors/d047f7f7be96445d. Report an issue: GitHub.