From b23bebebc0a5dd974b42c45eaac224bc420da4e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Tue, 16 Nov 2021 19:59:36 +0200 Subject: [PATCH] Remove validation of `super` in use paths --- crates/syntax/src/validation.rs | 39 ---------- ...> 0041_illegal_self_keyword_location.rast} | 0 ... => 0041_illegal_self_keyword_location.rs} | 0 .../0041_illegal_super_keyword_location.rast | 75 ------------------- .../0041_illegal_super_keyword_location.rs | 4 - ...ird_blocks.rast => 0042_weird_blocks.rast} | 0 ...3_weird_blocks.rs => 0042_weird_blocks.rs} | 0 ...ype.rast => 0043_unexpected_for_type.rast} | 0 ...or_type.rs => 0043_unexpected_for_type.rs} | 0 ...odifiers.rast => 0044_item_modifiers.rast} | 0 ...em_modifiers.rs => 0044_item_modifiers.rs} | 0 ....rast => 0045_ambiguous_trait_object.rast} | 0 ...ject.rs => 0045_ambiguous_trait_object.rs} | 0 ...item.rast => 0046_mutable_const_item.rast} | 0 ...nst_item.rs => 0046_mutable_const_item.rs} | 0 ...rast => 0047_repated_extern_modifier.rast} | 0 ...ier.rs => 0047_repated_extern_modifier.rs} | 0 ...double_fish.rast => 0048_double_fish.rast} | 0 ...049_double_fish.rs => 0048_double_fish.rs} | 0 19 files changed, 118 deletions(-) rename crates/syntax/test_data/parser/err/{0042_illegal_self_keyword_location.rast => 0041_illegal_self_keyword_location.rast} (100%) rename crates/syntax/test_data/parser/err/{0042_illegal_self_keyword_location.rs => 0041_illegal_self_keyword_location.rs} (100%) delete mode 100644 crates/syntax/test_data/parser/err/0041_illegal_super_keyword_location.rast delete mode 100644 crates/syntax/test_data/parser/err/0041_illegal_super_keyword_location.rs rename crates/syntax/test_data/parser/err/{0043_weird_blocks.rast => 0042_weird_blocks.rast} (100%) rename crates/syntax/test_data/parser/err/{0043_weird_blocks.rs => 0042_weird_blocks.rs} (100%) rename crates/syntax/test_data/parser/err/{0044_unexpected_for_type.rast => 0043_unexpected_for_type.rast} (100%) rename crates/syntax/test_data/parser/err/{0044_unexpected_for_type.rs => 0043_unexpected_for_type.rs} (100%) rename crates/syntax/test_data/parser/err/{0045_item_modifiers.rast => 0044_item_modifiers.rast} (100%) rename crates/syntax/test_data/parser/err/{0045_item_modifiers.rs => 0044_item_modifiers.rs} (100%) rename crates/syntax/test_data/parser/err/{0046_ambiguous_trait_object.rast => 0045_ambiguous_trait_object.rast} (100%) rename crates/syntax/test_data/parser/err/{0046_ambiguous_trait_object.rs => 0045_ambiguous_trait_object.rs} (100%) rename crates/syntax/test_data/parser/err/{0047_mutable_const_item.rast => 0046_mutable_const_item.rast} (100%) rename crates/syntax/test_data/parser/err/{0047_mutable_const_item.rs => 0046_mutable_const_item.rs} (100%) rename crates/syntax/test_data/parser/err/{0048_repated_extern_modifier.rast => 0047_repated_extern_modifier.rast} (100%) rename crates/syntax/test_data/parser/err/{0048_repated_extern_modifier.rs => 0047_repated_extern_modifier.rs} (100%) rename crates/syntax/test_data/parser/err/{0049_double_fish.rast => 0048_double_fish.rast} (100%) rename crates/syntax/test_data/parser/err/{0049_double_fish.rs => 0048_double_fish.rs} (100%) diff --git a/crates/syntax/src/validation.rs b/crates/syntax/src/validation.rs index af5e1739000..a0a0bab5b37 100644 --- a/crates/syntax/src/validation.rs +++ b/crates/syntax/src/validation.rs @@ -245,8 +245,6 @@ fn validate_range_expr(expr: ast::RangeExpr, errors: &mut Vec) { } fn validate_path_keywords(segment: ast::PathSegment, errors: &mut Vec) { - use ast::PathSegmentKind; - let path = segment.parent_path(); let is_path_start = segment.coloncolon_token().is_none() && path.qualifier().is_none(); @@ -264,26 +262,6 @@ fn validate_path_keywords(segment: ast::PathSegment, errors: &mut Vec Option { @@ -305,23 +283,6 @@ fn validate_path_keywords(segment: ast::PathSegment, errors: &mut Vec bool { - let segment = match path.segment() { - Some(it) => it, - None => return false, - }; - - if segment.kind() != Some(PathSegmentKind::SuperKw) { - return false; - } - - if let Some(ref subpath) = path.qualifier() { - return all_supers(subpath); - } - - true - } } fn validate_trait_object_ref_ty(ty: ast::RefType, errors: &mut Vec) { diff --git a/crates/syntax/test_data/parser/err/0042_illegal_self_keyword_location.rast b/crates/syntax/test_data/parser/err/0041_illegal_self_keyword_location.rast similarity index 100% rename from crates/syntax/test_data/parser/err/0042_illegal_self_keyword_location.rast rename to crates/syntax/test_data/parser/err/0041_illegal_self_keyword_location.rast diff --git a/crates/syntax/test_data/parser/err/0042_illegal_self_keyword_location.rs b/crates/syntax/test_data/parser/err/0041_illegal_self_keyword_location.rs similarity index 100% rename from crates/syntax/test_data/parser/err/0042_illegal_self_keyword_location.rs rename to crates/syntax/test_data/parser/err/0041_illegal_self_keyword_location.rs diff --git a/crates/syntax/test_data/parser/err/0041_illegal_super_keyword_location.rast b/crates/syntax/test_data/parser/err/0041_illegal_super_keyword_location.rast deleted file mode 100644 index 271f8d78038..00000000000 --- a/crates/syntax/test_data/parser/err/0041_illegal_super_keyword_location.rast +++ /dev/null @@ -1,75 +0,0 @@ -SOURCE_FILE@0..67 - USE@0..12 - USE_KW@0..3 "use" - WHITESPACE@3..4 " " - USE_TREE@4..11 - PATH@4..11 - PATH_SEGMENT@4..11 - COLON2@4..6 "::" - NAME_REF@6..11 - SUPER_KW@6..11 "super" - SEMICOLON@11..12 ";" - WHITESPACE@12..13 "\n" - USE@13..26 - USE_KW@13..16 "use" - WHITESPACE@16..17 " " - USE_TREE@17..25 - PATH@17..25 - PATH@17..18 - PATH_SEGMENT@17..18 - NAME_REF@17..18 - IDENT@17..18 "a" - COLON2@18..20 "::" - PATH_SEGMENT@20..25 - NAME_REF@20..25 - SUPER_KW@20..25 "super" - SEMICOLON@25..26 ";" - WHITESPACE@26..27 "\n" - USE@27..47 - USE_KW@27..30 "use" - WHITESPACE@30..31 " " - USE_TREE@31..46 - PATH@31..46 - PATH@31..39 - PATH@31..36 - PATH_SEGMENT@31..36 - NAME_REF@31..36 - SUPER_KW@31..36 "super" - COLON2@36..38 "::" - PATH_SEGMENT@38..39 - NAME_REF@38..39 - IDENT@38..39 "a" - COLON2@39..41 "::" - PATH_SEGMENT@41..46 - NAME_REF@41..46 - SUPER_KW@41..46 "super" - SEMICOLON@46..47 ";" - WHITESPACE@47..48 "\n" - USE@48..66 - USE_KW@48..51 "use" - WHITESPACE@51..52 " " - USE_TREE@52..65 - PATH@52..53 - PATH_SEGMENT@52..53 - NAME_REF@52..53 - IDENT@52..53 "a" - COLON2@53..55 "::" - USE_TREE_LIST@55..65 - L_CURLY@55..56 "{" - USE_TREE@56..64 - PATH@56..64 - PATH@56..61 - PATH_SEGMENT@56..61 - NAME_REF@56..61 - SUPER_KW@56..61 "super" - COLON2@61..63 "::" - PATH_SEGMENT@63..64 - NAME_REF@63..64 - IDENT@63..64 "b" - R_CURLY@64..65 "}" - SEMICOLON@65..66 ";" - WHITESPACE@66..67 "\n" -error 6..11: The `super` keyword may only be preceded by other `super`s -error 20..25: The `super` keyword may only be preceded by other `super`s -error 41..46: The `super` keyword may only be preceded by other `super`s -error 56..61: The `super` keyword may only be preceded by other `super`s diff --git a/crates/syntax/test_data/parser/err/0041_illegal_super_keyword_location.rs b/crates/syntax/test_data/parser/err/0041_illegal_super_keyword_location.rs deleted file mode 100644 index bd4d5804263..00000000000 --- a/crates/syntax/test_data/parser/err/0041_illegal_super_keyword_location.rs +++ /dev/null @@ -1,4 +0,0 @@ -use ::super; -use a::super; -use super::a::super; -use a::{super::b}; diff --git a/crates/syntax/test_data/parser/err/0043_weird_blocks.rast b/crates/syntax/test_data/parser/err/0042_weird_blocks.rast similarity index 100% rename from crates/syntax/test_data/parser/err/0043_weird_blocks.rast rename to crates/syntax/test_data/parser/err/0042_weird_blocks.rast diff --git a/crates/syntax/test_data/parser/err/0043_weird_blocks.rs b/crates/syntax/test_data/parser/err/0042_weird_blocks.rs similarity index 100% rename from crates/syntax/test_data/parser/err/0043_weird_blocks.rs rename to crates/syntax/test_data/parser/err/0042_weird_blocks.rs diff --git a/crates/syntax/test_data/parser/err/0044_unexpected_for_type.rast b/crates/syntax/test_data/parser/err/0043_unexpected_for_type.rast similarity index 100% rename from crates/syntax/test_data/parser/err/0044_unexpected_for_type.rast rename to crates/syntax/test_data/parser/err/0043_unexpected_for_type.rast diff --git a/crates/syntax/test_data/parser/err/0044_unexpected_for_type.rs b/crates/syntax/test_data/parser/err/0043_unexpected_for_type.rs similarity index 100% rename from crates/syntax/test_data/parser/err/0044_unexpected_for_type.rs rename to crates/syntax/test_data/parser/err/0043_unexpected_for_type.rs diff --git a/crates/syntax/test_data/parser/err/0045_item_modifiers.rast b/crates/syntax/test_data/parser/err/0044_item_modifiers.rast similarity index 100% rename from crates/syntax/test_data/parser/err/0045_item_modifiers.rast rename to crates/syntax/test_data/parser/err/0044_item_modifiers.rast diff --git a/crates/syntax/test_data/parser/err/0045_item_modifiers.rs b/crates/syntax/test_data/parser/err/0044_item_modifiers.rs similarity index 100% rename from crates/syntax/test_data/parser/err/0045_item_modifiers.rs rename to crates/syntax/test_data/parser/err/0044_item_modifiers.rs diff --git a/crates/syntax/test_data/parser/err/0046_ambiguous_trait_object.rast b/crates/syntax/test_data/parser/err/0045_ambiguous_trait_object.rast similarity index 100% rename from crates/syntax/test_data/parser/err/0046_ambiguous_trait_object.rast rename to crates/syntax/test_data/parser/err/0045_ambiguous_trait_object.rast diff --git a/crates/syntax/test_data/parser/err/0046_ambiguous_trait_object.rs b/crates/syntax/test_data/parser/err/0045_ambiguous_trait_object.rs similarity index 100% rename from crates/syntax/test_data/parser/err/0046_ambiguous_trait_object.rs rename to crates/syntax/test_data/parser/err/0045_ambiguous_trait_object.rs diff --git a/crates/syntax/test_data/parser/err/0047_mutable_const_item.rast b/crates/syntax/test_data/parser/err/0046_mutable_const_item.rast similarity index 100% rename from crates/syntax/test_data/parser/err/0047_mutable_const_item.rast rename to crates/syntax/test_data/parser/err/0046_mutable_const_item.rast diff --git a/crates/syntax/test_data/parser/err/0047_mutable_const_item.rs b/crates/syntax/test_data/parser/err/0046_mutable_const_item.rs similarity index 100% rename from crates/syntax/test_data/parser/err/0047_mutable_const_item.rs rename to crates/syntax/test_data/parser/err/0046_mutable_const_item.rs diff --git a/crates/syntax/test_data/parser/err/0048_repated_extern_modifier.rast b/crates/syntax/test_data/parser/err/0047_repated_extern_modifier.rast similarity index 100% rename from crates/syntax/test_data/parser/err/0048_repated_extern_modifier.rast rename to crates/syntax/test_data/parser/err/0047_repated_extern_modifier.rast diff --git a/crates/syntax/test_data/parser/err/0048_repated_extern_modifier.rs b/crates/syntax/test_data/parser/err/0047_repated_extern_modifier.rs similarity index 100% rename from crates/syntax/test_data/parser/err/0048_repated_extern_modifier.rs rename to crates/syntax/test_data/parser/err/0047_repated_extern_modifier.rs diff --git a/crates/syntax/test_data/parser/err/0049_double_fish.rast b/crates/syntax/test_data/parser/err/0048_double_fish.rast similarity index 100% rename from crates/syntax/test_data/parser/err/0049_double_fish.rast rename to crates/syntax/test_data/parser/err/0048_double_fish.rast diff --git a/crates/syntax/test_data/parser/err/0049_double_fish.rs b/crates/syntax/test_data/parser/err/0048_double_fish.rs similarity index 100% rename from crates/syntax/test_data/parser/err/0049_double_fish.rs rename to crates/syntax/test_data/parser/err/0048_double_fish.rs