@@ -101,28 +101,27 @@ let make ?(sandbox = Sandbox_config.default) ?(mode = Mode.Standard) ~context
101101 (action, deps))
102102 })
103103 in
104+ let report_error ?(extra_pp = [] ) message =
105+ match info with
106+ | From_dune_file loc ->
107+ let pp = [ Pp. text message ] @ extra_pp in
108+ User_error. raise ~loc pp
109+ | Internal
110+ | Source_file_copy _ ->
111+ Code_error. raise message
112+ [ (" info" , Info. to_dyn info); (" targets" , Targets. to_dyn targets) ]
113+ in
104114 let dir =
105115 match Targets. validate targets with
106116 | Valid { parent_dir } -> parent_dir
107- | No_targets -> (
108- match info with
109- | From_dune_file loc ->
110- User_error. raise ~loc [ Pp. text " Rule has no targets specified" ]
111- | Internal
112- | Source_file_copy _ ->
113- Code_error. raise " Rule.Targets: An internal rule with no targets" [] )
114- | Inconsistent_parent_dir -> (
115- match info with
116- | From_dune_file loc ->
117- User_error. raise ~loc
118- [ Pp. text " Rule has targets in different directories.\n Targets:"
119- ; Targets. pp targets
120- ]
121- | Internal
122- | Source_file_copy _ ->
123- Code_error. raise
124- " Rule.Targets: An internal rule has targets in different directories"
125- [ (" targets" , Targets. to_dyn targets) ])
117+ | No_targets -> report_error " Rule has no targets specified"
118+ | Inconsistent_parent_dir ->
119+ report_error " Rule has targets in different directories."
120+ ~extra_pp: [ Pp. text " Targets:" ; Targets. pp targets ]
121+ | File_and_directory_target_with_the_same_name path ->
122+ report_error
123+ (sprintf " %S is declared as both a file and a directory target."
124+ (Dpath. describe_target path))
126125 in
127126 let loc =
128127 match info with
0 commit comments