mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
Merge commit '9b3d03408c
' into sync-from-ra
This commit is contained in:
parent
883f16d805
commit
30d8aa1bec
136 changed files with 3865 additions and 1451 deletions
|
@ -709,7 +709,7 @@ impl ConstParam {
|
|||
pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
|
||||
pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
|
||||
pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
|
||||
pub fn default_val(&self) -> Option<Expr> { support::child(&self.syntax) }
|
||||
pub fn default_val(&self) -> Option<ConstArg> { support::child(&self.syntax) }
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
|
|
|
@ -503,11 +503,16 @@ pub fn hacky_block_expr(
|
|||
pub fn expr_unit() -> ast::Expr {
|
||||
expr_from_text("()")
|
||||
}
|
||||
|
||||
pub fn expr_literal(text: &str) -> ast::Literal {
|
||||
assert_eq!(text.trim(), text);
|
||||
ast_from_text(&format!("fn f() {{ let _ = {text}; }}"))
|
||||
}
|
||||
|
||||
pub fn expr_const_value(text: &str) -> ast::ConstArg {
|
||||
ast_from_text(&format!("trait Foo<const N: usize = {text}> {{}}"))
|
||||
}
|
||||
|
||||
pub fn expr_empty_block() -> ast::Expr {
|
||||
expr_from_text("{}")
|
||||
}
|
||||
|
@ -1100,7 +1105,7 @@ pub mod tokens {
|
|||
|
||||
pub(super) static SOURCE_FILE: Lazy<Parse<SourceFile>> = Lazy::new(|| {
|
||||
SourceFile::parse(
|
||||
"const C: <()>::Item = (1 != 1, 2 == 2, 3 < 3, 4 <= 4, 5 > 5, 6 >= 6, !true, *p, &p , &mut p)\n;\n\n",
|
||||
"const C: <()>::Item = ( true && true , true || true , 1 != 1, 2 == 2, 3 < 3, 4 <= 4, 5 > 5, 6 >= 6, !true, *p, &p , &mut p)\n;\n\n",
|
||||
)
|
||||
});
|
||||
|
||||
|
|
|
@ -61,6 +61,14 @@ impl ast::BlockExpr {
|
|||
pub fn tail_expr(&self) -> Option<ast::Expr> {
|
||||
self.stmt_list()?.tail_expr()
|
||||
}
|
||||
/// Block expressions accept outer and inner attributes, but only when they are the outer
|
||||
/// expression of an expression statement or the final expression of another block expression.
|
||||
pub fn may_carry_attributes(&self) -> bool {
|
||||
matches!(
|
||||
self.syntax().parent().map(|it| it.kind()),
|
||||
Some(SyntaxKind::BLOCK_EXPR | SyntaxKind::EXPR_STMT)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue