Skip to content

Commit e399926

Browse files
committed
rustboot: Report cyclic import errors at the right location
1 parent 2fcf81c commit e399926

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/boot/me/resolve.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ let rec lookup_type_by_name
291291
iflog cx (fun _ ->
292292
log cx "+++ lookup_type_by_name %a"
293293
Ast.sprintf_name name);
294-
match lookup_by_name cx [] scopes name with
294+
match lookup_by_name ?loc:loc cx [] scopes name with
295295
RES_failed name' -> raise (Resolution_failure [ name', name ])
296296
| RES_ok (scopes', id) ->
297297
let ty, params =

src/boot/me/semant.ml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1990,6 +1990,7 @@ let get_name_base_ident
19901990
type loop_check = (node_id * Ast.ident) list;;
19911991

19921992
let rec project_ident_from_items
1993+
?loc:loc
19931994
(cx:ctxt)
19941995
(lchk:loop_check)
19951996
(scopes:scope list)
@@ -2009,7 +2010,7 @@ let rec project_ident_from_items
20092010
in
20102011
let lchk' = (scope_id, ident)::lchk in
20112012
let lchk_strs = List.map string_of_loop_check (List.rev lchk') in
2012-
err (Some scope_id) "cyclic import for ident %s (%s)" ident
2013+
err loc "cyclic import for ident %s (%s)" ident
20132014
(String.concat " -> " lchk_strs)
20142015
else (scope_id, ident)::lchk
20152016
in
@@ -2047,6 +2048,7 @@ and project_name_comp_from_resolved
20472048
project_ident_from_items cx lchk scopes id md ident false
20482049

20492050
and lookup_by_name
2051+
?loc:loc
20502052
(cx:ctxt)
20512053
(lchk:loop_check)
20522054
(scopes:scope list)
@@ -2056,12 +2058,13 @@ and lookup_by_name
20562058
match name with
20572059
Ast.NAME_base nb ->
20582060
let ident = get_name_base_ident nb in
2059-
lookup_by_ident cx lchk scopes ident
2061+
lookup_by_ident ?loc:loc cx lchk scopes ident
20602062
| Ast.NAME_ext (name, ext) ->
20612063
let base_res = lookup_by_name cx lchk scopes name in
20622064
project_name_comp_from_resolved cx lchk base_res ext
20632065

20642066
and lookup_by_ident
2067+
?loc:loc
20652068
(cx:ctxt)
20662069
(lchk:loop_check)
20672070
(scopes:scope list)
@@ -2120,8 +2123,8 @@ and lookup_by_ident
21202123
end
21212124

21222125
| SCOPE_crate crate ->
2123-
project_ident_from_items
2124-
cx lchk scopes crate.id crate.node.Ast.crate_items ident true
2126+
project_ident_from_items ?loc:loc cx lchk
2127+
scopes crate.id crate.node.Ast.crate_items ident true
21252128

21262129
| SCOPE_obj_fn fn ->
21272130
would_capture (check_slots scopes fn.node.Ast.fn_input_slots)
@@ -2137,7 +2140,7 @@ and lookup_by_ident
21372140
check_slots scopes obj.Ast.obj_state
21382141

21392142
| Ast.MOD_ITEM_mod md ->
2140-
project_ident_from_items cx lchk
2143+
project_ident_from_items ?loc:loc cx lchk
21412144
scopes item.id md ident true
21422145

21432146
| _ -> no_such_ident ident

0 commit comments

Comments
 (0)