├── .github └── workflows │ └── ci.yml ├── .gitignore ├── .rustfmt.toml ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Cargo.toml ├── LICENSE ├── README.md ├── allocative ├── README.md ├── allocative │ ├── .gitignore │ ├── Cargo.toml │ ├── build.rs │ └── src │ │ ├── allocative_trait.rs │ │ ├── flamegraph.rs │ │ ├── global_root.rs │ │ ├── golden.rs │ │ ├── impls.rs │ │ ├── impls │ │ ├── anyhow.rs │ │ ├── bumpalo.rs │ │ ├── common.rs │ │ ├── compact_str.rs │ │ ├── compact_str_test_heap.src │ │ ├── compact_str_test_inline.src │ │ ├── dashmap.rs │ │ ├── either.rs │ │ ├── either_test_golden.src │ │ ├── futures.rs │ │ ├── hashbrown.rs │ │ ├── hashbrown_test_hash_table.src │ │ ├── hashbrown_test_raw_table.src │ │ ├── hashbrown_util.rs │ │ ├── indexmap.rs │ │ ├── lock_api.rs │ │ ├── num_bigint.rs │ │ ├── once_cell.rs │ │ ├── parking_lot.rs │ │ ├── prost_types.rs │ │ ├── relative_path.rs │ │ ├── serde_json.rs │ │ ├── slab.rs │ │ ├── smallvec.rs │ │ ├── sorted_vector_map.rs │ │ ├── std.rs │ │ ├── std │ │ │ ├── any.rs │ │ │ ├── cell.rs │ │ │ ├── cell_test_borrowed.src │ │ │ ├── cell_test_default.src │ │ │ ├── cell_test_once_cell.src │ │ │ ├── collections.rs │ │ │ ├── function.rs │ │ │ ├── mem.rs │ │ │ ├── net.rs │ │ │ ├── primitive.rs │ │ │ ├── sync.rs │ │ │ ├── sync_test_arc_align.src │ │ │ ├── thread.rs │ │ │ ├── time.rs │ │ │ ├── tuple.rs │ │ │ └── unsorted.rs │ │ ├── tokio.rs │ │ ├── triomphe.rs │ │ ├── triomphe_test_align.src │ │ ├── triomphe_test_shared.src │ │ └── triomphe_test_simple.src │ │ ├── key.rs │ │ ├── lib.rs │ │ ├── rc_str.rs │ │ ├── size_of.rs │ │ ├── test_derive.rs │ │ ├── test_derive │ │ ├── bounds.rs │ │ ├── dst.rs │ │ ├── skip.rs │ │ ├── visit.rs │ │ └── with_flamegraph.rs │ │ └── visitor.rs ├── allocative_derive │ ├── Cargo.toml │ └── src │ │ ├── derive_allocative.rs │ │ ├── lib.rs │ │ └── root.rs └── sample-flamegraph.png ├── benchmark ├── benchmark.py ├── results_linux.txt ├── results_mac.txt └── run_benchmark.py ├── docs ├── environment.md ├── gc.md ├── heaps.md ├── spec.md ├── types.md └── values.md ├── gazebo ├── README.md ├── cmp_any │ ├── Cargo.toml │ └── src │ │ ├── eq.rs │ │ ├── lib.rs │ │ └── ord.rs ├── display_container │ ├── Cargo.toml │ └── src │ │ └── lib.rs ├── dupe │ ├── Cargo.toml │ └── src │ │ ├── __macro_refs.rs │ │ ├── iter.rs │ │ ├── lib.rs │ │ └── option.rs ├── dupe_derive │ ├── Cargo.toml │ └── src │ │ ├── clone.rs │ │ ├── copy.rs │ │ ├── dupe.rs │ │ ├── lib.rs │ │ └── util.rs ├── gazebo │ ├── Cargo.toml │ └── src │ │ ├── cast.rs │ │ ├── cell.rs │ │ ├── cmp.rs │ │ ├── ext.rs │ │ ├── ext │ │ ├── iter.rs │ │ ├── option.rs │ │ └── vec.rs │ │ ├── file.rs │ │ ├── hash.rs │ │ ├── lib.rs │ │ ├── phantom.rs │ │ ├── prelude.rs │ │ ├── test.rs │ │ ├── types.rs │ │ └── variants.rs ├── gazebo_derive │ ├── Cargo.toml │ └── src │ │ ├── default.rs │ │ ├── lib.rs │ │ └── variant.rs ├── strong_hash │ ├── Cargo.toml │ └── src │ │ ├── impls.rs │ │ ├── impls │ │ ├── num_bigint.rs │ │ └── triomphe.rs │ │ └── lib.rs ├── strong_hash_derive │ ├── Cargo.toml │ └── src │ │ └── lib.rs └── strong_hash_tests │ ├── Cargo.toml │ └── src │ └── lib.rs ├── starlark ├── Cargo.toml ├── build.rs ├── fuzz │ ├── .gitignore │ ├── Cargo.toml │ └── fuzz_targets │ │ └── starlark.rs ├── hello_world.star ├── src │ ├── __derive_refs.rs │ ├── __derive_refs │ │ ├── components.rs │ │ ├── invoke_macro_error.rs │ │ ├── param_spec.rs │ │ ├── parse_args.rs │ │ └── sig.rs │ ├── analysis.rs │ ├── analysis │ │ ├── dubious.rs │ │ ├── find_call_name.rs │ │ ├── flow.rs │ │ ├── incompatible.rs │ │ ├── lint_message.rs │ │ ├── names.rs │ │ ├── performance.rs │ │ ├── types.rs │ │ ├── underscore.rs │ │ ├── unused_loads.rs │ │ └── unused_loads │ │ │ ├── find.rs │ │ │ ├── find │ │ │ ├── one_of_two_unused.golden │ │ │ ├── simple.golden │ │ │ ├── unused_annotation_on_arg.golden │ │ │ ├── used_in_top_level_assignment.golden │ │ │ ├── used_in_type_expr.golden │ │ │ └── with_rename.golden │ │ │ ├── find_tests.rs │ │ │ ├── remove.rs │ │ │ ├── remove │ │ │ ├── remove_all.golden │ │ │ ├── remove_first_of_two.golden │ │ │ └── remove_second_of_two.golden │ │ │ └── remove_tests.rs │ ├── any.rs │ ├── assert.rs │ ├── assert │ │ ├── assert.rs │ │ └── conformance.rs │ ├── cast.rs │ ├── coerce.rs │ ├── collections.rs │ ├── collections │ │ ├── aligned_padded_str.rs │ │ ├── alloca.rs │ │ ├── maybe_uninit_backport.rs │ │ ├── string_pool.rs │ │ ├── symbol.rs │ │ └── symbol │ │ │ ├── map.rs │ │ │ └── symbol.rs │ ├── debug.rs │ ├── debug │ │ ├── adapter.rs │ │ ├── adapter │ │ │ ├── implementation.rs │ │ │ └── tests.rs │ │ ├── evaluate.rs │ │ └── inspect.rs │ ├── docs.rs │ ├── docs │ │ ├── code.rs │ │ ├── markdown.rs │ │ ├── multipage.rs │ │ ├── parse.rs │ │ ├── tests.rs │ │ └── tests │ │ │ ├── golden │ │ │ ├── multipage │ │ │ │ ├── Magic.golden.md │ │ │ │ ├── Obj.golden.md │ │ │ │ ├── globals.golden.md │ │ │ │ └── submod.golden.md │ │ │ ├── multipage_linked_type │ │ │ │ ├── Magic.golden.md │ │ │ │ ├── Obj.golden.md │ │ │ │ ├── globals.golden.md │ │ │ │ └── submod.golden.md │ │ │ ├── native.golden.md │ │ │ ├── object.golden.md │ │ │ └── starlark.golden.md │ │ │ ├── markdown.rs │ │ │ └── rustdocs.rs │ ├── environment.rs │ ├── environment │ │ ├── globals.rs │ │ ├── methods.rs │ │ ├── module_dump.rs │ │ ├── modules.rs │ │ ├── names.rs │ │ └── slots.rs │ ├── errors.rs │ ├── errors │ │ └── did_you_mean.rs │ ├── eval.rs │ ├── eval │ │ ├── bc.rs │ │ ├── bc │ │ │ ├── addr.rs │ │ │ ├── bytecode.rs │ │ │ ├── call.rs │ │ │ ├── compiler.rs │ │ │ ├── compiler │ │ │ │ ├── assign.rs │ │ │ │ ├── assign_modify.rs │ │ │ │ ├── call.rs │ │ │ │ ├── compr.rs │ │ │ │ ├── def.rs │ │ │ │ ├── expr.rs │ │ │ │ ├── if_compiler.rs │ │ │ │ └── stmt.rs │ │ │ ├── definitely_assigned.rs │ │ │ ├── for_loop.rs │ │ │ ├── frame.rs │ │ │ ├── if_debug.rs │ │ │ ├── instr.rs │ │ │ ├── instr_arg.rs │ │ │ ├── instr_impl.rs │ │ │ ├── instrs.rs │ │ │ ├── native_function.rs │ │ │ ├── opcode.rs │ │ │ ├── repr.rs │ │ │ ├── slow_arg.rs │ │ │ ├── stack_ptr.rs │ │ │ └── writer.rs │ │ ├── compiler.rs │ │ ├── compiler │ │ │ ├── args.rs │ │ │ ├── call.rs │ │ │ ├── compr.rs │ │ │ ├── constants.rs │ │ │ ├── def.rs │ │ │ ├── def_inline.rs │ │ │ ├── def_inline │ │ │ │ └── local_as_value.rs │ │ │ ├── error.rs │ │ │ ├── expr.rs │ │ │ ├── expr_bool.rs │ │ │ ├── known.rs │ │ │ ├── module.rs │ │ │ ├── opt_ctx.rs │ │ │ ├── scope.rs │ │ │ ├── scope │ │ │ │ ├── payload.rs │ │ │ │ ├── scope_resolver_globals.rs │ │ │ │ └── tests.rs │ │ │ ├── small_vec_1.rs │ │ │ ├── span.rs │ │ │ ├── stmt.rs │ │ │ ├── type_expr.rs │ │ │ └── types.rs │ │ ├── params.rs │ │ ├── runtime.rs │ │ ├── runtime │ │ │ ├── arguments.rs │ │ │ ├── before_stmt.rs │ │ │ ├── cheap_call_stack.rs │ │ │ ├── evaluator.rs │ │ │ ├── file_loader.rs │ │ │ ├── frame_span.rs │ │ │ ├── frozen_file_span.rs │ │ │ ├── inlined_frame.rs │ │ │ ├── params.rs │ │ │ ├── params │ │ │ │ ├── display.rs │ │ │ │ ├── parser.rs │ │ │ │ └── spec.rs │ │ │ ├── profile.rs │ │ │ ├── profile │ │ │ │ ├── bc.rs │ │ │ │ ├── csv.rs │ │ │ │ ├── data.rs │ │ │ │ ├── flamegraph.rs │ │ │ │ ├── golden │ │ │ │ │ ├── bytecode.csv.golden │ │ │ │ │ ├── bytecode_pairs.csv.golden │ │ │ │ │ ├── coverage.csv.golden │ │ │ │ │ ├── heap_allocated.csv.golden │ │ │ │ │ ├── heap_allocated.flame.golden │ │ │ │ │ ├── heap_flame_allocated.flame.golden │ │ │ │ │ ├── heap_flame_retained.flame.golden │ │ │ │ │ ├── heap_retained.csv.golden │ │ │ │ │ ├── heap_retained.flame.golden │ │ │ │ │ ├── heap_summary_allocated.csv.golden │ │ │ │ │ ├── heap_summary_retained.csv.golden │ │ │ │ │ ├── statement.csv.golden │ │ │ │ │ ├── time_flame.flame.golden │ │ │ │ │ └── typecheck.csv.golden │ │ │ │ ├── heap.rs │ │ │ │ ├── instant.rs │ │ │ │ ├── mode.rs │ │ │ │ ├── or_instrumentation.rs │ │ │ │ ├── profiler_type.rs │ │ │ │ ├── stmt.rs │ │ │ │ ├── tests.rs │ │ │ │ ├── time_flame.rs │ │ │ │ └── typecheck.rs │ │ │ ├── rust_loc.rs │ │ │ ├── slots.rs │ │ │ ├── small_duration.rs │ │ │ └── visit_span.rs │ │ └── soft_error.rs │ ├── hint.rs │ ├── lib.rs │ ├── macros.rs │ ├── private.rs │ ├── read_line.rs │ ├── sealed.rs │ ├── stdlib.rs │ ├── stdlib │ │ ├── breakpoint.rs │ │ ├── call_stack.rs │ │ ├── extra.rs │ │ ├── funcs.rs │ │ ├── funcs │ │ │ ├── globals.rs │ │ │ ├── min_max.rs │ │ │ ├── other.rs │ │ │ └── zip.rs │ │ ├── internal.rs │ │ ├── json.rs │ │ └── partial.rs │ ├── syntax.rs │ ├── tests.rs │ ├── tests │ │ ├── basic.rs │ │ ├── bc.rs │ │ ├── bc │ │ │ ├── and_or.rs │ │ │ ├── call.rs │ │ │ ├── compr.rs │ │ │ ├── definitely_assigned.rs │ │ │ ├── expr.rs │ │ │ ├── for_stmt.rs │ │ │ ├── golden.rs │ │ │ ├── golden │ │ │ │ ├── and_or_false_and_x.golden │ │ │ │ ├── and_or_false_or_x.golden │ │ │ │ ├── and_or_true_and_x.golden │ │ │ │ ├── and_or_true_or_x.golden │ │ │ │ ├── and_or_x_and_false.golden │ │ │ │ ├── and_or_x_and_true.golden │ │ │ │ ├── and_or_x_or_false.golden │ │ │ │ ├── and_or_x_or_true.golden │ │ │ │ ├── call.golden │ │ │ │ ├── compr_if_true_clause.golden │ │ │ │ ├── compr_if_true_clause_on_freeze.golden │ │ │ │ ├── compr_no_loop_if_top_collection_is_empty.golden │ │ │ │ ├── compr_no_loop_if_top_collection_is_empty_on_freeze.golden │ │ │ │ ├── constant_folding_list_add.golden │ │ │ │ ├── def_inline_const_args_inlined.golden │ │ │ │ ├── def_inline_const_inlined.golden │ │ │ │ ├── def_inline_dict_inlined.golden │ │ │ │ ├── def_inline_list_inlined.golden │ │ │ │ ├── def_inline_locals_inlined.golden │ │ │ │ ├── def_inline_return_type_inlined.golden │ │ │ │ ├── definitely_assigned_mov_is_used.golden │ │ │ │ ├── definitely_assigned_no_op_movs.golden │ │ │ │ ├── definitely_assigned_slot_range_in_call.golden │ │ │ │ ├── definitely_assigned_slot_range_in_list.golden │ │ │ │ ├── eq_bool.golden │ │ │ │ ├── eq_const.golden │ │ │ │ ├── eq_enum.golden │ │ │ │ ├── eq_int.golden │ │ │ │ ├── eq_short_str.golden │ │ │ │ ├── eq_str.golden │ │ │ │ ├── expr_call_maybe_known_method.golden │ │ │ │ ├── expr_format_one.golden │ │ │ │ ├── expr_fstring.golden │ │ │ │ ├── expr_percent_s_one.golden │ │ │ │ ├── expr_spec_exec_list.golden │ │ │ │ ├── expr_type.golden │ │ │ │ ├── for.golden │ │ │ │ ├── for_break.golden │ │ │ │ ├── for_continue.golden │ │ │ │ ├── if_stmt_and_stmt.golden │ │ │ │ ├── if_stmt_if_else_x_and_y.golden │ │ │ │ ├── if_stmt_if_else_x_or_y.golden │ │ │ │ ├── if_stmt_if_false_and_x.golden │ │ │ │ ├── if_stmt_if_false_or_x.golden │ │ │ │ ├── if_stmt_if_true_and_x.golden │ │ │ │ ├── if_stmt_if_true_or_x.golden │ │ │ │ ├── if_stmt_if_x_and_false.golden │ │ │ │ ├── if_stmt_if_x_and_true.golden │ │ │ │ ├── if_stmt_if_x_or_false.golden │ │ │ │ ├── if_stmt_if_x_or_true.golden │ │ │ │ ├── if_stmt_or_stmt.golden │ │ │ │ ├── isinstance.golden │ │ │ │ ├── opt_empty_iterable_optimized_away.golden │ │ │ │ ├── opt_list_of_const_add.golden │ │ │ │ ├── opt_list_of_expr_add.golden │ │ │ │ ├── opt_list_plus_list.golden │ │ │ │ ├── opt_mutual_recursion.golden │ │ │ │ ├── opt_private_forward_mutable_module_vars_inlined.golden │ │ │ │ ├── opt_recursion.golden │ │ │ │ ├── opt_return_type_erased.golden │ │ │ │ ├── opt_return_type_present.golden │ │ │ │ ├── opt_same_module_struct_getattr_inlined.golden │ │ │ │ ├── opt_type_is_inlined.golden │ │ │ │ ├── opt_unreachable_code_optimized_away.golden │ │ │ │ ├── speculative_exec_enum_inline.golden │ │ │ │ ├── speculative_exec_format_speculatively_before_format_instr.golden │ │ │ │ └── speculative_exec_methods_invoked_speculatively.golden │ │ │ ├── if_stmt.rs │ │ │ └── isinstance.rs │ │ ├── before_stmt.rs │ │ ├── call.rs │ │ ├── comprehension.rs │ │ ├── def.rs │ │ ├── derive.rs │ │ ├── derive │ │ │ ├── alloc_value.rs │ │ │ ├── attrs.rs │ │ │ ├── docs.rs │ │ │ ├── freeze.rs │ │ │ ├── freeze │ │ │ │ ├── basic.rs │ │ │ │ ├── bounds.rs │ │ │ │ ├── enums.rs │ │ │ │ ├── identity.rs │ │ │ │ ├── validator.rs │ │ │ │ └── validator_order.rs │ │ │ ├── module.rs │ │ │ ├── module │ │ │ │ ├── basic.rs │ │ │ │ ├── default_value.rs │ │ │ │ ├── generic.rs │ │ │ │ ├── kwargs.rs │ │ │ │ ├── methods.rs │ │ │ │ ├── named_positional.rs │ │ │ │ ├── other_attributes.rs │ │ │ │ ├── return_impl.rs │ │ │ │ ├── special_params.rs │ │ │ │ ├── type_annotation.rs │ │ │ │ └── unpack_value.rs │ │ │ ├── trace.rs │ │ │ ├── trace │ │ │ │ ├── bounds.rs │ │ │ │ ├── enums.rs │ │ │ │ └── statics.rs │ │ │ ├── unpack_value.rs │ │ │ └── unpack_value_attr.rs │ │ ├── for_loop.rs │ │ ├── freeze_access_value.rs │ │ ├── fstring.rs │ │ ├── fstring │ │ │ └── golden │ │ │ │ ├── escape.err.golden.md │ │ │ │ ├── invalid_format.err.golden.md │ │ │ │ ├── invalid_identifier.err.golden.md │ │ │ │ ├── invalid_identifier_expression.err.golden.md │ │ │ │ ├── invalid_identifier_multiline.err.golden.md │ │ │ │ ├── invalid_identifier_raw.err.golden.md │ │ │ │ ├── invalid_identifier_triple_quotes.err.golden.md │ │ │ │ ├── not_enabled.err.golden.md │ │ │ │ └── undeclared_variable.err.golden.md │ │ ├── go.rs │ │ ├── interop.rs │ │ ├── opt.rs │ │ ├── opt │ │ │ ├── constant_folding.rs │ │ │ ├── def_inline.rs │ │ │ ├── eq.rs │ │ │ ├── if_rand.rs │ │ │ ├── list_add.rs │ │ │ ├── speculative_exec.rs │ │ │ ├── type_is.rs │ │ │ └── types.rs │ │ ├── replace_binary.rs │ │ ├── runtime.rs │ │ ├── type_annot.rs │ │ ├── uncategorized.rs │ │ ├── uncategorized_diagnostics_display_debug.golden │ │ ├── uncategorized_diagnostics_display_default.golden │ │ ├── uncategorized_diagnostics_display_hash.golden │ │ ├── uncategorized_error_display.golden │ │ ├── uncategorized_error_display_hash.golden │ │ └── util.rs │ ├── typing.rs │ ├── typing │ │ ├── arc_ty.rs │ │ ├── basic.rs │ │ ├── bindings.rs │ │ ├── call_args.rs │ │ ├── callable.rs │ │ ├── callable_param.rs │ │ ├── callable_param_test_param_spec_display.golden │ │ ├── ctx.rs │ │ ├── custom.rs │ │ ├── error.rs │ │ ├── fill_types_for_lint.rs │ │ ├── function.rs │ │ ├── interface.rs │ │ ├── macro_support.rs │ │ ├── mode.rs │ │ ├── oracle.rs │ │ ├── oracle │ │ │ ├── ctx.rs │ │ │ └── traits.rs │ │ ├── small_arc_vec.rs │ │ ├── small_arc_vec_or_static.rs │ │ ├── starlark_value.rs │ │ ├── structs.rs │ │ ├── tests.rs │ │ ├── tests │ │ │ ├── call.rs │ │ │ ├── callable.rs │ │ │ ├── golden │ │ │ │ ├── accepts_iterable.golden │ │ │ │ ├── bit_or_return_int.golden │ │ │ │ ├── bit_or_return_list.golden │ │ │ │ ├── call_callable.golden │ │ │ │ ├── call_callable_or_not_callable.golden │ │ │ │ ├── call_not_callable.golden │ │ │ │ ├── call_pos_only.golden │ │ │ │ ├── callable_named.golden │ │ │ │ ├── callable_with_args.golden │ │ │ │ ├── calls.golden │ │ │ │ ├── dict_bug.golden │ │ │ │ ├── dict_never_key.golden │ │ │ │ ├── dot_type_0.golden │ │ │ │ ├── dot_type_1.golden │ │ │ │ ├── failure.golden │ │ │ │ ├── false_negative.golden │ │ │ │ ├── function_as_type_bit_or.golden │ │ │ │ ├── incorrect_type_dot.golden │ │ │ │ ├── int_bitor_float.golden │ │ │ │ ├── int_mul_list.golden │ │ │ │ ├── int_plus_float.golden │ │ │ │ ├── kwargs_in_native_code.golden │ │ │ │ ├── list_append.golden │ │ │ │ ├── list_append_bug.golden │ │ │ │ ├── list_bin_op.golden │ │ │ │ ├── list_function.golden │ │ │ │ ├── list_less.golden │ │ │ │ ├── load_0.golden │ │ │ │ ├── load_1.golden │ │ │ │ ├── methods_work_for_ty_starlark_value.golden │ │ │ │ ├── never_call_bug.golden │ │ │ │ ├── new_list_dict_syntax.golden │ │ │ │ ├── new_list_dict_syntax_as_value.golden │ │ │ │ ├── struct.golden │ │ │ │ ├── success.golden │ │ │ │ ├── test_bit_or_with_load.golden │ │ │ │ ├── test_bit_or_with_load_foo.golden │ │ │ │ ├── tuple.golden │ │ │ │ ├── tuple_ellipsis.golden │ │ │ │ ├── type_alias.golden │ │ │ │ ├── type_kwargs.golden │ │ │ │ ├── types_of_args_kwargs.golden │ │ │ │ ├── un_op.golden │ │ │ │ ├── union.golden │ │ │ │ └── zip.golden │ │ │ ├── list.rs │ │ │ ├── special_function.rs │ │ │ ├── tuple.rs │ │ │ └── types.rs │ │ ├── tuple.rs │ │ ├── ty.rs │ │ ├── typecheck.rs │ │ └── user.rs │ ├── util.rs │ ├── util │ │ ├── arc_or_static.rs │ │ ├── arc_str.rs │ │ ├── non_static_type_id.rs │ │ ├── refcell.rs │ │ └── rtabort.rs │ ├── values.rs │ ├── values │ │ ├── alloc_value.rs │ │ ├── comparison.rs │ │ ├── demand.rs │ │ ├── error.rs │ │ ├── freeze.rs │ │ ├── freeze_error.rs │ │ ├── frozen_ref.rs │ │ ├── index.rs │ │ ├── iter.rs │ │ ├── layout.rs │ │ ├── layout │ │ │ ├── aligned_size.rs │ │ │ ├── alloc_static_simple.rs │ │ │ ├── avalue.rs │ │ │ ├── complex.rs │ │ │ ├── const_frozen_string.rs │ │ │ ├── const_type_id.rs │ │ │ ├── heap.rs │ │ │ ├── heap │ │ │ │ ├── allocator.rs │ │ │ │ ├── allocator │ │ │ │ │ ├── alloc.rs │ │ │ │ │ ├── alloc │ │ │ │ │ │ ├── allocator.rs │ │ │ │ │ │ ├── chain.rs │ │ │ │ │ │ ├── chunk.rs │ │ │ │ │ │ ├── chunk_part.rs │ │ │ │ │ │ └── per_thread.rs │ │ │ │ │ ├── api.rs │ │ │ │ │ └── bumpalo.rs │ │ │ │ ├── arena.rs │ │ │ │ ├── call_enter_exit.rs │ │ │ │ ├── fast_cell.rs │ │ │ │ ├── heap_type.rs │ │ │ │ ├── maybe_uninit_slice_util.rs │ │ │ │ ├── profile.rs │ │ │ │ ├── profile │ │ │ │ │ ├── aggregated.rs │ │ │ │ │ ├── alloc_counts.rs │ │ │ │ │ ├── by_type.rs │ │ │ │ │ ├── string_index.rs │ │ │ │ │ └── summary_by_function.rs │ │ │ │ └── repr.rs │ │ │ ├── identity.rs │ │ │ ├── pointer.rs │ │ │ ├── static_string.rs │ │ │ ├── typed.rs │ │ │ ├── typed │ │ │ │ └── string.rs │ │ │ ├── value.rs │ │ │ ├── value_alloc_size.rs │ │ │ ├── value_captured.rs │ │ │ ├── value_lifetimeless.rs │ │ │ ├── value_not_special.rs │ │ │ └── vtable.rs │ │ ├── owned.rs │ │ ├── owned_frozen_ref.rs │ │ ├── recursive_repr_or_json_guard.rs │ │ ├── stack_guard.rs │ │ ├── starlark_type_id.rs │ │ ├── thin_box_slice_frozen_value.rs │ │ ├── thin_box_slice_frozen_value │ │ │ ├── packed_impl.rs │ │ │ └── thin_box.rs │ │ ├── trace.rs │ │ ├── traits.rs │ │ ├── type_repr.rs │ │ ├── types.rs │ │ ├── types │ │ │ ├── any.rs │ │ │ ├── any_array.rs │ │ │ ├── any_complex.rs │ │ │ ├── array.rs │ │ │ ├── bigint.rs │ │ │ ├── bigint │ │ │ │ └── convert.rs │ │ │ ├── bool.rs │ │ │ ├── bool │ │ │ │ ├── alloc.rs │ │ │ │ ├── globals.rs │ │ │ │ ├── type_repr.rs │ │ │ │ ├── unpack.rs │ │ │ │ └── value.rs │ │ │ ├── dict.rs │ │ │ ├── dict │ │ │ │ ├── alloc.rs │ │ │ │ ├── dict_type.rs │ │ │ │ ├── globals.rs │ │ │ │ ├── methods.rs │ │ │ │ ├── refs.rs │ │ │ │ ├── traits.rs │ │ │ │ ├── unpack.rs │ │ │ │ └── value.rs │ │ │ ├── ellipsis.rs │ │ │ ├── enumeration.rs │ │ │ ├── enumeration │ │ │ │ ├── enum_type.rs │ │ │ │ ├── globals.rs │ │ │ │ ├── matcher.rs │ │ │ │ ├── ty_enum_type.rs │ │ │ │ └── value.rs │ │ │ ├── exported_name.rs │ │ │ ├── float.rs │ │ │ ├── float │ │ │ │ ├── float.rs │ │ │ │ ├── globals.rs │ │ │ │ └── unpack.rs │ │ │ ├── function.rs │ │ │ ├── int.rs │ │ │ ├── int │ │ │ │ ├── globals.rs │ │ │ │ ├── i32.rs │ │ │ │ ├── inline_int.rs │ │ │ │ ├── int_or_big.rs │ │ │ │ ├── pointer_i32.rs │ │ │ │ └── tests.rs │ │ │ ├── known_methods.rs │ │ │ ├── list.rs │ │ │ ├── list │ │ │ │ ├── alloc.rs │ │ │ │ ├── globals.rs │ │ │ │ ├── list_type.rs │ │ │ │ ├── methods.rs │ │ │ │ ├── refs.rs │ │ │ │ ├── unpack.rs │ │ │ │ └── value.rs │ │ │ ├── list_or_tuple.rs │ │ │ ├── namespace.rs │ │ │ ├── namespace │ │ │ │ ├── globals.rs │ │ │ │ ├── typing.rs │ │ │ │ └── value.rs │ │ │ ├── none.rs │ │ │ ├── none │ │ │ │ ├── globals.rs │ │ │ │ ├── none_or.rs │ │ │ │ └── none_type.rs │ │ │ ├── num.rs │ │ │ ├── num │ │ │ │ ├── globals.rs │ │ │ │ ├── typecheck.rs │ │ │ │ └── value.rs │ │ │ ├── range.rs │ │ │ ├── range │ │ │ │ ├── globals.rs │ │ │ │ └── range_type.rs │ │ │ ├── record.rs │ │ │ ├── record │ │ │ │ ├── field.rs │ │ │ │ ├── globals.rs │ │ │ │ ├── instance.rs │ │ │ │ ├── matcher.rs │ │ │ │ ├── record_type.rs │ │ │ │ ├── record_type │ │ │ │ │ ├── anon_record.golden │ │ │ │ │ ├── missing_field_error.golden │ │ │ │ │ ├── record_callable_compile_time.golden │ │ │ │ │ ├── record_type_as_type_compile_time.golden │ │ │ │ │ └── record_type_as_type_runtime.golden │ │ │ │ ├── ty_record_type.rs │ │ │ │ └── ty_record_type │ │ │ │ │ ├── fail_compile_time.golden │ │ │ │ │ ├── fail_runtime_time.golden │ │ │ │ │ ├── typecheck_field_fail.golden │ │ │ │ │ └── typecheck_record_type_call.golden │ │ │ ├── set.rs │ │ │ ├── set │ │ │ │ ├── methods.rs │ │ │ │ ├── refs.rs │ │ │ │ ├── set.rs │ │ │ │ └── value.rs │ │ │ ├── starlark_value_as_type.rs │ │ │ ├── string.rs │ │ │ ├── string │ │ │ │ ├── alloc_unpack.rs │ │ │ │ ├── dot_format.rs │ │ │ │ ├── globals.rs │ │ │ │ ├── intern.rs │ │ │ │ ├── intern │ │ │ │ │ └── interner.rs │ │ │ │ ├── interpolation.rs │ │ │ │ ├── iter.rs │ │ │ │ ├── methods.rs │ │ │ │ ├── repr.rs │ │ │ │ ├── simd.rs │ │ │ │ └── str_type.rs │ │ │ ├── structs.rs │ │ │ ├── structs │ │ │ │ ├── alloc.rs │ │ │ │ ├── refs.rs │ │ │ │ ├── structs.rs │ │ │ │ ├── unordered_hasher.rs │ │ │ │ └── value.rs │ │ │ ├── tuple.rs │ │ │ ├── tuple │ │ │ │ ├── alloc.rs │ │ │ │ ├── globals.rs │ │ │ │ ├── refs.rs │ │ │ │ ├── rust_tuple.rs │ │ │ │ ├── unpack.rs │ │ │ │ └── value.rs │ │ │ ├── type_instance_id.rs │ │ │ └── unbound.rs │ │ ├── typing.rs │ │ ├── typing │ │ │ ├── any.rs │ │ │ ├── callable.rs │ │ │ ├── callable │ │ │ │ └── param.rs │ │ │ ├── globals.rs │ │ │ ├── iter.rs │ │ │ ├── macro_refs.rs │ │ │ ├── never.rs │ │ │ ├── ty.rs │ │ │ ├── type_compiled.rs │ │ │ ├── type_compiled │ │ │ │ ├── alloc.rs │ │ │ │ ├── compiled.rs │ │ │ │ ├── factory.rs │ │ │ │ ├── globals.rs │ │ │ │ ├── matcher.rs │ │ │ │ ├── matchers.rs │ │ │ │ ├── tests.rs │ │ │ │ └── type_matcher_factory.rs │ │ │ └── type_type.rs │ │ ├── unpack.rs │ │ ├── unpack_and_discard.rs │ │ ├── value_of.rs │ │ └── value_of_unchecked.rs │ └── wasm.rs └── testcases │ └── eval │ └── go │ ├── README.md │ ├── assign.star │ ├── bool.star │ ├── builtin.star │ ├── control.star │ ├── dict.star │ ├── float.star │ ├── function.star │ ├── misc.star │ ├── set.star │ └── tuple.star ├── starlark_bin ├── Cargo.toml └── bin │ ├── bazel.rs │ ├── bazel │ └── label.rs │ ├── dap.rs │ ├── dap │ ├── library.rs │ └── library │ │ ├── events.rs │ │ ├── requests.rs │ │ ├── server.rs │ │ └── stream.rs │ ├── eval.rs │ ├── main.rs │ └── suppression.rs ├── starlark_derive ├── Cargo.toml └── src │ ├── alloc_value.rs │ ├── any_lifetime.rs │ ├── attrs.rs │ ├── bc.rs │ ├── coerce.rs │ ├── freeze.rs │ ├── lib.rs │ ├── module.rs │ ├── module │ ├── param_spec.rs │ ├── parse.rs │ ├── parse │ │ └── fun.rs │ ├── render.rs │ ├── render │ │ └── fun.rs │ ├── simple_param.rs │ ├── typ.rs │ └── util.rs │ ├── serde.rs │ ├── starlark_type_repr.rs │ ├── starlark_value.rs │ ├── trace.rs │ ├── unpack_value.rs │ ├── util.rs │ ├── v_lifetime.rs │ ├── visit_span.rs │ └── vtable.rs ├── starlark_js_example ├── Cargo.toml ├── README.md ├── index.html └── src │ └── lib.rs ├── starlark_lsp ├── Cargo.toml └── src │ ├── bind.rs │ ├── completion.rs │ ├── definition.rs │ ├── docs.rs │ ├── error.rs │ ├── exported.rs │ ├── inspect.rs │ ├── lib.rs │ ├── loaded.rs │ ├── server.rs │ ├── symbols.rs │ └── test.rs ├── starlark_map ├── Cargo.toml ├── build.rs └── src │ ├── hash_value.rs │ ├── hashed.rs │ ├── hasher.rs │ ├── iter.rs │ ├── lib.rs │ ├── mix_u32.rs │ ├── ordered_map.rs │ ├── ordered_set.rs │ ├── small_map.rs │ ├── small_map │ └── iter.rs │ ├── small_set.rs │ ├── small_set │ └── iter.rs │ ├── sorted_map.rs │ ├── sorted_set.rs │ ├── sorted_vec.rs │ ├── sorting.rs │ ├── sorting │ └── insertion.rs │ ├── unordered_map.rs │ ├── unordered_set.rs │ ├── vec2.rs │ ├── vec2 │ └── iter.rs │ ├── vec_map.rs │ └── vec_map │ ├── hint.rs │ ├── iter.rs │ └── simd.rs ├── starlark_syntax ├── Cargo.toml ├── build.rs ├── src │ ├── call_stack.rs │ ├── codemap.rs │ ├── convert_indices.rs │ ├── cursors.rs │ ├── diagnostic.rs │ ├── dialect.rs │ ├── dot_format_parser.rs │ ├── error.rs │ ├── eval_exception.rs │ ├── fast_string.rs │ ├── frame.rs │ ├── golden_test_template.rs │ ├── lexer.rs │ ├── lexer_tests.rs │ ├── lexer_tests │ │ ├── comment.golden │ │ ├── dedent.golden │ │ ├── error_messages.fail.golden │ │ ├── escape_newline.golden │ │ ├── f_string.golden │ │ ├── final_comment.golden │ │ ├── float_lit.golden │ │ ├── identifier.golden │ │ ├── indentation.golden │ │ ├── int_lit.fail.golden │ │ ├── int_lit.golden │ │ ├── keywords.golden │ │ ├── multiline_triple.golden │ │ ├── number_collated_with_keywords_or_identifier.golden │ │ ├── operators.golden │ │ ├── reserved.fail.golden │ │ ├── simple_example.golden │ │ ├── string_escape.fail.golden │ │ ├── string_escape.golden │ │ ├── string_lit.fail.golden │ │ └── symbols.golden │ ├── lib.rs │ ├── slice_vec_ext.rs │ ├── span_display.rs │ ├── syntax.rs │ └── syntax │ │ ├── ast.rs │ │ ├── call.rs │ │ ├── def.rs │ │ ├── def_tests │ │ ├── args_args.golden │ │ ├── default_after_kwargs.golden │ │ ├── dup_name.golden │ │ ├── kwargs_args.golden │ │ ├── kwargs_kwargs.golden │ │ ├── named_only_in_standard_dialect_def.golden │ │ ├── named_only_in_standard_dialect_lambda.golden │ │ ├── normal_after_default.golden │ │ ├── pos_after_default.golden │ │ ├── positional_only_cannot_be_first.golden │ │ ├── positional_only_in_standard_dialect_def.golden │ │ ├── positional_only_in_standard_dialect_lambda.golden │ │ ├── slash_slash.golden │ │ ├── star_cannot_be_last.golden │ │ ├── star_star.golden │ │ ├── star_then_args.golden │ │ └── star_then_kwargs.golden │ │ ├── grammar.lalrpop │ │ ├── grammar_tests.rs │ │ ├── grammar_tests │ │ ├── assignment_type_annotation.golden │ │ ├── bad_assignment.golden │ │ ├── ellipsis.golden │ │ ├── lambda.golden │ │ ├── list_in_index_expr.golden │ │ ├── top_level_def.golden │ │ └── top_level_statements.golden │ │ ├── grammar_util.rs │ │ ├── lint_suppressions.rs │ │ ├── module.rs │ │ ├── parser.rs │ │ ├── payload_map.rs │ │ ├── state.rs │ │ ├── testcases.rs │ │ ├── top_level_stmts.rs │ │ ├── type_expr.rs │ │ ├── uniplate.rs │ │ └── validate.rs └── testcases │ └── parse │ ├── README.md │ ├── action.star │ ├── alias_rules.star │ ├── android_sdk_repository_template.star │ ├── archive.star │ ├── asciidoc.star │ ├── asm.star │ ├── aspect.star │ ├── bazel_hash_dict.star │ ├── bazel_integration_test.star │ ├── bazel_java_integration_test.star │ ├── bazel_py_integration_test.star │ ├── bazel_tests.star │ ├── binary.star │ ├── bindata.star │ ├── bower_archives.star │ ├── bower_components.star │ ├── build.star │ ├── build_defs.star │ ├── bundle.star │ ├── bzl.star │ ├── cc.star │ ├── cc_configure.star │ ├── cgo.star │ ├── classpath.star │ ├── cm.star │ ├── common.star │ ├── compile.star │ ├── compiler.star │ ├── config.star │ ├── container.star │ ├── cover.star │ ├── csharp.star │ ├── def.star │ ├── dicts.star │ ├── docker.star │ ├── docker_base.star │ ├── docker_pull.star │ ├── docker_repository.star │ ├── dockerfile_build.star │ ├── dummy_toolchain.star │ ├── e4b_aspect.star │ ├── eclipse.star │ ├── eclipse_platform.star │ ├── embed_data.star │ ├── embedded_tools.star │ ├── empty.star │ ├── executable.star │ ├── extension.star │ ├── external_plugin_deps.star │ ├── files_equal_test.star │ ├── filetype.star │ ├── flatten.star │ ├── flavours.star │ ├── foo.star │ ├── gazelle.star │ ├── generate_test.star │ ├── generate_workspace.star │ ├── genproto.star │ ├── genrule2.star │ ├── git.star │ ├── git_repositories.star │ ├── go.star │ ├── go_proto_library.star │ ├── go_repository.star │ ├── go_toolchain.star │ ├── guava.star │ ├── gwt.star │ ├── hash.star │ ├── hello.star │ ├── http.star │ ├── image.star │ ├── import.star │ ├── info.star │ ├── intellij_plugin.star │ ├── intellij_plugin_debug_target.star │ ├── java.star │ ├── java_rules_skylark.star │ ├── javadoc.star │ ├── jekyll.star │ ├── jenkins.star │ ├── jenkins_base.star │ ├── jenkins_docker_build.star │ ├── jenkins_job.star │ ├── jenkins_node.star │ ├── jenkins_nodes.star │ ├── jetty.star │ ├── jgit.star │ ├── jobs.star │ ├── js.star │ ├── junit.star │ ├── label.star │ ├── layers.star │ ├── lib_cc_configure.star │ ├── library.star │ ├── license.star │ ├── line_length.star │ ├── lines_sorted_test.star │ ├── link.star │ ├── list.star │ ├── list_source_repository.star │ ├── load.star │ ├── maven.star │ ├── maven_jar.star │ ├── maven_rules.star │ ├── mode.star │ ├── oci.star │ ├── osx_archs.star │ ├── osx_cc_configure.star │ ├── pack.star │ ├── package.star │ ├── passwd.star │ ├── path.star │ ├── paths.star │ ├── pkg.star │ ├── pkg_war.star │ ├── plugin.star │ ├── plugins.star │ ├── popular_repos.star │ ├── prefix.star │ ├── printer.star │ ├── prolog.star │ ├── proto_alias.star │ ├── protobuf.star │ ├── providers.star │ ├── pull.star │ ├── push-all.star │ ├── push.star │ ├── python.star │ ├── redirects.star │ ├── remote.star │ ├── repositories.star │ ├── repository_tools.star │ ├── rpm.star │ ├── rust.star │ ├── self_extract_binary.star │ ├── serialize.star │ ├── sets.star │ ├── shared.star │ ├── shell.star │ ├── single_output_test.star │ ├── site.star │ ├── source.star │ ├── stdlib.star │ ├── structs.star │ ├── templates.star │ ├── test.star │ ├── test_defs.star │ ├── test_rules.star │ ├── tests.star │ ├── toolchain.star │ ├── toolchain_utils.star │ ├── toolchains.star │ ├── transitive_maven_jar.star │ ├── unix_cc_configure.star │ ├── utilities.star │ ├── vars.star │ ├── version.star │ ├── vet.star │ ├── win_rules.star │ ├── windows_cc_configure.star │ ├── with-defaults.star │ ├── with-tag.star │ ├── workspace.star │ ├── wrappers.star │ ├── xcode_configure.star │ ├── xcode_version_flag.star │ └── zip.star └── vscode ├── .gitignore ├── .vscodeignore ├── README.md ├── client ├── package-lock.json ├── package.json ├── src │ └── extension.ts └── tsconfig.json ├── package-lock.json ├── package.json ├── syntaxes ├── starlark.configuration.json └── starlark.tmLanguage.json └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | Cargo.lock 3 | *.wasm 4 | -------------------------------------------------------------------------------- /.rustfmt.toml: -------------------------------------------------------------------------------- 1 | # Get help on options with `rustfmt --help=config` 2 | # Please keep these in alphabetical order. 3 | edition = "2021" 4 | format_code_in_doc_comments = true 5 | group_imports = "StdExternalCrate" 6 | imports_granularity = "Item" 7 | merge_derives = false 8 | style_edition = "2024" 9 | use_field_init_shorthand = true 10 | -------------------------------------------------------------------------------- /allocative/allocative/.gitignore: -------------------------------------------------------------------------------- 1 | *.svg 2 | -------------------------------------------------------------------------------- /allocative/allocative/src/impls.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * 4 | * This source code is licensed under both the MIT license found in the 5 | * LICENSE-MIT file in the root directory of this source tree and the Apache 6 | * License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | * of this source tree. 8 | */ 9 | 10 | //! Manual implementations of `Allocative` for various types. 11 | 12 | mod anyhow; 13 | mod bumpalo; 14 | pub(crate) mod common; 15 | mod compact_str; 16 | mod dashmap; 17 | mod either; 18 | mod futures; 19 | pub(crate) mod hashbrown; 20 | pub(crate) mod hashbrown_util; 21 | mod indexmap; 22 | mod lock_api; 23 | mod num_bigint; 24 | mod once_cell; 25 | mod parking_lot; 26 | mod prost_types; 27 | mod relative_path; 28 | mod serde_json; 29 | mod slab; 30 | mod smallvec; 31 | mod sorted_vector_map; 32 | mod std; 33 | mod tokio; 34 | mod triomphe; 35 | -------------------------------------------------------------------------------- /allocative/allocative/src/impls/anyhow.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * 4 | * This source code is licensed under both the MIT license found in the 5 | * LICENSE-MIT file in the root directory of this source tree and the Apache 6 | * License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | * of this source tree. 8 | */ 9 | 10 | #![cfg(feature = "anyhow")] 11 | 12 | use crate::allocative_trait::Allocative; 13 | use crate::visitor::Visitor; 14 | 15 | impl Allocative for anyhow::Error { 16 | fn visit<'a, 'b: 'a>(&self, visitor: &'a mut Visitor<'b>) { 17 | // Don't know what the size is. 18 | let _ = visitor; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /allocative/allocative/src/impls/common.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * 4 | * This source code is licensed under both the MIT license found in the 5 | * LICENSE-MIT file in the root directory of this source tree and the Apache 6 | * License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | * of this source tree. 8 | */ 9 | 10 | use crate::key::Key; 11 | 12 | /// "Field" describing allocated but unused capacity (e.g. in `Vec`). 13 | pub(crate) const UNUSED_CAPACITY_NAME: Key = Key::new("unused_capacity"); 14 | 15 | /// "Field" describing all capacity (e.g. in `Vec`). 16 | pub(crate) const CAPACITY_NAME: Key = Key::new("capacity"); 17 | 18 | /// Generic pointee field in types like `Box`. 19 | pub(crate) const PTR_NAME: Key = Key::new("ptr"); 20 | 21 | /// Generic name for useful data (e.g. in `Vec`). 22 | pub(crate) const DATA_NAME: Key = Key::new("data"); 23 | 24 | pub(crate) const KEY_NAME: Key = Key::new("key"); 25 | pub(crate) const VALUE_NAME: Key = Key::new("value"); 26 | -------------------------------------------------------------------------------- /allocative/allocative/src/impls/compact_str_test_heap.src: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # ALLOCATIVE_REGENERATE_TESTS=1 cargo test -p allocative 5 | # ``` 6 | compact_str::CompactString 16 7 | compact_str::CompactString;ptr 8 8 | compact_str::CompactString;ptr;str 300 9 | -------------------------------------------------------------------------------- /allocative/allocative/src/impls/compact_str_test_inline.src: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # ALLOCATIVE_REGENERATE_TESTS=1 cargo test -p allocative 5 | # ``` 6 | compact_str::CompactString 24 7 | -------------------------------------------------------------------------------- /allocative/allocative/src/impls/either_test_golden.src: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # ALLOCATIVE_REGENERATE_TESTS=1 cargo test -p allocative 5 | # ``` 6 | either::Either 20 7 | either::Either;Left;u32 4 8 | -------------------------------------------------------------------------------- /allocative/allocative/src/impls/hashbrown_test_hash_table.src: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # ALLOCATIVE_REGENERATE_TESTS=1 cargo test -p allocative 5 | # ``` 6 | hashbrown::table::HashTable 24 7 | hashbrown::table::HashTable;data 8 8 | hashbrown::table::HashTable;data;capacity 800 9 | hashbrown::table::HashTable;data;capacity;alloc::string::String 1600 10 | hashbrown::table::HashTable;data;capacity;alloc::string::String;ptr 800 11 | hashbrown::table::HashTable;data;capacity;alloc::string::String;ptr;capacity;u8 190 12 | hashbrown::table::HashTable;data;capacity;alloc::string::String;ptr;capacity;unused_capacity 610 13 | -------------------------------------------------------------------------------- /allocative/allocative/src/impls/hashbrown_test_raw_table.src: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # ALLOCATIVE_REGENERATE_TESTS=1 cargo test -p allocative 5 | # ``` 6 | hashbrown::raw::inner::RawTable 24 7 | hashbrown::raw::inner::RawTable;data 8 8 | hashbrown::raw::inner::RawTable;data;capacity 800 9 | hashbrown::raw::inner::RawTable;data;capacity;alloc::string::String 1600 10 | hashbrown::raw::inner::RawTable;data;capacity;alloc::string::String;ptr 800 11 | hashbrown::raw::inner::RawTable;data;capacity;alloc::string::String;ptr;capacity;u8 190 12 | hashbrown::raw::inner::RawTable;data;capacity;alloc::string::String;ptr;capacity;unused_capacity 610 13 | -------------------------------------------------------------------------------- /allocative/allocative/src/impls/hashbrown_util.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * 4 | * This source code is licensed under both the MIT license found in the 5 | * LICENSE-MIT file in the root directory of this source tree and the Apache 6 | * License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | * of this source tree. 8 | */ 9 | 10 | use std::mem; 11 | 12 | /// Approximate allocated memory for hashbrown `RawTable`. 13 | #[allow(dead_code)] 14 | pub(crate) fn raw_table_alloc_size_for_len(len: usize) -> usize { 15 | let buckets = if len == 0 { 16 | 0 17 | } else if len < 4 { 18 | 4 19 | } else { 20 | len.next_power_of_two() 21 | }; 22 | let size_of_control_byte = 1; 23 | (mem::size_of::() + size_of_control_byte) * buckets 24 | } 25 | -------------------------------------------------------------------------------- /allocative/allocative/src/impls/parking_lot.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * 4 | * This source code is licensed under both the MIT license found in the 5 | * LICENSE-MIT file in the root directory of this source tree and the Apache 6 | * License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | * of this source tree. 8 | */ 9 | 10 | #![cfg(feature = "parking_lot")] 11 | 12 | use parking_lot::RawMutex; 13 | use parking_lot::RawRwLock; 14 | 15 | use crate::allocative_trait::Allocative; 16 | use crate::visitor::Visitor; 17 | 18 | impl Allocative for RawMutex { 19 | fn visit<'a, 'b: 'a>(&self, visitor: &'a mut Visitor<'b>) { 20 | visitor.enter_self_sized::().exit(); 21 | } 22 | } 23 | 24 | impl Allocative for RawRwLock { 25 | fn visit<'a, 'b: 'a>(&self, visitor: &'a mut Visitor<'b>) { 26 | visitor.enter_self_sized::().exit(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /allocative/allocative/src/impls/prost_types.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * 4 | * This source code is licensed under both the MIT license found in the 5 | * LICENSE-MIT file in the root directory of this source tree and the Apache 6 | * License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | * of this source tree. 8 | */ 9 | 10 | #![cfg(feature = "prost-types")] 11 | 12 | use prost_types::Duration; 13 | use prost_types::Timestamp; 14 | 15 | use crate::allocative_trait::Allocative; 16 | use crate::visitor::Visitor; 17 | 18 | impl Allocative for Timestamp { 19 | fn visit<'a, 'b: 'a>(&self, visitor: &'a mut Visitor<'b>) { 20 | visitor.enter_self_sized::().exit(); 21 | } 22 | } 23 | 24 | impl Allocative for Duration { 25 | fn visit<'a, 'b: 'a>(&self, visitor: &'a mut Visitor<'b>) { 26 | visitor.enter_self_sized::().exit(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /allocative/allocative/src/impls/std.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * 4 | * This source code is licensed under both the MIT license found in the 5 | * LICENSE-MIT file in the root directory of this source tree and the Apache 6 | * License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | * of this source tree. 8 | */ 9 | 10 | mod any; 11 | mod cell; 12 | mod collections; 13 | mod function; 14 | mod mem; 15 | mod net; 16 | mod primitive; 17 | mod sync; 18 | mod time; 19 | mod tuple; 20 | mod unsorted; 21 | -------------------------------------------------------------------------------- /allocative/allocative/src/impls/std/any.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * 4 | * This source code is licensed under both the MIT license found in the 5 | * LICENSE-MIT file in the root directory of this source tree and the Apache 6 | * License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | * of this source tree. 8 | */ 9 | 10 | use crate::allocative_trait::Allocative; 11 | use crate::visitor::Visitor; 12 | 13 | impl Allocative for std::any::TypeId { 14 | fn visit<'a, 'b: 'a>(&self, visitor: &'a mut Visitor<'b>) { 15 | visitor.visit_simple_sized::(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /allocative/allocative/src/impls/std/cell_test_borrowed.src: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # ALLOCATIVE_REGENERATE_TESTS=1 cargo test -p allocative 5 | # ``` 6 | core::cell::RefCell 32 7 | -------------------------------------------------------------------------------- /allocative/allocative/src/impls/std/cell_test_default.src: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # ALLOCATIVE_REGENERATE_TESTS=1 cargo test -p allocative 5 | # ``` 6 | core::cell::RefCell 8 7 | core::cell::RefCell;data;alloc::string::String 16 8 | core::cell::RefCell;data;alloc::string::String;ptr 8 9 | core::cell::RefCell;data;alloc::string::String;ptr;capacity;u8 3 10 | -------------------------------------------------------------------------------- /allocative/allocative/src/impls/std/cell_test_once_cell.src: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # ALLOCATIVE_REGENERATE_TESTS=1 cargo test -p allocative 5 | # ``` 6 | core::cell::once::OnceCell;data;alloc::string::String 16 7 | core::cell::once::OnceCell;data;alloc::string::String;ptr 8 8 | core::cell::once::OnceCell;data;alloc::string::String;ptr;capacity;u8 3 9 | -------------------------------------------------------------------------------- /allocative/allocative/src/impls/std/mem.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * 4 | * This source code is licensed under both the MIT license found in the 5 | * LICENSE-MIT file in the root directory of this source tree and the Apache 6 | * License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | * of this source tree. 8 | */ 9 | 10 | use std::mem::ManuallyDrop; 11 | 12 | use crate::Allocative; 13 | use crate::Key; 14 | use crate::Visitor; 15 | 16 | impl Allocative for ManuallyDrop { 17 | fn visit<'a, 'b: 'a>(&self, visitor: &'a mut Visitor<'b>) { 18 | let mut visitor = visitor.enter_self(self); 19 | visitor.visit_field::(Key::new("inner"), self); 20 | visitor.exit(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /allocative/allocative/src/impls/std/sync_test_arc_align.src: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # ALLOCATIVE_REGENERATE_TESTS=1 cargo test -p allocative 5 | # ``` 6 | ArcInner 64 7 | ArcInner;allocative::impls::std::sync::tests::CacheLine 63 8 | ArcInner;allocative::impls::std::sync::tests::CacheLine;0;u8 1 9 | alloc::sync::Arc;ptr 8 10 | -------------------------------------------------------------------------------- /allocative/allocative/src/impls/std/thread.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * 4 | * This source code is licensed under both the MIT license found in the 5 | * LICENSE-MIT file in the root directory of this source tree and the Apache 6 | * License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | * of this source tree. 8 | */ 9 | 10 | use std::thread::ThreadId; 11 | 12 | use crate::allocative_trait::Allocative; 13 | use crate::visitor::Visitor; 14 | 15 | impl Allocative for ThreadId { 16 | fn visit<'a, 'b: 'a>(&self, visitor: &'a mut Visitor<'b>) { 17 | visitor.enter_self_sized::().exit(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /allocative/allocative/src/impls/triomphe_test_align.src: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # ALLOCATIVE_REGENERATE_TESTS=1 cargo test -p allocative 5 | # ``` 6 | allocative::impls::triomphe::ArcInnerRepr 15 7 | allocative::impls::triomphe::ArcInnerRepr;data;u8 1 8 | triomphe::arc::Arc;ptr 8 9 | -------------------------------------------------------------------------------- /allocative/allocative/src/impls/triomphe_test_shared.src: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # ALLOCATIVE_REGENERATE_TESTS=1 cargo test -p allocative 5 | # ``` 6 | alloc::vec::Vec> 16 7 | alloc::vec::Vec>;ptr 8 8 | alloc::vec::Vec>;ptr;triomphe::arc::Arc;ptr 24 9 | allocative::impls::triomphe::ArcInnerRepr 8 10 | allocative::impls::triomphe::ArcInnerRepr;data;alloc::string::String 16 11 | allocative::impls::triomphe::ArcInnerRepr;data;alloc::string::String;ptr 8 12 | allocative::impls::triomphe::ArcInnerRepr;data;alloc::string::String;ptr;capacity;u8 100 13 | -------------------------------------------------------------------------------- /allocative/allocative/src/impls/triomphe_test_simple.src: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # ALLOCATIVE_REGENERATE_TESTS=1 cargo test -p allocative 5 | # ``` 6 | allocative::impls::triomphe::ArcInnerRepr 8 7 | allocative::impls::triomphe::ArcInnerRepr;data;alloc::string::String 16 8 | allocative::impls::triomphe::ArcInnerRepr;data;alloc::string::String;ptr 8 9 | allocative::impls::triomphe::ArcInnerRepr;data;alloc::string::String;ptr;capacity;u8 3 10 | triomphe::arc::Arc;ptr 8 11 | -------------------------------------------------------------------------------- /allocative/allocative/src/test_derive/dst.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * 4 | * This source code is licensed under both the MIT license found in the 5 | * LICENSE-MIT file in the root directory of this source tree and the Apache 6 | * License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | * of this source tree. 8 | */ 9 | 10 | use allocative_derive::Allocative; 11 | 12 | use crate as allocative; 13 | 14 | #[derive(Allocative)] 15 | struct Dst(str); 16 | -------------------------------------------------------------------------------- /allocative/allocative/src/test_derive/visit.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * 4 | * This source code is licensed under both the MIT license found in the 5 | * LICENSE-MIT file in the root directory of this source tree and the Apache 6 | * License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | * of this source tree. 8 | */ 9 | 10 | use allocative_derive::Allocative; 11 | 12 | use crate as allocative; 13 | use crate::Visitor; 14 | 15 | struct DoesNotImplementAllocative(T); 16 | 17 | fn visit_does_not_implement_allocative( 18 | _field: &DoesNotImplementAllocative, 19 | visitor: &mut Visitor<'_>, 20 | ) { 21 | visitor 22 | .enter_self_sized::>() 23 | .exit(); 24 | } 25 | 26 | #[derive(Allocative)] 27 | struct MyStruct { 28 | #[allocative(visit = visit_does_not_implement_allocative)] 29 | field: DoesNotImplementAllocative, 30 | } 31 | -------------------------------------------------------------------------------- /allocative/allocative_derive/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ["Meta"] 3 | description = "Implementation of derive(Allocative) for allocative crate" 4 | documentation = "https://docs.rs/allocative" 5 | edition = "2024" 6 | license = { workspace = true } 7 | name = "allocative_derive" 8 | repository = "https://github.com/facebookexperimental/allocative" 9 | version = "0.3.3" 10 | 11 | [lib] 12 | proc-macro = true 13 | 14 | [dependencies] 15 | proc-macro2 = { workspace = true } 16 | quote = { workspace = true } 17 | syn = { workspace = true } 18 | -------------------------------------------------------------------------------- /allocative/allocative_derive/src/lib.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * 4 | * This source code is licensed under both the MIT license found in the 5 | * LICENSE-MIT file in the root directory of this source tree and the Apache 6 | * License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | * of this source tree. 8 | */ 9 | 10 | use proc_macro::TokenStream; 11 | 12 | mod derive_allocative; 13 | mod root; 14 | 15 | #[proc_macro_derive(Allocative, attributes(allocative))] 16 | pub fn derive_allocative(input: TokenStream) -> TokenStream { 17 | derive_allocative::derive_allocative(input) 18 | } 19 | 20 | #[proc_macro_attribute] 21 | pub fn root(attr: TokenStream, input: TokenStream) -> TokenStream { 22 | root::root(attr, input) 23 | } 24 | -------------------------------------------------------------------------------- /allocative/sample-flamegraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebook/starlark-rust/303e95acf785ce0460b1bb057407eaa674340796/allocative/sample-flamegraph.png -------------------------------------------------------------------------------- /benchmark/results_linux.txt: -------------------------------------------------------------------------------- 1 | Updated 26 May 2020 2 | CPU: Intel(R) Xeon(R) CPU E5-2680 v4 @ 2.40GHz 3 | Mem: 264 GB 4 | 5 | Benchmarking: benchmark_loop ........... 6 | Python3 2.19s, Starlark Rust 0.68s 7 | Benchmarking: benchmark_multiply ........... 8 | Python3 4.15s, Starlark Rust 2.62s 9 | Benchmarking: benchmark_call_native_1pos ........... 10 | Python3 6.19s, Starlark Rust 8.08s 11 | Benchmarking: benchmark_call_def_1pos ........... 12 | Python3 8.52s, Starlark Rust 8.36s 13 | Benchmarking: benchmark_call_def_8pos ........... 14 | Python3 12.86s, Starlark Rust 14.03s 15 | Benchmarking: benchmark_call_def_1name ........... 16 | Python3 10.79s, Starlark Rust 8.91s 17 | Benchmarking: benchmark_call_def_8name ........... 18 | Python3 17.91s, Starlark Rust 21.10s 19 | -------------------------------------------------------------------------------- /benchmark/results_mac.txt: -------------------------------------------------------------------------------- 1 | Updated 26 May 2020 2 | CPU: 2.4 GHz 8-Core Intel Core i9 3 | Mem: 32 GB 2667 MHz DDR4 4 | 5 | Benchmarking: benchmark_loop ....... 6 | Python3 1.93s, Starlark Rust 0.50s 7 | Benchmarking: benchmark_multiply ....... 8 | Python3 3.80s, Starlark Rust 1.85s 9 | Benchmarking: benchmark_call_native_len ....... 10 | Python3 6.08s, Starlark Rust 1.75s 11 | Benchmarking: benchmark_call_native_1pos ....... 12 | Python3 5.84s, Starlark Rust 3.54s 13 | Benchmarking: benchmark_call_def_1pos ....... 14 | Python3 8.53s, Starlark Rust 3.93s 15 | Benchmarking: benchmark_call_def_8pos ....... 16 | Python3 12.10s, Starlark Rust 8.33s 17 | Benchmarking: benchmark_call_def_1name ....... 18 | Python3 10.41s, Starlark Rust 5.75s 19 | Benchmarking: benchmark_call_def_8name ....... 20 | Python3 16.91s, Starlark Rust 15.33s 21 | -------------------------------------------------------------------------------- /docs/spec.md: -------------------------------------------------------------------------------- 1 | # Starlark Language Specification 2 | 3 | The Starlark language spec can be found in the 4 | [Bazel GitHub repository](https://github.com/bazelbuild/starlark/blob/master/spec.md). 5 | -------------------------------------------------------------------------------- /gazebo/cmp_any/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ["Facebook"] 3 | categories = ["rust-patterns"] 4 | description = "Comparison for &dyn types" 5 | documentation = "https://docs.rs/cmp_any" 6 | edition = "2024" 7 | license = { workspace = true } 8 | name = "cmp_any" 9 | repository = "https://github.com/facebookincubator/gazebo" 10 | version = "0.8.1" 11 | -------------------------------------------------------------------------------- /gazebo/cmp_any/src/lib.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * 4 | * This source code is licensed under both the MIT license found in the 5 | * LICENSE-MIT file in the root directory of this source tree and the Apache 6 | * License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | * of this source tree. 8 | */ 9 | 10 | mod eq; 11 | mod ord; 12 | 13 | pub use eq::PartialEqAny; 14 | pub use ord::OrdAny; 15 | -------------------------------------------------------------------------------- /gazebo/display_container/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ["Facebook"] 3 | categories = ["rust-patterns"] 4 | description = "Utilities to implement Display" 5 | documentation = "https://docs.rs/display_container" 6 | edition = "2024" 7 | license = { workspace = true } 8 | name = "display_container" 9 | repository = "https://github.com/facebookincubator/gazebo" 10 | version = "0.9.0" 11 | 12 | [dependencies] 13 | either = { workspace = true } 14 | indenter = { workspace = true } 15 | -------------------------------------------------------------------------------- /gazebo/dupe/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ["Facebook"] 3 | categories = ["rust-patterns"] 4 | description = "Marker for types which are cheap to clone" 5 | documentation = "https://docs.rs/dupe" 6 | edition = "2024" 7 | license = { workspace = true } 8 | name = "dupe" 9 | repository = "https://github.com/facebookincubator/gazebo" 10 | version = "0.9.1" 11 | 12 | [dependencies] 13 | dupe_derive = { version = "=0.9.1", path = "../dupe_derive" } 14 | -------------------------------------------------------------------------------- /gazebo/dupe/src/__macro_refs.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * 4 | * This source code is licensed under both the MIT license found in the 5 | * LICENSE-MIT file in the root directory of this source tree and the Apache 6 | * License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | * of this source tree. 8 | */ 9 | 10 | #![doc(hidden)] 11 | 12 | use crate::Dupe; 13 | 14 | #[inline] 15 | pub const fn assert_dupe() {} 16 | -------------------------------------------------------------------------------- /gazebo/dupe_derive/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ["Facebook"] 3 | categories = ["rust-patterns"] 4 | description = "Derive Dupe" 5 | documentation = "https://docs.rs/dupe" 6 | edition = "2024" 7 | license = { workspace = true } 8 | name = "dupe_derive" 9 | repository = "https://github.com/facebookincubator/gazebo" 10 | version = "0.9.1" 11 | 12 | [lib] 13 | proc-macro = true 14 | 15 | [dependencies] 16 | proc-macro2 = "1.0" 17 | quote = "1.0.3" 18 | syn = { version = "2", features = ["extra-traits"] } 19 | -------------------------------------------------------------------------------- /gazebo/dupe_derive/src/copy.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * 4 | * This source code is licensed under both the MIT license found in the 5 | * LICENSE-MIT file in the root directory of this source tree and the Apache 6 | * License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | * of this source tree. 8 | */ 9 | 10 | use quote::quote; 11 | use syn::DeriveInput; 12 | use syn::parse_macro_input; 13 | 14 | pub fn derive_copy_(input: proc_macro::TokenStream) -> proc_macro::TokenStream { 15 | let input = parse_macro_input!(input as DeriveInput); 16 | let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl(); 17 | 18 | let name = &input.ident; 19 | let generated = quote! { 20 | impl #impl_generics ::std::marker::Copy for #name #ty_generics #where_clause { 21 | } 22 | }; 23 | generated.into() 24 | } 25 | -------------------------------------------------------------------------------- /gazebo/gazebo/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ["Facebook"] 3 | categories = ["rust-patterns"] 4 | description = "A collection of well-tested utilities" 5 | documentation = "https://docs.rs/gazebo" 6 | edition = "2024" 7 | license = { workspace = true } 8 | name = "gazebo" 9 | repository = "https://github.com/facebookincubator/gazebo" 10 | version = "0.8.1" 11 | 12 | [features] 13 | str_pattern_extensions = [] 14 | 15 | [dependencies] 16 | dupe = { version = "0.9.1", path = "../dupe" } 17 | gazebo_derive = { version = "0.8.0", path = "../gazebo_derive" } 18 | -------------------------------------------------------------------------------- /gazebo/gazebo/src/ext.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * 4 | * This source code is licensed under both the MIT license found in the 5 | * LICENSE-MIT file in the root directory of this source tree and the Apache 6 | * License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | * of this source tree. 8 | */ 9 | 10 | pub(crate) mod iter; 11 | pub(crate) mod option; 12 | pub(crate) mod vec; 13 | -------------------------------------------------------------------------------- /gazebo/gazebo/src/lib.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * 4 | * This source code is licensed under both the MIT license found in the 5 | * LICENSE-MIT file in the root directory of this source tree and the Apache 6 | * License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | * of this source tree. 8 | */ 9 | 10 | #![cfg_attr(feature = "str_pattern_extensions", feature(pattern))] 11 | #![allow(clippy::too_long_first_doc_paragraph)] 12 | 13 | //! A collection of well-tested primitives that have been useful. Most modules stand alone. 14 | 15 | pub mod cast; 16 | pub mod cell; 17 | pub mod cmp; 18 | pub(crate) mod ext; 19 | pub mod file; 20 | pub mod hash; 21 | pub mod phantom; 22 | pub mod prelude; 23 | pub mod types; 24 | pub mod variants; 25 | 26 | #[cfg(test)] 27 | mod test; 28 | -------------------------------------------------------------------------------- /gazebo/gazebo/src/test.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * 4 | * This source code is licensed under both the MIT license found in the 5 | * LICENSE-MIT file in the root directory of this source tree and the Apache 6 | * License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | * of this source tree. 8 | */ 9 | 10 | use std::collections::HashMap; 11 | 12 | use crate::prelude::*; 13 | 14 | enum NoDefault { 15 | _None, 16 | } 17 | 18 | #[derive(Default_)] 19 | struct Foo { 20 | mp: HashMap, 21 | xs: Vec, 22 | } 23 | 24 | #[derive(Default_, Debug, PartialEq)] 25 | struct Bar; 26 | 27 | #[test] 28 | fn test_default_() { 29 | let x: Foo = Default::default(); 30 | assert_eq!(x.mp.len(), 0); 31 | assert_eq!(x.xs.len(), 0); 32 | 33 | assert_eq!(Bar, Default::default()); 34 | } 35 | -------------------------------------------------------------------------------- /gazebo/gazebo_derive/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ["Facebook"] 3 | categories = ["rust-patterns"] 4 | description = "Derive macros for the Gazebo library" 5 | documentation = "https://docs.rs/gazebo_derive" 6 | edition = "2024" 7 | license = { workspace = true } 8 | name = "gazebo_derive" 9 | repository = "https://github.com/facebookincubator/gazebo" 10 | version = "0.8.0" 11 | 12 | [lib] 13 | proc-macro = true 14 | 15 | [dependencies] 16 | proc-macro2 = "1.0" 17 | quote = "1.0.3" 18 | syn = { version = "2", features = ["extra-traits"] } 19 | -------------------------------------------------------------------------------- /gazebo/strong_hash/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | description = "Hash trait similar to std::hash::Hash but for strong/cryptographic hashes" 3 | edition = "2024" 4 | license = { workspace = true } 5 | name = "strong_hash" 6 | repository = { workspace = true } 7 | version = "0.1.0" 8 | 9 | [dependencies] 10 | num-bigint = { version = "0.4.3", optional = true } 11 | ref-cast = { workspace = true } 12 | strong_hash_derive = { workspace = true } 13 | triomphe = { version = "0.1.8", optional = true } 14 | -------------------------------------------------------------------------------- /gazebo/strong_hash/src/impls.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * 4 | * This source code is licensed under both the MIT license found in the 5 | * LICENSE-MIT file in the root directory of this source tree and the Apache 6 | * License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | * of this source tree. 8 | */ 9 | 10 | mod num_bigint; 11 | mod triomphe; 12 | -------------------------------------------------------------------------------- /gazebo/strong_hash/src/impls/num_bigint.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * 4 | * This source code is licensed under both the MIT license found in the 5 | * LICENSE-MIT file in the root directory of this source tree and the Apache 6 | * License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | * of this source tree. 8 | */ 9 | 10 | #![cfg(feature = "num-bigint")] 11 | use crate as strong_hash; 12 | 13 | crate::impl_strong_hash_for_impl_hash!(num_bigint::BigInt); 14 | -------------------------------------------------------------------------------- /gazebo/strong_hash/src/impls/triomphe.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * 4 | * This source code is licensed under both the MIT license found in the 5 | * LICENSE-MIT file in the root directory of this source tree and the Apache 6 | * License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | * of this source tree. 8 | */ 9 | 10 | #![cfg(feature = "triomphe")] 11 | 12 | use crate::StrongHash; 13 | 14 | impl StrongHash for triomphe::Arc { 15 | fn strong_hash(&self, state: &mut H) { 16 | self.as_ref().strong_hash(state); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /gazebo/strong_hash_derive/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | description = "Proc macro for strong_hash crate" 3 | edition = "2024" 4 | license = { workspace = true } 5 | name = "strong_hash_derive" 6 | repository = { workspace = true } 7 | version = "0.1.0" 8 | 9 | [lib] 10 | proc-macro = true 11 | 12 | [dependencies] 13 | quote = { workspace = true } 14 | syn = { workspace = true } 15 | -------------------------------------------------------------------------------- /gazebo/strong_hash_tests/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | description = "Tests for strong_hash crate" 3 | edition = "2024" 4 | license = { workspace = true } 5 | name = "strong_hash_tests" 6 | repository = { workspace = true } 7 | version = "0.1.0" 8 | 9 | [dev-dependencies] 10 | blake3 = { workspace = true } 11 | strong_hash = { workspace = true } 12 | -------------------------------------------------------------------------------- /starlark/fuzz/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | corpus 3 | artifacts 4 | coverage 5 | -------------------------------------------------------------------------------- /starlark/fuzz/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | edition = "2024" 3 | name = "starlark-fuzz" 4 | publish = false 5 | version = "0.0.0" 6 | 7 | [package.metadata] 8 | cargo-fuzz = true 9 | 10 | [dependencies] 11 | libfuzzer-sys = "0.4" 12 | starlark.path = ".." 13 | 14 | # Prevent this from interfering with workspaces 15 | [workspace] 16 | members = ["."] 17 | 18 | [profile.release] 19 | debug = 1 20 | 21 | [[bin]] 22 | doc = false 23 | name = "starlark" 24 | path = "fuzz_targets/starlark.rs" 25 | test = false 26 | -------------------------------------------------------------------------------- /starlark/hello_world.star: -------------------------------------------------------------------------------- 1 | # Copyright 2018 The Starlark in Rust Authors. 2 | # Copyright (c) Facebook, Inc. and its affiliates. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # https://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # A simple Starlark file, as a Hello World 17 | 18 | def main(): 19 | return "Hello, World!" 20 | 21 | x = 1553 * 827 22 | main() 23 | -------------------------------------------------------------------------------- /starlark/src/analysis/unused_loads.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | pub(crate) mod find; 19 | mod find_tests; 20 | pub(crate) mod remove; 21 | mod remove_tests; 22 | -------------------------------------------------------------------------------- /starlark/src/analysis/unused_loads/find/one_of_two_unused.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | load("foo", "x", "y") 9 | print(x) 10 | 11 | Unused loads: 12 | 13 | error: Unused load 14 | --> one_of_two_unused:1:18 15 | | 16 | 1 | load("foo", "x", "y") 17 | | ^^^ 18 | | 19 | -------------------------------------------------------------------------------- /starlark/src/analysis/unused_loads/find/simple.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | load("foo", "x") 9 | 10 | Unused loads: 11 | 12 | error: Unused load 13 | --> simple:1:1 14 | | 15 | 1 | load("foo", "x") 16 | | ^^^^^^^^^^^^^^^^ 17 | | 18 | -------------------------------------------------------------------------------- /starlark/src/analysis/unused_loads/find/unused_annotation_on_arg.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | load("foo", 9 | "T", # @unused 10 | "U", 11 | ) 12 | 13 | Unused loads: 14 | 15 | error: Unused load 16 | --> unused_annotation_on_arg:3:5 17 | | 18 | 3 | "U", 19 | | ^^^ 20 | | 21 | -------------------------------------------------------------------------------- /starlark/src/analysis/unused_loads/find/used_in_top_level_assignment.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | load("foo", "x") 9 | y = x 10 | 11 | No unused loads 12 | -------------------------------------------------------------------------------- /starlark/src/analysis/unused_loads/find/used_in_type_expr.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | load("foo", "T") 9 | load("bar", "U") 10 | 11 | y: T = 1 12 | 13 | def f(x: U): 14 | pass 15 | 16 | No unused loads 17 | -------------------------------------------------------------------------------- /starlark/src/analysis/unused_loads/find/with_rename.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | load("foo", x="y", z="w") 9 | y = z 10 | 11 | Unused loads: 12 | 13 | error: Unused load 14 | --> with_rename:1:13 15 | | 16 | 1 | load("foo", x="y", z="w") 17 | | ^^^^^ 18 | | 19 | -------------------------------------------------------------------------------- /starlark/src/analysis/unused_loads/remove/remove_all.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | load("foo", "x", "y") 9 | print("test") 10 | 11 | Removed unused loads: 12 | 13 | print("test") 14 | -------------------------------------------------------------------------------- /starlark/src/analysis/unused_loads/remove/remove_first_of_two.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | load("foo", "x", "y") 9 | print(y) 10 | 11 | Removed unused loads: 12 | load("foo", "y") 13 | print(y) 14 | -------------------------------------------------------------------------------- /starlark/src/analysis/unused_loads/remove/remove_second_of_two.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | load("foo", "x", "y") 9 | print(x) 10 | 11 | Removed unused loads: 12 | load("foo", "x", ) 13 | print(x) 14 | -------------------------------------------------------------------------------- /starlark/src/collections/symbol.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | pub(crate) mod map; 19 | pub(crate) mod symbol; 20 | -------------------------------------------------------------------------------- /starlark/src/debug.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | //! Provides debug-related functionality and utilities. 19 | mod adapter; 20 | 21 | mod evaluate; 22 | mod inspect; 23 | 24 | pub use adapter::*; 25 | -------------------------------------------------------------------------------- /starlark/src/docs/tests.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | mod markdown; 19 | mod rustdocs; 20 | -------------------------------------------------------------------------------- /starlark/src/docs/tests/golden/multipage/Magic.golden.md: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | # Magic 8 | 9 | ```python 10 | def Magic(a1: int, a2: int = ..., step: int = 1, /) -> str 11 | ``` 12 | 13 | A function with only positional arguments. 14 | 15 | And a slightly longer description. With some example code: 16 | 17 | ```python 18 | Magic(1) 19 | ``` 20 | 21 | And some assertions: 22 | 23 | ```rust 24 | 1 == 1 25 | ``` 26 | -------------------------------------------------------------------------------- /starlark/src/docs/tests/golden/multipage/Obj.golden.md: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | # Obj 8 | 9 | These are where the module docs go 10 | 11 | ## Obj.\_\_exported\_\_ 12 | 13 | ```python 14 | def Obj.__exported__() -> None 15 | ``` 16 | 17 | Needs to be escaped when rendered in markdown. 18 | 19 | --- 20 | 21 | ## Obj.attr1 22 | 23 | ```python 24 | Obj.attr1: str 25 | ``` 26 | 27 | Docs for attr1 28 | 29 | --- 30 | 31 | ## Obj.attr2 32 | 33 | ```python 34 | Obj.attr2: str 35 | ``` 36 | 37 | --- 38 | 39 | ## Obj.func1 40 | 41 | ```python 42 | def Obj.func1(foo: str) -> str 43 | ``` 44 | 45 | Docs for func1 46 | 47 | #### Parameters 48 | 49 | * `foo`: Docs for foo 50 | 51 | 52 | #### Returns 53 | 54 | The string 'func1' 55 | 56 | --- 57 | 58 | ## Obj.func2 59 | 60 | ```python 61 | def Obj.func2() -> str 62 | ``` 63 | -------------------------------------------------------------------------------- /starlark/src/docs/tests/golden/multipage/globals.golden.md: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | # globals 8 | 9 | ## MAGIC 10 | 11 | ```python 12 | MAGIC: int 13 | ``` 14 | 15 | --- 16 | 17 | ## func1 18 | 19 | ```python 20 | def func1(foo: str) -> str 21 | ``` 22 | 23 | Docs for func1 24 | 25 | #### Parameters 26 | 27 | * `foo`: Docs for foo 28 | 29 | 30 | #### Returns 31 | 32 | The string 'func1' 33 | 34 | --- 35 | 36 | ## func2 37 | 38 | ```python 39 | def func2() -> str 40 | ``` 41 | 42 | --- 43 | 44 | ## pos\_either\_named 45 | 46 | ```python 47 | def pos_either_named(a: int, /, b: int, *, c: int) -> magic 48 | ``` 49 | 50 | --- 51 | 52 | ## with\_defaults 53 | 54 | ```python 55 | def with_defaults( 56 | explicit_default: list[str] = [], 57 | hidden_default: list[str] = ..., 58 | string_default: str = "my_default", 59 | ) -> None 60 | ``` 61 | -------------------------------------------------------------------------------- /starlark/src/docs/tests/golden/multipage/submod.golden.md: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | # submod 8 | 9 | ## new\_obj 10 | 11 | ```python 12 | def new_obj() -> obj 13 | ``` 14 | 15 | --- 16 | 17 | ## notypes 18 | 19 | ```python 20 | def notypes(a) 21 | ``` 22 | 23 | --- 24 | 25 | ## starlark\_args 26 | 27 | ```python 28 | def starlark_args(*args: str) -> None 29 | ``` 30 | 31 | --- 32 | 33 | ## starlark\_kwargs 34 | 35 | ```python 36 | def starlark_kwargs(**kwargs: int) -> None 37 | ``` 38 | -------------------------------------------------------------------------------- /starlark/src/docs/tests/golden/multipage_linked_type/Magic.golden.md: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | # Magic 8 | 9 |
def Magic(a1: int, a2: int = ..., step: int = 1, /) -> str
10 | 11 | A function with only positional arguments. 12 | 13 | And a slightly longer description. With some example code: 14 | 15 | ```python 16 | Magic(1) 17 | ``` 18 | 19 | And some assertions: 20 | 21 | ```rust 22 | 1 == 1 23 | ``` 24 | -------------------------------------------------------------------------------- /starlark/src/docs/tests/golden/multipage_linked_type/submod.golden.md: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | # submod 8 | 9 | ## new\_obj 10 | 11 |
def new_obj() -> obj
12 | 13 | --- 14 | 15 | ## notypes 16 | 17 |
def notypes(a)
18 | 19 | --- 20 | 21 | ## starlark\_args 22 | 23 |
def starlark_args(*args: str) -> None
24 | 25 | --- 26 | 27 | ## starlark\_kwargs 28 | 29 |
def starlark_kwargs(**kwargs: int) -> None
30 | -------------------------------------------------------------------------------- /starlark/src/docs/tests/golden/object.golden.md: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | # `name` type 8 | 9 | These are where the module docs go 10 | 11 | ## name.\_\_exported\_\_ 12 | 13 | ```python 14 | def name.__exported__() -> None 15 | ``` 16 | 17 | Needs to be escaped when rendered in markdown. 18 | 19 | --- 20 | 21 | ## name.attr1 22 | 23 | ```python 24 | name.attr1: str 25 | ``` 26 | 27 | Docs for attr1 28 | 29 | --- 30 | 31 | ## name.attr2 32 | 33 | ```python 34 | name.attr2: str 35 | ``` 36 | 37 | --- 38 | 39 | ## name.func1 40 | 41 | ```python 42 | def name.func1(foo: str) -> str 43 | ``` 44 | 45 | Docs for func1 46 | 47 | #### Parameters 48 | 49 | * `foo`: Docs for foo 50 | 51 | 52 | #### Returns 53 | 54 | The string 'func1' 55 | 56 | --- 57 | 58 | ## name.func2 59 | 60 | ```python 61 | def name.func2() -> str 62 | ``` 63 | -------------------------------------------------------------------------------- /starlark/src/errors.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | //! Error types used by Starlark. 19 | 20 | pub use starlark_syntax::frame::Frame; 21 | 22 | pub use crate::analysis::EvalMessage; 23 | pub use crate::analysis::EvalSeverity; 24 | pub use crate::analysis::Lint; 25 | 26 | pub(crate) mod did_you_mean; 27 | -------------------------------------------------------------------------------- /starlark/src/eval/bc/compiler.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | //! Compile module or function to bytecode. 19 | 20 | pub(crate) mod assign; 21 | pub(crate) mod assign_modify; 22 | pub(crate) mod call; 23 | pub(crate) mod compr; 24 | pub(crate) mod def; 25 | pub(crate) mod expr; 26 | pub(crate) mod if_compiler; 27 | pub(crate) mod stmt; 28 | -------------------------------------------------------------------------------- /starlark/src/eval/runtime/params.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | //! Function parameters. 19 | 20 | pub(crate) mod display; 21 | pub(crate) mod parser; 22 | pub(crate) mod spec; 23 | -------------------------------------------------------------------------------- /starlark/src/eval/runtime/profile/golden/coverage.csv.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | test.star:2:1-9:1 8 | test.star:3:5-9:1 9 | test.star:6:9-9:1 10 | test.star:7:13-19 11 | test.star:9:1-16:1 12 | test.star:10:5-11 13 | test.star:11:5-14:1 14 | test.star:12:9-17 15 | test.star:13:9-27 16 | test.star:14:5-13 17 | test.star:16:1-7 18 | test.star:17:1-7 19 | test.star:18:1-7 20 | test.star:20:1-11 21 | -------------------------------------------------------------------------------- /starlark/src/eval/runtime/profile/golden/heap_allocated.csv.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Function,Time(s),TimeRec(s),Calls,Callers,TopCaller,TopCallerCount,Allocs,AllocBytes,dict,array,list,tuple,function 8 | "TOTALS",0.378,0.378,24,0,"",0,378,3024,244,60,48,24,2 9 | "test.star.test",0.168,0.308,20,1,"module",1,156,1248,24,60,48,24,0 10 | "test.star.inner",0.140,0.140,0,1,"test.star.test",1,220,1760,220,0,0,0,0 11 | "module",0.070,0.378,4,1,"(root)",1,2,16,0,0,0,0,2 12 | -------------------------------------------------------------------------------- /starlark/src/eval/runtime/profile/golden/heap_allocated.flame.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | range 8 8 | module;function 16 9 | module;test.star.test;dict 192 10 | module;test.star.test;list 384 11 | module;test.star.test;array 480 12 | module;test.star.test;tuple 192 13 | module;test.star.test;test.star.inner;dict 1760 14 | -------------------------------------------------------------------------------- /starlark/src/eval/runtime/profile/golden/heap_flame_allocated.flame.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | range 8 8 | module;function 16 9 | module;test.star.test;dict 192 10 | module;test.star.test;list 384 11 | module;test.star.test;array 480 12 | module;test.star.test;tuple 192 13 | module;test.star.test;test.star.inner;dict 1760 14 | -------------------------------------------------------------------------------- /starlark/src/eval/runtime/profile/golden/heap_flame_retained.flame.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | module;function 16 8 | module;test.star.test;list 8 9 | -------------------------------------------------------------------------------- /starlark/src/eval/runtime/profile/golden/heap_retained.csv.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Function,Time(s),TimeRec(s),Calls,Callers,TopCaller,TopCallerCount,Allocs,AllocBytes,function,list 8 | "TOTALS",0.378,0.378,24,0,"",0,3,24,2,1 9 | "test.star.test",0.168,0.308,20,1,"module",1,1,8,0,1 10 | "test.star.inner",0.140,0.140,0,1,"test.star.test",1,0,0,0,0 11 | "module",0.070,0.378,4,1,"(root)",1,2,16,2,0 12 | -------------------------------------------------------------------------------- /starlark/src/eval/runtime/profile/golden/heap_retained.flame.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | module;function 16 8 | module;test.star.test;list 8 9 | -------------------------------------------------------------------------------- /starlark/src/eval/runtime/profile/golden/heap_summary_allocated.csv.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Function,Time(s),TimeRec(s),Calls,Callers,TopCaller,TopCallerCount,Allocs,AllocBytes,dict,array,list,tuple,function 8 | "TOTALS",0.378,0.378,24,0,"",0,378,3024,244,60,48,24,2 9 | "test.star.test",0.168,0.308,20,1,"module",1,156,1248,24,60,48,24,0 10 | "test.star.inner",0.140,0.140,0,1,"test.star.test",1,220,1760,220,0,0,0,0 11 | "module",0.070,0.378,4,1,"(root)",1,2,16,0,0,0,0,2 12 | -------------------------------------------------------------------------------- /starlark/src/eval/runtime/profile/golden/heap_summary_retained.csv.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Function,Time(s),TimeRec(s),Calls,Callers,TopCaller,TopCallerCount,Allocs,AllocBytes,function,list 8 | "TOTALS",0.378,0.378,24,0,"",0,3,24,2,1 9 | "test.star.test",0.168,0.308,20,1,"module",1,1,8,0,1 10 | "test.star.inner",0.140,0.140,0,1,"test.star.test",1,0,0,0,0 11 | "module",0.070,0.378,4,1,"(root)",1,2,16,2,0 12 | -------------------------------------------------------------------------------- /starlark/src/eval/runtime/profile/golden/statement.csv.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | File,Span,Duration(s),Count 8 | "TOTAL","",3.864,552 9 | "test.star","7:13-19",2.800,400 10 | "test.star","3:5-9:1",0.280,40 11 | "test.star","13:9-27",0.280,40 12 | "test.star","6:9-9:1",0.140,20 13 | "test.star","12:9-17",0.140,20 14 | "test.star","11:5-14:1",0.056,8 15 | "test.star","10:5-11",0.028,4 16 | "test.star","14:5-13",0.028,4 17 | "test.star","16:1-7",0.021,3 18 | "test.star","17:1-7",0.021,3 19 | "test.star","18:1-7",0.021,3 20 | "test.star","20:1-11",0.021,3 21 | "test.star","2:1-9:1",0.014,2 22 | "test.star","9:1-16:1",0.014,2 23 | -------------------------------------------------------------------------------- /starlark/src/eval/runtime/profile/golden/time_flame.flame.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | root 35 8 | root;"module" 70 9 | root;"module";test.star.test 168 10 | root;"module";test.star.test;test.star.inner 140 11 | -------------------------------------------------------------------------------- /starlark/src/eval/runtime/profile/golden/typecheck.csv.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Function,Time (s) 8 | "TOTAL",0.140 9 | "inner",0.140 10 | -------------------------------------------------------------------------------- /starlark/src/private.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Marker for code which is used in public API, but should not be used outside of the crate. 19 | // No `///` documentation here to trigger `#![deny(missing_docs)]` 20 | // if this accidentally becomes visible. 21 | pub struct Private; 22 | -------------------------------------------------------------------------------- /starlark/src/sealed.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Marker for traits which should not be implemented outside of the crate. 19 | // No `///` documentation here to trigger `#![deny(missing_docs)]` 20 | // if this accidentally becomes visible. 21 | pub trait Sealed {} 22 | -------------------------------------------------------------------------------- /starlark/src/stdlib/funcs.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | pub(crate) mod globals; 19 | pub(crate) mod min_max; 20 | pub(crate) mod other; 21 | pub(crate) mod zip; 22 | -------------------------------------------------------------------------------- /starlark/src/syntax.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | //! Public API for parser. 19 | 20 | pub use starlark_syntax::dialect::Dialect; 21 | pub use starlark_syntax::dialect::DialectTypes; 22 | pub use starlark_syntax::syntax::AstLoad; 23 | pub use starlark_syntax::syntax::AstModule; 24 | pub use starlark_syntax::syntax::ast; 25 | -------------------------------------------------------------------------------- /starlark/src/tests/bc.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | //! Bytecode generation tests. 19 | 20 | mod and_or; 21 | mod call; 22 | mod compr; 23 | mod definitely_assigned; 24 | mod expr; 25 | mod for_stmt; 26 | pub(crate) mod golden; 27 | mod if_stmt; 28 | mod isinstance; 29 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/and_or_false_and_x.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x): return False and x 8 | 9 | # Bytecode: 10 | 11 | Max stack size: 0 12 | Instructions: 13 | # instrs.star.bzl:1:14-32 14 | 0: ReturnConst False 15 | 16: End 16 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/and_or_false_or_x.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x): return False or x 8 | 9 | # Bytecode: 10 | 11 | Max stack size: 0 12 | Instructions: 13 | # instrs.star.bzl:1:14-31 14 | 0: Return &x 15 | 8: End 16 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/and_or_true_and_x.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x): return True and x 8 | 9 | # Bytecode: 10 | 11 | Max stack size: 0 12 | Instructions: 13 | # instrs.star.bzl:1:14-31 14 | 0: Return &x 15 | 8: End 16 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/and_or_true_or_x.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x): return True or x 8 | 9 | # Bytecode: 10 | 11 | Max stack size: 0 12 | Instructions: 13 | # instrs.star.bzl:1:14-30 14 | 0: ReturnConst True 15 | 16: End 16 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/and_or_x_and_false.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x): return x and False 8 | 9 | # Bytecode: 10 | 11 | Max stack size: 1 12 | Instructions: 13 | # instrs.star.bzl:1:14-32 14 | 0: IfNotBr &x 48 15 | 16: Const False ->&1 16 | 40: Br 64 17 | >48: Mov &x ->&1 18 | >64: Return &1 19 | 72: End 20 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/and_or_x_and_true.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x): return x and True 8 | 9 | # Bytecode: 10 | 11 | Max stack size: 1 12 | Instructions: 13 | # instrs.star.bzl:1:14-31 14 | 0: IfNotBr &x 48 15 | 16: Const True ->&1 16 | 40: Br 64 17 | >48: Mov &x ->&1 18 | >64: Return &1 19 | 72: End 20 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/and_or_x_or_false.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x): return x or False 8 | 9 | # Bytecode: 10 | 11 | Max stack size: 1 12 | Instructions: 13 | # instrs.star.bzl:1:14-31 14 | 0: IfNotBr &x 40 15 | 16: Mov &x ->&1 16 | 32: Br 64 17 | >40: Const False ->&1 18 | >64: Return &1 19 | 72: End 20 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/and_or_x_or_true.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x): return x or True 8 | 9 | # Bytecode: 10 | 11 | Max stack size: 1 12 | Instructions: 13 | # instrs.star.bzl:1:14-30 14 | 0: IfNotBr &x 40 15 | 16: Mov &x ->&1 16 | 32: Br 64 17 | >40: Const True ->&1 18 | >64: Return &1 19 | 72: End 20 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/call.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(a, k): 8 | noop( 9 | 10, 10 | 20, 11 | p=30, 12 | q=40, 13 | r=50, 14 | *a, 15 | **k, 16 | ) 17 | 18 | # Bytecode: 19 | 20 | Max stack size: 6 21 | Instructions: 22 | # instrs.star.bzl:2:5-10:6 23 | 0: Const 10 ->&3 24 | 24: Const 20 ->&4 25 | 48: Const 30 ->&5 26 | 72: Const 40 ->&6 27 | 96: Const 50 ->&7 28 | 120: CallFrozenNative noop {&3..&8 2 p q r *&0 **&1} instrs.star.bzl:2:5-10:6 ->&2 29 | # instrs.star.bzl:2:5-10:6 30 | 200: ReturnConst None 31 | 216: End 32 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/compr_if_true_clause.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(y): return [x for x in y if True] 8 | 9 | # Bytecode: 10 | 11 | Max stack size: 3 12 | Instructions: 13 | # instrs.star.bzl:1:14-43 14 | 0: ListNew ->&3 15 | 8: Iter &y 0 ->&4 ->&x 72 16 | > 32: ComprListAppend &3 &x 17 | 48: Continue &4 0 ->&x 32 72 18 | >72: Mov &3 ->&2 19 | 88: Return &2 20 | 96: End 21 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/compr_if_true_clause_on_freeze.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(y): return [x for x in y if C] 8 | C = False 9 | C = True 10 | 11 | # Bytecode: 12 | 13 | Max stack size: 3 14 | Instructions: 15 | # instrs.star.bzl:1:14-40 16 | 0: ListNew ->&3 17 | 8: Iter &y 0 ->&4 ->&x 72 18 | > 32: ComprListAppend &3 &x 19 | 48: Continue &4 0 ->&x 32 72 20 | >72: Mov &3 ->&2 21 | 88: Return &2 22 | 96: End 23 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/compr_no_loop_if_top_collection_is_empty.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(): return [x for x in []] 8 | 9 | # Bytecode: 10 | 11 | Max stack size: 1 12 | Instructions: 13 | # instrs.star.bzl:1:13-35 14 | 0: ListNew ->&1 15 | 8: Return &1 16 | 16: End 17 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/compr_no_loop_if_top_collection_is_empty_on_freeze.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(): return [x for x in D] 8 | D = {} 9 | 10 | # Bytecode: 11 | 12 | Max stack size: 1 13 | Instructions: 14 | # instrs.star.bzl:1:13-34 15 | 0: ListNew ->&1 16 | 8: Return &1 17 | 16: End 18 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/constant_folding_list_add.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(): return [1] + [2] 8 | 9 | # Bytecode: 10 | 11 | Max stack size: 1 12 | Instructions: 13 | # instrs.star.bzl:1:13-29 14 | 0: ListOfConsts [1, 2] ->&0 15 | 32: Return &0 16 | 40: End 17 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/def_inline_const_args_inlined.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def foo(x, y): 8 | return noop(y, x) 9 | 10 | def test(): 11 | # This call should be inlined. 12 | return foo(10, True) 13 | 14 | # Bytecode: 15 | 16 | Max stack size: 3 17 | Instructions: 18 | # instrs.star.bzl:6:5-25 19 | 0: Const True ->&1 20 | 24: Const 10 ->&2 21 | 48: CallFrozenNativePos noop &1..&3 instrs.star.bzl:2:12-22 ->&0 22 | # instrs.star.bzl:6:5-25 23 | 96: Return &0 24 | 104: End 25 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/def_inline_const_inlined.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def trivial(): 8 | return 10 9 | 10 | def test(): 11 | return trivial() 12 | 13 | # Bytecode: 14 | 15 | Max stack size: 0 16 | Instructions: 17 | # instrs.star.bzl:5:5-21 18 | 0: ReturnConst 10 19 | 16: End 20 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/def_inline_dict_inlined.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def returns_dict(): 8 | # This should fail at runtime. 9 | return {[]: 10} 10 | 11 | def test(): 12 | return returns_dict() 13 | 14 | # Bytecode: 15 | 16 | Max stack size: 3 17 | Instructions: 18 | # instrs.star.bzl:6:5-26 19 | 0: ListNew ->&1 20 | 8: Const 10 ->&2 21 | 32: DictNPop [&1, &2] ->&0 22 | 48: Return &0 23 | 56: End 24 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/def_inline_list_inlined.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(): 8 | return returns_list() 9 | 10 | # Also test function is inlined if it is defined after the caller. 11 | def returns_list(): 12 | return [10, True] 13 | 14 | # Bytecode: 15 | 16 | Max stack size: 1 17 | Instructions: 18 | # instrs.star.bzl:2:5-26 19 | 0: ListOfConsts [10, True] ->&0 20 | 32: Return &0 21 | 40: End 22 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/def_inline_locals_inlined.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def foo(x, y): 8 | return noop(y, x) 9 | 10 | def test(x, y): 11 | # This call should be inlined. 12 | return foo(y, x) 13 | 14 | # Bytecode: 15 | 16 | Max stack size: 1 17 | Instructions: 18 | # instrs.star.bzl:6:5-21 19 | 0: CallFrozenNativePos noop &0..&2 instrs.star.bzl:2:12-22 ->&2 20 | # instrs.star.bzl:6:5-21 21 | 48: Return &2 22 | 56: End 23 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/def_inline_return_type_inlined.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def smth() -> str: 8 | return "10" 9 | 10 | def test(): 11 | # This call should not be inlined. 12 | return smth() 13 | 14 | # Bytecode: 15 | 16 | Max stack size: 1 17 | Instructions: 18 | # instrs.star.bzl:6:5-18 19 | 0: CallFrozenDefPos instrs.star.bzl.smth &0..&0 instrs.star.bzl:6:12-18 ->&0 20 | # instrs.star.bzl:6:5-18 21 | 40: Return &0 22 | 48: End 23 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/definitely_assigned_mov_is_used.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x, y): noop(y, x) 8 | 9 | # Bytecode: 10 | 11 | Max stack size: 3 12 | Instructions: 13 | # instrs.star.bzl:1:17-27 14 | 0: Mov &y ->&3 15 | 16: Mov &x ->&4 16 | 32: CallFrozenNativePos noop &3..&5 instrs.star.bzl:1:17-27 ->&2 17 | # instrs.star.bzl:1:17-27 18 | 80: ReturnConst None 19 | 96: End 20 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/definitely_assigned_no_op_movs.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x): x = x 8 | 9 | # Bytecode: 10 | 11 | Max stack size: 0 12 | Instructions: 13 | # instrs.star.bzl:1:14-19 14 | 0: ReturnConst None 15 | 16: End 16 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/definitely_assigned_slot_range_in_call.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x, y): noop(x, y) 8 | 9 | # Bytecode: 10 | 11 | Max stack size: 1 12 | Instructions: 13 | # instrs.star.bzl:1:17-27 14 | 0: CallFrozenNativePos noop &0..&2 instrs.star.bzl:1:17-27 ->&2 15 | # instrs.star.bzl:1:17-27 16 | 48: ReturnConst None 17 | 64: End 18 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/definitely_assigned_slot_range_in_list.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x, y): return [x, y] 8 | 9 | # Bytecode: 10 | 11 | Max stack size: 1 12 | Instructions: 13 | # instrs.star.bzl:1:17-30 14 | 0: ListNPop [&x, &y] ->&2 15 | 16: Return &2 16 | 24: End 17 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/eq_bool.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x): 8 | return x == True 9 | 10 | # Bytecode: 11 | 12 | Max stack size: 1 13 | Instructions: 14 | # instrs.star.bzl:2:5-21 15 | 0: EqPtr &x True ->&1 16 | 24: Return &1 17 | 32: End 18 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/eq_const.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | S = struct(a = 2) 8 | 9 | def test(x): 10 | return x == S 11 | 12 | # Bytecode: 13 | 14 | Max stack size: 1 15 | Instructions: 16 | # instrs.star.bzl:4:5-18 17 | 0: EqConst &x struct(a=2) ->&1 18 | 24: Return &1 19 | 32: End 20 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/eq_enum.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Color = enum("RED", "GREEN", "BLUE") 8 | 9 | def test(x): 10 | return x == Color("RED") 11 | 12 | # Bytecode: 13 | 14 | Max stack size: 1 15 | Instructions: 16 | # instrs.star.bzl:4:5-29 17 | 0: EqPtr &x Color("RED") ->&1 18 | 24: Return &1 19 | 32: End 20 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/eq_int.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x): 8 | return x == 10 9 | 10 | # Bytecode: 11 | 12 | Max stack size: 1 13 | Instructions: 14 | # instrs.star.bzl:2:5-19 15 | 0: EqInt &x 10 ->&1 16 | 24: Return &1 17 | 32: End 18 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/eq_short_str.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x): 8 | return x == "a" 9 | 10 | # Bytecode: 11 | 12 | Max stack size: 1 13 | Instructions: 14 | # instrs.star.bzl:2:5-20 15 | 0: EqPtr &x "a" ->&1 16 | 24: Return &1 17 | 32: End 18 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/eq_str.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x): 8 | return x == "hello" 9 | 10 | # Bytecode: 11 | 12 | Max stack size: 1 13 | Instructions: 14 | # instrs.star.bzl:2:5-24 15 | 0: EqStr &x "hello" ->&1 16 | 24: Return &1 17 | 32: End 18 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/expr_call_maybe_known_method.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x): x.append(1) 8 | 9 | # Bytecode: 10 | 11 | Max stack size: 2 12 | Instructions: 13 | # instrs.star.bzl:1:14-25 14 | 0: Const 1 ->&2 15 | 24: CallMaybeKnownMethodPos &x append &2..&3 instrs.star.bzl:1:14-25 ->&1 16 | # instrs.star.bzl:1:14-25 17 | 112: ReturnConst None 18 | 128: End 19 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/expr_format_one.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x): return '(({}))'.format(x) 8 | 9 | # Bytecode: 10 | 11 | Max stack size: 1 12 | Instructions: 13 | # instrs.star.bzl:1:14-39 14 | 0: FormatOne "((" &x "))" ->&1 15 | 32: Return &1 16 | 40: End 17 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/expr_fstring.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x): return f'test: {x}' 8 | 9 | # Bytecode: 10 | 11 | Max stack size: 1 12 | Instructions: 13 | # instrs.star.bzl:1:14-33 14 | 0: FormatOne "test: " &x "" ->&1 15 | 32: Return &1 16 | 40: End 17 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/expr_percent_s_one.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x): return '((%s))' % x 8 | 9 | # Bytecode: 10 | 11 | Max stack size: 1 12 | Instructions: 13 | # instrs.star.bzl:1:14-33 14 | 0: PercentSOne "((" &x "))" ->&1 15 | 32: Return &1 16 | 40: End 17 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/expr_spec_exec_list.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(): return list((10, 20)) 8 | 9 | # Bytecode: 10 | 11 | Max stack size: 1 12 | Instructions: 13 | # instrs.star.bzl:1:13-34 14 | 0: ListOfConsts [10, 20] ->&0 15 | 32: Return &0 16 | 40: End 17 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/expr_type.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x): return type(x) 8 | 9 | # Bytecode: 10 | 11 | Max stack size: 1 12 | Instructions: 13 | # instrs.star.bzl:1:14-28 14 | 0: Type &x ->&1 15 | 16: Return &1 16 | 24: End 17 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/for.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x): 8 | for i in x: 9 | noop(i) 10 | 11 | # Bytecode: 12 | 13 | Max stack size: 2 14 | Instructions: 15 | # instrs.star.bzl:2:3-3:12 16 | 0: Iter &x 0 ->&2 ->&i 96 17 | # instrs.star.bzl:3:5-12 18 | > 24: CallFrozenNativePos noop &1..&2 instrs.star.bzl:3:5-12 ->&3 19 | # instrs.star.bzl:3:5-12 20 | 72: Continue &2 0 ->&i 24 96 21 | > 96: ReturnConst None 22 | 112: End 23 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/for_break.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x): 8 | for i in x: 9 | if i: break 10 | noop(i) 11 | 12 | # Bytecode: 13 | 14 | Max stack size: 2 15 | Instructions: 16 | # instrs.star.bzl:2:3-4:12 17 | 0: Iter &x 0 ->&2 ->&i 128 18 | # instrs.star.bzl:3:5-4:1 19 | > 24: IfNotBr &i 56 20 | # instrs.star.bzl:3:11-16 21 | 40: Break &2 128 22 | # instrs.star.bzl:4:5-12 23 | > 56: CallFrozenNativePos noop &1..&2 instrs.star.bzl:4:5-12 ->&3 24 | # instrs.star.bzl:4:5-12 25 | 104: Continue &2 0 ->&i 24 128 26 | >128: ReturnConst None 27 | 144: End 28 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/for_continue.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x): 8 | for i in x: 9 | if i: continue 10 | noop(i) 11 | 12 | # Bytecode: 13 | 14 | Max stack size: 2 15 | Instructions: 16 | # instrs.star.bzl:2:3-4:12 17 | 0: Iter &x 0 ->&2 ->&i 136 18 | # instrs.star.bzl:3:5-4:1 19 | > 24: IfNotBr &i 64 20 | # instrs.star.bzl:3:11-19 21 | 40: Continue &2 0 ->&i 24 136 22 | # instrs.star.bzl:4:5-12 23 | > 64: CallFrozenNativePos noop &1..&2 instrs.star.bzl:4:5-12 ->&3 24 | # instrs.star.bzl:4:5-12 25 | 112: Continue &2 0 ->&i 24 136 26 | >136: ReturnConst None 27 | 152: End 28 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/if_stmt_and_stmt.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x): 8 | x and noop() 9 | 10 | # Bytecode: 11 | 12 | Max stack size: 1 13 | Instructions: 14 | # instrs.star.bzl:2:3-15 15 | 0: IfNotBr &x 64 16 | # instrs.star.bzl:2:9-15 17 | 16: CallFrozenNativePos noop &0..&0 instrs.star.bzl:2:9-15 ->&1 18 | # instrs.star.bzl:2:9-15 19 | >64: ReturnConst None 20 | 80: End 21 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/if_stmt_if_else_x_and_y.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x, y): 8 | if x and y: 9 | return 10 10 | else: 11 | return 20 12 | 13 | # Bytecode: 14 | 15 | Max stack size: 0 16 | Instructions: 17 | # instrs.star.bzl:2:3-5:14 18 | 0: IfNotBr &x 56 19 | 16: IfNotBr &y 56 20 | # instrs.star.bzl:3:5-14 21 | 32: ReturnConst 10 22 | 48: Br 72 23 | # instrs.star.bzl:5:5-14 24 | >56: ReturnConst 20 25 | >72: ReturnConst None 26 | 88: End 27 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/if_stmt_if_else_x_or_y.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x, y): 8 | if x or y: 9 | return 10 10 | else: 11 | return 20 12 | 13 | # Bytecode: 14 | 15 | Max stack size: 0 16 | Instructions: 17 | # instrs.star.bzl:2:3-5:14 18 | 0: IfBr &x 32 19 | 16: IfNotBr &y 56 20 | # instrs.star.bzl:3:5-14 21 | >32: ReturnConst 10 22 | 48: Br 72 23 | # instrs.star.bzl:5:5-14 24 | >56: ReturnConst 20 25 | >72: ReturnConst None 26 | 88: End 27 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/if_stmt_if_false_and_x.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x): 8 | if False and x: noop() 9 | 10 | # Bytecode: 11 | 12 | Max stack size: 0 13 | Instructions: 14 | 0: ReturnConst None 15 | 16: End 16 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/if_stmt_if_false_or_x.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x): 8 | if False or x: noop() 9 | 10 | # Bytecode: 11 | 12 | Max stack size: 1 13 | Instructions: 14 | # instrs.star.bzl:2:3-24 15 | 0: IfNotBr &x 64 16 | # instrs.star.bzl:2:18-24 17 | 16: CallFrozenNativePos noop &0..&0 instrs.star.bzl:2:18-24 ->&1 18 | # instrs.star.bzl:2:18-24 19 | >64: ReturnConst None 20 | 80: End 21 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/if_stmt_if_true_and_x.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x): 8 | if True and x: noop() 9 | 10 | # Bytecode: 11 | 12 | Max stack size: 1 13 | Instructions: 14 | # instrs.star.bzl:2:3-24 15 | 0: IfNotBr &x 64 16 | # instrs.star.bzl:2:18-24 17 | 16: CallFrozenNativePos noop &0..&0 instrs.star.bzl:2:18-24 ->&1 18 | # instrs.star.bzl:2:18-24 19 | >64: ReturnConst None 20 | 80: End 21 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/if_stmt_if_true_or_x.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x): 8 | if True or x: noop() 9 | 10 | # Bytecode: 11 | 12 | Max stack size: 1 13 | Instructions: 14 | # instrs.star.bzl:2:17-23 15 | 0: CallFrozenNativePos noop &0..&0 instrs.star.bzl:2:17-23 ->&1 16 | # instrs.star.bzl:2:17-23 17 | 48: ReturnConst None 18 | 64: End 19 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/if_stmt_if_x_and_false.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x): 8 | if x and False: noop() 9 | 10 | # Bytecode: 11 | 12 | Max stack size: 0 13 | Instructions: 14 | # instrs.star.bzl:2:6-7 15 | 0: ReturnConst None 16 | 16: End 17 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/if_stmt_if_x_and_true.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x): 8 | if x and True: noop() 9 | 10 | # Bytecode: 11 | 12 | Max stack size: 1 13 | Instructions: 14 | # instrs.star.bzl:2:3-24 15 | 0: IfNotBr &x 64 16 | # instrs.star.bzl:2:18-24 17 | 16: CallFrozenNativePos noop &0..&0 instrs.star.bzl:2:18-24 ->&1 18 | # instrs.star.bzl:2:18-24 19 | >64: ReturnConst None 20 | 80: End 21 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/if_stmt_if_x_or_false.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x): 8 | if x or False: noop() 9 | 10 | # Bytecode: 11 | 12 | Max stack size: 1 13 | Instructions: 14 | # instrs.star.bzl:2:3-24 15 | 0: IfNotBr &x 64 16 | # instrs.star.bzl:2:18-24 17 | 16: CallFrozenNativePos noop &0..&0 instrs.star.bzl:2:18-24 ->&1 18 | # instrs.star.bzl:2:18-24 19 | >64: ReturnConst None 20 | 80: End 21 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/if_stmt_if_x_or_true.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x): 8 | if x or True: noop() 9 | 10 | # Bytecode: 11 | 12 | Max stack size: 1 13 | Instructions: 14 | # instrs.star.bzl:2:17-23 15 | 0: CallFrozenNativePos noop &0..&0 instrs.star.bzl:2:17-23 ->&1 16 | # instrs.star.bzl:2:17-23 17 | 48: ReturnConst None 18 | 64: End 19 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/if_stmt_or_stmt.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x): 8 | x or noop() 9 | 10 | # Bytecode: 11 | 12 | Max stack size: 1 13 | Instructions: 14 | # instrs.star.bzl:2:3-14 15 | 0: IfBr &x 64 16 | # instrs.star.bzl:2:8-14 17 | 16: CallFrozenNativePos noop &0..&0 instrs.star.bzl:2:8-14 ->&1 18 | # instrs.star.bzl:2:8-14 19 | >64: ReturnConst None 20 | 80: End 21 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/isinstance.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(x): return isinstance(x, str) 8 | 9 | # Bytecode: 10 | 11 | Max stack size: 1 12 | Instructions: 13 | # instrs.star.bzl:1:14-39 14 | 0: IsInstance &x str ->&1 15 | 24: Return &1 16 | 32: End 17 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/opt_empty_iterable_optimized_away.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | L = [] 8 | def test(): 9 | for x in L: 10 | print(x) 11 | 12 | # Bytecode: 13 | 14 | Max stack size: 0 15 | Instructions: 16 | 0: ReturnConst None 17 | 16: End 18 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/opt_list_of_const_add.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(): 8 | return [1, 2] + [3, 4, 5] 9 | 10 | # Bytecode: 11 | 12 | Max stack size: 1 13 | Instructions: 14 | # instrs.star.bzl:2:5-30 15 | 0: ListOfConsts [1, 2, 3, 4, 5] ->&0 16 | 32: Return &0 17 | 40: End 18 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/opt_list_of_expr_add.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(): 8 | return [noop(), noop()] + [noop(), noop(), noop()] 9 | 10 | # Bytecode: 11 | 12 | Max stack size: 6 13 | Instructions: 14 | # instrs.star.bzl:2:5-55 15 | 0: CallFrozenNativePos noop &0..&0 instrs.star.bzl:2:13-19 ->&1 16 | # instrs.star.bzl:2:5-55 17 | 48: CallFrozenNativePos noop &0..&0 instrs.star.bzl:2:21-27 ->&2 18 | # instrs.star.bzl:2:5-55 19 | 96: CallFrozenNativePos noop &0..&0 instrs.star.bzl:2:32-38 ->&3 20 | # instrs.star.bzl:2:5-55 21 | 144: CallFrozenNativePos noop &0..&0 instrs.star.bzl:2:40-46 ->&4 22 | # instrs.star.bzl:2:5-55 23 | 192: CallFrozenNativePos noop &0..&0 instrs.star.bzl:2:48-54 ->&5 24 | # instrs.star.bzl:2:5-55 25 | 240: ListNPop [&1, &2, &3, &4, &5] ->&0 26 | 256: Return &0 27 | 264: End 28 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/opt_list_plus_list.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | L = [1, 2] 8 | 9 | def test(): 10 | return L + [1] 11 | 12 | # Bytecode: 13 | 14 | Max stack size: 1 15 | Instructions: 16 | # instrs.star.bzl:4:5-19 17 | 0: ListOfConsts [1, 2, 1] ->&0 18 | 32: Return &0 19 | 40: End 20 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/opt_mutual_recursion.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(): 8 | return g() 9 | 10 | def g(): 11 | return test() 12 | 13 | # Bytecode: 14 | 15 | Max stack size: 1 16 | Instructions: 17 | # instrs.star.bzl:2:5-15 18 | 0: CallFrozenDefPos instrs.star.bzl.g &0..&0 instrs.star.bzl:2:12-15 ->&0 19 | # instrs.star.bzl:2:5-15 20 | 40: Return &0 21 | 48: End 22 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/opt_private_forward_mutable_module_vars_inlined.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(): 8 | # Reference to module variable should be replaced with constant 9 | return _private_forward_mutable 10 | 11 | _private_forward_mutable = {1: 2} 12 | 13 | # Bytecode: 14 | 15 | Max stack size: 0 16 | Instructions: 17 | # instrs.star.bzl:3:5-36 18 | 0: ReturnConst {1: 2} 19 | 16: End 20 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/opt_recursion.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(): return test() 8 | 9 | # Bytecode: 10 | 11 | Max stack size: 1 12 | Instructions: 13 | # instrs.star.bzl:1:13-26 14 | 0: CallFrozenDefPos instrs.star.bzl.test &0..&0 instrs.star.bzl:1:20-26 ->&0 15 | # instrs.star.bzl:1:13-26 16 | 40: Return &0 17 | 48: End 18 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/opt_return_type_erased.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test() -> typing.Any: return 1 8 | 9 | # Bytecode: 10 | 11 | Max stack size: 0 12 | Instructions: 13 | # instrs.star.bzl:1:27-35 14 | 0: ReturnConst 1 15 | 16: End 16 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/opt_return_type_present.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test() -> str: return 'x' 8 | 9 | # Bytecode: 10 | 11 | Max stack size: 1 12 | Instructions: 13 | # instrs.star.bzl:1:20-30 14 | 0: Const "x" ->&0 15 | 24: ReturnCheckType &0 16 | 32: End 17 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/opt_same_module_struct_getattr_inlined.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(): 8 | return _s.f 9 | 10 | _s = struct(f = 1) 11 | 12 | # Bytecode: 13 | 14 | Max stack size: 0 15 | Instructions: 16 | # instrs.star.bzl:2:5-16 17 | 0: ReturnConst 1 18 | 16: End 19 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/opt_type_is_inlined.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def is_list(x): 8 | return type(x) == type([]) 9 | 10 | def test(x): 11 | return is_list(x) 12 | 13 | # Bytecode: 14 | 15 | Max stack size: 1 16 | Instructions: 17 | # instrs.star.bzl:5:5-22 18 | 0: TypeIs &x "list" ->&1 19 | 24: Return &1 20 | 32: End 21 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/opt_unreachable_code_optimized_away.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(): 8 | if True: 9 | return 10 | fail("unreachable") 11 | 12 | # Bytecode: 13 | 14 | Max stack size: 0 15 | Instructions: 16 | # instrs.star.bzl:3:9-15 17 | 0: ReturnConst None 18 | 16: End 19 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/speculative_exec_enum_inline.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | MyEnum = enum("red", "green", "blue") 8 | 9 | def test(x): 10 | # Test there is no enum evaluation. 11 | return x == MyEnum("red") 12 | 13 | # Bytecode: 14 | 15 | Max stack size: 1 16 | Instructions: 17 | # instrs.star.bzl:5:5-30 18 | 0: EqPtr &x MyEnum("red") ->&1 19 | 24: Return &1 20 | 32: End 21 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/speculative_exec_format_speculatively_before_format_instr.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(): 8 | # Test this expression is compiled to constant, not to `FormatOne` instruction. 9 | return "x{}y".format(1) 10 | 11 | # Bytecode: 12 | 13 | Max stack size: 0 14 | Instructions: 15 | # instrs.star.bzl:3:5-28 16 | 0: ReturnConst "x1y" 17 | 16: End 18 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/golden/speculative_exec_methods_invoked_speculatively.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | def test(): 8 | return "foo".startswith("f") 9 | 10 | # Bytecode: 11 | 12 | Max stack size: 0 13 | Instructions: 14 | # instrs.star.bzl:2:5-33 15 | 0: ReturnConst True 16 | 16: End 17 | -------------------------------------------------------------------------------- /starlark/src/tests/bc/isinstance.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | use crate::tests::bc::golden::bc_golden_test; 19 | 20 | #[test] 21 | fn test_isinstance() { 22 | bc_golden_test("isinstance", "def test(x): return isinstance(x, str)"); 23 | } 24 | -------------------------------------------------------------------------------- /starlark/src/tests/derive.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | mod alloc_value; 19 | mod attrs; 20 | mod docs; 21 | mod freeze; 22 | mod module; 23 | mod trace; 24 | mod unpack_value; 25 | mod unpack_value_attr; 26 | -------------------------------------------------------------------------------- /starlark/src/tests/derive/freeze.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | mod basic; 19 | mod bounds; 20 | mod enums; 21 | mod identity; 22 | mod validator; 23 | mod validator_order; 24 | -------------------------------------------------------------------------------- /starlark/src/tests/derive/freeze/basic.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | use crate as starlark; 19 | use crate::values::Freeze; 20 | use crate::values::FreezeResult; 21 | 22 | #[derive(Freeze)] 23 | #[allow(dead_code)] 24 | struct TestUnitStruct; 25 | -------------------------------------------------------------------------------- /starlark/src/tests/derive/module.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | mod basic; 19 | mod default_value; 20 | mod generic; 21 | mod kwargs; 22 | mod methods; 23 | mod named_positional; 24 | mod other_attributes; 25 | mod return_impl; 26 | mod special_params; 27 | mod type_annotation; 28 | mod unpack_value; 29 | -------------------------------------------------------------------------------- /starlark/src/tests/derive/trace.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | mod bounds; 19 | mod enums; 20 | mod statics; 21 | -------------------------------------------------------------------------------- /starlark/src/tests/derive/trace/enums.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | use starlark_derive::Trace; 19 | 20 | use crate as starlark; 21 | use crate::values::Value; 22 | 23 | #[allow(dead_code)] // Just check it compiles. 24 | #[derive(Trace)] 25 | enum TestEnumForTrace<'v> { 26 | Foo(String), 27 | Bar(i32, Value<'v>), 28 | } 29 | -------------------------------------------------------------------------------- /starlark/src/tests/fstring/golden/escape.err.golden.md: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | error: Not a valid identifier: `bar baz` 8 | --> assert.bzl:1:10 9 | | 10 | 1 | f'foo \n {bar baz}' 11 | | ^^^^^^^ 12 | | 13 | -------------------------------------------------------------------------------- /starlark/src/tests/fstring/golden/invalid_format.err.golden.md: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | error: Invalid format: Unmatched '{' in format string `foo {bar` 8 | --> assert.bzl:1:1 9 | | 10 | 1 | f'foo {bar' 11 | | ^^^^^^^^^^^ 12 | | 13 | -------------------------------------------------------------------------------- /starlark/src/tests/fstring/golden/invalid_identifier.err.golden.md: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | error: Not a valid identifier: `bar baz` 8 | --> assert.bzl:1:8 9 | | 10 | 1 | f'foo {bar baz}' 11 | | ^^^^^^^ 12 | | 13 | -------------------------------------------------------------------------------- /starlark/src/tests/fstring/golden/invalid_identifier_expression.err.golden.md: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | error: Not a valid identifier: `bar[123]` 8 | --> assert.bzl:1:8 9 | | 10 | 1 | f'foo {bar[123]}' 11 | | ^^^^^^^^ 12 | | 13 | -------------------------------------------------------------------------------- /starlark/src/tests/fstring/golden/invalid_identifier_multiline.err.golden.md: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | error: Not a valid identifier: `bar baz` 8 | --> assert.bzl:2:3 9 | | 10 | 2 | {bar baz}''' 11 | | ^^^^^^^ 12 | | 13 | -------------------------------------------------------------------------------- /starlark/src/tests/fstring/golden/invalid_identifier_raw.err.golden.md: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | error: Not a valid identifier: `bar baz` 8 | --> assert.bzl:1:9 9 | | 10 | 1 | fr'foo {bar baz}' 11 | | ^^^^^^^ 12 | | 13 | -------------------------------------------------------------------------------- /starlark/src/tests/fstring/golden/invalid_identifier_triple_quotes.err.golden.md: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | error: Not a valid identifier: `bar baz` 8 | --> assert.bzl:1:10 9 | | 10 | 1 | f'''foo {bar baz}''' 11 | | ^^^^^^^ 12 | | 13 | -------------------------------------------------------------------------------- /starlark/src/tests/fstring/golden/not_enabled.err.golden.md: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | error: Your Starlark dialect must enable f-strings to use them 8 | --> assert.bzl:1:1 9 | | 10 | 1 | f'{foo}' 11 | | ^^^^^^^^ 12 | | 13 | -------------------------------------------------------------------------------- /starlark/src/tests/fstring/golden/undeclared_variable.err.golden.md: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | error: Variable `bar` not found, did you mean `chr`? 8 | --> assert.bzl:1:8 9 | | 10 | 1 | f'foo {bar}' 11 | | ^^^ 12 | | 13 | -------------------------------------------------------------------------------- /starlark/src/tests/uncategorized_diagnostics_display_debug.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Traceback (most recent call last): 8 | * assert.bzl:3, in 9 | should_fail() 10 | * imported.bzl:9, in should_fail 11 | rust_failure() 12 | error: rust failure 13 | --> imported.bzl:9:5 14 | | 15 | 9 | rust_failure() 16 | | ^^^^^^^^^^^^^^ 17 | | 18 | 19 | 20 | rust failure 21 | 22 | Caused by: 23 | 0: fail 3 24 | 1: fail 2 25 | 2: fail 1 26 | -------------------------------------------------------------------------------- /starlark/src/tests/uncategorized_diagnostics_display_default.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Traceback (most recent call last): 8 | * assert.bzl:3, in 9 | should_fail() 10 | * imported.bzl:9, in should_fail 11 | rust_failure() 12 | error: rust failure 13 | --> imported.bzl:9:5 14 | | 15 | 9 | rust_failure() 16 | | ^^^^^^^^^^^^^^ 17 | | 18 | -------------------------------------------------------------------------------- /starlark/src/tests/uncategorized_diagnostics_display_hash.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Traceback (most recent call last): 8 | * assert.bzl:3, in 9 | should_fail() 10 | * imported.bzl:9, in should_fail 11 | rust_failure() 12 | error: rust failure 13 | --> imported.bzl:9:5 14 | | 15 | 9 | rust_failure() 16 | | ^^^^^^^^^^^^^^ 17 | | 18 | 19 | 20 | rust failure 21 | 22 | Caused by: 23 | 0: fail 3 24 | 1: fail 2 25 | 2: fail 1 26 | -------------------------------------------------------------------------------- /starlark/src/tests/uncategorized_error_display.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Traceback (most recent call last): 8 | * assert.bzl:5, in 9 | add3(8) 10 | * assert.bzl:4, in add3 11 | add2(z) 12 | * imported.bzl:9, in add2 13 | add(z) 14 | * imported.bzl:11, in add 15 | x.append(z) 16 | error: Immutable 17 | --> imported.bzl:11:3 18 | | 19 | 11 | x.append(z) 20 | | ^^^^^^^^^^^ 21 | | 22 | -------------------------------------------------------------------------------- /starlark/src/tests/uncategorized_error_display_hash.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Traceback (most recent call last): 8 | * assert.bzl:5, in 9 | add3(8) 10 | * assert.bzl:4, in add3 11 | add2(z) 12 | * imported.bzl:9, in add2 13 | add(z) 14 | * imported.bzl:11, in add 15 | x.append(z) 16 | error: Immutable 17 | --> imported.bzl:11:3 18 | | 19 | 11 | x.append(z) 20 | | ^^^^^^^^^^^ 21 | | 22 | -------------------------------------------------------------------------------- /starlark/src/typing/mode.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | use dupe::Dupe; 19 | 20 | #[derive(Copy, Clone, Dupe, Debug, Eq, PartialEq)] 21 | pub(crate) enum TypecheckMode { 22 | /// Lint mode. 23 | Lint, 24 | /// Invoked from the compiler. 25 | Compiler, 26 | } 27 | -------------------------------------------------------------------------------- /starlark/src/typing/oracle.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | pub(crate) mod ctx; 19 | pub(crate) mod traits; 20 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/accepts_iterable.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def test(): 9 | accepts_iterable([1, ()]) 10 | 11 | No errors. 12 | 13 | Compiler typechecker (eval): 14 | No errors. 15 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/bit_or_return_int.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | test = int | 3 9 | 10 | def foo() -> test: 11 | pass 12 | 13 | No errors. 14 | 15 | Approximations: 16 | Approximation: Unknown type = "Span { begin: Pos(30), end: Pos(34) }" 17 | 18 | Compiler typechecker (eval): 19 | Compiler typechecker and eval results mismatch. 20 | 21 | error: Type `3` is not a valid type annotation 22 | --> filename:2:8 23 | | 24 | 2 | test = int | 3 25 | | ^^^^^^^ 26 | | 27 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/bit_or_return_list.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | test = int | list[3] 9 | 10 | def foo() -> test: 11 | pass 12 | 13 | No errors. 14 | 15 | Approximations: 16 | Approximation: Unknown type = "Span { begin: Pos(36), end: Pos(40) }" 17 | 18 | Compiler typechecker (eval): 19 | Compiler typechecker and eval results mismatch. 20 | 21 | error: Type `3` is not a valid type annotation 22 | --> filename:2:14 23 | | 24 | 2 | test = int | list[3] 25 | | ^^^^^^^ 26 | | 27 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/call_callable.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def foo(x: typing.Callable): 9 | x() 10 | 11 | No errors. 12 | 13 | Compiler typechecker (eval): 14 | No errors. 15 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/call_callable_or_not_callable.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def foo(x: [typing.Callable, str], y: [str, typing.Callable]): 9 | x() 10 | y() 11 | 12 | No errors. 13 | 14 | Compiler typechecker (eval): 15 | No errors. 16 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/call_not_callable.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def foo(x: list): 9 | x() 10 | 11 | Error: 12 | error: Call to a non-callable type `list` 13 | --> filename:3:5 14 | | 15 | 3 | x() 16 | | ^^^ 17 | | 18 | 19 | Compiler typechecker (eval): 20 | error: Call to a non-callable type `list` 21 | --> filename:3:5 22 | | 23 | 3 | x() 24 | | ^^^ 25 | | 26 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/call_pos_only.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def f(x, /): 9 | pass 10 | 11 | def test(): 12 | f("good") 13 | f(x="bad") 14 | 15 | Error: 16 | error: Unexpected parameter named `x` 17 | --> filename:7:7 18 | | 19 | 7 | f(x="bad") 20 | | ^^^^^^^ 21 | | 22 | 23 | Compiler typechecker (eval): 24 | error: Unexpected parameter named `x` 25 | --> filename:7:7 26 | | 27 | 7 | f(x="bad") 28 | | ^^^^^^^ 29 | | 30 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/callable_with_args.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def accept_f(x: typing.Callable[[int, str], str]): 9 | pass 10 | 11 | def good_function(x: int, y: str) -> str: 12 | return "" 13 | 14 | def bad_function(x: int, y: bool) -> str: 15 | return "" 16 | 17 | def test(): 18 | accept_f(good_function) 19 | accept_f(bad_function) 20 | 21 | Error: 22 | error: Expected type `typing.Callable[[int, str], str]` but got `def(x: int, y: bool) -> str` 23 | --> filename:13:14 24 | | 25 | 13 | accept_f(bad_function) 26 | | ^^^^^^^^^^^^ 27 | | 28 | 29 | Compiler typechecker (eval): 30 | error: Expected type `typing.Callable[[int, str], str]` but got `def(x: int, y: bool) -> str` 31 | --> filename:13:14 32 | | 33 | 13 | accept_f(bad_function) 34 | | ^^^^^^^^^^^^ 35 | | 36 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/calls.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def f(y): pass 9 | 10 | def g(): 11 | # Extra parameter. 12 | f(1, 2) 13 | 14 | # Not enough parameters. 15 | f() 16 | 17 | Error: 18 | error: Too many positional arguments 19 | --> filename:6:10 20 | | 21 | 6 | f(1, 2) 22 | | ^ 23 | | 24 | 25 | Error: 26 | error: Missing required parameter `y` 27 | --> filename:9:5 28 | | 29 | 9 | f() 30 | | ^^^ 31 | | 32 | 33 | Compiler typechecker (eval): 34 | error: Too many positional arguments 35 | --> filename:6:10 36 | | 37 | 6 | f(1, 2) 38 | | ^ 39 | | 40 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/dict_bug.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def test(): 9 | x = {} 10 | x.setdefault(33, "x") 11 | y = x[44] 12 | 13 | No errors. 14 | 15 | Types: 16 | y: typing.Never 17 | 18 | Compiler typechecker (eval): 19 | No errors. 20 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/dict_never_key.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | # We use `typing.Never` when expression is an error, 9 | # or it is a type parameter of empty list for example. 10 | # Dict lookup by never should not be an error. 11 | def test(d: dict[typing.Any, str], x: typing.Never): 12 | y = d[x] 13 | 14 | No errors. 15 | 16 | Compiler typechecker (eval): 17 | No errors. 18 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/dot_type_0.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def foo(x: list) -> bool: 9 | return type(x) == type(list) 10 | 11 | def bar(): 12 | foo([1,2,3]) 13 | 14 | No errors. 15 | 16 | Compiler typechecker (eval): 17 | No errors. 18 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/dot_type_1.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def foo(x: list) -> bool: 9 | return type(x) == [] 10 | 11 | def bar(): 12 | foo(True) 13 | 14 | Error: 15 | error: Expected type `str` but got `list[typing.Never]` 16 | --> filename:3:23 17 | | 18 | 3 | return type(x) == [] 19 | | ^^ 20 | | 21 | 22 | Error: 23 | error: Expected type `list` but got `bool` 24 | --> filename:6:9 25 | | 26 | 6 | foo(True) 27 | | ^^^^ 28 | | 29 | 30 | Compiler typechecker (eval): 31 | error: Expected type `str` but got `list[typing.Never]` 32 | --> filename:3:23 33 | | 34 | 3 | return type(x) == [] 35 | | ^^ 36 | | 37 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/failure.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def test(): 9 | hash(1) 10 | 11 | Error: 12 | error: Expected type `str` but got `int` 13 | --> filename:3:10 14 | | 15 | 3 | hash(1) 16 | | ^ 17 | | 18 | 19 | Compiler typechecker (eval): 20 | error: Expected type `str` but got `int` 21 | --> filename:3:10 22 | | 23 | 3 | hash(1) 24 | | ^ 25 | | 26 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/false_negative.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def test(): 9 | fail("Expected variable expansion in string: `{}`".format("x")) 10 | 11 | No errors. 12 | 13 | Compiler typechecker (eval): 14 | No errors. 15 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/function_as_type_bit_or.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def test(): 9 | # This test should work even if `t` is global. There's a bug in test framework somewhere. 10 | t = int | str 11 | 12 | No errors. 13 | 14 | Types: 15 | t: type 16 | 17 | Compiler typechecker (eval): 18 | No errors. 19 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/incorrect_type_dot.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def foo(x: list.foo.bar): 9 | pass 10 | 11 | Error: 12 | error: Operation `.foo` not supported on type `function` 13 | --> filename:2:12 14 | | 15 | 2 | def foo(x: list.foo.bar): 16 | | ^^^^^^^^ 17 | | 18 | 19 | Approximations: 20 | Approximation: Unknown type = "Span { begin: Pos(12), end: Pos(24) }" 21 | 22 | Compiler typechecker (eval): 23 | error: Operation `.foo` not supported on type `function` 24 | --> filename:2:17 25 | | 26 | 2 | def foo(x: list.foo.bar): 27 | | ^^^ 28 | | 29 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/int_bitor_float.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def test(): 9 | x = 0x60000000000000000000000 | 1.0 10 | 11 | Error: 12 | error: Binary operator `|` is not available on the types `int` and `float` 13 | --> filename:3:9 14 | | 15 | 3 | x = 0x60000000000000000000000 | 1.0 16 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | | 18 | 19 | Types: 20 | x: typing.Never 21 | 22 | Compiler typechecker (eval): 23 | error: Binary operator `|` is not available on the types `int` and `float` 24 | --> filename:3:9 25 | | 26 | 3 | x = 0x60000000000000000000000 | 1.0 27 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | | 29 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/int_mul_list.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def test(): 9 | x = 1 * ["a"] 10 | 11 | No errors. 12 | 13 | Types: 14 | x: list[str] 15 | 16 | Compiler typechecker (eval): 17 | No errors. 18 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/int_plus_float.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def test(): 9 | x = 1 + 1.0 10 | 11 | No errors. 12 | 13 | Types: 14 | x: float 15 | 16 | Compiler typechecker (eval): 17 | No errors. 18 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/kwargs_in_native_code.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def test(): 9 | # Good. 10 | accepts_typed_kwargs(x=1) 11 | # Bad. 12 | accepts_typed_kwargs(x=None) 13 | 14 | Error: 15 | error: Expected type `int` but got `None` 16 | --> filename:6:26 17 | | 18 | 6 | accepts_typed_kwargs(x=None) 19 | | ^^^^^^ 20 | | 21 | 22 | Compiler typechecker (eval): 23 | error: Expected type `int` but got `None` 24 | --> filename:6:26 25 | | 26 | 6 | accepts_typed_kwargs(x=None) 27 | | ^^^^^^ 28 | | 29 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/list_append.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def test(): 9 | # Type of `x` should be inferred as list of either `int` or `str`. 10 | x = [] 11 | x.append(1) 12 | x.append("") 13 | 14 | No errors. 15 | 16 | Types: 17 | x: list[int | str] 18 | 19 | Compiler typechecker (eval): 20 | No errors. 21 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/list_append_bug.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def test(): 9 | x = [] 10 | x.append(x) 11 | 12 | No errors. 13 | 14 | Approximations: 15 | Approximation: Fixed point didn't converge = "100" 16 | 17 | Types: 18 | x: list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[list[typing.Never]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]] 19 | 20 | Compiler typechecker (eval): 21 | No errors. 22 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/list_bin_op.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def test(a: list[str]): 9 | x = a + a 10 | y = a * 3 11 | z = 3 * a 12 | 13 | No errors. 14 | 15 | Types: 16 | x: list[str] 17 | y: list[str] 18 | z: list[str] 19 | 20 | Compiler typechecker (eval): 21 | No errors. 22 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/list_function.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def test(): 9 | x = list([1, 2]) 10 | 11 | No errors. 12 | 13 | Types: 14 | x: list[int] 15 | 16 | Compiler typechecker (eval): 17 | No errors. 18 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/list_less.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def test(x: list[str], y: list[str]) -> bool: 9 | return x < y 10 | 11 | No errors. 12 | 13 | Compiler typechecker (eval): 14 | No errors. 15 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/load_0.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def foo(x: list[bool]) -> str: 9 | return "test" 10 | 11 | No errors. 12 | 13 | Compiler typechecker (eval): 14 | No errors. 15 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/load_1.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | load("foo.bzl", "foo") 9 | def test(): 10 | res = [foo([])] 11 | 12 | No errors. 13 | 14 | Types: 15 | res: list[str] 16 | 17 | Compiler typechecker (eval): 18 | No errors. 19 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/methods_work_for_ty_starlark_value.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def test(s: str): 9 | x = s.startswith("a") 10 | 11 | No errors. 12 | 13 | Types: 14 | x: bool 15 | 16 | Compiler typechecker (eval): 17 | No errors. 18 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/never_call_bug.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def foo(x: typing.Never): 9 | y = x(1) 10 | 11 | No errors. 12 | 13 | Types: 14 | y: typing.Never 15 | 16 | Compiler typechecker (eval): 17 | No errors. 18 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/new_list_dict_syntax.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def new_list_dict_syntax(d: dict[str, int]) -> list[str]: 9 | return list(d.keys()) 10 | 11 | def test(): 12 | # Check type is properly parsed from the function return type. 13 | x = new_list_dict_syntax({"a": 1, "b": 2}) 14 | 15 | No errors. 16 | 17 | Types: 18 | x: list[str] 19 | 20 | Compiler typechecker (eval): 21 | No errors. 22 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/new_list_dict_syntax_as_value.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def test(): 9 | x = list[str] 10 | y = dict[int, bool] 11 | 12 | No errors. 13 | 14 | Types: 15 | x: typing.Any 16 | y: typing.Any 17 | 18 | Compiler typechecker (eval): 19 | No errors. 20 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/struct.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def test(): 9 | x = struct(a = 1, b = "test") 10 | 11 | No errors. 12 | 13 | Types: 14 | x: struct(a = int, b = str) 15 | 16 | Compiler typechecker (eval): 17 | No errors. 18 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/success.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def foo(x: str) -> str: 9 | return x.removeprefix("test") 10 | 11 | def bar(): 12 | y = hash(foo("magic")) 13 | 14 | No errors. 15 | 16 | Types: 17 | y: int 18 | 19 | Compiler typechecker (eval): 20 | No errors. 21 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/test_bit_or_with_load.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | load("foo.bzl", "foo") 9 | test = int | foo() 10 | def test() -> test: 11 | pass 12 | 13 | No errors. 14 | 15 | Approximations: 16 | Approximation: Unknown type = "Span { begin: Pos(57), end: Pos(61) }" 17 | 18 | Compiler typechecker (eval): 19 | Compiler typechecker and eval results mismatch. 20 | 21 | error: String literals are not allowed in type expressions: `"test"` 22 | --> filename:3:8 23 | | 24 | 3 | test = int | foo() 25 | | ^^^^^^^^^^^ 26 | | 27 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/test_bit_or_with_load_foo.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def foo() -> str: 9 | return "test" 10 | 11 | No errors. 12 | 13 | Compiler typechecker (eval): 14 | No errors. 15 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/tuple.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def empty_tuple_fixed_name() -> (): return tuple() 9 | def empty_tuple_name_fixed() -> tuple: return () 10 | 11 | No errors. 12 | 13 | Compiler typechecker (eval): 14 | No errors. 15 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/tuple_ellipsis.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def f(t: tuple[int, ...]) -> int: 9 | return t[0] 10 | 11 | def g(): 12 | # Good. 13 | f((1, 2, 3)) 14 | 15 | # Bad. 16 | f((1, "x")) 17 | 18 | Error: 19 | error: Expected type `tuple[int, ...]` but got `(int, str)` 20 | --> filename:10:7 21 | | 22 | 10 | f((1, "x")) 23 | | ^^^^^^^^ 24 | | 25 | 26 | Compiler typechecker (eval): 27 | error: Expected type `tuple[int, ...]` but got `(int, str)` 28 | --> filename:10:7 29 | | 30 | 10 | f((1, "x")) 31 | | ^^^^^^^^ 32 | | 33 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/type_alias.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | MyList = list[int] 9 | 10 | def f(x: MyList): 11 | pass 12 | 13 | No errors. 14 | 15 | Types: 16 | x: list[int] 17 | 18 | Compiler typechecker (eval): 19 | No errors. 20 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/type_kwargs.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def foo(**kwargs): 9 | pass 10 | 11 | def bar(): 12 | foo(**{1: "x"}) 13 | 14 | Error: 15 | error: Expected type `dict[str, typing.Any]` but got `dict[int, str]` 16 | --> filename:6:11 17 | | 18 | 6 | foo(**{1: "x"}) 19 | | ^^^^^^^^ 20 | | 21 | 22 | Compiler typechecker (eval): 23 | error: Expected type `dict[str, typing.Any]` but got `dict[int, str]` 24 | --> filename:6:11 25 | | 26 | 6 | foo(**{1: "x"}) 27 | | ^^^^^^^^ 28 | | 29 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/types_of_args_kwargs.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def foo(*args: str, **kwargs: int): 9 | pass 10 | 11 | def test(): 12 | # Good 13 | foo("a") 14 | foo(b=1) 15 | # Bad 16 | foo(1) 17 | foo(c="x") 18 | 19 | Error: 20 | error: Expected type `str` but got `int` 21 | --> filename:10:9 22 | | 23 | 10 | foo(1) 24 | | ^ 25 | | 26 | 27 | Error: 28 | error: Expected type `int` but got `str` 29 | --> filename:11:9 30 | | 31 | 11 | foo(c="x") 32 | | ^^^^^ 33 | | 34 | 35 | Types: 36 | args: tuple[str, ...] 37 | kwargs: dict[str, int] 38 | 39 | Compiler typechecker (eval): 40 | error: Expected type `str` but got `int` 41 | --> filename:10:9 42 | | 43 | 10 | foo(1) 44 | | ^ 45 | | 46 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/un_op.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def test(): 9 | # Good. 10 | x = -1 11 | # Bad. 12 | y = ~True 13 | # Union good and bad. 14 | z = -(1 if True else "") 15 | 16 | Error: 17 | error: Unary operator `~` is not available on the type `bool` 18 | --> filename:6:9 19 | | 20 | 6 | y = ~True 21 | | ^^^^^ 22 | | 23 | 24 | Types: 25 | x: int 26 | y: typing.Never 27 | z: int 28 | 29 | Compiler typechecker (eval): 30 | error: Unary operator `~` is not available on the type `bool` 31 | --> filename:6:9 32 | | 33 | 6 | y = ~True 34 | | ^^^^^ 35 | | 36 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/union.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def func_which_returns_union(p) -> str | int: 9 | if p == 56: 10 | return "a" 11 | elif p == 57: 12 | return 1 13 | else: 14 | return [] 15 | 16 | Error: 17 | error: Expected type `int | str` but got `list[typing.Never]` 18 | --> filename:8:9 19 | | 20 | 8 | return [] 21 | | ^^^^^^^^^ 22 | | 23 | 24 | Compiler typechecker (eval): 25 | error: Expected type `int | str` but got `list[typing.Never]` 26 | --> filename:8:9 27 | | 28 | 8 | return [] 29 | | ^^^^^^^^^ 30 | | 31 | -------------------------------------------------------------------------------- /starlark/src/typing/tests/golden/zip.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Code: 8 | def test(): 9 | x = zip([1,2], [True, False], ["a", "b"]) 10 | 11 | No errors. 12 | 13 | Types: 14 | x: list[(int, bool, str)] 15 | 16 | Compiler typechecker (eval): 17 | No errors. 18 | -------------------------------------------------------------------------------- /starlark/src/util.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | //! Utilities. 19 | 20 | pub(crate) mod arc_or_static; 21 | pub(crate) mod arc_str; 22 | pub(crate) mod non_static_type_id; 23 | pub(crate) mod refcell; 24 | pub(crate) mod rtabort; 25 | pub use crate::util::arc_str::ArcStr; 26 | -------------------------------------------------------------------------------- /starlark/src/values/layout/heap.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | //! Starlark heap implementation. 19 | 20 | pub(crate) mod allocator; 21 | pub(crate) mod arena; 22 | pub(crate) mod call_enter_exit; 23 | mod fast_cell; 24 | pub(crate) mod heap_type; 25 | pub(crate) mod maybe_uninit_slice_util; 26 | pub(crate) mod profile; 27 | pub(crate) mod repr; 28 | -------------------------------------------------------------------------------- /starlark/src/values/layout/heap/allocator.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | pub(crate) mod alloc; 19 | pub(crate) mod api; 20 | pub(crate) mod bumpalo; 21 | -------------------------------------------------------------------------------- /starlark/src/values/layout/heap/profile.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | //! Summary of heap allocations and function times with stacks. 19 | 20 | pub(crate) mod aggregated; 21 | pub(crate) mod alloc_counts; 22 | pub(crate) mod by_type; 23 | pub(crate) mod string_index; 24 | mod summary_by_function; 25 | -------------------------------------------------------------------------------- /starlark/src/values/thin_box_slice_frozen_value.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | pub(crate) mod packed_impl; 19 | mod thin_box; 20 | -------------------------------------------------------------------------------- /starlark/src/values/types/float.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | //! The floating point number type (3.14, 4e2). 19 | 20 | pub(crate) mod float; 21 | pub(crate) mod globals; 22 | pub(crate) mod unpack; 23 | 24 | pub use crate::values::types::float::float::StarlarkFloat; 25 | pub use crate::values::types::float::unpack::UnpackFloat; 26 | -------------------------------------------------------------------------------- /starlark/src/values/types/namespace.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | //! Provides the `namespace` type and global 19 | 20 | pub(crate) mod globals; 21 | mod typing; 22 | pub(crate) mod value; 23 | 24 | pub use value::FrozenNamespace; 25 | pub use value::Namespace; 26 | -------------------------------------------------------------------------------- /starlark/src/values/types/none.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | //! The `None` type. 19 | 20 | pub(crate) mod globals; 21 | mod none_or; 22 | pub(crate) mod none_type; 23 | 24 | pub use none_or::NoneOr; 25 | pub use none_type::NoneType; 26 | -------------------------------------------------------------------------------- /starlark/src/values/types/num.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | //! Helpers for numerical values. 19 | 20 | pub(crate) mod globals; 21 | pub(crate) mod typecheck; 22 | pub(crate) mod value; 23 | -------------------------------------------------------------------------------- /starlark/src/values/types/range.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | //! The range type, constructed with `range()`. 19 | 20 | pub(crate) mod globals; 21 | mod range_type; 22 | 23 | pub use range_type::Range; 24 | -------------------------------------------------------------------------------- /starlark/src/values/types/record/record_type/anon_record.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | 9 | record(a = field(int))(a = 1) 10 | 11 | Error: 12 | 13 | Traceback (most recent call last): 14 | * assert.bzl:1, in 15 | record(a = field(int))(a = 1) 16 | error: Record instance cannot be created if record type is not assigned to a global variable 17 | --> assert.bzl:1:1 18 | | 19 | 1 | record(a = field(int))(a = 1) 20 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 21 | | 22 | -------------------------------------------------------------------------------- /starlark/src/values/types/record/record_type/missing_field_error.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | 9 | RecFail = record(a = field(int), b = field(int)) 10 | 11 | _x = RecFail(a = 1) 12 | 13 | Error: 14 | 15 | Traceback (most recent call last): 16 | * assert.bzl:3, in 17 | _x = RecFail(a = 1) 18 | error: Missing named-only parameter `b` for call to `RecFail` 19 | --> assert.bzl:3:6 20 | | 21 | 3 | _x = RecFail(a = 1) 22 | | ^^^^^^^^^^^^^^ 23 | | 24 | -------------------------------------------------------------------------------- /starlark/src/values/types/record/record_type/record_callable_compile_time.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | 9 | Rec = record(a = int, b = str) 10 | 11 | def test(): 12 | Rec(c = []) 13 | 14 | Error: 15 | 16 | error: Unexpected parameter named `c` 17 | --> assert.bzl:4:9 18 | | 19 | 4 | Rec(c = []) 20 | | ^^^^^^ 21 | | 22 | -------------------------------------------------------------------------------- /starlark/src/values/types/record/record_type/record_type_as_type_compile_time.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | 9 | RecFailCt1 = record(a = field(int), b = field(int)) 10 | RecFailCt2 = record(a = field(int), b = field(int)) 11 | 12 | def f_fail_ct(x: RecFailCt1): 13 | return x.a 14 | 15 | def test(): 16 | f_fail_ct(RecFailCt2(a = 1, b = 2)) 17 | 18 | Error: 19 | 20 | error: Expected type `RecFailCt1` but got `RecFailCt2` 21 | --> assert.bzl:8:15 22 | | 23 | 8 | f_fail_ct(RecFailCt2(a = 1, b = 2)) 24 | | ^^^^^^^^^^^^^^^^^^^^^^^^ 25 | | 26 | -------------------------------------------------------------------------------- /starlark/src/values/types/record/record_type/record_type_as_type_runtime.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | 9 | RecFailRt1 = record(a = field(int), b = field(int)) 10 | RecFailRt2 = record(a = field(int), b = field(int)) 11 | 12 | def f_fail_rt(x: RecFailRt1): 13 | return x.a 14 | 15 | noop(f_fail_rt)(RecFailRt2(a = 1, b = 2)) 16 | 17 | Error: 18 | 19 | Traceback (most recent call last): 20 | * assert.bzl:7, in 21 | noop(f_fail_rt)(RecFailRt2(a = 1, b = 2)) 22 | error: Value `record[RecFailRt2](a=1, b=2)` of type `record` does not match the type annotation `RecFailRt1` for argument `x` 23 | --> assert.bzl:7:1 24 | | 25 | 7 | noop(f_fail_rt)(RecFailRt2(a = 1, b = 2)) 26 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 27 | | 28 | -------------------------------------------------------------------------------- /starlark/src/values/types/record/ty_record_type/fail_compile_time.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | 9 | MyRec = record(x = int) 10 | WrongRec = record(x = int) 11 | 12 | def foo(x: MyRec): pass 13 | 14 | def bar(): 15 | foo(WrongRec(x = 1)) 16 | 17 | Error: 18 | 19 | error: Expected type `MyRec` but got `WrongRec` 20 | --> assert.bzl:7:9 21 | | 22 | 7 | foo(WrongRec(x = 1)) 23 | | ^^^^^^^^^^^^^^^ 24 | | 25 | -------------------------------------------------------------------------------- /starlark/src/values/types/record/ty_record_type/fail_runtime_time.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | 9 | MyRec = record(x = int) 10 | WrongRec = record(x = int) 11 | 12 | def foo(x: MyRec): pass 13 | 14 | noop(foo)(WrongRec(x = 1)) 15 | 16 | Error: 17 | 18 | Traceback (most recent call last): 19 | * assert.bzl:6, in 20 | noop(foo)(WrongRec(x = 1)) 21 | error: Value `record[WrongRec](x=1)` of type `record` does not match the type annotation `MyRec` for argument `x` 22 | --> assert.bzl:6:1 23 | | 24 | 6 | noop(foo)(WrongRec(x = 1)) 25 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 26 | | 27 | -------------------------------------------------------------------------------- /starlark/src/values/types/record/ty_record_type/typecheck_field_fail.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | 9 | MyRec = record(x = int, y = int) 10 | 11 | def f(rec: MyRec) -> int: 12 | return rec.z 13 | 14 | Error: 15 | 16 | error: The attribute `z` is not available on the type `MyRec` 17 | --> assert.bzl:4:16 18 | | 19 | 4 | return rec.z 20 | | ^ 21 | | 22 | -------------------------------------------------------------------------------- /starlark/src/values/types/record/ty_record_type/typecheck_record_type_call.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | 9 | MyRec = record(x = int) 10 | 11 | def test(): 12 | MyRec(x = "") 13 | 14 | Error: 15 | 16 | error: Expected type `int` but got `str` 17 | --> assert.bzl:4:11 18 | | 19 | 4 | MyRec(x = "") 20 | | ^^^^^^ 21 | | 22 | -------------------------------------------------------------------------------- /starlark/src/values/types/set.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | //! The set type 19 | pub(crate) mod methods; 20 | pub(crate) mod refs; 21 | pub(crate) mod set; 22 | pub(crate) mod value; 23 | pub use crate::values::set::refs::SetMut; 24 | pub use crate::values::set::refs::SetRef; 25 | -------------------------------------------------------------------------------- /starlark/src/values/types/string/intern.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | pub(crate) mod interner; 19 | -------------------------------------------------------------------------------- /starlark/src/values/typing/type_compiled.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | pub(crate) mod alloc; 19 | pub(crate) mod compiled; 20 | pub(crate) mod factory; 21 | pub(crate) mod globals; 22 | pub(crate) mod matcher; 23 | pub(crate) mod matchers; 24 | pub(crate) mod tests; 25 | pub(crate) mod type_matcher_factory; 26 | -------------------------------------------------------------------------------- /starlark/src/wasm.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #![doc(hidden)] 19 | 20 | /// Are we on wasm? 21 | pub fn is_wasm() -> bool { 22 | cfg!(target_arch = "wasm32") 23 | } 24 | -------------------------------------------------------------------------------- /starlark/testcases/eval/go/README.md: -------------------------------------------------------------------------------- 1 | # Go evaluation test cases 2 | 3 | The Go Starlark project maintains a set of test cases, which were mirrored here. 4 | The original source is 5 | https://github.com/google/starlark-go/blob/e81fc95f7bd5bb1495fe69f27c1a99fcc77caa48/starlark/testdata/. 6 | Note that some files were not copied, because they are unsuitable tests for 7 | Starlark, as described in the `test_go` function. 8 | -------------------------------------------------------------------------------- /starlark_bin/bin/dap/library.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | pub(crate) use crate::dap::library::events::Client; 19 | pub(crate) use crate::dap::library::requests::DebugServer; 20 | pub(crate) use crate::dap::library::server::DapService; 21 | 22 | mod events; 23 | mod requests; 24 | mod server; 25 | mod stream; 26 | -------------------------------------------------------------------------------- /starlark_derive/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ["Facebook"] 3 | description = "Derive helpers for the starlark package." 4 | documentation = "https://docs.rs/starlark_derive" 5 | edition = "2024" 6 | license = "Apache-2.0" 7 | name = "starlark_derive" 8 | repository = "https://github.com/facebook/starlark-rust" 9 | version = "0.13.0" 10 | 11 | [lib] 12 | proc-macro = true 13 | 14 | [dependencies] 15 | dupe = { workspace = true } 16 | proc-macro2 = "1.0" 17 | quote = "1.0" 18 | syn = { version = "2", features = ["extra-traits", "full", "visit", "visit-mut"] } 19 | -------------------------------------------------------------------------------- /starlark_js_example/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | description = "Example of running starlark-rust interpreter in browser" 3 | edition = "2024" 4 | name = "starlark_js_example" 5 | publish = false 6 | version = "0.0.0" 7 | 8 | [dependencies] 9 | starlark = { path = "../starlark", version = "0.13.0" } 10 | 11 | [lib] 12 | crate-type = ["cdylib", "rlib"] 13 | -------------------------------------------------------------------------------- /starlark_js_example/README.md: -------------------------------------------------------------------------------- 1 | # Starlark JS 2 | 3 | This directory contains an example project making use of Starlark 4 | WebAssembly/WASM. To try it: 5 | 6 | ``` 7 | rustup target add wasm32-unknown-unknown 8 | cargo build --target wasm32-unknown-unknown --release 9 | cp ../target/wasm32-unknown-unknown/release/starlark_js.wasm . 10 | python -m http.server 11 | ``` 12 | 13 | Then visit [http://localhost:8000](http://localhost:8000). 14 | -------------------------------------------------------------------------------- /starlark_map/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = [ 3 | "Facebook", 4 | ] 5 | description = "Map implementation with starlark-rust specific optimizations" 6 | documentation = "https://docs.rs/starlark_map" 7 | edition = "2024" 8 | license = "Apache-2.0" 9 | name = "starlark_map" 10 | repository = "https://github.com/facebook/starlark-rust" 11 | version = "0.13.0" 12 | 13 | [dependencies] 14 | allocative = { workspace = true, features = ["hashbrown"] } 15 | dupe = { workspace = true } 16 | 17 | equivalent = { workspace = true } 18 | fxhash = "0.2.1" 19 | hashbrown = { version = "0.14.3", features = ["raw"] } 20 | serde = { version = "1.0", features = ["derive"] } 21 | strong_hash = { workspace = true } 22 | 23 | [dev-dependencies] 24 | serde_json = "1.0.48" 25 | 26 | [lints.rust] 27 | unexpected_cfgs = { level = "warn", check-cfg = ["cfg(rust_nightly)"] } 28 | -------------------------------------------------------------------------------- /starlark_map/src/sorting.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | pub(crate) mod insertion; 19 | -------------------------------------------------------------------------------- /starlark_map/src/vec_map/hint.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The Starlark in Rust Authors. 3 | * Copyright (c) Facebook, Inc. and its affiliates. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #[cfg(rust_nightly)] 19 | pub(crate) use std::intrinsics::likely; 20 | #[cfg(not(rust_nightly))] 21 | #[inline(always)] 22 | pub(crate) fn likely(x: bool) -> bool { 23 | x 24 | } 25 | -------------------------------------------------------------------------------- /starlark_syntax/src/lexer_tests/comment.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | # first comment 9 | # second comment 10 | a # third comment 11 | 12 | # But it should not eat everything 13 | [ 14 | # comment inside list 15 | ] 16 | 17 | Tokens: 18 | comment ' first comment' # # first comment 19 | comment ' second comment' # # second comment 20 | identifier 'a' # a 21 | comment ' third comment' # # third comment 22 | new line # \n 23 | new line # \n 24 | comment ' But it should not eat everything' # # But it should not eat everything 25 | symbol '[' # [ 26 | comment ' comment inside list' # # comment inside list 27 | symbol ']' # ] 28 | new line # 29 | -------------------------------------------------------------------------------- /starlark_syntax/src/lexer_tests/escape_newline.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | a \ 9 | b 10 | 11 | Tokens: 12 | identifier 'a' # a 13 | identifier 'b' # b 14 | new line # 15 | -------------------------------------------------------------------------------- /starlark_syntax/src/lexer_tests/f_string.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | f"basic1 {stuff1}" 9 | f'basic2 {stuff2}' 10 | 11 | # Raw f-string 12 | 13 | fr'' fr"" fr'\'' fr"\"" fr'"' fr"'" fr'\n' 14 | 15 | Tokens: 16 | f-string "basic1 {stuff1}" # f"basic1 {stuff1}" 17 | new line # \n 18 | f-string "basic2 {stuff2}" # f'basic2 {stuff2}' 19 | new line # \n 20 | new line # \n 21 | comment ' Raw f-string' # # Raw f-string 22 | new line # \n 23 | f-string "" # fr'' 24 | f-string "" # fr"" 25 | f-string "'" # fr'\'' 26 | f-string "\"" # fr"\"" 27 | f-string "\"" # fr'"' 28 | f-string "'" # fr"'" 29 | f-string "\\n" # fr'\n' 30 | new line # 31 | -------------------------------------------------------------------------------- /starlark_syntax/src/lexer_tests/final_comment.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | x 9 | # test 10 | 11 | Tokens: 12 | identifier 'x' # x 13 | new line # \n 14 | comment ' test' # # test 15 | new line # 16 | -------------------------------------------------------------------------------- /starlark_syntax/src/lexer_tests/identifier.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | a identifier CAPS _CAPS _0123 9 | 10 | Tokens: 11 | identifier 'a' # a 12 | identifier 'identifier' # identifier 13 | identifier 'CAPS' # CAPS 14 | identifier '_CAPS' # _CAPS 15 | identifier '_0123' # _0123 16 | new line # 17 | -------------------------------------------------------------------------------- /starlark_syntax/src/lexer_tests/int_lit.fail.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | x = 01 9 | 10 | Error: 11 | error: Parse error: integer cannot have leading 0, got `01` 12 | --> x:1:5 13 | | 14 | 1 | x = 01 15 | | ^^ 16 | | 17 | -------------------------------------------------------------------------------- /starlark_syntax/src/lexer_tests/int_lit.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | 0 123 9 | 0x7F 0x7d 10 | 0B1011 0b1010 11 | 0o755 0O753 12 | 13 | Tokens: 14 | integer literal '0' # 0 15 | integer literal '123' # 123 16 | new line # \n 17 | integer literal '127' # 0x7F 18 | integer literal '125' # 0x7d 19 | new line # \n 20 | integer literal '11' # 0B1011 21 | integer literal '10' # 0b1010 22 | new line # \n 23 | integer literal '493' # 0o755 24 | integer literal '491' # 0O753 25 | new line # 26 | -------------------------------------------------------------------------------- /starlark_syntax/src/lexer_tests/keywords.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | and else load break for not not in continue if or def in pass elif return lambda 9 | 10 | Tokens: 11 | keyword 'and' # and 12 | keyword 'else' # else 13 | keyword 'load' # load 14 | keyword 'break' # break 15 | keyword 'for' # for 16 | keyword 'not' # not 17 | keyword 'not' # not 18 | keyword 'in' # in 19 | keyword 'continue' # continue 20 | keyword 'if' # if 21 | keyword 'or' # or 22 | keyword 'def' # def 23 | keyword 'in' # in 24 | keyword 'pass' # pass 25 | keyword 'elif' # elif 26 | keyword 'return' # return 27 | keyword 'lambda' # lambda 28 | new line # 29 | -------------------------------------------------------------------------------- /starlark_syntax/src/lexer_tests/multiline_triple.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | cmd = """A \ 9 | B \ 10 | C \ 11 | """ 12 | 13 | Tokens: 14 | identifier 'cmd' # cmd 15 | symbol '=' # = 16 | string literal "A B C " # """A \\n B \\n C \\n """ 17 | new line # 18 | -------------------------------------------------------------------------------- /starlark_syntax/src/lexer_tests/operators.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | 1+-2 9 | 1+------2 10 | ///==/+- 11 | 12 | Tokens: 13 | integer literal '1' # 1 14 | symbol '+' # + 15 | symbol '-' # - 16 | integer literal '2' # 2 17 | new line # \n 18 | integer literal '1' # 1 19 | symbol '+' # + 20 | symbol '-' # - 21 | symbol '-' # - 22 | symbol '-' # - 23 | symbol '-' # - 24 | symbol '-' # - 25 | symbol '-' # - 26 | integer literal '2' # 2 27 | new line # \n 28 | symbol '//' # // 29 | symbol '/=' # /= 30 | symbol '=' # = 31 | symbol '/' # / 32 | symbol '+' # + 33 | symbol '-' # - 34 | new line # 35 | -------------------------------------------------------------------------------- /starlark_syntax/src/lexer_tests/string_escape.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | '\0\0\1n' 9 | '\0\00\000\0000' 10 | '\x000' 11 | '\372x' 12 | 13 | Tokens: 14 | string literal "\0\0\u{1}n" # '\0\0\1n' 15 | new line # \n 16 | string literal "\0\0\0\00" # '\0\00\000\0000' 17 | new line # \n 18 | string literal "\00" # '\x000' 19 | new line # \n 20 | string literal "úx" # '\372x' 21 | new line # 22 | -------------------------------------------------------------------------------- /starlark_syntax/src/syntax/def_tests/args_args.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | def test(*x, *y): pass 9 | 10 | Error: error: Args parameter after another args or kwargs parameter 11 | --> test.star:1:14 12 | | 13 | 1 | def test(*x, *y): pass 14 | | ^^ 15 | | 16 | -------------------------------------------------------------------------------- /starlark_syntax/src/syntax/def_tests/default_after_kwargs.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | def test(**kwargs, y=1): pass 9 | 10 | Error: error: Parameter after kwargs 11 | --> test.star:1:20 12 | | 13 | 1 | def test(**kwargs, y=1): pass 14 | | ^^^ 15 | | 16 | -------------------------------------------------------------------------------- /starlark_syntax/src/syntax/def_tests/dup_name.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | def test(x, y, x): pass 9 | 10 | Error: error: duplicated parameter name 11 | --> test.star:1:16 12 | | 13 | 1 | def test(x, y, x): pass 14 | | ^ 15 | | 16 | -------------------------------------------------------------------------------- /starlark_syntax/src/syntax/def_tests/kwargs_args.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | def test(**x, *y): pass 9 | 10 | Error: error: Args parameter after another args or kwargs parameter 11 | --> test.star:1:15 12 | | 13 | 1 | def test(**x, *y): pass 14 | | ^^ 15 | | 16 | -------------------------------------------------------------------------------- /starlark_syntax/src/syntax/def_tests/kwargs_kwargs.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | def test(**x, **y): pass 9 | 10 | Error: error: Multiple kwargs dictionary in parameters 11 | --> test.star:1:15 12 | | 13 | 1 | def test(**x, **y): pass 14 | | ^^^ 15 | | 16 | -------------------------------------------------------------------------------- /starlark_syntax/src/syntax/def_tests/named_only_in_standard_dialect_def.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | def test(*, x): pass 9 | 10 | Error: error: * keyword-only-arguments is not allowed in this dialect 11 | --> test.star:1:10 12 | | 13 | 1 | def test(*, x): pass 14 | | ^ 15 | | 16 | -------------------------------------------------------------------------------- /starlark_syntax/src/syntax/def_tests/named_only_in_standard_dialect_lambda.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | lambda *, x: 17 9 | 10 | Error: error: * keyword-only-arguments is not allowed in this dialect 11 | --> test.star:1:8 12 | | 13 | 1 | lambda *, x: 17 14 | | ^ 15 | | 16 | -------------------------------------------------------------------------------- /starlark_syntax/src/syntax/def_tests/normal_after_default.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | def test(x, y=1, z): pass 9 | 10 | Error: error: positional parameter after non positional 11 | --> test.star:1:18 12 | | 13 | 1 | def test(x, y=1, z): pass 14 | | ^ 15 | | 16 | -------------------------------------------------------------------------------- /starlark_syntax/src/syntax/def_tests/pos_after_default.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | def test(x=1, y): pass 9 | 10 | Error: error: positional parameter after non positional 11 | --> test.star:1:15 12 | | 13 | 1 | def test(x=1, y): pass 14 | | ^ 15 | | 16 | -------------------------------------------------------------------------------- /starlark_syntax/src/syntax/def_tests/positional_only_cannot_be_first.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | def test(/, x): pass 9 | 10 | Error: error: `/` cannot be first parameter 11 | --> test.star:1:10 12 | | 13 | 1 | def test(/, x): pass 14 | | ^ 15 | | 16 | -------------------------------------------------------------------------------- /starlark_syntax/src/syntax/def_tests/positional_only_in_standard_dialect_def.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | def test(/, x): pass 9 | 10 | Error: error: / positional-only-arguments is not allowed in this dialect 11 | --> test.star:1:10 12 | | 13 | 1 | def test(/, x): pass 14 | | ^ 15 | | 16 | -------------------------------------------------------------------------------- /starlark_syntax/src/syntax/def_tests/positional_only_in_standard_dialect_lambda.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | lambda /, x: 17 9 | 10 | Error: error: / positional-only-arguments is not allowed in this dialect 11 | --> test.star:1:8 12 | | 13 | 1 | lambda /, x: 17 14 | | ^ 15 | | 16 | -------------------------------------------------------------------------------- /starlark_syntax/src/syntax/def_tests/slash_slash.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | def test(x, /, y, /): pass 9 | 10 | Error: error: Multiple `/` in parameters 11 | --> test.star:1:19 12 | | 13 | 1 | def test(x, /, y, /): pass 14 | | ^ 15 | | 16 | -------------------------------------------------------------------------------- /starlark_syntax/src/syntax/def_tests/star_cannot_be_last.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | def test(x, *): pass 9 | 10 | Error: error: `*` parameter must not be last 11 | --> test.star:1:13 12 | | 13 | 1 | def test(x, *): pass 14 | | ^ 15 | | 16 | -------------------------------------------------------------------------------- /starlark_syntax/src/syntax/def_tests/star_star.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | def test(*, *): pass 9 | 10 | Error: error: Args parameter after another args or kwargs parameter 11 | --> test.star:1:13 12 | | 13 | 1 | def test(*, *): pass 14 | | ^ 15 | | 16 | -------------------------------------------------------------------------------- /starlark_syntax/src/syntax/def_tests/star_then_args.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | def test(x, *, *args): pass 9 | 10 | Error: error: Args parameter after another args or kwargs parameter 11 | --> test.star:1:16 12 | | 13 | 1 | def test(x, *, *args): pass 14 | | ^^^^^ 15 | | 16 | -------------------------------------------------------------------------------- /starlark_syntax/src/syntax/def_tests/star_then_kwargs.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | def test(x, *, **kwargs): pass 9 | 10 | Error: error: `*` must be followed by named parameter 11 | --> test.star:1:16 12 | | 13 | 1 | def test(x, *, **kwargs): pass 14 | | ^^^^^^^^ 15 | | 16 | -------------------------------------------------------------------------------- /starlark_syntax/src/syntax/grammar_tests/assignment_type_annotation.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | (x, y): int = foo 9 | 10 | Error: 11 | error: type annotations not allowed on multiple assignments 12 | --> assignment_type_annotation:1:9 13 | | 14 | 1 | (x, y): int = foo 15 | | ^^^ 16 | | 17 | -------------------------------------------------------------------------------- /starlark_syntax/src/syntax/grammar_tests/bad_assignment.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | [x or y] = 1 9 | 10 | Error: 11 | error: left-hand-side of assignment must take the form `a`, `a.b` or `a[b]` 12 | --> bad_assignment:1:2 13 | | 14 | 1 | [x or y] = 1 15 | | ^^^^^^ 16 | | 17 | 18 | 19 | Program: 20 | [x] += 1 21 | 22 | Error: 23 | error: left-hand-side of modifying assignment cannot be a list or tuple 24 | --> bad_assignment:1:1 25 | | 26 | 1 | [x] += 1 27 | | ^^^ 28 | | 29 | -------------------------------------------------------------------------------- /starlark_syntax/src/syntax/grammar_tests/ellipsis.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | x = ... 9 | 10 | Error: 11 | error: `...` is not allowed in this dialect 12 | --> ellipsis:1:5 13 | | 14 | 1 | x = ... 15 | | ^^^ 16 | | 17 | -------------------------------------------------------------------------------- /starlark_syntax/src/syntax/grammar_tests/lambda.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | x = lambda y: y + 1 9 | 10 | Error: 11 | error: `lambda` is not allowed in this dialect 12 | --> lambda:1:5 13 | | 14 | 1 | x = lambda y: y + 1 15 | | ^^^^^^^^^^^^^^^ 16 | | 17 | -------------------------------------------------------------------------------- /starlark_syntax/src/syntax/grammar_tests/list_in_index_expr.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | x[1, 2] = 3 9 | 10 | Error: 11 | error: left-hand-side of assignment must take the form `a`, `a.b` or `a[b]` 12 | --> list_in_index_expr:1:1 13 | | 14 | 1 | x[1, 2] = 3 15 | | ^^^^^^^ 16 | | 17 | -------------------------------------------------------------------------------- /starlark_syntax/src/syntax/grammar_tests/top_level_def.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | def toto(): 9 | pass 10 | 11 | Error: 12 | error: `def` is not allowed in this dialect 13 | --> top_level_def:1:1 14 | | 15 | 1 | / def toto(): 16 | 2 | | pass 17 | | |______^ 18 | | 19 | -------------------------------------------------------------------------------- /starlark_syntax/src/syntax/grammar_tests/top_level_statements.golden: -------------------------------------------------------------------------------- 1 | # @generated 2 | # To regenerate, run: 3 | # ``` 4 | # STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib 5 | # ``` 6 | 7 | Program: 8 | x = 1 9 | if x == 1: 10 | x = 2 11 | x = 3 12 | 13 | Error: 14 | error: `if` cannot be used outside `def` in this dialect 15 | --> top_level_statements:2:1 16 | | 17 | 2 | / if x == 1: 18 | 3 | | x = 2 19 | 4 | | x = 3 20 | | |_^ 21 | | 22 | 23 | 24 | Program: 25 | x = 1 26 | for x in []: 27 | pass 28 | 29 | Error: 30 | error: `for` cannot be used outside `def` in this dialect 31 | --> top_level_statements:2:1 32 | | 33 | 2 | / for x in []: 34 | 3 | | pass 35 | | |_______^ 36 | | 37 | -------------------------------------------------------------------------------- /starlark_syntax/testcases/parse/README.md: -------------------------------------------------------------------------------- 1 | # Parsing test cases 2 | 3 | A set of `.bzl` files taken from various open-source projects to test the 4 | Starlark parser against real world cases. 5 | 6 | Files are marked generated, that was done to mute linters. There's no automation 7 | to regenerate these files. 8 | -------------------------------------------------------------------------------- /starlark_syntax/testcases/parse/alias_rules.star: -------------------------------------------------------------------------------- 1 | # @generated 2 | # Copyright 2017 The Bazel Authors. All rights reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | """Skylark rules that stub out C++-related alias rules.""" 17 | def cc_toolchain_alias(name): 18 | if hasattr(native, "cc_toolchain_alias"): 19 | native.cc_toolchain_alias(name=name) 20 | else: 21 | pass 22 | -------------------------------------------------------------------------------- /starlark_syntax/testcases/parse/bzl.star: -------------------------------------------------------------------------------- 1 | # @generated 2 | load(":workspace.bzl", _mvn_deps="maven_dependencies") 3 | 4 | def _declare_maven(item): 5 | sha = item.get("sha1") 6 | kwargs = { 7 | "name": item["name"], 8 | "artifact": item["artifact"], 9 | "repository": item["repository"], 10 | } 11 | if sha != None: 12 | kwargs["sha1"] = sha 13 | native.maven_jar(**kwargs) 14 | 15 | def maven_dependencies(): 16 | _mvn_deps(_declare_maven) 17 | -------------------------------------------------------------------------------- /starlark_syntax/testcases/parse/classpath.star: -------------------------------------------------------------------------------- 1 | # @generated 2 | def _classpath_collector(ctx): 3 | all = set_which_is_banned() 4 | for d in ctx.attr.deps: 5 | if hasattr(d, 'java'): 6 | all += d.java.transitive_runtime_deps 7 | all += d.java.compilation_info.runtime_classpath 8 | elif hasattr(d, 'files'): 9 | all += d.files 10 | 11 | as_strs = [c.path for c in all] 12 | ctx.file_action(output= ctx.outputs.runtime, 13 | content="\n".join(sorted(as_strs))) 14 | 15 | classpath_collector = rule( 16 | attrs = { 17 | "deps": attr.label_list(), 18 | }, 19 | outputs = { 20 | "runtime": "%{name}.runtime_classpath", 21 | }, 22 | implementation = _classpath_collector, 23 | ) 24 | -------------------------------------------------------------------------------- /starlark_syntax/testcases/parse/config.star: -------------------------------------------------------------------------------- 1 | # @generated 2 | ADMIN_USERS = [ 3 | "dmarting@google.com", 4 | "dslomov@google.com", 5 | "laszlocsomor@google.com", 6 | "lberki@google.com", 7 | "pcloudy@google.com", 8 | "yueg@google.com", 9 | "jcater@google.com", 10 | "aehlig@google.com", 11 | "elenairina@google.com", 12 | "hlopko@google.com", 13 | "vladmos@google.com", 14 | "fisherii@google.com", 15 | "philwo@google.com", 16 | "buchgr@google.com", 17 | "davidstanke@google.com", 18 | ] 19 | -------------------------------------------------------------------------------- /starlark_syntax/testcases/parse/docker.star: -------------------------------------------------------------------------------- 1 | # @generated 2 | # Copyright 2015 The Bazel Authors. All rights reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | """Rules for manipulation Docker images.""" 16 | 17 | load(":build.bzl", "docker_build") 18 | load(":bundle.bzl", "docker_bundle") 19 | -------------------------------------------------------------------------------- /starlark_syntax/testcases/parse/dummy_toolchain.star: -------------------------------------------------------------------------------- 1 | # @generated 2 | # pylint: disable=g-bad-file-header 3 | # Copyright 2017 The Bazel Authors. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | """Skylark rule that stubs a toolchain.""" 18 | def _dummy_toolchain_impl(ctx): 19 | ctx = ctx # unused argument 20 | toolchain = platform_common.ToolchainInfo() 21 | return [toolchain] 22 | 23 | dummy_toolchain = rule(_dummy_toolchain_impl, attrs = {}) 24 | -------------------------------------------------------------------------------- /starlark_syntax/testcases/parse/empty.star: -------------------------------------------------------------------------------- 1 | # @generated 2 | """Minimalist example of a rule that does nothing.""" 3 | 4 | def _empty_impl(ctx): 5 | # This function is called when the rule is analyzed. 6 | # You may use print for debugging. 7 | print("This rule does nothing") 8 | 9 | empty = rule(implementation=_empty_impl) 10 | -------------------------------------------------------------------------------- /starlark_syntax/testcases/parse/executable.star: -------------------------------------------------------------------------------- 1 | # @generated 2 | """This example creates an executable rule. 3 | 4 | An executable rule, like `cc_library`, can be run using 'bazel run'. It 5 | can also be executed as part of the build. 6 | """ 7 | 8 | def _impl(ctx): 9 | # The implementation function must generate the file 'ctx.outputs.executable'. 10 | ctx.actions.write( 11 | output=ctx.outputs.executable, 12 | content="#!/bin/bash\necho Hello!", 13 | is_executable=True 14 | ) 15 | # The executable output is added automatically to this target. 16 | 17 | executable_rule = rule( 18 | implementation=_impl, 19 | executable=True 20 | ) 21 | -------------------------------------------------------------------------------- /starlark_syntax/testcases/parse/extension.star: -------------------------------------------------------------------------------- 1 | # @generated 2 | """This example shows how to create custom (user defined) outputs for a rule. 3 | 4 | This rule takes a list of output files from the user and writes content in 5 | each of them. 6 | """ 7 | 8 | def _impl(ctx): 9 | # Access the custom outputs using ctx.outputs.. 10 | for output in ctx.outputs.outs: 11 | ctx.actions.write( 12 | output=output, 13 | content="I am " + output.short_path + "\n" 14 | ) 15 | # The custom outputs are added automatically to this target. 16 | 17 | rule_with_outputs = rule( 18 | implementation=_impl, 19 | attrs={ 20 | "outs": attr.output_list() 21 | } 22 | ) 23 | -------------------------------------------------------------------------------- /starlark_syntax/testcases/parse/external_plugin_deps.star: -------------------------------------------------------------------------------- 1 | # @generated 2 | def external_plugin_deps(): 3 | pass -------------------------------------------------------------------------------- /starlark_syntax/testcases/parse/filetype.star: -------------------------------------------------------------------------------- 1 | # @generated 2 | # Copyright 2017 The Bazel Authors. All rights reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | """Filetype constants.""" 16 | 17 | # Filetype to restrict inputs 18 | tar = [".tar", ".tar.gz", ".tgz", ".tar.xz"] 19 | deb = [".deb", ".udeb"] 20 | 21 | # Docker files are tarballs, should we allow other extensions than tar? 22 | docker = tar 23 | -------------------------------------------------------------------------------- /starlark_syntax/testcases/parse/generate_test.star: -------------------------------------------------------------------------------- 1 | # @generated 2 | def _generate_script_impl(ctx): 3 | script_file = ctx.actions.declare_file(ctx.label.name + ".bash") 4 | ctx.actions.write(output=script_file, is_executable=True, content=""" 5 | {0} 6 | """.format(ctx.file.binary.short_path)) 7 | return struct( 8 | files = depset([script_file]), 9 | ) 10 | 11 | 12 | generate_script = rule( 13 | _generate_script_impl, 14 | attrs = { 15 | "binary": attr.label(allow_files=True, single_file=True), 16 | }, 17 | ) 18 | -------------------------------------------------------------------------------- /starlark_syntax/testcases/parse/guava.star: -------------------------------------------------------------------------------- 1 | # @generated 2 | GUAVA_VERSION = "21.0" 3 | 4 | GUAVA_BIN_SHA1 = "3a3d111be1be1b745edfa7d91678a12d7ed38709" 5 | 6 | GUAVA_DOC_URL = "https://google.github.io/guava/releases/" + GUAVA_VERSION + "/api/docs/" 7 | -------------------------------------------------------------------------------- /starlark_syntax/testcases/parse/hello.star: -------------------------------------------------------------------------------- 1 | # @generated 2 | # Label of the template file to use. 3 | _TEMPLATE = "//expand_template:hello.cc" 4 | 5 | def _hello_impl(ctx): 6 | ctx.actions.expand_template( 7 | template=ctx.file._template, 8 | output=ctx.outputs.source_file, 9 | substitutions={ 10 | "{FIRSTNAME}": ctx.attr.firstname 11 | }) 12 | 13 | hello = rule( 14 | implementation=_hello_impl, 15 | attrs={ 16 | "firstname": attr.string(mandatory=True), 17 | "_template": attr.label( 18 | default=Label(_TEMPLATE), allow_files=True, single_file=True), 19 | }, 20 | outputs={"source_file": "%{name}.cc"}, 21 | ) 22 | -------------------------------------------------------------------------------- /starlark_syntax/testcases/parse/java.star: -------------------------------------------------------------------------------- 1 | # @generated 2 | # Copyright (C) 2016 The Android Open Source Project 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # Syntactic sugar for native java_library() rule: 17 | # accept exported_deps attributes 18 | 19 | def java_library2(deps=[], exported_deps=[], exports=[], **kwargs): 20 | if exported_deps: 21 | deps += exported_deps 22 | exports += exported_deps 23 | native.java_library( 24 | deps = deps, 25 | exports = exports, 26 | **kwargs) 27 | -------------------------------------------------------------------------------- /starlark_syntax/testcases/parse/jenkins.star: -------------------------------------------------------------------------------- 1 | # @generated 2 | # Copyright 2017 The Bazel Authors. All rights reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # Some definition to setup jenkins and build the corresponding docker images 17 | load(":jenkins_docker_build.bzl", "jenkins_docker_build") 18 | load(":jenkins_node.bzl", "jenkins_node") 19 | load(":jenkins_nodes.bzl", "jenkins_nodes", "jenkins_node_names") 20 | load(":jenkins_job.bzl", "jenkins_job", "bazel_git_job", "bazel_github_job") 21 | -------------------------------------------------------------------------------- /starlark_syntax/testcases/parse/load.star: -------------------------------------------------------------------------------- 1 | # @generated 2 | def declare_maven(item): 3 | sha = item.get("sha1") 4 | if sha != None: 5 | native.maven_jar(name = item["name"], artifact = item["artifact"], sha1 = sha) 6 | else: 7 | native.maven_jar(name = item["name"], artifact = item["artifact"]) 8 | native.bind(name = item["bind"], actual = item["actual"]) 9 | -------------------------------------------------------------------------------- /starlark_syntax/testcases/parse/printer.star: -------------------------------------------------------------------------------- 1 | # @generated 2 | """Example of a rule that accesses its attributes.""" 3 | 4 | def _impl(ctx): 5 | # Print debug information about the target. 6 | print("Target {} has {} deps".format(ctx.label, len(ctx.attr.deps))) 7 | 8 | # For each target in deps, print its label and files. 9 | for i, d in enumerate(ctx.attr.deps): 10 | print(" {}. label = {}".format(i+1, d.label)) 11 | # A label can represent any number of files (possibly 0). 12 | print(" files = " + str([f.path for f in d.files])) 13 | 14 | printer = rule( 15 | implementation=_impl, 16 | attrs={ 17 | # Do not declare "name": It is added automatically. 18 | "number": attr.int(default = 1), 19 | "deps": attr.label_list(allow_files=True), 20 | }) 21 | -------------------------------------------------------------------------------- /starlark_syntax/testcases/parse/proto_alias.star: -------------------------------------------------------------------------------- 1 | # @generated 2 | # Copyright 2016 The Bazel Authors. All rights reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | def proto_alias(name, version): 17 | native.alias( 18 | name = name, 19 | actual = "//third_party/protobuf/" + version + ":" + name) 20 | -------------------------------------------------------------------------------- /starlark_syntax/testcases/parse/remote.star: -------------------------------------------------------------------------------- 1 | # @generated 2 | def _test_chdir_remote_impl(ctx): 3 | ctx.file("WORKSPACE", """workspace("test_chdir_remote")""") 4 | ctx.file("BUILD.bazel", "") 5 | for f in ["BUILD.bazel", "data_test.go", "data.txt"]: 6 | input = Label("@io_bazel_rules_go//tests/test_chdir:{}".format(f)) 7 | ctx.template("sub/" + f, input) 8 | 9 | _test_chdir_remote = repository_rule( 10 | implementation = _test_chdir_remote_impl, 11 | attrs = {}, 12 | ) 13 | 14 | def test_chdir_remote(): 15 | _test_chdir_remote(name="test_chdir_remote") -------------------------------------------------------------------------------- /starlark_syntax/testcases/parse/serialize.star: -------------------------------------------------------------------------------- 1 | # @generated 2 | # Copyright 2017 The Bazel Authors. All rights reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | """Methods for serializing objects.""" 16 | 17 | 18 | def dict_to_associative_list(dict_value): 19 | """Serializes a dict to an associative list.""" 20 | return ",".join(["%s=%s" % (k, dict_value[k]) for k in dict_value]) 21 | -------------------------------------------------------------------------------- /starlark_syntax/testcases/parse/tests.star: -------------------------------------------------------------------------------- 1 | # @generated 2 | load("//tools/bzl:junit.bzl", "junit_tests") 3 | 4 | def acceptance_tests( 5 | group, 6 | deps = [], 7 | labels = [], 8 | vm_args = ['-Xmx256m'], 9 | **kwargs): 10 | junit_tests( 11 | name = group, 12 | deps = deps + [ 13 | '//gerrit-acceptance-tests:lib', 14 | ], 15 | tags = labels + [ 16 | 'acceptance', 17 | 'slow', 18 | ], 19 | size = "large", 20 | jvm_flags = vm_args, 21 | **kwargs 22 | ) 23 | -------------------------------------------------------------------------------- /starlark_syntax/testcases/parse/vars.star: -------------------------------------------------------------------------------- 1 | # @generated 2 | # Copyright 2017 The Bazel Authors. All rights reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # Global constants for jenkins jobs substitutions 17 | 18 | MAIL_SUBSTITUTIONS = { 19 | "BAZEL_BUILD_RECIPIENT": "bazel-ci@googlegroups.com", 20 | "BAZEL_RELEASE_RECIPIENT": "bazel-discuss+release@googlegroups.com", 21 | "SENDER_EMAIL": "noreply@bazel.io", 22 | } 23 | -------------------------------------------------------------------------------- /starlark_syntax/testcases/parse/version.star: -------------------------------------------------------------------------------- 1 | # @generated 2 | """Version of the blaze plugin.""" 3 | 4 | VERSION = "2017.05.17.1" 5 | -------------------------------------------------------------------------------- /vscode/.gitignore: -------------------------------------------------------------------------------- 1 | out 2 | node_modules 3 | .vscode-test 4 | *.vsix 5 | -------------------------------------------------------------------------------- /vscode/.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | **/*.ts 3 | **/*.map 4 | .gitignore 5 | **/tsconfig.json 6 | **/tsconfig.base.json 7 | client/node_modules/** 8 | !client/node_modules/vscode-jsonrpc/** 9 | !client/node_modules/vscode-languageclient/** 10 | !client/node_modules/vscode-languageserver-protocol/** 11 | !client/node_modules/vscode-languageserver-types/** 12 | !client/node_modules/semver/** 13 | -------------------------------------------------------------------------------- /vscode/client/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lsp-sample-client", 3 | "description": "VSCode part of a language server", 4 | "author": "Microsoft Corporation", 5 | "license": "MIT", 6 | "version": "0.0.1", 7 | "publisher": "vscode", 8 | "repository": { 9 | "type": "git", 10 | "url": "https://github.com/Microsoft/vscode-extension-samples" 11 | }, 12 | "engines": { 13 | "vscode": "^1.43.0" 14 | }, 15 | "dependencies": { 16 | "cd": "^0.3.3", 17 | "starlark": "file:..", 18 | "vscode-languageclient": "^6.1.3" 19 | }, 20 | "devDependencies": { 21 | "@types/vscode": "1.43.0", 22 | "@vscode/test-electron": "^1.3.0" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /vscode/client/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es2019", 5 | "lib": ["ES2019"], 6 | "outDir": "out", 7 | "rootDir": "src", 8 | "sourceMap": true 9 | }, 10 | "include": ["src"], 11 | "exclude": ["node_modules", ".vscode-test"] 12 | } 13 | -------------------------------------------------------------------------------- /vscode/syntaxes/starlark.configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "comments": { 3 | "lineComment": "#" 4 | }, 5 | "brackets": [ 6 | ["{", "}"], 7 | ["[", "]"], 8 | ["(", ")"] 9 | ], 10 | "autoClosingPairs": [ 11 | ["{", "}"], 12 | ["[", "]"], 13 | ["(", ")"], 14 | { 15 | "open": "\"", 16 | "close": "\"", 17 | "notIn": ["string", "comment"] 18 | }, 19 | { 20 | "open": "'", 21 | "close": "'", 22 | "notIn": ["string", "comment"] 23 | } 24 | ], 25 | "surroundingPairs": [ 26 | ["{", "}"], 27 | ["[", "]"], 28 | ["(", ")"], 29 | ["\"", "\""], 30 | ["'", "'"] 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /vscode/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es2019", 5 | "lib": ["ES2019"], 6 | "outDir": "out", 7 | "rootDir": "src", 8 | "sourceMap": true 9 | }, 10 | "include": [ 11 | "src" 12 | ], 13 | "exclude": [ 14 | "node_modules", 15 | ".vscode-test" 16 | ], 17 | "references": [ 18 | { "path": "./client" }, 19 | ] 20 | } 21 | --------------------------------------------------------------------------------