diff options
author | Owen Avery <powerboat9.gamer@gmail.com> | 2023-06-05 10:41:43 -0400 |
---|---|---|
committer | CohenArthur <arthur.cohen@embecosm.com> | 2023-06-07 08:31:28 +0000 |
commit | 25b40ba2e03c4ff030adb7ce8ce00e5315c46cb3 (patch) | |
tree | ba48eaf0e4682b7958d74b437023fbf1a866d69d /gcc/rust/expand/rust-macro-builtins.cc | |
parent | 12d79b13fc314b349a727b2ab15d4d06270f3496 (diff) | |
download | gcc-25b40ba2e03c4ff030adb7ce8ce00e5315c46cb3.zip gcc-25b40ba2e03c4ff030adb7ce8ce00e5315c46cb3.tar.gz gcc-25b40ba2e03c4ff030adb7ce8ce00e5315c46cb3.tar.bz2 |
Add error message when derive macro is invoked
gcc/rust/ChangeLog:
* expand/rust-macro-builtins.cc: Fix comments.
(MacroBuiltin::proc_macro_builtin): Add error message.
* expand/rust-macro-builtins.h: Fix comments.
gcc/testsuite/ChangeLog:
* rust/compile/derive_macro8.rs: New test.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Diffstat (limited to 'gcc/rust/expand/rust-macro-builtins.cc')
-rw-r--r-- | gcc/rust/expand/rust-macro-builtins.cc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/gcc/rust/expand/rust-macro-builtins.cc b/gcc/rust/expand/rust-macro-builtins.cc index a4e9854..59a1f19 100644 --- a/gcc/rust/expand/rust-macro-builtins.cc +++ b/gcc/rust/expand/rust-macro-builtins.cc @@ -106,7 +106,7 @@ std::unordered_map< {"global_allocator", MacroBuiltin::sorry}, {"cfg_accessible", MacroBuiltin::sorry}, /* Derive builtins do not need a real transcriber, but still need one. It - will however never be called since builtin derive macros get expanded + should however never be called since builtin derive macros get expanded differently, and benefit from knowing on what kind of items they are applied (struct, enums, unions) rather than receiving a list of tokens like regular builtin macros */ @@ -949,9 +949,12 @@ MacroBuiltin::sorry (Location invoc_locus, AST::MacroInvocData &invoc) } AST::Fragment -MacroBuiltin::proc_macro_builtin (Location, AST::MacroInvocData &) +MacroBuiltin::proc_macro_builtin (Location invoc_locus, + AST::MacroInvocData &invoc) { - // nothing to do! + rust_error_at (invoc_locus, "cannot invoke derive macro: %qs", + invoc.get_path ().as_string ().c_str ()); + return AST::Fragment::create_error (); } |