public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Arthur Cohen <cohenarthur@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-7989] gccrs: resolver: Refactor assertion Date: Tue, 16 Jan 2024 18:11:26 +0000 (GMT) [thread overview] Message-ID: <20240116181126.794253857B9D@sourceware.org> (raw) https://gcc.gnu.org/g:342b071a0fac00d8acf745348c41afcd48cdb4cb commit r14-7989-g342b071a0fac00d8acf745348c41afcd48cdb4cb Author: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> Date: Mon Aug 28 10:54:12 2023 +0200 gccrs: resolver: Refactor assertion Change the condition with rust_unreachable to an assertion. This will keep the code clean and concise. Some styling issues appeared during review, this commit make the code more readable. gcc/rust/ChangeLog: * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Change to assertion. * util/rust-hir-map.cc (Mappings::lookup_derive_proc_macros): Add empty line. (Mappings::lookup_bang_proc_macros): Likewise. (Mappings::lookup_attribute_proc_macros): Likewise. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> Diff: --- gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc | 5 ++--- gcc/rust/util/rust-hir-map.cc | 3 +++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc index 61252988673..a09c738267e 100644 --- a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc +++ b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc @@ -75,9 +75,8 @@ void TopLevel::visit (AST::ExternCrate &crate) { CrateNum num; - if (!Analysis::Mappings::get ()->lookup_crate_name ( - crate.get_referenced_crate (), num)) - rust_unreachable (); + rust_assert (Analysis::Mappings::get ()->lookup_crate_name ( + crate.get_referenced_crate (), num)); auto attribute_macros = Analysis::Mappings::get ()->lookup_attribute_proc_macros (num); diff --git a/gcc/rust/util/rust-hir-map.cc b/gcc/rust/util/rust-hir-map.cc index 8ac957fd87d..7041aaa9945 100644 --- a/gcc/rust/util/rust-hir-map.cc +++ b/gcc/rust/util/rust-hir-map.cc @@ -978,6 +978,7 @@ Mappings::lookup_derive_proc_macros (CrateNum num) auto it = procmacrosDeriveMappings.find (num); if (it == procmacrosDeriveMappings.end ()) return tl::nullopt; + return it->second; } @@ -987,6 +988,7 @@ Mappings::lookup_bang_proc_macros (CrateNum num) auto it = procmacrosBangMappings.find (num); if (it == procmacrosBangMappings.end ()) return tl::nullopt; + return it->second; } @@ -996,6 +998,7 @@ Mappings::lookup_attribute_proc_macros (CrateNum num) auto it = procmacrosAttributeMappings.find (num); if (it == procmacrosAttributeMappings.end ()) return tl::nullopt; + return it->second; }
reply other threads:[~2024-01-16 18:11 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20240116181126.794253857B9D@sourceware.org \ --to=cohenarthur@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).