Skip to content

Commit fed0407

Browse files
authored
Merge pull request #3774 from Ten0/fix_auto_type_underscore_int_litterals
Fix underscore support in int litterals with auto_type
2 parents 748f4b7 + 92ca0af commit fed0407

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

dsl_auto_type/src/auto_type/expression_type_inference.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -312,12 +312,14 @@ impl TypeInferrer<'_> {
312312

313313
fn litteral_type(t: &proc_macro2::Literal) -> Result<syn::Type, syn::Error> {
314314
let val = t.to_string();
315-
let type_suffix = &val[val.find(|c: char| !c.is_ascii_digit()).ok_or_else(|| {
316-
syn::Error::new_spanned(
317-
t,
318-
format_args!("Litterals must have type suffix for auto_type, e.g. {val}i64"),
319-
)
320-
})?..];
315+
let type_suffix = &val[val
316+
.find(|c: char| !c.is_ascii_digit() && c != '_')
317+
.ok_or_else(|| {
318+
syn::Error::new_spanned(
319+
t,
320+
format_args!("Litterals must have type suffix for auto_type, e.g. {val}i64"),
321+
)
322+
})?..];
321323
syn::parse_str(type_suffix)
322324
.map_err(|_| syn::Error::new_spanned(t, "Invalid type suffix for litteral"))
323325
}

0 commit comments

Comments
 (0)