aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKushal Pal <kushalpal109@gmail.com>2024-07-09 10:37:27 +0000
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-19 15:32:02 +0100
commit37941c99df7cd15022ec27260cb7bc5de34dee98 (patch)
treedc9ebffc448b8042de5f41b4bc77acb0a56f78b3
parentb40b7afc3c030cbcfab5a4caacf86f08f7c38e46 (diff)
downloadgcc-37941c99df7cd15022ec27260cb7bc5de34dee98.zip
gcc-37941c99df7cd15022ec27260cb7bc5de34dee98.tar.gz
gcc-37941c99df7cd15022ec27260cb7bc5de34dee98.tar.bz2
gccrs: Add location to BIR::Loan
This commit adds location_t to BIR::Loan, this location will point to location is source code where the borrow occured, this information will be useful for reporting borrow-checking errors. gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-builder-internal.h: Fill location for loan. * checks/errors/borrowck/rust-bir-place.h (struct Loan): Add location field. Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
-rw-r--r--gcc/rust/checks/errors/borrowck/rust-bir-builder-internal.h5
-rw-r--r--gcc/rust/checks/errors/borrowck/rust-bir-place.h1
2 files changed, 4 insertions, 2 deletions
diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-builder-internal.h b/gcc/rust/checks/errors/borrowck/rust-bir-builder-internal.h
index 46f811e..16fcb6a 100644
--- a/gcc/rust/checks/errors/borrowck/rust-bir-builder-internal.h
+++ b/gcc/rust/checks/errors/borrowck/rust-bir-builder-internal.h
@@ -307,7 +307,7 @@ protected: // Helpers to add BIR statements
location_t location)
{
auto mutability = ty->as<const TyTy::ReferenceType> ()->mutability ();
- auto loan = ctx.place_db.add_loan ({mutability, place_id});
+ auto loan = ctx.place_db.add_loan ({mutability, place_id, location});
push_tmp_assignment (new BorrowExpr (place_id, loan,
ctx.place_db.get_next_free_region ()),
ty, location);
@@ -600,7 +600,8 @@ protected:
{
// TODO: deduplicate with borrow_place
auto loan = ctx.place_db.add_loan (
- {ty->as<const TyTy::ReferenceType> ()->mutability (), place_id});
+ {ty->as<const TyTy::ReferenceType> ()->mutability (), place_id,
+ location});
return_expr (new BorrowExpr (place_id, loan,
ctx.place_db.get_next_free_region ()),
ty, location);
diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-place.h b/gcc/rust/checks/errors/borrowck/rust-bir-place.h
index 8c38e8e..66da3da 100644
--- a/gcc/rust/checks/errors/borrowck/rust-bir-place.h
+++ b/gcc/rust/checks/errors/borrowck/rust-bir-place.h
@@ -162,6 +162,7 @@ struct Loan
{
Mutability mutability;
PlaceId place;
+ location_t location;
};
/** Allocated places and keeps track of paths. */