Auto merge of #15287 - lowr:internal/remove-crate-vis, r=lnicola

internal: remove `crate` visibility modifier

This PR removes `crate` as a now-unaccepted experimental visibility modifier from our parser. This feature has been [unaccepted] and [removed] from rustc more than a year ago, so I don't think this removal affects anyone.

[unaccepted]: https://github.com/rust-lang/rust/issues/53120#issuecomment-1124065083
[removed]: https://github.com/rust-lang/rust/pull/97239
This commit is contained in:
bors 2023-07-18 14:03:32 +00:00
commit 3759c41d3c
6 changed files with 40 additions and 157 deletions

View file

@ -211,8 +211,10 @@ impl BlockLike {
const VISIBILITY_FIRST: TokenSet = TokenSet::new(&[T![pub], T![crate]]);
fn opt_visibility(p: &mut Parser<'_>, in_tuple_field: bool) -> bool {
match p.current() {
T![pub] => {
if !p.at(T![pub]) {
return false;
}
let m = p.start();
p.bump(T![pub]);
if p.at(T!['(']) {
@ -258,24 +260,6 @@ fn opt_visibility(p: &mut Parser<'_>, in_tuple_field: bool) -> bool {
m.complete(p, VISIBILITY);
true
}
// test crate_keyword_vis
// crate fn main() { }
// struct S { crate field: u32 }
// struct T(crate u32);
T![crate] => {
if p.nth_at(1, T![::]) {
// test crate_keyword_path
// fn foo() { crate::foo(); }
return false;
}
let m = p.start();
p.bump(T![crate]);
m.complete(p, VISIBILITY);
true
}
_ => false,
}
}
fn opt_rename(p: &mut Parser<'_>) {
if p.at(T![as]) {

View file

@ -6,7 +6,6 @@ fn vis() {
check(PrefixEntryPoint::Vis, "fn foo() {}", "");
check(PrefixEntryPoint::Vis, "pub(fn foo() {}", "pub");
check(PrefixEntryPoint::Vis, "pub(crate fn foo() {}", "pub(crate");
check(PrefixEntryPoint::Vis, "crate fn foo() {}", "crate");
}
#[test]

View file

@ -1,63 +0,0 @@
SOURCE_FILE
FN
VISIBILITY
CRATE_KW "crate"
WHITESPACE " "
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "main"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE " "
R_CURLY "}"
WHITESPACE "\n"
STRUCT
STRUCT_KW "struct"
WHITESPACE " "
NAME
IDENT "S"
WHITESPACE " "
RECORD_FIELD_LIST
L_CURLY "{"
WHITESPACE " "
RECORD_FIELD
VISIBILITY
CRATE_KW "crate"
WHITESPACE " "
NAME
IDENT "field"
COLON ":"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "u32"
WHITESPACE " "
R_CURLY "}"
WHITESPACE "\n"
STRUCT
STRUCT_KW "struct"
WHITESPACE " "
NAME
IDENT "T"
TUPLE_FIELD_LIST
L_PAREN "("
TUPLE_FIELD
VISIBILITY
CRATE_KW "crate"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "u32"
R_PAREN ")"
SEMICOLON ";"
WHITESPACE "\n"

View file

@ -1,3 +0,0 @@
crate fn main() { }
struct S { crate field: u32 }
struct T(crate u32);

View file

@ -1,33 +0,0 @@
SOURCE_FILE
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "foo"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE " "
EXPR_STMT
CALL_EXPR
PATH_EXPR
PATH
PATH
PATH_SEGMENT
NAME_REF
CRATE_KW "crate"
COLON2 "::"
PATH_SEGMENT
NAME_REF
IDENT "foo"
ARG_LIST
L_PAREN "("
R_PAREN ")"
SEMICOLON ";"
WHITESPACE " "
R_CURLY "}"
WHITESPACE "\n"

View file

@ -1 +0,0 @@
fn foo() { crate::foo(); }