···113113 List.map
114114 (function
115115 | Lang.Compilation_unit.Import.Resolved _ as resolved -> resolved
116116- | Unresolved (name, _) as unresolved -> (
116116+ | Unresolved (_, None) as unresolved ->
117117+ (* Don't try to resolve imports without a digest. Looking up
118118+ modules in the include path could find stale artifacts from
119119+ a previous build, associating the wrong digest with this
120120+ import and breaking incremental rebuilds. *)
121121+ unresolved
122122+ | Unresolved (name, Some _) as unresolved -> (
117123 match Resolver.resolve_import resolver name with
118124 | Some root -> Resolved (root, Names.ModuleName.make_std name)
119125 | None -> unresolved))
+3-5
src/xref2/errors.ml
···340340 let open Component.Fmt in
341341 let report_error ~non_fatal =
342342 let r subject pp_a a =
343343- Lookup_failures.report ~non_fatal "Failed to %s %s %a%a" action subject pp_a
344344- a pp_tools_error tools_error
343343+ Lookup_failures.report ~non_fatal "Failed to %s %s %a%a" action subject
344344+ pp_a a pp_tools_error tools_error
345345 in
346346 let c = default in
347347 let fmt_id fmt id = model_identifier c fmt (id :> Paths.Identifier.t) in
···377377 match kind_of_error ~what tools_error with
378378 | Some (`Root name) -> Lookup_failures.report_root ~name
379379 | Some `OpaqueModule -> report_error ~non_fatal:true
380380- | None ->
381381- let non_fatal = match what with `Reference _ -> false | _ -> true in
382382- report_error ~non_fatal
380380+ | None -> report_error ~non_fatal:false
···11+When compiling with -no-alias-deps, module aliases produce imports without
22+digests. odoc should not try to resolve these imports, as looking them up in
33+the include path could find stale artifacts from a previous build, associating
44+a wrong digest and breaking incremental rebuilds.
55+66+Compile b.mli normally, and a.ml with -no-alias-deps. Module A contains
77+`module B = B`, so B appears as an import of A without a digest.
88+99+ $ ocamlc -c -bin-annot b.mli
1010+ $ ocamlc -c -bin-annot -no-alias-deps -w -49 a.ml
1111+1212+Verify that B has no digest in the compiled .cmt:
1313+1414+ $ ocamlobjinfo a.cmt | grep " -------------------------------- B" | head -1
1515+ -------------------------------- B
1616+1717+compile-deps correctly omits imports without digests:
1818+1919+ $ odoc compile-deps a.cmt | cut -d ' ' -f 1 | sort
2020+ A
2121+ CamlinternalFormatBasics
2222+ Stdlib
2323+2424+Compile both with odoc. B's .odoc is present in the include path.
2525+2626+ $ odoc compile --pkg test -I . b.cmti
2727+ $ odoc compile --pkg test -I . a.cmt
2828+2929+B should remain unresolved in A's imports, since it had no digest:
3030+3131+ $ odoc_print a.odoc | grep 'Unresolved.*"B"'
3232+ { "Unresolved": [ "B", "None" ] },
3333+3434+link-deps should not report B as a dependency:
3535+3636+ $ odoc link-deps . | grep B
3737+ [1]