Skip to content

Commit ceb156a

Browse files
authored
Merge pull request #2043 from tweag/remove-deprecated-to_json
Don't use deprecated struct methods
2 parents 0c66e7a + 3e643b8 commit ceb156a

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

.bazelrc.common

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ common --config common
1515
startup --host_jvm_args=-Djdk.tls.client.protocols=TLSv1.2
1616

1717
common --incompatible_require_linker_input_cc_api
18-
18+
common --incompatible_struct_has_no_methods
1919
common --incompatible_disallow_empty_glob=true
2020

2121
# test environment does not propagate locales by default some tests reads files

haskell/cabal.bzl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ def _haskell_cabal_library_impl(ctx):
559559

560560
(_, runghc_manifest) = ctx.resolve_tools(tools = [ctx.attr._runghc])
561561
json_args = ctx.actions.declare_file("{}_cabal_wrapper_args.json".format(ctx.label.name))
562-
ctx.actions.write(json_args, c.args.to_json())
562+
ctx.actions.write(json_args, json.encode(c.args))
563563
ctx.actions.run(
564564
executable = c.cabal_wrapper,
565565
arguments = [json_args.path],
@@ -861,7 +861,7 @@ def _haskell_cabal_binary_impl(ctx):
861861
)
862862
(_, runghc_manifest) = ctx.resolve_tools(tools = [ctx.attr._runghc])
863863
json_args = ctx.actions.declare_file("{}_cabal_wrapper_args.json".format(ctx.label.name))
864-
ctx.actions.write(json_args, c.args.to_json())
864+
ctx.actions.write(json_args, json.encode(c.args))
865865
ctx.actions.run(
866866
executable = c.cabal_wrapper,
867867
arguments = [json_args.path],
@@ -1291,7 +1291,7 @@ library
12911291
)
12921292

12931293
# Create a stack.yaml capturing user overrides to the snapshot.
1294-
stack_yaml_content = struct(**{
1294+
stack_yaml_content = json.encode(struct(**{
12951295
"resolver": str(snapshot),
12961296
"packages": [resolve_package] + core_packages + [
12971297
# Determines path to vendored package's root directory relative to
@@ -1311,7 +1311,7 @@ library
13111311
])
13121312
for (pkg, flags) in repository_ctx.attr.flags.items()
13131313
},
1314-
}).to_json()
1314+
}))
13151315
repository_ctx.file("stack.yaml", content = stack_yaml_content, executable = False)
13161316

13171317
# We declared core packages as local packages in stack.yaml for two reasons.
@@ -1679,7 +1679,7 @@ def _write_snapshot_json(repository_ctx, all_cabal_hashes, resolved):
16791679
"__GENERATED_FILE_DO_NOT_MODIFY_MANUALLY": checksum,
16801680
"all-cabal-hashes": repr(all_cabal_hashes),
16811681
"resolved": _pretty_print_kvs(1, {
1682-
name: struct(**spec).to_json()
1682+
name: json.encode(struct(**spec))
16831683
for (name, spec) in resolved.items()
16841684
}),
16851685
}),

haskell/private/actions/info.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def write_proto_file(hs, output_name, proto_type, content):
3131
"""
3232
proto_txt = hs.actions.declare_file(output_name + ".txt")
3333
proto_pb = hs.actions.declare_file(output_name + ".pb")
34-
hs.actions.write(output = proto_txt, content = content.to_proto())
34+
hs.actions.write(output = proto_txt, content = proto.encode_text(content))
3535

3636
protoc = hs.toolchain.protoc
3737
rule_info_protos = hs.toolchain.rule_info_proto[ProtoInfo].direct_sources

0 commit comments

Comments
 (0)