[[package]]
name = "ungrammar"
-version = "1.1.1"
+version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c4e20e58a08ee1bcf8a4695cf74550cf054d6c489105f594beacb2c684210aad"
+checksum = "bab6142ac77be714b1ea78faca6efaed5478c50724786b0fe80d8528d10692b3"
[[package]]
name = "unicode-bidi"
return None;
}
Some(Self::TraitMethod(
- sema.type_of_expr(&method_call.expr()?)?,
+ sema.type_of_expr(&method_call.receiver()?)?,
method_call.name_ref()?.syntax().to_string(),
))
}
if name.text() != "unwrap" {
return None;
}
- let caller = method_call.expr()?;
+ let caller = method_call.receiver()?;
let ty = ctx.sema.type_of_expr(&caller)?;
let happy_variant = TryEnum::from_ty(&ctx.sema, &ty)?.happy_case();
let target = method_call.syntax().text_range();
fn is_unsafe_method_call(&self, method_call_expr: &ast::MethodCallExpr) -> bool {
method_call_expr
- .expr()
+ .receiver()
.and_then(|expr| {
let field_expr = match expr {
ast::Expr::FieldExpr(field_expr) => field_expr,
self.alloc_expr(Expr::Call { callee, args }, syntax_ptr)
}
ast::Expr::MethodCallExpr(e) => {
- let receiver = self.collect_expr_opt(e.expr());
+ let receiver = self.collect_expr_opt(e.receiver());
let args = if let Some(arg_list) = e.arg_list() {
arg_list.args().map(|e| self.collect_expr(e)).collect()
} else {
if let Some(method_call_expr) = ast::MethodCallExpr::cast(parent) {
// As above
self.dot_receiver = method_call_expr
- .expr()
+ .receiver()
.map(|e| e.syntax().text_range())
.and_then(|r| find_node_with_range(original_file, r));
self.is_call = true;
hir::Access::Shared => (),
hir::Access::Exclusive => h |= HighlightModifier::Mutable,
hir::Access::Owned => {
- if let Some(receiver_ty) = method_call.expr().and_then(|it| sema.type_of_expr(&it))
+ if let Some(receiver_ty) =
+ method_call.receiver().and_then(|it| sema.type_of_expr(&it))
{
if !receiver_ty.is_copy(sema.db) {
h |= HighlightModifier::Consuming
// information on the placeholder match about autoderef and autoref. This allows us to use
// the placeholder in a context where autoderef and autoref don't apply.
if code_resolved_function.self_param(self.sema.db).is_some() {
- if let (Some(pattern_type), Some(expr)) = (&pattern_ufcs.qualifier_type, &code.expr()) {
+ if let (Some(pattern_type), Some(expr)) =
+ (&pattern_ufcs.qualifier_type, &code.receiver())
+ {
let deref_count = self.check_expr_type(pattern_type, expr)?;
let pattern_receiver = pattern_args.next();
- self.attempt_match_opt(phase, pattern_receiver.clone(), code.expr())?;
+ self.attempt_match_opt(phase, pattern_receiver.clone(), code.receiver())?;
if let Phase::Second(match_out) = phase {
if let Some(placeholder_value) = pattern_receiver
.and_then(|n| self.get_placeholder_for_node(n.syntax()))
}
}
} else {
- self.attempt_match_opt(phase, pattern_args.next(), code.expr())?;
+ self.attempt_match_opt(phase, pattern_args.next(), code.receiver())?;
}
let mut code_args =
code.arg_list().ok_or_else(|| match_error!("Code method call has no args"))?.args();
use crate::{resolving::ResolvedRule, Match, SsrMatches};
use itertools::Itertools;
use rustc_hash::{FxHashMap, FxHashSet};
-use syntax::ast::{self, AstToken};
+use syntax::ast::{self, AstNode, AstToken};
use syntax::{SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, TextRange, TextSize};
use test_utils::mark;
use text_edit::TextEdit;
}
fn render_node(&mut self, node: &SyntaxNode) {
- use syntax::ast::AstNode;
if let Some(mod_path) = self.match_info.rendered_template_paths.get(&node) {
self.out.push_str(&mod_path.to_string());
// Emit everything except for the segment's name-ref, since we already effectively
/// method call doesn't count. e.g. if the token is `$a`, then `$a.foo()` will return true, while
/// `($a + $b).foo()` or `x.foo($a)` will return false.
fn token_is_method_call_receiver(token: &SyntaxToken) -> bool {
- use syntax::ast::AstNode;
// Find the first method call among the ancestors of `token`, then check if the only token
// within the receiver is `token`.
if let Some(receiver) =
- token.ancestors().find_map(ast::MethodCallExpr::cast).and_then(|call| call.expr())
+ token.ancestors().find_map(ast::MethodCallExpr::cast).and_then(|call| call.receiver())
{
let tokens = receiver.syntax().descendants_with_tokens().filter_map(|node_or_token| {
match node_or_token {
}
fn parse_as_kind(code: &str, kind: SyntaxKind) -> Option<SyntaxNode> {
- use syntax::ast::AstNode;
if ast::Expr::can_cast(kind) {
if let Ok(expr) = ast::Expr::parse(code) {
return Some(expr.syntax().clone());
pub fn comma_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![,]) }
pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) }
pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
+ pub fn pipe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![|]) }
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct RetType {
impl ast::AttrsOwner for MethodCallExpr {}
impl ast::ArgListOwner for MethodCallExpr {}
impl MethodCallExpr {
- pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
+ pub fn receiver(&self) -> Option<Expr> { support::child(&self.syntax) }
pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) }
pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
pub fn generic_arg_list(&self) -> Option<GenericArgList> { support::child(&self.syntax) }
"#" => "pound",
"?" => "question_mark",
"," => "comma",
+ "|" => "pipe",
_ => name,
};
format_ident!("{}_token", name)