Skip to content

Commit e45b79e

Browse files
uefi-macros: Use a more precise error span
When the macro produces an error due to unnamed arguments, point precisely at the `_` part of the argument, rather than the whole argument including the type.
1 parent b231cbc commit e45b79e

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

uefi-macros/src/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,10 @@ fn get_function_arg_name(f: &ItemFn, arg_index: usize, errors: &mut TokenStream2
190190
Some(pat_ident.ident.clone())
191191
} else {
192192
// The argument is unnamed, i.e. `_`.
193-
errors.append_all(err!(arg.span(), "Entry method's arguments must be named"));
193+
errors.append_all(err!(
194+
arg.pat.span(),
195+
"Entry method's arguments must be named"
196+
));
194197
None
195198
}
196199
} else {

uefi-macros/tests/ui/entry_unnamed_image_arg.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ error: Entry method's arguments must be named
22
--> tests/ui/entry_unnamed_image_arg.rs:8:22
33
|
44
8 | fn unnamed_image_arg(_: Handle, _st: SystemTable<Boot>) -> Status {
5-
| ^^^^^^^^^
5+
| ^

uefi-macros/tests/ui/entry_unnamed_table_arg.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ error: Entry method's arguments must be named
22
--> tests/ui/entry_unnamed_table_arg.rs:8:38
33
|
44
8 | fn unnamed_table_arg(_image: Handle, _: SystemTable<Boot>) -> Status {
5-
| ^^^^^^^^^^^^^^^^^^^^
5+
| ^

0 commit comments

Comments
 (0)