Skip to content

Commit 5a542c5

Browse files
panglesdjonludlam
authored andcommitted
Consider warnings in occurrence resolving as normal warnings
They used to not be raised, as with non-persistent occurrences, some of them could never be got rid of! Signed-off-by: Paul-Elliot <[email protected]>
1 parent 5516e8e commit 5a542c5

File tree

1 file changed

+25
-146
lines changed

1 file changed

+25
-146
lines changed

src/xref2/link.ml

Lines changed: 25 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,8 @@ and should_resolve : Paths.Path.t -> bool =
135135
(* | `Resolved p -> should_reresolve (p :> Paths.Path.Resolved.t) *)
136136
(* | _ -> true *)
137137

138-
let type_path :
139-
?report_errors:bool -> Env.t -> Paths.Path.Type.t -> Paths.Path.Type.t =
140-
fun ?(report_errors = true) env p ->
138+
let type_path : Env.t -> Paths.Path.Type.t -> Paths.Path.Type.t =
139+
fun env p ->
141140
if not (should_resolve (p :> Paths.Path.t)) then p
142141
else
143142
let cp = Component.Of_Lang.(type_path (empty ()) p) in
@@ -151,13 +150,11 @@ let type_path :
151150
let result = Tools.reresolve_type env p' in
152151
`Resolved Lang_of.(Path.resolved_type (empty ()) result)
153152
| Error e ->
154-
if report_errors then
155-
Errors.report ~what:(`Type_path cp) ~tools_error:e `Lookup;
153+
Errors.report ~what:(`Type_path cp) ~tools_error:e `Lookup;
156154
p)
157155

158-
let value_path :
159-
?report_errors:bool -> Env.t -> Paths.Path.Value.t -> Paths.Path.Value.t =
160-
fun ?(report_errors = true) env p ->
156+
let value_path : Env.t -> Paths.Path.Value.t -> Paths.Path.Value.t =
157+
fun env p ->
161158
if not (should_resolve (p :> Paths.Path.t)) then p
162159
else
163160
let cp = Component.Of_Lang.(value_path (empty ()) p) in
@@ -171,16 +168,12 @@ let value_path :
171168
let result = Tools.reresolve_value env p' in
172169
`Resolved Lang_of.(Path.resolved_value (empty ()) result)
173170
| Error e ->
174-
if report_errors then
175-
Errors.report ~what:(`Value_path cp) ~tools_error:e `Lookup;
171+
Errors.report ~what:(`Value_path cp) ~tools_error:e `Lookup;
176172
p)
177173

178174
let constructor_path :
179-
?report_errors:bool ->
180-
Env.t ->
181-
Paths.Path.Constructor.t ->
182-
Paths.Path.Constructor.t =
183-
fun ?(report_errors = true) env p ->
175+
Env.t -> Paths.Path.Constructor.t -> Paths.Path.Constructor.t =
176+
fun env p ->
184177
(* if not (should_resolve (p : Paths.Path.Constructor.t :> Paths.Path.t)) then p *)
185178
(* else *)
186179
if not (should_resolve_constructor p) then p
@@ -196,16 +189,12 @@ let constructor_path :
196189
let result = Tools.reresolve_constructor env p' in
197190
`Resolved Lang_of.(Path.resolved_constructor (empty ()) result)
198191
| Error e ->
199-
if report_errors then
200-
Errors.report ~what:(`Constructor_path cp) ~tools_error:e `Lookup;
192+
Errors.report ~what:(`Constructor_path cp) ~tools_error:e `Lookup;
201193
p)
202194

203-
let class_type_path :
204-
?report_errors:bool ->
205-
Env.t ->
206-
Paths.Path.ClassType.t ->
207-
Paths.Path.ClassType.t =
208-
fun ?(report_errors = true) env p ->
195+
let class_type_path : Env.t -> Paths.Path.ClassType.t -> Paths.Path.ClassType.t
196+
=
197+
fun env p ->
209198
if not (should_resolve (p :> Paths.Path.t)) then p
210199
else
211200
let cp = Component.Of_Lang.(class_type_path (empty ()) p) in
@@ -219,16 +208,12 @@ let class_type_path :
219208
let result = Tools.reresolve_class_type env p' in
220209
`Resolved Lang_of.(Path.resolved_class_type (empty ()) result)
221210
| Error e ->
222-
if report_errors then
223-
Errors.report ~what:(`Class_type_path cp) ~tools_error:e `Lookup;
211+
Errors.report ~what:(`Class_type_path cp) ~tools_error:e `Lookup;
224212
p)
225213

226214
and module_type_path :
227-
?report_errors:bool ->
228-
Env.t ->
229-
Paths.Path.ModuleType.t ->
230-
Paths.Path.ModuleType.t =
231-
fun ?(report_errors = true) env p ->
215+
Env.t -> Paths.Path.ModuleType.t -> Paths.Path.ModuleType.t =
216+
fun env p ->
232217
if not (should_resolve (p :> Paths.Path.t)) then p
233218
else
234219
let cp = Component.Of_Lang.(module_type_path (empty ()) p) in
@@ -242,13 +227,11 @@ and module_type_path :
242227
let result = Tools.reresolve_module_type env p' in
243228
`Resolved Lang_of.(Path.resolved_module_type (empty ()) result)
244229
| Error e ->
245-
if report_errors then
246-
Errors.report ~what:(`Module_type_path cp) ~tools_error:e `Resolve;
230+
Errors.report ~what:(`Module_type_path cp) ~tools_error:e `Resolve;
247231
p)
248232

249-
and module_path :
250-
?report_errors:bool -> Env.t -> Paths.Path.Module.t -> Paths.Path.Module.t =
251-
fun ?(report_errors = true) env p ->
233+
and module_path : Env.t -> Paths.Path.Module.t -> Paths.Path.Module.t =
234+
fun env p ->
252235
if not (should_resolve (p :> Paths.Path.t)) then p
253236
else
254237
let cp = Component.Of_Lang.(module_path (empty ()) p) in
@@ -263,8 +246,7 @@ and module_path :
263246
`Resolved Lang_of.(Path.resolved_module (empty ()) result)
264247
| Error _ when is_forward p -> p
265248
| Error e ->
266-
if report_errors then
267-
Errors.report ~what:(`Module_path cp) ~tools_error:e `Resolve;
249+
Errors.report ~what:(`Module_path cp) ~tools_error:e `Resolve;
268250
p)
269251

270252
let rec comment_inline_element :
@@ -415,106 +397,6 @@ and open_ env parent = function
415397
| { Odoc_model__Lang.Open.doc; _ } as open_ ->
416398
{ open_ with doc = comment_docs env parent doc }
417399

418-
module Build_env = struct
419-
let rec unit env t =
420-
let open Compilation_unit in
421-
match t.content with
422-
| Module sg ->
423-
let env = signature env sg in
424-
env
425-
| Pack _ -> env
426-
427-
and signature env s =
428-
let env = Env.open_signature s env in
429-
signature_items env s.items
430-
431-
and simple_expansion : Env.t -> ModuleType.simple_expansion -> Env.t =
432-
fun env m ->
433-
match m with
434-
| Signature sg -> signature env sg
435-
| Functor (arg, sg) ->
436-
let env = Env.add_functor_parameter arg env in
437-
let env = functor_argument env arg in
438-
simple_expansion env sg
439-
440-
and functor_argument env a =
441-
match a with
442-
| FunctorParameter.Unit -> env
443-
| Named arg -> functor_parameter_parameter env arg
444-
445-
and functor_parameter_parameter : Env.t -> FunctorParameter.parameter -> Env.t
446-
=
447-
fun env a -> module_type_expr env a.expr
448-
449-
and module_type_expr : Env.t -> ModuleType.expr -> Env.t =
450-
fun env expr ->
451-
let open ModuleType in
452-
match expr with
453-
| Signature s -> signature env s
454-
| Path { p_path = _; p_expansion = Some p_expansion } ->
455-
simple_expansion env p_expansion
456-
| Path { p_path = _; p_expansion = None } -> env
457-
| With _ -> env
458-
| Functor (arg, res) ->
459-
let env = functor_argument env arg in
460-
let env = Env.add_functor_parameter arg env in
461-
let env = module_type_expr env res in
462-
env
463-
| TypeOf { t_expansion = None; _ } -> env
464-
| TypeOf { t_expansion = Some exp; _ } -> simple_expansion env exp
465-
466-
and signature_items : Env.t -> Signature.item list -> Env.t =
467-
fun env s ->
468-
let open Signature in
469-
List.fold_left
470-
(fun env item ->
471-
match item with
472-
| Module (_, m) -> module_ env m
473-
| ModuleSubstitution m -> Env.open_module_substitution m env
474-
| Type _ -> env
475-
| TypeSubstitution t -> Env.open_type_substitution t env
476-
| ModuleType mt -> module_type env mt
477-
| ModuleTypeSubstitution mts ->
478-
let env = Env.open_module_type_substitution mts env in
479-
module_type_substitution env mts
480-
| Value _ -> env
481-
| Comment _ -> env
482-
| TypExt _ -> env
483-
| Exception _ -> env
484-
| Class _ -> env
485-
| ClassType _ -> env
486-
| Include i -> include_ env i
487-
| Open _ -> env)
488-
env s
489-
490-
and module_type_substitution : Env.t -> ModuleTypeSubstitution.t -> Env.t =
491-
fun env m -> module_type_expr env m.manifest
492-
493-
and include_ : Env.t -> Include.t -> Env.t =
494-
fun env i ->
495-
let open Include in
496-
signature_items env i.expansion.content.items
497-
498-
and module_type : Env.t -> ModuleType.t -> Env.t =
499-
fun env m ->
500-
match m.expr with None -> env | Some expr -> module_type_expr env expr
501-
502-
and module_ : Env.t -> Module.t -> Env.t =
503-
fun env m ->
504-
let open Module in
505-
let env = module_decl env m.type_ in
506-
match m.type_ with
507-
| Alias (`Resolved _, Some exp) -> simple_expansion env exp
508-
| Alias _ | ModuleType _ -> env
509-
510-
and module_decl : Env.t -> Module.decl -> Env.t =
511-
fun env decl ->
512-
let open Module in
513-
match decl with
514-
| ModuleType expr -> module_type_expr env expr
515-
| Alias (_, None) -> env
516-
| Alias (_, Some e) -> simple_expansion env e
517-
end
518400
let rec unit env t =
519401
let open Compilation_unit in
520402
let content =
@@ -527,7 +409,6 @@ let rec unit env t =
527409
| Pack _ as p -> p
528410
in
529411
let source_info =
530-
let env = Build_env.unit env t in
531412
let open Source_info in
532413
match t.source_info with
533414
| Some inf ->
@@ -554,32 +435,30 @@ let rec unit env t =
554435
Value
555436
(jump_to v
556437
(Shape_tools.lookup_value_path env)
557-
(value_path ~report_errors:false env))
438+
(value_path env))
558439
| Module v ->
559440
Module
560441
(jump_to v
561442
(Shape_tools.lookup_module_path env)
562-
(module_path ~report_errors:false env))
443+
(module_path env))
563444
| ModuleType v ->
564445
ModuleType
565446
(jump_to v
566447
(Shape_tools.lookup_module_type_path env)
567-
(module_type_path ~report_errors:false env))
448+
(module_type_path env))
568449
| Type v ->
569450
Type
570451
(jump_to v
571452
(Shape_tools.lookup_type_path env)
572-
(type_path ~report_errors:false env))
453+
(type_path env))
573454
| Constructor v ->
574455
Constructor
575-
(jump_to v
576-
(fun _ -> None)
577-
(constructor_path ~report_errors:false env))
456+
(jump_to v (fun _ -> None) (constructor_path env))
578457
| ClassType v ->
579458
ClassType
580459
(jump_to v
581460
(Shape_tools.lookup_class_type_path env)
582-
(class_type_path ~report_errors:false env))
461+
(class_type_path env))
583462
| i -> i
584463
in
585464
(info, pos))

0 commit comments

Comments
 (0)