]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Use the path location for MetaItemPathExpr
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Fri, 5 Dec 2025 15:55:47 +0000 (16:55 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Wed, 17 Dec 2025 06:20:11 +0000 (07:20 +0100)
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 <pierre-emmanuel.patry@embecosm.com>
gcc/rust/ast/rust-expr.h
gcc/testsuite/rust/compile/issue-4301.rs [new file with mode: 0644]

index 3c36238c6ee6f40ed49b1e4237243e8ceed3b195..55a8df81829314246422e3f52db777fbf8e31ffa 100644 (file)
@@ -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 (file)
index 0000000..a6d524e
--- /dev/null
@@ -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 }