about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-11-16 18:18:47 +0000
committerGitHub <noreply@github.com>2021-11-16 18:18:47 +0000
commit9f1e26c3f9804eaaf2941feaa140d6f8c6d8c562 (patch)
tree0cabca3e7bc0c0e5a0c340bca143474118b07bcb
parent35ed853d84aa3e36a7d8aea4edc30a6566fe47ae (diff)
parentb23bebebc0a5dd974b42c45eaac224bc420da4e2 (diff)
downloadrust-9f1e26c3f9804eaaf2941feaa140d6f8c6d8c562.tar.gz
rust-9f1e26c3f9804eaaf2941feaa140d6f8c6d8c562.zip
Merge #10776
10776: fix: Remove validation of `super` in use paths r=Veykril a=lnicola

Fixes #10770

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
-rw-r--r--crates/syntax/src/validation.rs39
-rw-r--r--crates/syntax/test_data/parser/err/0041_illegal_self_keyword_location.rast (renamed from crates/syntax/test_data/parser/err/0042_illegal_self_keyword_location.rast)0
-rw-r--r--crates/syntax/test_data/parser/err/0041_illegal_self_keyword_location.rs (renamed from crates/syntax/test_data/parser/err/0042_illegal_self_keyword_location.rs)0
-rw-r--r--crates/syntax/test_data/parser/err/0041_illegal_super_keyword_location.rast75
-rw-r--r--crates/syntax/test_data/parser/err/0041_illegal_super_keyword_location.rs4
-rw-r--r--crates/syntax/test_data/parser/err/0042_weird_blocks.rast (renamed from crates/syntax/test_data/parser/err/0043_weird_blocks.rast)0
-rw-r--r--crates/syntax/test_data/parser/err/0042_weird_blocks.rs (renamed from crates/syntax/test_data/parser/err/0043_weird_blocks.rs)0
-rw-r--r--crates/syntax/test_data/parser/err/0043_unexpected_for_type.rast (renamed from crates/syntax/test_data/parser/err/0044_unexpected_for_type.rast)0
-rw-r--r--crates/syntax/test_data/parser/err/0043_unexpected_for_type.rs (renamed from crates/syntax/test_data/parser/err/0044_unexpected_for_type.rs)0
-rw-r--r--crates/syntax/test_data/parser/err/0044_item_modifiers.rast (renamed from crates/syntax/test_data/parser/err/0045_item_modifiers.rast)0
-rw-r--r--crates/syntax/test_data/parser/err/0044_item_modifiers.rs (renamed from crates/syntax/test_data/parser/err/0045_item_modifiers.rs)0
-rw-r--r--crates/syntax/test_data/parser/err/0045_ambiguous_trait_object.rast (renamed from crates/syntax/test_data/parser/err/0046_ambiguous_trait_object.rast)0
-rw-r--r--crates/syntax/test_data/parser/err/0045_ambiguous_trait_object.rs (renamed from crates/syntax/test_data/parser/err/0046_ambiguous_trait_object.rs)0
-rw-r--r--crates/syntax/test_data/parser/err/0046_mutable_const_item.rast (renamed from crates/syntax/test_data/parser/err/0047_mutable_const_item.rast)0
-rw-r--r--crates/syntax/test_data/parser/err/0046_mutable_const_item.rs (renamed from crates/syntax/test_data/parser/err/0047_mutable_const_item.rs)0
-rw-r--r--crates/syntax/test_data/parser/err/0047_repated_extern_modifier.rast (renamed from crates/syntax/test_data/parser/err/0048_repated_extern_modifier.rast)0
-rw-r--r--crates/syntax/test_data/parser/err/0047_repated_extern_modifier.rs (renamed from crates/syntax/test_data/parser/err/0048_repated_extern_modifier.rs)0
-rw-r--r--crates/syntax/test_data/parser/err/0048_double_fish.rast (renamed from crates/syntax/test_data/parser/err/0049_double_fish.rast)0
-rw-r--r--crates/syntax/test_data/parser/err/0048_double_fish.rs (renamed from crates/syntax/test_data/parser/err/0049_double_fish.rs)0
19 files changed, 0 insertions, 118 deletions
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<SyntaxError>) {
 }
 
 fn validate_path_keywords(segment: ast::PathSegment, errors: &mut Vec<SyntaxError>) {
-    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<SyntaxErro
                 token.text_range(),
             ));
         }
