Skip to content

Commit 0a2bc0a

Browse files
powerboat9CohenArthur
authored andcommitted
nr2.0: Adjust indentifier expression handling
gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Make sure to return early after a resolution error, improve the resolution error message, fix a typo, handle ambiguous resolutions, and remove an old comment. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery <[email protected]>
1 parent 3c89c31 commit 0a2bc0a

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

gcc/rust/resolve/rust-late-name-resolver-2.0.cc

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -232,21 +232,29 @@ Late::visit (AST::IdentifierExpr &expr)
232232
}
233233
else
234234
{
235-
if (auto typ = ctx.types.get_prelude (expr.get_ident ()))
236-
resolved = typ;
235+
if (auto type = ctx.types.get_prelude (expr.get_ident ()))
236+
{
237+
resolved = type;
238+
}
237239
else
238-
rust_error_at (expr.get_locus (),
239-
"could not resolve identifier expression: %qs",
240-
expr.get_ident ().as_string ().c_str ());
240+
{
241+
rust_error_at (expr.get_locus (), ErrorCode::E0425,
242+
"cannot find value %qs in this scope",
243+
expr.get_ident ().as_string ().c_str ());
244+
return;
245+
}
246+
}
247+
248+
if (resolved->is_ambiguous ())
249+
{
250+
rust_error_at (expr.get_locus (), ErrorCode::E0659, "%qs is ambiguous",
251+
expr.as_string ().c_str ());
252+
return;
241253
}
242254

243255
ctx.map_usage (Usage (expr.get_node_id ()),
244256
Definition (resolved->get_node_id ()));
245257

246-
// in the old resolver, resolutions are kept in the resolver, not the mappings
247-
// :/ how do we deal with that?
248-
// ctx.mappings.insert_resolved_name(expr, resolved);
249-
250258
// For empty types, do we perform a lookup in ctx.types or should the
251259
// toplevel instead insert a name in ctx.values? (like it currently does)
252260
}

gcc/testsuite/rust/compile/nr2/exclude

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
break-rust2.rs
21
canonical_paths1.rs
32
cfg1.rs
43
const_generics_3.rs
5-
const_generics_4.rs
64
feature_rust_attri0.rs
75
generics9.rs
86
issue-1901.rs
@@ -19,7 +17,6 @@ macros/mbe/macro43.rs
1917
macros/mbe/macro6.rs
2018
multiple_bindings1.rs
2119
multiple_bindings2.rs
22-
not_find_value_in_scope.rs
2320
privacy5.rs
2421
privacy8.rs
2522
pub_restricted_1.rs

0 commit comments

Comments
 (0)