Merge commit '9d8889cdfc' into sync-from-ra

This commit is contained in:
Laurențiu Nicola 2024-01-15 11:40:09 +02:00
parent 3afeb24198
commit 6bbd106c70
104 changed files with 1652 additions and 1026 deletions

View file

@ -13,8 +13,7 @@ doctest = false
[dependencies]
drop_bomb = "0.1.5"
rustc-dependencies.workspace = true
ra-ap-rustc_lexer.workspace = true
limit.workspace = true
[dev-dependencies]
@ -24,7 +23,7 @@ stdx.workspace = true
sourcegen.workspace = true
[features]
in-rust-tree = ["rustc-dependencies/in-rust-tree"]
in-rust-tree = []
[lints]
workspace = true
workspace = true

View file

@ -371,7 +371,15 @@ fn lhs(p: &mut Parser<'_>, r: Restrictions) -> Option<(CompletedMarker, BlockLik
if p.at(op) {
m = p.start();
p.bump(op);
if p.at_ts(EXPR_FIRST) && !(r.forbid_structs && p.at(T!['{'])) {
// test closure_range_method_call
// fn foo() {
// || .. .method();
// || .. .field;
// }
let has_access_after = p.at(T![.]) && p.nth_at(1, SyntaxKind::IDENT);
let struct_forbidden = r.forbid_structs && p.at(T!['{']);
if p.at_ts(EXPR_FIRST) && !has_access_after && !struct_forbidden {
expr_bp(p, None, r, 2);
}
let cm = m.complete(p, RANGE_EXPR);

View file

@ -8,8 +8,6 @@
//! Note that these tokens, unlike the tokens we feed into the parser, do
//! include info about comments and whitespace.
use rustc_dependencies::lexer as rustc_lexer;
use std::ops;
use rustc_lexer::unescape::{EscapeError, Mode};

View file

@ -21,6 +21,11 @@
#![allow(rustdoc::private_intra_doc_links)]
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
#[cfg(not(feature = "in-rust-tree"))]
extern crate ra_ap_rustc_lexer as rustc_lexer;
#[cfg(feature = "in-rust-tree")]
extern crate rustc_lexer;
mod lexed_str;
mod token_set;
mod syntax_kind;

View file

@ -0,0 +1,49 @@
SOURCE_FILE
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "foo"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n "
EXPR_STMT
METHOD_CALL_EXPR
CLOSURE_EXPR
PARAM_LIST
PIPE "|"
PIPE "|"
WHITESPACE " "
RANGE_EXPR
DOT2 ".."
WHITESPACE " "
DOT "."
NAME_REF
IDENT "method"
ARG_LIST
L_PAREN "("
R_PAREN ")"
SEMICOLON ";"
WHITESPACE "\n "
EXPR_STMT
FIELD_EXPR
CLOSURE_EXPR
PARAM_LIST
PIPE "|"
PIPE "|"
WHITESPACE " "
RANGE_EXPR
DOT2 ".."
WHITESPACE " "
DOT "."
NAME_REF
IDENT "field"
SEMICOLON ";"
WHITESPACE "\n"
R_CURLY "}"
WHITESPACE "\n"

View file

@ -0,0 +1,4 @@
fn foo() {
|| .. .method();
|| .. .field;
}