diff options
author | Kushal Pal <kushalpal109@gmail.com> | 2024-07-26 07:40:58 +0000 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-19 15:32:03 +0100 |
commit | 9bba18fcb828ae2c4c85ba7ec1832923e04d2a75 (patch) | |
tree | 53361a16a9dd2fe35e139107c488cd3cc3c8a190 /gcc/testsuite/rust | |
parent | 6f009aedaff88e359aee82628bccf683315222c6 (diff) | |
download | gcc-9bba18fcb828ae2c4c85ba7ec1832923e04d2a75.zip gcc-9bba18fcb828ae2c4c85ba7ec1832923e04d2a75.tar.gz gcc-9bba18fcb828ae2c4c85ba7ec1832923e04d2a75.tar.bz2 |
gccrs: Subset errors with locations
gcc/rust/ChangeLog:
* checks/errors/borrowck/rust-borrow-checker-diagnostics.cc
(BorrowCheckerDiagnostics::report_subset_errors): Highlight
lifetime locations while reporting subset errors.
(BorrowCheckerDiagnostics::get_lifetime_param): Helper function
to fetch HIR::Lifetime node from Polonius::Origin.
* checks/errors/borrowck/rust-borrow-checker-diagnostics.h:
Definition of helper function.
gcc/testsuite/ChangeLog:
* rust/borrowck/subset.rs: Better subset errors.
Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
Diffstat (limited to 'gcc/testsuite/rust')
-rw-r--r-- | gcc/testsuite/rust/borrowck/subset.rs | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/gcc/testsuite/rust/borrowck/subset.rs b/gcc/testsuite/rust/borrowck/subset.rs index d7c00ca..5b4a663 100644 --- a/gcc/testsuite/rust/borrowck/subset.rs +++ b/gcc/testsuite/rust/borrowck/subset.rs @@ -1,8 +1,19 @@ -// { 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 "" } fn missing_subset<'a, 'b>(x: &'a u32, y: &'b u32) -> &'a u32 { - // { dg-error "Found subset errors in function missing_subset" "" { target *-*-* } .-1 } + // { dg-error "subset error, some lifetime constraints need to be added" "" { target *-*-* } .-1 } y //~ ERROR + /* + { dg-begin-multiline-output "" } + NN | fn missing_subset<'a, 'b>(x: &'a u32, y: &'b u32) -> &'a u32 { + | ^~ ~~ ~~ + | | | | + | | | lifetime defined here + | | lifetime defined here + | subset error occurs in this function + { dg-end-multiline-output "" } + */ } fn missing_subset_fixed<'a, 'b>(x: &'a u32, y: &'b u32) -> &'a u32 where 'b: 'a { @@ -10,12 +21,22 @@ fn missing_subset_fixed<'a, 'b>(x: &'a u32, y: &'b u32) -> &'a u32 where 'b: 'a } fn complex_cfg_subset<'a, 'b>(b: bool, x: &'a u32, y: &'b u32) -> &'a u32 { - // { dg-error "Found subset errors in function complex_cfg_subset" "" { target *-*-* } .-1 } + // { dg-error "subset error, some lifetime constraints need to be added" "" { target *-*-* } .-1 } if b { y //~ ERROR } else { x } + /* + { dg-begin-multiline-output "" } + NN | fn complex_cfg_subset<'a, 'b>(b: bool, x: &'a u32, y: &'b u32) -> &'a u32 { + | ^~ ~~ ~~ + | | | | + | | | lifetime defined here + | | lifetime defined here + | subset error occurs in this function + { dg-end-multiline-output "" } + */ } fn complex_cfg_subset_fixed<'a, 'b>(b: bool, x: &'a u32, y: &'b u32) -> &'a u32 where 'b: 'a { @@ -24,4 +45,4 @@ fn complex_cfg_subset_fixed<'a, 'b>(b: bool, x: &'a u32, y: &'b u32) -> &'a u32 } else { y } -}
\ No newline at end of file +} |