From 51d2dd69618eae5b1107ecb2b8c81efa274ef53e Mon Sep 17 00:00:00 2001 From: Maxime Buyse Date: Thu, 30 Jan 2025 15:59:43 +0100 Subject: [PATCH 1/2] Add default case for disambiguation. --- engine/lib/concrete_ident/concrete_ident.ml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/engine/lib/concrete_ident/concrete_ident.ml b/engine/lib/concrete_ident/concrete_ident.ml index 98660e97e..af9d72956 100644 --- a/engine/lib/concrete_ident/concrete_ident.ml +++ b/engine/lib/concrete_ident/concrete_ident.ml @@ -269,8 +269,10 @@ module MakeToString (R : VIEW_RENDERER) = struct methods which may be repeated (with their implementations), and for fields (which are repeated by accessors). *) then - let path : View.ModPath.t = (View.of_def_id i.def_id).mod_path in - let path = List.map ~f:R.render_module path in + let mod_path : View.ModPath.t = + (View.of_def_id i.def_id).mod_path + in + let path = List.map ~f:R.render_module mod_path in (* Generates the list of all prefixes of reversed `path` *) List.folding_map ~init:[] (List.rev path) ~f:(fun acc chunk -> let acc = chunk :: acc in @@ -284,7 +286,9 @@ module MakeToString (R : VIEW_RENDERER) = struct path (* This might shadow, we should escape *)) (* Find the shortest name that doesn't exist already *) |> List.find ~f:(Hash_set.mem name_set >> not) - |> Option.value_exn + |> Option.value + ~default: + (name ^ (View.ModPath.hash mod_path |> Int.to_string)) else name in (* Update the maps and hashtables *) From 3937a6a19ea52f3bc90a6b7df433a2f857e821fc Mon Sep 17 00:00:00 2001 From: Maxime Buyse Date: Thu, 30 Jan 2025 17:41:30 +0100 Subject: [PATCH 2/2] Fix disambiguation in bundles: inherent impl associtem and default hash. --- engine/lib/concrete_ident/concrete_ident.ml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/engine/lib/concrete_ident/concrete_ident.ml b/engine/lib/concrete_ident/concrete_ident.ml index af9d72956..a09b761a3 100644 --- a/engine/lib/concrete_ident/concrete_ident.ml +++ b/engine/lib/concrete_ident/concrete_ident.ml @@ -256,7 +256,9 @@ module MakeToString (R : VIEW_RENDERER) = struct in let is_assoc_or_field (rel_path : View.RelPath.t) : bool = match List.last rel_path with - | Some (`AssociatedItem _ | `Field _) -> true + | Some (`AssociatedItem (_, (`Trait _ | `Impl (_, `Trait, _)))) + | Some (`Field _) -> + true | _ -> false in let name = @@ -269,10 +271,8 @@ module MakeToString (R : VIEW_RENDERER) = struct methods which may be repeated (with their implementations), and for fields (which are repeated by accessors). *) then - let mod_path : View.ModPath.t = - (View.of_def_id i.def_id).mod_path - in - let path = List.map ~f:R.render_module mod_path in + let path : View.ModPath.t = (View.of_def_id i.def_id).mod_path in + let path = List.map ~f:R.render_module path in (* Generates the list of all prefixes of reversed `path` *) List.folding_map ~init:[] (List.rev path) ~f:(fun acc chunk -> let acc = chunk :: acc in @@ -286,9 +286,7 @@ module MakeToString (R : VIEW_RENDERER) = struct path (* This might shadow, we should escape *)) (* Find the shortest name that doesn't exist already *) |> List.find ~f:(Hash_set.mem name_set >> not) - |> Option.value - ~default: - (name ^ (View.ModPath.hash mod_path |> Int.to_string)) + |> Option.value ~default:(name ^ ([%hash: t] i |> Int.to_string)) else name in (* Update the maps and hashtables *)