├── .devcontainer └── devcontainer.json ├── .github ├── install_deps.sh └── workflows │ └── main.yml ├── .gitignore ├── .towncrier.template.md ├── .vscode ├── launch.json ├── settings.json └── tasks.json ├── .zed └── settings.json ├── Cargo.lock ├── Cargo.toml ├── LICENSE-APACHE ├── Makefile ├── README.md ├── crates ├── bench │ ├── Cargo.toml │ ├── benches │ │ └── analysis.rs │ └── src │ │ └── main.rs ├── common │ ├── Cargo.toml │ └── src │ │ ├── config.rs │ │ ├── core.rs │ │ ├── diagnostics.rs │ │ ├── file │ │ ├── mod.rs │ │ └── workspace.rs │ │ ├── indexmap.rs │ │ ├── ingot.rs │ │ ├── lib.rs │ │ └── urlext.rs ├── driver │ ├── Cargo.toml │ └── src │ │ ├── db.rs │ │ ├── diagnostics.rs │ │ ├── files.rs │ │ └── lib.rs ├── fe │ ├── Cargo.toml │ └── src │ │ └── main.rs ├── hir-analysis │ ├── Cargo.toml │ ├── build.rs │ ├── src │ │ ├── analysis_pass.rs │ │ ├── diagnostics.rs │ │ ├── lib.rs │ │ ├── name_resolution │ │ │ ├── diagnostics.rs │ │ │ ├── import_resolver.rs │ │ │ ├── mod.rs │ │ │ ├── name_resolver.rs │ │ │ ├── path_resolver.rs │ │ │ ├── traits_in_scope.rs │ │ │ └── visibility_checker.rs │ │ └── ty │ │ │ ├── adt_def.rs │ │ │ ├── binder.rs │ │ │ ├── canonical.rs │ │ │ ├── const_ty.rs │ │ │ ├── def_analysis.rs │ │ │ ├── diagnostics.rs │ │ │ ├── fold.rs │ │ │ ├── func_def.rs │ │ │ ├── method_cmp.rs │ │ │ ├── method_table.rs │ │ │ ├── mod.rs │ │ │ ├── trait_def.rs │ │ │ ├── trait_lower.rs │ │ │ ├── trait_resolution │ │ │ ├── constraint.rs │ │ │ ├── mod.rs │ │ │ └── proof_forest.rs │ │ │ ├── ty_check │ │ │ ├── callable.rs │ │ │ ├── env.rs │ │ │ ├── expr.rs │ │ │ ├── method_selection.rs │ │ │ ├── mod.rs │ │ │ ├── pat.rs │ │ │ ├── path.rs │ │ │ └── stmt.rs │ │ │ ├── ty_def.rs │ │ │ ├── ty_error.rs │ │ │ ├── ty_lower.rs │ │ │ ├── unify.rs │ │ │ └── visitor.rs │ ├── test_files │ │ ├── constraints │ │ │ └── specialized.fe │ │ ├── corelib │ │ │ └── method_resolution.fe │ │ ├── def_analysis │ │ │ └── self_constraints.fe │ │ ├── early_path_resolution │ │ │ ├── alias_res.fe │ │ │ ├── alias_res.snap │ │ │ ├── generic_param.fe │ │ │ ├── generic_param.snap │ │ │ ├── nested_block.fe │ │ │ ├── nested_block.snap │ │ │ ├── scoped_import.fe │ │ │ └── scoped_import.snap │ │ ├── imports │ │ │ ├── cycle_glob.fe │ │ │ ├── cycle_glob.snap │ │ │ ├── glob_chain.fe │ │ │ ├── glob_chain.snap │ │ │ ├── glob_mutual_dep.fe │ │ │ ├── glob_mutual_dep.snap │ │ │ ├── glob_shadow.fe │ │ │ ├── glob_shadow.snap │ │ │ ├── multiple_domains.fe │ │ │ ├── multiple_domains.snap │ │ │ ├── use_depends_glob.fe │ │ │ └── use_depends_glob.snap │ │ └── ty_check │ │ │ ├── array.fe │ │ │ ├── array.snap │ │ │ ├── assign.fe │ │ │ ├── assign.snap │ │ │ ├── aug_assign.fe │ │ │ ├── aug_assign.snap │ │ │ ├── binary.fe │ │ │ ├── binary.snap │ │ │ ├── call.fe │ │ │ ├── call.snap │ │ │ ├── field_access.fe │ │ │ ├── field_access.snap │ │ │ ├── for_.fe │ │ │ ├── for_.snap │ │ │ ├── if_.fe │ │ │ ├── if_.snap │ │ │ ├── index.fe │ │ │ ├── index.snap │ │ │ ├── let_binding.fe │ │ │ ├── let_binding.snap │ │ │ ├── lit_int.fe │ │ │ ├── lit_int.snap │ │ │ ├── lit_str.fe │ │ │ ├── lit_str.snap │ │ │ ├── match_.fe │ │ │ ├── match_.snap │ │ │ ├── method.fe │ │ │ ├── method.snap │ │ │ ├── method │ │ │ ├── generics.fe │ │ │ ├── generics.snap │ │ │ ├── infer_by_constraints.fe │ │ │ ├── infer_by_constraints.snap │ │ │ ├── infer_by_method.fe │ │ │ ├── infer_by_method.snap │ │ │ ├── unique_trait.fe │ │ │ └── unique_trait.snap │ │ │ ├── pat │ │ │ ├── path_tuple.fe │ │ │ ├── path_tuple.snap │ │ │ ├── record.fe │ │ │ ├── record.snap │ │ │ ├── tuple_pat.fe │ │ │ └── tuple_pat.snap │ │ │ ├── path_generic.fe │ │ │ ├── path_generic.snap │ │ │ ├── record_init.fe │ │ │ ├── record_init.snap │ │ │ ├── ret.fe │ │ │ ├── ret.snap │ │ │ ├── shadowing.fe │ │ │ ├── shadowing.snap │ │ │ ├── tuple.fe │ │ │ ├── tuple.snap │ │ │ ├── type_alias.fe │ │ │ ├── type_alias.snap │ │ │ ├── unary.fe │ │ │ ├── unary.snap │ │ │ ├── while_.fe │ │ │ └── while_.snap │ └── tests │ │ ├── constraints.rs │ │ ├── corelib.rs │ │ ├── def_analysis.rs │ │ ├── early_path_resolution.rs │ │ ├── import.rs │ │ ├── repeated_updates.rs │ │ ├── test_db.rs │ │ └── ty_check.rs ├── hir │ ├── Cargo.toml │ └── src │ │ ├── hir_def │ │ ├── attr.rs │ │ ├── body.rs │ │ ├── expr.rs │ │ ├── ident.rs │ │ ├── item.rs │ │ ├── mod.rs │ │ ├── module_tree.rs │ │ ├── params.rs │ │ ├── pat.rs │ │ ├── path.rs │ │ ├── prim_ty.rs │ │ ├── scope_graph.rs │ │ ├── scope_graph_viz.rs │ │ ├── stmt.rs │ │ ├── types.rs │ │ └── use_tree.rs │ │ ├── lib.rs │ │ ├── lower │ │ ├── attr.rs │ │ ├── body.rs │ │ ├── expr.rs │ │ ├── item.rs │ │ ├── mod.rs │ │ ├── params.rs │ │ ├── parse.rs │ │ ├── pat.rs │ │ ├── path.rs │ │ ├── scope_builder.rs │ │ ├── stmt.rs │ │ ├── types.rs │ │ └── use_tree.rs │ │ ├── span │ │ ├── attr.rs │ │ ├── expr.rs │ │ ├── item.rs │ │ ├── mod.rs │ │ ├── params.rs │ │ ├── pat.rs │ │ ├── path.rs │ │ ├── stmt.rs │ │ ├── transition.rs │ │ ├── types.rs │ │ └── use_tree.rs │ │ └── visitor.rs ├── language-server │ ├── Cargo.toml │ ├── Makefile │ ├── README.md │ ├── src │ │ ├── backend │ │ │ ├── db.rs │ │ │ ├── mod.rs │ │ │ └── workspace.rs │ │ ├── cli.rs │ │ ├── fallback.rs │ │ ├── functionality │ │ │ ├── capabilities.rs │ │ │ ├── diagnostics.rs │ │ │ ├── goto.rs │ │ │ ├── handlers.rs │ │ │ ├── hover.rs │ │ │ ├── item_info.rs │ │ │ └── mod.rs │ │ ├── logging.rs │ │ ├── lsp_actor │ │ │ ├── mod.rs │ │ │ ├── registration.rs │ │ │ └── service.rs │ │ ├── lsp_streams.rs │ │ ├── main.rs │ │ ├── server.rs │ │ └── util.rs │ └── test_files │ │ ├── goto.fe │ │ ├── goto.snap │ │ ├── hoverable │ │ ├── fe.toml │ │ └── src │ │ │ ├── lib.fe │ │ │ └── stuff.fe │ │ ├── lol.fe │ │ ├── messy │ │ ├── dangling.fe │ │ └── foo │ │ │ └── bar │ │ │ ├── fe.toml │ │ │ └── src │ │ │ └── main.fe │ │ ├── nested_ingots │ │ ├── fe.toml │ │ ├── ingots │ │ │ └── foo │ │ │ │ ├── fe.toml │ │ │ │ └── src │ │ │ │ └── main.fe │ │ └── src │ │ │ └── lib.fe │ │ ├── single_ingot │ │ ├── fe.toml │ │ └── src │ │ │ ├── foo.fe │ │ │ ├── lib.fe │ │ │ └── lib.snap │ │ ├── smallest_enclosing.fe │ │ └── smallest_enclosing.snap ├── parser │ ├── Cargo.toml │ ├── build.rs │ ├── src │ │ ├── ast │ │ │ ├── attr.rs │ │ │ ├── expr.rs │ │ │ ├── item.rs │ │ │ ├── lit.rs │ │ │ ├── mod.rs │ │ │ ├── param.rs │ │ │ ├── pat.rs │ │ │ ├── path.rs │ │ │ ├── stmt.rs │ │ │ ├── types.rs │ │ │ └── use_tree.rs │ │ ├── lexer.rs │ │ ├── lib.rs │ │ ├── parser │ │ │ ├── attr.rs │ │ │ ├── expr.rs │ │ │ ├── expr_atom.rs │ │ │ ├── func.rs │ │ │ ├── item.rs │ │ │ ├── lit.rs │ │ │ ├── mod.rs │ │ │ ├── param.rs │ │ │ ├── pat.rs │ │ │ ├── path.rs │ │ │ ├── stmt.rs │ │ │ ├── struct_.rs │ │ │ ├── token_stream.rs │ │ │ ├── type_.rs │ │ │ └── use_tree.rs │ │ ├── syntax_kind.rs │ │ └── syntax_node.rs │ ├── test_files │ │ ├── error_recovery │ │ │ ├── exprs │ │ │ │ ├── array.fe │ │ │ │ ├── array.snap │ │ │ │ ├── block.fe │ │ │ │ ├── block.snap │ │ │ │ ├── call.fe │ │ │ │ ├── call.snap │ │ │ │ ├── if_.fe │ │ │ │ ├── if_.snap │ │ │ │ ├── index.fe │ │ │ │ ├── index.snap │ │ │ │ ├── match_.fe │ │ │ │ ├── match_.snap │ │ │ │ ├── method.fe │ │ │ │ └── method.snap │ │ │ ├── items │ │ │ │ ├── const_.fe │ │ │ │ ├── const_.snap │ │ │ │ ├── enum_.fe │ │ │ │ ├── enum_.snap │ │ │ │ ├── extern_.fe │ │ │ │ ├── extern_.snap │ │ │ │ ├── func.fe │ │ │ │ ├── func.snap │ │ │ │ ├── impl_.fe │ │ │ │ ├── impl_.snap │ │ │ │ ├── impl_trait.fe │ │ │ │ ├── impl_trait.snap │ │ │ │ ├── struct_.fe │ │ │ │ ├── struct_.snap │ │ │ │ ├── trait_.fe │ │ │ │ ├── trait_.snap │ │ │ │ ├── type_.fe │ │ │ │ ├── type_.snap │ │ │ │ ├── use_.fe │ │ │ │ └── use_.snap │ │ │ └── stmts │ │ │ │ ├── for_.fe │ │ │ │ ├── for_.snap │ │ │ │ ├── while_.fe │ │ │ │ └── while_.snap │ │ └── syntax_node │ │ │ ├── exprs │ │ │ ├── array.fe │ │ │ ├── array.snap │ │ │ ├── binop.fe │ │ │ ├── binop.snap │ │ │ ├── block.fe │ │ │ ├── block.snap │ │ │ ├── call.fe │ │ │ ├── call.snap │ │ │ ├── expr_path.fe │ │ │ ├── expr_path.snap │ │ │ ├── if.fe │ │ │ ├── if.snap │ │ │ ├── index.fe │ │ │ ├── index.snap │ │ │ ├── match.fe │ │ │ ├── match.snap │ │ │ ├── method.fe │ │ │ ├── method.snap │ │ │ ├── struct_init.fe │ │ │ ├── struct_init.snap │ │ │ ├── tuple.fe │ │ │ └── tuple.snap │ │ │ ├── items │ │ │ ├── const.fe │ │ │ ├── const.snap │ │ │ ├── contract.fe │ │ │ ├── contract.snap │ │ │ ├── enums.fe │ │ │ ├── enums.snap │ │ │ ├── extern.fe │ │ │ ├── extern.snap │ │ │ ├── func.fe │ │ │ ├── func.snap │ │ │ ├── impl.fe │ │ │ ├── impl.snap │ │ │ ├── impl_trait.fe │ │ │ ├── impl_trait.snap │ │ │ ├── mod.fe │ │ │ ├── mod.snap │ │ │ ├── path_generic.fe │ │ │ ├── path_generic.snap │ │ │ ├── trait.fe │ │ │ ├── trait.snap │ │ │ ├── type.fe │ │ │ ├── type.snap │ │ │ ├── use.fe │ │ │ └── use.snap │ │ │ ├── pats │ │ │ ├── lit.fe │ │ │ ├── lit.snap │ │ │ ├── or.fe │ │ │ ├── or.snap │ │ │ ├── path.fe │ │ │ ├── path.snap │ │ │ ├── path_tuple.fe │ │ │ ├── path_tuple.snap │ │ │ ├── record.fe │ │ │ ├── record.snap │ │ │ ├── rest_pattern.fe │ │ │ ├── rest_pattern.snap │ │ │ ├── wilecard.fe │ │ │ └── wilecard.snap │ │ │ ├── stmts │ │ │ ├── assign.fe │ │ │ ├── assign.snap │ │ │ ├── for.fe │ │ │ ├── for.snap │ │ │ ├── let.fe │ │ │ ├── let.snap │ │ │ ├── while.fe │ │ │ └── while.snap │ │ │ └── structs │ │ │ ├── attr.fe │ │ │ ├── attr.snap │ │ │ ├── empty.fe │ │ │ ├── empty.snap │ │ │ ├── generics.fe │ │ │ ├── generics.snap │ │ │ ├── tupel_field.fe │ │ │ └── tupel_field.snap │ └── tests │ │ ├── error_recovery.rs │ │ ├── syntax_node.rs │ │ └── test_runner.rs ├── resolver │ ├── Cargo.toml │ └── src │ │ ├── ingot.rs │ │ ├── ingot │ │ ├── config.rs │ │ └── source_files.rs │ │ └── lib.rs ├── test-utils │ ├── Cargo.toml │ └── src │ │ ├── _macro_support.rs │ │ ├── lib.rs │ │ └── url_utils.rs └── uitest │ ├── Cargo.toml │ ├── build.rs │ ├── fixtures │ ├── name_resolution │ │ ├── conflict.fe │ │ ├── conflict.snap │ │ ├── conflict_field.fe │ │ ├── conflict_field.snap │ │ ├── conflict_field_in_record_variant.fe │ │ ├── conflict_field_in_record_variant.snap │ │ ├── conflict_generics.fe │ │ ├── conflict_generics.snap │ │ ├── conflict_variant.fe │ │ ├── conflict_variant.snap │ │ ├── import_alias_cycle.fe │ │ ├── import_alias_cycle.snap │ │ ├── import_ambiguous.fe │ │ ├── import_ambiguous.snap │ │ ├── import_ambiguous_builtin.fe │ │ ├── import_ambiguous_builtin.snap │ │ ├── import_conflict.fe │ │ ├── import_conflict.snap │ │ ├── import_cycle.fe │ │ ├── import_cycle.snap │ │ ├── import_invisible.fe │ │ ├── import_invisible.snap │ │ ├── import_missing.fe │ │ ├── import_missing.snap │ │ ├── import_unimpotable.fe │ │ ├── import_unimpotable.snap │ │ ├── method_not_found.fe │ │ ├── method_not_found.snap │ │ ├── path_invalid_domain.fe │ │ ├── path_invalid_domain.snap │ │ ├── path_missing_generics.fe │ │ ├── path_missing_generics.snap │ │ ├── path_shadow.fe │ │ ├── path_shadow.snap │ │ ├── record_field_visibility.fe │ │ ├── record_field_visibility.snap │ │ ├── trait_visibility.fe │ │ └── trait_visibility.snap │ ├── parser │ │ ├── array.fe │ │ ├── array.snap │ │ ├── block.fe │ │ ├── block.snap │ │ ├── call.fe │ │ ├── call.snap │ │ ├── const_.fe │ │ ├── const_.snap │ │ ├── enum_.fe │ │ ├── enum_.snap │ │ ├── extern_.fe │ │ ├── extern_.snap │ │ ├── fn_missing_body.fe │ │ ├── fn_missing_body.snap │ │ ├── fn_missing_parameters.fe │ │ ├── fn_missing_parameters.snap │ │ ├── fn_modifiers.fe │ │ ├── fn_modifiers.snap │ │ ├── for_.fe │ │ ├── for_.snap │ │ ├── func.fe │ │ ├── func.snap │ │ ├── if_.fe │ │ ├── if_.snap │ │ ├── impl_.fe │ │ ├── impl_.snap │ │ ├── impl_trait.fe │ │ ├── impl_trait.snap │ │ ├── index.fe │ │ ├── index.snap │ │ ├── match_.fe │ │ ├── match_.snap │ │ ├── method.fe │ │ ├── method.snap │ │ ├── operators.fe │ │ ├── operators.snap │ │ ├── struct_.fe │ │ ├── struct_.snap │ │ ├── struct_field_missing_comma.fe │ │ ├── struct_field_missing_comma.snap │ │ ├── struct_missing_body.fe │ │ ├── struct_missing_body.snap │ │ ├── trait_.fe │ │ ├── trait_.snap │ │ ├── trait_pub_fn.fe │ │ ├── trait_pub_fn.snap │ │ ├── type_.fe │ │ ├── type_.snap │ │ ├── use_.fe │ │ ├── use_.snap │ │ ├── while_.fe │ │ └── while_.snap │ ├── ty │ │ ├── const_ty │ │ │ ├── const_ty_expected.fe │ │ │ ├── const_ty_expected.snap │ │ │ ├── const_ty_mismatch.fe │ │ │ ├── const_ty_mismatch.snap │ │ │ ├── normal_type_expected.fe │ │ │ ├── normal_type_expected.snap │ │ │ ├── trait_const_ty.fe │ │ │ └── trait_const_ty.snap │ │ ├── def │ │ │ ├── alias_arg_mismatch.fe │ │ │ ├── alias_arg_mismatch.snap │ │ │ ├── alias_cycle.fe │ │ │ ├── alias_cycle.snap │ │ │ ├── alias_kind_mismatch.fe │ │ │ ├── alias_kind_mismatch.snap │ │ │ ├── alias_non_mono.fe │ │ │ ├── alias_non_mono.snap │ │ │ ├── const_generics_cycle.fe │ │ │ ├── const_generics_cycle.snap │ │ │ ├── const_generics_invalid_ty.fe │ │ │ ├── const_generics_invalid_ty.snap │ │ │ ├── const_generics_trait_bound.fe │ │ │ ├── const_generics_trait_bound.snap │ │ │ ├── duplicated_arg_name.fe │ │ │ ├── duplicated_arg_name.snap │ │ │ ├── generic_param_conflict.fe │ │ │ ├── generic_param_conflict.snap │ │ │ ├── impl_conflict.fe │ │ │ ├── impl_conflict.snap │ │ │ ├── impl_foreign.fe │ │ │ ├── impl_foreign.snap │ │ │ ├── invalid_self_ty.fe │ │ │ ├── invalid_self_ty.snap │ │ │ ├── kind_bound.fe │ │ │ ├── kind_bound.snap │ │ │ ├── kind_mismatch.fe │ │ │ ├── kind_mismatch.snap │ │ │ ├── not_fully_applied.fe │ │ │ ├── not_fully_applied.snap │ │ │ ├── not_star_kind.fe │ │ │ ├── not_star_kind.snap │ │ │ ├── recursive_type.fe │ │ │ ├── recursive_type.snap │ │ │ ├── trait_arg_mismatch.fe │ │ │ ├── trait_arg_mismatch.snap │ │ │ ├── trait_def.fe │ │ │ ├── trait_def.snap │ │ │ ├── trait_impl_conflict.fe │ │ │ ├── trait_impl_conflict.snap │ │ │ ├── trait_impl_conflict_const.fe │ │ │ ├── trait_impl_conflict_const.snap │ │ │ ├── trait_impl_kind_mismatch.fe │ │ │ ├── trait_impl_kind_mismatch.snap │ │ │ ├── trait_super_trait_cycle.fe │ │ │ └── trait_super_trait_cycle.snap │ │ ├── trait_bound │ │ │ ├── coinductive.fe │ │ │ ├── coinductive.snap │ │ │ ├── const_ty.fe │ │ │ ├── const_ty.snap │ │ │ ├── hkt_bound.fe │ │ │ ├── hkt_bound.snap │ │ │ ├── occurence_check.fe │ │ │ ├── occurence_check.snap │ │ │ ├── sat_by_super.fe │ │ │ ├── sat_by_super.snap │ │ │ ├── super_trait.fe │ │ │ ├── super_trait.snap │ │ │ ├── trait_ref_arg.fe │ │ │ ├── trait_ref_arg.snap │ │ │ ├── type_arg.fe │ │ │ ├── type_arg.snap │ │ │ ├── type_arg_hkt.fe │ │ │ └── type_arg_hkt.snap │ │ └── trait_impl │ │ │ ├── impl_method_arg_mismatch.fe │ │ │ ├── impl_method_arg_mismatch.snap │ │ │ ├── impl_method_label_mismatch.fe │ │ │ ├── impl_method_label_mismatch.snap │ │ │ ├── impl_method_missing_method.fe │ │ │ ├── impl_method_missing_method.snap │ │ │ ├── impl_method_param_mismatch.fe │ │ │ ├── impl_method_param_mismatch.snap │ │ │ ├── impl_method_stricter_bound.fe │ │ │ └── impl_method_stricter_bound.snap │ └── ty_check │ │ ├── arg_count_mismatch.fe │ │ ├── arg_count_mismatch.snap │ │ ├── array.fe │ │ ├── array.snap │ │ ├── assign.fe │ │ ├── assign.snap │ │ ├── aug_assign.fe │ │ ├── aug_assign.snap │ │ ├── binary.fe │ │ ├── binary.snap │ │ ├── call.fe │ │ ├── call.snap │ │ ├── call_field.fe │ │ ├── call_field.snap │ │ ├── field_access.fe │ │ ├── field_access.snap │ │ ├── for_.fe │ │ ├── for_.snap │ │ ├── functor.fe │ │ ├── functor.snap │ │ ├── generic_arg_mismatch.fe │ │ ├── generic_arg_mismatch.snap │ │ ├── if_.fe │ │ ├── if_.snap │ │ ├── index.fe │ │ ├── index.snap │ │ ├── let_binding.fe │ │ ├── let_binding.snap │ │ ├── lit_str.fe │ │ ├── lit_str.snap │ │ ├── loop_control.fe │ │ ├── loop_control.snap │ │ ├── match_.fe │ │ ├── match_.snap │ │ ├── method_bound │ │ ├── arg_bound.fe │ │ ├── arg_bound.snap │ │ ├── generics.fe │ │ ├── generics.snap │ │ ├── ret_bound.fe │ │ ├── ret_bound.snap │ │ ├── specialized.fe │ │ └── specialized.snap │ │ ├── method_selection │ │ ├── ambiguous_inherent_method.fe │ │ ├── ambiguous_inherent_method.snap │ │ ├── ambiguous_trait_def.fe │ │ ├── ambiguous_trait_def.snap │ │ ├── ambiguous_trait_inst.fe │ │ ├── ambiguous_trait_inst.snap │ │ ├── require_explicit_import.fe │ │ └── require_explicit_import.snap │ │ ├── pat │ │ ├── duplicated_binding.fe │ │ ├── duplicated_binding.snap │ │ ├── path.fe │ │ ├── path.snap │ │ ├── path_tuple.fe │ │ ├── path_tuple.snap │ │ ├── record.fe │ │ ├── record.snap │ │ ├── tuple_pat.fe │ │ └── tuple_pat.snap │ │ ├── ret.fe │ │ ├── ret.snap │ │ ├── ret_mismatch.fe │ │ ├── ret_mismatch.snap │ │ ├── tuple.fe │ │ ├── tuple.snap │ │ ├── unary.fe │ │ └── unary.snap │ └── tests │ ├── name_resolution.rs │ ├── parser.rs │ ├── ty.rs │ └── ty_check.rs ├── funding.json ├── library └── core │ ├── fe.toml │ └── src │ ├── default.fe │ ├── lib.fe │ └── option.fe ├── logo ├── README.md ├── fe_png │ ├── fe.png │ ├── fe_favicon.png │ └── fe_source_small_size.png └── fe_svg │ ├── fe_favicon.svg │ ├── fe_source.svg │ └── fe_source_small_size.svg ├── newsfragments ├── 951.bugfix.md ├── 962.feature.md ├── 971.doc.md ├── 980.feature.md ├── README.md └── validate_files.py ├── pyproject.toml ├── release.toml ├── wasm_cleanup.patch └── website ├── CNAME ├── devconnect.html ├── devconnect_ist.png ├── fe-logo-small.svg ├── fe-logo.svg └── index.html /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "fe-lang-v2", 3 | "image": "mcr.microsoft.com/devcontainers/rust:latest", 4 | "features": { 5 | "ghcr.io/devcontainers/features/node:1": {}, 6 | "ghcr.io/devcontainers/features/github-cli:1": {}, 7 | }, 8 | "extensions": [ 9 | "GitHub.vscode-github-actions", 10 | "ms-vsliveshare.vsliveshare", 11 | "vadimcn.vscode-lldb", 12 | "matklad.rust-analyzer", 13 | "serayuzgur.crates", 14 | "tamasfe.even-better-toml", 15 | "usernamehw.errorlens", 16 | "aaron-bond.better-comments", 17 | "yzhang.markdown-all-in-one" 18 | ], 19 | "settings": { 20 | "explorer.compactFolders": false, 21 | "editor.rulers": [ 22 | 80 23 | ], 24 | "workbench.colorTheme": "Default Dark+", 25 | "workbench.preferredDarkColorTheme": "Monokai", 26 | "workbench.colorCustomizations": { 27 | "editorRuler.foreground": "#5f5f62" 28 | }, 29 | "workbench.activityBar.location": "top" 30 | } 31 | } -------------------------------------------------------------------------------- /.github/install_deps.sh: -------------------------------------------------------------------------------- 1 | sudo apt-get update 2 | sudo apt-get install -y libboost-all-dev 3 | sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 50 4 | sudo update-alternatives --set g++ "/usr/bin/g++-10" -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | /target 3 | **/*.rs.bk 4 | tarpaulin-report.html 5 | /output 6 | /docs/tmp_snippets 7 | .vscode 8 | .DS_Store 9 | -------------------------------------------------------------------------------- /.towncrier.template.md: -------------------------------------------------------------------------------- 1 | {% for section, _ in sections.items() %} 2 | {%- if section %}{{section}}{% endif -%} 3 | 4 | {% if sections[section] %} 5 | {% for category, val in definitions.items() if category in sections[section]%} 6 | ### {{ definitions[category]['name'] }} 7 | 8 | {% if definitions[category]['showcontent'] %} 9 | {% for text, values in sections[section][category].items() %} 10 | - {{ values|join(', ') }} {{ text }} 11 | {% endfor %} 12 | 13 | {% else %} 14 | - {{ sections[section][category]['']|join(', ') }} 15 | 16 | {% endif %} 17 | {% if sections[section][category]|length == 0 %} 18 | No significant changes. 19 | 20 | {% else %} 21 | {% endif %} 22 | 23 | {% endfor %} 24 | {% else %} 25 | No significant changes. 26 | 27 | {% endif %} 28 | {% endfor %} -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "args": [ 6 | "--extensionDevelopmentPath=${workspaceFolder}/crates/language-server/editors/vscode", 7 | "${workspaceFolder}/crates/", 8 | "--disable-extensions" 9 | ], 10 | "name": "Launch Fe VSCode Extension", 11 | "outFiles": [ 12 | "${workspaceFolder}/crates/language-server/editors/vscode/out/**/*.js" 13 | ], 14 | "preLaunchTask": "compile-vscode-extension", 15 | "request": "launch", 16 | "type": "extensionHost", 17 | "env": { 18 | "RUST_BACKTRACE": "full", 19 | "NODE_ENV": "development" 20 | } 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.tabSize": 4, 3 | "rust-analyzer.linkedProjects": [ 4 | "./crates/language-server/Cargo.toml" 5 | ], 6 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "compile-vscode-extension", 6 | "type": "shell", 7 | "command": "npm install && npm run compile", 8 | "options": { 9 | "cwd": "${workspaceFolder}/crates/language-server/editors/vscode" 10 | }, 11 | "problemMatcher": [] 12 | } 13 | ] 14 | } -------------------------------------------------------------------------------- /.zed/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "languages": { 3 | "Fe": { 4 | "enable_language_server": false 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Fe 3 | 4 | The Fe compiler is in the late stages of a major compiler rewrite, and the master branch isn't currently usable to compile contracts to evm bytecode. 5 | For the older version of the compiler, see the [legacy branch](https://github.com/ethereum/fe/tree/legacy). 6 | 7 | ## Overview 8 | 9 | Fe is a statically typed language for the Ethereum Virtual Machine (EVM). The syntax and type system is similar to rust's, with the addition of higher-kinded types. We're exploring additional type system, syntax, and semantic changes. 10 | 11 | ## Community 12 | 13 | - Twitter: [@official_fe](https://twitter.com/official_fe) 14 | - Chat: 15 | - We've recently moved to [Zulip](https://fe-lang.zulipchat.com/join/dqvssgylulrmjmp2dx7vcbrq/) 16 | - The [Discord](https://discord.gg/ywpkAXFjZH) server is still live, but our preference is zulip. 17 | 18 | ## License 19 | 20 | Licensed under Apache License, Version 2.0. 21 | -------------------------------------------------------------------------------- /crates/bench/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "fe-bench" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dev-dependencies] 7 | criterion = "0.5" 8 | walkdir = "2.4" 9 | 10 | [dependencies] 11 | hir-analysis.workspace = true 12 | driver.workspace = true 13 | parser.workspace = true 14 | common.workspace = true 15 | camino.workspace = true 16 | url.workspace = true 17 | 18 | [[bench]] 19 | name = "analysis" 20 | harness = false 21 | -------------------------------------------------------------------------------- /crates/bench/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | eprintln!("run `cargo bench`"); 3 | } 4 | -------------------------------------------------------------------------------- /crates/common/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "fe-common" 3 | version = "0.26.0" 4 | edition = "2021" 5 | license = "Apache-2.0" 6 | repository = "https://github.com/ethereum/fe" 7 | description = "Provides HIR definition and lowering for Fe lang." 8 | 9 | [dependencies] 10 | camino.workspace = true 11 | paste.workspace = true 12 | salsa.workspace = true 13 | serde-semver.workspace = true 14 | smol_str.workspace = true 15 | rust-embed = { version = "8.5.0", features = ["debug-embed"] } 16 | toml = "0.8.8" 17 | serde = { version = "1.0", features = ["derive"] } 18 | thiserror = "1.0" 19 | tracing.workspace = true 20 | 21 | parser.workspace = true 22 | url.workspace = true 23 | ordermap = "0.5.5" 24 | rustc-hash.workspace = true 25 | radix_immutable = { version = "0.0.1", git = "https://github.com/micahscopes/radix_immutable.git" } 26 | -------------------------------------------------------------------------------- /crates/common/src/config.rs: -------------------------------------------------------------------------------- 1 | use serde_semver::semver::Version; 2 | use smol_str::SmolStr; 3 | 4 | #[derive(Default, Debug, Clone, serde::Serialize, serde::Deserialize)] 5 | pub struct IngotMetadata { 6 | pub name: Option, 7 | pub version: Option, 8 | } 9 | -------------------------------------------------------------------------------- /crates/driver/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "fe-driver" 3 | version = "0.26.0" 4 | edition = "2021" 5 | license = "Apache-2.0" 6 | repository = "https://github.com/ethereum/fe" 7 | description = "Provides Fe driver" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | 11 | [dependencies] 12 | camino.workspace = true 13 | clap.workspace = true 14 | codespan-reporting.workspace = true 15 | salsa.workspace = true 16 | 17 | common.workspace = true 18 | hir.workspace = true 19 | hir-analysis.workspace = true 20 | resolver.workspace = true 21 | url.workspace = true 22 | smol_str.workspace = true 23 | test-utils.workspace = true 24 | -------------------------------------------------------------------------------- /crates/driver/src/files.rs: -------------------------------------------------------------------------------- 1 | use camino::Utf8PathBuf; 2 | 3 | pub const FE_TOML: &str = "fe.toml"; 4 | 5 | pub fn find_project_root() -> Option { 6 | let mut path = Utf8PathBuf::from_path_buf( 7 | std::env::current_dir().expect("Unable to get current directory"), 8 | ) 9 | .expect("Expected utf8 path"); 10 | 11 | loop { 12 | let fe_toml = path.join(FE_TOML); 13 | if fe_toml.is_file() { 14 | return Some(path); 15 | } 16 | 17 | if !path.pop() { 18 | break; 19 | } 20 | } 21 | 22 | None 23 | } 24 | -------------------------------------------------------------------------------- /crates/fe/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "fe" 3 | version = "0.26.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | clap.workspace = true 8 | driver.workspace = true 9 | -------------------------------------------------------------------------------- /crates/fe/src/main.rs: -------------------------------------------------------------------------------- 1 | use clap::Parser; 2 | use driver::Options; 3 | 4 | fn main() { 5 | let opts = Options::parse(); 6 | driver::run(&opts); 7 | } 8 | -------------------------------------------------------------------------------- /crates/hir-analysis/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "fe-hir-analysis" 3 | version = "0.26.0" 4 | edition = "2021" 5 | license = "Apache-2.0" 6 | repository = "https://github.com/ethereum/fe" 7 | description = "Provides HIR semantic analysis for Fe lang" 8 | 9 | [dependencies] 10 | bitflags = "2.8" 11 | cranelift-entity = "0.115" 12 | derive_more.workspace = true 13 | either = "1.13" 14 | ena = { version = "0.14", features = ["persistent"] } 15 | if_chain = "1.0" 16 | itertools = "0.14" 17 | num-bigint.workspace = true 18 | rustc-hash.workspace = true 19 | salsa.workspace = true 20 | smallvec.workspace = true 21 | smallvec1.workspace = true 22 | thin-vec.workspace = true 23 | tracing.workspace = true 24 | 25 | common.workspace = true 26 | test-utils.workspace = true 27 | hir.workspace = true 28 | url.workspace = true 29 | 30 | [dev-dependencies] 31 | camino.workspace = true 32 | codespan-reporting.workspace = true 33 | dir-test.workspace = true 34 | # TODO move cs diagnostics utils 35 | driver.workspace = true 36 | test-utils.workspace = true 37 | -------------------------------------------------------------------------------- /crates/hir-analysis/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | #[cfg(test)] 3 | println!("cargo:rerun-if-changed=./test_files"); 4 | } 5 | -------------------------------------------------------------------------------- /crates/hir-analysis/src/lib.rs: -------------------------------------------------------------------------------- 1 | use hir::{span::DynLazySpan, HirDb}; 2 | pub mod analysis_pass; 3 | pub mod diagnostics; 4 | 5 | #[salsa::db] 6 | pub trait HirAnalysisDb: HirDb {} 7 | 8 | #[salsa::db] 9 | impl HirAnalysisDb for T where T: HirDb {} 10 | 11 | pub mod name_resolution; 12 | pub mod ty; 13 | 14 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] 15 | pub struct Spanned<'db, T> { 16 | pub data: T, 17 | pub span: DynLazySpan<'db>, 18 | } 19 | 20 | impl<'db, T> Spanned<'db, T> { 21 | pub fn new(data: T, span: DynLazySpan<'db>) -> Self { 22 | Self { data, span } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/constraints/specialized.fe: -------------------------------------------------------------------------------- 1 | trait Trait { 2 | fn f(self) -> i32 3 | } 4 | 5 | struct S { 6 | t: T 7 | } 8 | 9 | struct S2 { 10 | s: S 11 | } 12 | 13 | impl Trait for S { 14 | fn f(self) -> i32 { 15 | self.t 16 | } 17 | } 18 | 19 | impl Trait for S2 20 | where S: Trait { 21 | fn f(self) -> i32 { 22 | self.s.f() 23 | } 24 | } 25 | 26 | fn bar() { 27 | let t: i32 = 1 28 | let s = S { t } 29 | let s2 = S2 { s } 30 | let _ = s2.f() 31 | } 32 | -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/corelib/method_resolution.fe: -------------------------------------------------------------------------------- 1 | use core::{Option, panic} 2 | 3 | fn f() -> usize { 4 | let x = Option::Some(10) 5 | let y = Option::default() 6 | 7 | if y.is_some() { 8 | y.unwrap() 9 | } else { 10 | x.unwrap_or_default() 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/def_analysis/self_constraints.fe: -------------------------------------------------------------------------------- 1 | trait Ring {} 2 | trait CommRing: Ring {} 3 | trait AddCommGroup {} 4 | 5 | trait Module 6 | where 7 | Self: Ring, 8 | M: AddCommGroup 9 | {} 10 | 11 | impl Module for K 12 | where K: CommRing, 13 | M: AddCommGroup 14 | {} -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/early_path_resolution/alias_res.fe: -------------------------------------------------------------------------------- 1 | use foo::Bar as FooBar 2 | 3 | struct Foo { 4 | x: FooBar, 5 | y: foo::Bar 6 | } 7 | 8 | mod foo { 9 | pub struct Bar {} 10 | } 11 | -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/early_path_resolution/alias_res.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/hir-analysis/tests/early_path_resolution.rs 3 | expression: res 4 | input_file: crates/hir-analysis/test_files/early_path_resolution/alias_res.fe 5 | --- 6 | note: 7 | ┌─ alias_res.fe:4:8 8 | │ 9 | 4 │ x: FooBar, 10 | │ ^^^^^^ alias_res::foo::Bar 11 | 12 | note: 13 | ┌─ alias_res.fe:5:13 14 | │ 15 | 5 │ y: foo::Bar 16 | │ ^^^ alias_res::foo::Bar 17 | -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/early_path_resolution/generic_param.fe: -------------------------------------------------------------------------------- 1 | trait InnerTrait { } 2 | 3 | trait TraitWithGenerics 4 | where U: InnerTrait 5 | { 6 | } 7 | 8 | pub struct MyS 9 | where T: TraitWithGenerics, 10 | U: InnerTrait 11 | { 12 | x: T, 13 | y: U, 14 | 15 | } -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/early_path_resolution/nested_block.fe: -------------------------------------------------------------------------------- 1 | fn foo() { 2 | struct Foo {} 3 | 4 | { 5 | struct Foo {} 6 | let f: Foo 7 | } 8 | 9 | let f: Foo 10 | } 11 | 12 | fn bar() { 13 | struct Bar {} 14 | 15 | let x: i32 = { 16 | { 17 | struct Bar {} 18 | 19 | impl Bar { 20 | fn len() -> u256 { 21 | 1 22 | } 23 | } 24 | let bar: Bar = Bar {} 25 | } 26 | 27 | struct Bar {} 28 | let bar: Bar = Bar {} 29 | 1 30 | } 31 | 32 | let bar: Bar = Bar {} 33 | } 34 | -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/early_path_resolution/scoped_import.fe: -------------------------------------------------------------------------------- 1 | pub fn foo() { 2 | { 3 | use mod1::Foo 4 | let v: Foo 5 | } 6 | 7 | let v: Foo 8 | } 9 | 10 | struct Foo {} 11 | 12 | mod mod1 { 13 | pub struct Foo {} 14 | } -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/early_path_resolution/scoped_import.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/hir-analysis/tests/early_path_resolution.rs 3 | expression: res 4 | input_file: crates/hir-analysis/test_files/early_path_resolution/scoped_import.fe 5 | --- 6 | note: 7 | ┌─ scoped_import.fe:4:16 8 | │ 9 | 4 │ let v: Foo 10 | │ ^^^ scoped_import::mod1::Foo 11 | 12 | note: 13 | ┌─ scoped_import.fe:7:12 14 | │ 15 | 7 │ let v: Foo 16 | │ ^^^ scoped_import::Foo 17 | -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/imports/cycle_glob.fe: -------------------------------------------------------------------------------- 1 | pub mod mod1 { 2 | // `Foo`, `Bar`, and `BarImported` are visible in this scope. 3 | pub use super::mod2::Bar as BarImported 4 | pub use super::mod2::* 5 | 6 | pub struct Foo {} 7 | 8 | } 9 | 10 | pub mod mod2 { 11 | // `Foo`, `Bar`, `BarImported`, and `BarPriv` are visible in this scope. 12 | pub use super::mod1::* 13 | 14 | pub struct Bar {} 15 | 16 | struct BarPriv {} 17 | } -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/imports/cycle_glob.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/hir-analysis/tests/import.rs 3 | expression: res 4 | input_file: crates/hir-analysis/test_files/imports/cycle_glob.fe 5 | --- 6 | note: 7 | ┌─ cycle_glob.fe:3:5 8 | │ 9 | 3 │ pub use super::mod2::Bar as BarImported 10 | │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cycle_glob::mod2::Bar 11 | 12 | note: 13 | ┌─ cycle_glob.fe:4:5 14 | │ 15 | 4 │ pub use super::mod2::* 16 | │ ^^^^^^^^^^^^^^^^^^^^^^ cycle_glob::mod1::Foo as Foo | cycle_glob::mod2::Bar as Bar | cycle_glob::mod2::Bar as BarImported 17 | 18 | note: 19 | ┌─ cycle_glob.fe:12:5 20 | │ 21 | 12 │ pub use super::mod1::* 22 | │ ^^^^^^^^^^^^^^^^^^^^^^ cycle_glob::mod1::Foo as Foo | cycle_glob::mod2::Bar as Bar | cycle_glob::mod2::Bar as BarImported 23 | -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/imports/glob_chain.fe: -------------------------------------------------------------------------------- 1 | use foo::* 2 | 3 | mod foo { 4 | pub use MyEnum::* 5 | 6 | pub struct Variant {} 7 | 8 | pub enum MyEnum { 9 | Variant, 10 | Variant2, 11 | } 12 | } -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/imports/glob_chain.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/hir-analysis/tests/import.rs 3 | expression: res 4 | input_file: crates/hir-analysis/test_files/imports/glob_chain.fe 5 | --- 6 | note: 7 | ┌─ glob_chain.fe:1:1 8 | │ 9 | 1 │ use foo::* 10 | │ ^^^^^^^^^^ glob_chain::foo::MyEnum as MyEnum | glob_chain::foo::MyEnum::Variant as Variant | glob_chain::foo::MyEnum::Variant2 as Variant2 | glob_chain::foo::Variant as Variant 11 | 12 | note: 13 | ┌─ glob_chain.fe:4:5 14 | │ 15 | 4 │ pub use MyEnum::* 16 | │ ^^^^^^^^^^^^^^^^^ glob_chain::foo::MyEnum::Variant as Variant | glob_chain::foo::MyEnum::Variant2 as Variant2 17 | -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/imports/glob_mutual_dep.fe: -------------------------------------------------------------------------------- 1 | use foo::* 2 | 3 | pub mod foo { 4 | pub use super::bar::* 5 | 6 | pub struct Foo {} 7 | } 8 | 9 | pub mod bar { 10 | pub use super::foo::* 11 | 12 | pub struct Bar {} 13 | } -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/imports/glob_mutual_dep.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/hir-analysis/tests/import.rs 3 | expression: res 4 | input_file: crates/hir-analysis/test_files/imports/glob_mutual_dep.fe 5 | --- 6 | note: 7 | ┌─ glob_mutual_dep.fe:1:1 8 | │ 9 | 1 │ use foo::* 10 | │ ^^^^^^^^^^ glob_mutual_dep::bar::Bar as Bar | glob_mutual_dep::foo::Foo as Foo 11 | 12 | note: 13 | ┌─ glob_mutual_dep.fe:4:5 14 | │ 15 | 4 │ pub use super::bar::* 16 | │ ^^^^^^^^^^^^^^^^^^^^^ glob_mutual_dep::bar::Bar as Bar | glob_mutual_dep::foo::Foo as Foo 17 | 18 | note: 19 | ┌─ glob_mutual_dep.fe:10:5 20 | │ 21 | 10 │ pub use super::foo::* 22 | │ ^^^^^^^^^^^^^^^^^^^^^ glob_mutual_dep::bar::Bar as Bar | glob_mutual_dep::foo::Foo as Foo 23 | -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/imports/glob_shadow.fe: -------------------------------------------------------------------------------- 1 | use foo::* 2 | 3 | mod foo { 4 | pub use MyEnum::* 5 | 6 | pub const Variant: i32 = 0 7 | 8 | pub enum MyEnum { 9 | Variant, 10 | Variant2, 11 | } 12 | } -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/imports/glob_shadow.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/hir-analysis/tests/import.rs 3 | expression: res 4 | input_file: crates/hir-analysis/test_files/imports/glob_shadow.fe 5 | --- 6 | note: 7 | ┌─ glob_shadow.fe:1:1 8 | │ 9 | 1 │ use foo::* 10 | │ ^^^^^^^^^^ glob_shadow::foo::MyEnum as MyEnum | glob_shadow::foo::MyEnum::Variant2 as Variant2 | glob_shadow::foo::Variant as Variant 11 | 12 | note: 13 | ┌─ glob_shadow.fe:4:5 14 | │ 15 | 4 │ pub use MyEnum::* 16 | │ ^^^^^^^^^^^^^^^^^ glob_shadow::foo::MyEnum::Variant as Variant | glob_shadow::foo::MyEnum::Variant2 as Variant2 17 | -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/imports/multiple_domains.fe: -------------------------------------------------------------------------------- 1 | use foo::S 2 | 3 | mod foo { 4 | pub struct S {} 5 | pub fn S() {} 6 | } 7 | -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/imports/multiple_domains.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/hir-analysis/tests/import.rs 3 | expression: res 4 | input_file: crates/hir-analysis/test_files/imports/multiple_domains.fe 5 | --- 6 | note: 7 | ┌─ multiple_domains.fe:1:1 8 | │ 9 | 1 │ use foo::S 10 | │ ^^^^^^^^^^ multiple_domains::foo::S | multiple_domains::foo::S 11 | -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/imports/use_depends_glob.fe: -------------------------------------------------------------------------------- 1 | use bar::Bar 2 | use foo::* 3 | 4 | mod foo { 5 | pub mod bar { 6 | pub struct Bar {} 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/imports/use_depends_glob.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/hir-analysis/tests/import.rs 3 | expression: res 4 | input_file: crates/hir-analysis/test_files/imports/use_depends_glob.fe 5 | --- 6 | note: 7 | ┌─ use_depends_glob.fe:1:1 8 | │ 9 | 1 │ use bar::Bar 10 | │ ^^^^^^^^^^^^ use_depends_glob::foo::bar::Bar 11 | 12 | note: 13 | ┌─ use_depends_glob.fe:2:1 14 | │ 15 | 2 │ use foo::* 16 | │ ^^^^^^^^^^ use_depends_glob::foo::bar as bar 17 | -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/ty_check/array.fe: -------------------------------------------------------------------------------- 1 | struct Foo {} 2 | 3 | fn foo() { 4 | let i_array: [i32; 2] = [1, 2] 5 | let b_array = [true, false] 6 | 7 | let array_rep = [true; 10] 8 | let array_rep2 = [Foo {}; 5] 9 | let array_rep3: [i32; 5] = [1; 5] 10 | } -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/ty_check/assign.fe: -------------------------------------------------------------------------------- 1 | pub struct Inner { 2 | x: i32, 3 | y: u32, 4 | } 5 | 6 | pub struct Outer { 7 | inner: Inner, 8 | } 9 | 10 | pub enum Option { 11 | Some(T), 12 | None 13 | } 14 | 15 | pub struct Gen { 16 | t: T 17 | } 18 | 19 | impl Outer { 20 | fn set_inner(mut self, x: i32, y: u32) { 21 | self.inner = Inner { x, y } 22 | } 23 | } 24 | 25 | pub fn foo(opt: Option) { 26 | let mut x = 1 27 | let y = 2 28 | 29 | let z = x = 2 30 | 31 | let mut arr = [false; 10] 32 | arr[1] = true 33 | 34 | let mut tuple = (true, false, Inner { x, y }) 35 | tuple.2.x = 1 36 | 37 | let mut outer = Outer { inner: Inner { x, y } } 38 | outer.inner.x = 2 39 | 40 | match opt { 41 | Option::Some(mut x) => { 42 | x = 2 43 | } 44 | Option::None => {} 45 | } 46 | 47 | Gen { t: false }.t = true 48 | } -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/ty_check/aug_assign.fe: -------------------------------------------------------------------------------- 1 | struct Foo { 2 | x: i32, 3 | } 4 | 5 | pub fn foo(mut foo: Foo, mut b: bool) -> i32 { 6 | foo.x *= 2 7 | b |= false 8 | 9 | let mut x = 1 10 | x += 1 11 | x *= 1 12 | x <<= 1 13 | x **= 2 14 | x 15 | 16 | let mut arr = [x, 1, 2] 17 | arr[0] -= arr[1] + 1 18 | arr[0] 19 | } -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/ty_check/binary.fe: -------------------------------------------------------------------------------- 1 | fn foo(x: u32, y: u32) { 2 | x + x 3 | true && false 4 | (x < 1) && (y > 10) || (x == y) 5 | let z = 1 + x 6 | } -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/ty_check/call.fe: -------------------------------------------------------------------------------- 1 | pub fn add(x: i32, y: i32) -> i32 { 2 | x + y 3 | } 4 | 5 | pub fn use_add() -> i32 { 6 | add(x: 1, y: 2) 7 | } 8 | 9 | pub fn make_pair(first: T, second: U) -> (T, U) { 10 | (first, second) 11 | } 12 | 13 | pub fn use_make_pair() -> (i32, bool) { 14 | make_pair(first: 1, second: false) 15 | } 16 | 17 | pub fn make_pair_i32_U(first: i32, second: U) -> (i32, U) { 18 | make_pair(first, second) 19 | } 20 | 21 | pub fn make_pair_explicit(first: i32, second: u32) -> (i32, u32) { 22 | make_pair(first, second) 23 | } 24 | 25 | pub fn hkt_func * -> *>(t: T) { } 26 | 27 | pub struct Foo { 28 | t: T, 29 | u: U, 30 | } 31 | 32 | pub fn use_hkt_func() { 33 | let foo = Foo { t: 1, u: 2 } 34 | hkt_func(t: foo) 35 | } 36 | -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/ty_check/field_access.fe: -------------------------------------------------------------------------------- 1 | fn foo1(x: (i32, u32)) -> i32 { 2 | let x: (i32, u32) 3 | x.0 4 | } 5 | 6 | fn swap(x: (T, U)) -> (U, T) { 7 | let elem0 = x.0 8 | let elem1 = x.1 9 | (elem1, elem0) 10 | } 11 | 12 | struct Bar { 13 | t: T, 14 | u: U, 15 | } 16 | 17 | fn swap2(bar: Bar) -> Bar { 18 | let u = bar.t 19 | let t = bar.u 20 | Bar {t, u} 21 | } -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/ty_check/for_.fe: -------------------------------------------------------------------------------- 1 | struct Foo { 2 | x: i32, 3 | y: i32, 4 | } 5 | 6 | fn foo() -> i256 { 7 | let arr = [1, 2, 3, 4, 5] 8 | let mut res = 0 9 | for i in arr { 10 | res += i 11 | } 12 | 13 | res 14 | } 15 | 16 | fn bar(foo_arr: [Foo; 10]) -> i32 { 17 | let mut res = 0 18 | for Foo {x, y} in foo_arr { 19 | res += x + y 20 | } 21 | 22 | res 23 | } -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/ty_check/if_.fe: -------------------------------------------------------------------------------- 1 | fn lit_if() -> i32 { 2 | if true { 3 | 1 4 | } else { 5 | 2 6 | } 7 | } 8 | 9 | fn string_if() -> String<5> { 10 | if true { 11 | "1" 12 | } else { 13 | "Foo" 14 | } 15 | } 16 | 17 | // If expression should be typed as `()` when else block doesn't exist. 18 | fn no_else() -> () { 19 | let x = if true { 20 | false 21 | } 22 | } 23 | 24 | fn else_if(b1: bool, b2: bool) -> i32 { 25 | if b1 { 26 | 1 27 | } else if b2 { 28 | 2 29 | } else { 30 | 3 31 | } 32 | } 33 | 34 | fn nested(b1: bool, b2: bool) -> String<10> { 35 | if b1 { 36 | "Foo" 37 | } else { 38 | if b2 { 39 | "Bar" 40 | } else { 41 | "Baz" 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/ty_check/index.fe: -------------------------------------------------------------------------------- 1 | pub fn foo() -> u32 { 2 | let x = [10; 3] 3 | x[1] 4 | } 5 | -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/ty_check/index.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/hir-analysis/tests/ty_check.rs 3 | expression: res 4 | input_file: crates/hir-analysis/test_files/ty_check/index.fe 5 | --- 6 | note: 7 | ┌─ index.fe:1:21 8 | │ 9 | 1 │ pub fn foo() -> u32 { 10 | │ ╭─────────────────────^ 11 | 2 │ │ let x = [10; 3] 12 | 3 │ │ x[1] 13 | 4 │ │ } 14 | │ ╰─^ u32 15 | 16 | note: 17 | ┌─ index.fe:2:9 18 | │ 19 | 2 │ let x = [10; 3] 20 | │ ^ [u32; 3] 21 | 22 | note: 23 | ┌─ index.fe:2:13 24 | │ 25 | 2 │ let x = [10; 3] 26 | │ ^^^^^^^ [u32; 3] 27 | 28 | note: 29 | ┌─ index.fe:2:14 30 | │ 31 | 2 │ let x = [10; 3] 32 | │ ^^ u32 33 | 34 | note: 35 | ┌─ index.fe:3:5 36 | │ 37 | 3 │ x[1] 38 | │ ^ [u32; 3] 39 | 40 | note: 41 | ┌─ index.fe:3:5 42 | │ 43 | 3 │ x[1] 44 | │ ^^^^ u32 45 | 46 | note: 47 | ┌─ index.fe:3:7 48 | │ 49 | 3 │ x[1] 50 | │ ^ u256 51 | -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/ty_check/let_binding.fe: -------------------------------------------------------------------------------- 1 | pub fn foo() { 2 | let x: i32 = 1 3 | let s = "Foo" 4 | } 5 | -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/ty_check/let_binding.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/hir-analysis/tests/ty_check.rs 3 | expression: res 4 | input_file: crates/hir-analysis/test_files/ty_check/let_binding.fe 5 | --- 6 | note: 7 | ┌─ let_binding.fe:1:14 8 | │ 9 | 1 │ pub fn foo() { 10 | │ ╭──────────────^ 11 | 2 │ │ let x: i32 = 1 12 | 3 │ │ let s = "Foo" 13 | 4 │ │ } 14 | │ ╰─^ () 15 | 16 | note: 17 | ┌─ let_binding.fe:2:9 18 | │ 19 | 2 │ let x: i32 = 1 20 | │ ^ i32 21 | 22 | note: 23 | ┌─ let_binding.fe:2:18 24 | │ 25 | 2 │ let x: i32 = 1 26 | │ ^ i32 27 | 28 | note: 29 | ┌─ let_binding.fe:3:9 30 | │ 31 | 3 │ let s = "Foo" 32 | │ ^ String<3> 33 | 34 | note: 35 | ┌─ let_binding.fe:3:13 36 | │ 37 | 3 │ let s = "Foo" 38 | │ ^^^^^ String<3> 39 | -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/ty_check/lit_int.fe: -------------------------------------------------------------------------------- 1 | fn lit_i32() -> i32 { 2 | 1 3 | } 4 | 5 | fn lit_i64() -> i64 { 6 | 1 7 | } -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/ty_check/lit_int.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/hir-analysis/tests/ty_check.rs 3 | expression: res 4 | input_file: crates/hir-analysis/test_files/ty_check/lit_int.fe 5 | --- 6 | note: 7 | ┌─ lit_int.fe:1:21 8 | │ 9 | 1 │ fn lit_i32() -> i32 { 10 | │ ╭─────────────────────^ 11 | 2 │ │ 1 12 | 3 │ │ } 13 | │ ╰─^ i32 14 | 15 | note: 16 | ┌─ lit_int.fe:2:5 17 | │ 18 | 2 │ 1 19 | │ ^ i32 20 | 21 | note: 22 | ┌─ lit_int.fe:5:21 23 | │ 24 | 5 │ fn lit_i64() -> i64 { 25 | │ ╭─────────────────────^ 26 | 6 │ │ 1 27 | 7 │ │ } 28 | │ ╰─^ i64 29 | 30 | note: 31 | ┌─ lit_int.fe:6:5 32 | │ 33 | 6 │ 1 34 | │ ^ i64 35 | -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/ty_check/lit_str.fe: -------------------------------------------------------------------------------- 1 | pub fn lit_str1() -> String<1> { 2 | "a" 3 | } 4 | 5 | pub fn lit_str2() -> String<10> { 6 | "abc" 7 | } -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/ty_check/lit_str.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/hir-analysis/tests/ty_check.rs 3 | expression: res 4 | input_file: crates/hir-analysis/test_files/ty_check/lit_str.fe 5 | --- 6 | note: 7 | ┌─ lit_str.fe:1:32 8 | │ 9 | 1 │ pub fn lit_str1() -> String<1> { 10 | │ ╭────────────────────────────────^ 11 | 2 │ │ "a" 12 | 3 │ │ } 13 | │ ╰─^ String<1> 14 | 15 | note: 16 | ┌─ lit_str.fe:2:5 17 | │ 18 | 2 │ "a" 19 | │ ^^^ String<1> 20 | 21 | note: 22 | ┌─ lit_str.fe:5:33 23 | │ 24 | 5 │ pub fn lit_str2() -> String<10> { 25 | │ ╭─────────────────────────────────^ 26 | 6 │ │ "abc" 27 | 7 │ │ } 28 | │ ╰─^ String<10> 29 | 30 | note: 31 | ┌─ lit_str.fe:6:5 32 | │ 33 | 6 │ "abc" 34 | │ ^^^^^ String<10> 35 | -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/ty_check/match_.fe: -------------------------------------------------------------------------------- 1 | pub enum E { 2 | Var { x: i32, u: i32 }, 3 | Var2(E2) 4 | } 5 | 6 | pub enum E2 { 7 | Var(i32) 8 | } 9 | 10 | impl E { 11 | fn extract_num(self) -> i32 { 12 | match self { 13 | Self::Var { x, .. } => x 14 | Self::Var2(E2::Var(x)) => x 15 | } 16 | } 17 | } 18 | 19 | pub fn foo(e: E) -> i32 { 20 | match e { 21 | E::Var { x, .. } => { 22 | x 23 | } 24 | E::Var2(E2::Var(x)) => { 25 | x 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/ty_check/method/generics.fe: -------------------------------------------------------------------------------- 1 | trait Clamp { 2 | fn clamp_into(self) -> Out 3 | } 4 | 5 | trait Add { 6 | fn add(self, _ rhs: Self) -> Self 7 | } 8 | 9 | impl Add for i32 { 10 | fn add(self, _ rhs: Self) -> Self { 11 | self + rhs 12 | } 13 | } 14 | 15 | extern { 16 | fn clamp_i64_i32(_ x: i64) -> i32 17 | } 18 | 19 | impl Clamp for i64 { 20 | fn clamp_into(self) -> i32 { 21 | clamp_i64_i32(self) 22 | } 23 | } 24 | 25 | trait ClampedAdd { 26 | fn clamped_add(self, _ rhs: Rhs) -> Self 27 | } 28 | 29 | impl ClampedAdd for T 30 | where RHS: Clamp, 31 | T: Add 32 | { 33 | fn clamped_add(self, _ rhs: RHS) -> Self { 34 | let rhs = rhs.clamp_into() 35 | self.add(rhs) 36 | } 37 | } 38 | 39 | fn foo(x: i32, y: i64) -> i32 { 40 | x.clamped_add(y) 41 | } -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/ty_check/method/infer_by_constraints.fe: -------------------------------------------------------------------------------- 1 | struct S { 2 | t: T, 3 | } 4 | 5 | impl S { 6 | fn new() -> Self { 7 | todo() 8 | } 9 | } 10 | 11 | trait Foo { 12 | fn foo(self) -> (T, U) 13 | } 14 | 15 | impl Foo for S { 16 | fn foo(self) -> (T, i32) { 17 | (self.t, 1) 18 | } 19 | } 20 | 21 | impl Foo for S { 22 | fn foo(self) -> (u32, u32) { 23 | (1, 1) 24 | } 25 | } 26 | 27 | extern { 28 | fn todo() -> ! 29 | } 30 | 31 | 32 | fn bar() -> (u64, i32) { 33 | let s = S::new() 34 | 35 | let (x, y) = s.foo() 36 | (x, y) 37 | } 38 | -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/ty_check/method/infer_by_method.fe: -------------------------------------------------------------------------------- 1 | enum Option { 2 | Some(T), 3 | None 4 | } 5 | 6 | impl Option { 7 | fn foo(self) {} 8 | } 9 | 10 | impl Option<()> { 11 | fn bool_true() -> Self { 12 | Self::Some(()) 13 | } 14 | fn bool_false() -> Self { 15 | Self::None 16 | } 17 | } 18 | 19 | fn foo() { 20 | let x = Option::None 21 | x.foo() 22 | 23 | let b = Option::bool_true() 24 | } 25 | -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/ty_check/method/unique_trait.fe: -------------------------------------------------------------------------------- 1 | // This test ensures that user doesn't need to import trait if its' unique. 2 | fn foo(x: i32) -> i32 { 3 | x.foo() 4 | } 5 | 6 | mod inner { 7 | trait Foo { 8 | fn foo(self) -> Self 9 | } 10 | 11 | impl Foo for i32 { 12 | fn foo(self) -> i32 { 13 | self 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/ty_check/method/unique_trait.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/hir-analysis/tests/ty_check.rs 3 | expression: res 4 | input_file: crates/hir-analysis/test_files/ty_check/method/unique_trait.fe 5 | --- 6 | note: 7 | ┌─ unique_trait.fe:2:23 8 | │ 9 | 2 │ fn foo(x: i32) -> i32 { 10 | │ ╭───────────────────────^ 11 | 3 │ │ x.foo() 12 | 4 │ │ } 13 | │ ╰─^ i32 14 | 15 | note: 16 | ┌─ unique_trait.fe:3:5 17 | │ 18 | 3 │ x.foo() 19 | │ ^ i32 20 | 21 | note: 22 | ┌─ unique_trait.fe:3:5 23 | │ 24 | 3 │ x.foo() 25 | │ ^^^^^^^ i32 26 | 27 | note: 28 | ┌─ unique_trait.fe:12:29 29 | │ 30 | 12 │ fn foo(self) -> i32 { 31 | │ ╭─────────────────────────────^ 32 | 13 │ │ self 33 | 14 │ │ } 34 | │ ╰─────────^ i32 35 | 36 | note: 37 | ┌─ unique_trait.fe:13:13 38 | │ 39 | 13 │ self 40 | │ ^^^^ i32 41 | -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/ty_check/pat/path_tuple.fe: -------------------------------------------------------------------------------- 1 | pub enum Foo { 2 | Variant(u8, u16, u32, u64) 3 | } 4 | 5 | pub fn foo() { 6 | let Foo::Variant(a, b, c, d) = Foo::Variant(1, 2, 3, 4) 7 | let Foo::Variant(.., a, b) = Foo::Variant(1, 2, 3, 4) 8 | let Foo::Variant(a, .., b, c) = Foo::Variant(1, 2, 3, 4) 9 | let Foo::Variant(a, b, c, ..) = Foo::Variant(1, 2, 3, 4) 10 | } -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/ty_check/pat/record.fe: -------------------------------------------------------------------------------- 1 | pub struct S { 2 | x: i32, 3 | y: T, 4 | } 5 | 6 | pub enum E { 7 | Variant{x: i32, y: T}, 8 | } 9 | 10 | pub enum Unit { 11 | U 12 | } 13 | 14 | pub fn foo() { 15 | let S {x, y}: S 16 | let S {x, y: Unit::U} 17 | let S {y: Unit::U, x} 18 | let E::Variant {x, y}: E 19 | let E::Variant {x, y: Unit::U} 20 | let E::Variant {y: Unit::U, x} 21 | } 22 | -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/ty_check/pat/tuple_pat.fe: -------------------------------------------------------------------------------- 1 | fn foo() { 2 | let (x, y, z): (i8, u16, u32) 3 | let (.., x, y): (u8, u16, u32, u64, u128) 4 | let (x, y, z, ..): (u8, u16, u32, u64, u128) 5 | let (x, .., y, z): (u8, u16, u32, u64, u128) 6 | } -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/ty_check/record_init.fe: -------------------------------------------------------------------------------- 1 | struct Foo { 2 | x: i32, 3 | y: String<10> 4 | } 5 | 6 | fn foo() { 7 | let x = 1 8 | let y = "FOO" 9 | 10 | let f = Foo {x, y} 11 | 12 | let f2 = Foo {x: 1, y: "FOO"} 13 | 14 | let f3 = Foo {y: "FOO", x: 1} 15 | } 16 | 17 | struct Bar { 18 | t: T, 19 | u: U 20 | } 21 | 22 | fn foo2(b: bool, z: Z) { 23 | let t = false 24 | let u = "Bar" 25 | let f = Bar {t, u} 26 | 27 | let f2 = Bar {t: z, u: f} 28 | } 29 | 30 | struct Wrapper 31 | where T: * -> * -> * 32 | { 33 | t: T 34 | } 35 | 36 | fn foo3() { 37 | let bar = Bar { t: 1, u: false } 38 | let x = Wrapper { t: bar } 39 | } 40 | 41 | enum G { 42 | V1 { val: T } 43 | } 44 | 45 | fn generic_path() { 46 | let g = G::V1 { val: 10 } 47 | } 48 | -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/ty_check/ret.fe: -------------------------------------------------------------------------------- 1 | enum Tag { 2 | Tag1, 3 | Tag2, 4 | Tag3 5 | } 6 | 7 | fn foo(b1: bool, b2: bool) -> i32 { 8 | use Tag::* 9 | 10 | let tag = if b1 { 11 | return 0 12 | } else if b2 { 13 | Tag1 14 | } else { 15 | Tag3 16 | } 17 | 18 | let b = match tag { 19 | Tag1 => { 20 | true 21 | } 22 | 23 | Tag2 => { 24 | return 3 25 | } 26 | 27 | Tag3 => { 28 | false 29 | } 30 | } 31 | 32 | if b { 33 | 1 34 | } else { 35 | 2 36 | } 37 | } -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/ty_check/shadowing.fe: -------------------------------------------------------------------------------- 1 | fn foo() -> i32 { 2 | let x = 1 3 | 4 | { 5 | let x = false 6 | if x { 7 | let x = "Hello" 8 | x 9 | } else { 10 | let x = "Hi" 11 | x 12 | } 13 | } 14 | 15 | x 16 | } 17 | 18 | 19 | fn bar() -> i32 { 20 | let bar = 1 21 | bar 22 | } -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/ty_check/tuple.fe: -------------------------------------------------------------------------------- 1 | struct Foo { 2 | x: i32, 3 | y: u32, 4 | } 5 | 6 | fn foo() { 7 | let f = Foo {x: 1, y: 2} 8 | let tup_1 = (f, true, false) 9 | let tup_2 = (("Foo", true), tup_1, "BAZ") 10 | } -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/ty_check/type_alias.fe: -------------------------------------------------------------------------------- 1 | struct Map {} 2 | 3 | mod foo { 4 | pub type Foo = super::Map 5 | } 6 | 7 | fn main() { 8 | let mut set: foo::Foo<()> 9 | } 10 | -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/ty_check/type_alias.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/hir-analysis/tests/ty_check.rs 3 | expression: res 4 | input_file: crates/hir-analysis/test_files/ty_check/type_alias.fe 5 | --- 6 | note: 7 | ┌─ type_alias.fe:7:11 8 | │ 9 | 7 │ fn main() { 10 | │ ╭───────────^ 11 | 8 │ │ let mut set: foo::Foo<()> 12 | 9 │ │ } 13 | │ ╰─^ () 14 | 15 | note: 16 | ┌─ type_alias.fe:8:9 17 | │ 18 | 8 │ let mut set: foo::Foo<()> 19 | │ ^^^^^^^ Map 20 | -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/ty_check/unary.fe: -------------------------------------------------------------------------------- 1 | pub fn foo(x: i32) { 2 | let i1: i32 = +1 3 | let i2 = -i1 4 | let i3 = ~i2 5 | 6 | let b = !false 7 | } -------------------------------------------------------------------------------- /crates/hir-analysis/test_files/ty_check/while_.fe: -------------------------------------------------------------------------------- 1 | pub fn factorial(mut num: u32) -> u32 { 2 | let mut res = 1 3 | while num > 0 { 4 | res *= num 5 | num -= 1 6 | } 7 | 8 | res 9 | } 10 | 11 | pub fn factorial2(mut num: u32) -> u32 { 12 | let mut res = 1 13 | while true { 14 | if num > 1 { 15 | res *= num 16 | num -= 1 17 | } else { 18 | return res 19 | } 20 | } 21 | 22 | return res 23 | } 24 | 25 | 26 | pub fn factorial3(mut num: u32) -> u32 { 27 | let mut res = 1 28 | while true { 29 | num = if num > 1 { 30 | res *= num 31 | num - 1 32 | } else { 33 | break 34 | } 35 | } 36 | 37 | res 38 | } -------------------------------------------------------------------------------- /crates/hir-analysis/tests/constraints.rs: -------------------------------------------------------------------------------- 1 | mod test_db; 2 | use std::path::Path; 3 | 4 | use dir_test::{dir_test, Fixture}; 5 | use test_db::HirAnalysisTestDb; 6 | 7 | #[dir_test( 8 | dir: "$CARGO_MANIFEST_DIR/test_files/constraints", 9 | glob: "*.fe" 10 | )] 11 | fn constraints_standalone(fixture: Fixture<&str>) { 12 | let mut db = HirAnalysisTestDb::default(); 13 | let path = Path::new(fixture.path()); 14 | let file_name = path.file_name().and_then(|file| file.to_str()).unwrap(); 15 | let file = db.new_stand_alone(file_name.into(), fixture.content()); 16 | let (top_mod, _) = db.top_mod(file); 17 | db.assert_no_diags(top_mod); 18 | } 19 | -------------------------------------------------------------------------------- /crates/hir-analysis/tests/def_analysis.rs: -------------------------------------------------------------------------------- 1 | mod test_db; 2 | use std::path::Path; 3 | 4 | use dir_test::{dir_test, Fixture}; 5 | use test_db::HirAnalysisTestDb; 6 | 7 | #[dir_test( 8 | dir: "$CARGO_MANIFEST_DIR/test_files/def_analysis", 9 | glob: "*.fe" 10 | )] 11 | fn def_analysis_standalone(fixture: Fixture<&str>) { 12 | let mut db = HirAnalysisTestDb::default(); 13 | let path = Path::new(fixture.path()); 14 | let file_name = path.file_name().and_then(|file| file.to_str()).unwrap(); 15 | let file = db.new_stand_alone(file_name.into(), fixture.content()); 16 | let (top_mod, _) = db.top_mod(file); 17 | db.assert_no_diags(top_mod); 18 | } 19 | -------------------------------------------------------------------------------- /crates/hir/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "fe-hir" 3 | version = "0.26.0" 4 | edition = "2021" 5 | license = "Apache-2.0" 6 | repository = "https://github.com/ethereum/fe" 7 | description = "Provides HIR definition and lowering for Fe lang" 8 | 9 | [dependencies] 10 | camino.workspace = true 11 | cranelift-entity = "0.115" 12 | derive_more.workspace = true 13 | dot2 = "1.0" 14 | num-bigint.workspace = true 15 | num-traits = "0.2.19" 16 | paste.workspace = true 17 | rustc-hash.workspace = true 18 | salsa.workspace = true 19 | smallvec.workspace = true 20 | thin-vec.workspace = true 21 | 22 | common.workspace = true 23 | parser.workspace = true 24 | url.workspace = true 25 | -------------------------------------------------------------------------------- /crates/hir/src/hir_def/attr.rs: -------------------------------------------------------------------------------- 1 | use super::{IdentId, Partial, StringId}; 2 | 3 | #[salsa::interned] 4 | #[derive(Debug)] 5 | pub struct AttrListId<'db> { 6 | #[return_ref] 7 | pub data: Vec>, 8 | } 9 | 10 | #[derive(Debug, Clone, PartialEq, Eq, Hash, derive_more::From)] 11 | pub enum Attr<'db> { 12 | Normal(NormalAttr<'db>), 13 | DocComment(DocCommentAttr<'db>), 14 | } 15 | 16 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] 17 | pub struct NormalAttr<'db> { 18 | pub name: Partial>, 19 | pub args: Vec>, 20 | } 21 | 22 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] 23 | pub struct DocCommentAttr<'db> { 24 | /// This is the text of the doc comment, excluding the `///` prefix. 25 | pub text: StringId<'db>, 26 | } 27 | 28 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] 29 | pub struct AttrArg<'db> { 30 | pub key: Partial>, 31 | pub value: Partial>, 32 | } 33 | -------------------------------------------------------------------------------- /crates/hir/src/lower/parse.rs: -------------------------------------------------------------------------------- 1 | use common::file::File; 2 | use parser::GreenNode; 3 | use salsa::Accumulator; 4 | 5 | use crate::{hir_def::TopLevelMod, HirDb}; 6 | 7 | #[salsa::tracked] 8 | pub fn parse_file_impl<'db>(db: &'db dyn HirDb, top_mod: TopLevelMod<'db>) -> GreenNode { 9 | let file = top_mod.file(db); 10 | let text = file.text(db); 11 | let (node, parse_errors) = parser::parse_source_file(text); 12 | 13 | for error in parse_errors { 14 | ParserError { file, error }.accumulate(db); 15 | } 16 | node 17 | } 18 | 19 | #[salsa::accumulator] 20 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] 21 | pub struct ParserError { 22 | pub file: File, 23 | pub error: parser::ParseError, 24 | } 25 | -------------------------------------------------------------------------------- /crates/hir/src/span/path.rs: -------------------------------------------------------------------------------- 1 | use parser::ast; 2 | 3 | use super::{define_lazy_span_node, params::LazyGenericArgListSpan, LazySpanAtom}; 4 | 5 | define_lazy_span_node!( 6 | LazyPathSpan, 7 | ast::Path, 8 | @idx { 9 | (segment, LazyPathSegmentSpan), 10 | } 11 | ); 12 | 13 | define_lazy_span_node!( 14 | LazyPathSegmentSpan, 15 | ast::PathSegment, 16 | @token { 17 | (ident, ident), 18 | } 19 | @node { 20 | (generic_args, generic_args, LazyGenericArgListSpan), 21 | } 22 | ); 23 | impl<'db> LazyPathSegmentSpan<'db> { 24 | pub fn into_atom(self) -> LazySpanAtom<'db> { 25 | LazySpanAtom(self.0) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /crates/language-server/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clippy 2 | clippy: 3 | cargo clippy -- -D warnings -A clippy::upper-case-acronyms -A clippy::large-enum-variant 4 | -------------------------------------------------------------------------------- /crates/language-server/src/backend/db.rs: -------------------------------------------------------------------------------- 1 | use common::{define_input_db, InputDb}; 2 | 3 | use hir::{HirDb, LowerHirDb, SpannedHirDb}; 4 | use hir_analysis::{diagnostics::SpannedHirAnalysisDb, HirAnalysisDb}; 5 | // xxx use salsa::{ParallelDatabase, Snapshot}; 6 | 7 | #[salsa::db] 8 | pub trait LanguageServerDb: 9 | salsa::Database + SpannedHirAnalysisDb + HirAnalysisDb + HirDb + LowerHirDb + SpannedHirDb + InputDb 10 | { 11 | } 12 | 13 | #[salsa::db] 14 | impl LanguageServerDb for DB where 15 | DB: Sized 16 | + salsa::Database 17 | + SpannedHirAnalysisDb 18 | + HirAnalysisDb 19 | + HirDb 20 | + LowerHirDb 21 | + SpannedHirDb 22 | + InputDb 23 | { 24 | } 25 | 26 | define_input_db!(LanguageServerDatabase); 27 | -------------------------------------------------------------------------------- /crates/language-server/src/backend/mod.rs: -------------------------------------------------------------------------------- 1 | pub(crate) mod db; 2 | pub(crate) mod workspace; 3 | use async_lsp::ClientSocket; 4 | use db::LanguageServerDatabase; 5 | use workspace::Workspace; 6 | 7 | pub struct Backend { 8 | pub(super) client: ClientSocket, 9 | pub(super) db: LanguageServerDatabase, 10 | pub(super) workspace: Workspace, 11 | #[allow(dead_code)] // TODO: salsa3-compatible parallelism 12 | pub(super) workers: tokio::runtime::Runtime, 13 | } 14 | 15 | impl Backend { 16 | pub fn new(client: ClientSocket) -> Self { 17 | let db = LanguageServerDatabase::default(); 18 | let workspace = Workspace::default(); 19 | 20 | let workers = tokio::runtime::Builder::new_multi_thread() 21 | .worker_threads(1) 22 | .enable_all() 23 | .build() 24 | .unwrap(); 25 | Self { 26 | client, 27 | db, 28 | workspace, 29 | workers, 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /crates/language-server/src/cli.rs: -------------------------------------------------------------------------------- 1 | use clap::{Parser, Subcommand}; 2 | 3 | /// Language Server Protocol (LSP) Server 4 | #[derive(Parser, Debug)] 5 | #[command(name = "fe-analyzer")] 6 | #[command(author = "Your Name ")] 7 | #[command(version = "1.0")] 8 | #[command(about = "LSP server for the Fe language", long_about = None)] 9 | pub struct CliArgs { 10 | /// Choose the communication method 11 | #[command(subcommand)] 12 | pub command: Option, 13 | } 14 | 15 | #[derive(Subcommand, Debug)] 16 | pub enum Commands { 17 | /// Start the LSP server with a TCP listener 18 | Tcp(TcpArgs), 19 | } 20 | 21 | #[derive(Parser, Debug)] 22 | pub struct TcpArgs { 23 | /// Port to listen on (default: 4242) 24 | #[arg(short, long, default_value_t = 4242)] 25 | pub port: u16, 26 | 27 | /// Timeout in seconds to shut down the server if no peers are connected (default: 10) 28 | #[arg(short, long, default_value_t = 10)] 29 | pub timeout: u64, 30 | } 31 | -------------------------------------------------------------------------------- /crates/language-server/src/functionality/mod.rs: -------------------------------------------------------------------------------- 1 | mod capabilities; 2 | pub(super) mod diagnostics; 3 | pub(super) mod goto; 4 | pub(super) mod handlers; 5 | pub(super) mod hover; 6 | pub(super) mod item_info; 7 | -------------------------------------------------------------------------------- /crates/language-server/test_files/goto.fe: -------------------------------------------------------------------------------- 1 | use core 2 | 3 | struct Foo {} 4 | struct Bar {} 5 | 6 | fn main() { 7 | let x: Foo 8 | let y: Bar 9 | let z: baz::Baz 10 | core::todo() 11 | } 12 | 13 | mod baz { 14 | pub struct Baz {} 15 | } 16 | -------------------------------------------------------------------------------- /crates/language-server/test_files/goto.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/language-server/src/functionality/goto.rs 3 | expression: snapshot 4 | input_file: test_files/goto.fe 5 | --- 6 | 0: use core 7 | 1: 8 | 2: struct Foo {} 9 | 3: struct Bar {} 10 | 4: 11 | 5: fn main() { 12 | 6: let x: Foo 13 | 7: let y: Bar 14 | 8: let z: baz::Baz 15 | 9: core::todo() 16 | 10: } 17 | 11: 18 | 12: mod baz { 19 | 13: pub struct Baz {} 20 | 14: } 21 | --- 22 | cursor position (6, 11), path: goto::Foo 23 | cursor position (7, 11), path: goto::Bar 24 | cursor position (8, 11), path: goto::baz 25 | cursor position (8, 16), path: goto::baz::Baz 26 | cursor position (9, 4), path: lib 27 | cursor position (9, 10), path: lib::todo 28 | -------------------------------------------------------------------------------- /crates/language-server/test_files/hoverable/fe.toml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ethereum/fe/416234aae85eee91c302b8440db53380accd1e12/crates/language-server/test_files/hoverable/fe.toml -------------------------------------------------------------------------------- /crates/language-server/test_files/hoverable/src/lib.fe: -------------------------------------------------------------------------------- 1 | use stuff::calculations::{ return_three, return_four } 2 | 3 | /// ## `return_seven` 4 | /// ### a function of numbers 5 | /// #### returns the 3+4=7 6 | pub fn return_seven() { 7 | return_three() + return_four() 8 | } 9 | 10 | fn calculate() { 11 | return_seven() 12 | let x: stuff::calculations::ambiguous 13 | } 14 | 15 | /// Anything that can be calculated ought to implement a 16 | /// `calculate` function 17 | pub trait Calculatable { 18 | fn calculate(self) 19 | } 20 | 21 | /// A struct for holding numbers like `x` and `y` 22 | struct Numbers { 23 | x: i32, 24 | y: i32 25 | } 26 | 27 | impl Calculatable for Numbers { 28 | fn calculate(self) { 29 | self.x + self.y 30 | } 31 | } -------------------------------------------------------------------------------- /crates/language-server/test_files/hoverable/src/stuff.fe: -------------------------------------------------------------------------------- 1 | /// ### Calculation helper functions 2 | pub mod calculations { 3 | /// A function that returns `3` 4 | pub fn return_three() -> u32 { 5 | 3 6 | } 7 | 8 | /// ## A function that returns 4 9 | pub fn return_four() { 10 | 4 11 | } 12 | 13 | /// which one is it? 14 | pub mod ambiguous { 15 | 16 | } 17 | /// is it this one? 18 | pub fn ambiguous() {} 19 | } -------------------------------------------------------------------------------- /crates/language-server/test_files/lol.fe: -------------------------------------------------------------------------------- 1 | struct Foo {} 2 | struct Bar {} 3 | 4 | fn main() { 5 | let x: Foo 6 | let y: Barrr 7 | let z: baz::Bazzz 8 | } 9 | 10 | mod baz { 11 | pub struct Baz {} 12 | } -------------------------------------------------------------------------------- /crates/language-server/test_files/messy/dangling.fe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ethereum/fe/416234aae85eee91c302b8440db53380accd1e12/crates/language-server/test_files/messy/dangling.fe -------------------------------------------------------------------------------- /crates/language-server/test_files/messy/foo/bar/fe.toml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ethereum/fe/416234aae85eee91c302b8440db53380accd1e12/crates/language-server/test_files/messy/foo/bar/fe.toml -------------------------------------------------------------------------------- /crates/language-server/test_files/messy/foo/bar/src/main.fe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ethereum/fe/416234aae85eee91c302b8440db53380accd1e12/crates/language-server/test_files/messy/foo/bar/src/main.fe -------------------------------------------------------------------------------- /crates/language-server/test_files/nested_ingots/fe.toml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ethereum/fe/416234aae85eee91c302b8440db53380accd1e12/crates/language-server/test_files/nested_ingots/fe.toml -------------------------------------------------------------------------------- /crates/language-server/test_files/nested_ingots/ingots/foo/fe.toml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ethereum/fe/416234aae85eee91c302b8440db53380accd1e12/crates/language-server/test_files/nested_ingots/ingots/foo/fe.toml -------------------------------------------------------------------------------- /crates/language-server/test_files/nested_ingots/ingots/foo/src/main.fe: -------------------------------------------------------------------------------- 1 | let foo = 1; -------------------------------------------------------------------------------- /crates/language-server/test_files/nested_ingots/src/lib.fe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ethereum/fe/416234aae85eee91c302b8440db53380accd1e12/crates/language-server/test_files/nested_ingots/src/lib.fe -------------------------------------------------------------------------------- /crates/language-server/test_files/single_ingot/fe.toml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ethereum/fe/416234aae85eee91c302b8440db53380accd1e12/crates/language-server/test_files/single_ingot/fe.toml -------------------------------------------------------------------------------- /crates/language-server/test_files/single_ingot/src/foo.fe: -------------------------------------------------------------------------------- 1 | pub fn why() { 2 | let x = 5 3 | x 4 | } 5 | 6 | pub struct Why { 7 | pub x: i32 8 | } -------------------------------------------------------------------------------- /crates/language-server/test_files/single_ingot/src/lib.fe: -------------------------------------------------------------------------------- 1 | use ingot::foo::Why 2 | 3 | mod who { 4 | use super::Why 5 | pub mod what { 6 | pub fn how() {} 7 | pub mod how { 8 | use ingot::Why 9 | pub struct When { 10 | x: Why 11 | } 12 | } 13 | } 14 | pub struct Bar { 15 | x: Why 16 | } 17 | } 18 | 19 | fn bar() -> () { 20 | let y: Why 21 | let z = who::what::how 22 | let z: who::what::how::When 23 | } -------------------------------------------------------------------------------- /crates/language-server/test_files/smallest_enclosing.fe: -------------------------------------------------------------------------------- 1 | struct Foo {} 2 | struct Bar {} 3 | 4 | fn main() { 5 | let x: Foo 6 | let y: Bar 7 | } -------------------------------------------------------------------------------- /crates/language-server/test_files/smallest_enclosing.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/language-server/src/functionality/goto.rs 3 | expression: result 4 | input_file: test_files/smallest_enclosing.fe 5 | --- 6 | struct Foo {} 7 | struct Bar {} 8 | 9 | fn main() { 10 | let x: Foo 11 | let y: Bar 12 | } 13 | --- 14 | cursor position: 49, path: 15 | cursor position: 52, path: smallest_enclosing::Foo 16 | cursor position: 64, path: 17 | cursor position: 67, path: smallest_enclosing::Bar 18 | -------------------------------------------------------------------------------- /crates/parser/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "fe-parser" 3 | version = "0.26.0" 4 | edition = "2021" 5 | license = "Apache-2.0" 6 | repository = "https://github.com/ethereum/fe" 7 | description = "Parser lib for Fe." 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | 11 | [dependencies] 12 | derive_more.workspace = true 13 | lazy_static = "1.5.0" 14 | logos = "0.15" 15 | rowan = "0.16.1" 16 | rustc-hash.workspace = true 17 | smallvec.workspace = true 18 | unwrap-infallible = "0.1.5" 19 | tracing.workspace = true 20 | 21 | [dev-dependencies] 22 | dir-test.workspace = true 23 | wasm-bindgen-test.workspace = true 24 | test-utils.workspace = true 25 | 26 | [target.'cfg(target_arch = "wasm32")'.dependencies] 27 | wasm-bindgen = "0.2" 28 | -------------------------------------------------------------------------------- /crates/parser/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | #[cfg(test)] 3 | println!("cargo:rerun-if-changed=./test_files"); 4 | } 5 | -------------------------------------------------------------------------------- /crates/parser/src/parser/lit.rs: -------------------------------------------------------------------------------- 1 | use std::convert::Infallible; 2 | 3 | use crate::SyntaxKind; 4 | 5 | use super::{define_scope, token_stream::TokenStream, Parser}; 6 | 7 | define_scope! { pub(crate) LitScope, Lit } 8 | impl super::Parse for LitScope { 9 | type Error = Infallible; 10 | 11 | /// Caller is expected to verify that the next token is a literal. 12 | fn parse(&mut self, parser: &mut Parser) -> Result<(), Self::Error> { 13 | assert!(is_lit(parser.current_kind().unwrap())); 14 | parser.bump(); 15 | Ok(()) 16 | } 17 | } 18 | 19 | pub fn is_lit(kind: SyntaxKind) -> bool { 20 | matches!( 21 | kind, 22 | SyntaxKind::Int | SyntaxKind::TrueKw | SyntaxKind::FalseKw | SyntaxKind::String 23 | ) 24 | } 25 | -------------------------------------------------------------------------------- /crates/parser/src/syntax_node.rs: -------------------------------------------------------------------------------- 1 | use crate::SyntaxKind; 2 | 3 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] 4 | pub enum FeLang {} 5 | 6 | impl rowan::Language for FeLang { 7 | type Kind = SyntaxKind; 8 | 9 | fn kind_from_raw(raw: rowan::SyntaxKind) -> Self::Kind { 10 | unsafe { std::mem::transmute::(raw.0) } 11 | } 12 | 13 | fn kind_to_raw(kind: Self::Kind) -> rowan::SyntaxKind { 14 | kind.into() 15 | } 16 | } 17 | 18 | pub type SyntaxNode = rowan::SyntaxNode; 19 | pub type SyntaxToken = rowan::SyntaxToken; 20 | pub type GreenNode = rowan::GreenNode; 21 | pub type TextRange = rowan::TextRange; 22 | pub type NodeOrToken = rowan::NodeOrToken; 23 | -------------------------------------------------------------------------------- /crates/parser/test_files/error_recovery/exprs/array.fe: -------------------------------------------------------------------------------- 1 | [1, 2 a, 3] 2 | [1, 2,] -------------------------------------------------------------------------------- /crates/parser/test_files/error_recovery/exprs/array.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/parser/tests/error_recovery.rs 3 | expression: node 4 | input_file: crates/parser/test_files/error_recovery/exprs/array.fe 5 | --- 6 | Root@0..19 7 | ArrayExpr@0..11 8 | LBracket@0..1 "[" 9 | LitExpr@1..2 10 | Lit@1..2 11 | Int@1..2 "1" 12 | Comma@2..3 "," 13 | WhiteSpace@3..4 " " 14 | LitExpr@4..5 15 | Lit@4..5 16 | Int@4..5 "2" 17 | WhiteSpace@5..6 " " 18 | Error@6..7 19 | Ident@6..7 "a" 20 | Comma@7..8 "," 21 | WhiteSpace@8..9 " " 22 | LitExpr@9..10 23 | Lit@9..10 24 | Int@9..10 "3" 25 | RBracket@10..11 "]" 26 | Newline@11..12 "\n" 27 | ArrayExpr@12..19 28 | LBracket@12..13 "[" 29 | LitExpr@13..14 30 | Lit@13..14 31 | Int@13..14 "1" 32 | Comma@14..15 "," 33 | WhiteSpace@15..16 " " 34 | LitExpr@16..17 35 | Lit@16..17 36 | Int@16..17 "2" 37 | Comma@17..18 "," 38 | RBracket@18..19 "]" 39 | -------------------------------------------------------------------------------- /crates/parser/test_files/error_recovery/exprs/block.fe: -------------------------------------------------------------------------------- 1 | { 2 | let x: i32 u32 = 10 3 | let y = 10 4 | 5 | } -------------------------------------------------------------------------------- /crates/parser/test_files/error_recovery/exprs/call.fe: -------------------------------------------------------------------------------- 1 | foo(x, y a, z ;) 2 | 3 | foo(x, y) 4 | -------------------------------------------------------------------------------- /crates/parser/test_files/error_recovery/exprs/if_.fe: -------------------------------------------------------------------------------- 1 | if a b { 2 | } 3 | 4 | if c { 5 | 6 | } else d {} 7 | 8 | if e { } else f if g { } else { } 9 | 10 | if h { 11 | 10 12 | else { 13 | 1 14 | } 15 | -------------------------------------------------------------------------------- /crates/parser/test_files/error_recovery/exprs/index.fe: -------------------------------------------------------------------------------- 1 | x[1 a] 2 | x[2 + 3 3 | x[41] -------------------------------------------------------------------------------- /crates/parser/test_files/error_recovery/exprs/match_.fe: -------------------------------------------------------------------------------- 1 | match X => { 2 | Foo() => true 3 | Bar 4 | } 5 | 6 | match X { 7 | Foo(i, j, => true x 8 | Bar => x 9 | } -------------------------------------------------------------------------------- /crates/parser/test_files/error_recovery/exprs/method.fe: -------------------------------------------------------------------------------- 1 | foo::bar.baz(1, 2) 2 | 3 | foo::bar.x(1, 2 E,) 4 | 5 | foo::bar.baz() -------------------------------------------------------------------------------- /crates/parser/test_files/error_recovery/items/const_.fe: -------------------------------------------------------------------------------- 1 | const X = 10 2 | 3 | const X: i32 4 | 5 | const X: ]@ = 1 -------------------------------------------------------------------------------- /crates/parser/test_files/error_recovery/items/enum_.fe: -------------------------------------------------------------------------------- 1 | pub enum MyEnum { 2 | X(u32, T 3 | A 4 | Y(T, u32) B 5 | Z 6 | } 7 | 8 | pub enum MyEnum2 9 | where 10 | T: * -> (* -> * 11 | U: * -> * 12 | { 13 | T(t) 14 | U(U) 15 | } 16 | -------------------------------------------------------------------------------- /crates/parser/test_files/error_recovery/items/extern_.fe: -------------------------------------------------------------------------------- 1 | extern { 2 | pub unsafe fn Foo 3 | 4 | pub fn bar() 5 | 6 | struct Foo { 7 | 8 | pub unsafe fn foo() 9 | } -------------------------------------------------------------------------------- /crates/parser/test_files/error_recovery/items/func.fe: -------------------------------------------------------------------------------- 1 | fn foo>(x: i32, _ mut y: u32, z: u32) -> T, u where T: Trait2 2 | { 3 | 4 | } 5 | 6 | fn foo<<(x: i32) 7 | where T: Trait2 8 | { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /crates/parser/test_files/error_recovery/items/impl_.fe: -------------------------------------------------------------------------------- 1 | impl Foo 6 | { } -------------------------------------------------------------------------------- /crates/parser/test_files/error_recovery/items/impl_trait.fe: -------------------------------------------------------------------------------- 1 | impl A for B i32 { 12 | return 1 13 | } 14 | 15 | x: i32 16 | } -------------------------------------------------------------------------------- /crates/parser/test_files/error_recovery/items/trait_.fe: -------------------------------------------------------------------------------- 1 | trait Foo{} 2 | 3 | trait Bar 6 | 7 | trait Bar where T: Add {} 8 | 9 | trait Bar< 10 | where T: Add 11 | { 12 | 13 | } -------------------------------------------------------------------------------- /crates/parser/test_files/error_recovery/items/type_.fe: -------------------------------------------------------------------------------- 1 | type Result 2 | 3 | type Foo = Result 4 | 5 | -------------------------------------------------------------------------------- /crates/parser/test_files/error_recovery/items/use_.fe: -------------------------------------------------------------------------------- 1 | use foo::bar::*::A 2 | use foo::bar::*::{A, B} 3 | use foo::bar::* as B -------------------------------------------------------------------------------- /crates/parser/test_files/error_recovery/stmts/for_.fe: -------------------------------------------------------------------------------- 1 | { 2 | for i arr { } 3 | 4 | for in arr { } 5 | 6 | for @ in arr {} 7 | 8 | for @ in arr x y {} 9 | } -------------------------------------------------------------------------------- /crates/parser/test_files/error_recovery/stmts/while_.fe: -------------------------------------------------------------------------------- 1 | while @ {} 2 | 3 | while true { 4 | x + 1 5 | }} 6 | 7 | while true {} -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/exprs/array.fe: -------------------------------------------------------------------------------- 1 | [1, {1 + 2}] 2 | [1; 16] -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/exprs/binop.fe: -------------------------------------------------------------------------------- 1 | 1 + 2 * 3 2 | 1 * 2 + 3 3 | 1 < 2 4 | 1 < (2 + 3) 5 | 1 < a(foo) 6 | 1 <= 2 7 | 1 >= 2 8 | true || false && 1 < 2 9 | true || false && (1 < 2) > 3 ^ 2 10 | a ** 2 ** 3 11 | 1 - 2 - 3 12 | 1 << 3 >> 2 13 | a.b.c 14 | a.0.c -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/exprs/block.fe: -------------------------------------------------------------------------------- 1 | { 2 | use super::Foo 3 | struct Foo {} 4 | fn foo() {} 5 | 6 | let x = 1 7 | } -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/exprs/call.fe: -------------------------------------------------------------------------------- 1 | foo() 2 | foo::Bar() 3 | foo(x: 1, z: 3) 4 | foo(x: 1, z: 3) 5 | foo(x: 1, 2, z: 3) 6 | foo(1, y: 2, z: 3) 7 | 8 | foo(val1: 2, val2: "String") 9 | foo<[u32; 1], {3 + 4}>(x: 1, y: 2) 10 | 11 | foo::bar(x) 12 | 13 | // Ths should be parsed as `(foo(1))`, not a tuple expression. 14 | (foo < i32, (u32) > (1)) 15 | -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/exprs/expr_path.fe: -------------------------------------------------------------------------------- 1 | super::Foo 2 | ingot::Bar 3 | Self::Foo -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/exprs/expr_path.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/parser/tests/syntax_node.rs 3 | expression: node 4 | input_file: crates/parser/test_files/syntax_node/exprs/expr_path.fe 5 | --- 6 | Root@0..31 7 | PathExpr@0..10 8 | Path@0..10 9 | PathSegment@0..5 10 | SuperKw@0..5 "super" 11 | Colon2@5..7 "::" 12 | PathSegment@7..10 13 | Ident@7..10 "Foo" 14 | Newline@10..11 "\n" 15 | PathExpr@11..21 16 | Path@11..21 17 | PathSegment@11..16 18 | IngotKw@11..16 "ingot" 19 | Colon2@16..18 "::" 20 | PathSegment@18..21 21 | Ident@18..21 "Bar" 22 | Newline@21..22 "\n" 23 | PathExpr@22..31 24 | Path@22..31 25 | PathSegment@22..26 26 | SelfTypeKw@22..26 "Self" 27 | Colon2@26..28 "::" 28 | PathSegment@28..31 29 | Ident@28..31 "Foo" 30 | -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/exprs/if.fe: -------------------------------------------------------------------------------- 1 | if b {} else {} 2 | 3 | if b {} else { 4 | let x = 1 5 | x 6 | } 7 | 8 | if b { 9 | let x = 1 10 | x 11 | } else {} 12 | 13 | if b { 14 | let x = 1 15 | x 16 | } 17 | 18 | if b { 19 | let x = 1 20 | x 21 | } else { 22 | let y = 1 23 | y 24 | } 25 | 26 | if match x { 27 | Scope::Parent => true 28 | Scope::Child => false 29 | } { 30 | return 31 | } else { 32 | 1 33 | } -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/exprs/index.fe: -------------------------------------------------------------------------------- 1 | x[1 + 2] 2 | x[foo.y(1, 2)] -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/exprs/match.fe: -------------------------------------------------------------------------------- 1 | match e {} 2 | 3 | match e { 4 | Enum::Add(x, y) => x + y 5 | Enum::Sub(x, y) => x - y 6 | } 7 | 8 | match (S {x: 1, y: 2}) { 9 | _ => 1 10 | } 11 | 12 | match e { 13 | Enum::Add(x, y) => x + y 14 | Enum::Sub(x, y) => x - y 15 | } 16 | 17 | match e { 18 | Enum::Add(x, y) => { 19 | x + y 20 | } 21 | Enum::Sub(x, y) => x - y 22 | Enum::Mul(x, y) => { x * y } 23 | } 24 | 25 | match e { Enum::Var(s) => s } 26 | 27 | match { 28 | let x = 1 29 | Enum::Var(x) 30 | } 31 | { 32 | Enum::Var(s) => s 33 | } 34 | 35 | match (S {x: Foo::Bar(x), y: 2}) { 36 | S {x: Boo::Bar(x), y} => true 37 | _ => false 38 | } -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/exprs/method.fe: -------------------------------------------------------------------------------- 1 | x.y() 2 | x.y(1, 2) 3 | 4 | x.y.z(x: 1, y: 2) 5 | x[0].z(x: 1) 6 | 7 | x.y(x: 1, y) 8 | 9 | x 10 | .y() 11 | .z() -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/exprs/struct_init.fe: -------------------------------------------------------------------------------- 1 | Struct {x, y} 2 | Struct {x: 1 + 2} 3 | Empty {} -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/exprs/tuple.fe: -------------------------------------------------------------------------------- 1 | () 2 | ( 3 | 1, 4 | 2, 5 | 3 6 | ) -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/exprs/tuple.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/parser/tests/syntax_node.rs 3 | expression: node 4 | input_file: crates/parser/test_files/syntax_node/exprs/tuple.fe 5 | --- 6 | Root@0..26 7 | TupleExpr@0..2 8 | LParen@0..1 "(" 9 | RParen@1..2 ")" 10 | Newline@2..3 "\n" 11 | TupleExpr@3..26 12 | LParen@3..4 "(" 13 | Newline@4..5 "\n" 14 | WhiteSpace@5..9 " " 15 | LitExpr@9..10 16 | Lit@9..10 17 | Int@9..10 "1" 18 | Comma@10..11 "," 19 | Newline@11..12 "\n" 20 | WhiteSpace@12..16 " " 21 | LitExpr@16..17 22 | Lit@16..17 23 | Int@16..17 "2" 24 | Comma@17..18 "," 25 | Newline@18..19 "\n" 26 | WhiteSpace@19..23 " " 27 | LitExpr@23..24 28 | Lit@23..24 29 | Int@23..24 "3" 30 | Newline@24..25 "\n" 31 | RParen@25..26 ")" 32 | -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/items/const.fe: -------------------------------------------------------------------------------- 1 | pub const FOO: i32 = 1 2 | 3 | const BAR: u256 = { 4 | let b = true 5 | let x = 1 6 | if b { 7 | 1 8 | } else if x == 1 { 9 | 2 10 | } else { 11 | 3 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/items/contract.fe: -------------------------------------------------------------------------------- 1 | contract Empty {} 2 | 3 | pub contract C { 4 | x: i32, 5 | y: u256, 6 | z: MyStruct::Encodable, 7 | } -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/items/enums.fe: -------------------------------------------------------------------------------- 1 | enum Empty {} 2 | 3 | enum Basic { 4 | Unit, 5 | Tup(i32, u32) 6 | } 7 | 8 | enum RecordVariants { 9 | Rectangle { w: u32, h: u32 }, 10 | Circle { r: u32 } 11 | } 12 | 13 | enum Option 14 | where T: Clone 15 | { 16 | /// Some value of type `T` 17 | Some(T), 18 | 19 | /// No value. 20 | None, 21 | } 22 | 23 | enum BoundEnum 24 | where Foo::Bar: Trait 25 | { 26 | AddMul(T), 27 | SubDiv(U), 28 | } 29 | 30 | enum HKTEnum *, U, V, W> 31 | where 32 | U: (* -> *) -> *, 33 | V: * -> * -> (* -> *), 34 | W: * -> * -> * -> * 35 | { 36 | Foo(U) 37 | } 38 | 39 | enum SingleLine { A, B, C { x: i32, y: u8 }, D(i8, i8) } 40 | -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/items/extern.fe: -------------------------------------------------------------------------------- 1 | extern { 2 | 3 | } 4 | 5 | extern { 6 | pub unsafe fn write(loc: *u32, value: u32) -> bool 7 | pub unsafe fn read(loc: *u32, len: usize) -> usize 8 | fn foo() 9 | } -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/items/func.fe: -------------------------------------------------------------------------------- 1 | pub fn foo() { 2 | let x = 1 3 | } 4 | 5 | fn bar(bar: i32, mut baz: u256) -> i32 { 6 | 1 7 | } 8 | 9 | fn baz(from sender: address, mut to recipient: address, _ val: u256, _ _: u256) -> i32 { 10 | 1 11 | } 12 | 13 | fn generics1(t: T, u: Option) -> T 14 | where Result: Trait, 15 | Option: Clone 16 | 17 | { 18 | t 19 | } 20 | 21 | fn decl(t: MyStruct) -> Result {} -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/items/impl.fe: -------------------------------------------------------------------------------- 1 | impl Foo::Bar { 2 | pub fn add(self, rhs: Self) -> Self { 3 | Self { 4 | val: self.val + rhs.val 5 | } 6 | } 7 | } 8 | 9 | impl Foo 10 | where Foo: Clone 11 | { 12 | fn add>(self, rhs: U) 13 | where T: Copy 14 | { 15 | (rhs - self.t) 16 | } 17 | } -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/items/impl_trait.fe: -------------------------------------------------------------------------------- 1 | impl Trait for F { 2 | fn foo() { 3 | return 1 4 | } 5 | } 6 | 7 | impl Trait for F 8 | where T: Clone, 9 | U: Bar 10 | { 11 | fn foo>(t: T) { 12 | do_something(t) 13 | } 14 | } 15 | 16 | impl Trait for F 17 | where U: Bar 18 | { 19 | fn foo>(t: T) { 20 | do_something(t) 21 | } 22 | } -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/items/mod.fe: -------------------------------------------------------------------------------- 1 | pub mod foo { 2 | fn foo_foo(bar: i32, mut baz: u256) -> i32 { 3 | 1 4 | } 5 | 6 | pub struct Foo {} 7 | } 8 | 9 | pub mod bar { 10 | pub struct Bar {} 11 | } -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/items/path_generic.fe: -------------------------------------------------------------------------------- 1 | struct Foo { 2 | t: T 3 | } 4 | 5 | impl Foo { 6 | fn method(self) -> T { 7 | self.t 8 | } 9 | } 10 | 11 | fn foo() { 12 | // Deciding the `Foo` type is not possible without a type argument for `Foo`. 13 | let x = Foo::method() 14 | 15 | // We need this! 16 | let x = Foo::method() 17 | } 18 | -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/items/trait.fe: -------------------------------------------------------------------------------- 1 | trait Marker {} 2 | 3 | pub trait Foo { 4 | fn foo(t: T, u: U) 5 | 6 | fn default_method(lhs: T, rhs: T) -> i32 { 7 | lhs + lhs - (rhs + rhs) 8 | } 9 | } 10 | 11 | pub trait Add 12 | { 13 | fn add(self, rhs: Rhs) -> Self 14 | where RHS: Sub 15 | } 16 | 17 | 18 | pub trait Parse { 19 | fn parse(mut self, mut parser: Parser) 20 | } 21 | 22 | impl Parser 23 | where S: TokenStream + Clone 24 | { 25 | pub fn parse(mut self, mut scope: T, checkpoint: Option) -> (bool, Checkpoint) { 26 | (SyntaxNode::new_root(self.builder.finish()), self.errors) 27 | } 28 | } 29 | 30 | 31 | pub trait SubTrait: Parse + Add 32 | where T: Add 33 | {} -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/items/type.fe: -------------------------------------------------------------------------------- 1 | pub type Int = i32 2 | 3 | type Result = Result -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/items/use.fe: -------------------------------------------------------------------------------- 1 | use Foo::Bar 2 | pub use Foo::Bar 3 | use Foo::* 4 | use Foo::Bar as Bar1 5 | use Foo::Trait as _ 6 | 7 | use Foo::{Foo, Bar} 8 | use Foo::{self, Bar} 9 | use Foo::{self, Bar as Bar1} 10 | use Foo::{self as self_, Bar::{Bar as _, Baz}, *} 11 | 12 | use {Foo::Bar as Bar1, Bar::Bar as Bar2, Baz::Bar as Bar3, Trait::T} 13 | use * 14 | 15 | use super::* 16 | use ingot::Foo 17 | -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/pats/lit.fe: -------------------------------------------------------------------------------- 1 | 0x1 2 | "String" -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/pats/lit.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/parser/tests/syntax_node.rs 3 | expression: node 4 | input_file: crates/parser/test_files/syntax_node/pats/lit.fe 5 | --- 6 | Root@0..12 7 | LitPat@0..3 8 | Lit@0..3 9 | Int@0..3 "0x1" 10 | Newline@3..4 "\n" 11 | LitPat@4..12 12 | Lit@4..12 13 | String@4..12 "\"String\"" 14 | -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/pats/or.fe: -------------------------------------------------------------------------------- 1 | Foo::Bar | FOO::Baz 2 | 3 | Foo::Bar(1 | 2) | Foo::Baz(..) 4 | 5 | Foo::Bar(1 | 2) | Foo::Baz(Foo::Bar(1 | 2) | Bar::Baz("STRING")) -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/pats/path.fe: -------------------------------------------------------------------------------- 1 | MyEnum::Foo -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/pats/path.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/parser/tests/syntax_node.rs 3 | expression: snapshot 4 | --- 5 | Root@0..11 6 | PathPat@0..11 7 | Path@0..11 8 | PathSegment@0..6 9 | Ident@0..6 "MyEnum" 10 | Colon2@6..8 "::" 11 | PathSegment@8..11 12 | Ident@8..11 "Foo" 13 | -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/pats/path_tuple.fe: -------------------------------------------------------------------------------- 1 | Empty() 2 | 3 | MyEnum::Empty() 4 | 5 | MyEnum::Foo(X::Foo, Z::Bar(1, 2), _, ..) 6 | 7 | MyEnum::Foo2( 8 | X::Foo, 9 | Z::Bar(1, 2), 10 | _, 11 | .. 12 | ) 13 | 14 | MyEnum::Bind(x) 15 | 16 | MyEnum::OrTuple(Int::I32 | Int::I64 | Int::Any(10)) -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/pats/record.fe: -------------------------------------------------------------------------------- 1 | Record {} 2 | 3 | foo::Empty { } 4 | 5 | Record { a, b } 6 | Record { a: x, b: y } 7 | Record {x: (1, a), Foo {x, y} } -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/pats/rest_pattern.fe: -------------------------------------------------------------------------------- 1 | .. -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/pats/rest_pattern.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/parser/tests/syntax_node.rs 3 | expression: snapshot 4 | --- 5 | Root@0..2 6 | RestPat@0..2 7 | Dot2@0..2 ".." 8 | -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/pats/wilecard.fe: -------------------------------------------------------------------------------- 1 | _ -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/pats/wilecard.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/parser/tests/syntax_node.rs 3 | expression: snapshot 4 | --- 5 | Root@0..1 6 | WildCardPat@0..1 7 | Underscore@0..1 "_" 8 | -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/stmts/assign.fe: -------------------------------------------------------------------------------- 1 | x = 1 2 | Foo{x, y} = foo -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/stmts/for.fe: -------------------------------------------------------------------------------- 1 | for i in arr { 2 | sum = sum + i 3 | } 4 | 5 | for Struct {x, y} in s_list.iter() { 6 | sum = sum + x + y 7 | } -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/stmts/let.fe: -------------------------------------------------------------------------------- 1 | let x 2 | 3 | let x = 1 4 | let x: i32 = 1 5 | let mut x: i32 = 1 6 | 7 | x += 1 + 1 8 | y <<= 1 >> 2 9 | 10 | let MyEnum::Foo(x, y) = e 11 | 12 | let S {x, y: z} = s 13 | 14 | let x = if b { 15 | y 16 | } else { 17 | z 18 | } 19 | 20 | let x = match b { 21 | MyEnum::A(x) | MyEnum::B(x) => x 22 | _ => 0 23 | } -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/stmts/while.fe: -------------------------------------------------------------------------------- 1 | while i < 10 { 2 | sum = 1 + 2 3 | i = i + 1 4 | } -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/structs/attr.fe: -------------------------------------------------------------------------------- 1 | /// DocComment1 2 | #attr 3 | // normal comment 4 | /// DocComment2 5 | pub struct StructAttr { 6 | /// This is `x` 7 | x: foo::Bar, 8 | /// This is `y` 9 | #cfg(target: evm) 10 | y: i32 11 | } -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/structs/empty.fe: -------------------------------------------------------------------------------- 1 | pub struct EmptyStruct { 2 | } -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/structs/empty.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/parser/tests/syntax_node.rs 3 | expression: node 4 | input_file: crates/parser/test_files/syntax_node/structs/empty.fe 5 | --- 6 | Root@0..26 7 | ItemList@0..26 8 | Item@0..26 9 | Struct@0..26 10 | ItemModifier@0..3 11 | PubKw@0..3 "pub" 12 | WhiteSpace@3..4 " " 13 | StructKw@4..10 "struct" 14 | WhiteSpace@10..11 " " 15 | Ident@11..22 "EmptyStruct" 16 | WhiteSpace@22..23 " " 17 | RecordFieldDefList@23..26 18 | LBrace@23..24 "{" 19 | Newline@24..25 "\n" 20 | RBrace@25..26 "}" 21 | -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/structs/generics.fe: -------------------------------------------------------------------------------- 1 | pub struct StructWithGenericParam 2 | { 3 | x: S, 4 | y: T, 5 | z: U, 6 | } 7 | 8 | pub struct StructWithGenericParam2< 9 | S, 10 | T: foo::Trait, 11 | U 12 | > { 13 | x: *(S, *i32), 14 | y: T, 15 | z: U, 16 | } 17 | 18 | pub struct StructWithGenericParam3< 19 | S: foo::Trait + bar::Trait, 20 | T, 21 | U: bar::Trait 22 | > where 23 | T: Trait1 + Trait2, 24 | Option: Trait1 + Trait2, 25 | Result: Trait2 + Trait3, 26 | { 27 | x: S, 28 | y: T, 29 | z: U, 30 | } 31 | 32 | pub struct MyArr 33 | where 34 | (T, U): Trait + Trait 35 | { 36 | __inner: [T; N], 37 | __inner2: (T, U) 38 | } -------------------------------------------------------------------------------- /crates/parser/test_files/syntax_node/structs/tupel_field.fe: -------------------------------------------------------------------------------- 1 | struct StructWithTupleField { 2 | x: (i32, u32), 3 | y: ( 4 | i32, 5 | foo::Bar, 6 | u32 7 | ), 8 | z: () 9 | } -------------------------------------------------------------------------------- /crates/resolver/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "fe-resolver" 3 | version = "0.26.0" 4 | authors = ["The Fe Developers "] 5 | edition = "2021" 6 | license = "Apache-2.0" 7 | repository = "https://github.com/ethereum/fe" 8 | description = "Resolver lib for Fe." 9 | 10 | [dependencies] 11 | common.workspace = true 12 | 13 | camino.workspace = true 14 | glob.workspace = true 15 | serde-semver.workspace = true 16 | toml = "0.8" 17 | serde = { version = "1", features = ["derive"] } 18 | smol_str.workspace = true 19 | -------------------------------------------------------------------------------- /crates/resolver/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod ingot; 2 | 3 | pub trait Resolver { 4 | type Description; 5 | type Resource; 6 | type Error; 7 | type Diagnostic; 8 | 9 | fn resolve(&mut self, description: &Self::Description) -> Result; 10 | fn take_diagnostics(&mut self) -> Vec; 11 | } 12 | -------------------------------------------------------------------------------- /crates/test-utils/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "fe-test-utils" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | insta = { default-features = false, version = "1.42" } 8 | tracing.workspace = true 9 | tracing-subscriber.workspace = true 10 | tracing-tree.workspace = true 11 | url.workspace = true 12 | camino.workspace = true 13 | -------------------------------------------------------------------------------- /crates/uitest/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "fe-uitest" 3 | version = "0.26.0" 4 | edition = "2021" 5 | license = "Apache-2.0" 6 | repository = "https://github.com/ethereum/fe" 7 | publish = false 8 | 9 | [dependencies] 10 | camino.workspace = true 11 | dir-test.workspace = true 12 | wasm-bindgen-test.workspace = true 13 | url.workspace = true 14 | 15 | driver.workspace = true 16 | test-utils.workspace = true 17 | hir.workspace = true 18 | hir-analysis.workspace = true 19 | common.workspace = true 20 | -------------------------------------------------------------------------------- /crates/uitest/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | #[cfg(test)] 3 | println!("cargo:rerun-if-changed=./fixtures"); 4 | } 5 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/conflict.fe: -------------------------------------------------------------------------------- 1 | // Value domain. 2 | pub fn Foo() {} 3 | pub const Foo: i32 = 1 4 | 5 | // Type domain. 6 | pub enum Foo {} 7 | pub struct Foo {} 8 | mod Foo {} 9 | enum Foo {} 10 | type Foo = i32 -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/conflict.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/name_resolution.rs 3 | expression: diags 4 | input_file: fixtures/name_resolution/conflict.fe 5 | --- 6 | error[3-0100]: conflicting definitions of `Foo` 7 | ┌─ conflict.fe:2:8 8 | │ 9 | 2 │ pub fn Foo() {} 10 | │ ^^^ `Foo` is defined here 11 | 3 │ pub const Foo: i32 = 1 12 | │ --- `Foo` is redefined here 13 | 14 | error[3-0100]: conflicting definitions of `Foo` 15 | ┌─ conflict.fe:6:10 16 | │ 17 | 6 │ pub enum Foo {} 18 | │ ^^^ `Foo` is defined here 19 | 7 │ pub struct Foo {} 20 | │ --- `Foo` is redefined here 21 | 8 │ mod Foo {} 22 | │ --- `Foo` is redefined here 23 | 9 │ enum Foo {} 24 | │ --- `Foo` is redefined here 25 | 10 │ type Foo = i32 26 | │ --- `Foo` is redefined here 27 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/conflict_field.fe: -------------------------------------------------------------------------------- 1 | pub struct MyS { 2 | x: i32, 3 | x: u32, 4 | } -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/conflict_field.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/name_resolution.rs 3 | expression: diags 4 | input_file: fixtures/name_resolution/conflict_field.fe 5 | --- 6 | error[3-0017]: duplicate field name in struct `MyS` 7 | ┌─ conflict_field.fe:2:5 8 | │ 9 | 2 │ x: i32, 10 | │ ^ `x` is defined here 11 | 3 │ x: u32, 12 | │ - `x` is redefined here 13 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/conflict_field_in_record_variant.fe: -------------------------------------------------------------------------------- 1 | enum E { 2 | R { 3 | x: i32, 4 | x: i32, 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/conflict_field_in_record_variant.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/name_resolution.rs 3 | expression: diags 4 | input_file: fixtures/name_resolution/conflict_field_in_record_variant.fe 5 | --- 6 | error[3-0017]: duplicate field name in enum variant `E::R` 7 | ┌─ conflict_field_in_record_variant.fe:3:9 8 | │ 9 | 3 │ x: i32, 10 | │ ^ `x` is defined here 11 | 4 │ x: i32, 12 | │ - `x` is redefined here 13 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/conflict_generics.fe: -------------------------------------------------------------------------------- 1 | pub struct MyS { 2 | x: T, 3 | y: U 4 | } -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/conflict_generics.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/name_resolution.rs 3 | expression: diags 4 | input_file: fixtures/name_resolution/conflict_generics.fe 5 | --- 6 | error[2-0004]: `T` is ambiguous 7 | ┌─ conflict_generics.fe:2:8 8 | │ 9 | 1 │ pub struct MyS { 10 | │ - - candidate 2 11 | │ │ 12 | │ candidate 1 13 | 2 │ x: T, 14 | │ ^ `T` is ambiguous 15 | 16 | error[3-0019]: duplicate generic parameter name in struct `MyS` 17 | ┌─ conflict_generics.fe:1:16 18 | │ 19 | 1 │ pub struct MyS { 20 | │ ^ - `T` is redefined here 21 | │ │ 22 | │ `T` is defined here 23 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/conflict_variant.fe: -------------------------------------------------------------------------------- 1 | pub enum MyE { 2 | Var1, 3 | Var2, 4 | Var1, 5 | } -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/conflict_variant.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/name_resolution.rs 3 | expression: diags 4 | input_file: fixtures/name_resolution/conflict_variant.fe 5 | --- 6 | error[3-0018]: duplicate variant name in enum `MyE` 7 | ┌─ conflict_variant.fe:2:5 8 | │ 9 | 2 │ Var1, 10 | │ ^^^^ `Var1` is defined here 11 | 3 │ Var2, 12 | 4 │ Var1, 13 | │ ---- `Var1` is redefined here 14 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/import_alias_cycle.fe: -------------------------------------------------------------------------------- 1 | pub mod mod1 { 2 | pub use super::mod2::Foo as Bar // Error 3 | } 4 | 5 | pub mod mod2 { 6 | pub use super::mod1::Bar as Foo // Error 7 | } -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/import_alias_cycle.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/name_resolution.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/name_resolution/import_alias_cycle.fe 5 | --- 6 | error[2-0002]: `Foo` is not found 7 | ┌─ import_alias_cycle.fe:2:26 8 | │ 9 | 2 │ pub use super::mod2::Foo as Bar // Error 10 | │ ^^^ `Foo` is not found 11 | 12 | error[2-0002]: `Bar` is not found 13 | ┌─ import_alias_cycle.fe:6:26 14 | │ 15 | 6 │ pub use super::mod1::Bar as Foo // Error 16 | │ ^^^ `Bar` is not found 17 | 18 | 19 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/import_ambiguous.fe: -------------------------------------------------------------------------------- 1 | use foo::* 2 | pub use S 3 | 4 | mod foo { 5 | pub use inner1::* 6 | pub use inner2::* 7 | pub use S 8 | 9 | 10 | pub mod inner1 { 11 | pub struct S {} 12 | } 13 | mod inner2 { 14 | pub struct S {} 15 | } 16 | } -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/import_ambiguous.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/name_resolution.rs 3 | expression: diags 4 | input_file: fixtures/name_resolution/import_ambiguous.fe 5 | --- 6 | error[2-0004]: `S` is ambiguous 7 | ┌─ import_ambiguous.fe:2:9 8 | │ 9 | 2 │ pub use S 10 | │ ^ `S` is ambiguous 11 | · 12 | 11 │ pub struct S {} 13 | │ - candidate 1 14 | · 15 | 14 │ pub struct S {} 16 | │ - candidate 2 17 | 18 | error[2-0004]: `S` is ambiguous 19 | ┌─ import_ambiguous.fe:7:13 20 | │ 21 | 7 │ pub use S 22 | │ ^ `S` is ambiguous 23 | · 24 | 11 │ pub struct S {} 25 | │ - candidate 1 26 | · 27 | 14 │ pub struct S {} 28 | │ - candidate 2 29 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/import_ambiguous_builtin.fe: -------------------------------------------------------------------------------- 1 | use foo::* 2 | 3 | use i32::* 4 | 5 | mod foo { 6 | pub mod i32 {} 7 | } 8 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/import_ambiguous_builtin.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/name_resolution.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/name_resolution/import_ambiguous_builtin.fe 5 | --- 6 | error[2-0004]: `i32` is ambiguous 7 | ┌─ import_ambiguous_builtin.fe:3:5 8 | │ 9 | 3 │ use i32::* 10 | │ ^^^ `i32` is ambiguous 11 | 12 | 13 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/import_conflict.fe: -------------------------------------------------------------------------------- 1 | use foo1::S 2 | use foo2::S 3 | 4 | pub mod foo1 { 5 | pub struct S {} 6 | } 7 | 8 | pub mod foo2 { 9 | pub struct S {} 10 | } -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/import_conflict.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/name_resolution.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/name_resolution/import_conflict.fe 5 | --- 6 | error[2-0001]: `S` conflicts with other definitions 7 | ┌─ import_conflict.fe:1:11 8 | │ 9 | 1 │ use foo1::S 10 | │ ^ `S` is defined here 11 | 2 │ use foo2::S 12 | │ - `S` is redefined here 13 | 14 | 15 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/import_cycle.fe: -------------------------------------------------------------------------------- 1 | use Foo as Bar 2 | use Bar as Baz 3 | use Baz as Foo 4 | 5 | pub mod mod1 { 6 | pub use super::mod2::Foo 7 | 8 | } 9 | 10 | pub mod mod2 { 11 | pub use super::mod1::Foo 12 | } -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/import_cycle.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/name_resolution.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/name_resolution/import_cycle.fe 5 | --- 6 | error[2-0002]: `Foo` is not found 7 | ┌─ import_cycle.fe:1:5 8 | │ 9 | 1 │ use Foo as Bar 10 | │ ^^^ `Foo` is not found 11 | 12 | error[2-0002]: `Bar` is not found 13 | ┌─ import_cycle.fe:2:5 14 | │ 15 | 2 │ use Bar as Baz 16 | │ ^^^ `Bar` is not found 17 | 18 | error[2-0002]: `Baz` is not found 19 | ┌─ import_cycle.fe:3:5 20 | │ 21 | 3 │ use Baz as Foo 22 | │ ^^^ `Baz` is not found 23 | 24 | error[2-0002]: `Foo` is not found 25 | ┌─ import_cycle.fe:6:26 26 | │ 27 | 6 │ pub use super::mod2::Foo 28 | │ ^^^ `Foo` is not found 29 | 30 | error[2-0002]: `Foo` is not found 31 | ┌─ import_cycle.fe:11:26 32 | │ 33 | 11 │ pub use super::mod1::Foo 34 | │ ^^^ `Foo` is not found 35 | 36 | 37 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/import_invisible.fe: -------------------------------------------------------------------------------- 1 | use foo::Bar 2 | mod foo { 3 | struct Bar {} 4 | } 5 | 6 | use foo2::Bar 7 | mod foo2 { 8 | use foo3::Bar 9 | 10 | mod foo3 { 11 | pub struct Bar {} 12 | } 13 | } 14 | 15 | use foo3::foo4::Bar 16 | mod foo3 { 17 | mod foo4 { 18 | pub struct Bar {} 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/import_invisible.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/name_resolution.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/name_resolution/import_invisible.fe 5 | --- 6 | error[2-0003]: `Bar` is not visible 7 | ┌─ import_invisible.fe:1:10 8 | │ 9 | 1 │ use foo::Bar 10 | │ ^^^ `Bar` is not visible 11 | 2 │ mod foo { 12 | 3 │ struct Bar {} 13 | │ --- `Bar` is defined here 14 | 15 | error[2-0003]: `Bar` is not visible 16 | ┌─ import_invisible.fe:6:11 17 | │ 18 | 6 │ use foo2::Bar 19 | │ ^^^ `Bar` is not visible 20 | 7 │ mod foo2 { 21 | 8 │ use foo3::Bar 22 | │ --- `Bar` is defined here 23 | 24 | error[2-0003]: `foo4` is not visible 25 | ┌─ import_invisible.fe:15:11 26 | │ 27 | 15 │ use foo3::foo4::Bar 28 | │ ^^^^ `foo4` is not visible 29 | 16 │ mod foo3 { 30 | 17 │ mod foo4 { 31 | │ ---- `foo4` is defined here 32 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/import_missing.fe: -------------------------------------------------------------------------------- 1 | use foo::Bar 2 | 3 | use foo::{Foo, Bar} 4 | 5 | use foo::bar::Foo 6 | 7 | 8 | mod foo { 9 | pub struct Foo {} 10 | 11 | mod baz { 12 | pub struct Baz {} 13 | } 14 | } -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/import_missing.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/src/lib.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/name_resolution/import_missing.fe 5 | --- 6 | error[2-0002]: `Bar` is not found 7 | ┌─ import_missing.fe:1:10 8 | │ 9 | 1 │ use foo::Bar 10 | │ ^^^ `Bar` is not found 11 | 12 | error[2-0002]: `Bar` is not found 13 | ┌─ import_missing.fe:3:16 14 | │ 15 | 3 │ use foo::{Foo, Bar} 16 | │ ^^^ `Bar` is not found 17 | 18 | error[2-0002]: `bar` is not found 19 | ┌─ import_missing.fe:5:10 20 | │ 21 | 5 │ use foo::bar::Foo 22 | │ ^^^ `bar` is not found 23 | 24 | 25 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/import_unimpotable.fe: -------------------------------------------------------------------------------- 1 | use S::{t, T} 2 | use E::T 3 | 4 | 5 | struct S { 6 | t: T 7 | } 8 | 9 | enum E { 10 | Bar(T) 11 | } -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/import_unimpotable.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/name_resolution.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/name_resolution/import_unimpotable.fe 5 | --- 6 | error[2-0003]: `T` is not visible 7 | ┌─ import_unimpotable.fe:2:8 8 | │ 9 | 2 │ use E::T 10 | │ ^ `T` is not visible 11 | · 12 | 9 │ enum E { 13 | │ - `T` is defined here 14 | 15 | error[2-0005]: `S` can't be used as a middle segment of a path 16 | ┌─ import_unimpotable.fe:1:5 17 | │ 18 | 1 │ use S::{t, T} 19 | │ ^ `S` can't be used as a middle segment of a path 20 | · 21 | 5 │ struct S { 22 | │ - `S` is defined here 23 | 24 | error[2-0005]: `S` can't be used as a middle segment of a path 25 | ┌─ import_unimpotable.fe:1:5 26 | │ 27 | 1 │ use S::{t, T} 28 | │ ^ `S` can't be used as a middle segment of a path 29 | · 30 | 5 │ struct S { 31 | │ - `S` is defined here 32 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/method_not_found.fe: -------------------------------------------------------------------------------- 1 | struct S {} 2 | 3 | fn f() { 4 | S::new() 5 | } 6 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/method_not_found.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/name_resolution.rs 3 | expression: diags 4 | input_file: fixtures/name_resolution/method_not_found.fe 5 | --- 6 | error[8-0029]: no method named `new` found for struct `S` 7 | ┌─ method_not_found.fe:4:8 8 | │ 9 | 4 │ S::new() 10 | │ ^^^ method not found in `S` 11 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/path_invalid_domain.fe: -------------------------------------------------------------------------------- 1 | pub const MyC: i32 = 1 2 | 3 | pub enum MyE { 4 | Var 5 | } 6 | 7 | pub trait MyT {} 8 | pub trait MyTWithGenerics {} 9 | 10 | use MyE::Var 11 | 12 | pub enum MyE2 13 | where T: MyE, 14 | U: MyTWithGenerics 15 | { 16 | Variant(MyC), 17 | Variant2(Var) 18 | } 19 | 20 | fn foo(t: T) {} 21 | 22 | pub struct S { 23 | s: foo::T 24 | } 25 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/path_missing_generics.fe: -------------------------------------------------------------------------------- 1 | pub trait Trait {} 2 | 3 | pub struct MyS 4 | where T: Trait, 5 | U: Trait, 6 | Z: Trait, 7 | { 8 | t: T, 9 | u: U, 10 | z: Z 11 | } 12 | 13 | impl MyS {} -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/path_missing_generics.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/name_resolution.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/name_resolution/path_missing_generics.fe 5 | --- 6 | error[2-0002]: `Z` is not found 7 | ┌─ path_missing_generics.fe:6:11 8 | │ 9 | 6 │ Z: Trait, 10 | │ ^ `Z` is not found 11 | 12 | error[2-0002]: `Z` is not found 13 | ┌─ path_missing_generics.fe:10:8 14 | │ 15 | 10 │ z: Z 16 | │ ^ `Z` is not found 17 | 18 | error[2-0002]: `V` is not found 19 | ┌─ path_missing_generics.fe:13:33 20 | │ 21 | 13 │ impl MyS {} 22 | │ ^ `V` is not found 23 | 24 | 25 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/path_shadow.fe: -------------------------------------------------------------------------------- 1 | pub trait T {} 2 | pub struct MyS 3 | where U: T 4 | { 5 | t: T, 6 | u: U 7 | } -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/path_shadow.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/name_resolution.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/name_resolution/path_shadow.fe 5 | --- 6 | error[2-0007]: expected trait item here 7 | ┌─ path_shadow.fe:3:14 8 | │ 9 | 3 │ where U: T 10 | │ ^ expected trait here, but found type `T` 11 | 12 | 13 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/record_field_visibility.fe: -------------------------------------------------------------------------------- 1 | pub mod my_mod { 2 | pub struct Foo { 3 | pub x: i32, 4 | y: u32 5 | } 6 | 7 | pub enum Bar { 8 | Variant {x: i32, pub y: u32} 9 | } 10 | } 11 | 12 | fn foo() { 13 | use my_mod::{Foo, Bar} 14 | 15 | let f = Foo {x: 1, y: 2} 16 | 17 | let bar = Bar::Variant {x: 1, y: 2} 18 | } -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/record_field_visibility.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/name_resolution.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/name_resolution/record_field_visibility.fe 5 | --- 6 | error[2-0003]: `y` is not visible 7 | ┌─ record_field_visibility.fe:15:24 8 | │ 9 | 4 │ y: u32 10 | │ - `y` is defined here 11 | · 12 | 15 │ let f = Foo {x: 1, y: 2} 13 | │ ^^^^ `y` is not visible 14 | 15 | error[2-0003]: `x` is not visible 16 | ┌─ record_field_visibility.fe:17:29 17 | │ 18 | 8 │ Variant {x: i32, pub y: u32} 19 | │ - `x` is defined here 20 | · 21 | 17 │ let bar = Bar::Variant {x: 1, y: 2} 22 | │ ^^^^ `x` is not visible 23 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/trait_visibility.fe: -------------------------------------------------------------------------------- 1 | fn foo(x: i32) -> i32 { 2 | x.foo() 3 | inner::Foo::foo(x) 4 | } 5 | 6 | mod inner { 7 | trait Foo { 8 | fn foo(self) -> Self 9 | } 10 | 11 | impl Foo for i32 { 12 | fn foo(self) -> i32 { 13 | self 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/name_resolution/trait_visibility.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/name_resolution.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/name_resolution/trait_visibility.fe 5 | --- 6 | error[2-0003]: `Foo` is not visible 7 | ┌─ trait_visibility.fe:3:12 8 | │ 9 | 3 │ inner::Foo::foo(x) 10 | │ ^^^ `Foo` is not visible 11 | · 12 | 7 │ trait Foo { 13 | │ --- `Foo` is defined here 14 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/array.fe: -------------------------------------------------------------------------------- 1 | fn f() { 2 | [1, 2 a, 3] 3 | [1, 2,] 4 | } -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/array.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/parser.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/parser/array.fe 5 | --- 6 | error[1-0001]: unexpected syntax while parsing array definition 7 | ┌─ array.fe:2:7 8 | │ 9 | 2 │ [1, 2 a, 3] 10 | │ ^ unexpected 11 | 12 | 13 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/block.fe: -------------------------------------------------------------------------------- 1 | fn f() { 2 | { 3 | let x: i32 u32 = 10 4 | let y = 10 5 | 6 | } 7 | } -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/block.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/parser.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/parser/block.fe 5 | --- 6 | error[1-0001]: unexpected syntax while parsing block 7 | ┌─ block.fe:3:16 8 | │ 9 | 3 │ let x: i32 u32 = 10 10 | │ ^^^^^^^^ unexpected 11 | 12 | 13 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/call.fe: -------------------------------------------------------------------------------- 1 | fn f() { 2 | foo(x, y a, z ;) 3 | 4 | foo(x, y) 5 | } -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/call.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/parser.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/parser/call.fe 5 | --- 6 | error[1-0001]: unexpected syntax while parsing function call arguments 7 | ┌─ call.fe:2:10 8 | │ 9 | 2 │ foo(x, y a, z ;) 10 | │ ^ unexpected 11 | 12 | error[1-0001]: unexpected syntax while parsing function call arguments 13 | ┌─ call.fe:2:15 14 | │ 15 | 2 │ foo(x, y a, z ;) 16 | │ ^ unexpected 17 | 18 | error[1-0001]: unexpected syntax while parsing generic type argument list 19 | ┌─ call.fe:4:12 20 | │ 21 | 4 │ foo(x, y) 22 | │ ^ unexpected 23 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/const_.fe: -------------------------------------------------------------------------------- 1 | const X = 10 2 | 3 | const X: i32 4 | 5 | const X: ]@ = 1 -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/const_.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/parser.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/parser/const_.fe 5 | --- 6 | error[1-0001]: missing type bound for const definition 7 | ┌─ const_.fe:1:8 8 | │ 9 | 1 │ const X = 10 10 | │ ^ expected `:` 11 | 12 | error[1-0001]: expected `=` 13 | ┌─ const_.fe:3:13 14 | │ 15 | 3 │ const X: i32 16 | │ ^ expected `=` 17 | 18 | error[1-0001]: expected type 19 | ┌─ const_.fe:5:9 20 | │ 21 | 5 │ const X: ]@ = 1 22 | │ ^ expected type 23 | 24 | error[1-0001]: unexpected syntax while parsing type 25 | ┌─ const_.fe:5:10 26 | │ 27 | 5 │ const X: ]@ = 1 28 | │ ^^ unexpected 29 | 30 | 31 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/enum_.fe: -------------------------------------------------------------------------------- 1 | pub enum MyEnum { 2 | X(u32, T 3 | A 4 | Y(T, u32) A 5 | Z 6 | } -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/enum_.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/parser.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/parser/enum_.fe 5 | --- 6 | error[1-0001]: missing closing `)` for tuple type definition 7 | ┌─ enum_.fe:2:13 8 | │ 9 | 2 │ X(u32, T 10 | │ ^ expected `)` or `,` 11 | 12 | error[1-0001]: missing closing `}` for `enum` variant list 13 | ┌─ enum_.fe:2:13 14 | │ 15 | 2 │ X(u32, T 16 | │ ^ expected `}` or `,` 17 | 18 | error[1-0001]: missing closing `}` for `enum` variant list 19 | ┌─ enum_.fe:3:6 20 | │ 21 | 3 │ A 22 | │ ^ expected `}` or `,` 23 | 24 | error[1-0001]: unexpected syntax while parsing `enum` variant list 25 | ┌─ enum_.fe:4:15 26 | │ 27 | 4 │ Y(T, u32) A 28 | │ ^ unexpected 29 | 30 | error[1-0001]: missing closing `}` for `enum` variant list 31 | ┌─ enum_.fe:4:16 32 | │ 33 | 4 │ Y(T, u32) A 34 | │ ^ expected `}` or `,` 35 | 36 | 37 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/extern_.fe: -------------------------------------------------------------------------------- 1 | extern { 2 | pub unsafe fn Foo(x: *usize) 3 | 4 | struct Foo { 5 | 6 | pub unsafe fn foo() 7 | } -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/extern_.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/parser.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/parser/extern_.fe 5 | --- 6 | error[1-0001]: only `fn` is allowed in this block 7 | ┌─ extern_.fe:4:5 8 | │ 9 | 4 │ struct Foo { 10 | │ ^^^^^^ only `fn` is allowed in this block 11 | 12 | error[1-0001]: expected name for field 13 | ┌─ extern_.fe:6:8 14 | │ 15 | 6 │ pub unsafe fn foo() 16 | │ ^ expected identifier 17 | 18 | error[1-0001]: unexpected syntax while parsing function definition 19 | ┌─ extern_.fe:7:1 20 | │ 21 | 7 │ } 22 | │ ^ unexpected 23 | 24 | 25 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/fn_missing_body.fe: -------------------------------------------------------------------------------- 1 | fn foo(x: u8, y: u64) -> u8 2 | 3 | fn bar() asdf 4 | 5 | fn baz(x: u8) -> u8 { 6 | return 10 7 | } 8 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/fn_missing_body.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/parser.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/parser/fn_missing_body.fe 5 | --- 6 | error[1-0001]: expected `{` or `where` 7 | ┌─ fn_missing_body.fe:1:28 8 | │ 9 | 1 │ fn foo(x: u8, y: u64) -> u8 10 | │ ^ expected `{` or `where` 11 | 12 | error[1-0001]: unexpected syntax while parsing function definition 13 | ┌─ fn_missing_body.fe:3:13 14 | │ 15 | 3 │ fn bar() asdf 16 | │ ^^^^ unexpected 17 | 18 | 19 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/fn_missing_parameters.fe: -------------------------------------------------------------------------------- 1 | fn foo -> u8 {} 2 | 3 | fn bar { 4 | } 5 | 6 | fn baz -> u8 {} 7 | 8 | fn f where T: U {} -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/fn_missing_parameters.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/parser.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/parser/fn_missing_parameters.fe 5 | --- 6 | error[1-0001]: expected function parameter list 7 | ┌─ fn_missing_parameters.fe:1:7 8 | │ 9 | 1 │ fn foo -> u8 {} 10 | │ ^ expected `(` 11 | 12 | error[1-0001]: expected function parameter list 13 | ┌─ fn_missing_parameters.fe:3:7 14 | │ 15 | 3 │ fn bar { 16 | │ ^ expected `(` 17 | 18 | error[1-0001]: expected function parameter list 19 | ┌─ fn_missing_parameters.fe:6:7 20 | │ 21 | 6 │ fn baz -> u8 {} 22 | │ ^ expected `(` 23 | 24 | error[1-0001]: expected function parameter list 25 | ┌─ fn_missing_parameters.fe:8:8 26 | │ 27 | 8 │ fn f where T: U {} 28 | │ ^ expected `(` 29 | 30 | 31 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/fn_modifiers.fe: -------------------------------------------------------------------------------- 1 | pub pub struct Foo {} 2 | impl Foo { 3 | pub pub unsafe unsafe fn f() {} 4 | unsafe pub fn g() {} 5 | unsafe unsafe pub unsafe pub pub unsafe fn h() {} 6 | } 7 | 8 | trait T { 9 | fn f(self) 10 | } 11 | 12 | impl T for Foo { 13 | pub unsafe fn f(self) {} 14 | } -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/for_.fe: -------------------------------------------------------------------------------- 1 | fn f() { 2 | for i arr { } 3 | 4 | for in arr { } 5 | 6 | for @ in arr {} 7 | 8 | for @ in arr x y {} 9 | } 10 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/func.fe: -------------------------------------------------------------------------------- 1 | fn foo>(x: i32, _ mut y: u32, z: u32) -> T, u where T: Trait2 2 | { 3 | 4 | } 5 | 6 | fn foo<<(x: i32) 7 | where T: Trait2 8 | { 9 | 10 | } 11 | 12 | fn bar() 13 | where T: 75 {} -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/if_.fe: -------------------------------------------------------------------------------- 1 | fn f() { 2 | 3 | if x y { 4 | } 5 | 6 | if x { 7 | 8 | } else x {} 9 | 10 | if x { } else x if x { } else { } 11 | 12 | if x { 13 | 10 14 | else { 15 | 1 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/if_.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/parser.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/parser/if_.fe 5 | --- 6 | error[1-0001]: unexpected syntax while parsing `if` expression 7 | ┌─ if_.fe:3:6 8 | │ 9 | 3 │ if x y { 10 | │ ^ unexpected 11 | 12 | error[1-0001]: unexpected syntax while parsing `if` expression 13 | ┌─ if_.fe:8:8 14 | │ 15 | 8 │ } else x {} 16 | │ ^ unexpected 17 | 18 | error[1-0001]: unexpected syntax while parsing `if` expression 19 | ┌─ if_.fe:10:15 20 | │ 21 | 10 │ if x { } else x if x { } else { } 22 | │ ^ unexpected 23 | 24 | error[1-0001]: expected expression 25 | ┌─ if_.fe:14:1 26 | │ 27 | 14 │ else { 28 | │ ^ expected expression 29 | 30 | 31 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/impl_.fe: -------------------------------------------------------------------------------- 1 | impl Foo 6 | { } -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/impl_.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/parser.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/parser/impl_.fe 5 | --- 6 | error[1-0001]: expected type 7 | ┌─ impl_.fe:1:12 8 | │ 9 | 1 │ impl Foo for Y { 3 | Foo() => true 4 | Bar 5 | } 6 | 7 | match X { 8 | Foo(i, j, => true x 9 | Bar => x 10 | } 11 | } -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/match_.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/parser.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/parser/match_.fe 5 | --- 6 | error[1-0001]: unexpected syntax while parsing `match` expression 7 | ┌─ match_.fe:2:10 8 | │ 9 | 2 │ match X => { 10 | │ ^^ unexpected 11 | 12 | error[1-0001]: expected `=>` 13 | ┌─ match_.fe:4:7 14 | │ 15 | 4 │ Bar 16 | │ ^ expected `=>` 17 | 18 | error[1-0001]: expected pattern 19 | ┌─ match_.fe:8:13 20 | │ 21 | 8 │ Foo(i, j, => true x 22 | │ ^ expected pattern 23 | 24 | error[1-0001]: unexpected syntax while parsing `match` arm list 25 | ┌─ match_.fe:8:24 26 | │ 27 | 8 │ Foo(i, j, => true x 28 | │ ^ unexpected 29 | 30 | 31 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/method.fe: -------------------------------------------------------------------------------- 1 | fn f() { 2 | foo::bar.baz(1, 2) 3 | 4 | foo::bar.x(1, 2 E,) 5 | 6 | foo::bar.baz() 7 | } -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/method.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/parser.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/parser/method.fe 5 | --- 6 | error[1-0001]: unexpected syntax while parsing generic type argument list 7 | ┌─ method.fe:2:23 8 | │ 9 | 2 │ foo::bar.baz(1, 2) 10 | │ ^ unexpected 11 | 12 | error[1-0001]: unexpected syntax while parsing function call arguments 13 | ┌─ method.fe:4:17 14 | │ 15 | 4 │ foo::bar.x(1, 2 E,) 16 | │ ^ unexpected 17 | 18 | 19 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/operators.fe: -------------------------------------------------------------------------------- 1 | fn f() { 2 | x += 1 3 | x + = 1 4 | x -= 1 5 | x - = 1 6 | x * = 1 7 | x << 1 8 | x < < 1 9 | x <= 1 10 | x < = 1 11 | } -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/struct_.fe: -------------------------------------------------------------------------------- 1 | pub struct i32 { 12 | return 1 13 | } 14 | 15 | x: i32 16 | } -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/struct_field_missing_comma.fe: -------------------------------------------------------------------------------- 1 | struct S { 2 | x: u8 3 | y: i8 4 | ,z: i8, 5 | } 6 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/struct_field_missing_comma.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/parser.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/parser/struct_field_missing_comma.fe 5 | --- 6 | error[1-0001]: missing closing `}` for record field list 7 | ┌─ struct_field_missing_comma.fe:2:10 8 | │ 9 | 2 │ x: u8 10 | │ ^ expected `}` or `,` 11 | 12 | 13 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/struct_missing_body.fe: -------------------------------------------------------------------------------- 1 | 2 | struct S 3 | 4 | struct T 5 | 6 | struct Foo {} 7 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/struct_missing_body.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/parser.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/parser/struct_missing_body.fe 5 | --- 6 | error[1-0001]: expected `{`, `where` or `<` 7 | ┌─ struct_missing_body.fe:2:9 8 | │ 9 | 2 │ struct S 10 | │ ^ expected `{`, `where` or `<` 11 | 12 | error[1-0001]: expected `{` or `where` 13 | ┌─ struct_missing_body.fe:4:12 14 | │ 15 | 4 │ struct T 16 | │ ^ expected `{` or `where` 17 | 18 | 19 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/trait_.fe: -------------------------------------------------------------------------------- 1 | trait Foo{} 2 | 3 | trait Bar 6 | 7 | trait Bar where T: Add {} 8 | 9 | trait Bar< 10 | where T: Add 11 | { 12 | 13 | } -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/trait_.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/parser.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/parser/trait_.fe 5 | --- 6 | error[1-0001]: expected identifier, `const` or `>` 7 | ┌─ trait_.fe:3:13 8 | │ 9 | 3 │ trait Bar` 11 | 12 | error[1-0001]: expected `{`, `where` or `:` 13 | ┌─ trait_.fe:5:15 14 | │ 15 | 5 │ trait Bar 16 | │ ^ expected `{`, `where` or `:` 17 | 18 | error[1-0001]: unexpected syntax while parsing generic parameter list 19 | ┌─ trait_.fe:9:11 20 | │ 21 | 9 │ trait Bar< 22 | │ ^ unexpected 23 | 24 | 25 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/trait_pub_fn.fe: -------------------------------------------------------------------------------- 1 | trait Fooable { 2 | pub fn foo(mut self) 3 | pub unsafe fn bar(self) 4 | fn x(self) 5 | } 6 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/trait_pub_fn.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/parser.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/parser/trait_pub_fn.fe 5 | --- 6 | error[1-0001]: `pub` modifier is not allowed in this block 7 | ┌─ trait_pub_fn.fe:2:5 8 | │ 9 | 2 │ pub fn foo(mut self) 10 | │ ^^^ unexpected 11 | 12 | error[1-0001]: `pub` modifier is not allowed in this block 13 | ┌─ trait_pub_fn.fe:3:5 14 | │ 15 | 3 │ pub unsafe fn bar(self) 16 | │ ^^^ unexpected 17 | 18 | error[1-0001]: `unsafe` modifier is not allowed in this block 19 | ┌─ trait_pub_fn.fe:3:9 20 | │ 21 | 3 │ pub unsafe fn bar(self) 22 | │ ^^^^^^ unexpected 23 | 24 | 25 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/type_.fe: -------------------------------------------------------------------------------- 1 | type Result -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/type_.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/parser.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/parser/type_.fe 5 | --- 6 | error[1-0001]: expected identifier, `const` or `>` 7 | ┌─ type_.fe:1:15 8 | │ 9 | 1 │ type Result 10 | │ ^ expected identifier, `const` or `>` 11 | 12 | 13 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/use_.fe: -------------------------------------------------------------------------------- 1 | use foo::bar::*::A 2 | use foo::bar::*::{A, B} 3 | use foo::bar::* as B -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/use_.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/parser.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/parser/use_.fe 5 | --- 6 | error[1-0001]: can't specify path after `*` 7 | ┌─ use_.fe:1:16 8 | │ 9 | 1 │ use foo::bar::*::A 10 | │ ^^ can't specify path after `*` 11 | 12 | error[1-0001]: can't use `*` with `{}` 13 | ┌─ use_.fe:2:18 14 | │ 15 | 2 │ use foo::bar::*::{A, B} 16 | │ ^ can't use `*` with `{}` 17 | 18 | error[1-0001]: can't use `as` with `*` 19 | ┌─ use_.fe:3:17 20 | │ 21 | 3 │ use foo::bar::* as B 22 | │ ^^ can't use `as` with `*` 23 | 24 | 25 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/while_.fe: -------------------------------------------------------------------------------- 1 | fn f() { 2 | while @ {} 3 | 4 | while true { 5 | x + 1 6 | }} 7 | 8 | while true {} 9 | } 10 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/parser/while_.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/parser.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/parser/while_.fe 5 | --- 6 | error[1-0001]: expected expression 7 | ┌─ while_.fe:2:6 8 | │ 9 | 2 │ while @ {} 10 | │ ^ expected expression 11 | 12 | error[1-0001]: unexpected syntax while parsing `while` statement 13 | ┌─ while_.fe:2:7 14 | │ 15 | 2 │ while @ {} 16 | │ ^ unexpected 17 | 18 | error[1-0001]: unexpected syntax while parsing item 19 | ┌─ while_.fe:8:1 20 | │ 21 | 8 │ ╭ while true {} 22 | 9 │ │ } 23 | │ ╰─^ unexpected 24 | 25 | 26 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/const_ty/const_ty_expected.fe: -------------------------------------------------------------------------------- 1 | pub struct Foo { 2 | N: u256 3 | } 4 | fn foo(x: Foo) {} -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/const_ty/const_ty_expected.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/ty.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/ty/const_ty/const_ty_expected.fe 5 | --- 6 | error[3-0012]: expected const type 7 | ┌─ const_ty_expected.fe:4:11 8 | │ 9 | 4 │ fn foo(x: Foo) {} 10 | │ ^^^^^^^^ expected const type of `u256` here 11 | 12 | 13 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/const_ty/const_ty_mismatch.fe: -------------------------------------------------------------------------------- 1 | pub struct Foo { 2 | N: u256 3 | } 4 | 5 | pub struct Foo2 { 6 | t: T, 7 | N: u256 8 | } 9 | 10 | 11 | pub struct Bar { 12 | N: bool 13 | } 14 | 15 | pub fn foo(a: Foo) {} 16 | pub fn foo2(b: Foo2) {} 17 | 18 | pub fn bar(c: Bar<3>) {} 19 | 20 | pub struct Bar2 { 21 | N: u64 22 | } 23 | 24 | pub enum Baz { 25 | MyField{N: u64, x: i32} 26 | } 27 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/const_ty/normal_type_expected.fe: -------------------------------------------------------------------------------- 1 | pub struct Foo { 2 | t: T 3 | } 4 | pub fn foo(x: Foo<1>) {} 5 | 6 | pub struct Bar { 7 | u: T, 8 | n: N, 9 | } 10 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/const_ty/normal_type_expected.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/ty.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/ty/const_ty/normal_type_expected.fe 5 | --- 6 | error[3-0013]: expected a normal type 7 | ┌─ normal_type_expected.fe:4:15 8 | │ 9 | 4 │ pub fn foo(x: Foo<1>) {} 10 | │ ^^^^^^ expected a normal type here, but `1` is given 11 | 12 | error[3-0013]: expected a normal type 13 | ┌─ normal_type_expected.fe:8:8 14 | │ 15 | 8 │ n: N, 16 | │ ^ expected a normal type here, but `const N: u32` is given 17 | 18 | 19 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/const_ty/trait_const_ty.fe: -------------------------------------------------------------------------------- 1 | pub trait Trait {} 2 | impl Trait for i32 {} 3 | impl Trait for i64 {} 4 | pub struct Foo 5 | where T: Trait 6 | {} 7 | 8 | pub trait Trait2 {} 9 | impl Trait2<1> for i32 {} 10 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/const_ty/trait_const_ty.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/ty.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/ty/const_ty/trait_const_ty.fe 5 | --- 6 | error[3-0011]: given type doesn't match the expected const type 7 | ┌─ trait_const_ty.fe:3:20 8 | │ 9 | 3 │ impl Trait for i64 {} 10 | │ ^^^^^^^^ expected `u32` type here, but `u64` is given 11 | 12 | error[3-0011]: given type doesn't match the expected const type 13 | ┌─ trait_const_ty.fe:5:14 14 | │ 15 | 5 │ where T: Trait 16 | │ ^^^^^^^^ expected `u32` type here, but `u64` is given 17 | 18 | error[3-0012]: expected const type 19 | ┌─ trait_const_ty.fe:2:6 20 | │ 21 | 2 │ impl Trait for i32 {} 22 | │ ^^^^^^^^^^ expected const type of `u32` here 23 | 24 | error[3-0013]: expected a normal type 25 | ┌─ trait_const_ty.fe:9:6 26 | │ 27 | 9 │ impl Trait2<1> for i32 {} 28 | │ ^^^^^^^^^ expected a normal type here, but `1` is given 29 | 30 | 31 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/def/alias_arg_mismatch.fe: -------------------------------------------------------------------------------- 1 | struct S2 { 2 | t: T1, 3 | t2: T1, 4 | u: T2, 5 | u2: T2, 6 | } 7 | 8 | pub struct S { 9 | t: T, 10 | u: U, 11 | } 12 | type T1 = S 13 | type T2 = T1 14 | 15 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/def/alias_arg_mismatch.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/ty.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/ty/alias_arg_mismatch.fe 5 | --- 6 | error[3-0003]: all type parameters of type alias must be given 7 | ┌─ alias_arg_mismatch.fe:2:8 8 | │ 9 | 2 │ t: T1, 10 | │ ^^^^^^^ expected at least 2 arguments here 11 | · 12 | 12 │ type T1 = S 13 | │ ----------------------- type alias defined here 14 | 15 | error[3-0003]: all type parameters of type alias must be given 16 | ┌─ alias_arg_mismatch.fe:13:14 17 | │ 18 | 12 │ type T1 = S 19 | │ ----------------------- type alias defined here 20 | 13 │ type T2 = T1 21 | │ ^^^^^ expected at least 2 arguments here 22 | 23 | 24 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/def/alias_cycle.fe: -------------------------------------------------------------------------------- 1 | type T1 = T1 2 | 3 | type T2 = T3 4 | type T3 = T4 5 | type T4 = T2 6 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/def/alias_cycle.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/ty.rs 3 | expression: diags 4 | input_file: fixtures/ty/def/alias_cycle.fe 5 | --- 6 | error[3-0004]: type alias cycle 7 | ┌─ alias_cycle.fe:1:11 8 | │ 9 | 1 │ type T1 = T1 10 | │ ^^ cycle happens here 11 | 12 | error[3-0004]: type alias cycle 13 | ┌─ alias_cycle.fe:5:11 14 | │ 15 | 3 │ type T2 = T3 16 | │ -- type alias defined here 17 | 4 │ type T3 = T4 18 | │ -- type alias defined here 19 | 5 │ type T4 = T2 20 | │ ^^ cycle happens here 21 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/def/alias_kind_mismatch.fe: -------------------------------------------------------------------------------- 1 | pub struct S0 { 2 | t: T, 3 | u: U, 4 | } 5 | 6 | type T1 = S0 7 | type T2 = S0 8 | type T3 = S0 9 | 10 | 11 | pub struct S1 { 12 | t: T3, 13 | } 14 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/def/alias_kind_mismatch.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/ty.rs 3 | expression: diags 4 | input_file: fixtures/ty/def/alias_kind_mismatch.fe 5 | --- 6 | error[3-0001]: invalid type argument kind 7 | ┌─ alias_kind_mismatch.fe:7:11 8 | │ 9 | 7 │ type T2 = S0 10 | │ ^^^^^^^^^^^ expected `*` kind, but `S0` has `(* -> (* -> *))` kind 11 | 12 | error[3-0001]: invalid type argument kind 13 | ┌─ alias_kind_mismatch.fe:12:8 14 | │ 15 | 12 │ t: T3, 16 | │ ^^^^^^^^^^^ expected `*` kind, but `S0` has `(* -> (* -> *))` kind 17 | 18 | error[3-0016]: too many generic args; expected 2, given 3 19 | ┌─ alias_kind_mismatch.fe:6:11 20 | │ 21 | 6 │ type T1 = S0 22 | │ ^^^^^^^^^^^^^^^^^ expected 2 arguments, but 3 were given 23 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/def/alias_non_mono.fe: -------------------------------------------------------------------------------- 1 | pub struct Foo { 2 | t: T, 3 | u: U, 4 | } 5 | 6 | pub type T = Foo 7 | pub type T2 = Foo -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/def/alias_non_mono.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/ty.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/ty/alias_non_mono.fe 5 | --- 6 | 7 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/def/const_generics_cycle.fe: -------------------------------------------------------------------------------- 1 | pub struct Foo {} 2 | pub struct Bar {} -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/def/const_generics_cycle.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/ty.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/ty/def/const_generics_cycle.fe 5 | --- 6 | error[3-0009]: invalid const parameter type 7 | ┌─ const_generics_cycle.fe:1:28 8 | │ 9 | 1 │ pub struct Foo {} 10 | │ ^ only integer or bool types are allowed as a const parameter type 11 | 12 | error[3-0009]: invalid const parameter type 13 | ┌─ const_generics_cycle.fe:2:28 14 | │ 15 | 2 │ pub struct Bar {} 16 | │ ^^^ only integer or bool types are allowed as a const parameter type 17 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/def/const_generics_invalid_ty.fe: -------------------------------------------------------------------------------- 1 | pub struct Foo {} 2 | pub struct Bar {} 3 | 4 | pub fn foo() {} -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/def/const_generics_invalid_ty.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/ty.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/ty/def/const_generics_invalid_ty.fe 5 | --- 6 | error[3-0009]: invalid const parameter type 7 | ┌─ const_generics_invalid_ty.fe:2:25 8 | │ 9 | 2 │ pub struct Bar {} 10 | │ ^^^ only integer or bool types are allowed as a const parameter type 11 | 12 | error[3-0009]: invalid const parameter type 13 | ┌─ const_generics_invalid_ty.fe:4:21 14 | │ 15 | 4 │ pub fn foo() {} 16 | │ ^^^ only integer or bool types are allowed as a const parameter type 17 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/def/const_generics_trait_bound.fe: -------------------------------------------------------------------------------- 1 | pub trait Trait {} 2 | 3 | pub struct Foo 4 | where U: Trait 5 | {} 6 | 7 | pub fn foo() 8 | where U: Trait 9 | {} -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/def/const_generics_trait_bound.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/ty.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/ty/def/const_generics_trait_bound.fe 5 | --- 6 | error[6-0006]: trait bound for const type is not allowed 7 | ┌─ const_generics_trait_bound.fe:4:7 8 | │ 9 | 4 │ where U: Trait 10 | │ ^ `const U: u32` is a const type 11 | 12 | error[6-0006]: trait bound for const type is not allowed 13 | ┌─ const_generics_trait_bound.fe:8:7 14 | │ 15 | 8 │ where U: Trait 16 | │ ^ `const U: bool` is a const type 17 | 18 | 19 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/def/duplicated_arg_name.fe: -------------------------------------------------------------------------------- 1 | pub fn foo(x: i32, y x: u64) {} 2 | 3 | trait Foo { 4 | fn foo(x y: i32, z y: i32) {} 5 | } 6 | 7 | impl Foo for i32 { 8 | fn foo(x y: i32, z y: i32) {} 9 | } 10 | 11 | fn bar(a x: i32, a y: i32) {} 12 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/def/generic_param_conflict.fe: -------------------------------------------------------------------------------- 1 | pub enum Result { 2 | Ok(T), 3 | Err(E), 4 | } 5 | 6 | impl Result 7 | { 8 | fn foo(self: Self) {} 9 | 10 | fn bar(self: Self) { 11 | fn baz(t: T) {} 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/def/generic_param_conflict.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/ty.rs 3 | expression: diags 4 | input_file: crates/uitest/fixtures/ty/def/generic_param_conflict.fe 5 | --- 6 | error[3-0007]: generic parameter is already defined in the parent item 7 | ┌─ generic_param_conflict.fe:8:12 8 | │ 9 | 6 │ impl Result 10 | │ - conflict with this generic parameter 11 | 7 │ { 12 | 8 │ fn foo(self: Self) {} 13 | │ ^ `E` is already defined 14 | 15 | error[3-0007]: generic parameter is already defined in the parent item 16 | ┌─ generic_param_conflict.fe:11:16 17 | │ 18 | 10 │ fn bar(self: Self) { 19 | │ - conflict with this generic parameter 20 | 11 │ fn baz(t: T) {} 21 | │ ^ `T` is already defined 22 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/def/impl_conflict.fe: -------------------------------------------------------------------------------- 1 | pub enum Result { 2 | Ok(T), 3 | Err(E), 4 | } 5 | 6 | impl Result { 7 | fn foo(self) {} 8 | } 9 | 10 | impl Result { 11 | fn foo(self) {} 12 | } 13 | 14 | impl Result { 15 | fn foo(self: Self) {} 16 | } -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/def/impl_conflict.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/ty.rs 3 | expression: diags 4 | input_file: fixtures/ty/def/impl_conflict.fe 5 | --- 6 | error[6-0000]: conflicting method implementations 7 | ┌─ impl_conflict.fe:7:8 8 | │ 9 | 7 │ fn foo(self) {} 10 | │ ^^^ 11 | · 12 | 11 │ fn foo(self) {} 13 | │ ^^^ 14 | 15 | error[6-0000]: conflicting method implementations 16 | ┌─ impl_conflict.fe:7:8 17 | │ 18 | 7 │ fn foo(self) {} 19 | │ ^^^ 20 | · 21 | 15 │ fn foo(self: Self) {} 22 | │ ^^^ 23 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/def/impl_foreign.fe: -------------------------------------------------------------------------------- 1 | impl i32 {} 2 | 3 | impl T {} 4 | 5 | impl *> T { 6 | } -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/def/impl_foreign.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/ty.rs 3 | expression: diags 4 | input_file: fixtures/ty/def/impl_foreign.fe 5 | --- 6 | error[6-0011]: invalid inherent implementation 7 | ┌─ impl_foreign.fe:1:6 8 | │ 9 | 1 │ impl i32 {} 10 | │ ^^^ inherent impl is not allowed for foreign type `i32` 11 | 12 | error[6-0011]: invalid inherent implementation 13 | ┌─ impl_foreign.fe:3:9 14 | │ 15 | 3 │ impl T {} 16 | │ ^ inherent impl is not allowed for non nominal type 17 | 18 | error[6-0011]: invalid inherent implementation 19 | ┌─ impl_foreign.fe:5:17 20 | │ 21 | 5 │ impl *> T { 22 | │ ^^^^^^ inherent impl is not allowed for non nominal type 23 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/def/invalid_self_ty.fe: -------------------------------------------------------------------------------- 1 | pub trait Foo { 2 | fn foo(self: i32) 3 | } 4 | 5 | impl Foo for Option { 6 | fn foo(self: i32) {} 7 | } 8 | 9 | pub enum Option { 10 | Some(T), 11 | None, 12 | 13 | } 14 | 15 | impl Option { 16 | fn method1(self: i32) {} 17 | } 18 | 19 | impl Option { 20 | fn method2(self: i32) {} 21 | } -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/def/kind_bound.fe: -------------------------------------------------------------------------------- 1 | // * -> * 2 | pub struct Wrapper1 3 | { 4 | value: T 5 | } 6 | 7 | // (* -> *) -> * -> * 8 | pub struct Wrapper2 9 | where T: * -> * 10 | { 11 | val: T 12 | } 13 | 14 | 15 | // ((* -> *) -> *) -> (* -> *) -> * 16 | pub struct Wrapper3 17 | where T: (* -> *) -> * -> *, 18 | U: * -> * 19 | { 20 | value: T 21 | } 22 | 23 | pub struct Foo { 24 | foo_x: Wrapper2, 25 | foo_err: Wrapper2, 26 | } 27 | 28 | 29 | pub struct Bar { 30 | bar_x: Wrapper3, 31 | bar_y: Wrapper1>, 32 | bar_err1: Wrapper3, 33 | bar_err2: Wrapper3, 34 | bar_err3: wrapper3, 35 | } 36 | 37 | pub struct InvalidBound *> 38 | where T: (* -> *) -> * 39 | { 40 | val: T 41 | } 42 | 43 | pub struct InvalidBound2 44 | where Self: * 45 | { 46 | val: i32 47 | } 48 | 49 | pub struct InvalidBound3 50 | where Wrapper1: * 51 | { 52 | val: Wrapper1 53 | } -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/def/kind_mismatch.fe: -------------------------------------------------------------------------------- 1 | pub struct Foo { 2 | t: T, 3 | u: U, 4 | } 5 | 6 | pub struct Bar { 7 | foo: Foo, 8 | bar: Foo, 9 | baz: Foo, 10 | boz: Foo>, 11 | } 12 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/def/kind_mismatch.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/ty.rs 3 | expression: diags 4 | input_file: fixtures/ty/def/kind_mismatch.fe 5 | --- 6 | error[3-0001]: invalid type argument kind 7 | ┌─ kind_mismatch.fe:7:10 8 | │ 9 | 7 │ foo: Foo, 10 | │ ^^^^^^^^^^^^^ expected `*` kind, but `Foo` has `(* -> (* -> *))` kind 11 | 12 | error[3-0001]: invalid type argument kind 13 | ┌─ kind_mismatch.fe:8:10 14 | │ 15 | 8 │ bar: Foo, 16 | │ ^^^^^^^^^^^^^ expected `*` kind, but `Foo` has `(* -> (* -> *))` kind 17 | 18 | error[3-0016]: too many generic args; expected 2, given 3 19 | ┌─ kind_mismatch.fe:9:10 20 | │ 21 | 9 │ baz: Foo, 22 | │ ^^^^^^^^^^^^^^^^^^^ expected 2 arguments, but 3 were given 23 | 24 | error[3-0016]: too many generic args; expected 2, given 3 25 | ┌─ kind_mismatch.fe:10:19 26 | │ 27 | 10 │ boz: Foo>, 28 | │ ^^^^^^^^^^^^^^^^^^^ expected 2 arguments, but 3 were given 29 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/def/not_fully_applied.fe: -------------------------------------------------------------------------------- 1 | pub struct Gen { 2 | t: T, 3 | u: U, 4 | } 5 | 6 | pub struct MyS { 7 | f: Gen, 8 | u: (i32, i32), 9 | } 10 | 11 | pub enum MyE { 12 | Variant(Gen, Gen), 13 | Variant2{ x: Gen, y: Gen } 14 | } 15 | 16 | pub contract MyC { 17 | f: Gen, 18 | } 19 | 20 | 21 | impl Gen { 22 | fn foo(self) {} 23 | 24 | fn bar(self: Self) {} 25 | } 26 | 27 | 28 | fn foo(gen: Gen) {} -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/def/not_star_kind.fe: -------------------------------------------------------------------------------- 1 | pub struct Gen { 2 | t: T, 3 | u: U, 4 | } 5 | 6 | pub struct MyS { 7 | f: Gen, 8 | u: (i32, i32), 9 | } 10 | 11 | pub enum MyE { 12 | Variant(Gen, Gen), 13 | Variant2{ x: Gen, y: Gen }, 14 | } 15 | 16 | pub contract MyC { 17 | f: Gen, 18 | } 19 | 20 | 21 | impl Gen { 22 | fn foo(self) {} 23 | 24 | fn bar(self: Self) {} 25 | } 26 | 27 | 28 | fn foo(gen: Gen) {} 29 | 30 | fn foo(gen: Gen) -> Gen {} -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/def/recursive_type.fe: -------------------------------------------------------------------------------- 1 | pub struct S1 { 2 | s: S1 3 | } 4 | 5 | pub struct S2 { 6 | s: S3 7 | } 8 | 9 | pub struct S3 { 10 | s: S4 11 | } 12 | 13 | pub struct S4 { 14 | s: S2 15 | } 16 | 17 | pub struct S5 { 18 | s: S6, 19 | t: T, 20 | } 21 | 22 | pub struct S6 { 23 | s: S5 24 | } -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/def/recursive_type.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: crates/uitest/tests/ty.rs 3 | expression: diags 4 | input_file: fixtures/ty/def/recursive_type.fe 5 | --- 6 | error[3-0002]: recursive type definition 7 | ┌─ recursive_type.fe:1:12 8 | │ 9 | 1 │ pub struct S1 { 10 | │ ^^ recursive type definition here 11 | 2 │ s: S1 12 | │ -- recursion occurs here 13 | 14 | error[3-0002]: recursive type definition 15 | ┌─ recursive_type.fe:5:12 16 | │ 17 | 5 │ pub struct S2 { 18 | │ ^^ recursive type definition here 19 | 6 │ s: S3 20 | │ -- recursion occurs here 21 | · 22 | 10 │ s: S4 23 | │ -- recursion occurs here 24 | · 25 | 14 │ s: S2 26 | │ -- recursion occurs here 27 | 28 | error[3-0002]: recursive type definition 29 | ┌─ recursive_type.fe:17:12 30 | │ 31 | 17 │ pub struct S5 { 32 | │ ^^ recursive type definition here 33 | 18 │ s: S6, 34 | │ -- recursion occurs here 35 | · 36 | 23 │ s: S5 37 | │ ------ recursion occurs here 38 | -------------------------------------------------------------------------------- /crates/uitest/fixtures/ty/def/trait_arg_mismatch.fe: -------------------------------------------------------------------------------- 1 | pub trait Foo *> {} 2 | 3 | enum Option { 4 | Some(T), 5 | None, 6 | } 7 | 8 | impl Foo for i32 {} 9 | impl Foo> for i32 {} 10 | impl Foo