]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Adjust segment start position errors
authorOwen Avery <powerboat9.gamer@gmail.com>
Thu, 17 Apr 2025 20:51:21 +0000 (16:51 -0400)
committerArthur Cohen <arthur.cohen@embecosm.com>
Mon, 28 Apr 2025 14:18:54 +0000 (16:18 +0200)
gcc/rust/ChangeLog:

* resolve/rust-ast-resolve-path.cc
(ResolvePath::resolve_path): Adjust error messages.
* resolve/rust-ast-resolve-type.cc
(ResolveRelativeTypePath::go): Likewise.
* resolve/rust-forever-stack.hxx
(check_leading_kw_at_start): Likewise.

gcc/testsuite/ChangeLog:

* rust/compile/issue-3568.rs: Adjust expected errors.
* rust/compile/name_resolution9.rs: Likewise.
* rust/compile/self-path2.rs: Likewise.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
gcc/rust/resolve/rust-ast-resolve-path.cc
gcc/rust/resolve/rust-ast-resolve-type.cc
gcc/rust/resolve/rust-forever-stack.hxx
gcc/testsuite/rust/compile/issue-3568.rs
gcc/testsuite/rust/compile/name_resolution9.rs
gcc/testsuite/rust/compile/self-path2.rs

index 530926d5d97a5bd6f47a436db33dd5d4522da066..fb6715d9528a5f14db62bec4abd5dee2127ccb9a 100644 (file)
@@ -68,8 +68,7 @@ ResolvePath::resolve_path (AST::PathInExpression &expr)
       if (in_middle_of_path && segment.is_lower_self_seg ())
        {
          rust_error_at (segment.get_locus (), ErrorCode::E0433,
-                        "leading path segment %qs can only be used at the "
-                        "beginning of a path",
+                        "%qs in paths can only be used in start position",
                         segment.as_string ().c_str ());
          return UNKNOWN_NODEID;
        }
@@ -372,8 +371,9 @@ ResolvePath::resolve_path (AST::SimplePath &expr)
        {
          if (!is_first_segment)
            {
-             rust_error_at (segment.get_locus (),
-                            "%<super%> can only be used in start position");
+             rust_error_at (
+               segment.get_locus (), ErrorCode::E0433,
+               "%<super%> in paths can only be used in start position");
              return UNKNOWN_NODEID;
            }
          if (module_scope_id == crate_scope_id)
index 606141cc8760dfaaae3c115a136cc0ce71353998..8fd69c3ead6a3b696be8781e30e48e1c46394d96 100644 (file)
@@ -176,8 +176,7 @@ ResolveRelativeTypePath::go (AST::TypePath &path, NodeId &resolved_node_id)
          if (in_middle_of_path && segment->is_lower_self_seg ())
            {
              rust_error_at (segment->get_locus (), ErrorCode::E0433,
-                            "leading path segment %qs can only be used at the "
-                            "beginning of a path",
+                            "%qs in paths can only be used in start position",
                             segment->as_string ().c_str ());
              return false;
            }
index 73c795668d9a487c131f1672e5a1af6e3c85c9d5..31a33016f099fe4b0eeb8162c26f99b6aead5aa9 100644 (file)
@@ -401,10 +401,9 @@ static inline bool
 check_leading_kw_at_start (const S &segment, bool condition)
 {
   if (condition)
-    rust_error_at (
-      segment.get_locus (), ErrorCode::E0433,
-      "leading path segment %qs can only be used at the beginning of a path",
-      segment.as_string ().c_str ());
+    rust_error_at (segment.get_locus (), ErrorCode::E0433,
+                  "%qs in paths can only be used in start position",
+                  segment.as_string ().c_str ());
 
   return condition;
 }
index 222a174ef381d29fd4064b57a6ea1cd5c555144d..fef43b5d1e40ad485b706442fa3f768a7ee2c659 100644 (file)
@@ -4,4 +4,4 @@ mod foo {
 }
 
 pub use foo::super::foo::S as T;
-// { dg-error ".super. can only be used in start position" "" { target *-*-* } .-1 }
+// { dg-error ".super. in paths can only be used in start position" "" { target *-*-* } .-1 }
index 93adb46d278a69ebea7d7c21e7f130a1c5336d87..792b3bdd6b5c87f5f89158efde44be3f250859f6 100644 (file)
@@ -6,11 +6,11 @@ pub mod foo {
             super::super::super::foo!(); // { dg-error "too many leading .super. keywords" }
                                          // { dg-error "could not resolve macro invocation" "" { target *-*-* } .-1 }
 
-            super::crate::foo!(); // { dg-error "leading path segment .crate. can only be used" }
+            super::crate::foo!(); // { dg-error ".crate. in paths can only be used" }
                                   // { dg-error "could not resolve macro invocation" "" { target *-*-* } .-1 }
 
                        
-            crate::foo::bar::super::foo!(); // { dg-error "leading path segment .super. can only be used" }
+            crate::foo::bar::super::foo!(); // { dg-error ".super. in paths can only be used" }
                                                    // { dg-error "could not resolve macro invocation" "" { target *-*-* } .-1 }
         }
     }
index 6441c3328f91b6cc1c041effb80e63182ed4f790..d955ed0071d280d3e01175cfd165c5846230ad3d 100644 (file)
@@ -11,11 +11,11 @@ fn baz() {
     crate::bar();
 
     crate::self::foo();
-    // { dg-error "leading path segment .self. can only be used at the beginning of a path" "" { target *-*-* } .-1 }
+    // { dg-error ".self. in paths can only be used in start position" "" { target *-*-* } .-1 }
 }
 
 type a = foo;
 type b = crate::foo;
 type c = self::foo;
 type d = crate::self::foo;
-// { dg-error "leading path segment .self. can only be used at the beginning of a path" "" { target *-*-* } .-1 }
+// { dg-error ".self. in paths can only be used in start position" "" { target *-*-* } .-1 }