forked from Rust-GCC/gccrs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gcc/rust/ChangeLog: * checks/errors/borrowck/rust-borrow-checker-diagnostics.cc (BorrowCheckerDiagnostics::report_loan_errors): Add label to where the borrow occurs and where the invalid access occurs. (BorrowCheckerDiagnostics::get_statement): Fetch BIR::Statement from Polonius::Point (BorrowCheckerDiagnostics::get_loan): Fetch BIR::Loan from Polonius::Loan * checks/errors/borrowck/rust-borrow-checker-diagnostics.h: Function definition of helpers. gcc/testsuite/ChangeLog: * rust/borrowck/reference.rs: Test rich errors for borrow-checker. * rust/borrowck/return_ref_to_local.rs: Likewise. * rust/borrowck/tmp.rs: Likewise. * rust/borrowck/use_while_mut.rs: Likewise. * rust/borrowck/use_while_mut_fr.rs: Likewise. * rust/borrowck/well_formed_function_inputs.rs: Likewise. Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
- Loading branch information
1 parent
155f6a9
commit 65bf72f
Showing
8 changed files
with
295 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,17 @@ | ||
// { dg-additional-options "-frust-compile-until=compilation -frust-borrowcheck" } | ||
// { dg-additional-options "-frust-compile-until=compilation -frust-borrowcheck -fdiagnostics-show-caret -fdiagnostics-show-line-numbers" } | ||
// { dg-enable-nn-line-numbers "" } | ||
|
||
pub fn return_ref_to_local() -> &'static i32 { // { dg-error "Found loan errors in function return_ref_to_local" } | ||
pub fn return_ref_to_local() -> &'static i32 { | ||
let x = 0; | ||
&x //~ ERROR | ||
// { dg-error "use of borrowed value" "" { target *-*-* } .-1 } | ||
/* | ||
{ dg-begin-multiline-output "" } | ||
NN | &x //~ ERROR | ||
| ^ | ||
| | | ||
| borrow occurs here | ||
| borrowed value used here | ||
{ dg-end-multiline-output "" } | ||
*/ | ||
} |
Oops, something went wrong.