aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
authorZac Pullar-Strecker <[email protected]>2020-07-31 03:12:44 +0100
committerZac Pullar-Strecker <[email protected]>2020-07-31 03:12:44 +0100
commitf05d7b41a719d848844b054a16477b29d0f063c6 (patch)
tree0a8a0946e8aef2ce64d4c13d0035ba41cce2daf3 /crates/ra_syntax
parent73ff610e41959e3e7c78a2b4b25b086883132956 (diff)
parent6b7cb8b5ab539fc4333ce34bc29bf77c976f232a (diff)
Merge remote-tracking branch 'upstream/master' into 503-hover-doc-links
Hasn't fixed tests yet.
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/Cargo.toml4
-rw-r--r--crates/ra_syntax/src/ast.rs22
-rw-r--r--crates/ra_syntax/src/ast/edit.rs46
-rw-r--r--crates/ra_syntax/src/ast/expr_ext.rs (renamed from crates/ra_syntax/src/ast/expr_extensions.rs)13
-rw-r--r--crates/ra_syntax/src/ast/generated/nodes.rs3812
-rw-r--r--crates/ra_syntax/src/ast/make.rs14
-rw-r--r--crates/ra_syntax/src/ast/node_ext.rs (renamed from crates/ra_syntax/src/ast/extensions.rs)91
-rw-r--r--crates/ra_syntax/src/ast/token_ext.rs (renamed from crates/ra_syntax/src/ast/tokens.rs)20
-rw-r--r--crates/ra_syntax/src/ast/traits.rs12
-rw-r--r--crates/ra_syntax/src/lib.rs12
-rw-r--r--crates/ra_syntax/src/parsing/text_tree_sink.rs9
-rw-r--r--crates/ra_syntax/src/ptr.rs2
-rw-r--r--crates/ra_syntax/src/syntax_node.rs4
-rw-r--r--crates/ra_syntax/src/tests.rs118
-rw-r--r--crates/ra_syntax/src/validation.rs8
-rw-r--r--crates/ra_syntax/src/validation/block.rs2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0000_struct_field_missing_comma.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/err/0001_item_recovery_in_file.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/err/0002_duplicate_shebang.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0003_C++_semicolon.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/err/0004_use_path_bad_segment.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0005_attribute_recover.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0006_named_field_recovery.rast10
-rw-r--r--crates/ra_syntax/test_data/parser/err/0007_stray_curly_in_file.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/err/0008_item_block_recovery.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/err/0009_broken_struct_type_parameter.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/err/0010_unsafe_lambda_block.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0011_extern_struct.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0012_broken_lambda.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/err/0013_invalid_type.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/err/0014_where_no_bounds.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/err/0015_curly_in_params.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0016_missing_semi.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0017_incomplete_binexpr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.rast16
-rw-r--r--crates/ra_syntax/test_data/parser/err/0019_let_recover.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0020_fn_recover.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/err/0021_incomplete_param.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0022_bad_exprs.rast12
-rw-r--r--crates/ra_syntax/test_data/parser/err/0023_mismatched_paren.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0024_many_type_parens.rast12
-rw-r--r--crates/ra_syntax/test_data/parser/err/0025_nope.rast46
-rw-r--r--crates/ra_syntax/test_data/parser/err/0026_imp_recovery.rast10
-rw-r--r--crates/ra_syntax/test_data/parser/err/0027_incomplere_where_for.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/err/0029_field_completion.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0031_block_inner_attrs.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0032_match_arms_inner_attrs.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0033_match_arms_outer_attrs.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0034_bad_box_pattern.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0035_use_recover.rast10
-rw-r--r--crates/ra_syntax/test_data/parser/err/0036_partial_use.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.rast12
-rw-r--r--crates/ra_syntax/test_data/parser/err/0038_endless_inclusive_range.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0039_lambda_recovery.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0040_illegal_crate_kw_location.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/err/0041_illegal_super_keyword_location.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/err/0042_illegal_self_keyword_location.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/err/0043_default_const.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/err/0044_unexpected_for_type.rast28
-rw-r--r--crates/ra_syntax/test_data/parser/err/0163_weird_blocks.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/fragments/item/ok/0000_fn.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/fuzz-failures/0000.rs4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0001_array_type_missing_semi.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0002_misplaced_label_err.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0003_pointer_type_no_mutability.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0004_impl_type.rast20
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0005_fn_pointer_type_missing_fn.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0006_unsafe_block_in_mod.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0007_async_without_semicolon.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0008_pub_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0009_attr_on_expr_not_allowed.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0010_bad_tuple_index_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0013_static_underscore.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0014_record_literal_before_ellipsis_recovery.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0015_empty_segment.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.rast12
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0002_use_tree_list.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0003_where_pred_for.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0004_value_parameters_no_patterns.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0005_function_type_params.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0006_self_param.rast14
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0007_type_param_bounds.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0008_path_part.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0009_loop_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0011_field_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0012_type_item_where_clause.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0013_pointer_type_mut.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0014_never_type.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0015_continue_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0017_array_type.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0018_arb_self_types.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0019_unary_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0020_use_star.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.rast12
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0022_crate_visibility.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0023_placeholder_type.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0024_slice_pat.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0025_slice_type.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0026_tuple_pat_fields.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0027_ref_pat.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0028_impl_trait_type.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0029_cast_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0030_cond.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0031_while_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0032_fn_pointer_type.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0033_reference_type;.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0034_break_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0036_unsafe_extern_fn.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0037_qual_paths.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0038_full_range_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0039_type_arg.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0040_crate_keyword_vis.rast14
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0041_trait_item.rast12
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0042_call_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0043_use_alias.rast14
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0044_block_items.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0045_param_list_opt_patterns.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0046_singleton_tuple_type.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0048_path_type_with_bounds.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0050_fn_decl.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0051_unit_type.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0052_path_type.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0053_path_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0054_record_field_attrs.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0055_literal_pattern.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0056_where_clause.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0057_const_fn.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0058_range_pat.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0059_match_arms_commas.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0060_extern_crate.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0061_record_lit.rast28
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0062_mod_contents.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0064_if_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0065_dyn_trait_type.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0066_match_arm.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0067_crate_path.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0068_union_items.rast12
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0069_use_tree_list_after_path.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0070_stmt_bin_expr_ambiguity.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0071_match_expr.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0072_return_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0073_type_item_type_params.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0074_stmt_postfix_expr_ambiguity.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0075_block.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0076_function_where_clause.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0077_try_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0078_type_item.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0080_postfix_range.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.rast12
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0082_ref_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0083_struct_items.rast26
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0084_paren_type.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0085_expr_literals.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0086_function_ret_type.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0088_break_ambiguity.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0089_extern_fn.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0090_type_param_default.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0092_fn_pointer_type_with_ret.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0093_index_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0095_placeholder_pat.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0096_no_semi_after_block.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0098_const_unsafe_fn.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0099_param_list.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0100_for_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0101_unsafe_fn.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0102_record_field_pat_list.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0103_array_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0104_path_fn_trait_args.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0106_lambda_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0107_method_call_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0108_tuple_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0109_label.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0110_use_path.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0112_bind_pat.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0113_nocontentexpr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0114_tuple_struct_where.rast16
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0115_tuple_field_attrs.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0117_macro_call_type.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0118_match_guard.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0120_match_arms_inner_attribute.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0121_match_arms_outer_attributes.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0122_generic_lifetime_type_attribute.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0123_param_list_vararg.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0124_async_fn.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0125_crate_keyword_path.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0125_record_literal_field_with_attr.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0126_attr_on_expr_stmt.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0127_attr_on_last_expr_in_block.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0129_marco_pat.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0130_let_stmt.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0130_try_block_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0131_existential_type.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0132_box_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0134_nocontentexpr_after_item.rast16
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0137_await_expr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0138_associated_type_bounds.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0138_expression_after_block.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0139_param_outer_arg.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0142_for_range_from.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0143_box_pat.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0144_dot_dot_pat.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0145_record_field_pat.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0146_as_precedence.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0147_const_param.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0150_array_attrs.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0150_impl_type_params.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0151_trait_alias.rast12
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0152_arg_with_attr.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0154_fn_pointer_param_ident_path.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0155_closure_params.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0156_fn_def_param.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0156_or_pattern.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0157_fn_pointer_unnamed_arg.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0157_variant_discriminant.rast10
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0158_binop_resets_statementness.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0158_lambda_ret_block.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0159_try_macro_fallback.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0161_labeled_block.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0162_unsafe_block.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_fn.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_impl.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0164_type_path_in_pattern.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0001_struct_item.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0002_struct_item_field.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0005_fn_item.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0007_extern_crate.rast13
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0008_mod_item.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0009_use_item.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0010_use_path_segments.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0011_outer_attribute.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0012_visibility.rast10
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0013_use_path_self_super.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0014_use_tree.rast14
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0015_use_tree.rast10
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0016_struct_flavors.rast26
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0017_attr_trailing_comma.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0018_struct_type_params.rast68
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0019_enums.rast52
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0020_type_param_bounds.rast40
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0021_extern_fn.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0023_static_items.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0024_const_item.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0025_extern_fn_in_block.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0026_const_fn_in_block.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0027_unsafe_fn_in_block.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0028_operator_binding_power.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0029_range_forms.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0030_string_suffixes.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0030_traits.rast12
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0031_extern.rast24
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0032_where_for.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0033_label_break.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0034_crate_path_in_call.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0035_weird_exprs.rast50
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0036_fully_qualified.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0038_where_pred_type.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0039_raw_fn_item.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0040_raw_struct_item_field.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0041_raw_keywords.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0042_ufcs_call_list.rast12
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0043_complex_assignment.rast20
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0044_let_attrs.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0045_block_inner_attrs.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0047_minus_in_inner_pattern.rast16
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0048_compound_assignment.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0049_async_block.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0050_async_block_as_argument.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.rast42
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0052_for_range_block.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0054_qual_path_in_type_arg.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0055_dot_dot_dot.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0056_neq_in_type.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0057_loop_in_call.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0058_unary_expr_precedence.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0059_loops_in_parens.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0060_as_range.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0061_match_full_range.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0062_macro_2.0.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0063_trait_fn_patterns.rast14
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0063_variadic_fun.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0064_impl_fn_params.rast12
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0065_comment_newline.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0065_plus_after_fn_trait_bound.rast4
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0066_default_const.rast6
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0067_where_for_pred.rast38
300 files changed, 2258 insertions, 3592 deletions
diff --git a/crates/ra_syntax/Cargo.toml b/crates/ra_syntax/Cargo.toml
index 49696ce75..fc4d7aa04 100644
--- a/crates/ra_syntax/Cargo.toml
+++ b/crates/ra_syntax/Cargo.toml
@@ -13,7 +13,7 @@ doctest = false
13[dependencies] 13[dependencies]
14itertools = "0.9.0" 14itertools = "0.9.0"
15rowan = "0.10.0" 15rowan = "0.10.0"
16rustc_lexer = { version = "666.0.0", package = "rustc-ap-rustc_lexer" } 16rustc_lexer = { version = "671.0.0", package = "rustc-ap-rustc_lexer" }
17rustc-hash = "1.1.0" 17rustc-hash = "1.1.0"
18arrayvec = "0.5.1" 18arrayvec = "0.5.1"
19once_cell = "1.3.1" 19once_cell = "1.3.1"
@@ -31,4 +31,6 @@ serde = { version = "1.0.106", features = ["derive"] }
31 31
32[dev-dependencies] 32[dev-dependencies]
33test_utils = { path = "../test_utils" } 33test_utils = { path = "../test_utils" }
34expect = { path = "../expect" }
34walkdir = "2.3.1" 35walkdir = "2.3.1"
36rayon = "1"
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs
index 9d02aeef3..fd426ece9 100644
--- a/crates/ra_syntax/src/ast.rs
+++ b/crates/ra_syntax/src/ast.rs
@@ -2,9 +2,9 @@
2 2
3mod generated; 3mod generated;
4mod traits; 4mod traits;
5mod tokens; 5mod token_ext;
6mod extensions; 6mod node_ext;
7mod expr_extensions; 7mod expr_ext;
8pub mod edit; 8pub mod edit;
9pub mod make; 9pub mod make;
10 10
@@ -16,13 +16,13 @@ use crate::{
16}; 16};
17 17
18pub use self::{ 18pub use self::{
19 expr_extensions::{ArrayExprKind, BinOp, Effect, ElseBranch, LiteralKind, PrefixOp, RangeOp}, 19 expr_ext::{ArrayExprKind, BinOp, Effect, ElseBranch, LiteralKind, PrefixOp, RangeOp},
20 extensions::{ 20 generated::{nodes::*, tokens::*},
21 node_ext::{
21 AttrKind, FieldKind, NameOrNameRef, PathSegmentKind, SelfParamKind, SlicePatComponents, 22 AttrKind, FieldKind, NameOrNameRef, PathSegmentKind, SelfParamKind, SlicePatComponents,
22 StructKind, TypeBoundKind, VisibilityKind, 23 StructKind, TypeBoundKind, VisibilityKind,
23 }, 24 },
24 generated::{nodes::*, tokens::*}, 25 token_ext::*,
25 tokens::*,
26 traits::*, 26 traits::*,
27}; 27};
28 28
@@ -139,7 +139,7 @@ fn test_doc_comment_of_statics() {
139 ) 139 )
140 .ok() 140 .ok()
141 .unwrap(); 141 .unwrap();
142 let st = file.syntax().descendants().find_map(StaticDef::cast).unwrap(); 142 let st = file.syntax().descendants().find_map(Static::cast).unwrap();
143 assert_eq!("Number of levels", st.doc_comment_text().unwrap()); 143 assert_eq!("Number of levels", st.doc_comment_text().unwrap());
144} 144}
145 145
@@ -235,7 +235,7 @@ fn test_comments_preserve_trailing_whitespace() {
235 ) 235 )
236 .ok() 236 .ok()
237 .unwrap(); 237 .unwrap();
238 let def = file.syntax().descendants().find_map(StructDef::cast).unwrap(); 238 let def = file.syntax().descendants().find_map(Struct::cast).unwrap();
239 assert_eq!( 239 assert_eq!(
240 "Representation of a Realm. \nIn the specification these are called Realm Records.", 240 "Representation of a Realm. \nIn the specification these are called Realm Records.",
241 def.doc_comment_text().unwrap() 241 def.doc_comment_text().unwrap()
@@ -286,7 +286,7 @@ where
286 let mut bounds = pred.type_bound_list().unwrap().bounds(); 286 let mut bounds = pred.type_bound_list().unwrap().bounds();
287 287
288 assert!(pred.for_token().is_none()); 288 assert!(pred.for_token().is_none());
289 assert!(pred.type_param_list().is_none()); 289 assert!(pred.generic_param_list().is_none());
290 assert_eq!("T", pred.type_ref().unwrap().syntax().text().to_string()); 290 assert_eq!("T", pred.type_ref().unwrap().syntax().text().to_string());
291 assert_bound("Clone", bounds.next()); 291 assert_bound("Clone", bounds.next());
292 assert_bound("Copy", bounds.next()); 292 assert_bound("Copy", bounds.next());
@@ -325,7 +325,7 @@ where
325 let mut bounds = pred.type_bound_list().unwrap().bounds(); 325 let mut bounds = pred.type_bound_list().unwrap().bounds();
326 326
327 assert!(pred.for_token().is_some()); 327 assert!(pred.for_token().is_some());
328 assert_eq!("<'a>", pred.type_param_list().unwrap().syntax().text().to_string()); 328 assert_eq!("<'a>", pred.generic_param_list().unwrap().syntax().text().to_string());
329 assert_eq!("F", pred.type_ref().unwrap().syntax().text().to_string()); 329 assert_eq!("F", pred.type_ref().unwrap().syntax().text().to_string());
330 assert_bound("Fn(&'a str)", bounds.next()); 330 assert_bound("Fn(&'a str)", bounds.next());
331} 331}
diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs
index 2ef173a03..8d3e42f25 100644
--- a/crates/ra_syntax/src/ast/edit.rs
+++ b/crates/ra_syntax/src/ast/edit.rs
@@ -29,9 +29,9 @@ impl ast::BinExpr {
29 } 29 }
30} 30}
31 31
32impl ast::FnDef { 32impl ast::Fn {
33 #[must_use] 33 #[must_use]
34 pub fn with_body(&self, body: ast::BlockExpr) -> ast::FnDef { 34 pub fn with_body(&self, body: ast::BlockExpr) -> ast::Fn {
35 let mut to_insert: ArrayVec<[SyntaxElement; 2]> = ArrayVec::new(); 35 let mut to_insert: ArrayVec<[SyntaxElement; 2]> = ArrayVec::new();
36 let old_body_or_semi: SyntaxElement = if let Some(old_body) = self.body() { 36 let old_body_or_semi: SyntaxElement = if let Some(old_body) = self.body() {
37 old_body.syntax().clone().into() 37 old_body.syntax().clone().into()
@@ -80,9 +80,12 @@ where
80 } 80 }
81} 81}
82 82
83impl ast::ItemList { 83impl ast::AssocItemList {
84 #[must_use] 84 #[must_use]
85 pub fn append_items(&self, items: impl IntoIterator<Item = ast::AssocItem>) -> ast::ItemList { 85 pub fn append_items(
86 &self,
87 items: impl IntoIterator<Item = ast::AssocItem>,
88 ) -> ast::AssocItemList {
86 let mut res = self.clone(); 89 let mut res = self.clone();
87 if !self.syntax().text().contains_char('\n') { 90 if !self.syntax().text().contains_char('\n') {
88 res = make_multiline(res); 91 res = make_multiline(res);
@@ -92,7 +95,7 @@ impl ast::ItemList {
92 } 95 }
93 96
94 #[must_use] 97 #[must_use]
95 pub fn append_item(&self, item: ast::AssocItem) -> ast::ItemList { 98 pub fn append_item(&self, item: ast::AssocItem) -> ast::AssocItemList {
96 let (indent, position) = match self.assoc_items().last() { 99 let (indent, position) = match self.assoc_items().last() {
97 Some(it) => ( 100 Some(it) => (
98 leading_indent(it.syntax()).unwrap_or_default().to_string(), 101 leading_indent(it.syntax()).unwrap_or_default().to_string(),
@@ -113,18 +116,18 @@ impl ast::ItemList {
113 } 116 }
114} 117}
115 118
116impl ast::RecordFieldList { 119impl ast::RecordExprFieldList {
117 #[must_use] 120 #[must_use]
118 pub fn append_field(&self, field: &ast::RecordField) -> ast::RecordFieldList { 121 pub fn append_field(&self, field: &ast::RecordExprField) -> ast::RecordExprFieldList {
119 self.insert_field(InsertPosition::Last, field) 122 self.insert_field(InsertPosition::Last, field)
120 } 123 }
121 124
122 #[must_use] 125 #[must_use]
123 pub fn insert_field( 126 pub fn insert_field(
124 &self, 127 &self,
125 position: InsertPosition<&'_ ast::RecordField>, 128 position: InsertPosition<&'_ ast::RecordExprField>,
126 field: &ast::RecordField, 129 field: &ast::RecordExprField,
127 ) -> ast::RecordFieldList { 130 ) -> ast::RecordExprFieldList {
128 let is_multiline = self.syntax().text().contains_char('\n'); 131 let is_multiline = self.syntax().text().contains_char('\n');
129 let ws; 132 let ws;
130 let space = if is_multiline { 133 let space = if is_multiline {
@@ -189,6 +192,21 @@ impl ast::RecordFieldList {
189 } 192 }
190} 193}
191 194
195impl ast::TypeAlias {
196 #[must_use]
197 pub fn remove_bounds(&self) -> ast::TypeAlias {
198 let colon = match self.colon_token() {
199 Some(it) => it,
200 None => return self.clone(),
201 };
202 let end = match self.type_bound_list() {
203 Some(it) => it.syntax().clone().into(),
204 None => colon.clone().into(),
205 };
206 self.replace_children(colon.into()..=end, iter::empty())
207 }
208}
209
192impl ast::TypeParam { 210impl ast::TypeParam {
193 #[must_use] 211 #[must_use]
194 pub fn remove_bounds(&self) -> ast::TypeParam { 212 pub fn remove_bounds(&self) -> ast::TypeParam {
@@ -244,9 +262,9 @@ impl ast::PathSegment {
244 } 262 }
245} 263}
246 264
247impl ast::UseItem { 265impl ast::Use {
248 #[must_use] 266 #[must_use]
249 pub fn with_use_tree(&self, use_tree: ast::UseTree) -> ast::UseItem { 267 pub fn with_use_tree(&self, use_tree: ast::UseTree) -> ast::Use {
250 if let Some(old) = self.use_tree() { 268 if let Some(old) = self.use_tree() {
251 return self.replace_descendant(old, use_tree); 269 return self.replace_descendant(old, use_tree);
252 } 270 }
@@ -300,9 +318,9 @@ impl ast::UseTree {
300 None => return self.clone(), 318 None => return self.clone(),
301 }; 319 };
302 let use_tree = make::use_tree( 320 let use_tree = make::use_tree(
303 suffix.clone(), 321 suffix,
304 self.use_tree_list(), 322 self.use_tree_list(),
305 self.alias(), 323 self.rename(),
306 self.star_token().is_some(), 324 self.star_token().is_some(),
307 ); 325 );
308 let nested = make::use_tree_list(iter::once(use_tree)); 326 let nested = make::use_tree_list(iter::once(use_tree));
diff --git a/crates/ra_syntax/src/ast/expr_extensions.rs b/crates/ra_syntax/src/ast/expr_ext.rs
index db5438d68..f5ba87223 100644
--- a/crates/ra_syntax/src/ast/expr_extensions.rs
+++ b/crates/ra_syntax/src/ast/expr_ext.rs
@@ -7,6 +7,8 @@ use crate::{
7 SyntaxToken, T, 7 SyntaxToken, T,
8}; 8};
9 9
10impl ast::AttrsOwner for ast::Expr {}
11
10impl ast::Expr { 12impl ast::Expr {
11 pub fn is_block_like(&self) -> bool { 13 pub fn is_block_like(&self) -> bool {
12 match self { 14 match self {
@@ -331,13 +333,12 @@ impl ast::Literal {
331 333
332 match token.kind() { 334 match token.kind() {
333 INT_NUMBER => { 335 INT_NUMBER => {
334 // FYI: there was a bug here previously, thus an if statement bellow is necessary. 336 // FYI: there was a bug here previously, thus the if statement below is necessary.
335 // The lexer treats e.g. `1f64` as an integer literal. See 337 // The lexer treats e.g. `1f64` as an integer literal. See
336 // https://github.com/rust-analyzer/rust-analyzer/issues/1592 338 // https://github.com/rust-analyzer/rust-analyzer/issues/1592
337 // and the comments on the linked PR. 339 // and the comments on the linked PR.
338 340
339 let text = token.text(); 341 let text = token.text();
340
341 if let suffix @ Some(_) = Self::find_suffix(&text, &FLOAT_SUFFIXES) { 342 if let suffix @ Some(_) = Self::find_suffix(&text, &FLOAT_SUFFIXES) {
342 LiteralKind::FloatNumber { suffix } 343 LiteralKind::FloatNumber { suffix }
343 } else { 344 } else {
@@ -399,7 +400,7 @@ impl ast::BlockExpr {
399 Some(it) => it, 400 Some(it) => it,
400 None => return true, 401 None => return true,
401 }; 402 };
402 !matches!(parent.kind(), FN_DEF | IF_EXPR | WHILE_EXPR | LOOP_EXPR | EFFECT_EXPR) 403 !matches!(parent.kind(), FN | IF_EXPR | WHILE_EXPR | LOOP_EXPR | EFFECT_EXPR)
403 } 404 }
404} 405}
405 406
@@ -410,8 +411,8 @@ fn test_literal_with_attr() {
410 assert_eq!(lit.token().text(), r#""Hello""#); 411 assert_eq!(lit.token().text(), r#""Hello""#);
411} 412}
412 413
413impl ast::RecordField { 414impl ast::RecordExprField {
414 pub fn parent_record_lit(&self) -> ast::RecordLit { 415 pub fn parent_record_lit(&self) -> ast::RecordExpr {
415 self.syntax().ancestors().find_map(ast::RecordLit::cast).unwrap() 416 self.syntax().ancestors().find_map(ast::RecordExpr::cast).unwrap()
416 } 417 }
417} 418}
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs
index 58141da11..4306efe13 100644
--- a/crates/ra_syntax/src/ast/generated/nodes.rs
+++ b/crates/ra_syntax/src/ast/generated/nodes.rs
@@ -5,557 +5,529 @@ use crate::{
5 SyntaxKind::{self, *}, 5 SyntaxKind::{self, *},
6 SyntaxNode, SyntaxToken, T, 6 SyntaxNode, SyntaxToken, T,
7}; 7};
8/// The entire Rust source file. Includes all top-level inner attributes and module items.
9///
10/// [Reference](https://doc.rust-lang.org/reference/crates-and-source-files.html)
11#[derive(Debug, Clone, PartialEq, Eq, Hash)] 8#[derive(Debug, Clone, PartialEq, Eq, Hash)]
12pub struct SourceFile { 9pub struct SourceFile {
13 pub(crate) syntax: SyntaxNode, 10 pub(crate) syntax: SyntaxNode,
14} 11}
15impl ast::ModuleItemOwner for SourceFile {}
16impl ast::AttrsOwner for SourceFile {} 12impl ast::AttrsOwner for SourceFile {}
17impl ast::DocCommentsOwner for SourceFile {} 13impl ast::ModuleItemOwner for SourceFile {}
18impl SourceFile { 14impl SourceFile {
19 pub fn modules(&self) -> AstChildren<Module> { support::children(&self.syntax) } 15 pub fn shebang_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![shebang]) }
20} 16}
21/// Function definition either with body or not. 17#[derive(Debug, Clone, PartialEq, Eq, Hash)]
22/// Includes all of its attributes and doc comments. 18pub struct Attr {
23///
24/// ```
25/// ❰
26/// /// Docs
27/// #[attr]
28/// pub extern "C" fn foo<T>(#[attr] Patern {p}: Pattern) -> u32
29/// where
30/// T: Debug
31/// {
32/// 42
33/// }
34/// ❱
35///
36/// extern "C" {
37/// ❰ fn fn_decl(also_variadic_ffi: u32, ...) -> u32; ❱
38/// }
39/// ```
40///
41/// - [Reference](https://doc.rust-lang.org/reference/items/functions.html)
42/// - [Nomicon](https://doc.rust-lang.org/nomicon/ffi.html#variadic-functions)
43#[derive(Debug, Clone, PartialEq, Eq, Hash)]
44pub struct FnDef {
45 pub(crate) syntax: SyntaxNode, 19 pub(crate) syntax: SyntaxNode,
46} 20}
47impl ast::VisibilityOwner for FnDef {} 21impl Attr {
48impl ast::NameOwner for FnDef {} 22 pub fn pound_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![#]) }
49impl ast::TypeParamsOwner for FnDef {} 23 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
50impl ast::DocCommentsOwner for FnDef {} 24 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
51impl ast::AttrsOwner for FnDef {} 25 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
52impl FnDef { 26 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
53 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) } 27 pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) }
28 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
29 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
30}
31#[derive(Debug, Clone, PartialEq, Eq, Hash)]
32pub struct Const {
33 pub(crate) syntax: SyntaxNode,
34}
35impl ast::AttrsOwner for Const {}
36impl ast::NameOwner for Const {}
37impl ast::VisibilityOwner for Const {}
38impl Const {
39 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
54 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } 40 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
41 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) }
42 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
43 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) }
44 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
45 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
46 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
47}
48#[derive(Debug, Clone, PartialEq, Eq, Hash)]
49pub struct Enum {
50 pub(crate) syntax: SyntaxNode,
51}
52impl ast::AttrsOwner for Enum {}
53impl ast::NameOwner for Enum {}
54impl ast::VisibilityOwner for Enum {}
55impl ast::GenericParamsOwner for Enum {}
56impl Enum {
57 pub fn enum_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![enum]) }
58 pub fn variant_list(&self) -> Option<VariantList> { support::child(&self.syntax) }
59}
60#[derive(Debug, Clone, PartialEq, Eq, Hash)]
61pub struct ExternBlock {
62 pub(crate) syntax: SyntaxNode,
63}
64impl ast::AttrsOwner for ExternBlock {}
65impl ExternBlock {
66 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
67 pub fn extern_item_list(&self) -> Option<ExternItemList> { support::child(&self.syntax) }
68}
69#[derive(Debug, Clone, PartialEq, Eq, Hash)]
70pub struct ExternCrate {
71 pub(crate) syntax: SyntaxNode,
72}
73impl ast::AttrsOwner for ExternCrate {}
74impl ast::VisibilityOwner for ExternCrate {}
75impl ExternCrate {
76 pub fn extern_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![extern]) }
77 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
78 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
79 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
80 pub fn rename(&self) -> Option<Rename> { support::child(&self.syntax) }
81 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
82}
83#[derive(Debug, Clone, PartialEq, Eq, Hash)]
84pub struct Fn {
85 pub(crate) syntax: SyntaxNode,
86}
87impl ast::AttrsOwner for Fn {}
88impl ast::NameOwner for Fn {}
89impl ast::VisibilityOwner for Fn {}
90impl ast::GenericParamsOwner for Fn {}
91impl Fn {
55 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } 92 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
56 pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) } 93 pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) }
94 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
57 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) } 95 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
96 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
58 pub fn fn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![fn]) } 97 pub fn fn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![fn]) }
59 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } 98 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
60 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } 99 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
61 pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) } 100 pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
62 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 101 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
63} 102}
64/// Return type annotation.
65///
66/// ```
67/// fn foo(a: u32) ❰ -> Option<u32> ❱ { Some(a) }
68/// ```
69///
70/// [Reference](https://doc.rust-lang.org/reference/items/functions.html)
71#[derive(Debug, Clone, PartialEq, Eq, Hash)] 103#[derive(Debug, Clone, PartialEq, Eq, Hash)]
72pub struct RetType { 104pub struct Impl {
73 pub(crate) syntax: SyntaxNode, 105 pub(crate) syntax: SyntaxNode,
74} 106}
75impl RetType { 107impl ast::AttrsOwner for Impl {}
76 pub fn thin_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![->]) } 108impl ast::VisibilityOwner for Impl {}
109impl ast::GenericParamsOwner for Impl {}
110impl Impl {
111 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
112 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
113 pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) }
114 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
77 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 115 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
116 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
117 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }
118 pub fn assoc_item_list(&self) -> Option<AssocItemList> { support::child(&self.syntax) }
119}
120#[derive(Debug, Clone, PartialEq, Eq, Hash)]
121pub struct MacroCall {
122 pub(crate) syntax: SyntaxNode,
123}
124impl ast::AttrsOwner for MacroCall {}
125impl ast::NameOwner for MacroCall {}
126impl MacroCall {
127 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
128 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
129 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
130 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
131}
132#[derive(Debug, Clone, PartialEq, Eq, Hash)]
133pub struct Module {
134 pub(crate) syntax: SyntaxNode,
135}
136impl ast::AttrsOwner for Module {}
137impl ast::NameOwner for Module {}
138impl ast::VisibilityOwner for Module {}
139impl Module {
140 pub fn mod_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mod]) }
141 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
142 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
143}
144#[derive(Debug, Clone, PartialEq, Eq, Hash)]
145pub struct Static {
146 pub(crate) syntax: SyntaxNode,
147}
148impl ast::AttrsOwner for Static {}
149impl ast::NameOwner for Static {}
150impl ast::VisibilityOwner for Static {}
151impl Static {
152 pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) }
153 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
154 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
155 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) }
156 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
157 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
158 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
78} 159}
79/// Struct definition. 160#[derive(Debug, Clone, PartialEq, Eq, Hash)]
80/// Includes all of its attributes and doc comments. 161pub struct Struct {
81///
82/// ```
83/// ❰
84/// /// Docs
85/// #[attr]
86/// struct Foo<T> where T: Debug {
87/// /// Docs
88/// #[attr]
89/// pub a: u32,
90/// b: T,
91/// }
92/// ❱
93///
94/// ❰ struct Foo; ❱
95/// ❰ struct Foo<T>(#[attr] T) where T: Debug; ❱
96/// ```
97///
98/// [Reference](https://doc.rust-lang.org/reference/items/structs.html)
99#[derive(Debug, Clone, PartialEq, Eq, Hash)]
100pub struct StructDef {
101 pub(crate) syntax: SyntaxNode, 162 pub(crate) syntax: SyntaxNode,
102} 163}
103impl ast::VisibilityOwner for StructDef {} 164impl ast::AttrsOwner for Struct {}
104impl ast::NameOwner for StructDef {} 165impl ast::NameOwner for Struct {}
105impl ast::TypeParamsOwner for StructDef {} 166impl ast::VisibilityOwner for Struct {}
106impl ast::AttrsOwner for StructDef {} 167impl ast::GenericParamsOwner for Struct {}
107impl ast::DocCommentsOwner for StructDef {} 168impl Struct {
108impl StructDef {
109 pub fn struct_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![struct]) } 169 pub fn struct_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![struct]) }
110 pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) }
111 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 170 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
171 pub fn field_list(&self) -> Option<FieldList> { support::child(&self.syntax) }
112} 172}
113/// Union definition. 173#[derive(Debug, Clone, PartialEq, Eq, Hash)]
114/// Includes all of its attributes and doc comments. 174pub struct Trait {
115/// 175 pub(crate) syntax: SyntaxNode,
116/// ``` 176}
117/// ❰ 177impl ast::AttrsOwner for Trait {}
118/// /// Docs 178impl ast::NameOwner for Trait {}
119/// #[attr] 179impl ast::VisibilityOwner for Trait {}
120/// pub union Foo<T> where T: Debug { 180impl ast::GenericParamsOwner for Trait {}
121/// /// Docs 181impl ast::TypeBoundsOwner for Trait {}
122/// #[attr] 182impl Trait {
123/// a: T, 183 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
124/// b: u32, 184 pub fn auto_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![auto]) }
125/// } 185 pub fn trait_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![trait]) }
126/// ❱ 186 pub fn assoc_item_list(&self) -> Option<AssocItemList> { support::child(&self.syntax) }
127/// ``` 187}
128/// 188#[derive(Debug, Clone, PartialEq, Eq, Hash)]
129/// [Reference](https://doc.rust-lang.org/reference/items/unions.html) 189pub struct TypeAlias {
130#[derive(Debug, Clone, PartialEq, Eq, Hash)]
131pub struct UnionDef {
132 pub(crate) syntax: SyntaxNode, 190 pub(crate) syntax: SyntaxNode,
133} 191}
134impl ast::VisibilityOwner for UnionDef {} 192impl ast::AttrsOwner for TypeAlias {}
135impl ast::NameOwner for UnionDef {} 193impl ast::NameOwner for TypeAlias {}
136impl ast::TypeParamsOwner for UnionDef {} 194impl ast::VisibilityOwner for TypeAlias {}
137impl ast::AttrsOwner for UnionDef {} 195impl ast::GenericParamsOwner for TypeAlias {}
138impl ast::DocCommentsOwner for UnionDef {} 196impl ast::TypeBoundsOwner for TypeAlias {}
139impl UnionDef { 197impl TypeAlias {
198 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
199 pub fn type_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![type]) }
200 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
201 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) }
202 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
203}
204#[derive(Debug, Clone, PartialEq, Eq, Hash)]
205pub struct Union {
206 pub(crate) syntax: SyntaxNode,
207}
208impl ast::AttrsOwner for Union {}
209impl ast::NameOwner for Union {}
210impl ast::VisibilityOwner for Union {}
211impl ast::GenericParamsOwner for Union {}
212impl Union {
140 pub fn union_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![union]) } 213 pub fn union_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![union]) }
141 pub fn record_field_def_list(&self) -> Option<RecordFieldDefList> { 214 pub fn record_field_list(&self) -> Option<RecordFieldList> { support::child(&self.syntax) }
142 support::child(&self.syntax) 215}
143 } 216#[derive(Debug, Clone, PartialEq, Eq, Hash)]
217pub struct Use {
218 pub(crate) syntax: SyntaxNode,
219}
220impl ast::AttrsOwner for Use {}
221impl ast::VisibilityOwner for Use {}
222impl Use {
223 pub fn use_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![use]) }
224 pub fn use_tree(&self) -> Option<UseTree> { support::child(&self.syntax) }
225 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
226}
227#[derive(Debug, Clone, PartialEq, Eq, Hash)]
228pub struct Visibility {
229 pub(crate) syntax: SyntaxNode,
230}
231impl Visibility {
232 pub fn pub_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![pub]) }
233 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
234 pub fn super_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![super]) }
235 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
236 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
237 pub fn in_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![in]) }
238 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
239 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
240}
241#[derive(Debug, Clone, PartialEq, Eq, Hash)]
242pub struct Name {
243 pub(crate) syntax: SyntaxNode,
244}
245impl Name {
246 pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) }
247}
248#[derive(Debug, Clone, PartialEq, Eq, Hash)]
249pub struct ItemList {
250 pub(crate) syntax: SyntaxNode,
251}
252impl ast::AttrsOwner for ItemList {}
253impl ast::ModuleItemOwner for ItemList {}
254impl ItemList {
255 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
256 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
257}
258#[derive(Debug, Clone, PartialEq, Eq, Hash)]
259pub struct NameRef {
260 pub(crate) syntax: SyntaxNode,
144} 261}
145/// Record field definition list including enclosing curly braces. 262impl NameRef {
146/// 263 pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) }
147/// ``` 264}
148/// struct Foo // same for union 265#[derive(Debug, Clone, PartialEq, Eq, Hash)]
149/// ❰ 266pub struct Rename {
150/// { 267 pub(crate) syntax: SyntaxNode,
151/// a: u32, 268}
152/// b: bool, 269impl ast::NameOwner for Rename {}
153/// } 270impl Rename {
154/// ❱ 271 pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) }
155/// ``` 272 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) }
156/// 273}
157/// [Reference](https://doc.rust-lang.org/reference/items/structs.html) 274#[derive(Debug, Clone, PartialEq, Eq, Hash)]
158#[derive(Debug, Clone, PartialEq, Eq, Hash)] 275pub struct UseTree {
159pub struct RecordFieldDefList { 276 pub(crate) syntax: SyntaxNode,
277}
278impl UseTree {
279 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
280 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
281 pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) }
282 pub fn use_tree_list(&self) -> Option<UseTreeList> { support::child(&self.syntax) }
283 pub fn rename(&self) -> Option<Rename> { support::child(&self.syntax) }
284}
285#[derive(Debug, Clone, PartialEq, Eq, Hash)]
286pub struct Path {
287 pub(crate) syntax: SyntaxNode,
288}
289impl Path {
290 pub fn qualifier(&self) -> Option<Path> { support::child(&self.syntax) }
291 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
292 pub fn segment(&self) -> Option<PathSegment> { support::child(&self.syntax) }
293}
294#[derive(Debug, Clone, PartialEq, Eq, Hash)]
295pub struct UseTreeList {
160 pub(crate) syntax: SyntaxNode, 296 pub(crate) syntax: SyntaxNode,
161} 297}
162impl RecordFieldDefList { 298impl UseTreeList {
163 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } 299 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
164 pub fn fields(&self) -> AstChildren<RecordFieldDef> { support::children(&self.syntax) } 300 pub fn use_trees(&self) -> AstChildren<UseTree> { support::children(&self.syntax) }
165 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } 301 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
166} 302}
167/// Record field definition including its attributes and doc comments. 303#[derive(Debug, Clone, PartialEq, Eq, Hash)]
168/// 304pub struct Abi {
169/// ` ``
170/// same for union
171/// struct Foo {
172/// ❰
173/// /// Docs
174/// #[attr]
175/// pub a: u32
176/// ❱
177///
178/// ❰ b: bool ❱
179/// }
180/// ```
181///
182/// [Reference](https://doc.rust-lang.org/reference/items/structs.html)
183#[derive(Debug, Clone, PartialEq, Eq, Hash)]
184pub struct RecordFieldDef {
185 pub(crate) syntax: SyntaxNode, 305 pub(crate) syntax: SyntaxNode,
186} 306}
187impl ast::VisibilityOwner for RecordFieldDef {} 307impl Abi {
188impl ast::NameOwner for RecordFieldDef {} 308 pub fn extern_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![extern]) }
189impl ast::AttrsOwner for RecordFieldDef {} 309}
190impl ast::DocCommentsOwner for RecordFieldDef {} 310#[derive(Debug, Clone, PartialEq, Eq, Hash)]
191impl ast::TypeAscriptionOwner for RecordFieldDef {} 311pub struct GenericParamList {
192impl RecordFieldDef {} 312 pub(crate) syntax: SyntaxNode,
193/// Tuple field definition list including enclosing parens. 313}
194/// 314impl GenericParamList {
195/// ``` 315 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) }
196/// struct Foo ❰ (u32, String, Vec<u32>) ❱; 316 pub fn generic_params(&self) -> AstChildren<GenericParam> { support::children(&self.syntax) }
197/// ``` 317 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
198/// 318}
199/// [Reference](https://doc.rust-lang.org/reference/items/structs.html) 319#[derive(Debug, Clone, PartialEq, Eq, Hash)]
200#[derive(Debug, Clone, PartialEq, Eq, Hash)] 320pub struct ParamList {
201pub struct TupleFieldDefList {
202 pub(crate) syntax: SyntaxNode, 321 pub(crate) syntax: SyntaxNode,
203} 322}
204impl TupleFieldDefList { 323impl ParamList {
205 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } 324 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
206 pub fn fields(&self) -> AstChildren<TupleFieldDef> { support::children(&self.syntax) } 325 pub fn self_param(&self) -> Option<SelfParam> { support::child(&self.syntax) }
326 pub fn comma_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![,]) }
327 pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) }
207 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 328 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
208} 329}
209/// Tuple field definition including its attributes.
210///
211/// ```
212/// struct Foo(❰ #[attr] u32 ❱);
213/// ```
214///
215/// [Reference](https://doc.rust-lang.org/reference/items/structs.html)
216#[derive(Debug, Clone, PartialEq, Eq, Hash)] 330#[derive(Debug, Clone, PartialEq, Eq, Hash)]
217pub struct TupleFieldDef { 331pub struct RetType {
218 pub(crate) syntax: SyntaxNode, 332 pub(crate) syntax: SyntaxNode,
219} 333}
220impl ast::VisibilityOwner for TupleFieldDef {} 334impl RetType {
221impl ast::AttrsOwner for TupleFieldDef {} 335 pub fn thin_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![->]) }
222impl TupleFieldDef { 336 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) }
223 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
224} 337}
225/// Enum definition. 338#[derive(Debug, Clone, PartialEq, Eq, Hash)]
226/// Includes all of its attributes and doc comments. 339pub struct WhereClause {
227///
228/// ```
229/// ❰
230/// /// Docs
231/// #[attr]
232/// pub enum Foo<T> where T: Debug {
233/// /// Docs
234/// #[attr]
235/// Bar,
236/// Baz(#[attr] u32),
237/// Bruh {
238/// a: u32,
239/// /// Docs
240/// #[attr]
241/// b: T,
242/// }
243/// }
244/// ❱
245/// ```
246///
247/// [Reference](https://doc.rust-lang.org/reference/items/enumerations.html)
248#[derive(Debug, Clone, PartialEq, Eq, Hash)]
249pub struct EnumDef {
250 pub(crate) syntax: SyntaxNode, 340 pub(crate) syntax: SyntaxNode,
251} 341}
252impl ast::VisibilityOwner for EnumDef {} 342impl WhereClause {
253impl ast::NameOwner for EnumDef {} 343 pub fn where_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![where]) }
254impl ast::TypeParamsOwner for EnumDef {} 344 pub fn predicates(&self) -> AstChildren<WherePred> { support::children(&self.syntax) }
255impl ast::AttrsOwner for EnumDef {} 345}
256impl ast::DocCommentsOwner for EnumDef {} 346#[derive(Debug, Clone, PartialEq, Eq, Hash)]
257impl EnumDef { 347pub struct BlockExpr {
258 pub fn enum_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![enum]) }
259 pub fn variant_list(&self) -> Option<EnumVariantList> { support::child(&self.syntax) }
260}
261/// Enum variant definition list including enclosing curly braces.
262///
263/// ```
264/// enum Foo
265/// ❰
266/// {
267/// Bar,
268/// Baz(u32),
269/// Bruh {
270/// a: u32
271/// }
272/// }
273/// ❱
274/// ```
275///
276/// [Reference](https://doc.rust-lang.org/reference/items/enumerations.html)
277#[derive(Debug, Clone, PartialEq, Eq, Hash)]
278pub struct EnumVariantList {
279 pub(crate) syntax: SyntaxNode, 348 pub(crate) syntax: SyntaxNode,
280} 349}
281impl EnumVariantList { 350impl ast::AttrsOwner for BlockExpr {}
351impl ast::ModuleItemOwner for BlockExpr {}
352impl BlockExpr {
353 pub fn label(&self) -> Option<Label> { support::child(&self.syntax) }
282 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } 354 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
283 pub fn variants(&self) -> AstChildren<EnumVariant> { support::children(&self.syntax) } 355 pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) }
356 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
284 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } 357 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
285} 358}
286/// Enum variant definition including its attributes and discriminant value definition. 359#[derive(Debug, Clone, PartialEq, Eq, Hash)]
287/// 360pub struct SelfParam {
288/// ```
289/// enum Foo {
290/// ❰
291/// /// Docs
292/// #[attr]
293/// Bar
294/// ❱
295///
296/// // same for tuple and record variants
297/// }
298/// ```
299///
300/// [Reference](https://doc.rust-lang.org/reference/items/enumerations.html)
301#[derive(Debug, Clone, PartialEq, Eq, Hash)]
302pub struct EnumVariant {
303 pub(crate) syntax: SyntaxNode, 361 pub(crate) syntax: SyntaxNode,
304} 362}
305impl ast::VisibilityOwner for EnumVariant {} 363impl ast::AttrsOwner for SelfParam {}
306impl ast::NameOwner for EnumVariant {} 364impl SelfParam {
307impl ast::DocCommentsOwner for EnumVariant {} 365 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
308impl ast::AttrsOwner for EnumVariant {} 366 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
309impl EnumVariant { 367 support::token(&self.syntax, T![lifetime])
310 pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) } 368 }
311 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 369 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
312 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 370 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
371 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
372 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) }
313} 373}
314/// Trait definition. 374#[derive(Debug, Clone, PartialEq, Eq, Hash)]
315/// Includes all of its attributes and doc comments. 375pub struct Param {
316///
317/// ```
318/// ❰
319/// /// Docs
320/// #[attr]
321/// pub unsafe trait Foo<T>: Debug where T: Debug {
322/// // ...
323/// }
324/// ❱
325/// ```
326///
327/// [Reference](https://doc.rust-lang.org/reference/items/traits.html)
328#[derive(Debug, Clone, PartialEq, Eq, Hash)]
329pub struct TraitDef {
330 pub(crate) syntax: SyntaxNode, 376 pub(crate) syntax: SyntaxNode,
331} 377}
332impl ast::VisibilityOwner for TraitDef {} 378impl ast::AttrsOwner for Param {}
333impl ast::NameOwner for TraitDef {} 379impl Param {
334impl ast::AttrsOwner for TraitDef {} 380 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
335impl ast::DocCommentsOwner for TraitDef {} 381 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
336impl ast::TypeParamsOwner for TraitDef {} 382 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) }
337impl ast::TypeBoundsOwner for TraitDef {} 383 pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) }
338impl TraitDef {
339 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
340 pub fn auto_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![auto]) }
341 pub fn trait_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![trait]) }
342 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
343} 384}
344/// Module definition either with body or not.
345/// Includes all of its inner and outer attributes, module items, doc comments.
346///
347/// ```
348/// ❰
349/// /// Docs
350/// #[attr]
351/// pub mod foo;
352/// ❱
353///
354/// ❰
355/// /// Docs
356/// #[attr]
357/// pub mod bar {
358/// //! Inner docs
359/// #![inner_attr]
360/// }
361/// ❱
362/// ```
363///
364/// [Reference](https://doc.rust-lang.org/reference/items/modules.html)
365#[derive(Debug, Clone, PartialEq, Eq, Hash)] 385#[derive(Debug, Clone, PartialEq, Eq, Hash)]
366pub struct Module { 386pub struct TypeBoundList {
367 pub(crate) syntax: SyntaxNode, 387 pub(crate) syntax: SyntaxNode,
368} 388}
369impl ast::VisibilityOwner for Module {} 389impl TypeBoundList {
370impl ast::NameOwner for Module {} 390 pub fn bounds(&self) -> AstChildren<TypeBound> { support::children(&self.syntax) }
371impl ast::AttrsOwner for Module {}
372impl ast::DocCommentsOwner for Module {}
373impl Module {
374 pub fn mod_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mod]) }
375 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
376 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
377} 391}
378/// Item defintion list.
379/// This is used for both top-level items and impl block items.
380///
381/// ```
382/// ❰
383/// fn foo {}
384/// struct Bar;
385/// enum Baz;
386/// trait Bruh;
387/// const BRUUH: u32 = 42;
388/// ❱
389///
390/// impl Foo
391/// ❰
392/// {
393/// fn bar() {}
394/// const BAZ: u32 = 42;
395/// }
396/// ❱
397/// ```
398///
399/// [Reference](https://doc.rust-lang.org/reference/items.html)
400#[derive(Debug, Clone, PartialEq, Eq, Hash)] 392#[derive(Debug, Clone, PartialEq, Eq, Hash)]
401pub struct ItemList { 393pub struct RecordFieldList {
402 pub(crate) syntax: SyntaxNode, 394 pub(crate) syntax: SyntaxNode,
403} 395}
404impl ast::ModuleItemOwner for ItemList {} 396impl RecordFieldList {
405impl ItemList {
406 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } 397 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
407 pub fn assoc_items(&self) -> AstChildren<AssocItem> { support::children(&self.syntax) } 398 pub fn fields(&self) -> AstChildren<RecordField> { support::children(&self.syntax) }
408 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } 399 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
409} 400}
410/// Constant variable definition. 401#[derive(Debug, Clone, PartialEq, Eq, Hash)]
411/// Includes all of its attributes and doc comments. 402pub struct TupleFieldList {
412///
413/// ```
414/// ❰
415/// /// Docs
416/// #[attr]
417/// pub const FOO: u32 = 42;
418/// ❱
419/// ```
420///
421/// [Reference](https://doc.rust-lang.org/reference/items/constant-items.html)
422#[derive(Debug, Clone, PartialEq, Eq, Hash)]
423pub struct ConstDef {
424 pub(crate) syntax: SyntaxNode, 403 pub(crate) syntax: SyntaxNode,
425} 404}
426impl ast::VisibilityOwner for ConstDef {} 405impl TupleFieldList {
427impl ast::NameOwner for ConstDef {} 406 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
428impl ast::TypeParamsOwner for ConstDef {} 407 pub fn fields(&self) -> AstChildren<TupleField> { support::children(&self.syntax) }
429impl ast::AttrsOwner for ConstDef {} 408 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
430impl ast::DocCommentsOwner for ConstDef {} 409}
431impl ast::TypeAscriptionOwner for ConstDef {} 410#[derive(Debug, Clone, PartialEq, Eq, Hash)]
432impl ConstDef { 411pub struct RecordField {
433 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } 412 pub(crate) syntax: SyntaxNode,
434 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } 413}
435 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 414impl ast::AttrsOwner for RecordField {}
436 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } 415impl ast::NameOwner for RecordField {}
437 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 416impl ast::VisibilityOwner for RecordField {}
417impl RecordField {
418 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
419 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) }
438} 420}
439/// Static variable definition. 421#[derive(Debug, Clone, PartialEq, Eq, Hash)]
440/// Includes all of its attributes and doc comments. 422pub struct TupleField {
441///
442/// ```
443/// ❰
444/// /// Docs
445/// #[attr]
446/// pub static mut FOO: u32 = 42;
447/// ❱
448/// ```
449///
450/// [Reference](https://doc.rust-lang.org/reference/items/static-items.html)
451#[derive(Debug, Clone, PartialEq, Eq, Hash)]
452pub struct StaticDef {
453 pub(crate) syntax: SyntaxNode, 423 pub(crate) syntax: SyntaxNode,
454} 424}
455impl ast::VisibilityOwner for StaticDef {} 425impl ast::AttrsOwner for TupleField {}
456impl ast::NameOwner for StaticDef {} 426impl ast::VisibilityOwner for TupleField {}
457impl ast::TypeParamsOwner for StaticDef {} 427impl TupleField {
458impl ast::AttrsOwner for StaticDef {} 428 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) }
459impl ast::DocCommentsOwner for StaticDef {} 429}
460impl ast::TypeAscriptionOwner for StaticDef {} 430#[derive(Debug, Clone, PartialEq, Eq, Hash)]
461impl StaticDef { 431pub struct VariantList {
462 pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) } 432 pub(crate) syntax: SyntaxNode,
463 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } 433}
434impl VariantList {
435 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
436 pub fn variants(&self) -> AstChildren<Variant> { support::children(&self.syntax) }
437 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
438}
439#[derive(Debug, Clone, PartialEq, Eq, Hash)]
440pub struct Variant {
441 pub(crate) syntax: SyntaxNode,
442}
443impl ast::AttrsOwner for Variant {}
444impl ast::NameOwner for Variant {}
445impl ast::VisibilityOwner for Variant {}
446impl Variant {
447 pub fn field_list(&self) -> Option<FieldList> { support::child(&self.syntax) }
464 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 448 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
465 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } 449 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
466 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
467} 450}
468/// Type alias definition. 451#[derive(Debug, Clone, PartialEq, Eq, Hash)]
469/// Includes associated type clauses with type bounds. 452pub struct AssocItemList {
470///
471/// ```
472/// ❰
473/// /// Docs
474/// #[attr]
475/// pub type Foo<T> where T: Debug = T;
476/// ❱
477///
478/// trait Bar {
479/// ❰ type Baz: Debug; ❱
480/// ❰ type Bruh = String; ❱
481/// ❰ type Bruuh: Debug = u32; ❱
482/// }
483/// ```
484///
485/// [Reference](https://doc.rust-lang.org/reference/items/type-aliases.html)
486#[derive(Debug, Clone, PartialEq, Eq, Hash)]
487pub struct TypeAliasDef {
488 pub(crate) syntax: SyntaxNode, 453 pub(crate) syntax: SyntaxNode,
489} 454}
490impl ast::VisibilityOwner for TypeAliasDef {} 455impl ast::AttrsOwner for AssocItemList {}
491impl ast::NameOwner for TypeAliasDef {} 456impl AssocItemList {
492impl ast::TypeParamsOwner for TypeAliasDef {} 457 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
493impl ast::AttrsOwner for TypeAliasDef {} 458 pub fn assoc_items(&self) -> AstChildren<AssocItem> { support::children(&self.syntax) }
494impl ast::DocCommentsOwner for TypeAliasDef {} 459 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
495impl ast::TypeBoundsOwner for TypeAliasDef {} 460}
496impl TypeAliasDef { 461#[derive(Debug, Clone, PartialEq, Eq, Hash)]
497 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } 462pub struct ExternItemList {
498 pub fn type_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![type]) } 463 pub(crate) syntax: SyntaxNode,
464}
465impl ast::AttrsOwner for ExternItemList {}
466impl ExternItemList {
467 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
468 pub fn extern_items(&self) -> AstChildren<ExternItem> { support::children(&self.syntax) }
469 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
470}
471#[derive(Debug, Clone, PartialEq, Eq, Hash)]
472pub struct LifetimeParam {
473 pub(crate) syntax: SyntaxNode,
474}
475impl ast::AttrsOwner for LifetimeParam {}
476impl LifetimeParam {
477 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
478 support::token(&self.syntax, T![lifetime])
479 }
480}
481#[derive(Debug, Clone, PartialEq, Eq, Hash)]
482pub struct TypeParam {
483 pub(crate) syntax: SyntaxNode,
484}
485impl ast::AttrsOwner for TypeParam {}
486impl ast::NameOwner for TypeParam {}
487impl ast::TypeBoundsOwner for TypeParam {}
488impl TypeParam {
499 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 489 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
500 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 490 pub fn default_type(&self) -> Option<TypeRef> { support::child(&self.syntax) }
501 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
502} 491}
503/// Inherent and trait impl definition. 492#[derive(Debug, Clone, PartialEq, Eq, Hash)]
504/// Includes all of its inner and outer attributes. 493pub struct ConstParam {
505///
506/// ```
507/// ❰
508/// #[attr]
509/// unsafe impl<T> const !Foo for Bar where T: Debug {
510/// #![inner_attr]
511/// // ...
512/// }
513/// ❱
514/// ```
515///
516/// [Reference](https://doc.rust-lang.org/reference/items/implementations.html)
517#[derive(Debug, Clone, PartialEq, Eq, Hash)]
518pub struct ImplDef {
519 pub(crate) syntax: SyntaxNode, 494 pub(crate) syntax: SyntaxNode,
520} 495}
521impl ast::TypeParamsOwner for ImplDef {} 496impl ast::AttrsOwner for ConstParam {}
522impl ast::AttrsOwner for ImplDef {} 497impl ast::NameOwner for ConstParam {}
523impl ast::DocCommentsOwner for ImplDef {} 498impl ConstParam {
524impl ImplDef {
525 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
526 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } 499 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
527 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) } 500 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
528 pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) } 501 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) }
529 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) } 502 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
530 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) } 503 pub fn default_val(&self) -> Option<Expr> { support::child(&self.syntax) }
531 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } 504}
505#[derive(Debug, Clone, PartialEq, Eq, Hash)]
506pub struct Literal {
507 pub(crate) syntax: SyntaxNode,
508}
509impl Literal {}
510#[derive(Debug, Clone, PartialEq, Eq, Hash)]
511pub struct TokenTree {
512 pub(crate) syntax: SyntaxNode,
513}
514impl TokenTree {
515 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
516 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
517 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
518 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
519 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
520 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
532} 521}
533/// Parenthesized type reference.
534/// Note: parens are only used for grouping, this is not a tuple type.
535///
536/// ```
537/// // This is effectively just `u32`.
538/// // Single-item tuple must be defined with a trailing comma: `(u32,)`
539/// type Foo = ❰ (u32) ❱;
540///
541/// let bar: &'static ❰ (dyn Debug) ❱ = "bruh";
542/// ```
543#[derive(Debug, Clone, PartialEq, Eq, Hash)] 522#[derive(Debug, Clone, PartialEq, Eq, Hash)]
544pub struct ParenType { 523pub struct ParenType {
545 pub(crate) syntax: SyntaxNode, 524 pub(crate) syntax: SyntaxNode,
546} 525}
547impl ParenType { 526impl ParenType {
548 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } 527 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
549 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 528 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) }
550 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 529 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
551} 530}
552/// Unnamed tuple type.
553///
554/// ```
555/// let foo: ❰ (u32, bool) ❱ = (42, true);
556/// ```
557///
558/// [Reference](https://doc.rust-lang.org/reference/types/tuple.html)
559#[derive(Debug, Clone, PartialEq, Eq, Hash)] 531#[derive(Debug, Clone, PartialEq, Eq, Hash)]
560pub struct TupleType { 532pub struct TupleType {
561 pub(crate) syntax: SyntaxNode, 533 pub(crate) syntax: SyntaxNode,
@@ -565,17 +537,6 @@ impl TupleType {
565 pub fn fields(&self) -> AstChildren<TypeRef> { support::children(&self.syntax) } 537 pub fn fields(&self) -> AstChildren<TypeRef> { support::children(&self.syntax) }
566 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 538 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
567} 539}
568/// The never type (i.e. the exclamation point).
569///
570/// ```
571/// type T = ❰ ! ❱;
572///
573/// fn no_return() -> ❰ ! ❱ {
574/// loop {}
575/// }
576/// ```
577///
578/// [Reference](https://doc.rust-lang.org/reference/types/never.html)
579#[derive(Debug, Clone, PartialEq, Eq, Hash)] 540#[derive(Debug, Clone, PartialEq, Eq, Hash)]
580pub struct NeverType { 541pub struct NeverType {
581 pub(crate) syntax: SyntaxNode, 542 pub(crate) syntax: SyntaxNode,
@@ -583,17 +544,6 @@ pub struct NeverType {
583impl NeverType { 544impl NeverType {
584 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) } 545 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
585} 546}
586/// Path to a type.
587/// Includes single identifier type names and elaborate paths with
588/// generic parameters.
589///
590/// ```
591/// type Foo = ❰ String ❱;
592/// type Bar = ❰ std::vec::Vec<T> ❱;
593/// type Baz = ❰ ::bruh::<Bruuh as Iterator>::Item ❱;
594/// ```
595///
596/// [Reference](https://doc.rust-lang.org/reference/paths.html)
597#[derive(Debug, Clone, PartialEq, Eq, Hash)] 547#[derive(Debug, Clone, PartialEq, Eq, Hash)]
598pub struct PathType { 548pub struct PathType {
599 pub(crate) syntax: SyntaxNode, 549 pub(crate) syntax: SyntaxNode,
@@ -601,14 +551,6 @@ pub struct PathType {
601impl PathType { 551impl PathType {
602 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 552 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
603} 553}
604/// Raw pointer type.
605///
606/// ```
607/// type Foo = ❰ *const u32 ❱;
608/// type Bar = ❰ *mut u32 ❱;
609/// ```
610///
611/// [Reference](https://doc.rust-lang.org/reference/types/pointer.html#raw-pointers-const-and-mut)
612#[derive(Debug, Clone, PartialEq, Eq, Hash)] 554#[derive(Debug, Clone, PartialEq, Eq, Hash)]
613pub struct PointerType { 555pub struct PointerType {
614 pub(crate) syntax: SyntaxNode, 556 pub(crate) syntax: SyntaxNode,
@@ -617,49 +559,28 @@ impl PointerType {
617 pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) } 559 pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) }
618 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } 560 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
619 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } 561 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
620 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 562 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) }
621} 563}
622/// Array type.
623///
624/// ```
625/// type Foo = ❰ [u32; 24 - 3] ❱;
626/// ```
627///
628/// [Reference](https://doc.rust-lang.org/reference/types/array.html)
629#[derive(Debug, Clone, PartialEq, Eq, Hash)] 564#[derive(Debug, Clone, PartialEq, Eq, Hash)]
630pub struct ArrayType { 565pub struct ArrayType {
631 pub(crate) syntax: SyntaxNode, 566 pub(crate) syntax: SyntaxNode,
632} 567}
633impl ArrayType { 568impl ArrayType {
634 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } 569 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
635 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 570 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) }
636 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 571 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
637 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 572 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
638 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } 573 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
639} 574}
640/// Slice type.
641///
642/// ```
643/// type Foo = ❰ [u8] ❱;
644/// ```
645///
646/// [Reference](https://doc.rust-lang.org/reference/types/slice.html)
647#[derive(Debug, Clone, PartialEq, Eq, Hash)] 575#[derive(Debug, Clone, PartialEq, Eq, Hash)]
648pub struct SliceType { 576pub struct SliceType {
649 pub(crate) syntax: SyntaxNode, 577 pub(crate) syntax: SyntaxNode,
650} 578}
651impl SliceType { 579impl SliceType {
652 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } 580 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
653 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 581 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) }
654 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } 582 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
655} 583}
656/// Reference type.
657///
658/// ```
659/// type Foo = ❰ &'static str ❱;
660/// ```
661///
662/// [Reference](https://doc.rust-lang.org/reference/types/pointer.html)
663#[derive(Debug, Clone, PartialEq, Eq, Hash)] 584#[derive(Debug, Clone, PartialEq, Eq, Hash)]
664pub struct ReferenceType { 585pub struct ReferenceType {
665 pub(crate) syntax: SyntaxNode, 586 pub(crate) syntax: SyntaxNode,
@@ -670,15 +591,8 @@ impl ReferenceType {
670 support::token(&self.syntax, T![lifetime]) 591 support::token(&self.syntax, T![lifetime])
671 } 592 }
672 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } 593 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
673 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 594 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) }
674} 595}
675/// Placeholder type (i.e. the underscore).
676///
677/// ```
678/// let foo: ❰ _ ❱ = 42_u32;
679/// ```
680///
681/// [Reference](https://doc.rust-lang.org/reference/types/inferred.html)
682#[derive(Debug, Clone, PartialEq, Eq, Hash)] 596#[derive(Debug, Clone, PartialEq, Eq, Hash)]
683pub struct PlaceholderType { 597pub struct PlaceholderType {
684 pub(crate) syntax: SyntaxNode, 598 pub(crate) syntax: SyntaxNode,
@@ -686,15 +600,6 @@ pub struct PlaceholderType {
686impl PlaceholderType { 600impl PlaceholderType {
687 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) } 601 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) }
688} 602}
689/// Function pointer type (not to be confused with `Fn*` family of traits).
690///
691/// ```
692/// type Foo = ❰ async fn(#[attr] u32, named: bool) -> u32 ❱;
693///
694/// type Bar = ❰ extern "C" fn(variadic: u32, #[attr] ...) ❱;
695/// ```
696///
697/// [Reference](https://doc.rust-lang.org/reference/types/function-pointer.html)
698#[derive(Debug, Clone, PartialEq, Eq, Hash)] 603#[derive(Debug, Clone, PartialEq, Eq, Hash)]
699pub struct FnPointerType { 604pub struct FnPointerType {
700 pub(crate) syntax: SyntaxNode, 605 pub(crate) syntax: SyntaxNode,
@@ -706,59 +611,31 @@ impl FnPointerType {
706 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } 611 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
707 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } 612 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
708} 613}
709/// Higher order type.
710///
711/// ```
712/// type Foo = ❰ for<'a> fn(&'a str) ❱;
713/// ```
714///
715/// [Reference](https://doc.rust-lang.org/nomicon/hrtb.html)
716#[derive(Debug, Clone, PartialEq, Eq, Hash)] 614#[derive(Debug, Clone, PartialEq, Eq, Hash)]
717pub struct ForType { 615pub struct ForType {
718 pub(crate) syntax: SyntaxNode, 616 pub(crate) syntax: SyntaxNode,
719} 617}
720impl ForType { 618impl ForType {
721 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) } 619 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }
722 pub fn type_param_list(&self) -> Option<TypeParamList> { support::child(&self.syntax) } 620 pub fn generic_param_list(&self) -> Option<GenericParamList> { support::child(&self.syntax) }
723 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 621 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) }
724} 622}
725/// Opaque `impl Trait` type.
726///
727/// ```
728/// fn foo(bar: ❰ impl Debug + Eq ❱) {}
729/// ```
730///
731/// [Reference](https://doc.rust-lang.org/reference/types/impl-trait.html)
732#[derive(Debug, Clone, PartialEq, Eq, Hash)] 623#[derive(Debug, Clone, PartialEq, Eq, Hash)]
733pub struct ImplTraitType { 624pub struct ImplTraitType {
734 pub(crate) syntax: SyntaxNode, 625 pub(crate) syntax: SyntaxNode,
735} 626}
736impl ast::TypeBoundsOwner for ImplTraitType {}
737impl ImplTraitType { 627impl ImplTraitType {
738 pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) } 628 pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) }
629 pub fn type_bound_list(&self) -> Option<TypeBoundList> { support::child(&self.syntax) }
739} 630}
740/// Trait object type.
741///
742/// ```
743/// type Foo = ❰ dyn Debug ❱;
744/// ```
745///
746/// [Reference](https://doc.rust-lang.org/reference/types/trait-object.html)
747#[derive(Debug, Clone, PartialEq, Eq, Hash)] 631#[derive(Debug, Clone, PartialEq, Eq, Hash)]
748pub struct DynTraitType { 632pub struct DynTraitType {
749 pub(crate) syntax: SyntaxNode, 633 pub(crate) syntax: SyntaxNode,
750} 634}
751impl ast::TypeBoundsOwner for DynTraitType {}
752impl DynTraitType { 635impl DynTraitType {
753 pub fn dyn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![dyn]) } 636 pub fn dyn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![dyn]) }
637 pub fn type_bound_list(&self) -> Option<TypeBoundList> { support::child(&self.syntax) }
754} 638}
755/// Tuple literal.
756///
757/// ```
758/// ❰ (42, true) ❱;
759/// ```
760///
761/// [Reference](https://doc.rust-lang.org/reference/expressions/tuple-expr.html)
762#[derive(Debug, Clone, PartialEq, Eq, Hash)] 639#[derive(Debug, Clone, PartialEq, Eq, Hash)]
763pub struct TupleExpr { 640pub struct TupleExpr {
764 pub(crate) syntax: SyntaxNode, 641 pub(crate) syntax: SyntaxNode,
@@ -769,15 +646,6 @@ impl TupleExpr {
769 pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) } 646 pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
770 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 647 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
771} 648}
772/// Array literal.
773///
774/// ```
775/// ❰ [#![inner_attr] true, false, true] ❱;
776///
777/// ❰ ["baz"; 24] ❱;
778/// ```
779///
780/// [Reference](https://doc.rust-lang.org/reference/expressions/array-expr.html)
781#[derive(Debug, Clone, PartialEq, Eq, Hash)] 649#[derive(Debug, Clone, PartialEq, Eq, Hash)]
782pub struct ArrayExpr { 650pub struct ArrayExpr {
783 pub(crate) syntax: SyntaxNode, 651 pub(crate) syntax: SyntaxNode,
@@ -786,17 +654,10 @@ impl ast::AttrsOwner for ArrayExpr {}
786impl ArrayExpr { 654impl ArrayExpr {
787 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } 655 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
788 pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) } 656 pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
657 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
789 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 658 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
790 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } 659 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
791} 660}
792/// Parenthesized expression.
793/// Note: parens are only used for grouping, this is not a tuple literal.
794///
795/// ```
796/// ❰ (#![inner_attr] 2 + 2) ❱ * 2;
797/// ```
798///
799/// [Reference](https://doc.rust-lang.org/reference/expressions/grouped-expr.html)
800#[derive(Debug, Clone, PartialEq, Eq, Hash)] 661#[derive(Debug, Clone, PartialEq, Eq, Hash)]
801pub struct ParenExpr { 662pub struct ParenExpr {
802 pub(crate) syntax: SyntaxNode, 663 pub(crate) syntax: SyntaxNode,
@@ -807,19 +668,6 @@ impl ParenExpr {
807 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 668 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
808 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 669 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
809} 670}
810/// Path to a symbol in expression context.
811/// Includes single identifier variable names and elaborate paths with
812/// generic parameters.
813///
814/// ```
815/// ❰ Some::<i32> ❱;
816/// ❰ foo ❱ + 42;
817/// ❰ Vec::<i32>::push ❱;
818/// ❰ <[i32]>::reverse ❱;
819/// ❰ <String as std::borrow::Borrow<str>>::borrow ❱;
820/// ```
821///
822/// [Reference](https://doc.rust-lang.org/reference/expressions/path-expr.html)
823#[derive(Debug, Clone, PartialEq, Eq, Hash)] 671#[derive(Debug, Clone, PartialEq, Eq, Hash)]
824pub struct PathExpr { 672pub struct PathExpr {
825 pub(crate) syntax: SyntaxNode, 673 pub(crate) syntax: SyntaxNode,
@@ -827,17 +675,6 @@ pub struct PathExpr {
827impl PathExpr { 675impl PathExpr {
828 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 676 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
829} 677}
830/// Anonymous callable object literal a.k.a. closure, lambda or functor.
831///
832/// ```
833/// ❰ || 42 ❱;
834/// ❰ |a: u32| val + 1 ❱;
835/// ❰ async |#[attr] Pattern(_): Pattern| { bar } ❱;
836/// ❰ move || baz ❱;
837/// ❰ || -> u32 { closure_with_ret_type_annotation_requires_block_expr } ❱
838/// ```
839///
840/// [Reference](https://doc.rust-lang.org/reference/expressions/closure-expr.html)
841#[derive(Debug, Clone, PartialEq, Eq, Hash)] 678#[derive(Debug, Clone, PartialEq, Eq, Hash)]
842pub struct LambdaExpr { 679pub struct LambdaExpr {
843 pub(crate) syntax: SyntaxNode, 680 pub(crate) syntax: SyntaxNode,
@@ -851,25 +688,6 @@ impl LambdaExpr {
851 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } 688 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
852 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } 689 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
853} 690}
854/// If expression. Includes both regular `if` and `if let` forms.
855/// Beware that `else if` is a special case syntax sugar, because in general
856/// there has to be block expression after `else`.
857///
858/// ```
859/// ❰ if bool_cond { 42 } ❱
860/// ❰ if bool_cond { 42 } else { 24 } ❱
861/// ❰ if bool_cond { 42 } else if bool_cond2 { 42 } ❱
862///
863/// ❰
864/// if let Pattern(foo) = bar {
865/// foo
866/// } else {
867/// panic!();
868/// }
869/// ❱
870/// ```
871///
872/// [Reference](https://doc.rust-lang.org/reference/expressions/if-expr.html)
873#[derive(Debug, Clone, PartialEq, Eq, Hash)] 691#[derive(Debug, Clone, PartialEq, Eq, Hash)]
874pub struct IfExpr { 692pub struct IfExpr {
875 pub(crate) syntax: SyntaxNode, 693 pub(crate) syntax: SyntaxNode,
@@ -879,40 +697,16 @@ impl IfExpr {
879 pub fn if_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![if]) } 697 pub fn if_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![if]) }
880 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) } 698 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) }
881} 699}
882/// Unconditional loop expression.
883///
884/// ```
885/// ❰
886/// loop {
887/// // yeah, it's that simple...
888/// }
889/// ❱
890/// ```
891///
892/// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html)
893#[derive(Debug, Clone, PartialEq, Eq, Hash)] 700#[derive(Debug, Clone, PartialEq, Eq, Hash)]
894pub struct LoopExpr { 701pub struct Condition {
895 pub(crate) syntax: SyntaxNode, 702 pub(crate) syntax: SyntaxNode,
896} 703}
897impl ast::AttrsOwner for LoopExpr {} 704impl Condition {
898impl ast::LoopBodyOwner for LoopExpr {} 705 pub fn let_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![let]) }
899impl LoopExpr { 706 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
900 pub fn loop_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![loop]) } 707 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
708 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
901} 709}
902/// Block expression with an optional prefix (label, try ketword,
903/// unsafe keyword, async keyword...).
904///
905/// ```
906/// ❰
907/// 'label: try {
908/// None?
909/// }
910/// ❱
911/// ```
912///
913/// - [try block](https://doc.rust-lang.org/unstable-book/language-features/try-blocks.html)
914/// - [unsafe block](https://doc.rust-lang.org/reference/expressions/block-expr.html#unsafe-blocks)
915/// - [async block](https://doc.rust-lang.org/reference/expressions/block-expr.html#async-blocks)
916#[derive(Debug, Clone, PartialEq, Eq, Hash)] 710#[derive(Debug, Clone, PartialEq, Eq, Hash)]
917pub struct EffectExpr { 711pub struct EffectExpr {
918 pub(crate) syntax: SyntaxNode, 712 pub(crate) syntax: SyntaxNode,
@@ -925,19 +719,24 @@ impl EffectExpr {
925 pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) } 719 pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) }
926 pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) } 720 pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
927} 721}
928/// For loop expression. 722#[derive(Debug, Clone, PartialEq, Eq, Hash)]
929/// Note: record struct literals are not valid as iterable expression 723pub struct Label {
930/// due to ambiguity. 724 pub(crate) syntax: SyntaxNode,
931/// 725}
932/// ``` 726impl Label {
933/// ❰ 727 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
934/// for i in (0..4) { 728 support::token(&self.syntax, T![lifetime])
935/// dbg!(i); 729 }
936/// } 730}
937/// ❱ 731#[derive(Debug, Clone, PartialEq, Eq, Hash)]
938/// ``` 732pub struct LoopExpr {
939/// 733 pub(crate) syntax: SyntaxNode,
940/// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html#iterator-loops) 734}
735impl ast::AttrsOwner for LoopExpr {}
736impl ast::LoopBodyOwner for LoopExpr {}
737impl LoopExpr {
738 pub fn loop_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![loop]) }
739}
941#[derive(Debug, Clone, PartialEq, Eq, Hash)] 740#[derive(Debug, Clone, PartialEq, Eq, Hash)]
942pub struct ForExpr { 741pub struct ForExpr {
943 pub(crate) syntax: SyntaxNode, 742 pub(crate) syntax: SyntaxNode,
@@ -950,22 +749,6 @@ impl ForExpr {
950 pub fn in_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![in]) } 749 pub fn in_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![in]) }
951 pub fn iterable(&self) -> Option<Expr> { support::child(&self.syntax) } 750 pub fn iterable(&self) -> Option<Expr> { support::child(&self.syntax) }
952} 751}
953/// While loop expression. Includes both regular `while` and `while let` forms.
954///
955/// ```
956/// ❰
957/// while bool_cond {
958/// 42;
959/// }
960/// ❱
961/// ❰
962/// while let Pattern(foo) = bar {
963/// bar += 1;
964/// }
965/// ❱
966/// ```
967///
968/// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html#predicate-loops)
969#[derive(Debug, Clone, PartialEq, Eq, Hash)] 752#[derive(Debug, Clone, PartialEq, Eq, Hash)]
970pub struct WhileExpr { 753pub struct WhileExpr {
971 pub(crate) syntax: SyntaxNode, 754 pub(crate) syntax: SyntaxNode,
@@ -976,22 +759,6 @@ impl WhileExpr {
976 pub fn while_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![while]) } 759 pub fn while_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![while]) }
977 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) } 760 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) }
978} 761}
979/// Continue expression.
980///
981/// ```
982/// while bool_cond {
983/// ❰ continue ❱;
984/// }
985///
986/// 'outer: loop {
987/// loop {
988/// ❰ continue 'outer ❱;
989/// }
990/// }
991///
992/// ```
993///
994/// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html#continue-expressions)
995#[derive(Debug, Clone, PartialEq, Eq, Hash)] 762#[derive(Debug, Clone, PartialEq, Eq, Hash)]
996pub struct ContinueExpr { 763pub struct ContinueExpr {
997 pub(crate) syntax: SyntaxNode, 764 pub(crate) syntax: SyntaxNode,
@@ -1005,25 +772,6 @@ impl ContinueExpr {
1005 support::token(&self.syntax, T![lifetime]) 772 support::token(&self.syntax, T![lifetime])
1006 } 773 }
1007} 774}
1008/// Break expression.
1009///
1010/// ```
1011/// while bool_cond {
1012/// ❰ break ❱;
1013/// }
1014/// 'outer: loop {
1015/// for foo in bar {
1016/// ❰ break 'outer ❱;
1017/// }
1018/// }
1019/// 'outer: loop {
1020/// loop {
1021/// ❰ break 'outer 42 ❱;
1022/// }
1023/// }
1024/// ```
1025///
1026/// [Refernce](https://doc.rust-lang.org/reference/expressions/loop-expr.html#break-expressions)
1027#[derive(Debug, Clone, PartialEq, Eq, Hash)] 775#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1028pub struct BreakExpr { 776pub struct BreakExpr {
1029 pub(crate) syntax: SyntaxNode, 777 pub(crate) syntax: SyntaxNode,
@@ -1036,104 +784,33 @@ impl BreakExpr {
1036 } 784 }
1037 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 785 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1038} 786}
1039/// Label.
1040///
1041/// ```
1042/// ❰ 'outer: ❱ loop {}
1043///
1044/// let foo = ❰ 'bar: ❱ loop {}
1045///
1046/// ❰ 'baz: ❱ {
1047/// break 'baz;
1048/// }
1049/// ```
1050///
1051/// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html?highlight=label#loop-labels)
1052/// [Labels for blocks RFC](https://github.com/rust-lang/rfcs/blob/master/text/2046-label-break-value.md)
1053#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1054pub struct Label {
1055 pub(crate) syntax: SyntaxNode,
1056}
1057impl Label {
1058 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
1059 support::token(&self.syntax, T![lifetime])
1060 }
1061}
1062/// Block expression. Includes unsafe blocks and block labels.
1063///
1064/// ```
1065/// let foo = ❰
1066/// {
1067/// #![inner_attr]
1068/// ❰ { } ❱
1069///
1070/// ❰ 'label: { break 'label } ❱
1071/// }
1072/// ❱;
1073/// ```
1074///
1075/// [Reference](https://doc.rust-lang.org/reference/expressions/block-expr.html)
1076/// [Labels for blocks RFC](https://github.com/rust-lang/rfcs/blob/master/text/2046-label-break-value.md)
1077#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1078pub struct BlockExpr {
1079 pub(crate) syntax: SyntaxNode,
1080}
1081impl ast::AttrsOwner for BlockExpr {}
1082impl ast::ModuleItemOwner for BlockExpr {}
1083impl BlockExpr {
1084 pub fn label(&self) -> Option<Label> { support::child(&self.syntax) }
1085 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
1086 pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) }
1087 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1088 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1089}
1090/// Return expression.
1091///
1092/// ```
1093/// || ❰ return 42 ❱;
1094///
1095/// fn bar() {
1096/// ❰ return ❱;
1097/// }
1098/// ```
1099///
1100/// [Reference](https://doc.rust-lang.org/reference/expressions/return-expr.html)
1101#[derive(Debug, Clone, PartialEq, Eq, Hash)] 787#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1102pub struct ReturnExpr { 788pub struct ReturnExpr {
1103 pub(crate) syntax: SyntaxNode, 789 pub(crate) syntax: SyntaxNode,
1104} 790}
1105impl ast::AttrsOwner for ReturnExpr {} 791impl ast::AttrsOwner for ReturnExpr {}
1106impl ReturnExpr { 792impl ReturnExpr {
793 pub fn return_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![return]) }
1107 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 794 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1108} 795}
1109/// Call expression (not to be confused with method call expression, it is
1110/// a separate ast node).
1111///
1112/// ```
1113/// ❰ foo() ❱;
1114/// ❰ &str::len("bar") ❱;
1115/// ❰ <&str as PartialEq<&str>>::eq(&"", &"") ❱;
1116/// ```
1117///
1118/// [Reference](https://doc.rust-lang.org/reference/expressions/call-expr.html)
1119#[derive(Debug, Clone, PartialEq, Eq, Hash)] 796#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1120pub struct CallExpr { 797pub struct CallExpr {
1121 pub(crate) syntax: SyntaxNode, 798 pub(crate) syntax: SyntaxNode,
1122} 799}
800impl ast::AttrsOwner for CallExpr {}
1123impl ast::ArgListOwner for CallExpr {} 801impl ast::ArgListOwner for CallExpr {}
1124impl CallExpr { 802impl CallExpr {
1125 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 803 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1126} 804}
1127/// Method call expression. 805#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1128/// 806pub struct ArgList {
1129/// ``` 807 pub(crate) syntax: SyntaxNode,
1130/// ❰ receiver_expr.method() ❱; 808}
1131/// ❰ receiver_expr.method::<T>(42, true) ❱; 809impl ArgList {
1132/// 810 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
1133/// ❰ ❰ ❰ foo.bar() ❱ .baz() ❱ .bruh() ❱; 811 pub fn args(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
1134/// ``` 812 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1135/// 813}
1136/// [Reference](https://doc.rust-lang.org/reference/expressions/method-call-expr.html)
1137#[derive(Debug, Clone, PartialEq, Eq, Hash)] 814#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1138pub struct MethodCallExpr { 815pub struct MethodCallExpr {
1139 pub(crate) syntax: SyntaxNode, 816 pub(crate) syntax: SyntaxNode,
@@ -1146,31 +823,19 @@ impl MethodCallExpr {
1146 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } 823 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
1147 pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) } 824 pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) }
1148} 825}
1149/// Index expression a.k.a. subscript operator call.
1150///
1151/// ```
1152/// ❰ foo[42] ❱;
1153/// ```
1154///
1155/// [Reference](https://doc.rust-lang.org/reference/expressions/array-expr.html)
1156#[derive(Debug, Clone, PartialEq, Eq, Hash)] 826#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1157pub struct IndexExpr { 827pub struct TypeArgList {
1158 pub(crate) syntax: SyntaxNode, 828 pub(crate) syntax: SyntaxNode,
1159} 829}
1160impl ast::AttrsOwner for IndexExpr {} 830impl TypeArgList {
1161impl IndexExpr { 831 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
1162 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } 832 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) }
1163 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } 833 pub fn type_args(&self) -> AstChildren<TypeArg> { support::children(&self.syntax) }
834 pub fn lifetime_args(&self) -> AstChildren<LifetimeArg> { support::children(&self.syntax) }
835 pub fn assoc_type_args(&self) -> AstChildren<AssocTypeArg> { support::children(&self.syntax) }
836 pub fn const_args(&self) -> AstChildren<ConstArg> { support::children(&self.syntax) }
837 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
1164} 838}
1165/// Field access expression.
1166///
1167/// ```
1168/// ❰ expr.bar ❱;
1169///
1170/// ❰ ❰ ❰ foo.bar ❱ .baz ❱ .bruh ❱;
1171/// ```
1172///
1173/// [Reference](https://doc.rust-lang.org/reference/expressions/field-expr.html)
1174#[derive(Debug, Clone, PartialEq, Eq, Hash)] 839#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1175pub struct FieldExpr { 840pub struct FieldExpr {
1176 pub(crate) syntax: SyntaxNode, 841 pub(crate) syntax: SyntaxNode,
@@ -1181,13 +846,15 @@ impl FieldExpr {
1181 pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) } 846 pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) }
1182 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } 847 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
1183} 848}
1184/// Await operator call expression. 849#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1185/// 850pub struct IndexExpr {
1186/// ``` 851 pub(crate) syntax: SyntaxNode,
1187/// ❰ expr.await ❱; 852}
1188/// ``` 853impl ast::AttrsOwner for IndexExpr {}
1189/// 854impl IndexExpr {
1190/// [Reference](https://doc.rust-lang.org/reference/expressions/await-expr.html) 855 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
856 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
857}
1191#[derive(Debug, Clone, PartialEq, Eq, Hash)] 858#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1192pub struct AwaitExpr { 859pub struct AwaitExpr {
1193 pub(crate) syntax: SyntaxNode, 860 pub(crate) syntax: SyntaxNode,
@@ -1198,13 +865,6 @@ impl AwaitExpr {
1198 pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) } 865 pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) }
1199 pub fn await_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![await]) } 866 pub fn await_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![await]) }
1200} 867}
1201/// The question mark operator call.
1202///
1203/// ```
1204/// ❰ expr? ❱;
1205/// ```
1206///
1207/// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#the-question-mark-operator)
1208#[derive(Debug, Clone, PartialEq, Eq, Hash)] 868#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1209pub struct TryExpr { 869pub struct TryExpr {
1210 pub(crate) syntax: SyntaxNode, 870 pub(crate) syntax: SyntaxNode,
@@ -1214,13 +874,6 @@ impl TryExpr {
1214 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 874 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1215 pub fn question_mark_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![?]) } 875 pub fn question_mark_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![?]) }
1216} 876}
1217/// Type cast expression.
1218///
1219/// ```
1220/// ❰ expr as T ❱;
1221/// ```
1222///
1223/// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#type-cast-expressions)
1224#[derive(Debug, Clone, PartialEq, Eq, Hash)] 877#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1225pub struct CastExpr { 878pub struct CastExpr {
1226 pub(crate) syntax: SyntaxNode, 879 pub(crate) syntax: SyntaxNode,
@@ -1229,18 +882,8 @@ impl ast::AttrsOwner for CastExpr {}
1229impl CastExpr { 882impl CastExpr {
1230 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 883 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1231 pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) } 884 pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) }
1232 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 885 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) }
1233} 886}
1234/// Borrow operator call.
1235///
1236/// ```
1237/// ❰ &foo ❱;
1238/// ❰ &mut bar ❱;
1239/// ❰ &raw const bar ❱;
1240/// ❰ &raw mut bar ❱;
1241/// ```
1242///
1243/// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#borrow-operators)
1244#[derive(Debug, Clone, PartialEq, Eq, Hash)] 887#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1245pub struct RefExpr { 888pub struct RefExpr {
1246 pub(crate) syntax: SyntaxNode, 889 pub(crate) syntax: SyntaxNode,
@@ -1253,15 +896,6 @@ impl RefExpr {
1253 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } 896 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
1254 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 897 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1255} 898}
1256/// Prefix operator call. This is either `!` or `*` or `-`.
1257///
1258/// ```
1259/// ❰ !foo ❱;
1260/// ❰ *bar ❱;
1261/// ❰ -42 ❱;
1262/// ```
1263///
1264/// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html)
1265#[derive(Debug, Clone, PartialEq, Eq, Hash)] 899#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1266pub struct PrefixExpr { 900pub struct PrefixExpr {
1267 pub(crate) syntax: SyntaxNode, 901 pub(crate) syntax: SyntaxNode,
@@ -1270,13 +904,6 @@ impl ast::AttrsOwner for PrefixExpr {}
1270impl PrefixExpr { 904impl PrefixExpr {
1271 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 905 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1272} 906}
1273/// Box operator call.
1274///
1275/// ```
1276/// ❰ box 42 ❱;
1277/// ```
1278///
1279/// [RFC](https://github.com/rust-lang/rfcs/blob/0806be4f282144cfcd55b1d20284b43f87cbe1c6/text/0809-box-and-in-for-stdlib.md)
1280#[derive(Debug, Clone, PartialEq, Eq, Hash)] 907#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1281pub struct BoxExpr { 908pub struct BoxExpr {
1282 pub(crate) syntax: SyntaxNode, 909 pub(crate) syntax: SyntaxNode,
@@ -1286,69 +913,18 @@ impl BoxExpr {
1286 pub fn box_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![box]) } 913 pub fn box_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![box]) }
1287 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 914 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1288} 915}
1289/// Range operator call.
1290///
1291/// ```
1292/// ❰ 0..42 ❱;
1293/// ❰ ..42 ❱;
1294/// ❰ 0.. ❱;
1295/// ❰ .. ❱;
1296/// ❰ 0..=42 ❱;
1297/// ❰ ..=42 ❱;
1298/// ```
1299///
1300/// [Reference](https://doc.rust-lang.org/reference/expressions/range-expr.html)
1301#[derive(Debug, Clone, PartialEq, Eq, Hash)] 916#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1302pub struct RangeExpr { 917pub struct RangeExpr {
1303 pub(crate) syntax: SyntaxNode, 918 pub(crate) syntax: SyntaxNode,
1304} 919}
1305impl ast::AttrsOwner for RangeExpr {} 920impl ast::AttrsOwner for RangeExpr {}
1306impl RangeExpr {} 921impl RangeExpr {}
1307/// Binary operator call.
1308/// Includes all arithmetic, logic, bitwise and assignment operators.
1309///
1310/// ```
1311/// ❰ 2 + ❰ 2 * 2 ❱ ❱;
1312/// ❰ ❰ true && false ❱ || true ❱;
1313/// ```
1314///
1315/// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#arithmetic-and-logical-binary-operators)
1316#[derive(Debug, Clone, PartialEq, Eq, Hash)] 922#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1317pub struct BinExpr { 923pub struct BinExpr {
1318 pub(crate) syntax: SyntaxNode, 924 pub(crate) syntax: SyntaxNode,
1319} 925}
1320impl ast::AttrsOwner for BinExpr {} 926impl ast::AttrsOwner for BinExpr {}
1321impl BinExpr {} 927impl BinExpr {}
1322/// [Raw] string, [raw] byte string, char, byte, integer, float or bool literal.
1323///
1324/// ```
1325/// ❰ "str" ❱;
1326/// ❰ br##"raw byte str"## ❱;
1327/// ❰ 'c' ❱;
1328/// ❰ b'c' ❱;
1329/// ❰ 42 ❱;
1330/// ❰ 1e9 ❱;
1331/// ❰ true ❱;
1332/// ```
1333///
1334/// [Reference](https://doc.rust-lang.org/reference/expressions/literal-expr.html)
1335#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1336pub struct Literal {
1337 pub(crate) syntax: SyntaxNode,
1338}
1339impl Literal {}
1340/// Match expression.
1341///
1342/// ```
1343/// ❰
1344/// match expr {
1345/// Pat1 => {}
1346/// Pat2(_) => 42,
1347/// }
1348/// ❱
1349/// ```
1350///
1351/// [Reference](https://doc.rust-lang.org/reference/expressions/match-expr.html)
1352#[derive(Debug, Clone, PartialEq, Eq, Hash)] 928#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1353pub struct MatchExpr { 929pub struct MatchExpr {
1354 pub(crate) syntax: SyntaxNode, 930 pub(crate) syntax: SyntaxNode,
@@ -1359,40 +935,15 @@ impl MatchExpr {
1359 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 935 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1360 pub fn match_arm_list(&self) -> Option<MatchArmList> { support::child(&self.syntax) } 936 pub fn match_arm_list(&self) -> Option<MatchArmList> { support::child(&self.syntax) }
1361} 937}
1362/// Match arm list part of match expression. Includes its inner attributes.
1363///
1364/// ```
1365/// match expr
1366/// ❰
1367/// {
1368/// #![inner_attr]
1369/// Pat1 => {}
1370/// Pat2(_) => 42,
1371/// }
1372/// ❱
1373/// ```
1374///
1375/// [Reference](https://doc.rust-lang.org/reference/expressions/match-expr.html)
1376#[derive(Debug, Clone, PartialEq, Eq, Hash)] 938#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1377pub struct MatchArmList { 939pub struct MatchArmList {
1378 pub(crate) syntax: SyntaxNode, 940 pub(crate) syntax: SyntaxNode,
1379} 941}
1380impl ast::AttrsOwner for MatchArmList {}
1381impl MatchArmList { 942impl MatchArmList {
1382 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } 943 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
1383 pub fn arms(&self) -> AstChildren<MatchArm> { support::children(&self.syntax) } 944 pub fn arms(&self) -> AstChildren<MatchArm> { support::children(&self.syntax) }
1384 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } 945 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1385} 946}
1386/// Match arm.
1387/// Note: record struct literals are not valid as target match expression
1388/// due to ambiguity.
1389/// ```
1390/// match expr {
1391/// ❰ #[attr] Pattern(it) if bool_cond => it ❱,
1392/// }
1393/// ```
1394///
1395/// [Reference](https://doc.rust-lang.org/reference/expressions/match-expr.html)
1396#[derive(Debug, Clone, PartialEq, Eq, Hash)] 947#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1397pub struct MatchArm { 948pub struct MatchArm {
1398 pub(crate) syntax: SyntaxNode, 949 pub(crate) syntax: SyntaxNode,
@@ -1404,15 +955,6 @@ impl MatchArm {
1404 pub fn fat_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=>]) } 955 pub fn fat_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=>]) }
1405 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 956 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1406} 957}
1407/// Match guard.
1408///
1409/// ```
1410/// match expr {
1411/// Pattern(it) ❰ if bool_cond ❱ => it,
1412/// }
1413/// ```
1414///
1415/// [Reference](https://doc.rust-lang.org/reference/expressions/match-expr.html#match-guards)
1416#[derive(Debug, Clone, PartialEq, Eq, Hash)] 958#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1417pub struct MatchGuard { 959pub struct MatchGuard {
1418 pub(crate) syntax: SyntaxNode, 960 pub(crate) syntax: SyntaxNode,
@@ -1421,76 +963,37 @@ impl MatchGuard {
1421 pub fn if_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![if]) } 963 pub fn if_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![if]) }
1422 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 964 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1423} 965}
1424/// Record literal expression. The same syntax is used for structs, 966#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1425/// unions and record enum variants. 967pub struct RecordExpr {
1426///
1427/// ```
1428/// ❰
1429/// foo::Bar {
1430/// #![inner_attr]
1431/// baz: 42,
1432/// bruh: true,
1433/// ..spread
1434/// }
1435/// ❱
1436/// ```
1437///
1438/// [Reference](https://doc.rust-lang.org/reference/expressions/struct-expr.html)
1439#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1440pub struct RecordLit {
1441 pub(crate) syntax: SyntaxNode, 968 pub(crate) syntax: SyntaxNode,
1442} 969}
1443impl RecordLit { 970impl RecordExpr {
1444 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 971 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1445 pub fn record_field_list(&self) -> Option<RecordFieldList> { support::child(&self.syntax) } 972 pub fn record_expr_field_list(&self) -> Option<RecordExprFieldList> {
973 support::child(&self.syntax)
974 }
1446} 975}
1447/// Record field list including enclosing curly braces.
1448///
1449/// foo::Bar ❰
1450/// {
1451/// baz: 42,
1452/// ..spread
1453/// }
1454/// ❱
1455///
1456/// [Reference](https://doc.rust-lang.org/reference/expressions/struct-expr.html)
1457#[derive(Debug, Clone, PartialEq, Eq, Hash)] 976#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1458pub struct RecordFieldList { 977pub struct RecordExprFieldList {
1459 pub(crate) syntax: SyntaxNode, 978 pub(crate) syntax: SyntaxNode,
1460} 979}
1461impl RecordFieldList { 980impl RecordExprFieldList {
1462 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } 981 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
1463 pub fn fields(&self) -> AstChildren<RecordField> { support::children(&self.syntax) } 982 pub fn fields(&self) -> AstChildren<RecordExprField> { support::children(&self.syntax) }
1464 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) } 983 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) }
1465 pub fn spread(&self) -> Option<Expr> { support::child(&self.syntax) } 984 pub fn spread(&self) -> Option<Expr> { support::child(&self.syntax) }
1466 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } 985 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1467} 986}
1468/// Record field.
1469///
1470/// ```
1471/// foo::Bar {
1472/// ❰ #[attr] baz: 42 ❱
1473/// }
1474/// ```
1475///
1476/// [Reference](https://doc.rust-lang.org/reference/expressions/struct-expr.html)
1477#[derive(Debug, Clone, PartialEq, Eq, Hash)] 987#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1478pub struct RecordField { 988pub struct RecordExprField {
1479 pub(crate) syntax: SyntaxNode, 989 pub(crate) syntax: SyntaxNode,
1480} 990}
1481impl ast::AttrsOwner for RecordField {} 991impl ast::AttrsOwner for RecordExprField {}
1482impl RecordField { 992impl RecordExprField {
1483 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } 993 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
1484 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } 994 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
1485 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 995 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1486} 996}
1487/// Disjunction of patterns.
1488///
1489/// ```
1490/// let ❰ Foo(it) | Bar(it) | Baz(it) ❱ = bruh;
1491/// ```
1492///
1493/// [Reference](https://doc.rust-lang.org/reference/patterns.html)
1494#[derive(Debug, Clone, PartialEq, Eq, Hash)] 997#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1495pub struct OrPat { 998pub struct OrPat {
1496 pub(crate) syntax: SyntaxNode, 999 pub(crate) syntax: SyntaxNode,
@@ -1498,14 +1001,6 @@ pub struct OrPat {
1498impl OrPat { 1001impl OrPat {
1499 pub fn pats(&self) -> AstChildren<Pat> { support::children(&self.syntax) } 1002 pub fn pats(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1500} 1003}
1501/// Parenthesized pattern.
1502/// Note: parens are only used for grouping, this is not a tuple pattern.
1503///
1504/// ```
1505/// if let ❰ &(0..=42) ❱ = foo {}
1506/// ```
1507///
1508/// https://doc.rust-lang.org/reference/patterns.html#grouped-patterns
1509#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1004#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1510pub struct ParenPat { 1005pub struct ParenPat {
1511 pub(crate) syntax: SyntaxNode, 1006 pub(crate) syntax: SyntaxNode,
@@ -1515,16 +1010,6 @@ impl ParenPat {
1515 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 1010 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1516 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 1011 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1517} 1012}
1518/// Reference pattern.
1519/// Note: this has nothing to do with `ref` keyword, the latter is used in bind patterns.
1520///
1521/// ```
1522/// let ❰ &mut foo ❱ = bar;
1523///
1524/// let ❰ & ❰ &mut ❰ &_ ❱ ❱ ❱ = baz;
1525/// ```
1526///
1527/// [Reference](https://doc.rust-lang.org/reference/patterns.html#reference-patterns)
1528#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1013#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1529pub struct RefPat { 1014pub struct RefPat {
1530 pub(crate) syntax: SyntaxNode, 1015 pub(crate) syntax: SyntaxNode,
@@ -1534,31 +1019,14 @@ impl RefPat {
1534 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } 1019 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
1535 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 1020 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1536} 1021}
1537/// Box pattern.
1538///
1539/// ```
1540/// let ❰ box foo ❱ = box 42;
1541/// ```
1542///
1543/// [Unstable book](https://doc.rust-lang.org/unstable-book/language-features/box-patterns.html)
1544#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1022#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1545pub struct BoxPat { 1023pub struct BoxPat {
1546 pub(crate) syntax: SyntaxNode, 1024 pub(crate) syntax: SyntaxNode,
1547} 1025}
1548impl BoxPat { 1026impl BoxPat {
1549 pub fn box_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![box]) } 1027 pub fn box_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![box]) }
1550 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 1028 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1551} 1029}
1552/// Bind pattern.
1553///
1554/// ```
1555/// match foo {
1556/// Some(❰ ref mut bar ❱) => {}
1557/// ❰ baz @ None ❱ => {}
1558/// }
1559/// ```
1560///
1561/// [Reference](https://doc.rust-lang.org/reference/patterns.html#identifier-patterns)
1562#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1030#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1563pub struct BindPat { 1031pub struct BindPat {
1564 pub(crate) syntax: SyntaxNode, 1032 pub(crate) syntax: SyntaxNode,
@@ -1571,13 +1039,6 @@ impl BindPat {
1571 pub fn at_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![@]) } 1039 pub fn at_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![@]) }
1572 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 1040 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1573} 1041}
1574/// Placeholder pattern a.k.a. the wildcard pattern or the underscore.
1575///
1576/// ```
1577/// let ❰ _ ❱ = foo;
1578/// ```
1579///
1580/// [Reference](https://doc.rust-lang.org/reference/patterns.html#wildcard-pattern)
1581#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1042#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1582pub struct PlaceholderPat { 1043pub struct PlaceholderPat {
1583 pub(crate) syntax: SyntaxNode, 1044 pub(crate) syntax: SyntaxNode,
@@ -1585,16 +1046,6 @@ pub struct PlaceholderPat {
1585impl PlaceholderPat { 1046impl PlaceholderPat {
1586 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) } 1047 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) }
1587} 1048}
1588/// Rest-of-the record/tuple pattern.
1589/// Note: this is not the unbonded range pattern (even more: it doesn't exist).
1590///
1591/// ```
1592/// let Foo { bar, ❰ .. ❱ } = baz;
1593/// let (❰ .. ❱, bruh) = (42, 24, 42);
1594/// let Bruuh(❰ .. ❱) = bruuuh;
1595/// ```
1596///
1597/// [Reference](https://doc.rust-lang.org/reference/patterns.html#struct-patterns)
1598#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1049#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1599pub struct DotDotPat { 1050pub struct DotDotPat {
1600 pub(crate) syntax: SyntaxNode, 1051 pub(crate) syntax: SyntaxNode,
@@ -1602,15 +1053,6 @@ pub struct DotDotPat {
1602impl DotDotPat { 1053impl DotDotPat {
1603 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) } 1054 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) }
1604} 1055}
1605/// Path pattern.
1606/// Doesn't include the underscore pattern (it is a special case, namely `PlaceholderPat`).
1607///
1608/// ```
1609/// let ❰ foo::bar::Baz ❱ { .. } = bruh;
1610/// if let ❰ CONST ❱ = 42 {}
1611/// ```
1612///
1613/// [Reference](https://doc.rust-lang.org/reference/patterns.html#path-patterns)
1614#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1056#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1615pub struct PathPat { 1057pub struct PathPat {
1616 pub(crate) syntax: SyntaxNode, 1058 pub(crate) syntax: SyntaxNode,
@@ -1618,13 +1060,6 @@ pub struct PathPat {
1618impl PathPat { 1060impl PathPat {
1619 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 1061 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1620} 1062}
1621/// Slice pattern.
1622///
1623/// ```
1624/// let ❰ [foo, bar, baz] ❱ = [1, 2, 3];
1625/// ```
1626///
1627/// [Reference](https://doc.rust-lang.org/reference/patterns.html#slice-patterns)
1628#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1063#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1629pub struct SlicePat { 1064pub struct SlicePat {
1630 pub(crate) syntax: SyntaxNode, 1065 pub(crate) syntax: SyntaxNode,
@@ -1634,33 +1069,14 @@ impl SlicePat {
1634 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) } 1069 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1635 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } 1070 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
1636} 1071}
1637/// Range pattern.
1638///
1639/// ```
1640/// match foo {
1641/// ❰ 0..42 ❱ => {}
1642/// ❰ 0..=42 ❱ => {}
1643/// }
1644/// ```
1645///
1646/// [Reference](https://doc.rust-lang.org/reference/patterns.html#range-patterns)
1647#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1072#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1648pub struct RangePat { 1073pub struct RangePat {
1649 pub(crate) syntax: SyntaxNode, 1074 pub(crate) syntax: SyntaxNode,
1650} 1075}
1651impl RangePat {} 1076impl RangePat {
1652/// Literal pattern. 1077 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) }
1653/// Includes only bool, number, char, and string literals. 1078 pub fn dotdoteq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..=]) }
1654/// 1079}
1655/// ```
1656/// match foo {
1657/// Number(❰ 42 ❱) => {}
1658/// String(❰ "42" ❱) => {}
1659/// Bool(❰ true ❱) => {}
1660/// }
1661/// ```
1662///
1663/// [Reference](https://doc.rust-lang.org/reference/patterns.html#literal-patterns)
1664#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1080#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1665pub struct LiteralPat { 1081pub struct LiteralPat {
1666 pub(crate) syntax: SyntaxNode, 1082 pub(crate) syntax: SyntaxNode,
@@ -1668,13 +1084,6 @@ pub struct LiteralPat {
1668impl LiteralPat { 1084impl LiteralPat {
1669 pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) } 1085 pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) }
1670} 1086}
1671/// Macro invocation in pattern position.
1672///
1673/// ```
1674/// let ❰ foo!(my custom syntax) ❱ = baz;
1675///
1676/// ```
1677/// [Reference](https://doc.rust-lang.org/reference/macros.html#macro-invocation)
1678#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1087#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1679pub struct MacroPat { 1088pub struct MacroPat {
1680 pub(crate) syntax: SyntaxNode, 1089 pub(crate) syntax: SyntaxNode,
@@ -1682,37 +1091,22 @@ pub struct MacroPat {
1682impl MacroPat { 1091impl MacroPat {
1683 pub fn macro_call(&self) -> Option<MacroCall> { support::child(&self.syntax) } 1092 pub fn macro_call(&self) -> Option<MacroCall> { support::child(&self.syntax) }
1684} 1093}
1685/// Record literal pattern.
1686///
1687/// ```
1688/// let ❰ foo::Bar { baz, .. } ❱ = bruh;
1689/// ```
1690///
1691/// [Reference](https://doc.rust-lang.org/reference/patterns.html#struct-patterns)
1692#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1094#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1693pub struct RecordPat { 1095pub struct RecordPat {
1694 pub(crate) syntax: SyntaxNode, 1096 pub(crate) syntax: SyntaxNode,
1695} 1097}
1696impl RecordPat { 1098impl RecordPat {
1099 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1697 pub fn record_field_pat_list(&self) -> Option<RecordFieldPatList> { 1100 pub fn record_field_pat_list(&self) -> Option<RecordFieldPatList> {
1698 support::child(&self.syntax) 1101 support::child(&self.syntax)
1699 } 1102 }
1700 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1701} 1103}
1702/// Record literal's field patterns list including enclosing curly braces.
1703///
1704/// ```
1705/// let foo::Bar ❰ { baz, bind @ bruh, .. } ❱ = bruuh;
1706/// ``
1707///
1708/// [Reference](https://doc.rust-lang.org/reference/patterns.html#struct-patterns)
1709#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1104#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1710pub struct RecordFieldPatList { 1105pub struct RecordFieldPatList {
1711 pub(crate) syntax: SyntaxNode, 1106 pub(crate) syntax: SyntaxNode,
1712} 1107}
1713impl RecordFieldPatList { 1108impl RecordFieldPatList {
1714 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } 1109 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
1715 pub fn pats(&self) -> AstChildren<RecordInnerPat> { support::children(&self.syntax) }
1716 pub fn record_field_pats(&self) -> AstChildren<RecordFieldPat> { 1110 pub fn record_field_pats(&self) -> AstChildren<RecordFieldPat> {
1717 support::children(&self.syntax) 1111 support::children(&self.syntax)
1718 } 1112 }
@@ -1720,15 +1114,6 @@ impl RecordFieldPatList {
1720 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) } 1114 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) }
1721 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } 1115 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1722} 1116}
1723/// Record literal's field pattern.
1724/// Note: record literal can also match tuple structs.
1725///
1726/// ```
1727/// let Foo { ❰ bar: _ ❱ } = baz;
1728/// let TupleStruct { ❰ 0: _ ❱ } = bruh;
1729/// ```
1730///
1731/// [Reference](https://doc.rust-lang.org/reference/patterns.html#struct-patterns)
1732#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1117#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1733pub struct RecordFieldPat { 1118pub struct RecordFieldPat {
1734 pub(crate) syntax: SyntaxNode, 1119 pub(crate) syntax: SyntaxNode,
@@ -1739,13 +1124,6 @@ impl RecordFieldPat {
1739 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } 1124 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
1740 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 1125 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1741} 1126}
1742/// Tuple struct literal pattern.
1743///
1744/// ```
1745/// let ❰ foo::Bar(baz, bruh) ❱ = bruuh;
1746/// ```
1747///
1748/// [Reference](https://doc.rust-lang.org/reference/patterns.html#tuple-struct-patterns)
1749#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1127#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1750pub struct TupleStructPat { 1128pub struct TupleStructPat {
1751 pub(crate) syntax: SyntaxNode, 1129 pub(crate) syntax: SyntaxNode,
@@ -1756,14 +1134,6 @@ impl TupleStructPat {
1756 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) } 1134 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1757 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 1135 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1758} 1136}
1759/// Tuple pattern.
1760/// Note: this doesn't include tuple structs (see `TupleStructPat`)
1761///
1762/// ```
1763/// let ❰ (foo, bar, .., baz) ❱ = bruh;
1764/// ```
1765///
1766/// [Reference](https://doc.rust-lang.org/reference/patterns.html#tuple-patterns)
1767#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1137#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1768pub struct TuplePat { 1138pub struct TuplePat {
1769 pub(crate) syntax: SyntaxNode, 1139 pub(crate) syntax: SyntaxNode,
@@ -1773,234 +1143,28 @@ impl TuplePat {
1773 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) } 1143 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1774 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 1144 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1775} 1145}
1776/// Visibility.
1777///
1778/// ```
1779/// ❰ pub mod ❱ foo;
1780/// ❰ pub(crate) ❱ struct Bar;
1781/// ❰ pub(self) ❱ enum Baz {}
1782/// ❰ pub(super) ❱ fn bruh() {}
1783/// ❰ pub(in bruuh::bruuuh) ❱ type T = u64;
1784/// ```
1785///
1786/// [Reference](https://doc.rust-lang.org/reference/visibility-and-privacy.html)
1787#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1788pub struct Visibility {
1789 pub(crate) syntax: SyntaxNode,
1790}
1791impl Visibility {
1792 pub fn pub_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![pub]) }
1793 pub fn super_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![super]) }
1794 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
1795 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
1796}
1797/// Single identifier.
1798/// Note(@matklad): `Name` is for things that install a new name into the scope,
1799/// `NameRef` is a usage of a name. Most of the time, this definition/reference
1800/// distinction can be determined purely syntactically, ie in
1801/// ```
1802/// fn foo() { foo() }
1803/// ```
1804/// the first foo is `Name`, the second one is `NameRef`.
1805/// The notable exception are patterns, where in
1806/// ``
1807/// let x = 92
1808/// ```
1809/// `x` can be semantically either a name or a name ref, depeding on
1810/// wether there's an `x` constant in scope.
1811/// We use `Name` for patterns, and disambiguate semantically (see `NameClass` in ide_db).
1812///
1813/// ```
1814/// let ❰ foo ❱ = bar;
1815/// struct ❰ Baz ❱;
1816/// fn ❰ bruh ❱() {}
1817/// ```
1818///
1819/// [Reference](https://doc.rust-lang.org/reference/identifiers.html)
1820#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1821pub struct Name {
1822 pub(crate) syntax: SyntaxNode,
1823}
1824impl Name {
1825 pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) }
1826}
1827/// Reference to a name.
1828/// See the explanation on the difference between `Name` and `NameRef`
1829/// in `Name` ast node docs.
1830///
1831/// ```
1832/// let foo = ❰ bar ❱(❰ Baz(❰ bruh ❱) ❱;
1833/// ```
1834///
1835/// [Reference](https://doc.rust-lang.org/reference/identifiers.html)
1836#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1837pub struct NameRef {
1838 pub(crate) syntax: SyntaxNode,
1839}
1840impl NameRef {}
1841/// Macro call.
1842/// Includes all of its attributes and doc comments.
1843///
1844/// ```
1845/// ❰
1846/// /// Docs
1847/// #[attr]
1848/// macro_rules! foo { // macro rules is also a macro call
1849/// ($bar: tt) => {}
1850/// }
1851/// ❱
1852///
1853/// // semicolon is a part of `MacroCall` when it is used in item positions
1854/// ❰ foo!(); ❱
1855///
1856/// fn main() {
1857/// ❰ foo!() ❱; // macro call in expression positions doesn't include the semi
1858/// }
1859/// ```
1860///
1861/// [Reference](https://doc.rust-lang.org/reference/macros.html)
1862#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1146#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1863pub struct MacroCall { 1147pub struct MacroDef {
1864 pub(crate) syntax: SyntaxNode, 1148 pub(crate) syntax: SyntaxNode,
1865} 1149}
1866impl ast::NameOwner for MacroCall {} 1150impl ast::NameOwner for MacroDef {}
1867impl ast::AttrsOwner for MacroCall {} 1151impl MacroDef {
1868impl ast::DocCommentsOwner for MacroCall {}
1869impl MacroCall {
1870 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1871 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
1872 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) } 1152 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
1873 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
1874}
1875/// Attribute.
1876///
1877/// ```
1878/// ❰ #![inner_attr] ❱
1879///
1880/// ❰ #[attr] ❱
1881/// ❰ #[foo = "bar"] ❱
1882/// ❰ #[baz(bruh::bruuh = "42")] ❱
1883/// struct Foo;
1884/// ```
1885///
1886/// [Reference](https://doc.rust-lang.org/reference/attributes.html)
1887#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1888pub struct Attr {
1889 pub(crate) syntax: SyntaxNode,
1890} 1153}
1891impl Attr {
1892 pub fn pound_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![#]) }
1893 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
1894 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
1895 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1896 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
1897 pub fn input(&self) -> Option<AttrInput> { support::child(&self.syntax) }
1898 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
1899}
1900/// Stores a list of lexer tokens and other `TokenTree`s.
1901/// It appears in attributes, macro_rules and macro call (foo!)
1902///
1903/// ```
1904/// macro_call! ❰ { my syntax here } ❱;
1905/// ```
1906///
1907/// [Reference](https://doc.rust-lang.org/reference/macros.html)
1908#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1154#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1909pub struct TokenTree { 1155pub struct MacroItems {
1910 pub(crate) syntax: SyntaxNode,
1911}
1912impl TokenTree {}
1913/// Generic lifetime, type and constants parameters list **declaration**.
1914///
1915/// ```
1916/// fn foo❰ <'a, 'b, T, U, const BAR: u64> ❱() {}
1917///
1918/// struct Baz❰ <T> ❱(T);
1919///
1920/// impl❰ <T> ❱ Bruh<T> {}
1921///
1922/// type Bruuh = for❰ <'a> ❱ fn(&'a str) -> &'a str;
1923/// ```
1924///
1925/// [Reference](https://doc.rust-lang.org/reference/items/generics.html)
1926#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1927pub struct TypeParamList {
1928 pub(crate) syntax: SyntaxNode,
1929}
1930impl TypeParamList {
1931 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) }
1932 pub fn generic_params(&self) -> AstChildren<GenericParam> { support::children(&self.syntax) }
1933 pub fn type_params(&self) -> AstChildren<TypeParam> { support::children(&self.syntax) }
1934 pub fn lifetime_params(&self) -> AstChildren<LifetimeParam> { support::children(&self.syntax) }
1935 pub fn const_params(&self) -> AstChildren<ConstParam> { support::children(&self.syntax) }
1936 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
1937}
1938/// Single type parameter **declaration**.
1939///
1940/// ```
1941/// fn foo<❰ K ❱, ❰ I ❱, ❰ E: Debug ❱, ❰ V = DefaultType ❱>() {}
1942/// ```
1943///
1944/// [Reference](https://doc.rust-lang.org/reference/items/generics.html)
1945#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1946pub struct TypeParam {
1947 pub(crate) syntax: SyntaxNode,
1948}
1949impl ast::NameOwner for TypeParam {}
1950impl ast::AttrsOwner for TypeParam {}
1951impl ast::TypeBoundsOwner for TypeParam {}
1952impl TypeParam {
1953 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
1954 pub fn default_type(&self) -> Option<TypeRef> { support::child(&self.syntax) }
1955}
1956/// Const generic parameter **declaration**.
1957/// ```
1958/// fn foo<T, U, ❰ const BAR: usize ❱, ❰ const BAZ: bool ❱>() {}
1959/// ```
1960///
1961/// [RFC](https://github.com/rust-lang/rfcs/blob/master/text/2000-const-generics.md#declaring-a-const-parameter)
1962#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1963pub struct ConstParam {
1964 pub(crate) syntax: SyntaxNode, 1156 pub(crate) syntax: SyntaxNode,
1965} 1157}
1966impl ast::NameOwner for ConstParam {} 1158impl ast::ModuleItemOwner for MacroItems {}
1967impl ast::AttrsOwner for ConstParam {} 1159impl MacroItems {}
1968impl ast::TypeAscriptionOwner for ConstParam {}
1969impl ConstParam {
1970 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
1971 pub fn default_val(&self) -> Option<Expr> { support::child(&self.syntax) }
1972}
1973/// Lifetime parameter **declaration**.
1974///
1975/// ```
1976/// fn foo<❰ 'a ❱, ❰ 'b ❱, V, G, D>(bar: &'a str, baz: &'b mut str) {}
1977/// ```
1978///
1979/// [Reference](https://doc.rust-lang.org/reference/items/generics.html)
1980#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1160#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1981pub struct LifetimeParam { 1161pub struct MacroStmts {
1982 pub(crate) syntax: SyntaxNode, 1162 pub(crate) syntax: SyntaxNode,
1983} 1163}
1984impl ast::AttrsOwner for LifetimeParam {} 1164impl MacroStmts {
1985impl LifetimeParam { 1165 pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) }
1986 pub fn lifetime_token(&self) -> Option<SyntaxToken> { 1166 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1987 support::token(&self.syntax, T![lifetime])
1988 }
1989} 1167}
1990/// Type bound declaration clause.
1991///
1992/// ```
1993/// fn foo<T: ❰ ?Sized ❱ + ❰ Debug ❱>() {}
1994///
1995/// trait Bar<T>
1996/// where
1997/// T: ❰ Send ❱ + ❰ Sync ❱
1998/// {
1999/// type Baz: ❰ !Sync ❱ + ❰ Debug ❱ + ❰ ?const Add ❱;
2000/// }
2001/// ```
2002///
2003/// [Reference](https://doc.rust-lang.org/reference/trait-bounds.html)
2004#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1168#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2005pub struct TypeBound { 1169pub struct TypeBound {
2006 pub(crate) syntax: SyntaxNode, 1170 pub(crate) syntax: SyntaxNode,
@@ -2012,40 +1176,6 @@ impl TypeBound {
2012 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } 1176 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
2013 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 1177 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2014} 1178}
2015/// Type bounds list.
2016///
2017/// ```
2018///
2019/// fn foo<T: ❰ ?Sized + Debug ❱>() {}
2020///
2021/// trait Bar<T>
2022/// where
2023/// T: ❰ Send + Sync ❱
2024/// {
2025/// type Baz: ❰ !Sync + Debug ❱;
2026/// }
2027/// ```
2028///
2029/// [Reference](https://doc.rust-lang.org/reference/trait-bounds.html)
2030#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2031pub struct TypeBoundList {
2032 pub(crate) syntax: SyntaxNode,
2033}
2034impl TypeBoundList {
2035 pub fn bounds(&self) -> AstChildren<TypeBound> { support::children(&self.syntax) }
2036}
2037/// Single where predicate.
2038///
2039/// ```
2040/// trait Foo<'a, 'b, T>
2041/// where
2042/// ❰ 'a: 'b ❱,
2043/// ❰ T: IntoIterator ❱,
2044/// ❰ for<'c> <T as IntoIterator>::Item: Bar<'c> ❱
2045/// {}
2046/// ```
2047///
2048/// [Reference](https://doc.rust-lang.org/reference/items/generics.html#where-clauses)
2049#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1179#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2050pub struct WherePred { 1180pub struct WherePred {
2051 pub(crate) syntax: SyntaxNode, 1181 pub(crate) syntax: SyntaxNode,
@@ -2053,64 +1183,12 @@ pub struct WherePred {
2053impl ast::TypeBoundsOwner for WherePred {} 1183impl ast::TypeBoundsOwner for WherePred {}
2054impl WherePred { 1184impl WherePred {
2055 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) } 1185 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }
2056 pub fn type_param_list(&self) -> Option<TypeParamList> { support::child(&self.syntax) } 1186 pub fn generic_param_list(&self) -> Option<GenericParamList> { support::child(&self.syntax) }
2057 pub fn lifetime_token(&self) -> Option<SyntaxToken> { 1187 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
2058 support::token(&self.syntax, T![lifetime]) 1188 support::token(&self.syntax, T![lifetime])
2059 } 1189 }
2060 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 1190 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2061} 1191}
2062/// Where clause.
2063///
2064/// ```
2065/// trait Foo<'a, T> ❰ where 'a: 'static, T: Debug ❱ {}
2066///
2067/// ```
2068///
2069/// [Reference](https://doc.rust-lang.org/reference/items/generics.html#where-clauses)
2070#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2071pub struct WhereClause {
2072 pub(crate) syntax: SyntaxNode,
2073}
2074impl WhereClause {
2075 pub fn where_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![where]) }
2076 pub fn predicates(&self) -> AstChildren<WherePred> { support::children(&self.syntax) }
2077}
2078/// Abi declaration.
2079/// Note: the abi string is optional.
2080///
2081/// ```
2082/// ❰ extern "C" ❱ {
2083/// fn foo() {}
2084/// }
2085///
2086/// type Bar = ❰ extern ❱ fn() -> u32;
2087///
2088/// type Baz = ❰ extern r#"stdcall"# ❱ fn() -> bool;
2089/// ```
2090///
2091/// - [Extern blocks reference](https://doc.rust-lang.org/reference/items/external-blocks.html)
2092/// - [FFI function pointers reference](https://doc.rust-lang.org/reference/items/functions.html#functions)
2093#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2094pub struct Abi {
2095 pub(crate) syntax: SyntaxNode,
2096}
2097impl Abi {}
2098/// Expression statement.
2099///
2100/// ```
2101/// ❰ 42; ❱
2102/// ❰ foo(); ❱
2103/// ❰ (); ❱
2104/// ❰ {}; ❱
2105///
2106/// // constructions with trailing curly brace can omit the semicolon
2107/// // but only when there are satements immediately after them (this is important!)
2108/// ❰ if bool_cond { } ❱
2109/// ❰ loop {} ❱
2110/// ❰ somestatment; ❱
2111/// ```
2112///
2113/// [Reference](https://doc.rust-lang.org/reference/statements.html)
2114#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1192#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2115pub struct ExprStmt { 1193pub struct ExprStmt {
2116 pub(crate) syntax: SyntaxNode, 1194 pub(crate) syntax: SyntaxNode,
@@ -2120,267 +1198,20 @@ impl ExprStmt {
2120 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1198 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
2121 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 1199 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
2122} 1200}
2123/// Let statement.
2124///
2125/// ```
2126/// ❰ #[attr] let foo; ❱
2127/// ❰ let bar: u64; ❱
2128/// ❰ let baz = 42; ❱
2129/// ❰ let bruh: bool = true; ❱
2130/// ```
2131///
2132/// [Reference](https://doc.rust-lang.org/reference/statements.html#let-statements)
2133#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1201#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2134pub struct LetStmt { 1202pub struct LetStmt {
2135 pub(crate) syntax: SyntaxNode, 1203 pub(crate) syntax: SyntaxNode,
2136} 1204}
2137impl ast::AttrsOwner for LetStmt {} 1205impl ast::AttrsOwner for LetStmt {}
2138impl ast::TypeAscriptionOwner for LetStmt {}
2139impl LetStmt { 1206impl LetStmt {
2140 pub fn let_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![let]) } 1207 pub fn let_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![let]) }
2141 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 1208 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1209 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
1210 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2142 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 1211 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
2143 pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) } 1212 pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) }
2144 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 1213 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
2145} 1214}
2146/// Condition of `if` or `while` expression.
2147///
2148/// ```
2149/// if ❰ true ❱ {}
2150/// if ❰ let Pat(foo) = bar ❱ {}
2151///
2152/// while ❰ true ❱ {}
2153/// while ❰ let Pat(baz) = bruh ❱ {}
2154/// ```
2155///
2156/// [If expression reference](https://doc.rust-lang.org/reference/expressions/if-expr.html)
2157/// [While expression reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html#predicate-loops)
2158#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2159pub struct Condition {
2160 pub(crate) syntax: SyntaxNode,
2161}
2162impl Condition {
2163 pub fn let_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![let]) }
2164 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
2165 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
2166 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
2167}
2168/// Parameter list **declaration**.
2169///
2170/// ```
2171/// fn foo❰ (a: u32, b: bool) ❱ -> u32 {}
2172/// let bar = ❰ |a, b| ❱ {};
2173///
2174/// impl Baz {
2175/// fn bruh❰ (&self, a: u32) ❱ {}
2176/// }
2177/// ```
2178///
2179/// [Reference](https://doc.rust-lang.org/reference/items/functions.html)ocs to codegen script
2180#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2181pub struct ParamList {
2182 pub(crate) syntax: SyntaxNode,
2183}
2184impl ParamList {
2185 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
2186 pub fn self_param(&self) -> Option<SelfParam> { support::child(&self.syntax) }
2187 pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) }
2188 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
2189}
2190/// Self parameter **declaration**.
2191///
2192/// ```
2193/// impl Bruh {
2194/// fn foo(❰ self ❱) {}
2195/// fn bar(❰ &self ❱) {}
2196/// fn baz(❰ &mut self ❱) {}
2197/// fn blah<'a>(❰ &'a self ❱) {}
2198/// fn blin(❰ self: Box<Self> ❱) {}
2199/// }
2200/// ```
2201///
2202/// [Reference](https://doc.rust-lang.org/reference/items/functions.html)
2203#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2204pub struct SelfParam {
2205 pub(crate) syntax: SyntaxNode,
2206}
2207impl ast::TypeAscriptionOwner for SelfParam {}
2208impl ast::AttrsOwner for SelfParam {}
2209impl SelfParam {
2210 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
2211 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
2212 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
2213 support::token(&self.syntax, T![lifetime])
2214 }
2215 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
2216}
2217/// Parameter **declaration**.
2218///
2219/// ```
2220/// fn foo(❰ #[attr] Pat(bar): Pat(u32) ❱, ❰ #[attr] _: bool ❱) {}
2221///
2222/// extern "C" {
2223/// fn bar(❰ baz: u32 ❱, ❰ ... ❱) -> u32;
2224/// }
2225/// ```
2226///
2227/// [Reference](https://doc.rust-lang.org/reference/items/functions.html)
2228#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2229pub struct Param {
2230 pub(crate) syntax: SyntaxNode,
2231}
2232impl ast::TypeAscriptionOwner for Param {}
2233impl ast::AttrsOwner for Param {}
2234impl Param {
2235 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
2236 pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) }
2237}
2238/// Use declaration.
2239///
2240/// ```
2241/// ❰ #[attr] pub use foo; ❱
2242/// ❰ use bar as baz; ❱
2243/// ❰ use bruh::{self, bruuh}; ❱
2244/// ❰ use { blin::blen, blah::* };
2245/// ```
2246///
2247/// [Reference](https://doc.rust-lang.org/reference/items/use-declarations.html)
2248#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2249pub struct UseItem {
2250 pub(crate) syntax: SyntaxNode,
2251}
2252impl ast::AttrsOwner for UseItem {}
2253impl ast::VisibilityOwner for UseItem {}
2254impl UseItem {
2255 pub fn use_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![use]) }
2256 pub fn use_tree(&self) -> Option<UseTree> { support::child(&self.syntax) }
2257}
2258/// Use tree.
2259///
2260/// ```
2261/// pub use ❰ foo::❰ * ❱ ❱;
2262/// use ❰ bar as baz ❱;
2263/// use ❰ bruh::bruuh::{ ❰ self ❱, ❰ blin ❱ } ❱;
2264/// use ❰ { ❰ blin::blen ❱ } ❱
2265/// ```
2266///
2267/// [Reference](https://doc.rust-lang.org/reference/items/use-declarations.html)
2268#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2269pub struct UseTree {
2270 pub(crate) syntax: SyntaxNode,
2271}
2272impl UseTree {
2273 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
2274 pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) }
2275 pub fn use_tree_list(&self) -> Option<UseTreeList> { support::child(&self.syntax) }
2276 pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) }
2277}
2278/// Item alias.
2279/// Note: this is not the type alias.
2280///
2281/// ```
2282/// use foo ❰ as bar ❱;
2283/// use baz::{bruh ❰ as _ ❱};
2284/// extern crate bruuh ❰ as blin ❱;
2285/// ```
2286///
2287/// [Reference](https://doc.rust-lang.org/reference/items/use-declarations.html)
2288#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2289pub struct Alias {
2290 pub(crate) syntax: SyntaxNode,
2291}
2292impl ast::NameOwner for Alias {}
2293impl Alias {
2294 pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) }
2295}
2296/// Sublist of use trees.
2297///
2298/// ```
2299/// use bruh::bruuh::❰ { ❰ self ❱, ❰ blin ❱ } ❱;
2300/// use ❰ { blin::blen::❰ {} ❱ } ❱
2301/// ```
2302///
2303/// [Reference](https://doc.rust-lang.org/reference/items/use-declarations.html)
2304#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2305pub struct UseTreeList {
2306 pub(crate) syntax: SyntaxNode,
2307}
2308impl UseTreeList {
2309 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
2310 pub fn use_trees(&self) -> AstChildren<UseTree> { support::children(&self.syntax) }
2311 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
2312}
2313/// Extern crate item.
2314///
2315/// ```
2316/// ❰ #[attr] pub extern crate foo; ❱
2317/// ❰ extern crate self as bar; ❱
2318/// ```
2319///
2320/// [Reference](https://doc.rust-lang.org/reference/items/extern-crates.html)
2321#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2322pub struct ExternCrateItem {
2323 pub(crate) syntax: SyntaxNode,
2324}
2325impl ast::AttrsOwner for ExternCrateItem {}
2326impl ast::VisibilityOwner for ExternCrateItem {}
2327impl ExternCrateItem {
2328 pub fn extern_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![extern]) }
2329 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
2330 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
2331 pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) }
2332}
2333/// Call site arguments list.
2334///
2335/// ```
2336/// foo::<T, U>❰ (42, true) ❱;
2337/// ```
2338///
2339/// [Reference](https://doc.rust-lang.org/reference/expressions/call-expr.html)
2340#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2341pub struct ArgList {
2342 pub(crate) syntax: SyntaxNode,
2343}
2344impl ArgList {
2345 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
2346 pub fn args(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
2347 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
2348}
2349/// Path to a symbol. Includes single identifier names and elaborate paths with
2350/// generic parameters.
2351///
2352/// ```
2353/// (0..10).❰ ❰ collect ❱ ::<Vec<_>> ❱();
2354/// ❰ ❰ ❰ Vec ❱ ::<u8> ❱ ::with_capacity ❱(1024);
2355/// ❰ ❰ <❰ Foo ❱ as ❰ ❰ bar ❱ ::Bar ❱> ❱ ::baz ❱();
2356/// ❰ ❰ <❰ bruh ❱> ❱ ::bruuh ❱();
2357/// ```
2358///
2359/// [Reference](https://doc.rust-lang.org/reference/paths.html)
2360#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2361pub struct Path {
2362 pub(crate) syntax: SyntaxNode,
2363}
2364impl Path {
2365 pub fn segment(&self) -> Option<PathSegment> { support::child(&self.syntax) }
2366 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
2367 pub fn qualifier(&self) -> Option<Path> { support::child(&self.syntax) }
2368}
2369/// Segment of the path to a symbol.
2370/// Only path segment of an absolute path holds the `::` token,
2371/// all other `::` tokens that connect path segments reside under `Path` itself.`
2372///
2373/// ```
2374/// (0..10).❰ collect ❱ :: ❰ <Vec<_>> ❱();
2375/// ❰ Vec ❱ :: ❰ <u8> ❱ :: ❰ with_capacity ❱(1024);
2376/// ❰ <❰ Foo ❱ as ❰ bar ❱ :: ❰ Bar ❱> ❱ :: ❰ baz ❱();
2377/// ❰ <❰ bruh ❱> ❱ :: ❰ bruuh ❱();
2378///
2379/// // Note that only in this case `::` token is inlcuded:
2380/// ❰ ::foo ❱;
2381/// ```
2382///
2383/// [Reference](https://doc.rust-lang.org/reference/paths.html)
2384#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1215#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2385pub struct PathSegment { 1216pub struct PathSegment {
2386 pub(crate) syntax: SyntaxNode, 1217 pub(crate) syntax: SyntaxNode,
@@ -2398,50 +1229,22 @@ impl PathSegment {
2398 pub fn path_type(&self) -> Option<PathType> { support::child(&self.syntax) } 1229 pub fn path_type(&self) -> Option<PathType> { support::child(&self.syntax) }
2399 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) } 1230 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
2400} 1231}
2401/// List of type arguments that are passed at generic instantiation site.
2402///
2403/// ```
2404/// type _ = Foo ❰ ::<'a, u64, Item = Bar, 42, {true}> ❱::Bar;
2405///
2406/// Vec❰ ::<bool> ❱::();
2407/// ```
2408///
2409/// [Reference](https://doc.rust-lang.org/reference/paths.html#paths-in-expressions)
2410#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1232#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2411pub struct TypeArgList { 1233pub struct TypeArg {
2412 pub(crate) syntax: SyntaxNode, 1234 pub(crate) syntax: SyntaxNode,
2413} 1235}
2414impl TypeArgList { 1236impl TypeArg {
2415 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) } 1237 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2416 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) }
2417 pub fn generic_args(&self) -> AstChildren<GenericArg> { support::children(&self.syntax) }
2418 pub fn type_args(&self) -> AstChildren<TypeArg> { support::children(&self.syntax) }
2419 pub fn lifetime_args(&self) -> AstChildren<LifetimeArg> { support::children(&self.syntax) }
2420 pub fn assoc_type_args(&self) -> AstChildren<AssocTypeArg> { support::children(&self.syntax) }
2421 pub fn const_args(&self) -> AstChildren<ConstArg> { support::children(&self.syntax) }
2422 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
2423} 1238}
2424/// Type argument that is passed at generic instantiation site.
2425///
2426/// ```
2427/// type _ = Foo::<'a, ❰ u64 ❱, ❰ bool ❱, Item = Bar, 42>::Baz;
2428/// ```
2429///
2430/// [Reference](https://doc.rust-lang.org/reference/paths.html#paths-in-expressions)
2431#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1239#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2432pub struct TypeArg { 1240pub struct LifetimeArg {
2433 pub(crate) syntax: SyntaxNode, 1241 pub(crate) syntax: SyntaxNode,
2434} 1242}
2435impl TypeArg { 1243impl LifetimeArg {
2436 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 1244 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
1245 support::token(&self.syntax, T![lifetime])
1246 }
2437} 1247}
2438/// Associated type argument that is passed at generic instantiation site.
2439/// ```
2440/// type Foo = Bar::<'a, u64, bool, ❰ Item = Baz ❱, 42>::Bruh;
2441///
2442/// trait Bruh<T>: Iterator<❰ Item: Debug ❱> {}
2443/// ```
2444///
2445#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1248#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2446pub struct AssocTypeArg { 1249pub struct AssocTypeArg {
2447 pub(crate) syntax: SyntaxNode, 1250 pub(crate) syntax: SyntaxNode,
@@ -2452,33 +1255,6 @@ impl AssocTypeArg {
2452 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 1255 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
2453 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 1256 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2454} 1257}
2455/// Lifetime argument that is passed at generic instantiation site.
2456///
2457/// ```
2458/// fn foo<'a>(s: &'a str) {
2459/// bar::<❰ 'a ❱>(s);
2460/// }
2461/// ```
2462///
2463/// [Reference](https://doc.rust-lang.org/reference/paths.html#paths-in-expressions)
2464#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2465pub struct LifetimeArg {
2466 pub(crate) syntax: SyntaxNode,
2467}
2468impl LifetimeArg {
2469 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
2470 support::token(&self.syntax, T![lifetime])
2471 }
2472}
2473/// Constant value argument that is passed at generic instantiation site.
2474///
2475/// ```
2476/// foo::<u32, ❰ { true } ❱>();
2477///
2478/// bar::<❰ { 2 + 2} ❱>();
2479/// ```
2480///
2481/// [RFC](https://github.com/rust-lang/rfcs/blob/master/text/2000-const-generics.md#declaring-a-const-parameter)
2482#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1258#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2483pub struct ConstArg { 1259pub struct ConstArg {
2484 pub(crate) syntax: SyntaxNode, 1260 pub(crate) syntax: SyntaxNode,
@@ -2487,136 +1263,24 @@ impl ConstArg {
2487 pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) } 1263 pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) }
2488 pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) } 1264 pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
2489} 1265}
2490/// FIXME: (@edwin0cheng) Remove it to use ItemList instead
2491/// https://github.com/rust-analyzer/rust-analyzer/pull/4083#discussion_r422666243
2492///
2493/// [Reference](https://doc.rust-lang.org/reference/macros.html)
2494#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2495pub struct MacroItems {
2496 pub(crate) syntax: SyntaxNode,
2497}
2498impl ast::ModuleItemOwner for MacroItems {}
2499impl MacroItems {}
2500/// FIXME: (@edwin0cheng) add some documentation here. As per the writing
2501/// of this comment this ast node is not used.
2502///
2503/// ```
2504/// // FIXME: example here
2505/// ```
2506///
2507/// [Reference](https://doc.rust-lang.org/reference/macros.html)
2508#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2509pub struct MacroStmts {
2510 pub(crate) syntax: SyntaxNode,
2511}
2512impl MacroStmts {
2513 pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) }
2514 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
2515}
2516/// List of items in an extern block.
2517///
2518/// ```
2519/// extern "C" ❰
2520/// {
2521/// fn foo();
2522/// static var: u32;
2523/// }
2524/// ❱
2525/// ```
2526///
2527/// [Reference](https://doc.rust-lang.org/reference/items/external-blocks.html)
2528#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2529pub struct ExternItemList {
2530 pub(crate) syntax: SyntaxNode,
2531}
2532impl ast::ModuleItemOwner for ExternItemList {}
2533impl ExternItemList {
2534 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
2535 pub fn extern_items(&self) -> AstChildren<ExternItem> { support::children(&self.syntax) }
2536 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
2537}
2538/// Extern block.
2539///
2540/// ```
2541/// ❰
2542/// extern "C" {
2543/// fn foo();
2544/// }
2545/// ❱
2546///
2547/// ```
2548///
2549/// [Reference](https://doc.rust-lang.org/reference/items/external-blocks.html)
2550#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2551pub struct ExternBlock {
2552 pub(crate) syntax: SyntaxNode,
2553}
2554impl ExternBlock {
2555 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
2556 pub fn extern_item_list(&self) -> Option<ExternItemList> { support::child(&self.syntax) }
2557}
2558/// Meta item in an attribute.
2559///
2560/// ```
2561/// #[❰ bar::baz = "42" ❱]
2562/// #[❰ bruh(bruuh("true")) ❱]
2563/// struct Foo;
2564/// ```
2565///
2566/// [Reference](https://doc.rust-lang.org/reference/attributes.html?highlight=meta,item#meta-item-attribute-syntax)
2567#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2568pub struct MetaItem {
2569 pub(crate) syntax: SyntaxNode,
2570}
2571impl MetaItem {
2572 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
2573 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
2574 pub fn attr_input(&self) -> Option<AttrInput> { support::child(&self.syntax) }
2575 pub fn nested_meta_items(&self) -> AstChildren<MetaItem> { support::children(&self.syntax) }
2576}
2577/// Macro 2.0 definition.
2578/// Their syntax is still WIP by rustc team...
2579/// ```
2580/// ❰
2581/// macro foo { }
2582/// ❱
2583/// ```
2584///
2585/// [RFC](https://github.com/rust-lang/rfcs/blob/master/text/1584-macros.md)
2586#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2587pub struct MacroDef {
2588 pub(crate) syntax: SyntaxNode,
2589}
2590impl MacroDef {
2591 pub fn name(&self) -> Option<Name> { support::child(&self.syntax) }
2592 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
2593}
2594/// Any kind of nominal type definition.