Skip to content

Commit 3b283cc

Browse files
committed
Use the path location for MetaItemPathExpr
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>
1 parent 40765b8 commit 3b283cc

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

gcc/rust/ast/rust-expr.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -294,15 +294,7 @@ class MetaItemPathExpr : public MetaItem
294294
return MetaItem::ItemKind::PathExpr;
295295
}
296296

297-
// There are two Locations in MetaItemPathExpr (path and expr),
298-
// we have no idea use which of them, just simply return UNKNOWN_LOCATION
299-
// now.
300-
// Maybe we will figure out when we really need the location in the future.
301-
location_t get_locus () const override
302-
{
303-
rust_unreachable ();
304-
return UNKNOWN_LOCATION;
305-
}
297+
location_t get_locus () const override { return path.get_locus (); }
306298

307299
void accept_vis (ASTVisitor &vis) override;
308300

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#![feature(unused_variables, server = b"\0")]
2+
// { dg-error {unknown feature .server = .} "" { target *-*-* } .-1 }
3+
// { dg-error {unknown feature .unused_variables.} "" { target *-*-* } .-2 }

0 commit comments

Comments
 (0)