| Message ID | 20261104111607.3871038-14-dkm+gcc@kataplop.net |
|---|---|
| State | New |
| Headers | show |
| Series | Upstreaming changes from Oct 29th to Nov 3rd | expand |
diff --git a/gcc/rust/resolve/rust-forever-stack.hxx b/gcc/rust/resolve/rust-forever-stack.hxx index 00d2d6ce448..715e04e2edc 100644 --- a/gcc/rust/resolve/rust-forever-stack.hxx +++ b/gcc/rust/resolve/rust-forever-stack.hxx @@ -494,6 +494,13 @@ ForeverStack<N>::find_starting_point ( if (seg.is_crate_path_seg ()) { + if (path.has_opening_scope ()) + { + collect_errors.emplace_back (seg.locus, ErrorCode::E0433, + "global paths cannot start with %qs", + seg.name.c_str ()); + return tl::nullopt; + } starting_point = root; insert_segment_resolution (Usage (seg.node_id), Definition (starting_point.get ().id), N); diff --git a/gcc/testsuite/rust/compile/extern_prelude_crate_keyword.rs b/gcc/testsuite/rust/compile/extern_prelude_crate_keyword.rs new file mode 100644 index 00000000000..bdc8dadbcf8 --- /dev/null +++ b/gcc/testsuite/rust/compile/extern_prelude_crate_keyword.rs @@ -0,0 +1,7 @@ +#![feature(no_core)] +#![no_core] + +use ::crate::Grey as Gray; +// { dg-error "global paths cannot start with .crate." "" { target *-*-* } .-1 } + +pub struct Grey;