-    } else if let Some(token) = segment.super_token() {
-        if segment.coloncolon_token().is_some() || !all_supers(&path) {
-            errors.push(SyntaxError::new(
-                "The `super` keyword may only be preceded by other `super`s",
-                token.text_range(),
-            ));
-            return;
-        }
-
-        let mut curr_path = path;
-        while let Some(prefix) = use_prefix(curr_path) {
-            if !all_supers(&prefix) {
-                errors.push(SyntaxError::new(
-                    "The `super` keyword may only be preceded by other `super`s",
-                    token.text_range(),
-                ));
-                return;
-            }
-            curr_path = prefix;
-        }
     }
 
     fn use_prefix(mut path: ast::Path) -> Option<ast::Path> {
@@ -305,23 +283,6 @@ fn validate_path_keywords(segment: ast::PathSegment, errors: &mut Vec<SyntaxErro
         }
         None
     }
-
-    fn all_supers(path: &ast::Path) -> 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<SyntaxError>) {
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
index 01f60109144..01f60109144 100644
--- 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
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
index b9e1d7d8be2..b9e1d7d8be2 100644
--- 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
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
index 25910cb4052..25910cb4052 100644
--- a/crates/syntax/test_data/parser/err/0043_weird_blocks.rast
+++ b/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
index 8fa324c1a14..8fa324c1a14 100644
--- a/crates/syntax/test_data/parser/err/0043_weird_blocks.rs
+++ b/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
index d4e4bf102ed..d4e4bf102ed 100644
--- a/crates/syntax/test_data/parser/err/0044_unexpected_for_type.rast
+++ b/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
index 0e9f8ccb4f8..0e9f8ccb4f8 100644
--- a/crates/syntax/test_data/parser/err/0044_unexpected_for_type.rs
+++ b/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
index b4ff1a14a7c..b4ff1a14a7c 100644
--- a/crates/syntax/test_data/parser/err/0045_item_modifiers.rast
+++ b/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
index 731e58013bd..731e58013bd 100644
--- a/crates/syntax/test_data/parser/err/0045_item_modifiers.rs
+++ b/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
index d94daacdc1d..d94daacdc1d 100644
--- a/crates/syntax/test_data/parser/err/0046_ambiguous_trait_object.rast
+++ b/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
index 3a73d81bb5d..3a73d81bb5d 100644
--- a/crates/syntax/test_data/parser/err/0046_ambiguous_trait_object.rs
+++ b/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
index c7eb312c92c..c7eb312c92c 100644
--- a/crates/syntax/test_data/parser/err/0047_mutable_const_item.rast
+++ b/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
index b34336f3f15..b34336f3f15 100644
--- a/crates/syntax/test_data/parser/err/0047_mutable_const_item.rs
+++ b/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
index 85e10ca36db..85e10ca36db 100644
--- a/crates/syntax/test_data/parser/err/0048_repated_extern_modifier.rast
+++ b/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
index 1fb18eaf1bc..1fb18eaf1bc 100644
--- a/crates/syntax/test_data/parser/err/0048_repated_extern_modifier.rs
+++ b/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
index ca52166fbc4..ca52166fbc4 100644
--- a/crates/syntax/test_data/parser/err/0049_double_fish.rast
+++ b/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
index 31c12bfff9f..31c12bfff9f 100644
--- a/crates/syntax/test_data/parser/err/0049_double_fish.rs
+++ b/crates/syntax/test_data/parser/err/0048_double_fish.rs