@@ -1910,7 +1910,7 @@ impl Expr<'_> {
1910
1910
1911
1911
pub fn method_ident ( & self ) -> Option < Ident > {
1912
1912
match self . kind {
1913
- ExprKind :: MethodCall ( receiver_method, ..) => Some ( receiver_method. ident ) ,
1913
+ ExprKind :: MethodCall ( receiver_method, ..) => Some ( receiver_method. ident ( ) ) ,
1914
1914
ExprKind :: Unary ( _, expr) | ExprKind :: AddrOf ( .., expr) => expr. method_ident ( ) ,
1915
1915
_ => None ,
1916
1916
}
@@ -1943,6 +1943,48 @@ pub fn is_range_literal(expr: &Expr<'_>) -> bool {
1943
1943
}
1944
1944
}
1945
1945
1946
+ #[ derive( Debug , Clone , Copy , HashStable_Generic ) ]
1947
+ pub enum MethodCallPath < ' hir > {
1948
+ Segment ( & ' hir PathSegment < ' hir > ) ,
1949
+ // Used in the `.await` desugaring.
1950
+ AwaitIntoFuture ( Span ) ,
1951
+ }
1952
+
1953
+ impl < ' hir > MethodCallPath < ' hir > {
1954
+ #[ inline]
1955
+ pub fn ident ( self ) -> Ident {
1956
+ match self {
1957
+ MethodCallPath :: Segment ( segment) => segment. ident ,
1958
+ MethodCallPath :: AwaitIntoFuture ( span) => Ident :: new ( sym:: into_future, span) ,
1959
+ }
1960
+ }
1961
+
1962
+ #[ inline]
1963
+ pub fn span ( self ) -> Span {
1964
+ match self {
1965
+ MethodCallPath :: Segment ( segment) => segment. ident . span ,
1966
+ MethodCallPath :: AwaitIntoFuture ( span) => span,
1967
+ }
1968
+ }
1969
+
1970
+ #[ inline]
1971
+ pub fn opt_args < ' a > ( self ) -> Option < & ' a GenericArgs < ' hir > > {
1972
+ match self {
1973
+ MethodCallPath :: Segment ( segment) => segment. args ,
1974
+ MethodCallPath :: AwaitIntoFuture ( _) => None ,
1975
+ }
1976
+ }
1977
+
1978
+ #[ inline]
1979
+ pub fn args < ' a > ( self ) -> & ' a GenericArgs < ' hir > {
1980
+ const EMPTY : GenericArgs < ' _ > = GenericArgs :: none ( ) ;
1981
+ match self {
1982
+ MethodCallPath :: Segment ( segment) => segment. args ( ) ,
1983
+ MethodCallPath :: AwaitIntoFuture ( _) => & EMPTY ,
1984
+ }
1985
+ }
1986
+ }
1987
+
1946
1988
#[ derive( Debug , Clone , Copy , HashStable_Generic ) ]
1947
1989
pub enum ExprKind < ' hir > {
1948
1990
/// Allow anonymous constants from an inline `const` block
@@ -1958,8 +2000,13 @@ pub enum ExprKind<'hir> {
1958
2000
Call ( & ' hir Expr < ' hir > , & ' hir [ Expr < ' hir > ] ) ,
1959
2001
/// A method call (e.g., `x.foo::<'static, Bar, Baz>(a, b, c, d)`).
1960
2002
///
1961
- /// The `PathSegment` represents the method name and its generic arguments
1962
- /// (within the angle brackets).
2003
+ /// The [`MethodCallPath`] is either:
2004
+ ///
2005
+ /// - a [`PathSegment`] that represents the method name and its generic arguments
2006
+ /// (within the angle brackets), or
2007
+ /// - `IntoFutureFn` that represents a call to `IntoFuture::into_future()`
2008
+ /// from the `.await` desugaring.
2009
+ ///
1963
2010
/// The `&Expr` is the expression that evaluates
1964
2011
/// to the object on which the method is being called on (the receiver),
1965
2012
/// and the `&[Expr]` is the rest of the arguments.
@@ -1972,7 +2019,7 @@ pub enum ExprKind<'hir> {
1972
2019
/// the `hir_id` of the `MethodCall` node itself.
1973
2020
///
1974
2021
/// [`type_dependent_def_id`]: ../../rustc_middle/ty/struct.TypeckResults.html#method.type_dependent_def_id
1975
- MethodCall ( & ' hir PathSegment < ' hir > , & ' hir Expr < ' hir > , & ' hir [ Expr < ' hir > ] , Span ) ,
2022
+ MethodCall ( MethodCallPath < ' hir > , & ' hir Expr < ' hir > , & ' hir [ Expr < ' hir > ] , Span ) ,
1976
2023
/// A tuple (e.g., `(a, b, c, d)`).
1977
2024
Tup ( & ' hir [ Expr < ' hir > ] ) ,
1978
2025
/// A binary operation (e.g., `a + b`, `a * b`).
0 commit comments