diff options
author | Thomas Young <wenzhang5800@gmail.com> | 2021-06-25 12:02:09 +0800 |
---|---|---|
committer | Thomas Young <wenzhang5800@gmail.com> | 2021-06-25 13:11:18 +0800 |
commit | 1a05bb190e5b6a6f45a1a4d448c24a60f82535b1 (patch) | |
tree | 0ccbc8d27c9053d7fa1d5be45b21317a48536128 /gcc | |
parent | 07b7486e2c27a83e5809b246b8c9797c5e69ae72 (diff) | |
download | gcc-1a05bb190e5b6a6f45a1a4d448c24a60f82535b1.zip gcc-1a05bb190e5b6a6f45a1a4d448c24a60f82535b1.tar.gz gcc-1a05bb190e5b6a6f45a1a4d448c24a60f82535b1.tar.bz2 |
borrowed function should not be unreachable function
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/lint/rust-lint-marklive.h | 6 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/torture/borrow_function.rs | 5 |
2 files changed, 11 insertions, 0 deletions
diff --git a/gcc/rust/lint/rust-lint-marklive.h b/gcc/rust/lint/rust-lint-marklive.h index f6d4b09..14364d2 100644 --- a/gcc/rust/lint/rust-lint-marklive.h +++ b/gcc/rust/lint/rust-lint-marklive.h @@ -39,6 +39,11 @@ public: void visit (HIR::PathInExpression &expr) override; void visit (HIR::IdentifierExpr &expr) override; + void visit (HIR::BorrowExpr &expr) override + { + expr.get_expr ().get ()->accept_vis (*this); + } + void visit (HIR::BlockExpr &expr) override { expr.iterate_stmts ([&] (HIR::Stmt *s) mutable -> bool { @@ -50,6 +55,7 @@ public: expr.get_final_expr ().get ()->accept_vis (*this); } } + void visit (HIR::Function &function) override { function.get_definition ().get ()->accept_vis (*this); diff --git a/gcc/testsuite/rust/compile/torture/borrow_function.rs b/gcc/testsuite/rust/compile/torture/borrow_function.rs new file mode 100644 index 0000000..98c6f99 --- /dev/null +++ b/gcc/testsuite/rust/compile/torture/borrow_function.rs @@ -0,0 +1,5 @@ +fn foo() {} + +fn main() { + let _a = &foo; +}
\ No newline at end of file |