From: Pierre-Emmanuel Patry <[email protected]>
Previously we aborted when querying the location on a MetaItemPathExpr,
the location should start on the path and continue over the expr but we
do not support that kind of location range yet.
gcc/rust/ChangeLog:
* ast/rust-expr.h: Use path locus.
gcc/testsuite/ChangeLog:
* rust/compile/issue-4301.rs: New test.
Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
---
This change was merged into the gccrs repository and is posted here for
upstream visibility and potential drive-by review, as requested by GCC
release managers.
Each commit email contains a link to its details on github from where you can
find the Pull-Request and associated discussions.
Commit on github:
https://github.com/Rust-GCC/gccrs/commit/3b283cc2a4b7a703e7acd17a850032c5b24a0358
The commit has been mentioned in the following pull-request(s):
- https://github.com/Rust-GCC/gccrs/pull/4324
gcc/rust/ast/rust-expr.h | 10 +---------
gcc/testsuite/rust/compile/issue-4301.rs | 3 +++
2 files changed, 4 insertions(+), 9 deletions(-)
create mode 100644 gcc/testsuite/rust/compile/issue-4301.rs
diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h
index 3c36238c6..55a8df818 100644
--- a/gcc/rust/ast/rust-expr.h
+++ b/gcc/rust/ast/rust-expr.h
@@ -294,15 +294,7 @@ public:
return MetaItem::ItemKind::PathExpr;
}
- // There are two Locations in MetaItemPathExpr (path and expr),
- // we have no idea use which of them, just simply return UNKNOWN_LOCATION
- // now.
- // Maybe we will figure out when we really need the location in the future.
- location_t get_locus () const override
- {
- rust_unreachable ();
- return UNKNOWN_LOCATION;
- }
+ location_t get_locus () const override { return path.get_locus (); }
void accept_vis (ASTVisitor &vis) override;
diff --git a/gcc/testsuite/rust/compile/issue-4301.rs
b/gcc/testsuite/rust/compile/issue-4301.rs
new file mode 100644
index 000000000..a6d524ed8
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-4301.rs
@@ -0,0 +1,3 @@
+#![feature(unused_variables, server = b"\0")]
+// { dg-error {unknown feature .server = .} "" { target *-*-* } .-1 }
+// { dg-error {unknown feature .unused_variables.} "" { target *-*-* } .-2 }
base-commit: 40765b86cc37cd0ab4a1b6ca4d6803fc3671d3b0
--
2.52.0